프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / DataBaseItemsModel.cs @ c8183702

이력 | 보기 | 이력해설 | 다운로드 (28.2 KB)

1
using GemBox.Spreadsheet;
2
using Markus.Message;
3
using Markus.Service.DataBase;
4
using Markus.Service.Extensions;
5
using Markus.Service.StationController.Behaviors;
6
using Markus.Service.StationController.Extensions;
7
using Microsoft.Win32;
8
using System;
9
using System.Collections.Generic;
10
using System.ComponentModel;
11
using System.Linq;
12
using System.Threading.Tasks;
13
using System.Web;
14
using System.Windows;
15
using Telerik.Windows.Controls;
16
using Telerik.Windows.Data;
17
using ConvertItem = Markus.Service.Interface.ConvertItem;
18

    
19
namespace Markus.Service.StationController.ViewModel
20
{
21
    //세미
22
    public class DataBaseItemsModel : Mvvm.ToolKit.ViewModelBase
23
    {
24
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _AliveItems;
25
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> AliveItems
26
        {
27
            get => _AliveItems; set
28
            {
29
                _AliveItems = value;
30
                OnPropertyChanged(() => AliveItems);
31
            }
32
        }
33

    
34
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _FilterConvertSource;
35
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> FilterConvertSource
36
        {
37
            get => _FilterConvertSource;
38
            set
39
            {
40
                _FilterConvertSource = value;
41
                OnPropertyChanged(() => FilterConvertSource);
42
            }
43
        }
44

    
45

    
46
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _RealConvertSource;
47
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> RealConvertSource
48
        {
49
            get => _RealConvertSource;
50
            set
51
            {
52
                _RealConvertSource = value;
53
                OnPropertyChanged(() => RealConvertSource);
54
            }
55
        }
56

    
57

    
58
        private System.Windows.Documents.FlowDocument connectionLog;
59
        public System.Windows.Documents.FlowDocument ConnectionLog
60
        {
61
            get => connectionLog;
62
            set
63
            {
64
                if (connectionLog != value)
65
                {
66
                    connectionLog = value;
67
                    OnPropertyChanged(() => ConnectionLog);
68
                }
69
            }
70
        }
71

    
72
        //public AliveViewModel()
73
        //{
74
        //}
75

    
76
        //// 진행률에 변화가 있을때 이벤트가 발생
77
        //private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
78
        //{
79
        //}
80

    
81
        //// 일이 모두 마쳤을때 수행되어야할 코드
82
        //private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
83
        //{
84
        //}
85

    
86
        // BackgroundWorker에서 수행할 일을 정의.
87
        private void AlivebackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
88
        {
89
        }
90
        private void AlivebackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
91
        {
92
        }
93
        private async void AlivebackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
94
        {
95
            while (IsAcitve)
96
            {
97

    
98
                if (!IsLoading)
99
                {
100
                    IsLoading = true;
101

    
102
                    try
103
                    {
104

    
105
                        List<ConvertItem> newitems = new List<ConvertItem>();
106

    
107
                        foreach (var client in App.StationClientList)
108
                        {
109
                            if (await SimplePingAsync(client.Endpoint.Address.ToString()))
110
                            {
111
                                try
112
                                {
113
                                    List<ConvertItem> itemsToList = new List<ConvertItem>();
114
                                    var items = await client.AliveConvertListAsync();
115

    
116
                                    foreach (var item in items)
117
                                    {
118
                                        ConvertItem itemsToEach = new ConvertItem();
119
                                        itemsToEach.ServiceID = item.ServiceID;
120
                                        itemsToEach.ConvertID = item.ConvertID;
121
                                        itemsToEach.ProjectNumber = item.ProjectNumber;
122
                                        try
123
                                        {
124
                                            itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
125
                                        }
126
                                        catch (Exception ex)
127
                                        {
128

    
129
                                            throw ex;
130
                                        }
131

    
132
                                        //itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
133
                                        itemsToEach.CurrentPageNo = item.CurrentPageNo;
134
                                        itemsToEach.TotalPage = item.TotalPage;
135
                                        itemsToEach.OriginfilePath = item.OriginfilePath;
136
                                        itemsToEach.ConvertPath = item.ConvertPath;
137

    
138
                                        itemsToList.Add(itemsToEach);
139
                                    }
140
                                    newitems.AddRange(itemsToList);
141
                                    System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
142

    
143
                                    if (items.Count() == 0)
144
                                    {
145
                                        System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
146
                                    }
147
                                }
148
                                catch (Exception ex)
149
                                {
150
                                    System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
151
                                }
152
                            }
153
                            else
154
                            {
155
                                System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
156
                            }
157
                        }
158
                        await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
159
                    }
160
                    catch (Exception ex)
161
                    {
162
                        System.Diagnostics.Debug.WriteLine(ex.ToString());
163
                    }
164

    
165
                    IsLoading = false;
166
                }
167

    
168
            }
169
        }
170

    
171

    
172
        private async void AliveDataSelect()
173
        {
174
            try
175
            {
176
                List<ConvertItem> newitems = new List<ConvertItem>();
177

    
178
                foreach (var client in App.StationClientList)
179
                {
180
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
181
                    {
182
                        try
183
                        {
184
                            List<ConvertItem> itemsToList = new List<ConvertItem>();
185
                            var items = await client.AliveConvertListAsync();
186
                            foreach (var item in items)
187
                            {
188
                                ConvertItem itemsToEach = new ConvertItem();
189
                                itemsToEach.ServiceID = item.ServiceID;
190
                                itemsToEach.ConvertID = item.ConvertID;
191
                                itemsToEach.ProjectNumber = item.ProjectNumber;
192
                                try
193
                                {
194
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
195
                                }
196
                                catch (Exception ex)
197
                                {
198

    
199
                                    throw ex;
200
                                }
201

    
202
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
203
                                itemsToEach.TotalPage = item.TotalPage;
204
                                itemsToEach.OriginfilePath = item.OriginfilePath;
205
                                itemsToEach.ConvertPath = item.ConvertPath;
206

    
207
                                itemsToList.Add(itemsToEach);
208
                            }
209
                            newitems.AddRange(itemsToList);
210
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
211

    
212
                            if (items.Count() == 0)
213
                            {
214
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
215
                            }
216
                        }
217
                        catch (Exception ex)
218
                        {
219
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
220
                        }
221
                    }
222
                    else
223
                    {
224
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
225
                    }
226
                }
227

    
228
                ItemsUpdate(newitems);
229
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
230
            }
231
            catch (Exception ex)
232
            {
233
                System.Diagnostics.Debug.WriteLine(ex.ToString());
234
            }
235
        }
236

    
237

    
238
        private void ItemsUpdate(List<ConvertItem> newitems)
239
        {
240

    
241
            foreach (var item in newitems)
242
            {
243
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
244
            }
245

    
246
            if (AliveItems == null)
247
            {
248
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
249

    
250
                foreach (var item in newitems)
251
                {
252
                    AliveItems.Add(item);
253
                }
254
            }
255
            else
256
            {
257
                /// 데이터 업데이트
258
                newitems.ForEach(newitem =>
259
                {
260
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
261
                });
262

    
263
                // 추가
264
                foreach (var item in newitems)
265
                {
266
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
267
                    {
268
                        AliveItems.Add(item);
269
                    }
270
                }
271

    
272
                /// 삭제
273

    
274
                for (int i = AliveItems.Count() - 1; i > -1; --i)
275
                {
276
                    var item = AliveItems[i];
277

    
278
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
279
                    {
280
                        try
281
                        {
282
                            AliveItems.RemoveAt(i);
283
                        }
284
                        catch (Exception ex)
285
                        {
286
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
287
                        }
288
                    }
289
                }
290
            }
291
        }
292

    
293
        private void LogWrite(string log, bool IsError)
294
        {
295
            if (IsError)
296
            {
297
                System.Diagnostics.Trace.Fail(log);
298
            }
299
            else
300
            {
301
                System.Diagnostics.Trace.TraceInformation(log);
302
            }
303
        }
304

    
305

    
306
        public static async Task<bool> SimplePingAsync(string uri)
307
        {
308
            bool result = false;
309

    
310
            try
311
            {
312
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
313
                {
314
                    Client.Timeout = new TimeSpan(0, 0, 60);
315

    
316
                    var message = await Client.GetAsync(uri);
317

    
318
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
319

    
320
                    switch (StatusCode)
321
                    {
322

    
323
                        case System.Net.HttpStatusCode.Accepted:
324
                        case System.Net.HttpStatusCode.OK:
325
                            result = true;
326
                            break;
327
                    }
328
                }
329
            }
330
            catch (Exception ex)
331
            {
332
                result = false;
333
                System.Diagnostics.Debug.WriteLine(ex.ToString());
334
            }
335

    
336
            return result;
337
        }
338

    
339
        BackgroundWorker backgroundWorker;
340
        private BackgroundWorker AlivebackgroundWorker;
341

    
342
        Random rnd = new Random();
343

    
344
        private Telerik.Windows.Data.EnumMemberViewModel _SelectedStatus;
345
        public Telerik.Windows.Data.EnumMemberViewModel SelectedStatus
346
        {
347
            get => _SelectedStatus;
348
            set
349
            {
350
                _SelectedStatus = value;
351
                OnPropertyChanged(() => SelectedStatus);
352
            }
353
        }
354

    
355

    
356
        private SelectedCountItem _SelectedCount;
357
        public SelectedCountItem SelectedCount
358
        {
359
            get => _SelectedCount;
360
            set
361
            {
362
                _SelectedCount = value;
363
                OnPropertyChanged(() => SelectedCount);
364
            }
365
        }
366

    
367
        private void DataConvert(object obj)
368
        {
369
            if (SelectFilterConvert == null && SelectRealConvert == null)
370
            {
371
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
372
            }
373
            else
374
            {
375
                ConvertDatabase _DataConvert = new ConvertDatabase(App.MarkusDataBaseConnecitonString);
376
                var resultRealConvert = 0;
377
                var resultFiltertConvert = 0;
378

    
379
                if (SelectRealConvert != null)
380
                {
381
                    resultRealConvert = _DataConvert.SetCleanUpItem(SelectRealConvert);
382
                }
383
                else if (SelectFilterConvert != null)
384
                {
385
                    resultFiltertConvert = _DataConvert.SetCleanUpItem(SelectFilterConvert);
386
                }
387
                //System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
388

    
389
                using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
390
                {
391
                    var items = database.GetConvertProjects(SelectFilterConvert);
392

    
393
                    foreach (var item in items)
394
                    {
395
                        RealConvertSource.Add(item);
396
                    }
397

    
398
                }
399
            }
400
        }
401

    
402
        private void DataDelete(object obj)
403
        {
404
            RadWindow.Alert("정말로 삭제 하시겠습니까?", this.OnClosed);
405
        }
406

    
407
        private void OnClosed(object sender, WindowClosedEventArgs e)
408
        {
409
            var result = e.DialogResult;
410
            if (result == true)
411
            {
412
                ConvertDatabase _DataConvert = new ConvertDatabase(App.MarkusDataBaseConnecitonString);
413
                var resultRealConvert = _DataConvert.RemoveItem(SelectRealConvert.ConvertID);
414
                var resultFiltertConvert = _DataConvert.RemoveItem(SelectFilterConvert.ConvertID);
415
                System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
416
            }
417
        }
418
        private void DataValidate(object obj)
419
        {
420
            MessageBox.Show("파일 체크 할껀데 정상인지 아닌지 ");
421

    
422
        }
423

    
424

    
425
        private ConvertItem _SelectFilterConvert;
426
        public ConvertItem SelectFilterConvert
427
        {
428
            get => _SelectFilterConvert;
429
            set
430
            {
431
                _SelectFilterConvert = value;
432
                OnPropertyChanged(() => SelectFilterConvert);
433
            }
434
        }
435

    
436
        private ConvertItem _SelectRealConvert;
437
        public ConvertItem SelectRealConvert
438
        {
439
            get => _SelectRealConvert;
440
            set
441
            {
442
                _SelectRealConvert = value;
443
                OnPropertyChanged(() => SelectRealConvert);
444
            }
445
        }
446

    
447

    
448
        private StatusTypeList _StatusType;
449
        public StatusTypeList StatusType
450
        {
451
            get => _StatusType;
452
            set
453
            {
454
                _StatusType = value;
455
                OnPropertyChanged(() => StatusType);
456
            }
457
        }
458

    
459
        private bool _IsLoading;
460
        public bool IsLoading
461
        {
462
            get => _IsLoading;
463
            set
464
            {
465
                if (_IsLoading != value)
466
                {
467
                    _IsLoading = value;
468
                    OnPropertyChanged(() => IsLoading);
469
                }
470
            }
471
        }
472

    
473
        List<SelectedCountItem> _SelectedCountList;
474
        public List<SelectedCountItem> SelectedCountList
475
        {
476
            get
477
            {
478
                if (_SelectedCountList == null)
479
                {
480
                    _SelectedCountList = new List<SelectedCountItem>
481
                    {
482
                        new SelectedCountItem{DisplayMember = "50",ValueMember = 50},
483
                        new SelectedCountItem{DisplayMember = "100",ValueMember = 100},
484
                        new SelectedCountItem{DisplayMember = "150",ValueMember = 150},
485
                        new SelectedCountItem{DisplayMember = "200",ValueMember = 200}
486
                    };
487
                }
488

    
489
                return _SelectedCountList;
490
            }
491
        }
492

    
493
        public DelegateCommand ConvertCommand { get; private set; }
494
        public DelegateCommand DeleteCommand { get; private set; }
495
        public DelegateCommand ValidateCommand { get; private set; }
496

    
497
        public DataBaseItemsModel()
498
        {
499
            DataSaveFileGemBoxCommand = new DelegateCommand(DataExportData);
500
            ConvertCommand = new DelegateCommand(DataConvert);
501
            DeleteCommand = new DelegateCommand(DataDelete);
502
            ValidateCommand = new DelegateCommand(DataValidate);
503
        }
504

    
505
        // 진행률에 변화가 있을때 이벤트가 발생
506
        private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
507
        {
508
            MessageBox.Show("진행률에 변화");
509
        }
510

    
511
        // 일이 모두 마쳤을때 수행되어야할 코드
512
        private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
513
        {
514
            MessageBox.Show("임무마침");
515
        }
516

    
517
        IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> _StatusCodeList;
518
        public IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> StatusCodeList
519
        {
520
            get
521
            {
522
                if (_StatusCodeList == null)
523
                {
524
                    _StatusCodeList = Telerik.Windows.Data.EnumDataSource.FromType<StatusCodeType>();
525
                }
526

    
527
                return _StatusCodeList;
528
            }
529
        }
530
        // BackgroundWorker에서 수행할 일을 정의.
531
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
532
        {
533

    
534
            while (IsAcitve)
535
            {
536

    
537
                if (FilterConvertSource == null)
538
                {
539
                    FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
540
                }
541

    
542
                if (RealConvertSource == null)
543
                {
544
                    RealConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
545
                }
546

    
547
                /// combobox 에서 선택된 items
548
                if (SelectedStatus != null)
549
                {
550
                    DataSelect(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
551
                }
552

    
553
                /// 컨버터중인 items
554
                RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
555
            }
556
        }
557

    
558

    
559

    
560
        private void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
561
        {
562
            try
563
            {
564
                using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
565
                {
566
                    var items = database.GetConvertProjects(collection)//x:database객체 y:statusCodeTypeList의값  Count()안에 predicator 조건 만족하면 count개수안에 넣음
567
                                          .Take(SelectedCount.ValueMember).ToList();//
568

    
569
                    items.ForEach(newitem =>
570
                    {
571
                        collection.UpdateWhere(changeitem =>
572
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ConvertID == newitem.ConvertID && x.ProjectNumber == newitem.ProjectNumber);
573
                    });
574
                }
575
            }
576
            catch (Exception ex)
577
            {
578
                MessageBox.Show(ex.ToString());
579
            }
580
        }
581
        //<>쓸때는 IEnumerable 
582

    
583
        private void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
584
        {
585
            try
586
            {
587
                using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
588
                {
589

    
590
                    int _status = 0;
591
                    if (SelectedStatus != null)
592
                    {
593
                        _status = (int)SelectedStatus.Value;
594
                    }
595

    
596
                    var items = database.GetConvertProjects(_status)//x:database객체 y:statusCodeTypeList의값  Count()안에 predicator 조건 만족하면 count개수안에 넣음
597
                                          .Take(SelectedCount.ValueMember).ToList();
598

    
599
                    if (collection.Count() == 0)
600
                    {
601
                        if (statusCodeTypeList.Count() == 1)
602
                        {
603
                            items.ForEach(x => collection.Add(x));
604
                        }
605
                    }
606
                    else
607
                    {
608

    
609
                        ////세미 업데이트
610
                        items.ForEach(newitem =>
611
                        {
612
                            collection.UpdateWhere(changeitem =>
613
                            ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
614
                        });
615

    
616

    
617
                        if (statusCodeTypeList.Count() == 1)
618
                        {
619
                            //삭제
620
                            for (int i = collection.Count() - 1; i >= 0; --i)
621
                            {
622
                                var item = collection[i];
623

    
624
                                if (items.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)//디비에서 가져온 값과 마지막값부터 차례대로 비교
625
                                {//참=> 0제외한 모든 수
626
                                    collection.RemoveAt(i);
627
                                }
628
                            }
629
                        }
630

    
631
                        if (statusCodeTypeList.Count() == 1)
632
                        {
633
                            //추가 convert 후 추가됨
634
                            foreach (var item in items)
635
                            {
636
                                if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)//그리드와 디비 변동 없으면 안들어감
637
                                {
638
                                    /*for (int i = 0; i < collection.Count()+1; i++)//위 그리드에서 카운드 개수 변함 없고 컨버터 끝난 후 추가할때 createtime 비교 하며 order by 순으로 추가*/
639
                                    for (int i = 0; i < 200; i++)
640
                                    {
641
                                        if (i < collection.Count() - 1)
642
                                        {
643
                                            if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
644
                                            {
645
                                                collection.Insert(i, item);
646
                                                break;
647
                                            }
648
                                        }
649
                                        else
650
                                        {
651
                                            collection.Add(item);
652
                                            break;
653
                                        }
654
                                    }
655

    
656
                                }
657

    
658
                            }
659
                        }
660

    
661
                    }
662
                }
663

    
664
            }
665
            catch (Exception ex)
666
            {
667
                MessageBox.Show(ex.ToString());
668
            }
669
        }
670

    
671
        public override void Loaded()
672
        {
673
            base.Loaded();
674

    
675
            if (!App.IsDesignMode)
676
            {
677
                backgroundWorker = new BackgroundWorker();
678
                backgroundWorker.DoWork += backgroundWorker_DoWork;
679
                backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted;
680
                backgroundWorker.WorkerReportsProgress = false;
681
                backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
682

    
683
                backgroundWorker.RunWorkerAsync();
684

    
685
                AlivebackgroundWorker = new BackgroundWorker();
686
                AlivebackgroundWorker.DoWork += AlivebackgroundWorker_DoWork;
687
                AlivebackgroundWorker.RunWorkerCompleted += AlivebackgroundWorker_RunWorkerCompleted;
688
                AlivebackgroundWorker.WorkerReportsProgress = false;
689
                AlivebackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(AlivebackgroundWorker_ProgressChanged);
690

    
691
                AlivebackgroundWorker.RunWorkerAsync();
692
            }
693
        }
694

    
695
        public override void Closed()
696
        {
697

    
698
            if (backgroundWorker != null)
699
            {
700
                backgroundWorker.DoWork -= backgroundWorker_DoWork;
701
                backgroundWorker.RunWorkerCompleted -= backgroundWorker_RunWorkerCompleted;
702
                backgroundWorker.WorkerReportsProgress = false;
703
                backgroundWorker.ProgressChanged -= new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
704

    
705
                AlivebackgroundWorker.DoWork -= AlivebackgroundWorker_DoWork;
706
                AlivebackgroundWorker.RunWorkerCompleted -= AlivebackgroundWorker_RunWorkerCompleted;
707
                AlivebackgroundWorker.WorkerReportsProgress = false;
708
                AlivebackgroundWorker.ProgressChanged -= new ProgressChangedEventHandler(AlivebackgroundWorker_ProgressChanged);
709

    
710
                AlivebackgroundWorker.Dispose();
711

    
712
            }
713
            base.Closed();
714
        }
715

    
716

    
717
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
718
        public void DataExportData(object obj)
719
        {
720
            DataExport dataExport = new DataExport();
721
            dataExport.DataExportData(FilterConvertSource);
722
        }
723

    
724
        public class SelectedCountItem : INotifyPropertyChanged
725
        {
726
            public event PropertyChangedEventHandler PropertyChanged;
727

    
728
            private void NotifyPropertyChanged(String info)
729
            {
730
                if (PropertyChanged != null)
731
                {
732
                    PropertyChanged(this, new PropertyChangedEventArgs(info));
733
                }
734
            }
735

    
736
            //public string DisplayMember { get; set; }
737
            public string _DisplayMember;
738

    
739
            public string DisplayMember
740
            {
741
                get => _DisplayMember;
742
                set
743
                {
744
                    _DisplayMember = value;
745

    
746
                    NotifyPropertyChanged("DisplayMember");
747
                }
748
            }
749
            //public int ValueMember { get; set; }
750
            public int _ValueMember;
751
            public int ValueMember
752
            {
753
                get => _ValueMember;
754
                set
755
                {
756
                    _ValueMember = value;
757
                    NotifyPropertyChanged("ValueMember");
758
                }
759
            }
760
        }
761
    }
762
}
763

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