프로젝트

일반

사용자정보

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

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

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

1 5c387707 semi
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 e1c892f7 taeseongkim
                                itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState.ToString());
1083 5c387707 semi
1084
                                if (item.OriginfilePath.Contains("/"))
1085
                                {
1086
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1087
                                }
1088
                                else
1089
                                {
1090
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1091
                                }
1092
                                itemsToEach.FileName = result;
1093
1094
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
1095
                                itemsToEach.TotalPage = item.TotalPage;
1096
                                itemsToEach.OriginfilePath = item.OriginfilePath;
1097
                                itemsToEach.ConvertPath = item.ConvertPath;
1098
                                itemsToEach.MarkusLink = MarkusLink;
1099
                                itemsToEach.DocumentID = item.DocumentID;
1100
                                itemsToEach.GroupNo = item.GroupNo;
1101 e1c892f7 taeseongkim
                                itemsToEach.DocumentName = item.DocumentName;
1102 5c387707 semi
                                itemsToEach.Revision = item.Revision;
1103
                                itemsToEach.Exception = item.Exception;
1104
                                itemsToEach.ConvertPath = item.ConvertPath;
1105
                                itemsToEach.CreateTime = item.CreateTime;
1106
                                itemsToEach.StartTime = item.StartTime;
1107
                                itemsToEach.EndTime = item.EndTime;
1108
1109
                                itemsToList.Add(itemsToEach);
1110
                            }
1111
                            newitems.AddRange(itemsToList);
1112
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1113
1114
                            if (items.Count() == 0)
1115
                            {
1116
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1117
                            }
1118
                        }
1119
                        catch (Exception ex)
1120
                        {
1121
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1122
                        }
1123
                    }
1124
                    else
1125
                    {
1126
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1127
                    }
1128
1129
                }
1130
                ItemsUpdate(newitems);
1131
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1132
            }
1133
            catch (Exception ex)
1134
            {
1135
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1136
            }
1137
        }
1138
1139
        /// <summary>
1140
        /// AliveDataSelect의 Data Update
1141
        /// </summary>
1142
        /// <param name = "newitems" ></ param >
1143
        private void ItemsUpdate(List<FinalPDF> newitems)
1144
        {
1145
1146
            foreach (var item in newitems)
1147
            {
1148
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1149
            }
1150
1151
            if (AliveItems == null)
1152
            {
1153
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>();
1154
1155
                foreach (var item in newitems)
1156
                {
1157
                    AliveItems.Add(item);
1158
                }
1159
            }
1160
            else
1161
            {
1162
                newitems.ForEach(newitem =>
1163
                {
1164
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1165
                });
1166
1167
                foreach (var item in newitems)
1168
                {
1169
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1170
                    {
1171
                        AliveItems.Add(item);
1172
                    }
1173
                }
1174
1175
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1176
                {
1177
                    var item = AliveItems[i];
1178
1179
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1180
                    {
1181
                        try
1182
                        {
1183
                            AliveItems.RemoveAt(i);
1184
                        }
1185
                        catch (Exception ex)
1186
                        {
1187
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1188
                        }
1189
                    }
1190
                }
1191
            }
1192
1193
1194
            Alive_Height = 80 + (newitems.Count() * 10);
1195
            DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
1196
        }
1197
1198
1199
        public static async Task<bool> SimplePingAsync(string uri)
1200
        {
1201
            bool result = false;
1202
1203
            try
1204
            {
1205
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1206
                {
1207
                    Client.Timeout = new TimeSpan(0, 0, 60);
1208
1209
                    var message = await Client.GetAsync(uri);
1210
1211
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1212
1213
                    switch (StatusCode)
1214
                    {
1215
1216
                        case System.Net.HttpStatusCode.Accepted:
1217
                        case System.Net.HttpStatusCode.OK:
1218
                            result = true;
1219
                            break;
1220
                    }
1221
                }
1222
            }
1223
            catch (Exception ex)
1224
            {
1225
                result = false;
1226
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1227
            }
1228
1229
            return result;
1230
        }
