프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (58.1 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
                    _SelectFilterConvertList.CollectionChanged += (snd, ect) =>
273
                      {
274
                          System.Diagnostics.Debug.WriteLine($"_SelectFilterConvertList : {_SelectFilterConvertList.Count()}");
275
                      };
276
                }
277
                return _SelectFilterConvertList;
278
            }
279
            set
280
            {
281
                _SelectFilterConvertList = value;
282
                OnPropertyChanged(() => SelectFilterConvertList);
283
            }
284
        }
285

    
286

    
287

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

    
299

    
300
        private ConvertPDF _SelectAliveConvert;
301
        public ConvertPDF SelectAliveConvert
302
        {
303
            get => _SelectAliveConvert;
304
            set
305
            {
306
                _SelectAliveConvert = value;
307
                OnPropertyChanged(() => SelectAliveConvert);
308
            }
309
        }
310

    
311

    
312
        private StatusTypeList _StatusType;
313
        public StatusTypeList StatusType
314
        {
315
            get => _StatusType;
316
            set
317
            {
318
                _StatusType = value;
319
                OnPropertyChanged(() => StatusType);
320
            }
321
        }
322

    
323
        private bool _IsLoading;
324
        public bool IsLoading
325
        {
326
            get => _IsLoading;
327
            set
328
            {
329
                if (_IsLoading != value)
330
                {
331
                    _IsLoading = value;
332
                    OnPropertyChanged(() => IsLoading);
333
                }
334
            }
335
        }
336

    
337
        IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> _StatusCodeList;
338
        public IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> StatusCodeList
339
        {
340
            get
341
            {
342
                if (_StatusCodeList == null)
343
                {
344
                    _StatusCodeList = Telerik.Windows.Data.EnumDataSource.FromType<StatusCodeType>();
345
                }
346

    
347
                return _StatusCodeList;
348
            }
349
        }
350

    
351
        public ProjectName _ProjectNumberFilter;
352
        public ProjectName ProjectNumberFilter
353
        {
354
            get
355
            {
356
                if (_ProjectNumberFilter == null)
357
                {
358
                    _ProjectNumberFilter = new ProjectName();
359
                }
360
                return _ProjectNumberFilter;
361
            }
362
            set
363
            {
364
                _ProjectNumberFilter = value;
365
                OnPropertyChanged(() => ProjectNumberFilter);
366
            }
367
        }
368

    
369
        public string _UniqueKeyFilter;
370
        public string UniqueKeyFilter
371
        {
372
            get
373
            {
374
                return _UniqueKeyFilter;
375
            }
376
            set
377
            {
378
                if (_UniqueKeyFilter == "")
379
                {
380
                    _UniqueKeyFilter = null;
381
                }
382
                else if (_UniqueKeyFilter != value)
383
                {
384
                    _UniqueKeyFilter = value;
385
                    OnPropertyChanged(() => UniqueKeyFilter);
386
                }
387
            }
388
        }
389

    
390
        public StatusCodeType _ConvertStateFilter;
391
        public StatusCodeType ConvertStateFilter
392
        {
393
            get { return _ConvertStateFilter; }
394
            set
395
            {
396
                if (_ConvertStateFilter != value)
397
                {
398
                    _ConvertStateFilter = value;
399
                    OnPropertyChanged(() => ConvertStateFilter);
400
                }
401
            }
402
        }
403

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

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

    
440
        public int? _ReconverterFilter = 0;
441
        public int? ReconverterFilter
442
        {
443
            get { return _ReconverterFilter; }
444
            set
445
            {
446
                if (_ReconverterFilter == null)
447
                {
448
                    _ReconverterFilter = 0;
449
                }
450
                else if (_ReconverterFilter != value)
451
                {
452
                    _ReconverterFilter = value;
453
                    OnPropertyChanged(() => ReconverterFilter);
454

    
455
                }
456
            }
457
        }
