프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceController / Markus.Service.StationController / ViewModel / FinalPDFViewModel.cs @ fc4e50f2

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

1
using Markus.Service.Extensions;
2
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
using Newtonsoft.Json;
25
using static Markus.Service.StationController.Data.FinalPDF;
26
using System.Collections.ObjectModel;
27

    
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
            FinalPDFPathFileSearchCommand = new DelegateCommand(FinalPDFPathFileSearch);
49
            Stop_ProcessCommand = new DelegateCommand(Stop_Process);
50
            DocumentFilterCommand = new DelegateCommand(DocumentFilter);
51
            Markup_CheckCommand = new DelegateCommand(Markup_Check);
52
        }
53

    
54
        #endregion
55

    
56
        #region Properties
57

    
58
        DataService.DataServiceClient WcfClient = new DataService.DataServiceClient();
59

    
60

    
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
        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
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _FilterSearch;
98
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> FilterSearch
99
        {
100
            get
101
            {
102
                if (_FilterSearch == null)
103
                {
104
                    _FilterSearch = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>
105
                            {
106
                                new FinalPDF{ProjectNumber = "Filter Search"}
107
                            };
108
                }
109

    
110
                return _FilterSearch;
111
            }
112
        }
113

    
114
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _AliveItems;
115
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> AliveItems
116
        {
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
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _FilterConvertSource;
135
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> FilterConvertSource
136
        {
137
            get
138
            {
139
                if (_FilterConvertSource == null)
140
                {
141
                    _FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
142
                }
143
                return _FilterConvertSource;
144
            }
145
            set
146
            {
147
                _FilterConvertSource = value;
148
                OnPropertyChanged(() => FilterConvertSource);
149
            }
150
        }
151

    
152

    
153
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _RealConvertSource;
154
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> RealConvertSource
155
        {
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
        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
        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
        private FinalPDF _SelectFilterConvert;
236
        public FinalPDF SelectFilterConvert
237
        {
238
            get => _SelectFilterConvert;
239
            set
240
            {
241
                _SelectFilterConvert = value;
242
                OnPropertyChanged(() => SelectFilterConvert);
243
            }
244
        }
245

    
246

    
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
        private FinalPDF _SelectRealConvert;
267
        public FinalPDF SelectRealConvert
268
        {
269
            get => _SelectRealConvert;
270
            set
271
            {
272
                _SelectRealConvert = value;
273
                OnPropertyChanged(() => SelectRealConvert);
274
            }
275
        }
276

    
277

    
278
        private FinalPDF _SelectAliveConvert;
279
        public FinalPDF SelectAliveConvert
280
        {
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
        public ProjectName _ProjectNumberFilter;
330
        public ProjectName ProjectNumberFilter
331
        {
332
            get
333
            {
334
                if (_ProjectNumberFilter == null)
335
                {
336
                    _ProjectNumberFilter = new ProjectName();
337
                }
338
                return _ProjectNumberFilter;
339
            }
340
            set
341
            {
342
                _ProjectNumberFilter = value;
343
                OnPropertyChanged(() => ProjectNumberFilter);
344
            }
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
        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

    
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
        static DateTime DefaultCreateTime = DateTime.Now.AddHours(-1);
556
        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

    
634
        public bool _AliveShow = false;
635
        public bool AliveShow
636
        {
637
            get => _AliveShow;
638
            set
639
            {
640
                _AliveShow = value;
641
                OnPropertyChanged(() => AliveShow);
642
            }
643
        }
644

    
645

    
646
        private int? _ExcptionCheck;
647
        public int? ExcptionCheck
648
        {
649
            get
650
            {
651
                return _ExcptionCheck;
652
            }
653
            set
654
            {
655
                _ExcptionCheck = value;
656
                OnPropertyChanged(() => ExcptionCheck);
657
            }
658
        }
659

    
660
        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
        #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
        public DelegateCommand FinalPDFPathFileSearchCommand { get; private set; }
690
        public DelegateCommand Stop_ProcessCommand { get; private set; }
691
        public DelegateCommand EnterCommand { get; private set; }
692
        public DelegateCommand DocumentFilterCommand { get; private set; }
693
        public DelegateCommand Markup_CheckCommand { get; private set; }
694

    
695
        #endregion
696

    
697
        #region Main Logic
698

    
699
        /// <summary>
700
        /// 각각의 Grid row 객체들 업데이트
701
        /// </summary>
702

    
703
        private DispatcherTimer dispatcherTimer;
704
        public override void Loaded()
705
        {
706
            base.Loaded();
707

    
708
            if (!App.IsDesignMode)
709
            {
710
                dispatcherTimer = new DispatcherTimer();
711
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
712
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
713
                dispatcherTimer.Start();
714
            }
715
        }
716

    
717
        private async void Timer_Tick(object sender, EventArgs e)
718
        {
719
            dispatcherTimer.Stop();
720

    
721
            if (IsAcitve)
722
            {
723
                await App.Current.Dispatcher.InvokeAsync(() =>
724
                {
725
                    DataSelect();
726

    
727
                    AliveDataSelect();
728
                });
729
            }
730

    
731
            await Task.Delay(5000);
732

    
733
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
734

    
735
            dispatcherTimer.Start();
736
        }
737

    
738
        private async void SearchTimer_Tick(object sender, EventArgs e)
739
        {
740
            dispatcherTimer.Stop();
741

    
742
            if (IsAcitve)
743
            {
744
                await App.Current.Dispatcher.InvokeAsync(() =>
745
                {
746
                    DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
747

    
748
                    RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
749

    
750
                    AliveDataSelect();
751
                });
752
            }
753

    
754
            await Task.Delay(5000);
755

    
756
            dispatcherTimer.Start();
757
        }
758

    
759

    
760
        public override void Closed()
761
        {
762
            if (dispatcherTimer != null)
763
            {
764
                dispatcherTimer.Stop();
765
            }
766

    
767
            base.Closed();
768
        }
769

    
770

    
771
        #endregion
772

    
773
        #region Function
774

    
775
        #region Return_FilterConvertSource
776

    
777
        public static void Return_FilterConvertSource(ObservableCollection<FinalPDF> convertPDFs)
778
        {
779
            ConvertSource = new ObservableCollection<FinalPDF>();
780
            ConvertSource = convertPDFs;
781
        }
782

    
783
        public static ObservableCollection<FinalPDF> Return_FilterConvertSource()
784
        {
785
            return ConvertSource;
786
        }
787

    
788

    
789
        #endregion
790

    
791
        #region Data Select
792

    
793
        /// <summary>
794
        /// 상단 그리드 중앙 그리드 출력 데이터
795
        /// </summary>
796
        private void DataSelect()
797
        {
798

    
799
            if (FilterConvertSource == null)
800
            {
801
                FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
802
            }
803

    
804
            if (RealConvertSource == null)
805
            {
806
                RealConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
807
            }
808

    
809
            /// combobox 에서 선택된 items
810
            if (SelectedStatus != null)
811
            {
812
                DataSelect(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
813
            }
814

    
815
            /// 컨버터중인 items
816
            RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
817

    
818
        }
819

    
820
        private async void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection)
821
        {
822
            try
823
            {
824
                IEnumerable<FinalPDF> Listitems = Enumerable.Empty<FinalPDF>();
825

    
826
                foreach (var coll in collection)
827
                {
828
                   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)
829
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
830
                                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,
831
                            x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
832

    
833
                }
834

    
835
                foreach (var Listitem in Listitems)
836
                {
837
                    collection.UpdateWhere(changeitem =>
838
                    ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
839
                }
840

    
841
                RealConvert_Height = 80 + (10 * collection.Count());
842
                DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
843
            }
844
            catch (Exception ex)
845
            {
846
                MessageBox.Show(ex.ToString());
847
            }
848
        }
849

    
850
        private async void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection)
851
        {
852
            try
853
            {
854
                int _status = 0;
855
                if (SelectedStatus != null)
856
                {
857
                    _status = (int)SelectedStatus.Value;
858
                }
859

    
860
                if (ProjectNames.Count() == 0)
861
                {
862
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
863
                    ProjectNames.Add(Clear);
864
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
865
                    {
866
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
867
                        ProjectNames.Add(projectName);
868
                    }
869
                }
870

    
871
                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)
872
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
873
                                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,
874
                        x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
875
                     , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
876

    
877
                if (collection.Count() == 0)
878
                {
879
                    if (statusCodeTypeList.Count() == 1)
880
                    {
881
                        foreach (var x in Listitems)
882
                        {
883
                            collection.Add(x);
884
                        }
885
                    }
886
                }
887
                else
888
                {
889
                    foreach (var newitem in Listitems)
890
                    {
891
                        collection.UpdateWhere(changeitem =>
892
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
893
                    }
894

    
895
                    if (statusCodeTypeList.Count() == 1)
896
                    {
897
                        for (int i = collection.Count() - 1; i >= 0; --i)
898
                        {
899
                            var item = collection[i];
900

    
901
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
902
                            {
903
                                collection.RemoveAt(i);
904
                            }
905
                        }
906
                    }
907

    
908
                    if (statusCodeTypeList.Count() == 1)
909
                    {
910
                        foreach (var item in Listitems)
911
                        {
912
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
913
                            {
914
                                for (int i = 0; i < 200; i++)
915
                                {
916
                                    if (i < collection.Count() - 1)
917
                                    {
918
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
919
                                        {
920
                                            collection.Insert(i, item);
921
                                            break;
922
                                        }
923
                                    }
924
                                    else
925
                                    {
926
                                        collection.Add(item);
927
                                        break;
928
                                    }
929
                                }
930

    
931
                            }
932

    
933
                        }
934
                    }
935
                }
936
            }
937
            catch (Exception ex)
938
            {
939
                MessageBox.Show(ex.ToString());
940
                System.Diagnostics.Debug.WriteLine(ex.ToString());
941
            }
942
        }
943

    
944
        private async void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection)
945
        {
946
            try
947
            {
948
                int _status = 0;
949
                if (SelectedStatus != null)
950
                {
951
                    _status = (int)SelectedStatus.Value;
952
                }
953

    
954
                DateTime? Start_CreateTime = null;
955
                DateTime? Finish_CreateTime = null;
956
                if (SelectedCreateTimeBegin != DefaultCreateTime)
957
                {
958
                    Start_CreateTime = SelectedCreateTimeBegin;
959
                }
960
                if (SelectedCreateTimeEnd != DefaultCreateTime)
961
                {
962
                    Finish_CreateTime = SelectedCreateTimeEnd;
963
                }
964

    
965
                if (ProjectNames.Count() == 0)
966
                {
967
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
968
                    ProjectNames.Add(Clear);
969
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
970
                    {
971
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
972
                        ProjectNames.Add(projectName);
973
                    }
974
                }
975

    
976
                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,
977
                    CreateUser_IDFilter, _status, SelectedCount.ValueMember, GROUP_NOFilter, REVISIONFilter, Start_CreateTime, Finish_CreateTime, null, null, null, null, Document_URLFilter, ExcptionCheck)
978
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
979
                                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,
980
                                    x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
981
                                 , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
982

    
983
                if (collection.Count() == 0)
984
                {
985
                    if (statusCodeTypeList.Count() == 1)
986
                    {
987
                        foreach (var x in Listitems)
988
                        {
989
                            collection.Add(x);
990
                        }
991
                    }
992
                }
993
                else
994
                {
995
                    foreach (var newitem in Listitems)
996
                    {
997
                        collection.UpdateWhere(changeitem =>
998
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
999
                    }
1000

    
1001
                    if (statusCodeTypeList.Count() == 1)
1002
                    {
1003

    
1004
                        for (int i = collection.Count() - 1; i >= 0; --i)
1005
                        {
1006
                            var item = collection[i];
1007

    
1008
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1009
                            {
1010
                                collection.RemoveAt(i);
1011
                            }
1012
                        }
1013
                    }
1014

    
1015
                    if (statusCodeTypeList.Count() == 1)
1016
                    {
1017
                        foreach (var item in Listitems)
1018
                        {
1019
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1020
                            {
1021
                                for (int i = 0; i < 200; i++)
1022
                                {
1023
                                    if (i < collection.Count() - 1)
1024
                                    {
1025
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
1026
                                        {
1027
                                            collection.Insert(i, item);
1028
                                            break;
1029
                                        }
1030
                                    }
1031
                                    else
1032
                                    {
1033
                                        collection.Add(item);
1034
                                        break;
1035
                                    }
1036
                                }
1037

    
1038
                            }
1039

    
1040
                        }
1041
                    }
1042

    
1043
                }
1044
            }
1045
            catch (Exception ex)
1046
            {
1047
                MessageBox.Show(ex.ToString());
1048
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1049
            }
1050
        }
1051
        /// <summary>
1052
        /// 서비스의 실시간 컨버터 Item
1053
        /// </summary>
1054
        private async void AliveDataSelect()
1055
        {
1056
            try
1057
            {
1058
                List<FinalPDF> newitems = new List<FinalPDF>();
1059
                foreach (var client in App.StationClientList)
1060
                {
1061
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
1062
                    {
1063
                        try
1064
                        {
1065
                            List<FinalPDF> itemsToList = new List<FinalPDF>();
1066
                            var items = await client.AliveConvertListAsync();
1067
                            string result = "";
1068

    
1069
                            if (items.Count() > 0)
1070
                            {
1071
                                AliveShow = true;
1072
                            }
1073

    
1074

    
1075
                            foreach (var item in items)
1076
                            {
1077
                                FinalPDF itemsToEach = new FinalPDF();
1078
                                itemsToEach.ConvertID = item.ConvertID;
1079
                                itemsToEach.ProjectNumber = item.ProjectNumber;
1080

    
1081
                                var MarkusLink = "kcom://" + CreateMarkusParam(item.ProjectNumber, item.DocumentID, "doftech");
1082

    
1083
                                if (item.ConvertState != null)
1084
                                {
1085
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
1086
                                }
1087

    
1088
                                if (item.OriginfilePath.Contains("/"))
1089
                                {
1090
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1091
                                }
1092
                                else
1093
                                {
1094
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1095
                                }
1096
                                itemsToEach.FileName = result;
1097

    
1098
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
1099
                                itemsToEach.TotalPage = item.TotalPage;
1100
                                itemsToEach.OriginfilePath = item.OriginfilePath;
1101
                                itemsToEach.ConvertPath = item.ConvertPath;
1102
                                itemsToEach.MarkusLink = MarkusLink;
1103
                                itemsToEach.DocumentID = item.DocumentID;
1104
                                itemsToEach.GroupNo = item.GroupNo;
1105
                                itemsToEach.DocumentName = item.DocumnetName;
1106
                                itemsToEach.Revision = item.Revision;
1107
                                itemsToEach.Exception = item.Exception;
1108
                                itemsToEach.ConvertPath = item.ConvertPath;
1109
                                itemsToEach.CreateTime = item.CreateTime;
1110
                                itemsToEach.StartTime = item.StartTime;
1111
                                itemsToEach.EndTime = item.EndTime;
1112

    
1113
                                itemsToList.Add(itemsToEach);
1114
                            }
1115
                            newitems.AddRange(itemsToList);
1116
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1117

    
1118
                            if (items.Count() == 0)
1119
                            {
1120
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1121
                            }
1122
                        }
1123
                        catch (Exception ex)
1124
                        {
1125
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1126
                        }
1127
                    }
1128
                    else
1129
                    {
1130
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1131
                    }
1132

    
1133
                }
1134
                ItemsUpdate(newitems);
1135
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1136
            }
1137
            catch (Exception ex)
1138
            {
1139
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1140
            }
1141
        }
1142

    
1143
        /// <summary>
1144
        /// AliveDataSelect의 Data Update
1145
        /// </summary>
1146
        /// <param name = "newitems" ></ param >
1147
        private void ItemsUpdate(List<FinalPDF> newitems)
1148
        {
1149

    
1150
            foreach (var item in newitems)
1151
            {
1152
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1153
            }
1154

    
1155
            if (AliveItems == null)
1156
            {
1157
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
1158

    
1159
                foreach (var item in newitems)
1160
                {
1161
                    AliveItems.Add(item);
1162
                }
1163
            }
1164
            else
1165
            {
1166
                newitems.ForEach(newitem =>
1167
                {
1168
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1169
                });
1170

    
1171
                foreach (var item in newitems)
1172
                {
1173
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1174
                    {
1175
                        AliveItems.Add(item);
1176
                    }
1177
                }
1178

    
1179
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1180
                {
1181
                    var item = AliveItems[i];
1182

    
1183
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1184
                    {
1185
                        try
1186
                        {
1187
                            AliveItems.RemoveAt(i);
1188
                        }
1189
                        catch (Exception ex)
1190
                        {
1191
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1192
                        }
1193
                    }
1194
                }
1195
            }
1196

    
1197

    
1198
            Alive_Height = 80 + (newitems.Count() * 10);
1199
            DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
1200
        }
1201

    
1202

    
1203
        public static async Task<bool> SimplePingAsync(string uri)
1204
        {
1205
            bool result = false;
1206

    
1207
            try
1208
            {
1209
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1210
                {
1211
                    Client.Timeout = new TimeSpan(0, 0, 60);
1212

    
1213
                    var message = await Client.GetAsync(uri);
1214

    
1215
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1216

    
1217
                    switch (StatusCode)
1218
                    {
1219

    
1220
                        case System.Net.HttpStatusCode.Accepted:
1221
                        case System.Net.HttpStatusCode.OK:
1222
                            result = true;
1223
                            break;
1224
                    }
1225
                }
1226
            }
1227
            catch (Exception ex)
1228
            {
1229
                result = false;
1230
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1231
            }
1232

    
1233
            return result;
1234
        }
1235

    
1236
        #endregion
1237

    
1238
        #region Data Convert
1239

    
1240
        private async void DataConvert(object obj)
1241
        {
1242
            if (obj is FinalPDF)
1243
            {
1244

    
1245
                if (obj != null)
1246
                {
1247
                    var convertitem = obj as FinalPDF;
1248

    
1249
                    SelectRealConvert = convertitem;
1250
                    SetCleanUpItem(SelectRealConvert);
1251

    
1252

    
1253
                    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)
1254
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
1255
                                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,
1256
                            x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1257
                         , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
1258

    
1259
                    foreach (var item in items)
1260
                    {
1261
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1262
                        {
1263
                            RealConvertSource.Add(item);
1264
                        }
1265
                        if (RealConvertSource.Count() == 1)
1266
                        {
1267
                            ConvertShow = true;
1268
                        }
1269
                    }
1270
                }
1271
            }
1272
            else if (SelectFilterConvertList == null)
1273
            {
1274
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1275
            }
1276
            else
1277
            {
1278
                if (SelectFilterConvertList != null)
1279
                {
1280
                    foreach (var SelectFilterConvert in SelectFilterConvertList)
1281
                    {
1282
                        SetCleanUpItem(SelectFilterConvert);
1283
                    }
1284
                }
1285

    
1286
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1287
                {
1288
                    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)
1289
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
1290
                                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,
1291
                            x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1292
                         , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
1293

    
1294

    
1295
                    foreach (var item in items)
1296
                    {
1297
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1298
                        {
1299
                            RealConvertSource.Add(item);
1300
                        }
1301
                        if (RealConvertSource.Count() == 1)
1302
                        {
1303
                            ConvertShow = true;
1304
                        }
1305
                    }
1306
                }
1307
            }
1308
        }
