프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (59.5 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
            EnterCommand = new DelegateCommand(Enter);
51
            DocumentFilterCommand = new DelegateCommand(DocumentFilter);
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 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

    
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

    
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
        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
        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
        #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
        #region Data Select
791

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

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

    
803
            if (RealConvertSource == null)
804
            {
805
                RealConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
806
            }
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
        private async void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection)
820
        {
821
            try
822
            {
823
                IEnumerable<FinalPDF> Listitems = Enumerable.Empty<FinalPDF>();
824

    
825
                foreach (var coll in collection)
826
                {
827
                   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
                                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

    
832
                }
833

    
834
                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
                }
839

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

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

    
859
                if (ProjectNames.Count() == 0)
860
                {
861
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
862
                    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
                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

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

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

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

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

    
930
                            }
931

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

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

    
953
                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

    
964
                if (ProjectNames.Count() == 0)
965
                {
966
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
967
                    ProjectNames.Add(Clear);
968
                    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
                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
                                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
                                    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

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

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

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

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

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

    
1037
                            }
1038

    
1039
                        }
1040
                    }
1041

    
1042
                }
1043
            }
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
                List<FinalPDF> newitems = new List<FinalPDF>();
1058
                foreach (var client in App.StationClientList)
1059
                {
1060
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
1061
                    {
1062
                        try
1063
                        {
1064
                            List<FinalPDF> itemsToList = new List<FinalPDF>();
1065
                            var items = await client.AliveConvertListAsync();
1066
                            string result = "";
1067

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

    
1073

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

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

    
1082
                                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
                                itemsToEach.MarkusLink = MarkusLink;
1102
                                itemsToEach.DocumentID = item.DocumentID;
1103
                                itemsToEach.GroupNo = item.GroupNo;
1104
                                itemsToEach.DocumentName = item.DocumnetName;
1105
                                itemsToEach.Revision = item.Revision;
1106
                                itemsToEach.Exception = item.Exception;
1107
                                itemsToEach.ConvertPath = item.ConvertPath;
1108
                                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
        private void ItemsUpdate(List<FinalPDF> newitems)
1147
        {
1148

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

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

    
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

    
1197
            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
        private async void DataConvert(object obj)
1240
        {
1241
            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
            {
1273
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1274
            }
1275
            else
1276
            {
1277
                if (SelectFilterConvertList != null)
1278
                {
1279
                    foreach (var SelectFilterConvert in SelectFilterConvertList)
1280
                    {
1281
                        SetCleanUpItem(SelectFilterConvert);
1282
                    }
1283
                }
1284

    
1285
                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

    
1293

    
1294
                    foreach (var item in items)
1295
                    {
1296
                        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
                    }
1305
                }
1306
            }
1307
        }
1308

    
1309

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

    
1313
            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

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

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

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

    
1324
            }
1325
        }
1326

    
1327
        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
        #endregion
1350

    
1351
        #region Validation
1352

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

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

    
1362
                    SelectRealConvert = convertitem;
1363

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

    
1369
                    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
            {
1396
                MessageBox.Show("하나만 클릭해 주세요");
1397
            }
1398
            else if (SelectFilterConvertList.Count() == 0)
1399
            {
1400
                MessageBox.Show("왼쪽 버튼 클릭 후 Validate 해주세요!");
1401
            }
1402
            else
1403
            {
1404
                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
                {
1413
                    response = (HttpWebResponse)webRequest.GetResponse();
1414
                    result = true;
1415
                }
1416
                catch (WebException webException)
1417
                {
1418
                    MessageBox.Show(SelectFilterConvertList[0].FileName + " doesn't exist: " + webException.Message);
1419
                    result = false;
1420
                }
1421
                finally
1422
                {
1423
                    if (response != null)
1424
                    {
1425
                        response.Close();
1426
                    }
1427
                }
1428
                if (result == true)
1429
                {
1430
                    MessageBox.Show("File exists");
1431
                }
1432
            }
1433

    
1434
        }
1435

    
1436
        #endregion
1437

    
1438
        #region Data Delete
1439

    
1440
        private void DataDelete(object obj)
1441
        {
1442
            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
        }
1454

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

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

    
1466
                }
1467
            }
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
                {
1480
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectFilterConvertList[0].ConvertID);
1481
                }
1482
            }
1483
        }
1484

    
1485
        #endregion
1486

    
1487
        #region Stop Process