458

    
459
        public string _Service_IDFilter;
460
        public string Service_IDFilter
461
        {
462
            get { return _Service_IDFilter; }
463
            set
464
            {
465
                if (_Service_IDFilter == "")
466
                {
467
                    _Service_IDFilter = null;
468
                }
469
                else if (_Service_IDFilter != value)
470
                {
471
                    _Service_IDFilter = value;
472
                    OnPropertyChanged(() => Service_IDFilter);
473
                }
474
            }
475
        }
476

    
477
        public string _RevisionFilter;
478
        public string RevisionFilter
479
        {
480
            get { return _RevisionFilter; }
481
            set
482
            {
483
                if (_RevisionFilter == "")
484
                {
485
                    _RevisionFilter = null;
486
                }
487
                else if (_RevisionFilter != value)
488
                {
489
                    _RevisionFilter = value;
490
                    OnPropertyChanged(() => RevisionFilter);
491
                }
492
            }
493
        }
494

    
495
        public string _GroupNOFilter;
496
        public string GroupNOFilter
497
        {
498
            get { return _GroupNOFilter; }
499
            set
500
            {
501
                if (_GroupNOFilter == "")
502
                {
503
                    _GroupNOFilter = null;
504
                }
505
                else if (_GroupNOFilter != value)
506
                {
507
                    _GroupNOFilter = value;
508
                    OnPropertyChanged(() => GroupNOFilter);
509
                }
510
            }
511
        }
512

    
513
        public string _DOCUMENT_URLFilter;
514
        public string DOCUMENT_URLFilter
515
        {
516
            get { return _DOCUMENT_URLFilter; }
517
            set
518
            {
519
                if (_DOCUMENT_URLFilter == "")
520
                {
521
                    _DOCUMENT_URLFilter = null;
522
                }
523
                else if (_DOCUMENT_URLFilter != value)
524
                {
525
                    _DOCUMENT_URLFilter = value;
526
                    OnPropertyChanged(() => DOCUMENT_URLFilter);
527
                }
528
            }
529
        }
530

    
531
        static DateTime DefaultCreateTime = DateTime.Now.AddHours(-1);
532
        private DateTime _SelectedCreateTimeBegin = DefaultCreateTime;
533
        public DateTime SelectedCreateTimeBegin
534
        {
535

    
536
            get { return _SelectedCreateTimeBegin; }
537
            set
538
            {
539
                if (_SelectedCreateTimeBegin == value)
540
                    return;
541
                _SelectedCreateTimeBegin = value;
542
                OnPropertyChanged(() => SelectedCreateTimeBegin);
543

    
544
            }
545
        }
546

    
547
        private DateTime _SelectedCreateTimeEnd = DefaultCreateTime;
548
        public DateTime SelectedCreateTimeEnd
549
        {
550

    
551
            get { return _SelectedCreateTimeEnd; }
552
            set
553
            {
554
                if (_SelectedCreateTimeEnd == value)
555
                    return;
556
                _SelectedCreateTimeEnd = value;
557
                OnPropertyChanged(() => SelectedCreateTimeEnd);
558
            }
559
        }
560

    
561
        public bool _ConvertShow;
562
        public bool ConvertShow
563
        {
564
            get => _ConvertShow;
565
            set
566
            {
567
                if (_ConvertShow = !value)
568
                {
569
                    _ConvertShow = false;
570
                }
571
                _ConvertShow = value;
572
                OnPropertyChanged(() => ConvertShow);
573
            }
574
        }
575

    
576
        public bool _AliveShow = false;
577
        public bool AliveShow
578
        {
579
            get => _AliveShow;
580
            set
581
            {
582
                _AliveShow = value;
583
                OnPropertyChanged(() => AliveShow);
584
            }
585
        }
586

    
587
        public bool _SearchTimerOn = false;
588
        public bool SearchTimerOn