1309

    
1310

    
1311
        public async void SetCleanUpItem(FinalPDF _ConvertItem)
1312
        {
1313

    
1314
            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);
1315

    
1316
            if (items.Count() > 0)
1317
            {
1318
                var item = items.First();
1319

    
1320
                var _CREATE_DATETIME = DateTime.Now.AddHours(-1);
1321
                var _STATUS = (int)StatusCodeType.None;
1322

    
1323
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, 0, _CREATE_DATETIME, _STATUS, null);
1324

    
1325
            }
1326
        }
1327

    
1328
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1329
        {
1330
            ViewInfo viewInfo = new ViewInfo();
1331

    
1332
            viewInfo.DocumentItemID = documentID;
1333
            viewInfo.ProjectNO = projectNo;
1334
            viewInfo.UserID = userID;
1335

    
1336
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1337

    
1338
        }
1339

    
1340
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1341
        {
1342

    
1343
            if (oEncoding == null)
1344
                oEncoding = System.Text.Encoding.UTF8;
1345

    
1346
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1347

    
1348
        }
1349

    
1350
        #endregion
1351

    
1352
        #region Validation
1353

    
1354
        private void DataValidate(object obj)
1355
        {
1356
            if (obj is FinalPDF)
1357
            {
1358

    
1359
                if (obj != null)
1360
                {
1361
                    var convertitem = obj as FinalPDF;
1362

    
1363
                    SelectRealConvert = convertitem;
1364

    
1365
                    bool result = false;
1366
                    WebRequest webRequest = WebRequest.Create(SelectRealConvert.OriginfilePath);
1367
                    webRequest.Timeout = 1200; // miliseconds
1368
                    webRequest.Method = "HEAD";
1369

    
1370
                    HttpWebResponse response = null;
1371

    
1372
                    try
1373
                    {
1374
                        response = (HttpWebResponse)webRequest.GetResponse();
1375
                        result = true;
1376
                    }
1377
                    catch (WebException webException)
1378
                    {
1379
                        MessageBox.Show(SelectRealConvert.FileName + " doesn't exist: " + webException.Message);
1380
                        result = true;
1381
                    }
1382
                    finally
1383
                    {
1384
                        if (response != null)
1385
                        {
1386
                            response.Close();
1387
                        }
1388
                    }
1389
                    if (result == true)
1390
                    {
1391
                        MessageBox.Show("File exists");
1392
                    }
1393
                }
1394
            }
1395
            else if (SelectFilterConvertList.Count() > 1)
1396
            {
1397
                MessageBox.Show("하나만 클릭해 주세요");
1398
            }
1399
            else if (SelectFilterConvertList.Count() == 0)
1400
            {
1401
                MessageBox.Show("왼쪽 버튼 클릭 후 Validate 해주세요!");
1402
            }
1403
            else
1404
            {
1405
                bool result = false;
1406
                WebRequest webRequest = WebRequest.Create(SelectFilterConvertList[0].OriginfilePath);
1407
                webRequest.Timeout = 1200; // miliseconds
1408
                webRequest.Method = "HEAD";
1409

    
1410
                HttpWebResponse response = null;
1411

    
1412
                try
1413
                {
1414
                    response = (HttpWebResponse)webRequest.GetResponse();
1415
                    result = true;
1416
                }
1417
                catch (WebException webException)
1418
                {
1419
                    MessageBox.Show(SelectFilterConvertList[0].FileName + " doesn't exist: " + webException.Message);
1420
                    result = false;
1421
                }
1422
                finally
1423
                {
1424
                    if (response != null)
1425
                    {
1426
                        response.Close();
1427
                    }
1428
                }
1429
                if (result == true)
1430
                {
1431
                    MessageBox.Show("File exists");
1432
                }
1433
            }
1434

    
1435
        }
