개정판 c62dde30
issue #0000
sync, save 작업시간 소요되는 부분 backgroundworker로 변경
Change-Id: I3ee82f0c1fd190de7d2ee5be7141ae081fa25895
ID2.Manager/ID2.Manager/Classes/DocumentsWorker.cs | ||
---|---|---|
10 | 10 |
using ID2.Manager.Data.Models; |
11 | 11 |
using ID2.Manager.Controller.Controllers; |
12 | 12 |
using static ID2.Manager.Data.Models.Documents; |
13 |
using ID2.Manager.Common; |
|
13 | 14 |
|
14 | 15 |
namespace ID2.Manager.Classes |
15 | 16 |
{ |
... | ... | |
69 | 70 |
public delegate void OnWorkCompleted(RunWorkerCompletedEventArgs e); |
70 | 71 |
public OnWorkCompleted OnWorkCompletedHandler; |
71 | 72 |
|
73 |
readonly Informations informations = Informations.Instance; |
|
74 |
|
|
72 | 75 |
List<Documents> DocList { get; set; } |
73 | 76 |
List<Documents> OrgList { get; set; } |
74 |
List<Documents> SetList { get; set; } |
|
75 |
List<Documents> DelList { get; set; } |
|
77 |
List<Documents> SetList { get; set; } = new List<Documents>();
|
|
78 |
List<Documents> DelList { get; set; } = new List<Documents>();
|
|
76 | 79 |
|
77 |
public SetDocumentsWorker(List<Documents> docList, List<Documents> orgDocList, List<Documents> setDocList, List<Documents> delDocList, Control parent = null) : base(parent)
|
|
80 |
public SetDocumentsWorker(List<Documents> docList, List<Documents> orgDocList, Control parent = null) : base(parent) |
|
78 | 81 |
{ |
79 | 82 |
this.DocList = docList; |
80 | 83 |
this.OrgList = orgDocList; |
81 |
this.SetList = setDocList; |
|
82 |
this.DelList = delDocList; |
|
83 | 84 |
} |
84 | 85 |
protected override void DoWork(BackgroundWorker worker, DoWorkEventArgs e) |
85 | 86 |
{ |
... | ... | |
88 | 89 |
.ToList().ForEach(x => this.SetList.Add(x)); |
89 | 90 |
//삭제리스트 |
90 | 91 |
this.DelList.AddRange(this.OrgList.Except(this.DocList, new DocumentsKeyComparer())); |
92 |
|
|
93 |
e.Result = new DocumentController().SetDocumentData(SetList, DelList, informations.ActiveUser.ID); |
|
94 |
} |
|
95 |
|
|
96 |
protected override void WorkCompleted(RunWorkerCompletedEventArgs e) |
|
97 |
{ |
|
98 |
this.OnWorkCompletedHandler?.Invoke(e); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
class SyncDocumentsWorker : BaseWorker |
|
103 |
{ |
|
104 |
public delegate void OnWorkCompleted(RunWorkerCompletedEventArgs e); |
|
105 |
public OnWorkCompleted OnWorkCompletedHandler; |
|
106 |
|
|
107 |
readonly Informations informations = Informations.Instance; |
|
108 |
|
|
109 |
public SyncDocumentsWorker(Control parent = null) : base(parent) |
|
110 |
{ |
|
111 |
} |
|
112 |
protected override void DoWork(BackgroundWorker worker, DoWorkEventArgs e) |
|
113 |
{ |
|
114 |
var id2Prjs = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).Select(x => x.ID2Info).ToList(); |
|
115 |
|
|
116 |
e.Result = new DocumentController().SetID2Sync(informations.ActiveProject.ProjectID, id2Prjs, informations.ActiveUser.ID); |
|
91 | 117 |
} |
92 | 118 |
|
93 | 119 |
protected override void WorkCompleted(RunWorkerCompletedEventArgs e) |
ID2.Manager/ID2.Manager/Main.cs | ||
---|---|---|
1386 | 1386 |
{ |
1387 | 1387 |
if (RadMessageBox.Show("Do you want to Save?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes) |
1388 | 1388 |
{ |
1389 |
List<Documents> setDocuments = new List<Documents>(); |
|
1390 |
List<Documents> delDocuments = new List<Documents>(); |
|
1391 |
|
|
1392 |
var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, setDocuments, delDocuments, this.radGridViewDocuments); |
|
1389 |
var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, this.radGridViewDocuments); |
|
1393 | 1390 |
worker.OnWorkCompletedHandler += (e) => |
1394 | 1391 |
{ |
1395 |
bool result = new DocumentController().SetDocumentData(setDocuments, delDocuments, informations.ActiveUser.ID);
|
|
1392 |
bool result = (bool)e.Result;
|
|
1396 | 1393 |
|
1397 | 1394 |
bool markusResult = new MarkusInfoController().SetMarkusInfo(this.documents); |
1398 | 1395 |
|
... | ... | |
1458 | 1455 |
{ |
1459 | 1456 |
if (RadMessageBox.Show("Do you want to ID2 Sync?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes) |
1460 | 1457 |
{ |
1461 |
var id2Prjs = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).Select(x => x.ID2Info).ToList(); |
|
1462 |
|
|
1463 |
bool result = new DocumentController().SetID2Sync(informations.ActiveProject.ProjectID, id2Prjs, informations.ActiveUser.ID); |
|
1464 |
|
|
1465 |
if (result) |
|
1458 |
var worker = new SyncDocumentsWorker(this.radGridViewDocuments); |
|
1459 |
worker.OnWorkCompletedHandler += (arg) => |
|
1466 | 1460 |
{ |
1467 |
this.GetDocList(); |
|
1468 |
} |
|
1461 |
if ((bool)arg.Result) |
|
1462 |
{ |
|
1463 |
this.GetDocList(); |
|
1464 |
|
|
1465 |
RadMessageBox.Show("Sync with ID2 completed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
|
1466 |
} |
|
1467 |
}; |
|
1468 |
worker.StartWork(); |
|
1469 | 1469 |
} |
1470 | 1470 |
} |
1471 | 1471 |
catch (Exception ex) |
내보내기 Unified diff