1231
1232
        #endregion
1233
1234
        #region Data Convert
1235
1236
        private async void DataConvert(object obj)
1237
        {
1238
            if (obj is FinalPDF)
1239
            {
1240
1241
                if (obj != null)
1242
                {
1243
                    var convertitem = obj as FinalPDF;
1244
1245
                    SelectRealConvert = convertitem;
1246
                    SetCleanUpItem(SelectRealConvert);
1247
1248
1249
                    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)
1250
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
1251
                                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,
1252
                            x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1253
                         , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
1254
1255
                    foreach (var item in items)
1256
                    {
1257
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1258
                        {
1259
                            RealConvertSource.Add(item);
1260
                        }
1261
                        if (RealConvertSource.Count() == 1)
1262
                        {
1263
                            ConvertShow = true;
1264
                        }
1265
                    }
1266
                }
1267
            }
1268
            else if (SelectFilterConvertList == null)
1269
            {
1270
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1271
            }
1272
            else
1273
            {
1274
                if (SelectFilterConvertList != null)
1275
                {
1276
                    foreach (var SelectFilterConvert in SelectFilterConvertList)
1277
                    {
1278
                        SetCleanUpItem(SelectFilterConvert);
1279
                    }
1280
                }
1281
1282
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1283
                {
1284
                    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)
1285
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech")
1286
                                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,
1287
                            x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1288
                         , x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink);
1289
1290
1291
                    foreach (var item in items)
1292
                    {
1293
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1294
                        {
1295
                            RealConvertSource.Add(item);
1296
                        }
1297
                        if (RealConvertSource.Count() == 1)
1298
                        {
1299
                            ConvertShow = true;
1300
                        }
1301
                    }
1302
                }
1303
            }
1304
        }
1305
1306
1307
        public async void SetCleanUpItem(FinalPDF _ConvertItem)
1308
        {
1309
1310
            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);
1311
1312
            if (items.Count() > 0)
1313
            {
1314
                var item = items.First();
1315
1316
                var _CREATE_DATETIME = DateTime.Now.AddHours(-1);
1317
                var _STATUS = (int)StatusCodeType.None;
1318
1319
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, 0, _CREATE_DATETIME, _STATUS, null);
1320
1321
            }
1322
        }
1323
1324
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1325
        {
1326
            ViewInfo viewInfo = new ViewInfo();
1327
1328
            viewInfo.DocumentItemID = documentID;
1329
            viewInfo.ProjectNO = projectNo;
1330
            viewInfo.UserID = userID;
1331
1332
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1333
1334
        }
1335
1336
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1337
        {
1338
1339
            if (oEncoding == null)
1340
                oEncoding = System.Text.Encoding.UTF8;
1341
1342
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1343
1344
        }
1345
1346
        #endregion
1347
1348
        #region Validation
1349
1350
        private void DataValidate(object obj)