589
        {
590
            get => _SearchTimerOn;
591
            set
592
            {
593
                if (_SearchTimerOn = !value)
594
                {
595
                    _SearchTimerOn = false;
596
                }
597
                _SearchTimerOn = value;
598
                OnPropertyChanged(() => SearchTimerOn);
599
            }
600
        }
601

    
602
        #endregion
603

    
604
        #region Command
605

    
606
        public DelegateCommand ConvertCommand { get; private set; }
607
        public DelegateCommand DeleteCommand { get; private set; }
608
        public DelegateCommand ValidateCommand { get; private set; }
609
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
610
        public DelegateCommand MarkusLinkCommand { get; private set; }
611
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
612

    
613
        public DelegateCommand DataFilterCommand { get; private set; }
614
        public DelegateCommand ResetCommand { get; private set; }
615
        public DelegateCommand ConvertAddCommand { get; private set; }
616
        public DelegateCommand ConvertPathFileSearchCommand { get; private set; }
617
        public DelegateCommand Stop_ProcessCommand { get; private set; }
618
        public DelegateCommand EnterCommand { get; private set; }
619
        public DelegateCommand DocumentFilterCommand { get; private set; }
620

    
621
        #endregion
622

    
623
        #region Main Logic
624

    
625
        /// <summary>
626
        /// 각각의 Grid row 객체들 업데이트
627
        /// </summary>
628

    
629
        private DispatcherTimer dispatcherTimer;
630
        public override void Loaded()
631
        {
632
            base.Loaded();
633

    
634
            if (!App.IsDesignMode)
635
            {
636
                dispatcherTimer = new DispatcherTimer();
637
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
638
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
639
                dispatcherTimer.Start();
640
            }
641
        }
642

    
643
        private async void Timer_Tick(object sender, EventArgs e)
644
        {
645
            dispatcherTimer.Stop();
646

    
647
            if (IsAcitve)
648
            {
649
                await App.Current.Dispatcher.InvokeAsync(() =>
650
                {
651
                    DataSelect();
652

    
653
                    AliveDataSelect();
654
                });
655
            }
656

    
657
            await Task.Delay(5000);
658

    
659
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
660

    
661
            dispatcherTimer.Start();
662
        }
663

    
664
        private async void SearchTimer_Tick(object sender, EventArgs e)
665
        {
666
            dispatcherTimer.Stop();
667

    
668
            if (IsAcitve)
669
            {
670
                await App.Current.Dispatcher.InvokeAsync(() =>
671
                {
672
                    DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
673

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

    
676
                    AliveDataSelect();
677
                });
678
            }
679

    
680
            await Task.Delay(5000);
681

    
682
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
683

    
684
            dispatcherTimer.Start();
685
        }
686

    
687
        public override void Closed()
688
        {
689
            if (dispatcherTimer != null)
690
            {
691
                dispatcherTimer.Stop();
692
            }
693

    
694
            base.Closed();
695
        }
696

    
697

    
698
        #endregion
699

    
700
        #region Function
701

    
702
        #region Return_FilterConvertSource
703

    
704
        public static void Return_FilterConvertSource(ObservableCollection<ConvertPDF> convertPDFs)
705
        {
706
            ConvertSource = new ObservableCollection<ConvertPDF>();
707
            ConvertSource = convertPDFs;
708
        }
709

    
710
        public static ObservableCollection<ConvertPDF> Return_FilterConvertSource()
711
        {
712
            return ConvertSource;
713
        }
714

    
715
        #endregion
716

    
717
        #region Data Select
718

    
719
        /// <summary>
720
        /// 상단 그리드 중앙 그리드 출력 데이터
721
        /// </summary>
722
        private void DataSelect()
