프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / FinalPDFViewModel.cs @ 29cd086e

이력 | 보기 | 이력해설 | 다운로드 (56.8 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
        }
51

    
52
        #endregion
53

    
54
        #region Properties
55

    
56
        DataService.DataServiceClient WcfClient = new DataService.DataServiceClient();
57

    
58

    
59
        private static System.Collections.ObjectModel.ObservableCollection<FinalPDF> _ConvertSource;
60
        public static System.Collections.ObjectModel.ObservableCollection<FinalPDF> ConvertSource
61
        {
62
            get
63
            {
64
                if (_ConvertSource == null)
65
                {
66
                    _ConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
67
                }
68
                return _ConvertSource;
69
            }
70
            set
71
            {
72
                _ConvertSource = value;
73
            }
74
        }
75

    
76
        public ObservableCollection<ProjectName> _ProjectNames;
77
        public ObservableCollection<ProjectName> ProjectNames
78
        {
79
            get
80
            {
81
                if (_ProjectNames == null)
82
                {
83
                    _ProjectNames = new System.Collections.ObjectModel.ObservableCollection<ProjectName>();
84
                }
85

    
86
                return _ProjectNames;
87
            }
88
            set
89
            {
90
                _ProjectNames = value;
91
                OnPropertyChanged(() => ProjectNames);
92
            }
93
        }
94

    
95
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _FilterSearch;
96
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> FilterSearch
97
        {
98
            get
99
            {
100
                if (_FilterSearch == null)
101
                {
102
                    _FilterSearch = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>
103
                            {
104
                                new FinalPDF{ProjectNumber = "Filter Search"}
105
                            };
106
                }
107

    
108
                return _FilterSearch;
109
            }
110
        }
111

    
112
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _AliveItems;
113
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> AliveItems
114
        {
115
            get => _AliveItems;
116
            set
117
            {
118
                _AliveItems = value;
119
                OnPropertyChanged(() => AliveItems);
120
            }
121
        }
122

    
123
        public ICollectionView FilterConvertSourceView
124
        {
125
            get
126
            {
127
                var view = CollectionViewSource.GetDefaultView(FilterConvertSource);
128
                return view;
129
            }
130
        }
131

    
132
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _FilterConvertSource;
133
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> FilterConvertSource
134
        {
135
            get
136
            {
137
                if (_FilterConvertSource == null)
138
                {
139
                    _FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
140
                }
141
                return _FilterConvertSource;
142
            }
143
            set
144
            {
145
                _FilterConvertSource = value;
146
                OnPropertyChanged(() => FilterConvertSource);
147
            }
148
        }
149

    
150

    
151
        private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _RealConvertSource;
152
        public System.Collections.ObjectModel.ObservableCollection<FinalPDF> RealConvertSource
153
        {
154
            get => _RealConvertSource;
155
            set
156
            {
157
                _RealConvertSource = value;
158
                OnPropertyChanged(() => RealConvertSource);
159
            }
160
        }
161

    
162

    
163
        private System.Windows.Documents.FlowDocument connectionLog;
164
        public System.Windows.Documents.FlowDocument ConnectionLog
165
        {
166
            get => connectionLog;
167
            set
168
            {
169
                if (connectionLog != value)
170
                {
171
                    connectionLog = value;
172
                    OnPropertyChanged(() => ConnectionLog);
173
                }
174
            }
175
        }
176

    
177

    
178
        private int _SelectedInt = 4;
179
        public int SelectedInt
180
        {
181
            get => _SelectedInt;
182
            set
183
            {
184
                _SelectedInt = value;
185
                OnPropertyChanged(() => SelectedInt);
186
            }
187
        }
188

    
189

    
190
        private Telerik.Windows.Data.EnumMemberViewModel _SelectedStatus;
191
        public Telerik.Windows.Data.EnumMemberViewModel SelectedStatus
192
        {
193
            get => _SelectedStatus;
194
            set
195
            {
196
                _SelectedStatus = value;
197
                OnPropertyChanged(() => SelectedStatus);
198
            }
199
        }
200

    
201

    
202
        private SelectedCountItem _SelectedCount;
203
        public SelectedCountItem SelectedCount
