프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / DataBaseItemsModel.cs @ f047c8bf

이력 | 보기 | 이력해설 | 다운로드 (57.4 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.ConvertPDF;
26
using System.Collections.ObjectModel;
27
using Markus.Service;
28

    
29
namespace Markus.Service.StationController.ViewModel
30
{
31
    //세미
32
    public class DataBaseItemsModel : Mvvm.ToolKit.ViewModelBase
33
    {
34
        #region Constructor
35

    
36
        /// <summary>
37
        /// 실행하면 처음 들어가는 부분
38
        /// </summary>
39
        public DataBaseItemsModel()
40
        {
41
            DataFilterCommand = new DelegateCommand(DataFilter);
42
            DataSaveFileGemBoxCommand = new DelegateCommand(DataExportData);
43
            ConvertCommand = new DelegateCommand(DataConvert);
44
            DeleteCommand = new DelegateCommand(DataDelete);
45
            ValidateCommand = new DelegateCommand(DataValidate);
46
            MarkusLinkCommand = new DelegateCommand(MarkusLink);
47
            RemoveCreateTimeFilterCommand = new DelegateCommand(RemoveCreateTimeFilter);
48
            ResetCommand = new DelegateCommand(Reset);
49
            ConvertAddCommand = new DelegateCommand(ConvertAdd);
50
            ConvertPathFileSearchCommand = new DelegateCommand(ConvertPathFileSearch);
51
            Stop_ProcessCommand = new DelegateCommand(Stop_Process);
52
            EnterCommand = new DelegateCommand(Enter);
53
            DocumentFilterCommand = new DelegateCommand(DocumentFilter);
54
        }
55

    
56
        #endregion
57

    
58
        #region Properties
59

    
60
        DataService.DataServiceClient WcfClient = new DataService.DataServiceClient();
61

    
62
        public ObservableCollection<ProjectName> _ProjectNames;
63
        public ObservableCollection<ProjectName> ProjectNames
64
        {
65
            get
66
            {
67
                if (_ProjectNames == null)
68
                {
69
                    _ProjectNames = new System.Collections.ObjectModel.ObservableCollection<ProjectName>();
70
                }
71

    
72
                return _ProjectNames;
73
            }
74
            set
75
            {
76
                _ProjectNames = value;
77
                OnPropertyChanged(() => ProjectNames);
78
            }
79
        }
80

    
81
        private bool _ExcptionCheck = false;
82
        public bool ExcptionCheck
83
        {
84
            get
85
            {
86
                return _ExcptionCheck;
87
            }
88
            set
89
            {
90
                _ExcptionCheck = value;
91
                OnPropertyChanged(() => ExcptionCheck);
92
            }
93
        }
94

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

    
108
                return _FilterSearch;
109
            }
110
        }
111

    
112
        private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _AliveItems;
113
        public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> 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 static System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _ConvertSource;
133
        public static System.Collections.ObjectModel.ObservableCollection<ConvertPDF> ConvertSource
134
        {
135
            get
136
            {
137
                if (_ConvertSource == null)
138
                {
139
                    _ConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
140
                }
141
                return _ConvertSource;
142
            }
143
            set
144
            {
145
                _ConvertSource = value;
146
            }
147
        }
148

    
149
        private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _FilterConvertSource;
150
        public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> FilterConvertSource
151
        {
152
            get
153
            {
154
                if (_FilterConvertSource == null)
155
                {
156
                    _FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
157
                }
158
                return _FilterConvertSource;
159
            }
160
            set
161
            {
162
                _FilterConvertSource = value;
163
                OnPropertyChanged(() => FilterConvertSource);
164
            }
165
        }
166

    
167
        private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _RealConvertSource;
168
        public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> RealConvertSource
169
        {
170
            get => _RealConvertSource;
171
            set
172
            {
173
                _RealConvertSource = value;
174
                OnPropertyChanged(() => RealConvertSource);
175
            }
176
        }
177

    
178

    
179
        private System.Windows.Documents.FlowDocument connectionLog;
180
        public System.Windows.Documents.FlowDocument ConnectionLog
181
        {
182
            get => connectionLog;
183
            set
184
            {
185
                if (connectionLog != value)
186
                {
187
                    connectionLog = value;
188
                    OnPropertyChanged(() => ConnectionLog);
189
                }
190
            }
191
        }
192

    
193

    
194
        private int _SelectedInt = 4;
195
        public int SelectedInt
196
        {
197
            get => _SelectedInt;
198
            set
199
            {
200
                _SelectedInt = value;
201
                OnPropertyChanged(() => SelectedInt);
202
            }
203
        }
204

    
205
        private Telerik.Windows.Data.EnumMemberViewModel _SelectedStatus;
206
        public Telerik.Windows.Data.EnumMemberViewModel SelectedStatus
207
        {
208
            get => _SelectedStatus;
209
            set
210
            {
211
                _SelectedStatus = value;
212
                OnPropertyChanged(() => SelectedStatus);
213
            }
214
        }
215

    
216

    
217
        private SelectedCountItem _SelectedCount;
218
        public SelectedCountItem SelectedCount
219
        {
220
            get => _SelectedCount;
221
            set
222
            {
223
                _SelectedCount = value;
224
                OnPropertyChanged(() => SelectedCount);
225
            }
226
        }
227

    
228
        List<SelectedCountItem> _SelectedCountList;
229
        public List<SelectedCountItem> SelectedCountList
230
        {
231
            get
232
            {
233
                if (_SelectedCountList == null)
234
                {
235
                    _SelectedCountList = new List<SelectedCountItem>
236
                    {
237
                        new SelectedCountItem{DisplayMember = "50",ValueMember = 50},
238
                        new SelectedCountItem{DisplayMember = "100",ValueMember = 100},
239
                        new SelectedCountItem{DisplayMember = "150",ValueMember = 150},
240
                        new SelectedCountItem{DisplayMember = "200",ValueMember = 200}
241
                    };
242
                }
243

    
244
                return _SelectedCountList;
245
            }
246
        }
247

    
248
        private ConvertPDF _SelectFilterConvert;
249
        public ConvertPDF SelectFilterConvert
250
        {
251
            get
252
            {
253
                return _SelectFilterConvert;
254
            }
255
            set
256
            {
257
                _SelectFilterConvert = value;
258
                OnPropertyChanged(() => SelectFilterConvert);
259
            }
260
        }
261

    
262

    
263
        private ObservableCollection<ConvertPDF> _SelectFilterConvertList;
264
        public ObservableCollection<ConvertPDF> SelectFilterConvertList
265
        {
266
            get
267
            {
268
                if (_SelectFilterConvertList == null)
269
                {
270
                    _SelectFilterConvertList = new ObservableCollection<ConvertPDF>();
271
                }
272
                return _SelectFilterConvertList;
273
            }
274
            set
275
            {
276
                _SelectFilterConvertList = value;
277
                OnPropertyChanged(() => SelectFilterConvertList);
278
            }
279
        }
280

    
281

    
282

    
283
        private ConvertPDF _SelectRealConvert;
284
        public ConvertPDF SelectRealConvert
285
        {
286
            get => _SelectRealConvert;
287
            set
288
            {
289
                _SelectRealConvert = value;
290
                OnPropertyChanged(() => SelectRealConvert);
291
            }
292
        }
293

    
294

    
295
        private ConvertPDF _SelectAliveConvert;
296
        public ConvertPDF SelectAliveConvert
297
        {
298
            get => _SelectAliveConvert;
299
            set
300
            {
301
                _SelectAliveConvert = value;
302
                OnPropertyChanged(() => SelectAliveConvert);
303
            }
304
        }
305

    
306

    
307
        private StatusTypeList _StatusType;
308
        public StatusTypeList StatusType
309
        {
310
            get => _StatusType;
311
            set
312
            {
313
                _StatusType = value;
314
                OnPropertyChanged(() => StatusType);
315
            }
316
        }
317

    
318
        private bool _IsLoading;
319
        public bool IsLoading
320
        {
321
            get => _IsLoading;
322
            set
323
            {
324
                if (_IsLoading != value)
325
                {
326
                    _IsLoading = value;
327
                    OnPropertyChanged(() => IsLoading);
328
                }
329
            }
330
        }
331

    
332
        IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> _StatusCodeList;
333
        public IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> StatusCodeList
334
        {
335
            get
336
            {
337
                if (_StatusCodeList == null)
338
                {
339
                    _StatusCodeList = Telerik.Windows.Data.EnumDataSource.FromType<StatusCodeType>();
340
                }
341

    
342
                return _StatusCodeList;
343
            }
344
        }
345

    
346
        public ProjectName _ProjectNumberFilter;
347
        public ProjectName ProjectNumberFilter
348
        {
349
            get
350
            {
351
                if (_ProjectNumberFilter == null)
352
                {
353
                    _ProjectNumberFilter = new ProjectName();
354
                }
355
                return _ProjectNumberFilter;
356
            }
357
            set
358
            {
359
                _ProjectNumberFilter = value;
360
                OnPropertyChanged(() => ProjectNumberFilter);
361
            }
362
        }
363

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

    
385
        public StatusCodeType _ConvertStateFilter;
386
        public StatusCodeType ConvertStateFilter
387
        {
388
            get { return _ConvertStateFilter; }
389
            set
390
            {
391
                if (_ConvertStateFilter != value)
392
                {
393
                    _ConvertStateFilter = value;
394
                    OnPropertyChanged(() => ConvertStateFilter);
395
                }
396
            }
397
        }
398

    
399
        public string _Docuemnt_NOFilter;
400
        public string Docuemnt_NOFilter
401
        {
402
            get { return _Docuemnt_NOFilter; }
403
            set
404
            {
405
                if (_Docuemnt_NOFilter == "")
406
                {
407
                    _Docuemnt_NOFilter = null;
408
                }
409
                else if (_Docuemnt_NOFilter != value)
410
                {
411
                    _Docuemnt_NOFilter = value;
412
                    OnPropertyChanged(() => Docuemnt_NOFilter);
413
                }
414
            }
415
        }
416

    
417
        public string _Document_NameFilter;
418
        public string Document_NameFilter
419
        {
420
            get { return _Document_NameFilter; }
421
            set
422
            {
423
                if (_Document_NameFilter == "")
424
                {
425
                    _Document_NameFilter = null;
426
                }
427
                else if (_Document_NameFilter != value)
428
                {
429
                    _Document_NameFilter = value;
430
                    OnPropertyChanged(() => Document_NameFilter);
431
                }
432
            }
433
        }
434

    
435
        public int? _ReconverterFilter = 0;
436
        public int? ReconverterFilter
437
        {
438
            get { return _ReconverterFilter; }
439
            set
440
            {
441
                if (_ReconverterFilter == null)
442
                {
443
                    _ReconverterFilter = 0;
444
                }
445
                else if (_ReconverterFilter != value)
446
                {
447
                    _ReconverterFilter = value;
448
                    OnPropertyChanged(() => ReconverterFilter);
449

    
450
                }
451
            }
452
        }
453

    
454
        public string _Service_IDFilter;
455
        public string Service_IDFilter
456
        {
457
            get { return _Service_IDFilter; }
458
            set
459
            {
460
                if (_Service_IDFilter == "")
461
                {
462
                    _Service_IDFilter = null;
463
                }
464
                else if (_Service_IDFilter != value)
465
                {
466
                    _Service_IDFilter = value;
467
                    OnPropertyChanged(() => Service_IDFilter);
468
                }
469
            }
470
        }
471

    
472
        public string _RevisionFilter;
473
        public string RevisionFilter
474
        {
475
            get { return _RevisionFilter; }
476
            set
477
            {
478
                if (_RevisionFilter == "")
479
                {
480
                    _RevisionFilter = null;
481
                }
482
                else if (_RevisionFilter != value)
483
                {
484
                    _RevisionFilter = value;
485
                    OnPropertyChanged(() => RevisionFilter);
486
                }
487
            }
488
        }
489

    
490
        public string _GroupNOFilter;
491
        public string GroupNOFilter
492
        {
493
            get { return _GroupNOFilter; }
494
            set
495
            {
496
                if (_GroupNOFilter == "")
497
                {
498
                    _GroupNOFilter = null;
499
                }
500
                else if (_GroupNOFilter != value)
501
                {
502
                    _GroupNOFilter = value;
503
                    OnPropertyChanged(() => GroupNOFilter);
504
                }
505
            }
506
        }
507

    
508
        public string _DOCUMENT_URLFilter;
509
        public string DOCUMENT_URLFilter
510
        {
511
            get { return _DOCUMENT_URLFilter; }
512
            set
513
            {
514
                if (_DOCUMENT_URLFilter == "")
515
                {
516
                    _DOCUMENT_URLFilter = null;
517
                }
518
                else if (_DOCUMENT_URLFilter != value)
519
                {
520
                    _DOCUMENT_URLFilter = value;
521
                    OnPropertyChanged(() => DOCUMENT_URLFilter);
522
                }
523
            }
524
        }
525

    
526
        static DateTime DefaultCreateTime = DateTime.Now.AddHours(-1);
527
        private DateTime _SelectedCreateTimeBegin = DefaultCreateTime;
528
        public DateTime SelectedCreateTimeBegin
529
        {
530

    
531
            get { return _SelectedCreateTimeBegin; }
532
            set
533
            {
534
                if (_SelectedCreateTimeBegin == value)
535
                    return;
536
                _SelectedCreateTimeBegin = value;
537
                OnPropertyChanged(() => SelectedCreateTimeBegin);
538

    
539
            }
540
        }
541

    
542
        private DateTime _SelectedCreateTimeEnd = DefaultCreateTime;
543
        public DateTime SelectedCreateTimeEnd
544
        {
545

    
546
            get { return _SelectedCreateTimeEnd; }
547
            set
548
            {
549
                if (_SelectedCreateTimeEnd == value)
550
                    return;
551
                _SelectedCreateTimeEnd = value;
552
                OnPropertyChanged(() => SelectedCreateTimeEnd);
553
            }
554
        }
555

    
556
        public bool _ConvertShow;
557
        public bool ConvertShow
558
        {
559
            get => _ConvertShow;
560
            set
561
            {
562
                if (_ConvertShow = !value)
563
                {
564
                    _ConvertShow = false;
565
                }
566
                _ConvertShow = value;
567
                OnPropertyChanged(() => ConvertShow);
568
            }
569
        }
570

    
571
        public bool _AliveShow = false;
572
        public bool AliveShow
573
        {
574
            get => _AliveShow;
575
            set
576
            {
577
                _AliveShow = value;
578
                OnPropertyChanged(() => AliveShow);
579
            }
580
        }
581

    
582
        public bool _SearchTimerOn = false;
583
        public bool SearchTimerOn
584
        {
585
            get => _SearchTimerOn;
586
            set
587
            {
588
                if (_SearchTimerOn = !value)
589
                {
590
                    _SearchTimerOn = false;
591
                }
592
                _SearchTimerOn = value;
593
                OnPropertyChanged(() => SearchTimerOn);
594
            }
595
        }
596

    
597
        #endregion
598

    
599
        #region Command
600

    
601
        public DelegateCommand ConvertCommand { get; private set; }
602
        public DelegateCommand DeleteCommand { get; private set; }
603
        public DelegateCommand ValidateCommand { get; private set; }
604
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
605
        public DelegateCommand MarkusLinkCommand { get; private set; }
606
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
607

    
608
        public DelegateCommand DataFilterCommand { get; private set; }
609
        public DelegateCommand ResetCommand { get; private set; }
610
        public DelegateCommand ConvertAddCommand { get; private set; }
611
        public DelegateCommand ConvertPathFileSearchCommand { get; private set; }
612
        public DelegateCommand Stop_ProcessCommand { get; private set; }
613
        public DelegateCommand EnterCommand { get; private set; }
614
        public DelegateCommand DocumentFilterCommand { get; private set; }
615

    
616
        #endregion
617

    
618
        #region Main Logic
619

    
620
        /// <summary>
621
        /// 각각의 Grid row 객체들 업데이트
622
        /// </summary>
623

    
624
        private DispatcherTimer dispatcherTimer;
625
        public override void Loaded()
626
        {
627
            base.Loaded();
628

    
629
            if (!App.IsDesignMode)
630
            {
631
                dispatcherTimer = new DispatcherTimer();
632
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
633
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
634
                dispatcherTimer.Start();
635
            }
636
        }
637

    
638
        private async void Timer_Tick(object sender, EventArgs e)
639
        {
640
            dispatcherTimer.Stop();
641

    
642
            if (IsAcitve)
643
            {
644
                await App.Current.Dispatcher.InvokeAsync(() =>
645
                {
646
                    DataSelect();
647

    
648
                    AliveDataSelect();
649
                });
650
            }
651

    
652
            await Task.Delay(5000);
653

    
654
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
655

    
656
            dispatcherTimer.Start();
657
        }
658

    
659
        private async void SearchTimer_Tick(object sender, EventArgs e)
660
        {
661
            dispatcherTimer.Stop();
662

    
663
            if (IsAcitve)
664
            {
665
                await App.Current.Dispatcher.InvokeAsync(() =>
666
                {
667
                    DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
668

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

    
671
                    AliveDataSelect();
672
                });
673
            }
674

    
675
            await Task.Delay(5000);
676

    
677
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
678

    
679
            dispatcherTimer.Start();
680
        }
681

    
682
        public override void Closed()
683
        {
684
            if (dispatcherTimer != null)
685
            {
686
                dispatcherTimer.Stop();
687
            }
688

    
689
            base.Closed();
690
        }
691

    
692

    
693
        #endregion
694

    
695
        #region Function
696

    
697
        #region Return_FilterConvertSource
698

    
699
        public static void Return_FilterConvertSource(ObservableCollection<ConvertPDF> convertPDFs)
700
        {
701
            ConvertSource = new ObservableCollection<ConvertPDF>();
702
            ConvertSource = convertPDFs;
703
        }
704

    
705
        public static ObservableCollection<ConvertPDF> Return_FilterConvertSource()
706
        {
707
            return ConvertSource;
708
        }
709

    
710
        #endregion
711

    
712
        #region Data Select
713

    
714
        /// <summary>
715
        /// 상단 그리드 중앙 그리드 출력 데이터
716
        /// </summary>
717
        private void DataSelect()
718
        {
719

    
720
            if (FilterConvertSource == null)
721
            {
722
                FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
723
            }
724

    
725
            if (RealConvertSource == null)
726
            {
727
                RealConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
728
            }
729

    
730
            /// combobox 에서 선택된 items
731
            if (SelectedStatus != null)
732
            {
733
                DataSelect(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
734
            }
735

    
736

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

    
740
        }
741

    
742
        private async void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
743
        {
744
            try
745
            {
746
                List<ConvertPDF> Listitems = new List<ConvertPDF>();
747

    
748
                foreach (var coll in collection)
749
                {
750
                    var collectionItems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(coll.ConvertID, coll.ProjectNumber, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
751
                                          let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
752
                                          select new ConvertPDF(num.SERVICE_ID, num.ID, num.PROJECT_NO, num.STATUS, num.DOCUMENT_ID, num.DOCUMENT_NAME, num.DOCUMENT_NO, num.DOCUMENT_URL, num.REVISION, num.CURRENT_PAGE,
753
                                      num.TOTAL_PAGE, num.EXCEPTION, num.GROUP_NO, num.CREATE_DATETIME, num.START_DATETIME, num.END_DATETIME, num.DOCUMENT_URL, num.CONVERT_PATH, MarkusLink, num.RECONVERTER);
754

    
755
                    var collectionItem = collectionItems.Cast<ConvertPDF>().ToList();
756

    
757
                    Listitems.AddRange(collectionItem);
758
                }
759

    
760
                foreach (var Listitem in Listitems)
761
                {
762
                    collection.UpdateWhere(changeitem =>
763
                    ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
764
                }
765
            }
766
            catch (Exception ex)
767
            {
768
                MessageBox.Show(ex.ToString());
769
            }
770
        }
771

    
772
        private async void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
773
        {
774
            try
775
            {
776
                int _status = 0;
777
                if (SelectedStatus != null)
778
                {
779
                    _status = (int)SelectedStatus.Value;
780
                }
781

    
782
                if (ProjectNames.Count() == 0)
783
                {
784
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
785
                    ProjectNames.Add(Clear);
786

    
787
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
788
                    {
789
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
790
                        ProjectNames.Add(projectName);
791
                    }
792
                }
793

    
794
                var Listitems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(null, null, null, _status, SelectedCount.ValueMember, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
795
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
796
                                select new ConvertPDF(num.SERVICE_ID, num.ID, num.PROJECT_NO, num.STATUS, num.DOCUMENT_ID, num.DOCUMENT_NAME, num.DOCUMENT_NO, num.DOCUMENT_URL, num.REVISION, num.CURRENT_PAGE,
797
                                                        num.TOTAL_PAGE, num.EXCEPTION, num.GROUP_NO, num.CREATE_DATETIME, num.START_DATETIME, num.END_DATETIME, num.DOCUMENT_URL, num.CONVERT_PATH, MarkusLink, num.RECONVERTER);
798

    
799
                if (collection.Count() == 0)
800
                {
801
                    if (statusCodeTypeList.Count() == 1)
802
                    {
803
                        foreach (var Listitem in Listitems.ToList())
804
                        {
805
                            collection.Add(Listitem);
806
                        }
807
                    }
808
                }
809
                else
810
                {
811
                    foreach (var Listitem in Listitems)
812
                    {
813
                        collection.UpdateWhere(changeitem =>
814
                        ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
815
                    }
816
                    if (statusCodeTypeList.Count() == 1)
817
                    {
818
                        for (int i = collection.Count() - 1; i >= 0; --i)
819
                        {
820
                            var item = collection[i];
821

    
822
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
823
                            {
824
                                collection.RemoveAt(i);
825
                            }
826
                        }
827
                    }
828

    
829
                    if (statusCodeTypeList.Count() == 1)
830
                    {
831
                        foreach (var item in Listitems)
832
                        {
833
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
834
                            {
835
                                for (int i = 0; i < 200; i++)
836
                                {
837
                                    if (i < collection.Count() - 1)
838
                                    {
839
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
840
                                        {
841
                                            collection.Insert(i, item);
842
                                            break;
843
                                        }
844
                                    }
845
                                    else
846
                                    {
847
                                        collection.Add(item);
848
                                        break;
849
                                    }
850
                                }
851

    
852
                            }
853

    
854
                        }
855
                    }
856
                }
857
            }
858
            catch (Exception ex)
859
            {
860
                MessageBox.Show(ex.ToString());
861
            }
862
        }
863

    
864
        private async void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
865
        {
866
            try
867
            {
868
                int _status = 0;
869
                if (SelectedStatus != null)
870
                {
871
                    _status = (int)SelectedStatus.Value;
872
                }
873
                DateTime? Start_CreateTime = null;
874
                DateTime? Finish_CreateTime = null;
875
                if (SelectedCreateTimeBegin != DefaultCreateTime)
876
                {
877
                    Start_CreateTime = SelectedCreateTimeBegin;
878
                }
879
                if (SelectedCreateTimeEnd != DefaultCreateTime)
880
                {
881
                    Finish_CreateTime = SelectedCreateTimeEnd;
882
                }
883

    
884
                if (ProjectNames.Count() == 0)
885
                {
886
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
887
                    ProjectNames.Add(Clear);
888

    
889
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
890
                    {
891
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
892
                        ProjectNames.Add(projectName);
893
                    }
894
                }
895

    
896
                var Listitems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(null, ProjectNumberFilter.Project_NO, UniqueKeyFilter, _status, SelectedCount.ValueMember, Start_CreateTime, Finish_CreateTime, null,
897
            null, null, null, GroupNOFilter, Document_NameFilter, Docuemnt_NOFilter, RevisionFilter, Service_IDFilter, ReconverterFilter, DOCUMENT_URLFilter, ExcptionCheck)
898
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
899
                                select new ConvertPDF(num.SERVICE_ID, num.ID, num.PROJECT_NO, num.STATUS, num.DOCUMENT_ID, num.DOCUMENT_NAME, num.DOCUMENT_NO, num.DOCUMENT_URL, num.REVISION, num.CURRENT_PAGE,
900
           num.TOTAL_PAGE, num.EXCEPTION, num.GROUP_NO, num.CREATE_DATETIME, num.START_DATETIME, num.END_DATETIME, num.DOCUMENT_URL, num.CONVERT_PATH, MarkusLink, num.RECONVERTER);
901

    
902
                if (collection.Count() == 0)
903
                {
904
                    if (statusCodeTypeList.Count() == 1)
905
                    {
906
                        foreach (var x in Listitems)
907
                        {
908
                            collection.Add(x);
909
                        }
910
                    }
911
                }
912
                else
913
                {
914
                    foreach (var newitem in Listitems)
915
                    {
916
                        collection.UpdateWhere(changeitem =>
917
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
918
                    }
919

    
920

    
921
                    if (statusCodeTypeList.Count() == 1)
922
                    {
923
                        for (int i = collection.Count() - 1; i >= 0; --i)
924
                        {
925
                            var item = collection[i];
926

    
927
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
928
                            {
929
                                collection.RemoveAt(i);
930
                            }
931
                        }
932
                    }
933

    
934
                    if (statusCodeTypeList.Count() == 1)
935
                    {
936
                        foreach (var item in Listitems)
937
                        {
938
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
939
                            {
940
                                for (int i = 0; i < 200; i++)
941
                                {
942
                                    if (i < collection.Count() - 1)
943
                                    {
944
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
945
                                        {
946
                                            collection.Insert(i, item);
947
                                            break;
948
                                        }
949
                                    }
950
                                    else
951
                                    {
952
                                        collection.Add(item);
953
                                        break;
954
                                    }
955
                                }
956
                            }
957
                        }
958
                    }
959
                }
960
            }
961
            catch (Exception ex)
962
            {
963
                MessageBox.Show(ex.ToString());
964
            }
965
        }
966
        /// <summary>
967
        /// 서비스의 실시간 컨버터 Item
968
        /// </summary>
969
        private async void AliveDataSelect()
970
        {
971
            try
972
            {
973
                List<ConvertPDF> newitems = new List<ConvertPDF>();
974
                foreach (var client in App.StationClientList)
975
                {
976
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
977
                    {
978
                        try
979
                        {
980
                            List<ConvertPDF> itemsToList = new List<ConvertPDF>();
981
                            var items = await client.AliveConvertListAsync();
982
                            string result = "";
983

    
984
                            if (items.Count() > 0)
985
                            {
986
                                AliveShow = true;
987
                            }
988

    
989
                            foreach (var item in items)
990
                            {
991
                                ConvertPDF itemsToEach = new ConvertPDF();
992
                                itemsToEach.ServiceID = item.ServiceID;
993
                                itemsToEach.ConvertID = item.ConvertID;
994
                                itemsToEach.ProjectNumber = item.ProjectNumber;
995

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

    
998
                                if (item.ConvertState != null)
999
                                {
1000
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
1001
                                }
1002

    
1003
                                if (item.OriginfilePath.Contains("/"))
1004
                                {
1005
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1006
                                }
1007
                                else
1008
                                {
1009
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1010
                                }
1011
                                itemsToEach.FileName = result;
1012

    
1013
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
1014
                                itemsToEach.TotalPage = item.TotalPage;
1015
                                itemsToEach.OriginfilePath = item.OriginfilePath;
1016
                                itemsToEach.ConvertPath = item.ConvertPath;
1017
                                itemsToEach.MarkusLink = MarkusLink;
1018
                                itemsToEach.UniqueKey = item.UniqueKey;
1019
                                itemsToEach.GroupNo = item.GroupNo;
1020
                                itemsToEach.DocumentName = item.DocumnetName;
1021
                                itemsToEach.Revision = item.Revision;
1022
                                itemsToEach.Exception = item.Exception;
1023
                                itemsToEach.ConvertPath = item.ConvertPath;
1024
                                itemsToEach.CreateTime = item.CreateTime;
1025
                                itemsToEach.ReConverter = item.ReConverter;
1026
                                itemsToEach.DocumentID = item.DocumentID;
1027
                                itemsToEach.StartTime = item.StartTime;
1028
                                itemsToEach.EndTime = item.EndTime;
1029

    
1030
                                itemsToList.Add(itemsToEach);
1031
                            }
1032
                            newitems.AddRange(itemsToList);
1033
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1034

    
1035
                            if (items.Count() == 0)
1036
                            {
1037
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1038
                            }
1039
                        }
1040
                        catch (Exception ex)
1041
                        {
1042
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1043
                        }
1044
                    }
1045
                    else
1046
                    {
1047
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1048
                    }
1049

    
1050
                }
1051
                ItemsUpdate(newitems);
1052
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1053
            }
1054
            catch (Exception ex)
1055
            {
1056
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1057
            }
1058
        }
1059

    
1060
        /// <summary>
1061
        /// AliveDataSelect의 Data Update
1062
        /// </summary>
1063
        /// <param name="newitems"></param>
1064
        private void ItemsUpdate(List<ConvertPDF> newitems)
1065
        {
1066

    
1067
            foreach (var item in newitems)
1068
            {
1069
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1070
            }
1071

    
1072
            if (AliveItems == null)
1073
            {
1074
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
1075

    
1076
                foreach (var item in newitems)
1077
                {
1078
                    AliveItems.Add(item);
1079
                }
1080
            }
1081
            else
1082
            {
1083
                newitems.ForEach(newitem =>
1084
                {
1085
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1086
                });
1087

    
1088
                foreach (var item in newitems)
1089
                {
1090
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1091
                    {
1092
                        AliveItems.Add(item);
1093
                    }
1094
                }
1095

    
1096
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1097
                {
1098
                    var item = AliveItems[i];
1099

    
1100
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1101
                    {
1102
                        try
1103
                        {
1104
                            AliveItems.RemoveAt(i);
1105
                        }
1106
                        catch (Exception ex)
1107
                        {
1108
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1109
                        }
1110
                    }
1111
                }
1112
            }
1113
        }
1114

    
1115

    
1116
        public static async Task<bool> SimplePingAsync(string uri)
1117
        {
1118
            bool result = false;
1119

    
1120
            try
1121
            {
1122
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1123
                {
1124
                    Client.Timeout = new TimeSpan(0, 0, 60);
1125

    
1126
                    var message = await Client.GetAsync(uri);
1127

    
1128
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1129

    
1130
                    switch (StatusCode)
1131
                    {
1132

    
1133
                        case System.Net.HttpStatusCode.Accepted:
1134
                        case System.Net.HttpStatusCode.OK:
1135
                            result = true;
1136
                            break;
1137
                    }
1138
                }
1139
            }
1140
            catch (Exception ex)
1141
            {
1142
                result = false;
1143
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1144
            }
1145

    
1146
            return result;
1147
        }
1148

    
1149
        #endregion
1150

    
1151
        #region Data Convert
1152

    
1153
        private async void DataConvert(object obj)
1154
        {
1155
            if (obj is ConvertPDF)
1156
            {
1157

    
1158
                if (obj != null)
1159
                {
1160
                    var convertitem = obj as ConvertPDF;
1161

    
1162
                    SelectRealConvert = convertitem;
1163
                    SetCleanUpItem(SelectRealConvert);
1164

    
1165

    
1166
                    var items = from x in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(SelectRealConvert.ConvertID, null, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
1167
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1168
                                select new ConvertPDF(x.SERVICE_ID, x.ID, x.PROJECT_NO, x.STATUS, x.DOCUMENT_ID, x.DOCUMENT_NAME, x.DOCUMENT_NO, x.DOCUMENT_URL, x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1169
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1170

    
1171
                    foreach (var item in items)
1172
                    {
1173
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1174
                        {
1175
                            RealConvertSource.Add(item);
1176
                        }
1177
                        if (RealConvertSource.Count() == 1)
1178
                        {
1179
                            ConvertShow = true;
1180
                        }
1181
                    }
1182
                }
1183
            }
1184
            else if (SelectFilterConvertList == null)
1185
            {
1186
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1187
            }
1188
            else
1189
            {
1190
                if (SelectFilterConvertList != null)
1191
                {
1192
                    foreach (var SelectFilterConvert in SelectFilterConvertList)
1193
                    {
1194
                        SetCleanUpItem(SelectFilterConvert);
1195
                    }
1196
                }
1197

    
1198
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1199
                {
1200

    
1201
                    var items = from x in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(SelectFilterConvert.ConvertID, null, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
1202
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1203
                                select new ConvertPDF(x.SERVICE_ID, x.ID, x.PROJECT_NO, x.STATUS, x.DOCUMENT_ID, x.DOCUMENT_NAME, x.DOCUMENT_NO, x.DOCUMENT_URL, x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1204
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1205

    
1206
                    foreach (var item in items)
1207
                    {
1208
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1209
                        {
1210
                            RealConvertSource.Add(item);
1211
                        }
1212
                        if (RealConvertSource.Count() == 1)
1213
                        {
1214
                            ConvertShow = true;
1215
                        }
1216
                    }
1217
                }
1218
            }
1219
        }
1220

    
1221

    
1222
        public async void SetCleanUpItem(ConvertPDF _ConvertItem)
1223
        {
1224

    
1225
            var items = await WcfClient.GET_SELECT_CONVERT_ITEMAsync(_ConvertItem.ConvertID, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
1226

    
1227
            if (items.Count() > 0)
1228
            {
1229
                var item = items.First();
1230

    
1231
                var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
1232
                var _CREATE_DATETIME = DateTime.Now;
1233
                var _STATUS = (int)StatusCodeType.None;
1234

    
1235
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null);
1236
            }
1237
        }
1238

    
1239

    
1240
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1241
        {
1242
            ViewInfo viewInfo = new ViewInfo();
1243

    
1244
            viewInfo.DocumentItemID = documentID;
1245
            viewInfo.ProjectNO = projectNo;
1246
            viewInfo.UserID = userID;
1247

    
1248
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1249

    
1250
        }
1251

    
1252
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1253
        {
1254

    
1255
            if (oEncoding == null)
1256
                oEncoding = System.Text.Encoding.UTF8;
1257

    
1258
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1259

    
1260
        }
1261

    
1262

    
1263
        #endregion
1264

    
1265
        #region Validation
1266

    
1267
        private void DataValidate(object obj)
1268
        {
1269
            if (obj is ConvertPDF)
1270
            {
1271

    
1272
                if (obj != null)
1273
                {
1274
                    var convertitem = obj as ConvertPDF;
1275

    
1276
                    SelectRealConvert = convertitem;
1277

    
1278
                    bool result = false;
1279
                    WebRequest webRequest = WebRequest.Create(SelectRealConvert.OriginfilePath);
1280
                    webRequest.Timeout = 1200; // miliseconds
1281
                    webRequest.Method = "HEAD";
1282

    
1283
                    HttpWebResponse response = null;
1284

    
1285
                    try
1286
                    {
1287
                        response = (HttpWebResponse)webRequest.GetResponse();
1288
                        result = true;
1289
                    }
1290
                    catch (WebException webException)
1291
                    {
1292
                        MessageBox.Show(SelectRealConvert.FileName + " doesn't exist: " + webException.Message);
1293
                        result = true;
1294
                    }
1295
                    finally
1296
                    {
1297
                        if (response != null)
1298
                        {
1299
                            response.Close();
1300
                        }
1301
                    }
1302
                    if (result == true)
1303
                    {
1304
                        MessageBox.Show("File exists");
1305
                    }
1306
                }
1307
            }
1308
            else if (SelectFilterConvertList.Count() > 1)
1309
            {
1310
                MessageBox.Show("하나만 클릭해 주세요");
1311
            }
1312
            else if (SelectFilterConvertList.Count() == 0)
1313
            {
1314
                MessageBox.Show("왼쪽 버튼 클릭 후 Validate 해주세요!");
1315
            }
1316
            else
1317
            {
1318
                bool result = false;
1319
                WebRequest webRequest = WebRequest.Create(SelectFilterConvertList[0].OriginfilePath);
1320
                webRequest.Timeout = 1200; // miliseconds
1321
                webRequest.Method = "HEAD";
1322

    
1323
                HttpWebResponse response = null;
1324

    
1325
                try
1326
                {
1327
                    response = (HttpWebResponse)webRequest.GetResponse();
1328
                    result = true;
1329
                }
1330
                catch (WebException webException)
1331
                {
1332
                    MessageBox.Show(SelectFilterConvert.FileName + " doesn't exist: " + webException.Message);
1333
                    result = true;
1334
                }
1335
                finally
1336
                {
1337
                    if (response != null)
1338
                    {
1339
                        response.Close();
1340
                    }
1341
                }
1342
                if (result == true)
1343
                {
1344
                    MessageBox.Show("File exists");
1345
                }
1346
            }
1347

    
1348
        }
1349

    
1350
        #endregion
1351

    
1352
        #region Data Delete
1353

    
1354
        private void DataDelete(object obj)
1355
        {
1356
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1357
            {
1358
                var result = evt.DialogResult;
1359

    
1360
                if (result == true)
1361
                {
1362
                    OnClosed(obj);
1363
                }
1364
            };
1365

    
1366
            RadWindow.Confirm("Do you want to delete it??", handler);
1367
        }
1368

    
1369
        private async void OnClosed(object obj)
1370
        {
1371
            if (obj is ConvertPDF)
1372
            {
1373
                if (obj != null)
1374
                {
1375
                    var convertitem = obj as ConvertPDF;
1376

    
1377
                    SelectRealConvert = convertitem;
1378
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1379

    
1380
                }
1381
            }
1382
            else if (SelectFilterConvertList.Count() > 1)
1383
            {
1384
                MessageBox.Show("하나만 클릭해 주세요!");
1385
            }
1386
            else if (SelectFilterConvertList.Count() == 0)
1387
            {
1388
                MessageBox.Show("왼쪽 버튼 클릭 후 Delete 해주세요!");
1389
            }
1390
            else
1391
            {
1392
                if (SelectFilterConvertList != null)
1393
                {
1394
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectFilterConvertList[0].ConvertID);
1395
                }
1396
            }
1397
        }
1398
        #endregion
1399

    
1400
        #region Stop Process
1401

    
1402
        private void Stop_Process(object obj)
1403
        {
1404

    
1405
            string convertid = "";
1406

    
1407
            if (obj is ConvertPDF)
1408
            {
1409

    
1410
                if (obj != null)
1411
                {
1412
                    var convertitem = obj as ConvertPDF;
1413

    
1414
                    SelectRealConvert = convertitem;
1415

    
1416
                    SelectAliveConvert = convertitem;
1417

    
1418
                    convertid = convertitem.ConvertID;
1419
                }
1420
            }
1421

    
1422

    
1423
#if DEBUG
1424
            convertid = "TEST";
1425
#endif
1426

    
1427
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1428
            {
1429
                var result = evt.DialogResult;
1430

    
1431
                if (result == true)
1432
                {
1433
                    Stop_Process(convertid);
1434
                }
1435
            };
1436

    
1437
            RadWindow.Confirm("프로세스 종료 할까요??", handler);
1438
        }
1439

    
1440
        private async void Stop_Process(string convertId)
1441
        {
1442
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10));
1443

    
1444
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1445

    
1446
            for (int i = process.Count() - 1; i >= 0; i--)
1447
            {
1448
                try
1449
                {
1450
                    var commandLines = process[i].Arguments().CommandLine;
1451

    
1452
                    if (commandLines.Count() > 0)
1453
                    {
1454
                        if (commandLines[0] == convertId)
1455
                        {
1456

    
1457
                            var _CREATE_DATETIME = DateTime.Now;
1458

    
1459
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 3, null);
1460
                            process[i].WaitForExit(5000);
1461
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 99, null);
1462
                            process[i].Kill();
1463
                        }
1464
                    }
1465
                }
1466
                catch (Exception ex)
1467
                {
1468
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
1469
                }
1470
            }
1471
        }
1472
        #endregion
1473

    
1474
        #region DataFilter
1475

    
1476
        public void DataFilter(object obj)
1477
        {
1478
            SearchTimerOn = true;
1479
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1480
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1481
        }
1482

    
1483
        #endregion
1484

    
1485
        #region Filter Enter
1486

    
1487

    
1488
        /// <summary>
1489
        /// 필터된 상단 그리드 엑셀로 출력
1490
        /// </summary>
1491

    
1492
        public void Enter(object sender)
1493
        {
1494
            SearchTimerOn = true;
1495
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1496
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1497
        }
1498

    
1499
        #endregion
1500

    
1501
        #region MarkusLink
1502

    
1503
        private void MarkusLink(object obj)
1504
        {
1505
            if (obj is ConvertPDF)
1506
            {
1507

    
1508
                if (obj != null)
1509
                {
1510
                    var convertitem = obj as ConvertPDF;
1511

    
1512
                    SelectFilterConvertList.Add(convertitem);
1513

    
1514
                    SelectRealConvert = convertitem;
1515

    
1516
                    SelectAliveConvert = convertitem;
1517

    
1518
                    ProcessStartInfo startInfo = null;
1519

    
1520
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1521

    
1522
                    Process.Start(startInfo);
1523
                }
1524

    
1525
            }
1526
        }
1527

    
1528
        #endregion
1529

    
1530
        #region Data Export
1531

    
1532

    
1533
        /// <summary>
1534
        /// 필터된 상단 그리드 엑셀로 출력
1535
        /// </summary>
1536

    
1537
        public void DataExportData(object obj)
1538
        {
1539
            if (SearchTimerOn == true)
1540
            {
1541
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1542
            }
1543
            else
1544
            {
1545
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1546
            }
1547

    
1548
            Return_FilterConvertSource(FilterConvertSource);
1549

    
1550
            Views.ConvertExcelDialog convertExcelDialog = new Views.ConvertExcelDialog();
1551

    
1552
            convertExcelDialog.Owner = Application.Current.MainWindow;
1553
            convertExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1554

    
1555
            convertExcelDialog.ShowDialog();
1556

    
1557
            if (SearchTimerOn == true)
1558
            {
1559
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1560
            }
1561
            else
1562
            {
1563
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1564
            }
1565
        }
1566

    
1567
        #endregion
1568

    
1569
        #region Data Search
1570

    
1571
        public void RemoveCreateTimeFilter(object obj)
1572
        {
1573
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1574
            SelectedCreateTimeBegin = DefaultCreateTime;
1575
            SelectedCreateTimeEnd = DefaultCreateTime;
1576
        }
1577

    
1578
        #endregion
1579

    
1580
        #region Reset
1581

    
1582
        /// <summary>
1583
        /// 그리드 상단 원상복귀 버튼
1584
        /// 필터를 끝낸 후 다시 복귀
1585
        /// </summary>
1586

    
1587
        public void Reset(object obj)
1588
        {
1589
            SearchTimerOn = false;
1590
            ExcptionCheck = false;
1591
            SelectedInt = 10;
1592
            ProjectNumberFilter = ProjectNames[0];
1593
            UniqueKeyFilter = null;
1594
            Service_IDFilter = null;
1595
            Document_NameFilter = null;
1596
            Docuemnt_NOFilter = null;
1597
            ReconverterFilter = null;
1598
            RevisionFilter = null;
1599
            GroupNOFilter = null;
1600
            DOCUMENT_URLFilter = null;
1601
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1602
            SelectedCreateTimeBegin = DefaultCreateTime;
1603
            SelectedCreateTimeEnd = DefaultCreateTime;
1604
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1605
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1606
        }
1607

    
1608
        #endregion
1609

    
1610
        #region ConvertAddDialog
1611

    
1612
        /// <summary>
1613
        /// 그리드 상단 Conver 추가 버튼
1614
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1615
        /// </summary>
1616

    
1617
        public void ConvertAdd(object obj)
1618
        {
1619
            try
1620
            {
1621
                if (SearchTimerOn == true)
1622
                {
1623
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1624
                }
1625
                else
1626
                {
1627
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1628
                }
1629

    
1630
                Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1631

    
1632
                convertAddDialog.Owner = Application.Current.MainWindow;
1633
                convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1634

    
1635
                convertAddDialog.ShowDialog();
1636

    
1637
                if (SearchTimerOn == true)
1638
                {
1639
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1640
                }
1641
                else
1642
                {
1643
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1644
                }
1645
            }
1646
            catch (Exception ex)
1647
            {
1648
                MessageBox.Show(ex.ToString());
1649
            }
1650
        }
1651

    
1652
        #endregion
1653

    
1654
        #region DocumentFilter
1655

    
1656
        /// <summary>
1657
        /// 그리드 상단 Conver 추가 버튼
1658
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1659
        /// </summary>
1660

    
1661
        public void DocumentFilter(object obj)
1662
        {
1663
            try
1664
            {
1665
                if (SearchTimerOn == true)
1666
                {
1667
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1668
                }
1669
                else
1670
                {
1671
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1672
                }
1673

    
1674

    
1675
                Views.ConvertDocumentDialog convertDocumentDialog = new Views.ConvertDocumentDialog(SelectedCount.ValueMember, RevisionFilter, Docuemnt_NOFilter, Document_NameFilter, GroupNOFilter, DOCUMENT_URLFilter, UniqueKeyFilter, ProjectNumberFilter.Project_NO);
1676

    
1677
                convertDocumentDialog.Owner = Application.Current.MainWindow;
1678
                convertDocumentDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1679

    
1680
                convertDocumentDialog.ShowDialog();
1681

    
1682
                if (SearchTimerOn == true)
1683
                {
1684
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1685
                }
1686
                else
1687
                {
1688
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1689
                }
1690
            }
1691
            catch (Exception ex)
1692
            {
1693
                MessageBox.Show(ex.ToString());
1694
            }
1695
        }
1696

    
1697
        #endregion
1698

    
1699
        #region ConvertPathFileSearch
1700

    
1701
        /// <summary>
1702
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1703
        /// </summary>
1704

    
1705
        public void ConvertPathFileSearch(object obj)
1706
        {
1707
            if (obj is ConvertPDF)
1708
            {
1709
                if (obj != null)
1710
                {
1711
                    var convertitem = obj as ConvertPDF;
1712

    
1713
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
1714
                    {
1715
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
1716
                    }
1717
                }
1718
            }
1719
        }
1720

    
1721
        #endregion
1722

    
1723
        #endregion
1724
    }
1725
}
클립보드 이미지 추가 (최대 크기: 500 MB)