1436

    
1437
        #endregion
1438

    
1439
        #region Data Delete
1440

    
1441
        private void DataDelete(object obj)
1442
        {
1443
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1444
            {
1445
                var result = evt.DialogResult;
1446

    
1447
                if (result == true)
1448
                {
1449
                    OnClosed(obj);
1450
                }
1451
            };
1452

    
1453
            RadWindow.Confirm("Do you want to delete it??", handler);
1454
        }
1455

    
1456
        private async void OnClosed(object obj)
1457
        {
1458
            if (obj is FinalPDF)
1459
            {
1460
                if (obj != null)
1461
                {
1462
                    var convertitem = obj as FinalPDF;
1463

    
1464
                    SelectRealConvert = convertitem;
1465
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1466

    
1467
                }
1468
            }
1469
            else if (SelectFilterConvertList.Count() > 1)
1470
            {
1471
                MessageBox.Show("하나만 클릭해 주세요!");
1472
            }
1473
            else if (SelectFilterConvertList.Count() == 0)
1474
            {
1475
                MessageBox.Show("왼쪽 버튼 클릭 후 Delete 해주세요!");
1476
            }
1477
            else
1478
            {
1479
                if (SelectFilterConvertList != null)
1480
                {
1481
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectFilterConvertList[0].ConvertID);
1482
                }
1483
            }
