프로젝트

일반

사용자정보

개정판 904fbe46

ID904fbe464b1f25e3c72c822faf20b2f26d779d91
상위 3ccb1a8d
하위 04703422

유성호이(가) 일년 이상 전에 추가함

issue #0000
조회/sync 시 backgroundworker 로 변경
worker result 추가
document result class 추가

Change-Id: I5637214998b1b76ab26431a000bab92b94a15b48

차이점 보기:

ID2.Manager/ID2.Manager.Controller/Controllers/DocumentController.cs
50 50
        {
51 51
            try
52 52
            {
53
                IEnumerable<Documents> docs = this.GetDocuments(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult).dwgs;
53
                var (dwgs, totalCnt) = this.GetDocuments(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult);
54

  
55
                IEnumerable<Documents> docs = dwgs;
54 56
                List<ID2Drawings> id2docs = null;
55 57

  
56 58
                if (id2Infos.Any())
......
125 127
                                     MarkupText = doc.MarkupText
126 128
                                 };
127 129

  
128
                    return (result, 0);
130
                    return (result, totalCnt);
129 131

  
130 132
                }
131
                return (docs, 0);
133
                return (dwgs, totalCnt);
132 134
            }
133 135
            catch (Exception ex)
134 136
            {
ID2.Manager/ID2.Manager.Data/Models/Documents.cs
255 255
        [DataMember]
256 256
        public byte[] Image { get; set; }
257 257
    }
258

  
259
    public class DocumentsResult
260
    {
261
        public List<Documents> Dwgs { get; set; }
262
        public int TotalCount { get; set; }
263
    }
258 264
}
ID2.Manager/ID2.Manager/Classes/BaseWorker.cs
80 80
                    Console.WriteLine(ex.Message);
81 81
                }
82 82
            }
83
            this.WorkCompleted();
83
            this.WorkCompleted(e);
84 84
        }
85 85

  
86 86
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
87 87
        {
88
            this.DoWork(sender as BackgroundWorker);
88
            this.DoWork(sender as BackgroundWorker, e);
89 89
        }
90 90

  
91
        protected virtual void DoWork(System.ComponentModel.BackgroundWorker worker) { throw new NotImplementedException(); }
91
        protected virtual void DoWork(System.ComponentModel.BackgroundWorker worker, DoWorkEventArgs args) { throw new NotImplementedException(); }
92 92
        protected virtual void UpdateProgress(int precent) { }
93
        protected virtual void WorkCompleted() { }
93
        protected virtual void WorkCompleted(RunWorkerCompletedEventArgs args) { }
94 94
    }
