프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / FinalPDFViewModel.cs @ 6a19b48d

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

1 31beca73 semi
using Markus.Service.Extensions;
2 3bde451b semi
using Markus.Service.StationController.Data;
3
using Markus.Service.StationController.Behaviors;
4
using Markus.Service.StationController.Extensions;
5
using Markus.Service.StationController.Controls;
6
using Microsoft.Win32;
7
using System;
8
using System.Collections.Generic;
9
using System.ComponentModel;
10
using System.Linq;
11
using System.Threading.Tasks;
12
using System.Web;
13
using System.Windows;
14
using Telerik.Windows.Controls;
15
using Telerik.Windows.Data;
16
using System.Net;
17
using System.Windows.Threading;
18
using System.Diagnostics;
19
using System.Windows.Input;
20
using Markus.Mvvm.ToolKit;
21
using System.Windows.Data;
22
using System.Windows.Controls;
23
using System.IO;
24 2c634aed semi
using Newtonsoft.Json;
25 78683624 semi
using static Markus.Service.StationController.Data.FinalPDF;
26 037ab674 semi
using System.Collections.ObjectModel;
27 3bde451b semi
28
namespace Markus.Service.StationController.ViewModel
29
{
30
    class FinalPDFViewModel : Mvvm.ToolKit.ViewModelBase
31
    {
32
        #region Constructor
33
34
        /// <summary>
35
        /// 실행하면 처음 들어가는 부분
36
        /// </summary>
37
        public FinalPDFViewModel()
38
        {
39
            DataFilterCommand = new DelegateCommand(DataFilter);
40
            DataSaveFileGemBoxCommand = new DelegateCommand(DataExportData);
41
            ConvertCommand = new DelegateCommand(DataConvert);
42
            DeleteCommand = new DelegateCommand(DataDelete);
43
            ValidateCommand = new DelegateCommand(DataValidate);
44
            MarkusLinkCommand = new DelegateCommand(MarkusLink);
45
            RemoveCreateTimeFilterCommand = new DelegateCommand(RemoveCreateTimeFilter);
46
            ResetCommand = new DelegateCommand(Reset);
47
            ConverAddCommand = new DelegateCommand(ConverAdd);
48 95e7bd84 semi
            FinalPDFPathFileSearchCommand = new DelegateCommand(FinalPDFPathFileSearch);
49 f5ec88b8 semi
            Stop_ProcessCommand = new DelegateCommand(Stop_Process);
50 aaed7be2 semi
            EnterCommand = new DelegateCommand(Enter);
51 f047c8bf semi
            DocumentFilterCommand = new DelegateCommand(DocumentFilter);
52 3bde451b semi
        }
53
54
        #endregion
55
56
        #region Properties
57
58 037ab674 semi
        DataService.DataServiceClient WcfClient = new DataService.DataServiceClient();
59
60 19d6b221 semi
61
        private static System.Collections.ObjectModel.ObservableCollection<FinalPDF> _ConvertSource;
62
        public static System.Collections.ObjectModel.ObservableCollection<FinalPDF> ConvertSource
63
        {
64
            get
65
            {
66
                if (_ConvertSource == null)
67
                {
68
                    _ConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
69
                }
70
                return _ConvertSource;
71
            }
72
            set
73
            {
74
                _ConvertSource = value;
75
            }
76
        }
77
78 037ab674 semi
        public ObservableCollection<ProjectName> _ProjectNames;
79
        public ObservableCollection<ProjectName> ProjectNames
80
        {
81
            get
82
            {
83
                if (_ProjectNames == null)
84
                {
85
                    _ProjectNames = new System.Collections.ObjectModel.ObservableCollection<ProjectName>();
86
                }
87
88
                return _ProjectNames;
89
            }
90
            set
91
            {
92
                _ProjectNames = value;
93
                OnPropertyChanged(() => ProjectNames);
94
            }
95
        }
96
97 78683624 semi
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _FilterSearch;
98
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> FilterSearch
99 3bde451b semi
        {
100
            get
101
            {
102
                if (_FilterSearch == null)
103
                {
104 78683624 semi
                    _FilterSearch = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>
105 3bde451b semi
                            {
106 78683624 semi
                                new FinalPDF{ProjectNumber = "Filter Search"}
107 3bde451b semi
                            };
108
                }
109
110
                return _FilterSearch;
111
            }
112
        }
113
114 78683624 semi
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _AliveItems;
115
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> AliveItems
116 3bde451b semi
        {
117
            get => _AliveItems;
118
            set
119
            {
120
                _AliveItems = value;
121
                OnPropertyChanged(() => AliveItems);
122
            }
123
        }
124
125
        public ICollectionView FilterConvertSourceView
126
        {
127
            get
128
            {
129
                var view = CollectionViewSource.GetDefaultView(FilterConvertSource);
130
                return view;
131
            }
132
        }
133
134 78683624 semi
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _FilterConvertSource;
135
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> FilterConvertSource
136 3bde451b semi
        {
137
            get
138
            {
139
                if (_FilterConvertSource == null)
140
                {
141 78683624 semi
                    _FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
142 3bde451b semi
                }
143
                return _FilterConvertSource;
144
            }
145
            set
146
            {
147
                _FilterConvertSource = value;
148
                OnPropertyChanged(() => FilterConvertSource);
149
            }
150
        }
151
152
153 78683624 semi
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _RealConvertSource;
154
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> RealConvertSource
155 3bde451b semi
        {
156
            get => _RealConvertSource;
157
            set
158
            {
159
                _RealConvertSource = value;
160
                OnPropertyChanged(() => RealConvertSource);
161
            }
162
        }
163
164
165
        private System.Windows.Documents.FlowDocument connectionLog;
166
        public System.Windows.Documents.FlowDocument ConnectionLog
167
        {
168
            get => connectionLog;
169
            set
170
            {
171
                if (connectionLog != value)
172
                {
173
                    connectionLog = value;
174
                    OnPropertyChanged(() => ConnectionLog);
175
                }
176
            }
177
        }
178
179
180 037ab674 semi
        private int _SelectedInt = 4;
181
        public int SelectedInt
182
        {
183
            get => _SelectedInt;
184
            set
185
            {
186
                _SelectedInt = value;
187
                OnPropertyChanged(() => SelectedInt);
188
            }
189
        }
190
191
192 3bde451b semi
        private Telerik.Windows.Data.EnumMemberViewModel _SelectedStatus;
193
        public Telerik.Windows.Data.EnumMemberViewModel SelectedStatus
194
        {
195
            get => _SelectedStatus;
196
            set
197
            {
198
                _SelectedStatus = value;
199
                OnPropertyChanged(() => SelectedStatus);
200
            }
201
        }
202
203
204
        private SelectedCountItem _SelectedCount;
205
        public SelectedCountItem SelectedCount
206
        {
207
            get => _SelectedCount;
208
            set
209
            {
210
                _SelectedCount = value;
211
                OnPropertyChanged(() => SelectedCount);
212
            }
213
        }
214
215
        List<SelectedCountItem> _SelectedCountList;
216
        public List<SelectedCountItem> SelectedCountList
217
        {
218
            get
219
            {
220
                if (_SelectedCountList == null)
221
                {
222
                    _SelectedCountList = new List<SelectedCountItem>
223
                            {
224
                                new SelectedCountItem{DisplayMember = "50",ValueMember = 50},
225
                                new SelectedCountItem{DisplayMember = "100",ValueMember = 100},
226
                                new SelectedCountItem{DisplayMember = "150",ValueMember = 150},
227
                                new SelectedCountItem{DisplayMember = "200",ValueMember = 200}
228
                            };
229
                }
230
231
                return _SelectedCountList;
232
            }
233
        }
234
235 78683624 semi
        private FinalPDF _SelectFilterConvert;
236
        public FinalPDF SelectFilterConvert
237 3bde451b semi
        {
238
            get => _SelectFilterConvert;
239
            set
240
            {
241
                _SelectFilterConvert = value;
242
                OnPropertyChanged(() => SelectFilterConvert);
243
            }
244
        }
245
246 9b2f01e1 semi
247
248
        private ObservableCollection<FinalPDF> _SelectFilterConvertList;
249
        public ObservableCollection<FinalPDF> SelectFilterConvertList
250
        {
251
            get
252
            {
253
                if (_SelectFilterConvertList == null)
254
                {
255
                    _SelectFilterConvertList = new ObservableCollection<FinalPDF>();
256
                }
257
                return _SelectFilterConvertList;
258
            }
259
            set
260
            {
261
                _SelectFilterConvertList = value;
262
                OnPropertyChanged(() => SelectFilterConvertList);
263
            }
264
        }
265
266 78683624 semi
        private FinalPDF _SelectRealConvert;
267
        public FinalPDF SelectRealConvert
268 3bde451b semi
        {
269
            get => _SelectRealConvert;
270
            set
271
            {
272
                _SelectRealConvert = value;
273
                OnPropertyChanged(() => SelectRealConvert);
274
            }
275
        }
276
277
278 78683624 semi
        private FinalPDF _SelectAliveConvert;
279
        public FinalPDF SelectAliveConvert
280 3bde451b semi
        {
281
            get => _SelectAliveConvert;
282
            set
283
            {
284
                _SelectAliveConvert = value;
285
                OnPropertyChanged(() => SelectAliveConvert);
286
            }
287
        }
288
289
290
        private StatusTypeList _StatusType;
291
        public StatusTypeList StatusType
292
        {
293
            get => _StatusType;
294
            set
295
            {
296
                _StatusType = value;
297
                OnPropertyChanged(() => StatusType);
298
            }
299
        }
300
301
        private bool _IsLoading;
302
        public bool IsLoading
303
        {
304
            get => _IsLoading;
305
            set
306
            {
307
                if (_IsLoading != value)
308
                {
309
                    _IsLoading = value;
310
                    OnPropertyChanged(() => IsLoading);
311
                }
312
            }
313
        }
314
315
        IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> _StatusCodeList;
316
        public IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> StatusCodeList
317
        {
318
            get
319
            {
320
                if (_StatusCodeList == null)
321
                {
322
                    _StatusCodeList = Telerik.Windows.Data.EnumDataSource.FromType<StatusCodeType>();
323
                }
324
325
                return _StatusCodeList;
326
            }
327
        }
328
329 037ab674 semi
        public ProjectName _ProjectNumberFilter;
330
        public ProjectName ProjectNumberFilter
331 3bde451b semi
        {
332 037ab674 semi
            get
333 3bde451b semi
            {
334 037ab674 semi
                if (_ProjectNumberFilter == null)
335 3bde451b semi
                {
336 037ab674 semi
                    _ProjectNumberFilter = new ProjectName();
337 3bde451b semi
                }
338 037ab674 semi
                return _ProjectNumberFilter;
339
            }
340
            set
341
            {
342
                _ProjectNumberFilter = value;
343
                OnPropertyChanged(() => ProjectNumberFilter);
344 3bde451b semi
            }
345
        }
346
347
        public string _DocumentIDFilter;
348
        public string DocumentIDFilter
349
        {
350
            get
351
            {
352
                return _DocumentIDFilter;
353
            }
354
            set
355
            {
356
                if (_DocumentIDFilter == "")
357
                {
358
                    _DocumentIDFilter = null;
359
                }
360
                else if (_DocumentIDFilter != value)
361
                {
362
                    _DocumentIDFilter = value;
363
                    OnPropertyChanged(() => DocumentIDFilter);
364
                }
365
            }
366
        }
367
368
        public string _DOCINFO_IDFilter;
369
        public string DOCINFO_IDFilter
370
        {
371
            get
372
            {
373
                return _DOCINFO_IDFilter;
374
            }
375
            set
376
            {
377
                if (_DOCINFO_IDFilter == "")
378
                {
379
                    _DOCINFO_IDFilter = null;
380
                }
381
                else if (_DOCINFO_IDFilter != value)
382
                {
383
                    _DOCINFO_IDFilter = value;
384
                    OnPropertyChanged(() => DOCINFO_IDFilter);
385
                }
386
            }
387
        }
388
389 31beca73 semi
        public string _Document_URLFilter;
390
        public string Document_URLFilter
391
        {
392
            get
393
            {
394
                return _Document_URLFilter;
395
            }
396
            set
397
            {
398
                if (_Document_URLFilter != value)
399
                {
400
                    _Document_URLFilter = value;
401
                    OnPropertyChanged(() => Document_URLFilter);
402
                }
403
            }
404
        }
405 3bde451b semi
406
        public string _MarkupInfo_IDFilter;
407
        public string MarkupInfo_IDFilter
408
        {
409
            get
410
            {
411
                return _MarkupInfo_IDFilter;
412
            }
413
            set
414
            {
415
                if (_MarkupInfo_IDFilter != value)
416
                {
417
                    _MarkupInfo_IDFilter = value;
418
                    OnPropertyChanged(() => MarkupInfo_IDFilter);
419
                }
420
            }
421
        }
422
423
        public string _CreateUser_IDFilter;
424
        public string CreateUser_IDFilter
425
        {
426
            get
427
            {
428
                return _CreateUser_IDFilter;
429
            }
430
            set
431
            {
432
                if (_CreateUser_IDFilter == "")
433
                {
434
                    _CreateUser_IDFilter = null;
435
                }
436
                else if (_CreateUser_IDFilter != value)
437
                {
438
                    _CreateUser_IDFilter = value;
439
                    OnPropertyChanged(() => CreateUser_IDFilter);
440
                }
441
            }
442
        }
443
444
        public string _GROUP_NOFilter;
445
        public string GROUP_NOFilter
446
        {
447
            get
448
            {
449
                return _GROUP_NOFilter;
450
            }
451
            set
452
            {
453
                if (_GROUP_NOFilter == "")
454
                {
455
                    _GROUP_NOFilter = null;
456
                }
457
                else if (_GROUP_NOFilter != value)
458
                {
459
                    _GROUP_NOFilter = value;
460
                    OnPropertyChanged(() => GROUP_NOFilter);
461
                }
462
            }
463
        }
464
465
        public string _REVISIONFilter;
466
        public string REVISIONFilter
467
        {
468
            get
469
            {
470
                return _REVISIONFilter;
471
            }
472
            set
473
            {
474
                if (_REVISIONFilter == "")
475
                {
476
                    _REVISIONFilter = null;
477
                }
478
                else if (_REVISIONFilter != value)
479
                {
480
                    _REVISIONFilter = value;
481
                    OnPropertyChanged(() => REVISIONFilter);
482
                }
483
            }
484
        }
485
486
        public StatusCodeType _ConvertStateFilter;
487
        public StatusCodeType ConvertStateFilter
488
        {
489
            get { return _ConvertStateFilter; }
490
            set
491
            {
492
                if (_ConvertStateFilter != value)
493
                {
494
                    _ConvertStateFilter = value;
495
                    OnPropertyChanged(() => ConvertStateFilter);
496
                }
497
            }
498
        }
499
500
        public string _Document_NOFilter;
501
        public string Document_NOFilter
502
        {
503
            get { return _Document_NOFilter; }
504
            set
505
            {
506
                if (_Document_NOFilter == "")
507
                {
508
                    _Document_NOFilter = null;
509
                }
510
                else if (_Document_NOFilter != value)
511
                {
512
                    _Document_NOFilter = value;
513
                    OnPropertyChanged(() => Document_NOFilter);
514
                }
515
            }
516
        }
517
518
        public string _Exception;
519
        public string Exception
520
        {
521
            get { return _Exception; }
522
            set
523
            {
524
                if (_Exception == "")
525
                {
526
                    _Exception = null;
527
                }
528
                else if (_Exception != value)
529
                {
530
                    _Exception = value;
531
                    OnPropertyChanged(() => Exception);
532
                }
533
            }
534
        }
535
536
        public string _Document_NameFilter;
537
        public string Document_NameFilter
538
        {
539
            get { return _Document_NameFilter; }
540
            set
541
            {
542
                if (_Document_NameFilter == "")
543
                {
544
                    _Document_NameFilter = null;
545
                }
546
                else if (_Document_NameFilter != value)
547
                {
548
                    _Document_NameFilter = value;
549
                    OnPropertyChanged(() => Document_NameFilter);
550
                }
551
            }
552
        }
553
554
555 95e7bd84 semi
        static DateTime DefaultCreateTime = DateTime.Now.AddHours(-1);
556 3bde451b semi
        private DateTime _SelectedCreateTimeBegin = DefaultCreateTime;
557
        public DateTime SelectedCreateTimeBegin
558
        {
559
560
            get { return _SelectedCreateTimeBegin; }
561
            set
562
            {
563
                if (_SelectedCreateTimeBegin == value)
564
                    return;
565
                _SelectedCreateTimeBegin = value;
566
                OnPropertyChanged(() => SelectedCreateTimeBegin);
567
568
            }
569
        }
570
571
        private DateTime _SelectedCreateTimeEnd = DefaultCreateTime;
572
        public DateTime SelectedCreateTimeEnd
573
        {
574
575
            get { return _SelectedCreateTimeEnd; }
576
            set
577
            {
578
                if (_SelectedCreateTimeEnd == value)
579
                    return;
580
                _SelectedCreateTimeEnd = value;
581
                OnPropertyChanged(() => SelectedCreateTimeEnd);
582
            }
583
        }
584
585
        public int _DataBase_ItemsHeight = 800;
586
        public int DataBase_ItemsHeight
587
        {
588
            get { return _DataBase_ItemsHeight; }
589
            set
590
            {
591
                _DataBase_ItemsHeight = value;
592
                OnPropertyChanged(() => DataBase_ItemsHeight);
593
            }
594
        }
595
596
597
        public int _RealConvert_Height = 80;
598
        public int RealConvert_Height
599
        {
600
            get { return _RealConvert_Height; }
601
            set
602
            {
603
                _RealConvert_Height = value;
604
                OnPropertyChanged(() => RealConvert_Height);
605
            }
606
        }
607
608
        public int _Alive_Height = 80;
609
        public int Alive_Height
610
        {
611
            get { return _Alive_Height; }
612
            set
613
            {
614
                _Alive_Height = value;
615
                OnPropertyChanged(() => Alive_Height);
616
            }
617
        }
618
619
        public bool _ConvertShow;
620
        public bool ConvertShow
621
        {
622
            get => _ConvertShow;
623
            set
624
            {
625
                if (_ConvertShow = !value)
626
                {
627
                    _ConvertShow = false;
628
                }
629
                _ConvertShow = value;
630
                OnPropertyChanged(() => ConvertShow);
631
            }
632
        }
633 037ab674 semi
634 aaed7be2 semi
        public bool _AliveShow = false;
635 cb806a91 semi
        public bool AliveShow
636
        {
637
            get => _AliveShow;
638
            set
639
            {
640
                _AliveShow = value;
641
                OnPropertyChanged(() => AliveShow);
642
            }
643
        }
644
645 037ab674 semi
646
        private bool _ExcptionCheck = false;
647
        public bool ExcptionCheck
648
        {
649
            get
650
            {
651
                return _ExcptionCheck;
652
            }
653
            set
654
            {
655
                _ExcptionCheck = value;
656
                OnPropertyChanged(() => ExcptionCheck);
657
            }
658
        }
659 19d6b221 semi
660 50b63148 semi
        public bool _SearchTimerOn = false;
661
        public bool SearchTimerOn
662
        {
663
            get => _SearchTimerOn;
664
            set
665
            {
666
                if (_SearchTimerOn = !value)
667
                {
668
                    _SearchTimerOn = false;
669
                }
670
                _SearchTimerOn = value;
671
                OnPropertyChanged(() => SearchTimerOn);
672
            }
673
        }
674
675 3bde451b semi
        #endregion
676
677
        #region Command
678
679
        public DelegateCommand ConvertCommand { get; private set; }
680
        public DelegateCommand DeleteCommand { get; private set; }
681
        public DelegateCommand ValidateCommand { get; private set; }
682
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
683
        public DelegateCommand MarkusLinkCommand { get; private set; }
684
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
685
686
        public DelegateCommand DataFilterCommand { get; private set; }
687
        public DelegateCommand ResetCommand { get; private set; }
688
        public DelegateCommand ConverAddCommand { get; private set; }
689 95e7bd84 semi
        public DelegateCommand FinalPDFPathFileSearchCommand { get; private set; }
690 f5ec88b8 semi
        public DelegateCommand Stop_ProcessCommand { get; private set; }
691 aaed7be2 semi
        public DelegateCommand EnterCommand { get; private set; }
692 f047c8bf semi
        public DelegateCommand DocumentFilterCommand { get; private set; }
693 3bde451b semi
694
        #endregion
695
696
        #region Main Logic
697
698
        /// <summary>
699
        /// 각각의 Grid row 객체들 업데이트
700
        /// </summary>
701
702
        private DispatcherTimer dispatcherTimer;
703
        public override void Loaded()
704
        {
705
            base.Loaded();
706
707
            if (!App.IsDesignMode)
708
            {
709
                dispatcherTimer = new DispatcherTimer();
710
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
711
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
712
                dispatcherTimer.Start();
713
            }
714
        }
715
716
        private async void Timer_Tick(object sender, EventArgs e)
717
        {
718
            dispatcherTimer.Stop();
719
720
            if (IsAcitve)
721
            {
722
                await App.Current.Dispatcher.InvokeAsync(() =>
723
                {
724
                    DataSelect();
725
726
                    AliveDataSelect();
727
                });
728
            }
729
730
            await Task.Delay(5000);
731
732
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
733
734
            dispatcherTimer.Start();
735
        }
736
737 037ab674 semi
        private async void SearchTimer_Tick(object sender, EventArgs e)
738
        {
739
            dispatcherTimer.Stop();
740
741
            if (IsAcitve)
742
            {
743
                await App.Current.Dispatcher.InvokeAsync(() =>
744
                {
745
                    DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
746
747
                    RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
748
749
                    AliveDataSelect();
750
                });
751
            }
752
753
            await Task.Delay(5000);
754
755
            dispatcherTimer.Start();
756
        }
757
758
759 3bde451b semi
        public override void Closed()
760
        {
761
            if (dispatcherTimer != null)
762
            {
763
                dispatcherTimer.Stop();
764
            }
765
766
            base.Closed();
767
        }
768
769
770
        #endregion
771
772
        #region Function
773
774 19d6b221 semi
        #region Return_FilterConvertSource
775
776
        public static void Return_FilterConvertSource(ObservableCollection<FinalPDF> convertPDFs)
777
        {
778
            ConvertSource = new ObservableCollection<FinalPDF>();
779
            ConvertSource = convertPDFs;
780
        }
781
782
        public static ObservableCollection<FinalPDF> Return_FilterConvertSource()
783
        {
784
            return ConvertSource;
785
        }
786
787
788
        #endregion
789
790 3bde451b semi
        #region Data Select
791
792
        /// <summary>
793
        /// 상단 그리드 중앙 그리드 출력 데이터
794
        /// </summary>
795
        private void DataSelect()
796
        {
797
798
            if (FilterConvertSource == null)
799
            {
800 78683624 semi
                FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
801 3bde451b semi
            }
802
803
            if (RealConvertSource == null)
804
            {
805 78683624 semi
                RealConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
806 3bde451b semi
            }
807
808
            /// combobox 에서 선택된 items
809
            if (SelectedStatus != null)
810
            {
811
                DataSelect(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
812
            }
813
814
            /// 컨버터중인 items
815
            RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
816
817
        }
818
819 037ab674 semi
        private async void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection)
820 3bde451b semi
        {
821
            try
822
            {
823 19d6b221 semi
                IEnumerable<FinalPDF> Listitems = Enumerable.Empty<FinalPDF>();
824 3bde451b semi
825 037ab674 semi
                foreach (var coll in collection)
826
                {
827 19d6b221 semi
                   Listitems = from x in await WcfClient.GET_SELECT_FINAL_PDF_ITEMAsync(coll.ConvertID, coll.ProjectNumber, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
828 037ab674 semi
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
829
                                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, x.REVISION, x.CURRENT_PAGE,
830
                            x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
831 19d6b221 semi
832 037ab674 semi
                }
833 3bde451b semi
834 037ab674 semi
                foreach (var Listitem in Listitems)
835
                {
836
                    collection.UpdateWhere(changeitem =>
837
                    ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
838 3bde451b semi
                }
839 037ab674 semi
840
                RealConvert_Height = 80 + (10 * collection.Count());
841
                DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
842 3bde451b semi
            }
843
            catch (Exception ex)
844
            {
845
                MessageBox.Show(ex.ToString());
846
            }
847
        }
848
849 037ab674 semi
        private async void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection)
850 3bde451b semi
        {
851
            try
852
            {
853 037ab674 semi
                int _status = 0;
854
                if (SelectedStatus != null)
855 3bde451b semi
                {
856 037ab674 semi
                    _status = (int)SelectedStatus.Value;
857
                }
858 3bde451b semi
859 72862ad1 semi
                if (ProjectNames.Count() == 0)
860
                {
861 aaed7be2 semi
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
862 72862ad1 semi
                    ProjectNames.Add(Clear);
863
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
864
                    {
865
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
866
                        ProjectNames.Add(projectName);
867
                    }
868
                }
869
870 037ab674 semi
                var Listitems = from x in await WcfClient.GET_SELECT_FINAL_PDF_ITEMAsync(null, null, null, null, null, null, null, null, _status, SelectedCount.ValueMember, null, null, null, null, null, null, null, null, null, null)
871
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
872
                                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,
873
                        x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
874
                     , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
875 3bde451b semi
876 037ab674 semi
                if (collection.Count() == 0)
877
                {
878
                    if (statusCodeTypeList.Count() == 1)
879 3bde451b semi
                    {
880 037ab674 semi
                        foreach (var x in Listitems)
881 3bde451b semi
                        {
882 037ab674 semi
                            collection.Add(x);
883 3bde451b semi
                        }
884
                    }
885 037ab674 semi
                }
886
                else
887
                {
888
                    foreach (var newitem in Listitems)
889 3bde451b semi
                    {
890 037ab674 semi
                        collection.UpdateWhere(changeitem =>
891
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
892
                    }
893 3bde451b semi
894 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
895
                    {
896
                        for (int i = collection.Count() - 1; i >= 0; --i)
897 3bde451b semi
                        {
898 037ab674 semi
                            var item = collection[i];
899 3bde451b semi
900 037ab674 semi
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
901 3bde451b semi
                            {
902 037ab674 semi
                                collection.RemoveAt(i);
903 3bde451b semi
                            }
904
                        }
905 037ab674 semi
                    }
906 3bde451b semi
907 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
908
                    {
909
                        foreach (var item in Listitems)
910 3bde451b semi
                        {
911 037ab674 semi
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
912 3bde451b semi
                            {
913 037ab674 semi
                                for (int i = 0; i < 200; i++)
914 3bde451b semi
                                {
915 037ab674 semi
                                    if (i < collection.Count() - 1)
916 3bde451b semi
                                    {
917 037ab674 semi
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
918 3bde451b semi
                                        {
919 037ab674 semi
                                            collection.Insert(i, item);
920 3bde451b semi
                                            break;
921
                                        }
922
                                    }
923 037ab674 semi
                                    else
924
                                    {
925
                                        collection.Add(item);
926
                                        break;
927
                                    }
928 3bde451b semi
                                }
929
930
                            }
931 037ab674 semi
932 3bde451b semi
                        }
933
                    }
934
                }
935
            }
936
            catch (Exception ex)
937
            {
938
                MessageBox.Show(ex.ToString());
939
                System.Diagnostics.Debug.WriteLine(ex.ToString());
940
            }
941
        }
942
943 037ab674 semi
        private async void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection)
944 3bde451b semi
        {
945
            try
946
            {
947 037ab674 semi
                int _status = 0;
948
                if (SelectedStatus != null)
949 3bde451b semi
                {
950 037ab674 semi
                    _status = (int)SelectedStatus.Value;
951
                }
952 3bde451b semi
953 037ab674 semi
                DateTime? Start_CreateTime = null;
954
                DateTime? Finish_CreateTime = null;
955
                if (SelectedCreateTimeBegin != DefaultCreateTime)
956
                {
957
                    Start_CreateTime = SelectedCreateTimeBegin;
958
                }
959
                if (SelectedCreateTimeEnd != DefaultCreateTime)
960
                {
961
                    Finish_CreateTime = SelectedCreateTimeEnd;
962
                }
963 3bde451b semi
964 72862ad1 semi
                if (ProjectNames.Count() == 0)
965
                {
966 aaed7be2 semi
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
967
                    ProjectNames.Add(Clear);
968 72862ad1 semi
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
969
                    {
970
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
971
                        ProjectNames.Add(projectName);
972
                    }
973
                }
974
975 037ab674 semi
                var Listitems = from x in await WcfClient.GET_SELECT_FINAL_PDF_ITEMAsync(null, ProjectNumberFilter.Project_NO, DocumentIDFilter, MarkupInfo_IDFilter, DOCINFO_IDFilter, Document_NameFilter, Document_NOFilter,
976
                    CreateUser_IDFilter, _status, SelectedCount.ValueMember, GROUP_NOFilter, REVISIONFilter, Start_CreateTime, Finish_CreateTime, null, null, null, null, Document_URLFilter, ExcptionCheck)
977
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
978 cb806a91 semi
                                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,
979 037ab674 semi
                                    x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
980
                                 , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
981 3bde451b semi
982 037ab674 semi
                if (collection.Count() == 0)
983
                {
984
                    if (statusCodeTypeList.Count() == 1)
985 3bde451b semi
                    {
986 037ab674 semi
                        foreach (var x in Listitems)
987 3bde451b semi
                        {
988 037ab674 semi
                            collection.Add(x);
989 3bde451b semi
                        }
990
                    }
991 037ab674 semi
                }
992
                else
993
                {
994
                    foreach (var newitem in Listitems)
995 3bde451b semi
                    {
996 037ab674 semi
                        collection.UpdateWhere(changeitem =>
997
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
998
                    }
999 3bde451b semi
1000 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
1001
                    {
1002 3bde451b semi
1003 037ab674 semi
                        for (int i = collection.Count() - 1; i >= 0; --i)
1004 3bde451b semi
                        {
1005 037ab674 semi
                            var item = collection[i];
1006 3bde451b semi
1007 037ab674 semi
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1008 3bde451b semi
                            {
1009 037ab674 semi
                                collection.RemoveAt(i);
1010 3bde451b semi
                            }
1011
                        }
1012 037ab674 semi
                    }
1013 3bde451b semi
1014 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
1015
                    {
1016
                        foreach (var item in Listitems)
1017 3bde451b semi
                        {
1018 037ab674 semi
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1019 3bde451b semi
                            {
1020 037ab674 semi
                                for (int i = 0; i < 200; i++)
1021 3bde451b semi
                                {
1022 037ab674 semi
                                    if (i < collection.Count() - 1)
1023 3bde451b semi
                                    {
1024 037ab674 semi
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
1025 3bde451b semi
                                        {
1026 037ab674 semi
                                            collection.Insert(i, item);
1027 3bde451b semi
                                            break;
1028
                                        }
1029
                                    }
1030 037ab674 semi
                                    else
1031
                                    {
1032
                                        collection.Add(item);
1033
                                        break;
1034
                                    }
1035 3bde451b semi
                                }
1036
1037
                            }
1038
1039 037ab674 semi
                        }
1040 3bde451b semi
                    }
1041
1042 037ab674 semi
                }
1043 3bde451b semi
            }
1044
            catch (Exception ex)
1045
            {
1046
                MessageBox.Show(ex.ToString());
1047
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1048
            }
1049
        }
1050
        /// <summary>
1051
        /// 서비스의 실시간 컨버터 Item
1052
        /// </summary>
1053
        private async void AliveDataSelect()
1054
        {
1055
            try
1056
            {
1057 78683624 semi
                List<FinalPDF> newitems = new List<FinalPDF>();
1058 3bde451b semi
                foreach (var client in App.StationClientList)
1059
                {
1060
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
1061
                    {
1062
                        try
1063
                        {
1064 78683624 semi
                            List<FinalPDF> itemsToList = new List<FinalPDF>();
1065 3bde451b semi
                            var items = await client.AliveConvertListAsync();
1066
                            string result = "";
1067
1068 aaed7be2 semi
                            if (items.Count() > 0)
1069
                            {
1070
                                AliveShow = true;
1071
                            }
1072
1073
1074 3bde451b semi
                            foreach (var item in items)
1075
                            {
1076 78683624 semi
                                FinalPDF itemsToEach = new FinalPDF();
1077 3bde451b semi
                                itemsToEach.ConvertID = item.ConvertID;
1078
                                itemsToEach.ProjectNumber = item.ProjectNumber;
1079
1080 037ab674 semi
                                var MarkusLink = "kcom://" + CreateMarkusParam(item.ProjectNumber, item.DocumentID, "doftech");
1081
1082 3bde451b semi
                                if (item.ConvertState != null)
1083
                                {
1084
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
1085
                                }
1086
1087
                                if (item.OriginfilePath.Contains("/"))
1088
                                {
1089
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1090
                                }
1091
                                else
1092
                                {
1093
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1094
                                }
1095
                                itemsToEach.FileName = result;
1096
1097
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
1098
                                itemsToEach.TotalPage = item.TotalPage;
1099
                                itemsToEach.OriginfilePath = item.OriginfilePath;
1100
                                itemsToEach.ConvertPath = item.ConvertPath;
1101 037ab674 semi
                                itemsToEach.MarkusLink = MarkusLink;
1102 3bde451b semi
                                itemsToEach.DocumentID = item.DocumentID;
1103
                                itemsToEach.GroupNo = item.GroupNo;
1104 5feff9f0 semi
                                itemsToEach.DocumentName = item.DocumnetName;
1105 3bde451b semi
                                itemsToEach.Revision = item.Revision;
1106
                                itemsToEach.Exception = item.Exception;
1107 037ab674 semi
                                itemsToEach.ConvertPath = item.ConvertPath;
1108 3bde451b semi
                                itemsToEach.CreateTime = item.CreateTime;
1109
                                itemsToEach.StartTime = item.StartTime;
1110
                                itemsToEach.EndTime = item.EndTime;
1111
1112
                                itemsToList.Add(itemsToEach);
1113
                            }
1114
                            newitems.AddRange(itemsToList);
1115
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1116
1117
                            if (items.Count() == 0)
1118
                            {
1119
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1120
                            }
1121
                        }
1122
                        catch (Exception ex)
1123
                        {
1124
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1125
                        }
1126
                    }
1127
                    else
1128
                    {
1129
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1130
                    }
1131
1132
                }
1133
                ItemsUpdate(newitems);
1134
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1135
            }
1136
            catch (Exception ex)
1137
            {
1138
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1139
            }
1140
        }
1141
1142
        /// <summary>
1143
        /// AliveDataSelect의 Data Update
1144
        /// </summary>
1145
        /// <param name = "newitems" ></ param >
1146 78683624 semi
        private void ItemsUpdate(List<FinalPDF> newitems)
1147 3bde451b semi
        {
1148
1149
            foreach (var item in newitems)
1150
            {
1151
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1152
            }
1153
1154
            if (AliveItems == null)
1155
            {
1156 78683624 semi
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
1157 3bde451b semi
1158
                foreach (var item in newitems)
1159
                {
1160
                    AliveItems.Add(item);
1161
                }
1162
            }
1163
            else
1164
            {
1165
                newitems.ForEach(newitem =>
1166
                {
1167
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1168
                });
1169
1170
                foreach (var item in newitems)
1171
                {
1172
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1173
                    {
1174
                        AliveItems.Add(item);
1175
                    }
1176
                }
1177
1178
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1179
                {
1180
                    var item = AliveItems[i];
1181
1182
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1183
                    {
1184
                        try
1185
                        {
1186
                            AliveItems.RemoveAt(i);
1187
                        }
1188
                        catch (Exception ex)
1189
                        {
1190
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1191
                        }
1192
                    }
1193
                }
1194
            }
1195
1196 cb806a91 semi
1197 3bde451b semi
            Alive_Height = 80 + (newitems.Count() * 10);
1198
            DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
1199
        }
1200
1201
1202
        public static async Task<bool> SimplePingAsync(string uri)
1203
        {
1204
            bool result = false;
1205
1206
            try
1207
            {
1208
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1209
                {
1210
                    Client.Timeout = new TimeSpan(0, 0, 60);
1211
1212
                    var message = await Client.GetAsync(uri);
1213
1214
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1215
1216
                    switch (StatusCode)
1217
                    {
1218
1219
                        case System.Net.HttpStatusCode.Accepted:
1220
                        case System.Net.HttpStatusCode.OK:
1221
                            result = true;
1222
                            break;
1223
                    }
1224
                }
1225
            }
1226
            catch (Exception ex)
1227
            {
1228
                result = false;
1229
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1230
            }
1231
1232
            return result;
1233
        }
1234
1235
        #endregion
1236
1237
        #region Data Convert
1238
1239 037ab674 semi
        private async void DataConvert(object obj)
1240 3bde451b semi
        {
1241 29cd086e semi
            if (obj is FinalPDF)
1242
            {
1243
1244
                if (obj != null)
1245
                {
1246
                    var convertitem = obj as FinalPDF;
1247
1248
                    SelectRealConvert = convertitem;
1249
                    SetCleanUpItem(SelectRealConvert);
1250
1251
1252
                    var items = from x in await WcfClient.GET_SELECT_FINAL_PDF_ITEMAsync(SelectRealConvert.ConvertID, null, null, null, null, null, null, null, null, 1, null, null, null, null, null, null, null, null, null, null)
1253
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
1254
                                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,
1255
                            x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1256
                         , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
1257
1258
                    foreach (var item in items)
1259
                    {
1260
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1261
                        {
1262
                            RealConvertSource.Add(item);
1263
                        }
1264
                        if (RealConvertSource.Count() == 1)
1265
                        {
1266
                            ConvertShow = true;
1267
                        }
1268
                    }
1269
                }
1270
            }
1271
            else if (SelectFilterConvertList == null)
1272 3bde451b semi
            {
1273
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1274
            }
1275
            else
1276
            {
1277 29cd086e semi
                if (SelectFilterConvertList != null)
1278 3bde451b semi
                {
1279 29cd086e semi
                    foreach (var SelectFilterConvert in SelectFilterConvertList)
1280
                    {
1281
                        SetCleanUpItem(SelectFilterConvert);
1282
                    }
1283 3bde451b semi
                }
1284
1285 29cd086e semi
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1286
                {
1287
                    var items = from x in await WcfClient.GET_SELECT_FINAL_PDF_ITEMAsync(SelectFilterConvert.ConvertID, null, null, null, null, null, null, null, null, 1, null, null, null, null, null, null, null, null, null, null)
1288
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
1289
                                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,
1290
                            x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1291
                         , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
1292 3bde451b semi
1293
1294 29cd086e semi
                    foreach (var item in items)
1295 b6bc5408 semi
                    {
1296 29cd086e semi
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1297
                        {
1298
                            RealConvertSource.Add(item);
1299
                        }
1300
                        if (RealConvertSource.Count() == 1)
1301
                        {
1302
                            ConvertShow = true;
1303
                        }
1304 3bde451b semi
                    }
1305
                }
1306
            }
1307
        }
1308
1309
1310 29cd086e semi
        public async void SetCleanUpItem(FinalPDF _ConvertItem)
1311 3bde451b semi
        {
1312
1313 037ab674 semi
            var items = await WcfClient.GET_SELECT_FINAL_PDF_ITEMAsync(_ConvertItem.ConvertID, null, null, null, null, null, null, null, null, 1, null, null, null, null, null, null, null, null, null, null);
1314 3bde451b semi
1315 037ab674 semi
            if (items.Count() > 0)
1316
            {
1317
                var item = items.First();
1318 3bde451b semi
1319 95e7bd84 semi
                var _CREATE_DATETIME = DateTime.Now.AddHours(-1);
1320 037ab674 semi
                var _STATUS = (int)StatusCodeType.None;
1321 3bde451b semi
1322 cb806a91 semi
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, 0, _CREATE_DATETIME, _STATUS, null);
1323 3bde451b semi
1324
            }
1325
        }
1326
1327 2c634aed semi
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1328
        {
1329
            ViewInfo viewInfo = new ViewInfo();
1330
1331
            viewInfo.DocumentItemID = documentID;
1332
            viewInfo.ProjectNO = projectNo;
1333
            viewInfo.UserID = userID;
1334
1335
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1336
1337
        }
1338
1339
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1340
        {
1341
1342
            if (oEncoding == null)
1343
                oEncoding = System.Text.Encoding.UTF8;
1344
1345
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1346
1347
        }
1348
1349 3bde451b semi
        #endregion
1350
1351
        #region Validation
1352
1353
        private void DataValidate(object obj)
1354
        {
1355 29cd086e semi
            if (obj is FinalPDF)
1356
            {
1357 3bde451b semi
1358 29cd086e semi
                if (obj != null)
1359
                {
1360
                    var convertitem = obj as FinalPDF;
1361 3bde451b semi
1362 29cd086e semi
                    SelectRealConvert = convertitem;
1363 3bde451b semi
1364 29cd086e semi
                    bool result = false;
1365
                    WebRequest webRequest = WebRequest.Create(SelectRealConvert.OriginfilePath);
1366
                    webRequest.Timeout = 1200; // miliseconds
1367
                    webRequest.Method = "HEAD";
1368 3bde451b semi
1369 29cd086e semi
                    HttpWebResponse response = null;
1370
1371
                    try
1372
                    {
1373
                        response = (HttpWebResponse)webRequest.GetResponse();
1374
                        result = true;
1375
                    }
1376
                    catch (WebException webException)
1377
                    {
1378
                        MessageBox.Show(SelectRealConvert.FileName + " doesn't exist: " + webException.Message);
1379
                        result = true;
1380
                    }
1381
                    finally
1382
                    {
1383
                        if (response != null)
1384
                        {
1385
                            response.Close();
1386
                        }
1387
                    }
1388
                    if (result == true)
1389
                    {
1390
                        MessageBox.Show("File exists");
1391
                    }
1392
                }
1393
            }
1394
            else if (SelectFilterConvertList.Count() > 1)
1395 3bde451b semi
            {
1396 29cd086e semi
                MessageBox.Show("하나만 클릭해 주세요");
1397 3bde451b semi
            }
1398 29cd086e semi
            else if (SelectFilterConvertList.Count() == 0)
1399 3bde451b semi
            {
1400 29cd086e semi
                MessageBox.Show("왼쪽 버튼 클릭 후 Validate 해주세요!");
1401 3bde451b semi
            }
1402 29cd086e semi
            else
1403 3bde451b semi
            {
1404 29cd086e semi
                bool result = false;
1405
                WebRequest webRequest = WebRequest.Create(SelectFilterConvertList[0].OriginfilePath);
1406
                webRequest.Timeout = 1200; // miliseconds
1407
                webRequest.Method = "HEAD";
1408
1409
                HttpWebResponse response = null;
1410
1411
                try
1412 3bde451b semi
                {
1413 29cd086e semi
                    response = (HttpWebResponse)webRequest.GetResponse();
1414
                    result = true;
1415
                }
1416
                catch (WebException webException)
1417
                {
1418 944a39ed semi
                    MessageBox.Show(SelectFilterConvertList[0].FileName + " doesn't exist: " + webException.Message);
1419
                    result = false;
1420 29cd086e semi
                }
1421
                finally
1422
                {
1423
                    if (response != null)
1424
                    {
1425
                        response.Close();
1426
                    }
1427
                }
1428
                if (result == true)
1429
                {
1430
                    MessageBox.Show("File exists");
1431 3bde451b semi
                }
1432
            }
1433 29cd086e semi
1434 3bde451b semi
        }
1435
1436
        #endregion
1437
1438 f5ec88b8 semi
        #region Data Delete
1439
1440
        private void DataDelete(object obj)
1441
        {
1442 29cd086e semi
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1443
            {
1444
                var result = evt.DialogResult;
1445
1446
                if (result == true)
1447
                {
1448
                    OnClosed(obj);
1449
                }
1450
            };
1451
1452
            RadWindow.Confirm("Do you want to delete it??", handler);
1453 f5ec88b8 semi
        }
1454
1455 29cd086e semi
        private async void OnClosed(object obj)
1456 f5ec88b8 semi
        {
1457 29cd086e semi
            if (obj is FinalPDF)
1458 f5ec88b8 semi
            {
1459 29cd086e semi
                if (obj != null)
1460 f5ec88b8 semi
                {
1461 29cd086e semi
                    var convertitem = obj as FinalPDF;
1462
1463
                    SelectRealConvert = convertitem;
1464
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1465
1466 f5ec88b8 semi
                }
1467 29cd086e semi
            }
1468
            else if (SelectFilterConvertList.Count() > 1)
1469
            {
1470
                MessageBox.Show("하나만 클릭해 주세요!");
1471
            }
1472
            else if (SelectFilterConvertList.Count() == 0)
1473
            {
1474
                MessageBox.Show("왼쪽 버튼 클릭 후 Delete 해주세요!");
1475
            }
1476
            else
1477
            {
1478
                if (SelectFilterConvertList != null)
1479 f5ec88b8 semi
                {
1480 29cd086e semi
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectFilterConvertList[0].ConvertID);
1481 f5ec88b8 semi
                }
1482
            }
1483
        }
1484
1485
        #endregion
1486
1487
        #region Stop Process
1488
1489
        private void Stop_Process(object obj)
1490
        {
1491 f0ad40d3 semi
1492
            string convertid = "";
1493
1494 29cd086e semi
            if (obj is FinalPDF)
1495 f5ec88b8 semi
            {
1496 29cd086e semi
1497
                if (obj != null)
1498 f0ad40d3 semi
                {
1499 29cd086e semi
                    var convertitem = obj as FinalPDF;
1500
1501
                    SelectRealConvert = convertitem;
1502
1503
                    SelectAliveConvert = convertitem;
1504
1505
                    convertid = convertitem.ConvertID;
1506 f0ad40d3 semi
                }
1507 f5ec88b8 semi
            }
1508
1509 29cd086e semi
1510
#if DEBUG
1511
            convertid = "TEST";
1512
#endif
1513
1514 f0ad40d3 semi
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1515
            {
1516
                var result = evt.DialogResult;
1517
1518
                if (result == true)
1519
                {
1520
                    Stop_Process(convertid);
1521
                }
1522
            };
1523
1524
            RadWindow.Confirm("프로세스 종료 할까요??", handler);
1525 f5ec88b8 semi
        }
1526
1527 29cd086e semi
        private async void Stop_Process(string convertId)
1528 f5ec88b8 semi
        {
1529 29cd086e semi
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10));
1530 f5ec88b8 semi
1531 f0ad40d3 semi
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1532
1533
            for (int i = process.Count() - 1; i >= 0; i--)
1534
            {
1535
                try
1536 c68259ac semi
                {
1537 f0ad40d3 semi
                    var commandLines = process[i].Arguments().CommandLine;
1538 f5ec88b8 semi
1539 f0ad40d3 semi
                    if (commandLines.Count() > 0)
1540
                    {
1541
                        if (commandLines[0] == convertId)
1542 c68259ac semi
                        {
1543 29cd086e semi
1544
                            var _CREATE_DATETIME = DateTime.Now;
1545
1546
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 3, null);
1547
                            process[i].WaitForExit(5000);
1548
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 99, null);
1549 f0ad40d3 semi
                            process[i].Kill();
1550 f5ec88b8 semi
                        }
1551 c68259ac semi
                    }
1552 f0ad40d3 semi
                }