1484
        }
1485

    
1486
        #endregion
1487

    
1488
        #region Stop Process
1489

    
1490
        private void Stop_Process(object obj)
1491
        {
1492

    
1493
            string convertid = "";
1494

    
1495
            if (obj is FinalPDF)
1496
            {
1497

    
1498
                if (obj != null)
1499
                {
1500
                    var convertitem = obj as FinalPDF;
1501

    
1502
                    SelectRealConvert = convertitem;
1503

    
1504
                    SelectAliveConvert = convertitem;
1505

    
1506
                    convertid = convertitem.ConvertID;
1507
                }
1508
            }
1509

    
1510

    
1511
#if DEBUG
1512
            convertid = "TEST";
1513
#endif
1514

    
1515
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1516
            {
1517
                var result = evt.DialogResult;
1518

    
1519
                if (result == true)
1520
                {
1521
                    Stop_Process(convertid);
1522
                }
1523
            };
1524

    
1525
            RadWindow.Confirm("프로세스 종료 할까요??", handler);
1526
        }
1527

    
1528
        private async void Stop_Process(string convertId)
1529
        {
1530
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10));
1531

    
1532
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1533

    
1534
            for (int i = process.Count() - 1; i >= 0; i--)
1535
            {
1536
                try
1537
                {
1538
                    var commandLines = process[i].Arguments().CommandLine;
1539

    
1540
                    if (commandLines.Count() > 0)
1541
                    {
1542
                        if (commandLines[0] == convertId)
1543
                        {
1544

    
1545
                            var _CREATE_DATETIME = DateTime.Now;
1546

    
1547
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 3, null);
1548
                            process[i].WaitForExit(5000);
1549
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 99, null);
1550
                            process[i].Kill();
1551
                        }
1552
                    }