204
        {
205
            get => _SelectedCount;
206
            set
207
            {
208
                _SelectedCount = value;
209
                OnPropertyChanged(() => SelectedCount);
210
            }
211
        }
212

    
213
        List<SelectedCountItem> _SelectedCountList;
214
        public List<SelectedCountItem> SelectedCountList
215
        {
216
            get
217
            {
218
                if (_SelectedCountList == null)
219
                {
220
                    _SelectedCountList = new List<SelectedCountItem>
221
                            {
222
                                new SelectedCountItem{DisplayMember = "50",ValueMember = 50},
223
                                new SelectedCountItem{DisplayMember = "100",ValueMember = 100},
224
                                new SelectedCountItem{DisplayMember = "150",ValueMember = 150},
225
                                new SelectedCountItem{DisplayMember = "200",ValueMember = 200}
226
                            };
227
                }
228

    
229
                return _SelectedCountList;
230
            }
231
        }
232

    
233
        private FinalPDF _SelectFilterConvert;
234
        public FinalPDF SelectFilterConvert
235
        {
236
            get => _SelectFilterConvert;
237
            set
238
            {
239
                _SelectFilterConvert = value;
240
                OnPropertyChanged(() => SelectFilterConvert);
241
            }
242
        }
243

    
244

    
245

    
246
        private ObservableCollection<FinalPDF> _SelectFilterConvertList;
247
        public ObservableCollection<FinalPDF> SelectFilterConvertList
248
        {
249
            get
250
            {
251
                if (_SelectFilterConvertList == null)
252
                {
253
                    _SelectFilterConvertList = new ObservableCollection<FinalPDF>();
254
                }
255
                return _SelectFilterConvertList;
256
            }
257
            set
258
            {
259
                _SelectFilterConvertList = value;
260
                OnPropertyChanged(() => SelectFilterConvertList);
261
            }
262
        }
263

    
264
        private FinalPDF _SelectRealConvert;
265
        public FinalPDF SelectRealConvert
266
        {
267
            get => _SelectRealConvert;
268
            set
269
            {
270
                _SelectRealConvert = value;
271
                OnPropertyChanged(() => SelectRealConvert);
272
            }
273
        }
274

    
275

    
276
        private FinalPDF _SelectAliveConvert;
277
        public FinalPDF SelectAliveConvert
278
        {
279
            get => _SelectAliveConvert;
280
            set
281
            {
282
                _SelectAliveConvert = value;
283
                OnPropertyChanged(() => SelectAliveConvert);
284
            }
285
        }
286

    
287

    
288
        private StatusTypeList _StatusType;
289
        public StatusTypeList StatusType
290
        {
291
            get => _StatusType;
292
            set
293
            {
294
                _StatusType = value;
295
                OnPropertyChanged(() => StatusType);
296
            }
297
        }
298

    
299
        private bool _IsLoading;
300
        public bool IsLoading
301
        {
302
            get => _IsLoading;
303
            set
304
            {
305
                if (_IsLoading != value)
306
                {
307
                    _IsLoading = value;
308
                    OnPropertyChanged(() => IsLoading);
309
                }
310
            }
311
        }
312

    
313
        IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> _StatusCodeList;
314
        public IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> StatusCodeList
315
        {
316
            get
317
            {
318
                if (_StatusCodeList == null)
319
                {
320
                    _StatusCodeList = Telerik.Windows.Data.EnumDataSource.FromType<StatusCodeType>();
321
                }
322

    
323
                return _StatusCodeList;
324
            }
325
        }
326

    
327
        public ProjectName _ProjectNumberFilter;
328
        public ProjectName ProjectNumberFilter
329
        {
330
            get
331
            {
332
                if (_ProjectNumberFilter == null)
333
                {
334
                    _ProjectNumberFilter = new ProjectName();
335
                }
336
                return _ProjectNumberFilter;
337
            }
338
            set
339
            {
340
                _ProjectNumberFilter = value;
341
                OnPropertyChanged(() => ProjectNumberFilter);
342
            }
343
        }
344

    
345
        public string _DocumentIDFilter;
346
        public string DocumentIDFilter