1553
                catch (Exception ex)
1554
                {
1555
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
1556 f5ec88b8 semi
                }
1557
            }
1558
        }
1559 29cd086e semi
1560 f5ec88b8 semi
        #endregion
1561
1562 3bde451b semi
        #region DataFilter
1563
1564
        public void DataFilter(object obj)
1565
        {
1566 50b63148 semi
            SearchTimerOn = true;
1567 3bde451b semi
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1568 72862ad1 semi
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1569 944a39ed semi
1570
            FilterConvertSource.Clear();
1571
1572
            SearchTimer_Tick(null, new EventArgs());
1573 3bde451b semi
        }
1574
1575
        #endregion
1576
1577
        #region MarkusLink
1578
1579
        private void MarkusLink(object obj)///여기서 부터 
1580
        {
1581 78683624 semi
            if (obj is FinalPDF)
1582 3bde451b semi
            {
1583
                if (obj != null)
1584
                {
1585 78683624 semi
                    var convertitem = obj as FinalPDF;
1586 3bde451b semi
1587 9b2f01e1 semi
                    SelectFilterConvertList.Add(convertitem);
1588 3bde451b semi
1589
                    SelectRealConvert = convertitem;
1590
1591
                    ProcessStartInfo startInfo = null;
1592
1593
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1594
1595
                    Process.Start(startInfo);
1596
                }
1597
            }
1598
        }