1553
                }
1554
                catch (Exception ex)
1555
                {
1556
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
1557
                }
1558
            }
1559
        }
1560

    
1561
        #endregion
1562

    
1563
        #region DataFilter
1564

    
1565
        public void DataFilter(object obj)
1566
        {
1567
            SearchTimerOn = true;
1568
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1569
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1570

    
1571
            FilterConvertSource.Clear();
1572

    
1573
            SearchTimer_Tick(null, new EventArgs());
1574
        }
1575

    
1576
        #endregion
1577

    
1578
        #region MarkusLink
1579

    
1580
        private void MarkusLink(object obj)///여기서 부터 
1581
        {
1582
            if (obj is FinalPDF)
1583
            {
1584
                if (obj != null)
1585
                {
1586
                    var convertitem = obj as FinalPDF;
1587

    
1588
                    SelectFilterConvertList.Add(convertitem);
1589

    
1590
                    SelectRealConvert = convertitem;
1591

    
1592
                    ProcessStartInfo startInfo = null;
1593

    
1594
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1595

    
1596
                    Process.Start(startInfo);
1597
                }
1598
            }
1599
        }
1600

    
1601
        #endregion
1602

    
1603
        #region Data Export
1604

    
1605

    
1606
        /// <summary>
1607
        /// 필터된 상단 그리드 엑셀로 출력