1351
        {
1352
            if (obj is FinalPDF)
1353
            {
1354
1355
                if (obj != null)
1356
                {
1357
                    var convertitem = obj as FinalPDF;
1358
1359
                    SelectRealConvert = convertitem;
1360
1361
                    bool result = false;
1362
                    WebRequest webRequest = WebRequest.Create(SelectRealConvert.OriginfilePath);
1363
                    webRequest.Timeout = 1200; // miliseconds
1364
                    webRequest.Method = "HEAD";
1365
1366
                    HttpWebResponse response = null;
1367
1368
                    try
1369
                    {
1370
                        response = (HttpWebResponse)webRequest.GetResponse();
1371
                        result = true;
1372
                    }
1373
                    catch (WebException webException)
1374
                    {
1375
                        MessageBox.Show(SelectRealConvert.FileName + " doesn't exist: " + webException.Message);
1376
                        result = true;
1377
                    }
1378
                    finally
1379
                    {
1380
                        if (response != null)
1381
                        {
1382
                            response.Close();
1383
                        }
1384
                    }
1385
                    if (result == true)
1386
                    {
1387
                        MessageBox.Show("File exists");
1388
                    }
1389
                }
1390
            }
1391
            else if (SelectFilterConvertList.Count() > 1)
1392
            {
1393
                MessageBox.Show("하나만 클릭해 주세요");
1394
            }
1395
            else if (SelectFilterConvertList.Count() == 0)
1396
            {
1397
                MessageBox.Show("왼쪽 버튼 클릭 후 Validate 해주세요!");
1398
            }
1399
            else
1400
            {
1401
                bool result = false;
1402
                WebRequest webRequest = WebRequest.Create(SelectFilterConvertList[0].OriginfilePath);
1403
                webRequest.Timeout = 1200; // miliseconds
1404
                webRequest.Method = "HEAD";
1405
1406
                HttpWebResponse response = null;
1407
1408
                try
1409
                {
1410
                    response = (HttpWebResponse)webRequest.GetResponse();
1411
                    result = true;
1412
                }
1413
                catch (WebException webException)
1414
                {
1415
                    MessageBox.Show(SelectFilterConvertList[0].FileName + " doesn't exist: " + webException.Message);
1416
                    result = false;
1417
                }
1418
                finally
1419
                {
1420
                    if (response != null)
1421
                    {
1422
                        response.Close();
1423
                    }
1424
                }
1425
                if (result == true)
1426
                {
1427
                    MessageBox.Show("File exists");
1428
                }
1429
            }
1430
1431
        }
1432
1433
        #endregion
1434
1435
        #region Data Delete
1436
1437
        private void DataDelete(object obj)
1438
        {
1439
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1440
            {
1441
                var result = evt.DialogResult;
1442
1443
                if (result == true)
1444
                {
1445
                    OnClosed(obj);
1446
                }
1447
            };
1448
1449
            RadWindow.Confirm("Do you want to delete it??", handler);
1450
        }
1451
1452
        private async void OnClosed(object obj)
1453
        {
1454
            if (obj is FinalPDF)
1455
            {
1456
                if (obj != null)
1457
                {
1458
                    var convertitem = obj as FinalPDF;
1459
1460
                    SelectRealConvert = convertitem;
1461
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1462
1463
                }
1464
            }
1465
            else if (SelectFilterConvertList.Count() > 1)
1466
            {
1467
                MessageBox.Show("하나만 클릭해 주세요!");
1468
            }
1469
            else if (SelectFilterConvertList.Count() == 0)
1470
            {
1471
                MessageBox.Show("왼쪽 버튼 클릭 후 Delete 해주세요!");
1472
            }
1473
            else
1474
            {
1475
                if (SelectFilterConvertList != null)
1476
                {
1477
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectFilterConvertList[0].ConvertID);
1478
                }
1479
            }
1480
        }
1481
1482
        #endregion
1483
1484
        #region Stop Process
1485
1486
        private void Stop_Process(object obj)
1487
        {
1488
1489
            string convertid = "";
1490
1491
            if (obj is FinalPDF)
1492
            {
1493
1494
                if (obj != null)
1495
                {
1496
                    var convertitem = obj as FinalPDF;
1497
1498
                    SelectRealConvert = convertitem;
1499
1500
                    SelectAliveConvert = convertitem;
1501
1502
                    convertid = convertitem.ConvertID;
1503
                }
1504
            }
1505
1506
1507
#if DEBUG
1508
            convertid = "TEST";
1509
#endif
1510
1511
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1512
            {
1513
                var result = evt.DialogResult;
1514
1515
                if (result == true)
1516
                {
1517
                    Stop_Process(convertid);
1518
                }
1519
            };
1520
1521
            RadWindow.Confirm("프로세스 종료 할까요??", handler);
1522
        }
1523
1524
        private async void Stop_Process(string convertId)
1525
        {
1526
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10));
1527
1528
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1529
1530
            for (int i = process.Count() - 1; i >= 0; i--)