1488

    
1489
        private void Stop_Process(object obj)
1490
        {
1491

    
1492
            string convertid = "";
1493

    
1494
            if (obj is FinalPDF)
1495
            {
1496

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

    
1501
                    SelectRealConvert = convertitem;
1502

    
1503
                    SelectAliveConvert = convertitem;
1504

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

    
1509

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

    
1514
            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
        }
1526

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

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

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

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

    
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
                            process[i].Kill();
1550
                        }
1551
                    }
1552
                }
1553
                catch (Exception ex)
1554
                {
1555
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
1556
                }
1557
            }
1558
        }
1559

    
1560
        #endregion
1561

    
1562
        #region DataFilter
1563

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

    
1570
            FilterConvertSource.Clear();
1571

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

    
1575
        #endregion
1576

    
1577
        #region MarkusLink
1578

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

    
1587
                    SelectFilterConvertList.Add(convertitem);
1588

    
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
        #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

    
1615
            FilterConvertSource.Clear();
1616

    
1617
            SearchTimer_Tick(null, new EventArgs());
1618
        }
1619

    
1620
        #endregion
1621

    
1622
        #region Data Export
1623

    
1624

    
1625
        /// <summary>
1626
        /// 필터된 상단 그리드 엑셀로 출력
1627
        /// </summary>
1628

    
1629
        public void DataExportData(object obj)
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
            Return_FilterConvertSource(FilterConvertSource);
1641

    
1642
            Views.FinalPDFExcelDialog finalPDFExcelDialog = new Views.FinalPDFExcelDialog();
1643

    
1644
            finalPDFExcelDialog.Owner = Application.Current.MainWindow;
1645
            finalPDFExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1646

    
1647
            finalPDFExcelDialog.ShowDialog();
1648

    
1649

    
1650
            if (SearchTimerOn == true)
1651
            {
1652
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1653
            }
1654
            else
1655
            {
1656
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1657
            }
1658
        }
1659

    
1660
        #endregion
1661

    
1662
        #region Data Search
1663

    
1664
        public void RemoveCreateTimeFilter(object obj)
1665
        {
1666
            DefaultCreateTime = DateTime.Now.AddHours(-1); ;
1667
            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
            SearchTimerOn = false;
1684
            ExcptionCheck = false;
1685
            SelectedInt = 10;
1686
            ProjectNumberFilter = ProjectNames[0];
1687
            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
            Document_URLFilter = null;
1696

    
1697
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1698
            SelectedCreateTimeBegin = DefaultCreateTime;
1699
            SelectedCreateTimeEnd = DefaultCreateTime;
1700

    
1701
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1702
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1703

    
1704
            FilterConvertSource.Clear();
1705

    
1706
            Timer_Tick(null, new EventArgs());
1707

    
1708
        }
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
            if (SearchTimerOn == true)
1722
            {
1723
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1724
            }
1725
            else
1726
            {
1727
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1728
            }
1729

    
1730
            Views.FinalPDFAddDialog convertAddDialog = new Views.FinalPDFAddDialog();
1731

    
1732
            convertAddDialog.Owner = Application.Current.MainWindow;
1733
            convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1734

    
1735
            convertAddDialog.ShowDialog();
1736

    
1737
            if (SearchTimerOn == true)
1738
            {
1739
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1740
            }
1741
            else
1742
            {
1743
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1744
            }
1745
        }
1746

    
1747
        #endregion
1748

    
1749
        #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
                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

    
1772
                convertDocumentDialog.Owner = Application.Current.MainWindow;
1773
                convertDocumentDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1774
                convertDocumentDialog.Width = 1000;
1775
                convertDocumentDialog.Height = 600;
1776

    
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
            }
1788
            catch (Exception ex)
1789
            {
1790
                MessageBox.Show(ex.ToString());
1791
            }
1792
        }
1793

    
1794
        #endregion
1795

    
1796
        #region FinalPDFPathFileSearch
1797

    
1798
        /// <summary>
1799
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1800
        /// </summary>
1801

    
1802
        public void FinalPDFPathFileSearch(object obj)
1803
        {
1804
            if (obj is FinalPDF)
1805
            {
1806
                if (obj != null)
1807
                {
1808
                    var convertitem = obj as FinalPDF;
1809

    
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
        #endregion
1827
    }
1828
}
클립보드 이미지 추가 (최대 크기: 500 MB)