프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceController / Markus.Service.StationController / ViewModel / DashBoardViewModel.cs @ 5c387707

이력 | 보기 | 이력해설 | 다운로드 (27.8 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 FinalPDF _SelectedFinalPDF;
227
        public FinalPDF SelectedFinalPDF
228
        {
229
            get
230
            { 
231
                return _SelectedFinalPDF;
232
            }
233
            set
234
            {
235
                _SelectedFinalPDF = value;
236
                OnPropertyChanged(() => SelectedFinalPDF);
237
            }
238
        }
239

    
240
        private ConvertPDF _SelectedConvert;
241
        public ConvertPDF SelectedConvert
242
        {
243
            get => _SelectedConvert;
244
            set
245
            {
246
                _SelectedConvert = value;
247
                OnPropertyChanged(() => SelectedConvert);
248
            }
249
        }
250
        #endregion
251

    
252
        #region Command
253

    
254
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
255
        public DelegateCommand ConvertPDFMarkusLinkCommand { get; private set; }
256
        public DelegateCommand FinalPDFMarkusLinkCommand { get; private set; }
257
        public DelegateCommand ConvertPathFileSearchCommand { get; private set; }
258

    
259
        #endregion
260

    
261
        #region Main Logic
262

    
263
        /// <summary>
264
        /// 각각의 Grid row 객체들 업데이트
265
        /// </summary>
266

    
267
        private DispatcherTimer dispatcherTimer;
268
        public override void Loaded()
269
        {
270
            base.Loaded();
271

    
272
            if (!App.IsDesignMode)
273
            {
274
                dispatcherTimer = new DispatcherTimer();
275
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
276
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
277
                dispatcherTimer.Start();
278
            }
279
        }
280

    
281
        private async void Timer_Tick(object sender, EventArgs e)
282
        {
283
            dispatcherTimer.Stop();
284

    
285
            if (IsAcitve)
286
            {
287
                await App.Current.Dispatcher.InvokeAsync(() =>
288
                {
289
                    DataSelect();
290
                });
291
            }
292

    
293
            await Task.Delay(10000);
294

    
295
            dispatcherTimer.Start();
296
        }
297

    
298
        public override void Closed()
299
        {
300
            if (dispatcherTimer != null)
301
            {
302
                dispatcherTimer.Stop();
303
            }
304

    
305
            base.Closed();
306
        }
307

    
308

    
309
        #endregion
310

    
311
        #region Function
312

    
313
        #region ConvertPathFileSearch
314

    
315
        /// <summary>
316
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
317
        /// </summary>
318

    
319
        public void ConvertPathFileSearch(object obj)
320
        {
321
            if (obj is ConvertPDF)
322
            {
323
                if (obj != null)
324
                {
325
                    var convertitem = obj as ConvertPDF;
326

    
327
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
328
                    {
329
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
330
                    }
331
                }
332
            }
333
        }
334

    
335
        #endregion
336

    
337
        #region FinalPDFPathFileSearch
338

    
339
        /// <summary>
340
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
341
        /// </summary>
342

    
343
        public void FinalPDFPathFileSearch(object obj)
344
        {
345
            if (obj is FinalPDF)
346
            {
347
                if (obj != null)
348
                {
349
                    var convertitem = obj as FinalPDF;
350

    
351
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
352

    
353
                    saveFileDialog.FileName = "Document"; // Default file name
354
                    saveFileDialog.DefaultExt = ".txt"; // Default file extension
355
                    saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension
356

    
357

    
358
                    if (saveFileDialog.ShowDialog() == true)
359
                    {
360
                    }
361
                }
362
            }
363
        }
364

    
365
        #endregion
366

    
367
        #region MarkusLink
368

    
369
        private void ConvertPDFMarkusLink(object obj)
370
        {
371
            if (obj is ConvertPDF)
372
            {
373

    
374
                if (obj != null)
375
                {
376
                    var convertitem = obj as ConvertPDF;
377

    
378
                    SelectedConvert = convertitem;
379

    
380
                    ProcessStartInfo startInfo = null;
381

    
382
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
383

    
384
                    Process.Start(startInfo);
385
                }
386

    
387
            }
388
        }
389

    
390
        private void FinalPDFMarkusLink(object obj)
391
        {
392
            if (obj is FinalPDF)
393
            {
394

    
395
                if (obj != null)
396
                {
397
                    var convertitem = obj as FinalPDF;
398

    
399
                    SelectedFinalPDF = convertitem;
400

    
401
                    ProcessStartInfo startInfo = null;
402

    
403
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
404

    
405
                    Process.Start(startInfo);
406
                }
407

    
408
            }
409
        }
410

    
411
        #endregion
412

    
413

    
414
        #region RemoveCreateTimeFilter
415

    
416
        public void RemoveCreateTimeFilter(object obj)
417
        {
418
            DefaultCreateTime = DateTime.Now;
419
            SelectedCreateTimeBegin = DefaultCreateTime;
420
            SelectedCreateTimeEnd = DefaultCreateTime;
421
        }
422

    
423
        #endregion
424

    
425

    
426
        #region Data Select
427

    
428
        /// <summary>
429
        /// 상단 그리드 중앙 그리드 출력 데이터
430
        /// </summary>
431
        private void DataSelect()
432
        {
433
            if (ConvertView == null)
434
            {
435
               ConvertView = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
436
            }
437

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

    
440
            if (FinalPDFView == null)
441
            {
442
                FinalPDFView = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
443
            }
444

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

    
447
            if (ConvertCOUNTDashBoard == null)
448
            {
449
                ConvertCOUNTDashBoard = new ObservableCollection<ConvertCOUNT>();
450
            }
451
            if(FinalPDFCOUNTDashBoard == null)
452
            {
453
                FinalPDFCOUNTDashBoard = new ObservableCollection<FinalPDFCOUNT>();
454
            }
455

    
456
            if (SelectedStatus != null)
457
            {
458
                ConvertDataSelect(new[] { (ConvertPDF.StatusCodeType)(SelectedStatus.Value) }, ConvertCOUNTDashBoard);
459
                FinalPDFDataSelect(new[] { (FinalPDF.StatusCodeType)(SelectedStatus.Value) }, FinalPDFCOUNTDashBoard);
460
            }
461
        }
462

    
463
        private async void FinalPDFView_DataSelect(IEnumerable<FinalPDF.StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection)
464
        {
465
            try
466
            {
467
                int _status = 0;
468
                if (SelectedStatus != null)
469
                {
470
                    _status = (int)SelectedStatus.Value;
471
                }
472

    
473
                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)
474
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
475
                                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,
476
                        x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
477
                     , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
478

    
479
                if (collection.Count() == 0)
480
                {
481
                    if (statusCodeTypeList.Count() == 1)
482
                    {
483
                        foreach (var x in Listitems)
484
                        {
485
                            collection.Add(x);
486
                        }
487
                    }
488
                }
489
                else
490
                {
491
                    foreach (var newitem in Listitems)
492
                    {
493
                        collection.UpdateWhere(changeitem =>
494
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
495
                    }
496

    
497
                    if (statusCodeTypeList.Count() == 1)
498
                    {
499
                        for (int i = collection.Count() - 1; i >= 0; --i)
500
                        {
501
                            var item = collection[i];
502

    
503
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
504
                            {
505
                                collection.RemoveAt(i);
506
                            }
507
                        }
508
                    }
509

    
510
                    if (statusCodeTypeList.Count() == 1)
511
                    {
512
                        foreach (var item in Listitems)
513
                        {
514
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
515
                            {
516
                                for (int i = 0; i < 5; i++)
517
                                {
518
                                    if (i < collection.Count() - 1)
519
                                    {
520
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
521
                                        {
522
                                            collection.Insert(i, item);
523
                                            break;
524
                                        }
525
                                    }
526
                                    else
527
                                    {
528
                                        collection.Add(item);
529
                                        break;
530
                                    }
531
                                }
532

    
533
                            }
534

    
535
                        }
536
                    }
537
                }
538
            }
539
            catch (Exception ex)
540
            {
541
                MessageBox.Show(ex.ToString());
542
                System.Diagnostics.Debug.WriteLine(ex.ToString());
543
            }
544
        }
545

    
546
        private async void ConvertView_DataSelect(IEnumerable<ConvertPDF.StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
547
        {
548
            try
549
            {
550
                int _status = 0;
551
                if (SelectedStatus != null)
552
                {
553
                    _status = (int)SelectedStatus.Value;
554
                }
555

    
556
                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)
557
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
558
                                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,
559
                                                        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);
560

    
561
                if (collection.Count() == 0)
562
                {
563
                    if (statusCodeTypeList.Count() == 1)
564
                    {
565
                        foreach (var Listitem in Listitems.ToList())
566
                        {
567
                            collection.Add(Listitem);
568
                        }
569
                    }
570
                }
571
                else
572
                {
573
                    foreach (var Listitem in Listitems)
574
                    {
575
                        collection.UpdateWhere(changeitem =>
576
                        ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
577
                    }
578
                    if (statusCodeTypeList.Count() == 1)
579
                    {
580
                        for (int i = collection.Count() - 1; i >= 0; --i)
581
                        {
582
                            var item = collection[i];
583

    
584
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
585
                            {
586
                                collection.RemoveAt(i);
587
                            }
588
                        }
589
                    }
590

    
591
                    if (statusCodeTypeList.Count() == 1)
592
                    {
593
                        foreach (var item in Listitems)
594
                        {
595
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
596
                            {
597
                                for (int i = 0; i < 5; i++)
598
                                {
599
                                    if (i < collection.Count() - 1)
600
                                    {
601
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
602
                                        {
603
                                            collection.Insert(i, item);
604
                                            break;
605
                                        }
606
                                    }
607
                                    else
608
                                    {
609
                                        collection.Add(item);
610
                                        break;
611
                                    }
612
                                }
613

    
614
                            }
615

    
616
                        }
617
                    }
618
                }
619
            }
620
            catch (Exception ex)
621
            {
622
                MessageBox.Show(ex.ToString());
623
            }
624
        }
625

    
626
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
627
        {
628
            ViewInfo viewInfo = new ViewInfo();
629

    
630
            viewInfo.DocumentItemID = documentID;
631
            viewInfo.ProjectNO = projectNo;
632
            viewInfo.UserID = userID;
633

    
634
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
635

    
636
        }
637

    
638
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
639
        {
640

    
641
            if (oEncoding == null)
642
                oEncoding = System.Text.Encoding.UTF8;
643

    
644
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
645

    
646
        }
647

    
648
        private async void ConvertDataSelect(IEnumerable<ConvertPDF.StatusCodeType> statusCodeTypeList, ObservableCollection<ConvertCOUNT> collection)
649
        {
650
            try
651
            {
652
                int _status = 0;
653
                if (SelectedStatus != null)
654
                {
655
                    _status = (int)SelectedStatus.Value;
656
                }
657

    
658
                DateTime? Start_CreateTime = null;
659
                DateTime? Finish_CreateTime = null;
660
                if (SelectedCreateTimeBegin != DefaultCreateTime)
661
                {
662
                    Start_CreateTime = SelectedCreateTimeBegin;
663
                }
664
                if (SelectedCreateTimeEnd != DefaultCreateTime)
665
                {
666
                    Finish_CreateTime = SelectedCreateTimeEnd;
667
                }
668

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

    
672
                if (collection.Count() == 0)
673
                {
674
                    if (statusCodeTypeList.Count() == 1)
675
                    {
676
                        foreach (var x in Listitems)
677
                        {
678
                            collection.Add(x);
679
                        }
680
                    }
681
                }
682
                else
683
                {
684
                    foreach (var newitem in Listitems)
685
                    {
686
                        collection.UpdateWhere(changeitem =>
687
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.Project_NO == newitem.Project_NO && x.Count == newitem.Count);
688
                    }
689

    
690

    
691
                    if (statusCodeTypeList.Count() == 1)
692
                    {
693

    
694
                        for (int i = collection.Count() - 1; i >= 0; --i)
695
                        {
696
                            var item = collection[i];
697

    
698
                            if (Listitems.Count(x => x.Project_NO == item.Project_NO && x.Count == item.Count) == 0)
699
                            {
700
                                collection.RemoveAt(i);
701
                            }
702
                        }
703
                    }
704

    
705
                    if (statusCodeTypeList.Count() == 1)
706
                    {
707
                        foreach (var item in Listitems)
708
                        {
709
                            if (collection.Count(x => x.Project_NO == item.Project_NO && x.Count == item.Count) == 0)
710
                            {
711
                                for (int i = 0; i < 200; i++)
712
                                {
713
                                    collection.Add(item);
714
                                    break;
715
                                }
716
                            }
717
                        }
718
                    }
719
                }
720

    
721
            }
722
            catch (Exception ex)
723
            {
724
                MessageBox.Show(ex.ToString());
725
            }
726
        }
727

    
728
        private async void FinalPDFDataSelect(IEnumerable<FinalPDF.StatusCodeType> statusCodeTypeList, ObservableCollection<FinalPDFCOUNT> collection)
729
        {
730
            try
731
            {
732

    
733
                int _status = 0;
734
                if (SelectedStatus != null)
735
                {
736
                    _status = (int)SelectedStatus.Value;
737
                }
738

    
739
                DateTime? Start_CreateTime = null;
740
                DateTime? Finish_CreateTime = null;
741
                if (SelectedCreateTimeBegin != DefaultCreateTime)
742
                {
743
                    Start_CreateTime = SelectedCreateTimeBegin;
744
                }
745
                if (SelectedCreateTimeEnd != DefaultCreateTime)
746
                {
747
                    Finish_CreateTime = SelectedCreateTimeEnd;
748
                }
749

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

    
753
                if (collection.Count() == 0)
754
                {
755
                    if (statusCodeTypeList.Count() == 1)
756
                    {
757
                        foreach (var x in Listitems)
758
                        {
759
                            collection.Add(x);
760
                        }
761
                    }
762
                }
763
                else
764
                {
765
                    foreach (var newitem in Listitems)
766
                    {
767
                        collection.UpdateWhere(changeitem =>
768
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.Project_NO == newitem.Project_NO && x.Count == newitem.Count);
769
                    }
770

    
771

    
772
                    if (statusCodeTypeList.Count() == 1)
773
                    {
774
                        for (int i = collection.Count() - 1; i >= 0; --i)
775
                        {
776
                            var item = collection[i];
777

    
778
                            if (Listitems.Count(x => x.Project_NO == item.Project_NO && x.Count == item.Count) == 0)
779
                            {
780
                                collection.RemoveAt(i);
781
                            }
782
                        }
783
                    }
784

    
785
                    if (statusCodeTypeList.Count() == 1)
786
                    {
787
                        foreach (var item in Listitems)
788
                        {
789
                            if (collection.Count(x => x.Project_NO == item.Project_NO && x.Count == item.Count) == 0)
790
                            {
791
                                for (int i = 0; i < 200; i++)
792
                                {
793
                                    collection.Add(item);
794
                                    break;
795
                                }
796
                            }
797
                        }
798
                    }
799

    
800
                }
801
            }
802
            catch (Exception ex)
803
            {
804
                MessageBox.Show(ex.ToString());
805
            }
806
        }
807
        #endregion
808

    
809
        #endregion
810
    }
811
}
812

    
813
public class NameValidator : ValidationRule
814
{
815
    public override ValidationResult Validate
816
      (object value, System.Globalization.CultureInfo cultureInfo)
817
    {
818
        if (value == null)
819
            return new ValidationResult(false, "value cannot be empty.");
820
        else
821
        {
822
            if (value.ToString().Length > 3)
823
                return new ValidationResult
824
                (false, "Name cannot be more than 3 characters long.");
825
        }
826
        return ValidationResult.ValidResult;
827
    }
828
}
클립보드 이미지 추가 (최대 크기: 500 MB)