347
        {
348
            get
349
            {
350
                return _DocumentIDFilter;
351
            }
352
            set
353
            {
354
                if (_DocumentIDFilter == "")
355
                {
356
                    _DocumentIDFilter = null;
357
                }
358
                else if (_DocumentIDFilter != value)
359
                {
360
                    _DocumentIDFilter = value;
361
                    OnPropertyChanged(() => DocumentIDFilter);
362
                }
363
            }
364
        }
365

    
366
        public string _DOCINFO_IDFilter;
367
        public string DOCINFO_IDFilter
368
        {
369
            get
370
            {
371
                return _DOCINFO_IDFilter;
372
            }
373
            set
374
            {
375
                if (_DOCINFO_IDFilter == "")
376
                {
377
                    _DOCINFO_IDFilter = null;
378
                }
379
                else if (_DOCINFO_IDFilter != value)
380
                {
381
                    _DOCINFO_IDFilter = value;
382
                    OnPropertyChanged(() => DOCINFO_IDFilter);
383
                }
384
            }
385
        }
386

    
387
        public string _Document_URLFilter;
388
        public string Document_URLFilter
389
        {
390
            get
391
            {
392
                return _Document_URLFilter;
393
            }
394
            set
395
            {
396
                if (_Document_URLFilter != value)
397
                {
398
                    _Document_URLFilter = value;
399
                    OnPropertyChanged(() => Document_URLFilter);
400
                }
401
            }
402
        }
403

    
404
        public string _MarkupInfo_IDFilter;
405
        public string MarkupInfo_IDFilter
406
        {
407
            get
408
            {
409
                return _MarkupInfo_IDFilter;
410
            }
411
            set
412
            {
413
                if (_MarkupInfo_IDFilter != value)
414
                {
415
                    _MarkupInfo_IDFilter = value;
416
                    OnPropertyChanged(() => MarkupInfo_IDFilter);
417
                }
418
            }
419
        }
420

    
421
        public string _CreateUser_IDFilter;
422
        public string CreateUser_IDFilter
423
        {
424
            get
425
            {
426
                return _CreateUser_IDFilter;
427
            }
428
            set
429
            {
430
                if (_CreateUser_IDFilter == "")
431
                {
432
                    _CreateUser_IDFilter = null;
433
                }
434
                else if (_CreateUser_IDFilter != value)
435
                {
436
                    _CreateUser_IDFilter = value;
437
                    OnPropertyChanged(() => CreateUser_IDFilter);
438
                }
439
            }
440
        }
441

    
442
        public string _GROUP_NOFilter;
443
        public string GROUP_NOFilter
444
        {
445
            get
446
            {
447
                return _GROUP_NOFilter;
448
            }
449
            set
450
            {
451
                if (_GROUP_NOFilter == "")
452
                {
453
                    _GROUP_NOFilter = null;
454
                }
455
                else if (_GROUP_NOFilter != value)
456
                {
457
                    _GROUP_NOFilter = value;
458
                    OnPropertyChanged(() => GROUP_NOFilter);
459
                }
460
            }
461
        }
462

    
463
        public string _REVISIONFilter;
464
        public string REVISIONFilter
465
        {
466
            get
467
            {
468
                return _REVISIONFilter;
469
            }
470
            set
471
            {
472
                if (_REVISIONFilter == "")
473
                {
474
                    _REVISIONFilter = null;
475
                }
476
                else if (_REVISIONFilter != value)
477
                {
478
                    _REVISIONFilter = value;
479
                    OnPropertyChanged(() => REVISIONFilter);
480
                }
481
            }
482
        }
483

    
484
        public StatusCodeType _ConvertStateFilter;
485
        public StatusCodeType ConvertStateFilter
486
        {
487
            get { return _ConvertStateFilter; }
488
            set
489
            {
490
                if (_ConvertStateFilter != value)
491
                {
492
                    _ConvertStateFilter = value;
493
                    OnPropertyChanged(() => ConvertStateFilter);
494
                }
495
            }
496
        }
497

    
498
        public string _Document_NOFilter;
499
        public string Document_NOFilter