95 95
}
ID2.Manager/ID2.Manager/Classes/DocumentsWorker.cs
8 8
using System.Windows.Forms;
9 9

  
10 10
using ID2.Manager.Data.Models;
11
using ID2.Manager.Controller.Controllers;
11 12
using static ID2.Manager.Data.Models.Documents;
12 13

  
13 14
namespace ID2.Manager.Classes
14 15
{
16
    class LoadDocumentsWorker : BaseWorker
17
    {
18
        public delegate void OnWorkCompleted(RunWorkerCompletedEventArgs e);
19
        public OnWorkCompleted OnWorkCompletedHandler;
20

  
21
        List<ID2ProjectInfo> ID2Prjs { get; set; }
22
        string ProjectCode { get; set; }
23
        string PersonIncharge { get; set; }
24
        string JobLevel { get; set; } 
25
        string DocumentNo { get; set; } 
26
        string IsToIsDiscussion { get; set; }
27
        string IsFrReviewStatus { get; set; }
28
        string IsID2Work { get; set; }
29
        string Id2Status { get; set; }
30
        string AvevaStatus { get; set; }
31
        string ProdIsResult { get; set; }
32
        string ClientIsResult { get; set; }
33

  
34
        public LoadDocumentsWorker(string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string isID2Work, string id2Status, string avevaStatus, string prodIsResult, string clientIsResult, Control parent = null) : base(parent)
35
        {
36
            this.ProjectCode = projectCode;
37
            this.PersonIncharge = personIncharge;
38
            this.JobLevel = jobLevel;
39
            this.DocumentNo = documentNo;
40
            this.IsToIsDiscussion = isToIsDiscussion;
41
            this.IsFrReviewStatus = isFrReviewStatus;
42
            this.IsID2Work = isID2Work;
43
            this.Id2Status = id2Status;
44
            this.AvevaStatus = avevaStatus;
45
            this.ProdIsResult = prodIsResult;
46
            this.ClientIsResult = clientIsResult;
47
        }
48

  
49
        public LoadDocumentsWorker(List<ID2ProjectInfo> id2Infos, string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string isID2Work, string id2Status, string avevaStatus, string prodIsResult, string clientIsResult, Control parent = null) : base(parent)
50
        {
51
            this.ID2Prjs = id2Infos;
52
            this.ProjectCode = projectCode;
53
            this.PersonIncharge = personIncharge;
54
            this.JobLevel = jobLevel;
55
            this.DocumentNo = documentNo;
56
            this.IsToIsDiscussion = isToIsDiscussion;
57
            this.IsFrReviewStatus = isFrReviewStatus;
58
            this.IsID2Work = isID2Work;
59
            this.Id2Status = id2Status;
60
            this.AvevaStatus = avevaStatus;
61
            this.ProdIsResult = prodIsResult;
62
            this.ClientIsResult = clientIsResult;
63
        }
64

  
65
        protected override void DoWork(BackgroundWorker worker, DoWorkEventArgs e)
66
        {
67
            if (this.ID2Prjs == null)
68
            {
69
                var (dwgs, totalCnt) = new DocumentController().GetDocuments(this.ProjectCode, this.PersonIncharge, this.JobLevel, this.DocumentNo, this.IsToIsDiscussion, this.IsFrReviewStatus, this.IsID2Work, this.Id2Status, this.AvevaStatus, this.ProdIsResult, this.ClientIsResult);
70
                e.Result = new DocumentsResult() { Dwgs = dwgs.ToList(), TotalCount = totalCnt };
71
            }
72
            else
73
            {
74
                var (dwgs, totalCnt) = new DocumentController().GetDocuments(this.ID2Prjs, this.ProjectCode, this.PersonIncharge, this.JobLevel, this.DocumentNo, this.IsToIsDiscussion, this.IsFrReviewStatus, this.IsID2Work, this.Id2Status, this.AvevaStatus, this.ProdIsResult, this.ClientIsResult);
75
                e.Result = new DocumentsResult() { Dwgs = dwgs.ToList(), TotalCount = totalCnt };
76
            }
77
        }
78

  
79
        protected override void WorkCompleted(RunWorkerCompletedEventArgs e)
80
        {
81
            this.OnWorkCompletedHandler?.Invoke(e);
82
        }
83
    }
84

  
15 85
    class SetDocumentsWorker : BaseWorker
16 86
    {
17
        public delegate void OnWorkCompleted();
87
        public delegate void OnWorkCompleted(RunWorkerCompletedEventArgs e);
18 88
        public OnWorkCompleted OnWorkCompletedHandler;
19 89

  
20 90
        List<Documents> DocList { get; set; }
......
29 99
            this.SetList = setDocList;
30 100
            this.DelList = delDocList;
31 101
        }
32
        protected override void DoWork(BackgroundWorker worker)
102
        protected override void DoWork(BackgroundWorker worker, DoWorkEventArgs e)
33 103
        {
34 104
            //수정리스트
35 105
            this.DocList.Where(x => !this.OrgList.Any(y => y.Equals(x)))
......
38 108
            this.DelList.AddRange(this.OrgList.Except(this.DocList, new DocumentsKeyComparer()));
39 109
        }
40 110

  
41
        protected override void WorkCompleted()
111
        protected override void WorkCompleted(RunWorkerCompletedEventArgs e)
42 112
        {
43
            if (this.OnWorkCompletedHandler != null) this.OnWorkCompletedHandler();
113
            this.OnWorkCompletedHandler?.Invoke(e);
44 114
        }
45 115
    }
46 116
}
ID2.Manager/ID2.Manager/Main.cs
527 527
            #endregion
528 528

  
529 529
            this.GetDocList();
530
            this.DocumentListBinding();
531 530
        }
532 531

  
533 532
        #region Document List 조회
......
537 536
            {
538 537
                string projectCode = this.radDropDownListProject.SelectedValue.ToString();
539 538
                string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
540
                string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();//
539
                string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();
541 540
                string documentNo = this.radTextBoxDocumentNo.Text.Trim();
542 541

  
543 542
                string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString();
544 543
                string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString();
545
                string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString();//
544
                string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString();
546 545

  
547
                string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();//
548
                string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();//
546
                string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();
547
                string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();
549 548

  
550
                string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();//
551
                string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();//
549
                string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();
550
                string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();
552 551

  
553
                var (dwgs, totalCnt) = new DocumentController().GetDocuments(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult);
552
                var worker = new LoadDocumentsWorker(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult, this.radGridViewDocuments);
553
                worker.OnWorkCompletedHandler += (e) =>
554
                {
555
                    var docData = e.Result as DocumentsResult;
554 556

  
555
                this.documents = dwgs.ToList();
556
                this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(this.documents));
557
                this.TotalCount = totalCnt;
557
                    this.documents = docData.Dwgs;
558
                    this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(docData.Dwgs));
