프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceController / Markus.Service.StationController / ViewModel / DataBaseItemsModel.cs @ c1b3e862

이력 | 보기 | 이력해설 | 다운로드 (59.5 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
            Run_ProjectCommand = new DelegateCommand(Run_Project);
55
        }
56

    
57
        #endregion
58

    
59
        #region Properties
60

    
61
        DataService.DataServiceClient WcfClient;
62

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

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

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

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

    
109
                return _FilterSearch;
110
            }
111
        }
112

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

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

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

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

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

    
179

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

    
194

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

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

    
217

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

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

    
245
                return _SelectedCountList;
246
            }
247
        }
248

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

    
263

    
264
        private ObservableCollection<ConvertPDF> _SelectFilterConvertList;
265
        public ObservableCollection<ConvertPDF> SelectFilterConvertList
266
        {
267
            get
268
            {
269
                if (_SelectFilterConvertList == null)
270
                {
271
                    _SelectFilterConvertList = new ObservableCollection<ConvertPDF>();
272

    
273
                    _SelectFilterConvertList.CollectionChanged += (snd, ect) =>
274
                      {
275
                          System.Diagnostics.Debug.WriteLine($"_SelectFilterConvertList : {_SelectFilterConvertList.Count()}");
276
                      };
277
                }
278
                return _SelectFilterConvertList;
279
            }
280
            set
281
            {
282
                _SelectFilterConvertList = value;
283
                OnPropertyChanged(() => SelectFilterConvertList);
284
            }
285
        }
286

    
287

    
288

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

    
300

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

    
312

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

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

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

    
348
                return _StatusCodeList;
349
            }
350
        }
351

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

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

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

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

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

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

    
456
                }
457
            }
458
        }
459

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

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

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

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

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

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

    
545
            }
546
        }
547

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

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

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

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

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

    
603
        #endregion
604

    
605
        #region Command
606

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

    
614
        public DelegateCommand DataFilterCommand { get; private set; }
615
        public DelegateCommand ResetCommand { get; private set; }
616
        public DelegateCommand ConvertAddCommand { get; private set; }
617
        public DelegateCommand ConvertPathFileSearchCommand { get; private set; }
618
        public DelegateCommand Stop_ProcessCommand { get; private set; }
619
        public DelegateCommand EnterCommand { get; private set; }
620
        public DelegateCommand DocumentFilterCommand { get; private set; }
621
        public DelegateCommand Run_ProjectCommand { get; private set; }
622
        #endregion
623

    
624
        #region Main Logic
625

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

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

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

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

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

    
655
                    AliveDataSelect();
656
                });
657
            }
658

    
659
            await Task.Delay(5000);
660

    
661
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
662

    
663
            dispatcherTimer.Start();
664
        }
665

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

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

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

    
678
                    AliveDataSelect();
679
                });
680
            }
681

    
682
            await Task.Delay(5000);
683

    
684
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
685

    
686
            dispatcherTimer.Start();
687
        }
688

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

    
696
            base.Closed();
697
        }
698

    
699

    
700
        #endregion
701

    
702
        #region Function
703

    
704
        #region Return_FilterConvertSource
705

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

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

    
717
        #endregion
718

    
719
        #region Data Select
720

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

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

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

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

    
743

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

    
747
        }
748

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

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

    
762
                    var collectionItem = collectionItems.Cast<ConvertPDF>().ToList();
763

    
764
                    Listitems.AddRange(collectionItem);
765
                }
766

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

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

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

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

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

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

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

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

    
859
                            }
860

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

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

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

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

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

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

    
927

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1122

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

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

    
1133
                    var message = await Client.GetAsync(uri);
1134

    
1135
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1136

    
1137
                    switch (StatusCode)
1138
                    {
1139

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

    
1153
            return result;
1154
        }
1155

    
1156
        #endregion
1157

    
1158
        #region Data Convert
1159

    
1160
        private async void DataConvert(object obj)