1531
            {
1532
                try
1533
                {
1534
                    var commandLines = process[i].Arguments().CommandLine;
1535
1536
                    if (commandLines.Count() > 0)
1537
                    {
1538
                        if (commandLines[0] == convertId)
1539
                        {
1540
1541
                            var _CREATE_DATETIME = DateTime.Now;
1542
1543
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 3, null);
1544
                            process[i].WaitForExit(5000);
1545
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 99, null);
1546
                            process[i].Kill();
1547
                        }
1548
                    }
1549
                }
1550
                catch (Exception ex)
1551
                {
1552
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
1553
                }
1554
            }
1555
        }
1556
1557
        #endregion
1558
1559
        #region DataFilter
1560
1561
        public void DataFilter(object obj)
1562
        {
1563
            SearchTimerOn = true;
1564
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1565
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1566
1567
            FilterConvertSource.Clear();
1568
1569
            SearchTimer_Tick(null, new EventArgs());
1570
        }
1571
1572
        #endregion
1573
1574
        #region MarkusLink
1575
1576
        private void MarkusLink(object obj)///여기서 부터 
1577
        {
1578
            if (obj is FinalPDF)
1579
            {
1580
                if (obj != null)
1581
                {
1582
                    var convertitem = obj as FinalPDF;
1583
1584
                    SelectFilterConvertList.Add(convertitem);
1585
1586
                    SelectRealConvert = convertitem;
1587
1588
                    ProcessStartInfo startInfo = null;
1589
1590
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1591
1592
                    Process.Start(startInfo);
1593
                }
1594
            }
1595
        }
1596
1597
        #endregion
1598
1599
        #region Filter Enter
1600
1601
1602
        /// <summary>
1603
        /// 필터된 상단 그리드 엑셀로 출력
1604
        /// </summary>
1605
1606
        public void Enter(object sender)
1607
        {
1608
            SearchTimerOn = true;
1609
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1610
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1611
1612
            FilterConvertSource.Clear();
1613
1614
            SearchTimer_Tick(null, new EventArgs());
1615
        }
1616
1617
        #endregion
1618
1619
        #region Data Export
1620
1621
1622
        /// <summary>
1623
        /// 필터된 상단 그리드 엑셀로 출력
1624
        /// </summary>
1625
1626
        public void DataExportData(object obj)
1627
        {
1628
            if (SearchTimerOn == true)
1629
            {
1630
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1631
            }
1632
            else
1633
            {
1634
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1635
            }
1636
1637
            Return_FilterConvertSource(FilterConvertSource);
1638
1639
            Views.FinalPDFExcelDialog finalPDFExcelDialog = new Views.FinalPDFExcelDialog();
1640
1641
            finalPDFExcelDialog.Owner = Application.Current.MainWindow;
1642
            finalPDFExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1643
1644
            finalPDFExcelDialog.ShowDialog();
1645
1646
1647
            if (SearchTimerOn == true)
1648
            {
1649
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1650
            }
1651
            else
1652
            {
1653
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1654
            }
1655
        }
1656
1657
        #endregion
1658
1659
        #region Data Search
1660
1661
        public void RemoveCreateTimeFilter(object obj)
1662
        {
1663
            DefaultCreateTime = DateTime.Now.AddHours(-1); ;
1664
            SelectedCreateTimeBegin = DefaultCreateTime;
1665
            SelectedCreateTimeEnd = DefaultCreateTime;
1666
1667
        }
1668
1669
        #endregion
1670
1671
        #region Reset
1672
1673
        /// <summary>
1674
        /// 그리드 상단 원상복귀 버튼
1675
        /// 필터를 끝낸 후 다시 복귀
1676
        /// </summary>
1677
1678
        public void Reset(object obj)