1608
        /// </summary>
1609

    
1610
        public void DataExportData(object obj)
1611
        {
1612
            if (SearchTimerOn == true)
1613
            {
1614
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1615
            }
1616
            else
1617
            {
1618
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1619
            }
1620

    
1621
            Return_FilterConvertSource(FilterConvertSource);
1622

    
1623
            Views.FinalPDFExcelDialog finalPDFExcelDialog = new Views.FinalPDFExcelDialog();
1624

    
1625
            finalPDFExcelDialog.Owner = Application.Current.MainWindow;
1626
            finalPDFExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1627

    
1628
            finalPDFExcelDialog.ShowDialog();
1629

    
1630

    
1631
            if (SearchTimerOn == true)
1632
            {
1633
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1634
            }
1635
            else
1636
            {
1637
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1638
            }
1639
        }
1640

    
1641
        #endregion
1642

    
1643
        #region Data Search
1644

    
1645
        public void RemoveCreateTimeFilter(object obj)
1646
        {
1647
            DefaultCreateTime = DateTime.Now.AddHours(-1); ;
1648
            SelectedCreateTimeBegin = DefaultCreateTime;
1649
            SelectedCreateTimeEnd = DefaultCreateTime;
1650

    
1651
        }
1652

    
1653
        #endregion