500
        {
501
            get { return _Document_NOFilter; }
502
            set
503
            {
504
                if (_Document_NOFilter == "")
505
                {
506
                    _Document_NOFilter = null;
507
                }
508
                else if (_Document_NOFilter != value)
509
                {
510
                    _Document_NOFilter = value;
511
                    OnPropertyChanged(() => Document_NOFilter);
512
                }
513
            }
514
        }
515

    
516
        public string _Exception;
517
        public string Exception
518
        {
519
            get { return _Exception; }
520
            set
521
            {
522
                if (_Exception == "")
523
                {
524
                    _Exception = null;
525
                }
526
                else if (_Exception != value)
527
                {
528
                    _Exception = value;
529
                    OnPropertyChanged(() => Exception);
530
                }
531
            }
532
        }
533

    
534
        public string _Document_NameFilter;
535
        public string Document_NameFilter
536
        {
537
            get { return _Document_NameFilter; }
538
            set
539
            {
540
                if (_Document_NameFilter == "")
541
                {
542
                    _Document_NameFilter = null;
543
                }
544
                else if (_Document_NameFilter != value)
545
                {
546
                    _Document_NameFilter = value;
547
                    OnPropertyChanged(() => Document_NameFilter);
548
                }
549
            }
550
        }
551

    
552

    
553
        static DateTime DefaultCreateTime = DateTime.Now.AddHours(-1);
554
        private DateTime _SelectedCreateTimeBegin = DefaultCreateTime;
555
        public DateTime SelectedCreateTimeBegin
556
        {
557

    
558
            get { return _SelectedCreateTimeBegin; }
559
            set
560
            {
561
                if (_SelectedCreateTimeBegin == value)
562
                    return;
563
                _SelectedCreateTimeBegin = value;
564
                OnPropertyChanged(() => SelectedCreateTimeBegin);
565

    
566
            }
567
        }
568

    
569
        private DateTime _SelectedCreateTimeEnd = DefaultCreateTime;
570
        public DateTime SelectedCreateTimeEnd
571
        {
572

    
573
            get { return _SelectedCreateTimeEnd; }
574
            set
575
            {
576
                if (_SelectedCreateTimeEnd == value)
577
                    return;
578
                _SelectedCreateTimeEnd = value;
579
                OnPropertyChanged(() => SelectedCreateTimeEnd);
580
            }
581
        }
582

    
583
        public int _DataBase_ItemsHeight = 800;
584
        public int DataBase_ItemsHeight
585
        {
586
            get { return _DataBase_ItemsHeight; }
587
            set
588
            {
589
                _DataBase_ItemsHeight = value;
590
                OnPropertyChanged(() => DataBase_ItemsHeight);
591
            }
592
        }
593

    
594

    
595
        public int _RealConvert_Height = 80;
596
        public int RealConvert_Height
597
        {
598
            get { return _RealConvert_Height; }
599
            set
600
            {
601
                _RealConvert_Height = value;
602
                OnPropertyChanged(() => RealConvert_Height);
603
            }
604
        }
605

    
606
        public int _Alive_Height = 80;
607
        public int Alive_Height
608
        {
609
            get { return _Alive_Height; }
610
            set
611
            {
612
                _Alive_Height = value;
613
                OnPropertyChanged(() => Alive_Height);
614
            }
615
        }
616

    
617
        public bool _ConvertShow;
618
        public bool ConvertShow
619
        {
620
            get => _ConvertShow;
621
            set
622
            {
623
                if (_ConvertShow = !value)
624
                {
625
                    _ConvertShow = false;
626
                }
627
                _ConvertShow = value;
628
                OnPropertyChanged(() => ConvertShow);
629
            }
630
        }
631

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

    
647

    
648
        private bool _ExcptionCheck = false;
649
        public bool ExcptionCheck
650
        {
651
            get
652
            {
653
                return _ExcptionCheck;
654
            }
655
            set
656
            {
657
                _ExcptionCheck = value;
658
                OnPropertyChanged(() => ExcptionCheck);
659
            }
660
        }
661

    
662
        public bool _SearchTimerOn = false;
663
        public bool SearchTimerOn
664
        {
665
            get => _SearchTimerOn;
666
            set
667
            {
668
                if (_SearchTimerOn = !value)
669
                {
670
                    _SearchTimerOn = false;
671
                }
672
                _SearchTimerOn = value;
673
                OnPropertyChanged(() => SearchTimerOn);
674
            }
675
        }
