개정판 3b484ebb
issue #000: Temp 관련 기능 TempFile Class로 이동 및 수정
Change-Id: If6157c1c9ae87400128ed1d69e24afa60f4dd7bb
KCOM/Common/TempFile.cs | ||
---|---|---|
21 | 21 |
using System.Text; |
22 | 22 |
using System.Windows; |
23 | 23 |
using System.Windows.Media; |
24 |
using System.Windows.Threading; |
|
24 | 25 |
using System.Xml; |
25 | 26 |
using System.Xml.Serialization; |
26 | 27 |
|
... | ... | |
32 | 33 |
public static string PathString = Path.GetTempPath() + "\\MARKUS"; |
33 | 34 |
public static string FilePath = PathString + "\\" + App.ViewInfo.DocumentItemID + ".tmp"; |
34 | 35 |
|
35 |
internal static void WriteTemp(List<MainMenu.TempDt> tempDtList)
|
|
36 |
internal static void WriteTemp(List<TempDt> tempDtList) |
|
36 | 37 |
{ |
37 | 38 |
if (tempDtList.Count > 0) |
38 | 39 |
{ |
... | ... | |
292 | 293 |
xmlDoc.Save(FilePath); |
293 | 294 |
xmlDoc = null; |
294 | 295 |
} |
295 |
} |
|
296 |
|
|
297 |
public class TempLoadData |
|
298 |
{ |
|
299 |
public int PageNumber { get; set; } |
|
300 |
public string CommentID { get; set; } |
|
301 |
public string ConvertData { get; set; } |
|
302 |
public string DATA_TYPE { get; set; } |
|
303 |
public string MarkupInfoID { get; set; } |
|
304 |
public int IsUpdate { get; set; } |
|
305 |
} |
|
306 |
|
|
307 |
static List<TempLoadData> tempLoadData = new List<TempLoadData>(); |
|
308 |
|
|
309 |
|
|
310 |
public static Undo_data UndoData { get; set; } |
|
311 |
|
|
312 |
public class TempDt |
|
313 |
{ |
|
314 |
public int PageNumber { get; set; } |
|
315 |
public string CommentID { get; set; } |
|
316 |
public string ConvertData { get; set; } |
|
317 |
public int DATA_TYPE { get; set; } |
|
318 |
public string MarkupInfoID { get; set; } |
|
319 |
public int IsUpdate { get; set; } |
|
320 |
} |
|
321 |
|
|
322 |
public static List<TempDt> tempDtList = new List<TempDt>(); |
|
323 |
|
|
324 |
public static void TempLoad() |
|
325 |
{ |
|
326 |
if ((System.IO.File.Exists(FilePath)) == true) |
|
327 |
{ |
|
328 |
XmlDocument xdoc = new XmlDocument(); |
|
329 |
xdoc.Load(FilePath); |
|
330 |
XmlNodeList nodes = xdoc.SelectNodes("/Root/CommentID"); |
|
331 |
int PageNumber = 0; |
|
332 |
if (nodes.Count > 0) |
|
333 |
{ |
|
334 |
if (MessageBox.Show("저장하지 못한 데이터가 있습니다. 불러오시겠습니까?", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK) |
|
335 |
{ |
|
336 |
foreach (XmlNode node in nodes) |
|
337 |
{ |
|
338 |
string CommentID = node.Attributes["Value"].Value; |
|
339 |
string ConvertData = node.SelectSingleNode("ConvertData").InnerText; |
|
340 |
string DATA_TYPE = node.SelectSingleNode("DATA_TYPE").InnerText; |
|
341 |
string MarkupInfoID = node.SelectSingleNode("MarkupInfoID").InnerText; |
|
342 |
int IsUpdate = Convert.ToInt32(node.SelectSingleNode("IsUpdate").InnerText); |
|
343 |
PageNumber = Convert.ToInt32(node.SelectSingleNode("PageNumber").InnerText); |
|
344 |
|
|
345 |
tempLoadData.Add(new TempLoadData() |
|
346 |
{ |
|
347 |
PageNumber = PageNumber, |
|
348 |
CommentID = CommentID, |
|
349 |
ConvertData = ConvertData, |
|
350 |
DATA_TYPE = DATA_TYPE, |
|
351 |
MarkupInfoID = MarkupInfoID, |
|
352 |
IsUpdate = IsUpdate |
|
353 |
}); |
|
354 |
} |
|
355 |
|
|
356 |
if (PageNumber > 0) |
|
357 |
{ |
|
358 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(PageNumber); |
|
359 |
} |
|
360 |
|
|
361 |
// Temp Object add |
|
362 |
if (Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber == PageNumber) |
|
363 |
{ |
|
364 |
TempControlLoad(); |
|
365 |
} |
|
366 |
tempLoadData.Clear(); |
|
367 |
} |
|
368 |
} |
|
369 |
else //파일 삭제 |
|
370 |
{ |
|
371 |
TempFile.Remove(); |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
375 |
|
|
376 |
|
|
377 |
//Temp Control Load |
|
378 |
public static void TempControlLoad() |
|
379 |
{ |
|
380 |
List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
|
381 |
|
|
382 |
for (int k = 0; k < tempLoadData.Count; k++) |
|
383 |
{ |
|
384 |
System.Windows.Controls.Control item = null; |
|
385 |
Multi_Undo_data multi_Undo_Data; |
|
386 |
|
|
387 |
|
|
388 |
switch (tempLoadData[k].IsUpdate) |
|
389 |
{ |
|
390 |
case 0://추가 |
|
391 |
var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault(); |
|
392 |
if (control != null) |
|
393 |
{ |
|
394 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
|
395 |
var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault(); |
|
396 |
ViewerDataModel.Instance.MarkupList_USER.Remove(Item_); |
|
397 |
} |
|
398 |
|
|
399 |
//Control |
|
400 |
item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID); |
|
401 |
|
|
402 |
UndoData = new Undo_data() |
|
403 |
{ |
|
404 |
IsUndo = false, |
|
405 |
Event = Event_Type.Create, |
|
406 |
EventTime = DateTime.Now, |
|
407 |
Opacity = ViewerDataModel.Instance.ControlOpacity, |
|
408 |
Markup_List = new List<Multi_Undo_data>() |
|
409 |
}; |
|
410 |
|
|
411 |
multi_Undo_Data = new Multi_Undo_data(); |
|
412 |
multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo); |
|
413 |
UndoData.Markup_List.Add(multi_Undo_Data); |
|
414 |
ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
|
415 |
break; |
|
416 |
case 1://수정 |
|
417 |
control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault(); |
|
418 |
if (control != null) |
|
419 |
{ |
|
420 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
|
421 |
var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault(); |
|
422 |
ViewerDataModel.Instance.MarkupList_USER.Remove(Item_); |
|
423 |
} |
|
424 |
|
|
425 |
//Control |
|
426 |
item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID); |
|
427 |
|
|
428 |
UndoData = new Undo_data() |
|
429 |
{ |
|
430 |
IsUndo = false, |
|
431 |
Event = Event_Type.Thumb, |
|
432 |
EventTime = DateTime.Now, |
|
433 |
Opacity = ViewerDataModel.Instance.ControlOpacity, |
|
434 |
Markup_List = new List<Multi_Undo_data>() |
|
435 |
}; |
|
436 |
|
|
437 |
multi_Undo_Data = new Multi_Undo_data(); |
|
438 |
multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo); |
|
439 |
UndoData.Markup_List.Add(multi_Undo_Data); |
|
440 |
ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
|
441 |
break; |
|
442 |
case 2://삭제 |
|
443 |
|
|
444 |
control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault(); |
|
445 |
if (control != null) |
|
446 |
{ |
|
447 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
|
448 |
var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault(); |
|
449 |
ViewerDataModel.Instance.MarkupList_USER.Remove(Item_); |
|
450 |
} |
|
451 |
break; |
|
452 |
} |
|
453 |
} |
|
454 |
} |
|
455 |
// public static Dispatcher Dispatcher { get; } |
|
456 |
public static void TempFileAdd() |
|
457 |
{ |
|
458 |
System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate |
|
459 |
{ |
|
460 |
if (ViewerDataModel.Instance.UndoDataList.Count > 0) |
|
461 |
{ |
|
462 |
DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime; |
|
463 |
DateTime updatetime = DateTime.Now.AddDays(-1); |
|
464 |
if (ViewerDataModel.Instance._markupInfoList.Count > 0) |
|
465 |
{ |
|
466 |
updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime; |
|
467 |
} |
|
468 |
|
|
469 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.EmptyControlCheck(); |
|
470 |
|
|
471 |
if (undoTime > updatetime) |
|
472 |
{ |
|
473 |
if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0) |
|
474 |
{ |
|
475 |
foreach (var control in ViewerDataModel.Instance.MarkupControls_USER) |
|
476 |
{ |
|
477 |
var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID); |
|
478 |
|
|
479 |
var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault(); |
|
480 |
if (existItem != null) |
|
481 |
{ |
|
482 |
if (existItem.Data != root.ConvertData) |
|
483 |
{ |
|
484 |
tempDtList.Add(new TempDt() |
|
485 |
{ |
|
486 |
CommentID = control.CommentID, |
|
487 |
ConvertData = root.ConvertData, |
|
488 |
DATA_TYPE = root.DATA_TYPE, |
|
489 |
MarkupInfoID = App.Custom_ViewInfoId, |
|
490 |
PageNumber = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber, |
|
491 |
IsUpdate = 1 |
|
492 |
}); |
|
493 |
} |
|
494 |
} |
|
495 |
else //신규 추가 된 코멘트 |
|
496 |
{ |
|
497 |
if (root.CommentID != null) |
|
498 |
{ |
|
499 |
var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault(); |
|
500 |
if (currentCommentCheck != null) |
|
501 |
{ |
|
502 |
tempDtList.Add(new TempDt() |
|
503 |
{ |
|
504 |
CommentID = control.CommentID, |
|
505 |
ConvertData = root.ConvertData, |
|
506 |
DATA_TYPE = root.DATA_TYPE, |
|
507 |
MarkupInfoID = App.Custom_ViewInfoId, |
|
508 |
PageNumber = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber, |
|
509 |
IsUpdate = 1 |
|
510 |
}); |
|
511 |
} |
|
512 |
else |
|
513 |
{ |
|
514 |
tempDtList.Add(new TempDt() |
|
515 |
{ |
|
516 |
CommentID = control.CommentID, |
|
517 |
ConvertData = root.ConvertData, |
|
518 |
DATA_TYPE = root.DATA_TYPE, |
|
519 |
MarkupInfoID = App.Custom_ViewInfoId, |
|
520 |
PageNumber = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber, |
|
521 |
IsUpdate = 0 |
|
522 |
}); |
|
523 |
} |
|
524 |
} |
|
525 |
} |
|
526 |
} |
|
527 |
} |
|
528 |
|
|
529 |
WriteTemp(tempDtList); |
|
530 |
tempDtList.Clear(); |
|
531 |
} |
|
532 |
} |
|
533 |
})); |
|
534 |
|
|
535 |
} |
|
536 |
|
|
537 |
//public static string PathString = System.IO.Path.GetTempPath() + "\\MARKUS\\" + App.ViewInfo.DocumentItemID + ".tmp"; |
|
538 |
|
|
539 |
} |
|
296 | 540 |
} |
297 | 541 |
|
내보내기 Unified diff