1654

    
1655
        #region Reset
1656

    
1657
        /// <summary>
1658
        /// 그리드 상단 원상복귀 버튼
1659
        /// 필터를 끝낸 후 다시 복귀
1660
        /// </summary>
1661

    
1662
        public void Reset(object obj)
1663
        {
1664
            SearchTimerOn = false;
1665
            ExcptionCheck = null;
1666
            SelectedInt = 12;
1667
            ProjectNumberFilter = ProjectNames[0];
1668
            DocumentIDFilter = null;
1669
            MarkupInfo_IDFilter = null;
1670
            DOCINFO_IDFilter = null;
1671
            Document_NameFilter = null;
1672
            Document_NOFilter = null;
1673
            CreateUser_IDFilter = null;
1674
            GROUP_NOFilter = null;
1675
            REVISIONFilter = null;
1676
            Document_URLFilter = null;
1677

    
1678
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1679
            SelectedCreateTimeBegin = DefaultCreateTime;
1680
            SelectedCreateTimeEnd = DefaultCreateTime;
1681

    
1682
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1683
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1684

    
1685
            FilterConvertSource.Clear();
1686

    
1687
            Timer_Tick(null, new EventArgs());
1688

    
1689
        }
1690

    
1691
        #endregion
1692

    
1693
        #region ConvertAddDialog