676

    
677
        #endregion
678

    
679
        #region Command
680

    
681
        public DelegateCommand ConvertCommand { get; private set; }
682
        public DelegateCommand DeleteCommand { get; private set; }
683
        public DelegateCommand ValidateCommand { get; private set; }
684
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
685
        public DelegateCommand MarkusLinkCommand { get; private set; }
686
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
687

    
688
        public DelegateCommand DataFilterCommand { get; private set; }
689
        public DelegateCommand ResetCommand { get; private set; }
690
        public DelegateCommand ConverAddCommand { get; private set; }
691
        public DelegateCommand FinalPDFPathFileSearchCommand { get; private set; }
692
        public DelegateCommand Stop_ProcessCommand { 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("Clear", "Clear");
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
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
967
                    {
968
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
969
                        ProjectNames.Add(projectName);
970
                    }
971
                }
972

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

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

    
998
                    if (statusCodeTypeList.Count() == 1)
999
                    {
1000

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

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

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

    
1035
                            }
1036

    
1037
                        }
1038
                    }
1039

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

    
1066
                            foreach (var item in items)
1067
                            {
1068
                                FinalPDF itemsToEach = new FinalPDF();
1069
                                itemsToEach.ConvertID = item.ConvertID;
1070
                                itemsToEach.ProjectNumber = item.ProjectNumber;
1071

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

    
1074
                                if (item.ConvertState != null)
1075
                                {
1076
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
1077
                                }
1078

    
1079
                                if (item.OriginfilePath.Contains("/"))
1080
                                {
1081
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1082
                                }
1083
                                else
1084
                                {
1085
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1086
                                }
1087
                                itemsToEach.FileName = result;
1088

    
1089
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
1090
                                itemsToEach.TotalPage = item.TotalPage;
1091
                                itemsToEach.OriginfilePath = item.OriginfilePath;
1092
                                itemsToEach.ConvertPath = item.ConvertPath;
1093
                                itemsToEach.MarkusLink = MarkusLink;
1094
                                itemsToEach.DocumentID = item.DocumentID;
1095
                                itemsToEach.GroupNo = item.GroupNo;
1096
                                itemsToEach.DocumentName = item.DocumnetName;
1097
                                itemsToEach.Revision = item.Revision;
1098
                                itemsToEach.Exception = item.Exception;
1099
                                itemsToEach.ConvertPath = item.ConvertPath;
1100
                                itemsToEach.CreateTime = item.CreateTime;
1101
                                itemsToEach.StartTime = item.StartTime;
1102
                                itemsToEach.EndTime = item.EndTime;
1103

    
1104
                                itemsToList.Add(itemsToEach);
1105
                            }
1106
                            newitems.AddRange(itemsToList);
1107
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1108

    
1109
                            if (items.Count() == 0)
1110
                            {
1111
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1112
                            }
1113
                        }
1114
                        catch (Exception ex)
1115
                        {
1116
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1117
                        }
1118
                    }
1119
                    else
1120
                    {
1121
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1122
                    }
1123

    
1124
                }
1125
                ItemsUpdate(newitems);
1126
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1127
            }
1128
            catch (Exception ex)
1129
            {
1130
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1131
            }
1132
        }
1133

    
1134
        /// <summary>
1135
        /// AliveDataSelect의 Data Update
1136
        /// </summary>
1137
        /// <param name = "newitems" ></ param >
1138
        private void ItemsUpdate(List<FinalPDF> newitems)
