개정판 3b484ebb
issue #000: Temp 관련 기능 TempFile Class로 이동 및 수정
Change-Id: If6157c1c9ae87400128ed1d69e24afa60f4dd7bb
KCOM/Views/MainMenu.xaml.cs | ||
---|---|---|
407 | 407 |
{ |
408 | 408 |
Stopwatch sw = new Stopwatch(); |
409 | 409 |
sw.Start(); |
410 |
TempFileAdd(); |
|
410 |
TempFile.TempFileAdd();
|
|
411 | 411 |
sw.Stop(); |
412 | 412 | |
413 | 413 |
Dispatcher.InvokeAsync(new Action(delegate |
... | ... | |
421 | 421 |
////GC.Collect(); |
422 | 422 |
} |
423 | 423 | |
424 |
void TempFileAdd() |
|
425 |
{ |
|
426 |
Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate |
|
427 |
{ |
|
428 |
if (ViewerDataModel.Instance.UndoDataList.Count > 0) |
|
429 |
{ |
|
430 |
DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime; |
|
431 |
DateTime updatetime = DateTime.Now.AddDays(-1); |
|
432 |
if (ViewerDataModel.Instance._markupInfoList.Count > 0) |
|
433 |
{ |
|
434 |
updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime; |
|
435 |
} |
|
436 | ||
437 |
EmptyControlCheck(); |
|
438 | ||
439 |
if (undoTime > updatetime) |
|
440 |
{ |
|
441 |
if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0) |
|
442 |
{ |
|
443 |
foreach (var control in ViewerDataModel.Instance.MarkupControls_USER) |
|
444 |
{ |
|
445 |
var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID); |
|
446 | ||
447 |
var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault(); |
|
448 |
if (existItem != null) |
|
449 |
{ |
|
450 |
if (existItem.Data != root.ConvertData) |
|
451 |
{ |
|
452 |
tempDtList.Add(new TempDt() |
|
453 |
{ |
|
454 |
CommentID = control.CommentID, |
|
455 |
ConvertData = root.ConvertData, |
|
456 |
DATA_TYPE = root.DATA_TYPE, |
|
457 |
MarkupInfoID = App.Custom_ViewInfoId, |
|
458 |
PageNumber = this.pageNavigator.CurrentPage.PageNumber, |
|
459 |
IsUpdate = 1 |
|
460 |
}); |
|
461 |
} |
|
462 |
} |
|
463 |
else //신규 추가 된 코멘트 |
|
464 |
{ |
|
465 |
if (root.CommentID != null) |
|
466 |
{ |
|
467 |
var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault(); |
|
468 |
if (currentCommentCheck != null) |
|
469 |
{ |
|
470 |
tempDtList.Add(new TempDt() |
|
471 |
{ |
|
472 |
CommentID = control.CommentID, |
|
473 |
ConvertData = root.ConvertData, |
|
474 |
DATA_TYPE = root.DATA_TYPE, |
|
475 |
MarkupInfoID = App.Custom_ViewInfoId, |
|
476 |
PageNumber = this.pageNavigator.CurrentPage.PageNumber, |
|
477 |
IsUpdate = 1 |
|
478 |
}); |
|
479 |
} |
|
480 |
else |
|
481 |
{ |
|
482 |
tempDtList.Add(new TempDt() |
|
483 |
{ |
|
484 |
CommentID = control.CommentID, |
|
485 |
ConvertData = root.ConvertData, |
|
486 |
DATA_TYPE = root.DATA_TYPE, |
|
487 |
MarkupInfoID = App.Custom_ViewInfoId, |
|
488 |
PageNumber = this.pageNavigator.CurrentPage.PageNumber, |
|
489 |
IsUpdate = 0 |
|
490 |
}); |
|
491 |
} |
|
492 |
} |
|
493 |
} |
|
494 |
} |
|
495 |
} |
|
496 | ||
497 |
TempFile.WriteTemp(tempDtList); |
|
498 |
tempDtList.Clear(); |
|
499 |
} |
|
500 |
} |
|
501 |
})); |
|
502 | ||
503 |
} |
|
504 | ||
505 | ||
506 |
public class TempLoadData |
|
507 |
{ |
|
508 |
public int PageNumber { get; set; } |
|
509 |
public string CommentID { get; set; } |
|
510 |
public string ConvertData { get; set; } |
|
511 |
public string DATA_TYPE { get; set; } |
|
512 |
public string MarkupInfoID { get; set; } |
|
513 |
public int IsUpdate { get; set; } |
|
514 |
} |
|
515 | ||
516 |
List<TempLoadData> tempLoadData = new List<TempLoadData>(); |
|
517 |
//public string FilePath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\" + ; |
|
518 |
public static string PathString = System.IO.Path.GetTempPath() + "\\MARKUS\\" + App.ViewInfo.DocumentItemID + ".tmp"; |
|
519 | ||
520 |
public void TempLoad() |
|
521 |
{ |
|
522 |
if ((System.IO.File.Exists(FilePath)) == true) |
|
523 |
{ |
|
524 |
XmlDocument xdoc = new XmlDocument(); |
|
525 |
xdoc.Load(FilePath); |
|
526 |
XmlNodeList nodes = xdoc.SelectNodes("/Root/CommentID"); |
|
527 |
int PageNumber = 0; |
|
528 |
if (nodes.Count > 0) |
|
529 |
{ |
|
530 |
if (MessageBox.Show("저장하지 못한 데이터가 있습니다. 불러오시겠습니까?", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK) |
|
531 |
{ |
|
532 |
foreach (XmlNode node in nodes) |
|
533 |
{ |
|
534 |
string CommentID = node.Attributes["Value"].Value; |
|
535 |
string ConvertData = node.SelectSingleNode("ConvertData").InnerText; |
|
536 |
string DATA_TYPE = node.SelectSingleNode("DATA_TYPE").InnerText; |
|
537 |
string MarkupInfoID = node.SelectSingleNode("MarkupInfoID").InnerText; |
|
538 |
int IsUpdate = Convert.ToInt32(node.SelectSingleNode("IsUpdate").InnerText); |
|
539 |
PageNumber = Convert.ToInt32(node.SelectSingleNode("PageNumber").InnerText); |
|
540 | ||
541 |
tempLoadData.Add(new TempLoadData() |
|
542 |
{ |
|
543 |
PageNumber = PageNumber, |
|
544 |
CommentID = CommentID, |
|
545 |
ConvertData = ConvertData, |
|
546 |
DATA_TYPE = DATA_TYPE, |
|
547 |
MarkupInfoID = MarkupInfoID, |
|
548 |
IsUpdate = IsUpdate |
|
549 |
}); |
|
550 |
} |
|
551 | ||
552 |
if (PageNumber > 0) |
|
553 |
{ |
|
554 |
this.pageNavigator.GotoPage(PageNumber); |
|
555 |
} |
|
556 | ||
557 |
// Temp Object add |
|
558 |
if (pageNavigator.CurrentPage.PageNumber == PageNumber) |
|
559 |
{ |
|
560 |
TempControlLoad(); |
|
561 |
} |
|
562 |
tempLoadData.Clear(); |
|
563 |
} |
|
564 |
} |
|
565 |
else //파일 삭제 |
|
566 |
{ |
|
567 |
TempFile.Remove(); |
|
568 |
} |
|
569 |
} |
|
570 |
} |
|
571 | ||
572 | ||
573 | 424 |
public void ReleaseAdorner() |
574 | 425 |
{ |
575 | 426 |
try |
... | ... | |
950 | 801 |
} |
951 | 802 | |
952 | 803 | |
953 |
//Temp Control Load |
|
954 |
public void TempControlLoad() |
|
955 |
{ |
|
956 |
List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
|
957 | ||
958 |
for (int k = 0; k < tempLoadData.Count; k++) |
|
959 |
{ |
|
960 |
System.Windows.Controls.Control item = null; |
|
961 |
Multi_Undo_data multi_Undo_Data; |
|
962 | ||
963 | ||
964 |
switch (tempLoadData[k].IsUpdate) |
|
965 |
{ |
|
966 |
case 0://추가 |
|
967 |
var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault(); |
|
968 |
if (control != null) |
|
969 |
{ |
|
970 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
|
971 |
var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault(); |
|
972 |
ViewerDataModel.Instance.MarkupList_USER.Remove(Item_); |
|
973 |
} |
|
974 | ||
975 |
//Control |
|
976 |
item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID); |
|
977 | ||
978 |
UndoData = new Undo_data() |
|
979 |
{ |
|
980 |
IsUndo = false, |
|
981 |
Event = Event_Type.Create, |
|
982 |
EventTime = DateTime.Now, |
|
983 |
Opacity = ViewerDataModel.Instance.ControlOpacity, |
|
984 |
Markup_List = new List<Multi_Undo_data>() |
|
985 |
}; |
|
986 | ||
987 |
multi_Undo_Data = new Multi_Undo_data(); |
|
988 |
multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo); |
|
989 |
UndoData.Markup_List.Add(multi_Undo_Data); |
|
990 |
ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
|
991 |
break; |
|
992 |
case 1://수정 |
|
993 |
control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault(); |
|
994 |
if (control != null) |
|
995 |
{ |
|
996 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
|
997 |
var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault(); |
|
998 |
ViewerDataModel.Instance.MarkupList_USER.Remove(Item_); |
|
999 |
} |
|
1000 | ||
1001 |
//Control |
|
1002 |
item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID); |
|
1003 | ||
1004 |
UndoData = new Undo_data() |
|
1005 |
{ |
|
1006 |
IsUndo = false, |
|
1007 |
Event = Event_Type.Thumb, |
|
1008 |
EventTime = DateTime.Now, |
|
1009 |
Opacity = ViewerDataModel.Instance.ControlOpacity, |
|
1010 |
Markup_List = new List<Multi_Undo_data>() |
|
1011 |
}; |
|
1012 | ||
1013 |
multi_Undo_Data = new Multi_Undo_data(); |
|
1014 |
multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo); |
|
1015 |
UndoData.Markup_List.Add(multi_Undo_Data); |
|
1016 |
ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
|
1017 |
break; |
|
1018 |
case 2://삭제 |
|
1019 | ||
1020 |
control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault(); |
|
1021 |
if (control != null) |
|
1022 |
{ |
|
1023 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
|
1024 |
var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault(); |
|
1025 |
ViewerDataModel.Instance.MarkupList_USER.Remove(Item_); |
|
1026 |
} |
|
1027 |
break; |
|
1028 |
} |
|
1029 |
} |
|
1030 |
} |
|
804 |
|
|
1031 | 805 | |
1032 | 806 |
private void SetCommentPages(bool onlyMe = false) |
1033 | 807 |
{ |
... | ... | |
6706 | 6480 |
} |
6707 | 6481 |
#endregion |
6708 | 6482 | |
6709 |
TempFile temp = new TempFile(); |
|
6710 | 6483 |
//MarkupInfoItem |
6711 | 6484 |
public void CreateControl() |
6712 | 6485 |
{ |
내보내기 Unified diff