1694

    
1695
        /// <summary>
1696
        /// 그리드 상단 Conver 추가 버튼
1697
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1698
        /// </summary>
1699

    
1700
        public void ConverAdd(object obj)
1701
        {
1702
            if (SearchTimerOn == true)
1703
            {
1704
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1705
            }
1706
            else
1707
            {
1708
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1709
            }
1710

    
1711
            Views.FinalPDFAddDialog convertAddDialog = new Views.FinalPDFAddDialog();
1712

    
1713
            convertAddDialog.Owner = Application.Current.MainWindow;
1714
            convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1715

    
1716
            convertAddDialog.ShowDialog();
1717

    
1718
            if (SearchTimerOn == true)
1719
            {
1720
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1721
            }
1722
            else
1723
            {
1724
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1725
            }
1726
        }
1727

    
1728
        #endregion
1729

    
1730
        #region DocumentFilter
1731

    
1732
        /// <summary>
1733
        /// 그리드 상단 Conver 추가 버튼
1734
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1735
        /// </summary>
1736

    
1737
        public void DocumentFilter(object obj)
1738
        {
1739
            try
1740
            {
1741
                if (SearchTimerOn == true)
1742
                {
1743
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1744
                }
1745
                else
1746
                {
1747
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1748
                }
1749

    
1750

    
1751
                Views.ConvertDocumentDialog convertDocumentDialog = new Views.ConvertDocumentDialog(SelectedCount.ValueMember, REVISIONFilter, Document_NOFilter, Document_NameFilter, GROUP_NOFilter, Document_URLFilter, DocumentIDFilter, ProjectNumberFilter.Project_NO);
1752

    
1753
                convertDocumentDialog.Owner = Application.Current.MainWindow;
1754
                convertDocumentDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1755
                convertDocumentDialog.Width = 1000;
1756
                convertDocumentDialog.Height = 600;
1757

    
1758
                convertDocumentDialog.ShowDialog();
1759

    
1760
                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
            catch (Exception ex)
1770
            {
1771
                MessageBox.Show(ex.ToString());
1772
            }
1773
        }
1774

    
1775
        #endregion
1776

    
1777
        #region FinalPDFPathFileSearch
1778

    
1779
        /// <summary>
1780
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1781
        /// </summary>
1782

    
1783
        public void FinalPDFPathFileSearch(object obj)
1784
        {
1785
            if (obj is FinalPDF)
1786
            {
1787
                if (obj != null)
1788
                {
1789
                    var convertitem = obj as FinalPDF;
1790

    
1791
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
1792

    
1793
                    saveFileDialog.FileName = "Document"; // Default file name
1794
                    saveFileDialog.DefaultExt = ".txt"; // Default file extension
1795
                    saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension
1796

    
1797

    
1798
                    if (saveFileDialog.ShowDialog() == true)
1799
                    {
1800
                    }
1801
                }
1802
            }
1803
        }
1804

    
1805
        #endregion
1806

    
1807
        #region Markup_Check
1808

    
1809
        public void Markup_Check(object obj)
1810
        {
1811
            if (SearchTimerOn == true)
1812
            {
1813
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1814
            }
1815
            else
1816
            {
1817
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1818
            }
1819

    
1820
            if (SelectFilterConvertList != null)
1821
            {
1822
                Views.MarkupCheckView markupCheckView = new Views.MarkupCheckView(SelectFilterConvertList[0].ProjectNumber, SelectFilterConvertList[0].DocumentID);
1823

    
1824
                markupCheckView.Owner = Application.Current.MainWindow;
1825
                markupCheckView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1826
                markupCheckView.Width = 1000;
1827
                markupCheckView.Height = 600;
1828

    
1829
                markupCheckView.Show();
1830
            }
1831

    
1832
            if (SearchTimerOn == true)
1833
            {
1834
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1835
            }
1836
            else
1837
            {
1838
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1839
            }
1840
        }
1841

    
1842
        #endregion
1843

    
1844
        #endregion
1845
    }
1846
}
클립보드 이미지 추가 (최대 크기: 500 MB)