1139
        {
1140

    
1141
            foreach (var item in newitems)
1142
            {
1143
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1144
            }
1145

    
1146
            if (AliveItems == null)
1147
            {
1148
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
1149

    
1150
                foreach (var item in newitems)
1151
                {
1152
                    AliveItems.Add(item);
1153
                }
1154
            }
1155
            else
1156
            {
1157
                newitems.ForEach(newitem =>
1158
                {
1159
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1160
                });
1161

    
1162
                foreach (var item in newitems)
1163
                {
1164
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1165
                    {
1166
                        AliveItems.Add(item);
1167
                    }
1168
                }
1169

    
1170
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1171
                {
1172
                    var item = AliveItems[i];
1173

    
1174
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1175
                    {
1176
                        try
1177
                        {
1178
                            AliveItems.RemoveAt(i);
1179
                        }
1180
                        catch (Exception ex)
1181
                        {
1182
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1183
                        }
1184
                    }
1185
                }
1186
            }
1187

    
1188
            if (AliveItems.Count() > 1)
1189
            {
1190
                AliveShow = true;
1191
            }
1192

    
1193
            Alive_Height = 80 + (newitems.Count() * 10);
1194
            DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
1195
        }
1196

    
1197

    
1198
        public static async Task<bool> SimplePingAsync(string uri)
1199
        {
1200
            bool result = false;
1201

    
1202
            try
1203
            {
1204
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1205
                {
1206
                    Client.Timeout = new TimeSpan(0, 0, 60);
1207

    
1208
                    var message = await Client.GetAsync(uri);
1209

    
1210
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1211

    
1212
                    switch (StatusCode)
1213
                    {
1214

    
1215
                        case System.Net.HttpStatusCode.Accepted:
1216
                        case System.Net.HttpStatusCode.OK:
1217
                            result = true;
1218
                            break;
1219
                    }
1220
                }
1221
            }
1222
            catch (Exception ex)
1223
            {
1224
                result = false;
1225
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1226
            }
1227

    
1228
            return result;
1229
        }
1230

    
1231
        #endregion
1232

    
1233
        #region Data Convert
1234

    
1235
        private async void DataConvert(object obj)
1236
        {
1237
            if (obj is FinalPDF)
1238
            {
1239

    
1240
                if (obj != null)
1241
                {
1242
                    var convertitem = obj as FinalPDF;
1243

    
1244
                    SelectRealConvert = convertitem;
1245
                    SetCleanUpItem(SelectRealConvert);
1246

    
1247

    
1248
                    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)
1249
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
1250
                                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,
1251
                            x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1252
                         , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
1253

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

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

    
1289

    
1290
                    foreach (var item in items)
1291
                    {
1292
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1293
                        {
1294
                            RealConvertSource.Add(item);
1295
                        }
1296
                        if (RealConvertSource.Count() == 1)
1297
                        {
1298
                            ConvertShow = true;
1299
                        }
1300
                    }
1301
                }
1302
            }
1303
        }
1304

    
1305

    
1306
        public async void SetCleanUpItem(FinalPDF _ConvertItem)
1307
        {
1308

    
1309
            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);
1310

    
1311
            if (items.Count() > 0)
1312
            {
1313
                var item = items.First();
1314

    
1315
                var _CREATE_DATETIME = DateTime.Now.AddHours(-1);
1316
                var _STATUS = (int)StatusCodeType.None;
1317

    
1318
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, 0, _CREATE_DATETIME, _STATUS, null);
1319

    
1320
            }
1321
        }
1322

    
1323
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1324
        {
1325
            ViewInfo viewInfo = new ViewInfo();
1326

    
1327
            viewInfo.DocumentItemID = documentID;
1328
            viewInfo.ProjectNO = projectNo;
1329
            viewInfo.UserID = userID;
1330

    
1331
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1332

    
1333
        }
1334

    
1335
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1336
        {
1337

    
1338
            if (oEncoding == null)
1339
                oEncoding = System.Text.Encoding.UTF8;
1340

    
1341
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1342

    
1343
        }
1344

    
1345
        #endregion
1346

    
1347
        #region Validation
1348

    
1349
        private void DataValidate(object obj)