1599
1600
        #endregion
1601
1602 aaed7be2 semi
        #region Filter Enter
1603
1604
1605
        /// <summary>
1606
        /// 필터된 상단 그리드 엑셀로 출력
1607
        /// </summary>
1608
1609
        public void Enter(object sender)
1610
        {
1611
            SearchTimerOn = true;
1612
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1613
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1614 944a39ed semi
1615
            FilterConvertSource.Clear();
1616
1617
            SearchTimer_Tick(null, new EventArgs());
1618 aaed7be2 semi
        }
1619
1620
        #endregion
1621
1622 3bde451b semi
        #region Data Export
1623
1624
1625
        /// <summary>
1626
        /// 필터된 상단 그리드 엑셀로 출력
1627
        /// </summary>
1628
1629
        public void DataExportData(object obj)
1630
        {
1631 50b63148 semi
            if (SearchTimerOn == true)
1632
            {
1633
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1634
            }
1635
            else
1636
            {
1637
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1638
            }
1639 3bde451b semi
1640 19d6b221 semi
            Return_FilterConvertSource(FilterConvertSource);
1641 3bde451b semi
1642 19d6b221 semi
            Views.FinalPDFExcelDialog finalPDFExcelDialog = new Views.FinalPDFExcelDialog();
1643 3bde451b semi
1644 19d6b221 semi
            finalPDFExcelDialog.Owner = Application.Current.MainWindow;
1645
            finalPDFExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1646 3bde451b semi
1647 19d6b221 semi
            finalPDFExcelDialog.ShowDialog();
1648 3bde451b semi
1649
1650 50b63148 semi
            if (SearchTimerOn == true)
1651
            {
1652
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1653
            }
1654
            else
1655
            {
1656
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1657
            }
1658 3bde451b semi
        }
