프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / DashBoardViewModel.cs @ 95e7bd84

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

1
using Markus.Service.Extensions;
2
using Markus.Service.StationController.Data;
3
using Markus.Service.StationController.Extensions;
4
using Newtonsoft.Json;
5
using Telerik.Charting;
6
using Telerik.Windows.Controls;
7
using Telerik.Windows.Controls.ChartView;
8
using System;
9
using System.Collections.Generic;
10
using System.Linq;
11
using System.Text;
12
using System.Threading.Tasks;
13
using System.Windows;
14
using System.Windows.Threading;
15
using ConverCOUNT = Markus.Service.StationController.Data.ConvertCOUNT;
16
using System.Collections.ObjectModel;
17
using System.ComponentModel;
18
using System.Windows.Data;
19
using System.Diagnostics;
20
using Microsoft.Win32;
21
using System.Windows.Controls;
22

    
23
namespace Markus.Service.StationController.ViewModel
24
{
25
    class DashBoardViewModel : Mvvm.ToolKit.ViewModelBase 
26
    {
27
        #region Constructor
28

    
29

    
30
        public DashBoardViewModel()
31
        {
32
            RemoveCreateTimeFilterCommand = new DelegateCommand(RemoveCreateTimeFilter);
33
            ConvertPDFMarkusLinkCommand = new DelegateCommand(ConvertPDFMarkusLink);
34
            FinalPDFMarkusLinkCommand = new DelegateCommand(FinalPDFMarkusLink);
35
            ConvertPathFileSearchCommand = new DelegateCommand(ConvertPathFileSearch);
36
        }
37

    
38
        #endregion
39

    
40
        #region Properties
41

    
42
        DataService.DataServiceClient WcfClient = new DataService.DataServiceClient();
43

    
44
        static DateTime DefaultCreateTime = DateTime.Now;
45
        private DateTime _SelectedCreateTimeBegin = DefaultCreateTime;
46
        public DateTime SelectedCreateTimeBegin
47
        {
48

    
49
            get { return _SelectedCreateTimeBegin; }
50
            set
51
            {
52
                if (_SelectedCreateTimeBegin == value)
53
                    return;
54
                _SelectedCreateTimeBegin = value;
55
                OnPropertyChanged(() => SelectedCreateTimeBegin);
56

    
57
            }
58
        }
59

    
60
        private DateTime _SelectedCreateTimeEnd = DefaultCreateTime;
61
        public DateTime SelectedCreateTimeEnd
62
        {
63

    
64
            get { return _SelectedCreateTimeEnd; }
65
            set
66
            {
67
                if (_SelectedCreateTimeEnd == value)
68
                    return;
69
                _SelectedCreateTimeEnd = value;
70
                OnPropertyChanged(() => SelectedCreateTimeEnd);
71
            }
72
        }
73

    
74
        private SelectedCountItem _SelectedCount;
75
        public SelectedCountItem SelectedCount
76
        {
77
            get => _SelectedCount;
78
            set
79
            {
80
                _SelectedCount = value;
81
                OnPropertyChanged(() => SelectedCount);
82
            }
83
        }
84

    
85
        List<SelectedCountItem> _SelectedCountList;
86
        public List<SelectedCountItem> SelectedCountList
87
        {
88
            get
89
            {
90
                if (_SelectedCountList == null)
91
                {
92
                    _SelectedCountList = new List<SelectedCountItem>
93
                    {
94
                        new SelectedCountItem{DisplayMember = "50",ValueMember = 50},
95
                        new SelectedCountItem{DisplayMember = "100",ValueMember = 100},
96
                        new SelectedCountItem{DisplayMember = "150",ValueMember = 150},
97
                        new SelectedCountItem{DisplayMember = "200",ValueMember = 200}
98
                    };
99
                }
100

    
101
                return _SelectedCountList;
102
            }
103
        }
104

    
105
        private ObservableCollection<ConvertCOUNT> _ConvertCOUNTDashBoard;
106
        public ObservableCollection<ConvertCOUNT> ConvertCOUNTDashBoard
107
        {
108
            get
109
            {
110
                if (_ConvertCOUNTDashBoard == null)
111
                {
112
                    _ConvertCOUNTDashBoard = new ObservableCollection<ConvertCOUNT>();
113
                }
114
                return _ConvertCOUNTDashBoard;
115
            }
116
            set
117
            {
118
                if (_ConvertCOUNTDashBoard != value)
119
                {
120
                    _ConvertCOUNTDashBoard = value;
121
                    OnPropertyChanged(() => ConvertCOUNTDashBoard);
122
                }
123
            }
124
        }
125

    
126
        private ObservableCollection<FinalPDFCOUNT> _FinalPDFCOUNTDashBoard;
127
        public ObservableCollection<FinalPDFCOUNT> FinalPDFCOUNTDashBoard
128
        {
129
            get
130
            {
131
                if (_FinalPDFCOUNTDashBoard == null)
132
                {
133
                    _FinalPDFCOUNTDashBoard = new ObservableCollection<FinalPDFCOUNT>();
134
                }
135
                return _FinalPDFCOUNTDashBoard;
136
            }
137
            set
138
            {
139
                if (_FinalPDFCOUNTDashBoard != value)
140
                {
141
                    _FinalPDFCOUNTDashBoard = value;
142
                    OnPropertyChanged(() => FinalPDFCOUNTDashBoard);
143
                }
144
            }
145
        }
146

    
147
        private Telerik.Windows.Data.EnumMemberViewModel _SelectedStatus;
148
        public Telerik.Windows.Data.EnumMemberViewModel SelectedStatus
149
        {
150
            get => _SelectedStatus;
151
            set
152
            {
153
                _SelectedStatus = value;
154
                OnPropertyChanged(() => SelectedStatus);
155
            }
156
        }
157

    
158
        IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> _StatusCodeList;
159
        public IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> StatusCodeList
160
        {
161
            get
162
            {
163
                if (_StatusCodeList == null)
164
                {
165
                    _StatusCodeList = Telerik.Windows.Data.EnumDataSource.FromType<ConvertPDF.StatusCodeType>();
166
                }
167

    
168
                return _StatusCodeList;
169
            }
170
        }
171

    
172
        public ICollectionView DashBoard_Convert
173
        {
174
            get
175
            {
176
                var view = CollectionViewSource.GetDefaultView(ConvertView);
177
                return view;
178
            }
179
        }
180

    
181
        private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _ConvertView;
182
        public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> ConvertView
183
        {
184
            get
185
            {
186
                if (_ConvertView == null)
187
                {
188
                    _ConvertView = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
189
                }
190
                return _ConvertView;
191
            }
192
            set
193
            {
194
                _ConvertView = value;
195
                OnPropertyChanged(() => ConvertView);
196
            }
197
        }
198

    
199
        public ICollectionView DashBoard_FinalPDF
200
        {
201
            get
202
            {
203
                var view = CollectionViewSource.GetDefaultView(FinalPDFView);
204
                return view;
205
            }
206
        }
207

    
208
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _FinalPDFView;
209
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> FinalPDFView
210
        {
211
            get
212
            {
213
                if (_FinalPDFView == null)
214
                {
215
                    _FinalPDFView = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
216
                }
217
                return _FinalPDFView;
218
            }
219
            set
220
            {
221
                _FinalPDFView = value;
222
                OnPropertyChanged(() => FinalPDFView);
223
            }
224
        }
225

    
226
        private ObservableCollection<FinalPDF> _SelectedFinalPDFList;
227
        public ObservableCollection<FinalPDF> SelectedFinalPDFList
228
        {
229
            get
230
            {
231
                if (_SelectedFinalPDFList == null)
232
                {
233
                    _SelectedFinalPDFList = new ObservableCollection<FinalPDF>();
234
                }
235
                return _SelectedFinalPDFList;
236
            }
237
            set
238
            {
239
                _SelectedFinalPDFList = value;
240
                OnPropertyChanged(() => SelectedFinalPDFList);
241
            }
242
        }
243

    
244
        private ObservableCollection<ConvertPDF> _SelectedConvertList;
245
        public ObservableCollection<ConvertPDF> SelectedConvertList
246
        {
247
            get
248
            {
249
                if (_SelectedConvertList == null)
250
                {
251
                    _SelectedConvertList = new ObservableCollection<ConvertPDF>();
252
                }
253
                return _SelectedConvertList;
254
            }
255
            set
256
            {
257
                _SelectedConvertList = value;
258
                OnPropertyChanged(() => SelectedConvertList);
259
            }
260
        }
261
        #endregion
262

    
263
        #region Command
264

    
265
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
266
        public DelegateCommand ConvertPDFMarkusLinkCommand { get; private set; }
267
        public DelegateCommand FinalPDFMarkusLinkCommand { get; private set; }
268
        public DelegateCommand ConvertPathFileSearchCommand { get; private set; }
269

    
270
        #endregion
271

    
272
        #region Main Logic
273

    
274
        /// <summary>
275
        /// 각각의 Grid row 객체들 업데이트
276
        /// </summary>
277

    
278
        private DispatcherTimer dispatcherTimer;
279
        public override void Loaded()
280
        {
281
            base.Loaded();
282

    
283
            if (!App.IsDesignMode)
284
            {
285
                dispatcherTimer = new DispatcherTimer();
286
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
287
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
288
                dispatcherTimer.Start();
289
            }
290
        }
291

    
292
        private async void Timer_Tick(object sender, EventArgs e)
293
        {
294
            dispatcherTimer.Stop();
295

    
296
            if (IsAcitve)
297
            {
298
                await App.Current.Dispatcher.InvokeAsync(() =>
299
                {
300
                    DataSelect();
301
                });
302
            }
303

    
304
            await Task.Delay(10000);
305

    
306
            dispatcherTimer.Start();
307
        }
308

    
309
        public override void Closed()
310
        {
311
            if (dispatcherTimer != null)
312
            {
313
                dispatcherTimer.Stop();
314
            }
315

    
316
            base.Closed();
317
        }
318

    
319

    
320
        #endregion
321

    
322
        #region Function
323

    
324
        #region ConvertPathFileSearch
325

    
326
        /// <summary>
327
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
328
        /// </summary>
329

    
330
        public void ConvertPathFileSearch(object obj)
331
        {
332
            if (obj is ConvertPDF)
333
            {
334
                if (obj != null)
335
                {
336
                    var convertitem = obj as ConvertPDF;
337

    
338
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
339
                    {
340
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
341
                    }
342
                }
343
            }
344
        }
345

    
346
        #endregion
347

    
348
        #region FinalPDFPathFileSearch
349

    
350
        /// <summary>
351
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
352
        /// </summary>
353

    
354
        public void FinalPDFPathFileSearch(object obj)
355
        {
356
            if (obj is FinalPDF)
357
            {
358
                if (obj != null)
359
                {
360
                    var convertitem = obj as FinalPDF;
361

    
362
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
363

    
364
                    saveFileDialog.FileName = "Document"; // Default file name
365
                    saveFileDialog.DefaultExt = ".txt"; // Default file extension
366
                    saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension
367

    
368

    
369
                    if (saveFileDialog.ShowDialog() == true)
370
                    {
371
                    }
372
                }
373
            }
374
        }
375

    
376
        #endregion
377

    
378
        #region MarkusLink
379

    
380
        private void ConvertPDFMarkusLink(object obj)
381
        {
382
            if (obj is ConvertPDF)
383
            {
384

    
385
                if (obj != null)
386
                {
387
                    var convertitem = obj as ConvertPDF;
388

    
389
                    SelectedConvertList.Add(convertitem);
390

    
391
                    ProcessStartInfo startInfo = null;
392

    
393
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
394

    
395
                    Process.Start(startInfo);
396
                }
397

    
398
            }
399
        }
400

    
401
        private void FinalPDFMarkusLink(object obj)
402
        {
403
            if (obj is FinalPDF)
404
            {
405

    
406
                if (obj != null)
407
                {
408
                    var convertitem = obj as FinalPDF;
409

    
410
                    SelectedFinalPDFList.Add(convertitem);
411

    
412
                    ProcessStartInfo startInfo = null;
413

    
414
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
415

    
416
                    Process.Start(startInfo);
417
                }
418

    
419
            }
420
        }
421

    
422
        #endregion
423

    
424

    
425
        #region RemoveCreateTimeFilter
426

    
427
        public void RemoveCreateTimeFilter(object obj)
428
        {
429
            DefaultCreateTime = DateTime.Now;
430
            SelectedCreateTimeBegin = DefaultCreateTime;
431
            SelectedCreateTimeEnd = DefaultCreateTime;
432
        }
433

    
434
        #endregion
435

    
436

    
437
        #region Data Select
438

    
439
        /// <summary>
440
        /// 상단 그리드 중앙 그리드 출력 데이터
441
        /// </summary>
442
        private void DataSelect()
443
        {
444
            if (ConvertView == null)
445
            {
446
               ConvertView = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
447
            }
448

    
449
            ConvertView_DataSelect(new[] { (ConvertPDF.StatusCodeType)(SelectedStatus.Value) }, ConvertView);
450

    
451
            if (FinalPDFView == null)
452
            {
453
                FinalPDFView = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
454
            }
455

    
456
            FinalPDFView_DataSelect(new[] { (FinalPDF.StatusCodeType)(SelectedStatus.Value) }, FinalPDFView);
457

    
458
            if (ConvertCOUNTDashBoard == null)
459
            {
460
                ConvertCOUNTDashBoard = new ObservableCollection<ConvertCOUNT>();
461
            }
462
            if(FinalPDFCOUNTDashBoard == null)
463
            {
464
                FinalPDFCOUNTDashBoard = new ObservableCollection<FinalPDFCOUNT>();
465
            }
466

    
467
            if (SelectedStatus != null)
468
            {
469
                ConvertDataSelect(new[] { (ConvertPDF.StatusCodeType)(SelectedStatus.Value) }, ConvertCOUNTDashBoard);
470
                FinalPDFDataSelect(new[] { (FinalPDF.StatusCodeType)(SelectedStatus.Value) }, FinalPDFCOUNTDashBoard);
471
            }
472
        }
473

    
474
        private async void FinalPDFView_DataSelect(IEnumerable<FinalPDF.StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection)
475
        {
476
            try
477
            {
478
                int _status = 0;
479
                if (SelectedStatus != null)
480
                {
481
                    _status = (int)SelectedStatus.Value;
482
                }
483

    
484
                var Listitems = from x in await WcfClient.GET_SELECT_FINAL_PDF_ITEMAsync(null, null, null, null, null, null, null, null, _status, 5, null, null, null, null, null, null, null, null, null, null)
485
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
486
                                select new FinalPDF(x.ID, x.PROJECT_NO, x.STATUS, x.DOCUMENT_ID, x.MARKUPINFO_ID, x.DOCINFO_ID, x.DOCUMENT_NAME, x.DOCUMENT_NO, x.CREATE_USER_ID,
487
                        x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
488
                     , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
489

    
490
                if (collection.Count() == 0)
491
                {
492
                    if (statusCodeTypeList.Count() == 1)
493
                    {
494
                        foreach (var x in Listitems)
495
                        {
496
                            collection.Add(x);
497
                        }
498
                    }
499
                }
500
                else
501
                {
502
                    foreach (var newitem in Listitems)
503
                    {
504
                        collection.UpdateWhere(changeitem =>
505
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
506
                    }
507

    
508
                    if (statusCodeTypeList.Count() == 1)
509
                    {
510
                        for (int i = collection.Count() - 1; i >= 0; --i)
511
                        {
512
                            var item = collection[i];
513

    
514
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
515
                            {
516
                                collection.RemoveAt(i);
517
                            }
518
                        }
519
                    }
520

    
521
                    if (statusCodeTypeList.Count() == 1)
522
                    {
523
                        foreach (var item in Listitems)
524
                        {
525
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
526
                            {
527
                                for (int i = 0; i < 5; i++)
528
                                {
529
                                    if (i < collection.Count() - 1)
530
                                    {
531
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
532
                                        {
533
                                            collection.Insert(i, item);
534
                                            break;
535
                                        }
536
                                    }
537
                                    else
538
                                    {
539
                                        collection.Add(item);
540
                                        break;
541
                                    }
542
                                }
543

    
544
                            }
545

    
546
                        }
547
                    }
548
                }
549
            }
550
            catch (Exception ex)
551
            {
552
                MessageBox.Show(ex.ToString());
553
                System.Diagnostics.Debug.WriteLine(ex.ToString());
554
            }
555
        }
556

    
557
        private async void ConvertView_DataSelect(IEnumerable<ConvertPDF.StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
558
        {
559
            try
560
            {
561
                int _status = 0;
562
                if (SelectedStatus != null)
563
                {
564
                    _status = (int)SelectedStatus.Value;
565
                }
566

    
567
                var Listitems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(null, null, null, _status, 5, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
568
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
569
                                select new ConvertPDF(num.SERVICE_ID, num.ID, num.PROJECT_NO, num.STATUS, num.DOCUMENT_ID, num.DOCUMENT_NAME, num.DOCUMENT_NO, num.DOCUMENT_URL, num.REVISION, num.CURRENT_PAGE,
570
                                                        num.TOTAL_PAGE, num.EXCEPTION, num.GROUP_NO, num.CREATE_DATETIME, num.START_DATETIME, num.END_DATETIME, num.DOCUMENT_URL, num.CONVERT_PATH, MarkusLink, num.RECONVERTER);
571

    
572
                if (collection.Count() == 0)
573
                {
574
                    if (statusCodeTypeList.Count() == 1)
575
                    {
576
                        foreach (var Listitem in Listitems.ToList())
577
                        {
578
                            collection.Add(Listitem);
579
                        }
580
                    }
581
                }
582
                else
583
                {
584
                    foreach (var Listitem in Listitems)
585
                    {
586
                        collection.UpdateWhere(changeitem =>
587
                        ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
588
                    }
589
                    if (statusCodeTypeList.Count() == 1)
590
                    {
591
                        for (int i = collection.Count() - 1; i >= 0; --i)
592
                        {
593
                            var item = collection[i];
594

    
595
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
596
                            {
597
                                collection.RemoveAt(i);
598
                            }
599
                        }
600
                    }
601

    
602
                    if (statusCodeTypeList.Count() == 1)
603
                    {
604
                        foreach (var item in Listitems)
605
                        {
606
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
607
                            {
608
                                for (int i = 0; i < 5; i++)
609
                                {
610
                                    if (i < collection.Count() - 1)
611
                                    {
612
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
613
                                        {
614
                                            collection.Insert(i, item);
615
                                            break;
616
                                        }
617
                                    }
618
                                    else
619
                                    {
620
                                        collection.Add(item);
621
                                        break;
622
                                    }
623
                                }
624

    
625
                            }
626

    
627
                        }
628
                    }
629
                }
630
            }
631
            catch (Exception ex)
632
            {
633
                MessageBox.Show(ex.ToString());
634
            }
635
        }
636

    
637
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
638
        {
639
            ViewInfo viewInfo = new ViewInfo();
640

    
641
            viewInfo.DocumentItemID = documentID;
642
            viewInfo.ProjectNO = projectNo;
643
            viewInfo.UserID = userID;
644

    
645
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
646

    
647
        }
648

    
649
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
650
        {
651

    
652
            if (oEncoding == null)
653
                oEncoding = System.Text.Encoding.UTF8;
654

    
655
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
656

    
657
        }
658

    
659
        private async void ConvertDataSelect(IEnumerable<ConvertPDF.StatusCodeType> statusCodeTypeList, ObservableCollection<ConvertCOUNT> collection)
660
        {
661
            try
662
            {
663
                int _status = 0;
664
                if (SelectedStatus != null)
665
                {
666
                    _status = (int)SelectedStatus.Value;
667
                }
668

    
669
                DateTime? Start_CreateTime = null;
670
                DateTime? Finish_CreateTime = null;
671
                if (SelectedCreateTimeBegin != DefaultCreateTime)
672
                {
673
                    Start_CreateTime = SelectedCreateTimeBegin;
674
                }
675
                if (SelectedCreateTimeEnd != DefaultCreateTime)
676
                {
677
                    Finish_CreateTime = SelectedCreateTimeEnd;
678
                }
679

    
680
                var Listitems = from num in await WcfClient.GET_CONVERT_COUNTAsync(_status, Start_CreateTime, Finish_CreateTime)
681
                            select new ConvertCOUNT(num.PROJECT_NO, num.COUNT.Value, num.EXCEPTION_COUNT.Value);
682

    
683
                if (collection.Count() == 0)
684
                {
685
                    if (statusCodeTypeList.Count() == 1)
686
                    {
687
                        foreach (var x in Listitems)
688
                        {
689
                            collection.Add(x);
690
                        }
691
                    }
692
                }
693
                else
694
                {
695
                    foreach (var newitem in Listitems)
696
                    {
697
                        collection.UpdateWhere(changeitem =>
698
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.Project_NO == newitem.Project_NO && x.Count == newitem.Count);
699
                    }
700

    
701

    
702
                    if (statusCodeTypeList.Count() == 1)
703
                    {
704

    
705
                        for (int i = collection.Count() - 1; i >= 0; --i)
706
                        {
707
                            var item = collection[i];
708

    
709
                            if (Listitems.Count(x => x.Project_NO == item.Project_NO && x.Count == item.Count) == 0)
710
                            {
711
                                collection.RemoveAt(i);
712
                            }
713
                        }
714
                    }
715

    
716
                    if (statusCodeTypeList.Count() == 1)
717
                    {
718
                        foreach (var item in Listitems)
719
                        {
720
                            if (collection.Count(x => x.Project_NO == item.Project_NO && x.Count == item.Count) == 0)
721
                            {
722
                                for (int i = 0; i < 200; i++)
723
                                {
724
                                    collection.Add(item);
725
                                    break;
726
                                }
727
                            }
728
                        }
729
                    }
730
                }
731

    
732
            }
733
            catch (Exception ex)
734
            {
735
                MessageBox.Show(ex.ToString());
736
            }
737
        }
738

    
739
        private async void FinalPDFDataSelect(IEnumerable<FinalPDF.StatusCodeType> statusCodeTypeList, ObservableCollection<FinalPDFCOUNT> collection)
740
        {
741
            try
742
            {
743

    
744
                int _status = 0;
745
                if (SelectedStatus != null)
746
                {
747
                    _status = (int)SelectedStatus.Value;
748
                }
749

    
750
                DateTime? Start_CreateTime = null;
751
                DateTime? Finish_CreateTime = null;
752
                if (SelectedCreateTimeBegin != DefaultCreateTime)
753
                {
754
                    Start_CreateTime = SelectedCreateTimeBegin;
755
                }
756
                if (SelectedCreateTimeEnd != DefaultCreateTime)
757
                {
758
                    Finish_CreateTime = SelectedCreateTimeEnd;
759
                }
760

    
761
                var Listitems = from num in await WcfClient.GET_FINALPDF_COUNTAsync(_status, Start_CreateTime, Finish_CreateTime)
762
                                select new FinalPDFCOUNT(num.PROJECT_NO, num.COUNT.Value, num.EXCEPTION_COUNT.Value);
763

    
764
                if (collection.Count() == 0)
765
                {
766
                    if (statusCodeTypeList.Count() == 1)
767
                    {
768
                        foreach (var x in Listitems)
769
                        {
770
                            collection.Add(x);
771
                        }
772
                    }
773
                }
774
                else
775
                {
776
                    foreach (var newitem in Listitems)
777
                    {
778
                        collection.UpdateWhere(changeitem =>
779
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.Project_NO == newitem.Project_NO && x.Count == newitem.Count);
780
                    }
781

    
782

    
783
                    if (statusCodeTypeList.Count() == 1)
784
                    {
785
                        for (int i = collection.Count() - 1; i >= 0; --i)
786
                        {
787
                            var item = collection[i];
788

    
789
                            if (Listitems.Count(x => x.Project_NO == item.Project_NO && x.Count == item.Count) == 0)
790
                            {
791
                                collection.RemoveAt(i);
792
                            }
793
                        }
794
                    }
795

    
796
                    if (statusCodeTypeList.Count() == 1)
797
                    {
798
                        foreach (var item in Listitems)
799
                        {
800
                            if (collection.Count(x => x.Project_NO == item.Project_NO && x.Count == item.Count) == 0)
801
                            {
802
                                for (int i = 0; i < 200; i++)
803
                                {
804
                                    collection.Add(item);
805
                                    break;
806
                                }
807
                            }
808
                        }
809
                    }
810

    
811
                }
812
            }
813
            catch (Exception ex)
814
            {
815
                MessageBox.Show(ex.ToString());
816
            }
817
        }
818
        #endregion
819

    
820
        #endregion
821
    }
822
}
823

    
824
public class NameValidator : ValidationRule
825
{
826
    public override ValidationResult Validate
827
      (object value, System.Globalization.CultureInfo cultureInfo)
828
    {
829
        if (value == null)
830
            return new ValidationResult(false, "value cannot be empty.");
831
        else
832
        {
833
            if (value.ToString().Length > 3)
834
                return new ValidationResult
835
                (false, "Name cannot be more than 3 characters long.");
836
        }
837
        return ValidationResult.ValidResult;
838
    }
839
}
클립보드 이미지 추가 (최대 크기: 500 MB)