559
                    this.TotalCount = docData.TotalCount;
558 560

  
559
                List<string> projectCodes = new List<string>();
561
                    List<string> projectCodes = new List<string>();
560 562

  
561
                if(!string.IsNullOrWhiteSpace(projectCode))
562
                {
563
                    projectCodes.Add(projectCode);
564
                }
565
                else
566
                {
567
                    projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
568
                }
563
                    if (!string.IsNullOrWhiteSpace(projectCode))
564
                    {
565
                        projectCodes.Add(projectCode);
566
                    }
567
                    else
568
                    {
569
                        projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
570
                    }
571

  
572
                    this.Markups = new List<MarkupText>(new MarkusInfoController().GetMarkupData(projectCodes, this.documents.Select(x => x.DocumentNo)));
569 573

  
570
                this.Markups = new List<MarkupText>(new MarkusInfoController().GetMarkupData(projectCodes, this.documents.Select(x => x.DocumentNo)));
574
                    this.DocumentListBinding();
575
                };
576
                worker.StartWork();
571 577
            }
572 578
        }
573 579

  
......
591 597
                string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();
592 598

  
593 599
                var id2Prjs = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).Select(x => x.ID2Info).ToList();
594
                var(dwgs, totalCnt) = new DocumentController().GetDocuments(id2Prjs, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult);
595
                this.documents = dwgs.ToList();
596
                this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(this.documents));
597
                this.lbSelectAndTotal.Text = totalCnt.ToString();
600

  
601
                var worker = new LoadDocumentsWorker(id2Prjs, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult, this.radGridViewDocuments);
602
                worker.OnWorkCompletedHandler += (e) =>
603
                {
604
                    var docData = e.Result as DocumentsResult;
605

  
606
                    this.documents = docData.Dwgs;
607
                    this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(docData.Dwgs));
608
                    this.TotalCount = docData.TotalCount;
609

  
610
                    List<string> projectCodes = new List<string>();
611

  
612
                    if (!string.IsNullOrWhiteSpace(projectCode))
613
                    {
614
                        projectCodes.Add(projectCode);
615
                    }
616
                    else
617
                    {
618
                        projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
619
                    }
620

  
621
                    this.Markups = new List<MarkupText>(new MarkusInfoController().GetMarkupData(projectCodes, this.documents.Select(x => x.DocumentNo)));
622

  
623
                    this.DocumentListBinding();
624
                };
625
                worker.StartWork();
626

  
627
                
628
                //var(dwgs, totalCnt) = new DocumentController().GetDocuments(id2Prjs, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult);
629
                //this.documents = dwgs.ToList();
630
                //this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(this.documents));
631
                //this.lbSelectAndTotal.Text = totalCnt.ToString();
598 632
            }
599 633
        }
600 634

  
......
693 727
        private void RadButtonSearch_Click(object sender, EventArgs e)
694 728
        {
695 729
            this.GetDocList();
696
            this.DocumentListBinding();
697 730
        }
698 731

  
699 732
        private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e)
......
1336 1369
                List<Documents> delDocuments = new List<Documents>();
1337 1370

  
1338 1371
                var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, setDocuments, delDocuments, this.radGridViewDocuments);
1339
                worker.OnWorkCompletedHandler += () =>
1372
                worker.OnWorkCompletedHandler += (e) =>
1340 1373
                {
1341 1374
                    bool result = new DocumentController().SetDocumentData(setDocuments, delDocuments, informations.ActiveUser.ID);
1342 1375

  
1343 1376
                    bool markusResult = new MarkusInfoController().SetMarkusInfo(this.documents);
1344 1377

  
1345
                    var users = new UserController().GetAllUserInfo();
1346

  
1347
                    bool markusMembersResult = new MarkusInfoController().SetMembers(users);
1378
                    bool markusMembersResult = new MarkusInfoController().SetMembers(informations.UserList);
1348 1379

  
1349 1380
                    if (result && markusResult && markusMembersResult)
1350 1381
                    {
......
1404 1435
                if (result)
1405 1436
                {
1406 1437
                    this.GetDocListbyID2();
1407
                    this.DocumentListBinding();
1408 1438
                }
1409 1439
            }
1410 1440
        }

내보내기 Unified diff