1659
1660
        #endregion
1661
1662
        #region Data Search
1663
1664
        public void RemoveCreateTimeFilter(object obj)
1665
        {
1666 95e7bd84 semi
            DefaultCreateTime = DateTime.Now.AddHours(-1); ;
1667 3bde451b semi
            SelectedCreateTimeBegin = DefaultCreateTime;
1668
            SelectedCreateTimeEnd = DefaultCreateTime;
1669
1670
        }
1671
1672
        #endregion
1673
1674
        #region Reset
1675
1676
        /// <summary>
1677
        /// 그리드 상단 원상복귀 버튼
1678
        /// 필터를 끝낸 후 다시 복귀
1679
        /// </summary>
1680
1681
        public void Reset(object obj)
1682
        {
1683 50b63148 semi
            SearchTimerOn = false;
1684 93f5e32a semi
            ExcptionCheck = false;
1685 037ab674 semi
            SelectedInt = 10;
1686
            ProjectNumberFilter = ProjectNames[0];
1687 3bde451b semi
            DocumentIDFilter = null;
1688
            MarkupInfo_IDFilter = null;
1689
            DOCINFO_IDFilter = null;
1690
            Document_NameFilter = null;
1691
            Document_NOFilter = null;
1692
            CreateUser_IDFilter = null;
1693
            GROUP_NOFilter = null;
1694
            REVISIONFilter = null;
1695 aaed7be2 semi
            Document_URLFilter = null;
1696 3bde451b semi
1697 95e7bd84 semi
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1698 3bde451b semi
            SelectedCreateTimeBegin = DefaultCreateTime;
1699 037ab674 semi
            SelectedCreateTimeEnd = DefaultCreateTime;
1700 3bde451b semi
1701 037ab674 semi
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1702 3bde451b semi
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1703
1704 d6526b0c semi
            FilterConvertSource.Clear();
1705
1706
            Timer_Tick(null, new EventArgs());
1707
1708 3bde451b semi
        }