723
        {
724

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

    
730
            if (RealConvertSource == null)
731
            {
732
                RealConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
733
            }
734

    
735
            /// combobox 에서 선택된 items
736
            if (SelectedStatus != null)
737
            {
738
                DataSelect(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
739
            }
740

    
741

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

    
745
        }
746

    
747
        private async void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
748
        {
749
            try
750
            {
751
                List<ConvertPDF> Listitems = new List<ConvertPDF>();
752

    
753
                foreach (var coll in collection)
754
                {
755
                    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)
756
                                          let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
757
                                          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,
758
                                      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);
759

    
760
                    var collectionItem = collectionItems.Cast<ConvertPDF>().ToList();
761

    
762
                    Listitems.AddRange(collectionItem);
763
                }
764

    
765
                foreach (var Listitem in Listitems)
766
                {
767
                    collection.UpdateWhere(changeitem =>
768
                    ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
769
                }
770
            }
771
            catch (Exception ex)
772
            {
773
                MessageBox.Show(ex.ToString());
774
            }
775
        }
776

    
777
        private async void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
778
        {
779
            try
780
            {
781
                int _status = 0;
782
                if (SelectedStatus != null)
783
                {
784
                    _status = (int)SelectedStatus.Value;
785
                }
786

    
787
                if (ProjectNames.Count() == 0)
788
                {
789
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
790
                    ProjectNames.Add(Clear);
791

    
792
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
793
                    {
794
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
795
                        ProjectNames.Add(projectName);
796
                    }
797
                }
798

    
799
                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)
800
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
801
                                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,
802
                                                        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);
803

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

    
827
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
828
                            {
829
                                collection.RemoveAt(i);
830
                            }
831
                        }
832
                    }
833

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

    
857
                            }
858

    
859
                        }
860
                    }
861
                }
862
            }
863
            catch (Exception ex)
864
            {
865
                MessageBox.Show(ex.ToString());
866
            }
867
        }
868

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

    
889
                if (ProjectNames.Count() == 0)
890
                {
891
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
892
                    ProjectNames.Add(Clear);
893

    
894
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
895
                    {
896
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
897
                        ProjectNames.Add(projectName);
898
                    }
899
                }
900

    
901
                var Listitems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(null, ProjectNumberFilter.Project_NO, UniqueKeyFilter, _status, SelectedCount.ValueMember, Start_CreateTime, Finish_CreateTime, null,
902
            null, null, null, GroupNOFilter, Document_NameFilter, Docuemnt_NOFilter, RevisionFilter, Service_IDFilter, ReconverterFilter, DOCUMENT_URLFilter, ExcptionCheck)
903
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
904
                                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,
905
           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);
906

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

    
925

    
926
                    if (statusCodeTypeList.Count() == 1)
927
                    {
928
                        for (int i = collection.Count() - 1; i >= 0; --i)
929
                        {
930
                            var item = collection[i];
931

    
932
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
933
                            {
934
                                collection.RemoveAt(i);
935
                            }
936
                        }
937
                    }
938

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

    
989
                            if (items.Count() > 0)
990
                            {
991
                                AliveShow = true;
992
                            }
993

    
994
                            foreach (var item in items)
995
                            {
996
                                ConvertPDF itemsToEach = new ConvertPDF();
997
                                itemsToEach.ServiceID = item.ServiceID;
998
                                itemsToEach.ConvertID = item.ConvertID;
999
                                itemsToEach.ProjectNumber = item.ProjectNumber;
1000

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

    
1003
                                if (item.ConvertState != null)
1004
                                {
1005
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
1006
                                }
1007

    
1008
                                if (item.OriginfilePath.Contains("/"))
1009
                                {
1010
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1011
                                }
1012
                                else
1013
                                {
1014
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1015
                                }
1016
                                itemsToEach.FileName = result;
1017

    
1018
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
1019
                                itemsToEach.TotalPage = item.TotalPage;
1020
                                itemsToEach.OriginfilePath = item.OriginfilePath;
1021
                                itemsToEach.ConvertPath = item.ConvertPath;
1022
                                itemsToEach.MarkusLink = MarkusLink;
1023
                                itemsToEach.UniqueKey = item.UniqueKey;
1024
                                itemsToEach.GroupNo = item.GroupNo;
1025
                                itemsToEach.DocumentName = item.DocumnetName;
1026
                                itemsToEach.Revision = item.Revision;
1027
                                itemsToEach.Exception = item.Exception;
1028
                                itemsToEach.ConvertPath = item.ConvertPath;
1029
                                itemsToEach.CreateTime = item.CreateTime;
1030
                                itemsToEach.ReConverter = item.ReConverter;
1031
                                itemsToEach.DocumentID = item.DocumentID;
1032
                                itemsToEach.StartTime = item.StartTime;
1033
                                itemsToEach.EndTime = item.EndTime;
1034

    
1035
                                itemsToList.Add(itemsToEach);
1036
                            }
