프로젝트

일반

사용자정보

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

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

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

1
using Markus.Service.Extensions;
2
using Markus.Service.StationController.Data;
3
using Markus.Service.StationController.Behaviors;
4
using Markus.Service.StationController.Extensions;
5
using Markus.Service.StationController.Controls;
6
using Microsoft.Win32;
7
using System;
8
using System.Collections.Generic;
9
using System.ComponentModel;
10
using System.Linq;
11
using System.Threading.Tasks;
12
using System.Web;
13
using System.Windows;
14
using Telerik.Windows.Controls;
15
using Telerik.Windows.Data;
16
using System.Net;
17
using System.Windows.Threading;
18
using System.Diagnostics;
19
using System.Windows.Input;
20
using Markus.Mvvm.ToolKit;
21
using System.Windows.Data;
22
using System.Windows.Controls;
23
using System.IO;
24
using Newtonsoft.Json;
25
using static Markus.Service.StationController.Data.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
        }
54

    
55
        #endregion
56

    
57
        #region Properties
58

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

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

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

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

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

    
107
                return _FilterSearch;
108
            }
109
        }
110

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

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

    
131
        private static System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _ConvertSource;
132
        public static System.Collections.ObjectModel.ObservableCollection<ConvertPDF> ConvertSource
133
        {
134
            get
135
            {
136
                if (_ConvertSource == null)
137
                {
138
                    _ConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
139
                }
140
                return _ConvertSource;
141
            }
142
            set
143
            {
144
                _ConvertSource = value;
145
            }
146
        }
147

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

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

    
177

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

    
192

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

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

    
215

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

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

    
243
                return _SelectedCountList;
244
            }
245
        }
246

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

    
261

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

    
280

    
281

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

    
293

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

    
305

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

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

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

    
341
                return _StatusCodeList;
342
            }
343
        }
344

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

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

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

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

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

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

    
449
                }
450
            }
451
        }
452

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

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

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

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

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

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

    
538
            }
539
        }
540

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

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

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

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

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

    
596

    
597

    
598
        #endregion
599

    
600
        #region Command
601

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

    
609
        public DelegateCommand DataFilterCommand { get; private set; }
610
        public DelegateCommand ResetCommand { get; private set; }
611
        public DelegateCommand ConvertAddCommand { get; private set; }
612
        public DelegateCommand ConvertPathFileSearchCommand { get; private set; }
613
        public DelegateCommand Stop_ProcessCommand { get; private set; }
614
        public DelegateCommand EnterCommand { 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 ConvertPathFileSearch
1655

    
1656
        /// <summary>
1657
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1658
        /// </summary>
1659

    
1660
        public void ConvertPathFileSearch(object obj)
1661
        {
1662
            if (obj is ConvertPDF)
1663
            {
1664
                if (obj != null)
1665
                {
1666
                    var convertitem = obj as ConvertPDF;
1667

    
1668
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
1669
                    {
1670
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
1671
                    }
1672
                }
1673
            }
1674
        }
1675

    
1676
        #endregion
1677

    
1678
        #endregion
1679
    }
1680
}
클립보드 이미지 추가 (최대 크기: 500 MB)