1709
1710
        #endregion
1711
1712
        #region ConvertAddDialog
1713
1714
        /// <summary>
1715
        /// 그리드 상단 Conver 추가 버튼
1716
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1717
        /// </summary>
1718
1719
        public void ConverAdd(object obj)
1720
        {
1721 50b63148 semi
            if (SearchTimerOn == true)
1722
            {
1723
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1724
            }
1725
            else
1726
            {
1727
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1728
            }
1729 3bde451b semi
1730
            Views.FinalPDFAddDialog convertAddDialog = new Views.FinalPDFAddDialog();
1731
1732 50b63148 semi
            convertAddDialog.Owner = Application.Current.MainWindow;
1733 3bde451b semi
            convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1734
1735
            convertAddDialog.ShowDialog();
1736
1737 50b63148 semi
            if (SearchTimerOn == true)
1738
            {
1739
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1740
            }
1741
            else
1742
            {
1743
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1744
            }
1745 3bde451b semi
        }
1746
1747
        #endregion
1748
1749 f047c8bf semi
        #region DocumentFilter
1750
1751
        /// <summary>
1752
        /// 그리드 상단 Conver 추가 버튼
1753
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1754
        /// </summary>
1755
1756
        public void DocumentFilter(object obj)
1757
        {
1758
            try
1759
            {
1760 f25fc1d9 semi
                if (SearchTimerOn == true)
1761
                {
1762
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1763
                }
1764
                else
1765
                {
1766
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1767
                }
1768
1769
1770
                Views.ConvertDocumentDialog convertDocumentDialog = new Views.ConvertDocumentDialog(SelectedCount.ValueMember, REVISIONFilter, Document_NOFilter, Document_NameFilter, GROUP_NOFilter, Document_URLFilter, DocumentIDFilter, ProjectNumberFilter.Project_NO);
1771 f047c8bf semi
1772 f25fc1d9 semi
                convertDocumentDialog.Owner = Application.Current.MainWindow;
1773
                convertDocumentDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1774 944a39ed semi
                convertDocumentDialog.Width = 1000;
1775
                convertDocumentDialog.Height = 600;
1776 f25fc1d9 semi
1777
                convertDocumentDialog.ShowDialog();
1778
1779
                if (SearchTimerOn == true)
1780
                {
1781
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1782
                }
1783
                else
1784
                {
1785
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1786
                }
1787 f047c8bf semi
            }
1788
            catch (Exception ex)
1789
            {
1790
                MessageBox.Show(ex.ToString());
1791
            }
1792
        }
1793
1794
        #endregion
1795
1796 95e7bd84 semi
        #region FinalPDFPathFileSearch
1797 78683624 semi
1798
        /// <summary>
1799
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1800
        /// </summary>
1801
1802 95e7bd84 semi
        public void FinalPDFPathFileSearch(object obj)
1803 78683624 semi
        {
1804
            if (obj is FinalPDF)
1805
            {
1806
                if (obj != null)
1807
                {
1808 95e7bd84 semi
                    var convertitem = obj as FinalPDF;
1809 78683624 semi
1810
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
1811
1812
                    saveFileDialog.FileName = "Document"; // Default file name
1813
                    saveFileDialog.DefaultExt = ".txt"; // Default file extension
1814
                    saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension
1815
1816
1817
                    if (saveFileDialog.ShowDialog() == true)
1818
                    {
1819
                    }
1820
                }
1821
            }
1822
        }
1823
1824
        #endregion
1825
1826 3bde451b semi
        #endregion
1827
    }
1828
}
클립보드 이미지 추가 (최대 크기: 500 MB)