1037
                            newitems.AddRange(itemsToList);
1038
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1039

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

    
1055
                }
1056
                ItemsUpdate(newitems);
1057
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1058
            }
1059
            catch (Exception ex)
1060
            {
1061
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1062
            }
1063
        }
1064

    
1065
        /// <summary>
1066
        /// AliveDataSelect의 Data Update
1067
        /// </summary>
1068
        /// <param name="newitems"></param>
1069
        private void ItemsUpdate(List<ConvertPDF> newitems)
1070
        {
1071

    
1072
            foreach (var item in newitems)
1073
            {
1074
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1075
            }
1076

    
1077
            if (AliveItems == null)
1078
            {
1079
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
1080

    
1081
                foreach (var item in newitems)
1082
                {
1083
                    AliveItems.Add(item);
1084
                }
1085
            }
1086
            else
1087
            {
1088
                newitems.ForEach(newitem =>
1089
                {
1090
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1091
                });
1092

    
1093
                foreach (var item in newitems)
1094
                {
1095
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1096
                    {
1097
                        AliveItems.Add(item);
1098
                    }
1099
                }
1100

    
1101
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1102
                {
1103
                    var item = AliveItems[i];
1104

    
1105
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1106
                    {
1107
                        try
1108
                        {
1109
                            AliveItems.RemoveAt(i);
1110
                        }
1111
                        catch (Exception ex)
1112
                        {
1113
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1114
                        }
1115
                    }
1116
                }
1117
            }
1118
        }
1119

    
1120

    
1121
        public static async Task<bool> SimplePingAsync(string uri)
1122
        {
1123
            bool result = false;
1124

    
1125
            try
1126
            {
1127
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1128
                {
1129
                    Client.Timeout = new TimeSpan(0, 0, 60);
1130

    
1131
                    var message = await Client.GetAsync(uri);
1132

    
1133
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1134

    
1135
                    switch (StatusCode)
1136
                    {
1137

    
1138
                        case System.Net.HttpStatusCode.Accepted:
1139
                        case System.Net.HttpStatusCode.OK:
1140
                            result = true;
1141
                            break;
1142
                    }
1143
                }
1144
            }
1145
            catch (Exception ex)
1146
            {
1147
                result = false;
1148
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1149
            }
1150

    
1151
            return result;
1152
        }
1153

    
1154
        #endregion
1155

    
1156
        #region Data Convert
1157

    
1158
        private async void DataConvert(object obj)
1159
        {
1160
            if (obj is ConvertPDF)
1161
            {
1162

    
1163
                if (obj != null)
1164
                {
1165
                    var convertitem = obj as ConvertPDF;
1166

    
1167
                    SelectRealConvert = convertitem;
1168
                    SetCleanUpItem(SelectRealConvert);
1169

    
1170

    
1171
                    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)
1172
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1173
                                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
1174
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1175

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

    
1203
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1204
                {
1205

    
1206
                    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)
1207
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1208
                                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
1209
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1210

    
1211
                    foreach (var item in items)
1212
                    {
1213
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1214
                        {
1215
                            RealConvertSource.Add(item);
1216
                        }
1217
                        if (RealConvertSource.Count() == 1)
1218
                        {
1219
                            ConvertShow = true;
1220
                        }
1221
                    }
1222
                }
1223
            }