1350
        {
1351
            if (obj is FinalPDF)
1352
            {
1353

    
1354
                if (obj != null)
1355
                {
1356
                    var convertitem = obj as FinalPDF;
1357

    
1358
                    SelectRealConvert = convertitem;
1359

    
1360
                    bool result = false;
1361
                    WebRequest webRequest = WebRequest.Create(SelectRealConvert.OriginfilePath);
1362
                    webRequest.Timeout = 1200; // miliseconds
1363
                    webRequest.Method = "HEAD";
1364

    
1365
                    HttpWebResponse response = null;
1366

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

    
1405
                HttpWebResponse response = null;
1406

    
1407
                try
1408
                {
1409
                    response = (HttpWebResponse)webRequest.GetResponse();
1410
                    result = true;
1411
                }
1412
                catch (WebException webException)
1413
                {
1414
                    MessageBox.Show(SelectFilterConvert.FileName + " doesn't exist: " + webException.Message);
1415
                    result = true;
1416
                }
1417
                finally
1418
                {
1419
                    if (response != null)
1420
                    {
1421
                        response.Close();
1422
                    }
1423
                }
1424
                if (result == true)
1425
                {
1426
                    MessageBox.Show("File exists");
1427
                }
1428
            }
1429

    
1430
        }
1431

    
1432
        #endregion
1433

    
1434
        #region Data Delete
1435

    
1436
        private void DataDelete(object obj)
1437
        {
1438
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1439
            {
1440
                var result = evt.DialogResult;
1441

    
1442
                if (result == true)
1443
                {
1444
                    OnClosed(obj);
1445
                }
1446
            };
1447

    
1448
            RadWindow.Confirm("Do you want to delete it??", handler);
1449
        }
1450

    
1451
        private async void OnClosed(object obj)
1452
        {
1453
            if (obj is FinalPDF)
1454
            {
1455
                if (obj != null)
1456
                {
1457
                    var convertitem = obj as FinalPDF;
1458

    
1459
                    SelectRealConvert = convertitem;
1460
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1461

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

    
1481
        #endregion
1482

    
1483
        #region Stop Process
1484

    
1485
        private void Stop_Process(object obj)
1486
        {
1487

    
1488
            string convertid = "";
1489

    
1490
            if (obj is FinalPDF)
1491
            {
1492

    
1493
                if (obj != null)
1494
                {
1495
                    var convertitem = obj as FinalPDF;
1496

    
1497
                    SelectRealConvert = convertitem;
1498

    
1499
                    SelectAliveConvert = convertitem;
1500

    
1501
                    convertid = convertitem.ConvertID;
1502
                }
1503
            }
1504

    
1505

    
1506
#if DEBUG
1507
            convertid = "TEST";
1508
#endif
1509

    
1510
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1511
            {
1512
                var result = evt.DialogResult;
1513

    
1514
                if (result == true)
1515
                {
1516
                    Stop_Process(convertid);
1517
                }
1518
            };
1519

    
1520
            RadWindow.Confirm("프로세스 종료 할까요??", handler);
1521
        }
1522

    
1523
        private async void Stop_Process(string convertId)
1524
        {
1525
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10));
1526

    
1527
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1528

    
1529
            for (int i = process.Count() - 1; i >= 0; i--)
1530
            {
1531
                try
1532
                {
1533
                    var commandLines = process[i].Arguments().CommandLine;
1534

    
1535
                    if (commandLines.Count() > 0)
1536
                    {
1537
                        if (commandLines[0] == convertId)
1538
                        {
1539

    
1540
                            var _CREATE_DATETIME = DateTime.Now;
1541

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

    
1556
        #endregion
1557

    
1558
        #region DataFilter
1559

    
1560
        public void DataFilter(object obj)
1561
        {
1562
            SearchTimerOn = true;
1563
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1564
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1565
        }
1566

    
1567
        #endregion
1568

    
1569
        #region MarkusLink
1570

    
1571
        private void MarkusLink(object obj)///여기서 부터 
1572
        {
1573
            if (obj is FinalPDF)
1574
            {
1575
                if (obj != null)
1576
                {
1577
                    var convertitem = obj as FinalPDF;
1578

    
1579
                    SelectFilterConvertList.Add(convertitem);
1580

    
1581
                    SelectRealConvert = convertitem;
1582

    
1583
                    ProcessStartInfo startInfo = null;
1584

    
1585
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1586

    
1587
                    Process.Start(startInfo);
1588
                }
1589
            }
1590
        }
1591

    
1592
        #endregion
1593

    
1594
        #region Data Export
1595

    
1596

    
1597
        /// <summary>
1598
        /// 필터된 상단 그리드 엑셀로 출력
1599
        /// </summary>
1600

    
1601
        public void DataExportData(object obj)
1602
        {
1603
            if (SearchTimerOn == true)
1604
            {
1605
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1606
            }
1607
            else
1608
            {
1609
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1610
            }
1611

    
1612
            Return_FilterConvertSource(FilterConvertSource);
1613

    
1614
            Views.FinalPDFExcelDialog finalPDFExcelDialog = new Views.FinalPDFExcelDialog();
1615

    
1616
            finalPDFExcelDialog.Owner = Application.Current.MainWindow;
1617
            finalPDFExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1618

    
1619
            finalPDFExcelDialog.ShowDialog();
1620

    
1621

    
1622
            if (SearchTimerOn == true)
1623
            {
1624
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1625
            }
1626
            else
1627
            {
1628
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1629
            }
1630
        }
1631

    
1632
        #endregion
1633

    
1634
        #region Data Search
1635

    
1636
        public void RemoveCreateTimeFilter(object obj)
1637
        {
1638
            DefaultCreateTime = DateTime.Now.AddHours(-1); ;
1639
            SelectedCreateTimeBegin = DefaultCreateTime;
1640
            SelectedCreateTimeEnd = DefaultCreateTime;
1641

    
1642
        }
1643

    
1644
        #endregion
1645

    
1646
        #region Reset
1647

    
1648
        /// <summary>
1649
        /// 그리드 상단 원상복귀 버튼
1650
        /// 필터를 끝낸 후 다시 복귀
1651
        /// </summary>
1652

    
1653
        public void Reset(object obj)
1654
        {
1655
            SearchTimerOn = false;
1656
            ExcptionCheck = false;
1657
            SelectedInt = 10;
1658
            ProjectNumberFilter = ProjectNames[0];
1659
            DocumentIDFilter = null;
1660
            MarkupInfo_IDFilter = null;
1661
            DOCINFO_IDFilter = null;
1662
            Document_NameFilter = null;
1663
            Document_NOFilter = null;
1664
            CreateUser_IDFilter = null;
1665
            GROUP_NOFilter = null;
1666
            REVISIONFilter = null;
1667

    
1668
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1669
            SelectedCreateTimeBegin = DefaultCreateTime;
1670
            SelectedCreateTimeEnd = DefaultCreateTime;
1671

    
1672
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1673
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1674

    
1675
        }
1676

    
1677
        #endregion
1678

    
1679
        #region ConvertAddDialog
1680

    
1681
        /// <summary>
1682
        /// 그리드 상단 Conver 추가 버튼
1683
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1684
        /// </summary>
1685

    
1686
        public void ConverAdd(object obj)
1687
        {
1688
            if (SearchTimerOn == true)
1689
            {
1690
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1691
            }
1692
            else
1693
            {
1694
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1695
            }
1696

    
1697
            Views.FinalPDFAddDialog convertAddDialog = new Views.FinalPDFAddDialog();
1698

    
1699
            convertAddDialog.Owner = Application.Current.MainWindow;
1700
            convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1701

    
1702
            convertAddDialog.ShowDialog();
1703

    
1704
            if (SearchTimerOn == true)
1705
            {
1706
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1707
            }
1708
            else
1709
            {
1710
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1711
            }
1712
        }
1713

    
1714
        #endregion
1715

    
1716
        #region FinalPDFPathFileSearch
1717

    
1718
        /// <summary>
1719
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1720
        /// </summary>
1721

    
1722
        public void FinalPDFPathFileSearch(object obj)
1723
        {
1724
            if (obj is FinalPDF)
1725
            {
1726
                if (obj != null)
1727
                {
1728
                    var convertitem = obj as FinalPDF;
1729

    
1730
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
1731

    
1732
                    saveFileDialog.FileName = "Document"; // Default file name
1733
                    saveFileDialog.DefaultExt = ".txt"; // Default file extension
1734
                    saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension
1735

    
1736

    
1737
                    if (saveFileDialog.ShowDialog() == true)
1738
                    {
1739
                    }
1740
                }
1741
            }
1742
        }
1743

    
1744
        #endregion
1745

    
1746
        #endregion
1747
    }
1748
}
클립보드 이미지 추가 (최대 크기: 500 MB)