1679
        {
1680
            SearchTimerOn = false;
1681
            ExcptionCheck = false;
1682 64e36f82 semi
            SelectedInt = 12;
1683 5c387707 semi
            ProjectNumberFilter = ProjectNames[0];
1684
            DocumentIDFilter = null;
1685
            MarkupInfo_IDFilter = null;
1686
            DOCINFO_IDFilter = null;
1687
            Document_NameFilter = null;
1688
            Document_NOFilter = null;
1689
            CreateUser_IDFilter = null;
1690
            GROUP_NOFilter = null;
1691
            REVISIONFilter = null;
1692
            Document_URLFilter = null;
1693
1694
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1695
            SelectedCreateTimeBegin = DefaultCreateTime;
1696
            SelectedCreateTimeEnd = DefaultCreateTime;
1697
1698
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1699
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1700
1701
            FilterConvertSource.Clear();
1702
1703
            Timer_Tick(null, new EventArgs());
1704
1705
        }
1706
1707
        #endregion
1708
1709
        #region ConvertAddDialog
1710
1711
        /// <summary>
1712
        /// 그리드 상단 Conver 추가 버튼
1713
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1714
        /// </summary>
1715
1716
        public void ConverAdd(object obj)
1717
        {
1718
            if (SearchTimerOn == true)
1719
            {
1720
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1721
            }
1722
            else
1723
            {
1724
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1725
            }
1726
1727
            Views.FinalPDFAddDialog convertAddDialog = new Views.FinalPDFAddDialog();
1728
1729
            convertAddDialog.Owner = Application.Current.MainWindow;
1730
            convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1731
1732
            convertAddDialog.ShowDialog();
1733
1734
            if (SearchTimerOn == true)
1735
            {
1736
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1737
            }
1738
            else
1739
            {
1740
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1741
            }
1742
        }
1743
1744
        #endregion
1745
1746
        #region DocumentFilter
1747
1748
        /// <summary>
1749
        /// 그리드 상단 Conver 추가 버튼
1750
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1751
        /// </summary>
1752
1753
        public void DocumentFilter(object obj)
1754
        {
1755
            try
1756
            {
1757
                if (SearchTimerOn == true)
1758
                {
1759
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1760
                }
1761
                else
1762
                {
1763
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1764
                }
1765
1766
1767
                Views.ConvertDocumentDialog convertDocumentDialog = new Views.ConvertDocumentDialog(SelectedCount.ValueMember, REVISIONFilter, Document_NOFilter, Document_NameFilter, GROUP_NOFilter, Document_URLFilter, DocumentIDFilter, ProjectNumberFilter.Project_NO);
1768
1769
                convertDocumentDialog.Owner = Application.Current.MainWindow;
1770
                convertDocumentDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1771
                convertDocumentDialog.Width = 1000;
1772
                convertDocumentDialog.Height = 600;
1773
1774
                convertDocumentDialog.ShowDialog();
1775
1776
                if (SearchTimerOn == true)
1777
                {
1778
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1779
                }
1780
                else
1781
                {
1782
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1783
                }
1784
            }
1785
            catch (Exception ex)
1786
            {
1787
                MessageBox.Show(ex.ToString());
1788
            }
1789
        }
1790
1791
        #endregion
1792
1793
        #region FinalPDFPathFileSearch
1794
1795
        /// <summary>
1796
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1797
        /// </summary>
1798
1799
        public void FinalPDFPathFileSearch(object obj)
1800
        {
1801
            if (obj is FinalPDF)
1802
            {
1803
                if (obj != null)
1804
                {
1805
                    var convertitem = obj as FinalPDF;
1806
1807
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
1808
1809
                    saveFileDialog.FileName = "Document"; // Default file name
1810
                    saveFileDialog.DefaultExt = ".txt"; // Default file extension
1811
                    saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension
1812
1813
1814
                    if (saveFileDialog.ShowDialog() == true)
1815
                    {
1816
                    }
1817
                }
1818
            }
1819
        }
1820
1821
        #endregion
1822
1823
        #endregion
1824
    }
1825
}
클립보드 이미지 추가 (최대 크기: 500 MB)