1224
        }
1225

    
1226

    
1227
        public async void SetCleanUpItem(ConvertPDF _ConvertItem)
1228
        {
1229

    
1230
            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);
1231

    
1232
            if (items.Count() > 0)
1233
            {
1234
                var item = items.First();
1235

    
1236
                var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
1237
                var _CREATE_DATETIME = DateTime.Now;
1238
                var _STATUS = (int)StatusCodeType.None;
1239

    
1240
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null);
1241
            }
1242
        }
1243

    
1244

    
1245
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1246
        {
1247
            ViewInfo viewInfo = new ViewInfo();
1248

    
1249
            viewInfo.DocumentItemID = documentID;
1250
            viewInfo.ProjectNO = projectNo;
1251
            viewInfo.UserID = userID;
1252

    
1253
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1254

    
1255
        }
1256

    
1257
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1258
        {
1259

    
1260
            if (oEncoding == null)
1261
                oEncoding = System.Text.Encoding.UTF8;
1262

    
1263
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1264

    
1265
        }
1266

    
1267

    
1268
        #endregion
1269

    
1270
        #region Validation
1271

    
1272
        private void DataValidate(object obj)
1273
        {
1274
            if (obj is ConvertPDF)
1275
            {
1276

    
1277
                if (obj != null)
1278
                {
1279
                    var convertitem = obj as ConvertPDF;
1280

    
1281
                    SelectRealConvert = convertitem;
1282

    
1283
                    bool result = false;
1284
                    WebRequest webRequest = WebRequest.Create(SelectRealConvert.OriginfilePath);
1285
                    webRequest.Timeout = 1200; // miliseconds
1286
                    webRequest.Method = "HEAD";
1287

    
1288
                    HttpWebResponse response = null;
1289

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

    
1328
                HttpWebResponse response = null;
1329

    
1330
                try
1331
                {
1332
                    response = (HttpWebResponse)webRequest.GetResponse();
1333
                    result = true;
1334
                }
1335
                catch (WebException webException)
1336
                {
1337
                    MessageBox.Show(SelectFilterConvertList[0].FileName + " doesn't exist: " + webException.Message);
1338
                    result = false;
1339
                }
1340
                finally
1341
                {
1342
                    if (response != null)
1343
                    {
1344
                        response.Close();
1345
                    }
1346
                }
1347
                if (result == true)
1348
                {
1349
                    MessageBox.Show("File exists");
1350
                }
1351
            }
1352

    
1353
        }
1354

    
1355
        #endregion
1356

    
1357
        #region Data Delete
1358

    
1359
        private void DataDelete(object obj)
1360
        {
1361
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1362
            {
1363
                var result = evt.DialogResult;
1364

    
1365
                if (result == true)
1366
                {
1367
                    OnClosed(obj);
1368
                }
1369
            };
1370

    
1371
            RadWindow.Confirm("Do you want to delete it??", handler);
1372
        }
1373

    
1374
        private async void OnClosed(object obj)
1375
        {
1376
            if (obj is ConvertPDF)
1377
            {
1378
                if (obj != null)
1379
                {
1380
                    var convertitem = obj as ConvertPDF;
1381

    
1382
                    SelectRealConvert = convertitem;
1383
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1384

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

    
1405
        #region Stop Process
1406

    
1407
        private void Stop_Process(object obj)
1408
        {
1409

    
1410
            string convertid = "";
1411

    
1412
            if (obj is ConvertPDF)
1413
            {
1414

    
1415
                if (obj != null)
1416
                {
1417
                    var convertitem = obj as ConvertPDF;
1418

    
1419
                    SelectRealConvert = convertitem;
1420

    
1421
                    SelectAliveConvert = convertitem;
1422

    
1423
                    convertid = convertitem.ConvertID;
1424
                }
1425
            }
1426

    
1427

    
1428
#if DEBUG
1429
            convertid = "TEST";
1430
#endif
1431

    
1432
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1433
            {
1434
                var result = evt.DialogResult;
1435

    
1436
                if (result == true)
1437
                {
1438
                    Stop_Process(convertid);
1439
                }
1440
            };
1441

    
1442
            RadWindow.Confirm("프로세스 종료 할까요??", handler);
1443
        }
1444

    
1445
        private async void Stop_Process(string convertId)
1446
        {
1447
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10));
1448

    
1449
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1450

    
1451
            for (int i = process.Count() - 1; i >= 0; i--)
1452
            {
1453
                try
1454
                {
1455
                    var commandLines = process[i].Arguments().CommandLine;
1456

    
1457
                    if (commandLines.Count() > 0)
1458
                    {
1459
                        if (commandLines[0] == convertId)
1460
                        {
1461

    
1462
                            var _CREATE_DATETIME = DateTime.Now;
1463

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

    
1479
        #region DataFilter
1480

    
1481
        public void DataFilter(object obj)
1482
        {
1483
            SearchTimerOn = true;
1484
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1485
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1486

    
1487
            FilterConvertSource.Clear();
1488
            
1489
            SearchTimer_Tick(null,new EventArgs());
1490
        }
1491

    
1492
        #endregion
1493

    
1494
        #region Filter Enter
1495

    
1496

    
1497
        /// <summary>
1498
        /// 필터된 상단 그리드 엑셀로 출력
1499
        /// </summary>
1500

    
1501
        public void Enter(object sender)
1502
        {
1503
            SearchTimerOn = true;
1504
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1505
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1506

    
1507
            FilterConvertSource.Clear();
1508

    
1509
            SearchTimer_Tick(null, new EventArgs());
1510
        }
1511

    
1512
        #endregion
1513

    
1514
        #region MarkusLink
1515

    
1516
        private void MarkusLink(object obj)
1517
        {
1518
            if (obj is ConvertPDF)
1519
            {
1520

    
1521
                if (obj != null)
1522
                {
1523
                    var convertitem = obj as ConvertPDF;
1524

    
1525
                    SelectFilterConvertList.Add(convertitem);
1526

    
1527
                    SelectRealConvert = convertitem;
1528

    
1529
                    SelectAliveConvert = convertitem;
1530

    
1531
                    ProcessStartInfo startInfo = null;
1532

    
1533
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1534

    
1535
                    Process.Start(startInfo);
1536
                }
1537

    
1538
            }
1539
        }
1540

    
1541
        #endregion
1542

    
1543
        #region Data Export
1544

    
1545

    
1546
        /// <summary>
1547
        /// 필터된 상단 그리드 엑셀로 출력
1548
        /// </summary>
1549

    
1550
        public void DataExportData(object obj)
1551
        {
1552
            if (SearchTimerOn == true)
1553
            {
1554
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1555
            }
1556
            else
1557
            {
1558
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1559
            }
1560

    
1561
            Return_FilterConvertSource(FilterConvertSource);
1562

    
1563
            Views.ConvertExcelDialog convertExcelDialog = new Views.ConvertExcelDialog();
1564

    
1565
            convertExcelDialog.Owner = Application.Current.MainWindow;
1566
            convertExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1567

    
1568
            convertExcelDialog.ShowDialog();
1569

    
1570
            if (SearchTimerOn == true)
1571
            {
1572
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1573
            }
1574
            else
1575
            {
1576
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1577
            }
1578
        }
1579

    
1580
        #endregion
1581

    
1582
        #region Data Search
1583

    
1584
        public void RemoveCreateTimeFilter(object obj)
1585
        {
1586
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1587
            SelectedCreateTimeBegin = DefaultCreateTime;
1588
            SelectedCreateTimeEnd = DefaultCreateTime;
1589
        }
1590

    
1591
        #endregion
1592

    
1593
        #region Reset
1594

    
1595
        /// <summary>
1596
        /// 그리드 상단 원상복귀 버튼
1597
        /// 필터를 끝낸 후 다시 복귀
1598
        /// </summary>
1599

    
1600
        public void Reset(object obj)
1601
        {
1602
            SearchTimerOn = false;
1603
            ExcptionCheck = false;
1604
            SelectedInt = 10;
1605
            ProjectNumberFilter = ProjectNames[0];
1606
            UniqueKeyFilter = null;
1607
            Service_IDFilter = null;
1608
            Document_NameFilter = null;
1609
            Docuemnt_NOFilter = null;
1610
            ReconverterFilter = null;
1611
            RevisionFilter = null;
1612
            GroupNOFilter = null;
1613
            DOCUMENT_URLFilter = null;
1614
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1615
            SelectedCreateTimeBegin = DefaultCreateTime;
1616
            SelectedCreateTimeEnd = DefaultCreateTime;
1617
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1618
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1619

    
1620
            FilterConvertSource.Clear();
1621

    
1622
            Timer_Tick(null, new EventArgs());
1623
        }
1624

    
1625
        #endregion
1626

    
1627
        #region ConvertAddDialog
1628

    
1629
        /// <summary>
1630
        /// 그리드 상단 Conver 추가 버튼
1631
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1632
        /// </summary>
1633

    
1634
        public void ConvertAdd(object obj)
1635
        {
1636
            try
1637
            {
1638
                if (SearchTimerOn == true)
1639
                {
1640
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1641
                }
1642
                else
1643
                {
1644
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1645
                }
1646

    
1647
                Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1648

    
1649
                convertAddDialog.Owner = Application.Current.MainWindow;
1650
                convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1651

    
1652
                convertAddDialog.ShowDialog();
1653

    
1654
                if (SearchTimerOn == true)
1655
                {
1656
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1657
                }
1658
                else
1659
                {
1660
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1661
                }
1662
            }
1663
            catch (Exception ex)
1664
            {
1665
                MessageBox.Show(ex.ToString());
1666
            }
1667
        }
1668

    
1669
        #endregion
1670

    
1671
        #region DocumentFilter
1672

    
1673
        /// <summary>
1674
        /// 그리드 상단 Conver 추가 버튼
1675
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1676
        /// </summary>
1677

    
1678
        public void DocumentFilter(object obj)
1679
        {
1680
            try
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

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

    
1694
                convertDocumentDialog.Owner = Application.Current.MainWindow;
1695
                convertDocumentDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1696
                convertDocumentDialog.Width = 1000;
1697
                convertDocumentDialog.Height = 600;
1698

    
1699
                convertDocumentDialog.ShowDialog();
1700

    
1701
                if (SearchTimerOn == true)
1702
                {
1703
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1704
                }
1705
                else
1706
                {
1707
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1708
                }
1709
            }
1710
            catch (Exception ex)
1711
            {
1712
                MessageBox.Show(ex.ToString());
1713
            }
1714
        }
1715

    
1716
        #endregion
1717

    
1718
        #region ConvertPathFileSearch
1719

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

    
1724
        public void ConvertPathFileSearch(object obj)
1725
        {
1726
            if (obj is ConvertPDF)
1727
            {
1728
                if (obj != null)
1729
                {
1730
                    var convertitem = obj as ConvertPDF;
1731

    
1732
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
1733
                    {
1734
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
1735
                    }
1736
                }
1737
            }
1738
        }
1739

    
1740
        #endregion
1741

    
1742
        #endregion
1743
    }
1744
}
클립보드 이미지 추가 (최대 크기: 500 MB)