프로젝트

일반

사용자정보

개정판 b92f142f

IDb92f142f6eb14780b6bde03439e392aa44595c2d
상위 31f18afa
하위 c517099d

김태성이(가) 5년 이상 전에 추가함

convert service 수정
Controller 수정

Change-Id: I38994fcc4d4452d638ea74b27cc8638f4157e17a

차이점 보기:

ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/DataBaseByStatusViewModel.cs
7 7
using System.Threading.Tasks;
8 8
using Markus.Service.Extensions;
9 9
using Markus.Message;
10
using Markus.Service.WcfClient.StationServiceTask;
10
using Markus.Service.StationController.Extensions;
11
using Markus.Service.Interface;
11 12

  
12 13
namespace Markus.Service.StationController.ViewModel
13 14
{
......
15 16
    {
16 17
        BackgroundWorker backgroundWorker;
17 18

  
18
        private List<ConvertItem> items;
19
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> items;
20
        private ConvertItem selectItem;
21

  
19 22
        private StatusCodeType statusType;
20 23
        private bool isLoading;
21 24

  
22
        public List<ConvertItem> Items
25
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> Items
23 26
        {
24 27
            get => items; set
25 28
            {
......
28 31
            }
29 32
        }
30 33

  
31
      
34
        public ConvertItem SelectItem
35
        {
36
            get => selectItem; set
37
            {
38
                selectItem = value;
39
                OnPropertyChanged(() => SelectItem);
40
            }
41
        }
42

  
43

  
32 44
        public StatusCodeType StatusType
33 45
        {
34 46
            get => statusType; set
......
50 62
            }
51 63
        }
52 64

  
65
       
66

  
53 67
        public DataBaseByStatusViewModel()
54 68
        {
55 69
        }
......
65 79
        }
66 80

  
67 81
        // BackgroundWorker에서 수행할 일을 정의.
68
        private async void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
82
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
69 83
        {
70 84
            while (IsAcitve)
71 85
            {
......
77 91

  
78 92
                    List<ConvertItem> newitems = new List<ConvertItem>();
79 93

  
80
                    foreach (var client in App.StationClientList)
94
                    using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
81 95
                    {
82
                        var items = await client.AliveConvertListAsync();
83

  
84
                        newitems.AddRange(items);
96
                        newitems = database.GetConvertItems(StatusType, x=>x.CREATE_DATETIME > DateTime.Today,10).ToList();
85 97
                    }
86 98

  
87
                  //newitems.Update(Items);
88

  
89
                    Items = newitems;
99
                    if (Items == null)
100
                    {
101
                        Items = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
90 102

  
103
                        foreach (var item in newitems)
104
                        {
105
                            Items.Add(item);
106
                        }
107
                    }
108
                    else
109
                    {
110
                        /// 데이터 업데이트
111
                        newitems.ForEach(newitem =>
112
                        {
113
                            Items.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
114
                        });
115

  
116
                        // 추가
117
                        foreach (var item in newitems)
118
                        {
119
                            if (Items.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
120
                            {
121
                                Items.Add(item);
122
                            }
123
                        }
124

  
125
                        /// 삭제
126

  
127
                        for (int i = Items.Count() - 1; i > -1; --i)
128
                        {
129
                            var item = Items[i];
130

  
131
                            if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
132
                            {
133
                                Items.RemoveAt(i);
134
                            }
135
                        }
136
                    }
91 137
                }
92 138
                catch (Exception ex)
93 139
                {
......
100 146
        {
101 147
            base.Loaded();
102 148

  
103
            backgroundWorker = new BackgroundWorker();
104
            backgroundWorker.DoWork += backgroundWorker_DoWork;
105
            backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted;
106
            backgroundWorker.WorkerReportsProgress = false;
107
            backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
149
            if (!IsDesignMode)
150
            {
151
                backgroundWorker = new BackgroundWorker();
152
                backgroundWorker.DoWork += backgroundWorker_DoWork;
153
                backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted;
154
                backgroundWorker.WorkerReportsProgress = false;
155
                backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
108 156

  
109
            backgroundWorker.RunWorkerAsync();
157
                backgroundWorker.RunWorkerAsync();
158
            }
110 159
        }
111 160

  
112 161
        public override void Closed()
113 162
        {
114
            backgroundWorker.DoWork -= backgroundWorker_DoWork;
115
            backgroundWorker.RunWorkerCompleted -= backgroundWorker_RunWorkerCompleted;
116
            backgroundWorker.WorkerReportsProgress = false;
117
            backgroundWorker.ProgressChanged -= new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
163
            if (!IsDesignMode)
164
            {
165
                backgroundWorker.DoWork -= backgroundWorker_DoWork;
166
                backgroundWorker.RunWorkerCompleted -= backgroundWorker_RunWorkerCompleted;
167
                backgroundWorker.WorkerReportsProgress = false;
168
                backgroundWorker.ProgressChanged -= new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
118 169

  
119
            backgroundWorker.Dispose();
170
                backgroundWorker.Dispose();
171
            }
120 172

  
121 173
            base.Closed();
122 174
        }

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)