1161
        {
1162
            if (obj is ConvertPDF)
1163
            {
1164

    
1165
                if (obj != null)
1166
                {
1167
                    var convertitem = obj as ConvertPDF;
1168

    
1169
                    SelectRealConvert = convertitem;
1170
                    SetCleanUpItem(SelectRealConvert);
1171

    
1172

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

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

    
1205
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1206
                {
1207

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

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

    
1228

    
1229
        public async void SetCleanUpItem(ConvertPDF _ConvertItem)
1230
        {
1231

    
1232
            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);
1233

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

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

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

    
1246

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

    
1251
            viewInfo.DocumentItemID = documentID;
1252
            viewInfo.ProjectNO = projectNo;
1253
            viewInfo.UserID = userID;
1254

    
1255
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1256

    
1257
        }
1258

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

    
1262
            if (oEncoding == null)
1263
                oEncoding = System.Text.Encoding.UTF8;
1264

    
1265
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1266

    
1267
        }
1268

    
1269

    
1270
        #endregion
1271

    
1272
        #region Validation
1273

    
1274
        private void DataValidate(object obj)
1275
        {
1276
            if (obj is ConvertPDF)
1277
            {
1278

    
1279
                if (obj != null)
1280
                {
1281
                    var convertitem = obj as ConvertPDF;
1282

    
1283
                    SelectRealConvert = convertitem;
1284

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

    
1290
                    HttpWebResponse response = null;
1291

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

    
1330
                HttpWebResponse response = null;
1331

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

    
1355
        }
1356

    
1357
        #endregion
1358

    
1359
        #region Data Delete
1360

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

    
1367
                if (result == true)
1368
                {
1369
                    OnClosed(obj);
1370
                }
1371
            };
1372

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

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

    
1384
                    SelectRealConvert = convertitem;
1385
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1386

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

    
1407
        #region Stop Process
1408

    
1409
        private void Stop_Process(object obj)
1410
        {
1411

    
1412
            string convertid = "";
1413

    
1414
            if (obj is ConvertPDF)
1415
            {
1416

    
1417
                if (obj != null)
1418
                {
1419
                    var convertitem = obj as ConvertPDF;
1420

    
1421
                    SelectRealConvert = convertitem;
1422

    
1423
                    SelectAliveConvert = convertitem;
1424

    
1425
                    convertid = convertitem.ConvertID;
1426
                }
1427
            }
1428

    
1429

    
1430
#if DEBUG
1431
            convertid = "TEST";
1432
#endif
1433

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

    
1438
                if (result == true)
1439
                {
1440
                    Stop_Process(convertid);
1441
                }
1442
            };
1443

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

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

    
1451
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1452

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

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

    
1464
                            var _CREATE_DATETIME = DateTime.Now;
1465

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

    
1481
        #region DataFilter
1482

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

    
1489
            FilterConvertSource.Clear();
1490
            
1491
            SearchTimer_Tick(null,new EventArgs());
1492
        }
1493

    
1494
        #endregion
1495

    
1496
        #region Filter Enter
1497

    
1498

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

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

    
1509
            FilterConvertSource.Clear();
1510

    
1511
            SearchTimer_Tick(null, new EventArgs());
1512
        }
1513

    
1514
        #endregion
1515

    
1516
        #region MarkusLink
1517

    
1518
        private void MarkusLink(object obj)
1519
        {
1520
            if (obj is ConvertPDF)
1521
            {
1522

    
1523
                if (obj != null)
1524
                {
1525
                    var convertitem = obj as ConvertPDF;
1526

    
1527
                    SelectFilterConvertList.Add(convertitem);
1528

    
1529
                    SelectRealConvert = convertitem;
1530

    
1531
                    SelectAliveConvert = convertitem;
1532

    
1533
                    ProcessStartInfo startInfo = null;
1534

    
1535
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1536

    
1537
                    Process.Start(startInfo);
1538
                }
1539

    
1540
            }
1541
        }
1542

    
1543
        #endregion
1544

    
1545
        #region Data Export
1546

    
1547

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

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

    
1563
            Return_FilterConvertSource(FilterConvertSource);
1564

    
1565
            Views.ConvertExcelDialog convertExcelDialog = new Views.ConvertExcelDialog();
1566

    
1567
            convertExcelDialog.Owner = Application.Current.MainWindow;
1568
            convertExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1569

    
1570
            convertExcelDialog.ShowDialog();
1571

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

    
1582
        #endregion
1583

    
1584
        #region Data Search
1585

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

    
1593
        #endregion
1594

    
1595
        #region Reset
1596

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

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

    
1622
            FilterConvertSource.Clear();
1623

    
1624
            Timer_Tick(null, new EventArgs());
1625
        }
1626

    
1627
        #endregion
1628

    
1629
        #region ConvertAddDialog
1630

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

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

    
1649
                Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1650

    
1651
                convertAddDialog.Owner = Application.Current.MainWindow;
1652
                convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1653

    
1654
                convertAddDialog.ShowDialog();
1655

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

    
1671
        #endregion
1672

    
1673
        #region DocumentFilter
1674

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

    
1680
        public void DocumentFilter(object obj)
1681
        {
1682
            try
1683
            {
1684
                if (SearchTimerOn == true)
1685
                {
1686
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1687
                }
1688
                else
1689
                {
1690
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1691
                }
1692

    
1693

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

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

    
1701
                convertDocumentDialog.ShowDialog();
1702

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

    
1718
        #endregion
1719

    
1720
        #region Run_Project
1721

    
1722
        public void Run_Project(object obj)
1723
        {
1724
            try
1725
            {
1726
                if (SearchTimerOn == true)
1727
                {
1728
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1729
                }
1730
                else
1731
                {
1732
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1733
                }
1734

    
1735
                Views.Run_Property_Dialog run_Property_Dialog = new Views.Run_Property_Dialog();
1736
                
1737

    
1738
                run_Property_Dialog.Owner = Application.Current.MainWindow;
1739
                run_Property_Dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1740
                run_Property_Dialog.Width = 1000;
1741
                run_Property_Dialog.Height = 350;
1742

    
1743
                run_Property_Dialog.ShowDialog();
1744

    
1745
                if (SearchTimerOn == true)
1746
                {
1747
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1748
                }
1749
                else
1750
                {
1751
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1752
                }
1753
            }
1754
            catch (Exception ex)
1755
            {
1756
                MessageBox.Show(ex.ToString());
1757
            }
1758
        }
1759

    
1760
        #endregion
1761

    
1762
        #region ConvertPathFileSearch
1763

    
1764
        /// <summary>
1765
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1766
        /// </summary>
1767

    
1768
        public void ConvertPathFileSearch(object obj)
1769
        {
1770
            if (obj is ConvertPDF)
1771
            {
1772
                if (obj != null)
1773
                {
1774
                    var convertitem = obj as ConvertPDF;
1775

    
1776
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
1777
                    {
1778
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
1779
                    }
1780
                }
1781
            }
1782
        }
1783

    
1784
        #endregion
1785

    
1786
        #endregion
1787
    }
1788
}
클립보드 이미지 추가 (최대 크기: 500 MB)