프로젝트

일반

사용자정보

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

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

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

1 5c387707 semi
using Markus.Service.Extensions;
2
using Markus.Service.StationController.Data;
3
using Markus.Service.StationController.Behaviors;
4
using Markus.Service.StationController.Extensions;
5
using Markus.Service.StationController.Controls;
6
using Microsoft.Win32;
7
using System;
8
using System.Collections.Generic;
9
using System.ComponentModel;
10
using System.Linq;
11
using System.Threading.Tasks;
12
using System.Web;
13
using System.Windows;
14
using Telerik.Windows.Controls;
15
using Telerik.Windows.Data;
16
using System.Net;
17
using System.Windows.Threading;
18
using System.Diagnostics;
19
using System.Windows.Input;
20
using Markus.Mvvm.ToolKit;
21
using System.Windows.Data;
22
using System.Windows.Controls;
23
using System.IO;
24
using Newtonsoft.Json;
25
using static Markus.Service.StationController.Data.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 64e36f82 semi
            Run_ProjectCommand = new DelegateCommand(Run_Project);
55 5c387707 semi
        }
56
57
        #endregion
58
59
        #region Properties
60
61 be7b18b6 semi
        DataService.DataServiceClient WcfClient;
62 5c387707 semi
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 aa42c9c1 semi
        private int? _ExcptionCheck;
83
        public int? ExcptionCheck
84 5c387707 semi
        {
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 c1b3e862 semi
        public int? _ReconverterFilter = null;
442 5c387707 semi
        public int? ReconverterFilter
443
        {
444
            get { return _ReconverterFilter; }
445
            set
446
            {
447 ec1eb4f9 semi
                _ReconverterFilter = value;
448
                OnPropertyChanged(() => ReconverterFilter);
449 5c387707 semi
            }
450
        }
451
452
        public string _Service_IDFilter;
453
        public string Service_IDFilter
454
        {
455
            get { return _Service_IDFilter; }
456
            set
457
            {
458
                if (_Service_IDFilter == "")
459
                {
460
                    _Service_IDFilter = null;
461
                }
462
                else if (_Service_IDFilter != value)
463
                {
464
                    _Service_IDFilter = value;
465
                    OnPropertyChanged(() => Service_IDFilter);
466
                }
467
            }
468
        }
469
470
        public string _RevisionFilter;
471
        public string RevisionFilter
472
        {
473
            get { return _RevisionFilter; }
474
            set
475
            {
476
                if (_RevisionFilter == "")
477
                {
478
                    _RevisionFilter = null;
479
                }
480
                else if (_RevisionFilter != value)
481
                {
482
                    _RevisionFilter = value;
483
                    OnPropertyChanged(() => RevisionFilter);
484
                }
485
            }
486
        }
487
488
        public string _GroupNOFilter;
489
        public string GroupNOFilter
490
        {
491
            get { return _GroupNOFilter; }
492
            set
493
            {
494
                if (_GroupNOFilter == "")
495
                {
496
                    _GroupNOFilter = null;
497
                }
498
                else if (_GroupNOFilter != value)
499
                {
500
                    _GroupNOFilter = value;
501
                    OnPropertyChanged(() => GroupNOFilter);
502
                }
503
            }
504
        }
505
506
        public string _DOCUMENT_URLFilter;
507
        public string DOCUMENT_URLFilter
508
        {
509
            get { return _DOCUMENT_URLFilter; }
510
            set
511
            {
512
                if (_DOCUMENT_URLFilter == "")
513
                {
514
                    _DOCUMENT_URLFilter = null;
515
                }
516
                else if (_DOCUMENT_URLFilter != value)
517
                {
518
                    _DOCUMENT_URLFilter = value;
519
                    OnPropertyChanged(() => DOCUMENT_URLFilter);
520
                }
521
            }
522
        }
523
524
        static DateTime DefaultCreateTime = DateTime.Now.AddHours(-1);
525
        private DateTime _SelectedCreateTimeBegin = DefaultCreateTime;
526
        public DateTime SelectedCreateTimeBegin
527
        {
528
529
            get { return _SelectedCreateTimeBegin; }
530
            set
531
            {
532
                if (_SelectedCreateTimeBegin == value)
533
                    return;
534
                _SelectedCreateTimeBegin = value;
535
                OnPropertyChanged(() => SelectedCreateTimeBegin);
536
537
            }
538
        }
539
540
        private DateTime _SelectedCreateTimeEnd = DefaultCreateTime;
541
        public DateTime SelectedCreateTimeEnd
542
        {
543
544
            get { return _SelectedCreateTimeEnd; }
545
            set
546
            {
547
                if (_SelectedCreateTimeEnd == value)
548
                    return;
549
                _SelectedCreateTimeEnd = value;
550
                OnPropertyChanged(() => SelectedCreateTimeEnd);
551
            }
552
        }
553
554
        public bool _ConvertShow;
555
        public bool ConvertShow
556
        {
557
            get => _ConvertShow;
558
            set
559
            {
560
                if (_ConvertShow = !value)
561
                {
562
                    _ConvertShow = false;
563
                }
564
                _ConvertShow = value;
565
                OnPropertyChanged(() => ConvertShow);
566
            }
567
        }
568
569
        public bool _AliveShow = false;
570
        public bool AliveShow
571
        {
572
            get => _AliveShow;
573
            set
574
            {
575
                _AliveShow = value;
576
                OnPropertyChanged(() => AliveShow);
577
            }
578
        }
579
580
        public bool _SearchTimerOn = false;
581
        public bool SearchTimerOn
582
        {
583
            get => _SearchTimerOn;
584
            set
585
            {
586
                if (_SearchTimerOn = !value)
587
                {
588
                    _SearchTimerOn = false;
589
                }
590
                _SearchTimerOn = value;
591
                OnPropertyChanged(() => SearchTimerOn);
592
            }
593
        }
594
595
        #endregion
596
597
        #region Command
598
599
        public DelegateCommand ConvertCommand { get; private set; }
600
        public DelegateCommand DeleteCommand { get; private set; }
601
        public DelegateCommand ValidateCommand { get; private set; }
602
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
603
        public DelegateCommand MarkusLinkCommand { get; private set; }
604
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
605
606
        public DelegateCommand DataFilterCommand { get; private set; }
607
        public DelegateCommand ResetCommand { get; private set; }
608
        public DelegateCommand ConvertAddCommand { get; private set; }
609
        public DelegateCommand ConvertPathFileSearchCommand { get; private set; }
610
        public DelegateCommand Stop_ProcessCommand { get; private set; }
611
        public DelegateCommand EnterCommand { get; private set; }
612
        public DelegateCommand DocumentFilterCommand { get; private set; }
613 64e36f82 semi
        public DelegateCommand Run_ProjectCommand { get; private set; }
614 5c387707 semi
        #endregion
615
616
        #region Main Logic
617
618
        /// <summary>
619
        /// 각각의 Grid row 객체들 업데이트
620
        /// </summary>
621
622
        private DispatcherTimer dispatcherTimer;
623
        public override void Loaded()
624
        {
625
            base.Loaded();
626
627
            if (!App.IsDesignMode)
628
            {
629 919dee1b semi
630
631 be7b18b6 semi
                WcfClient = new DataService.DataServiceClient();
632 5c387707 semi
                dispatcherTimer = new DispatcherTimer();
633
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
634
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
635
                dispatcherTimer.Start();
636
            }
637
        }
638
639
        private async void Timer_Tick(object sender, EventArgs e)
640
        {
641
            dispatcherTimer.Stop();
642
643
            if (IsAcitve)
644
            {
645
                await App.Current.Dispatcher.InvokeAsync(() =>
646
                {
647
                    DataSelect();
648
649
                    AliveDataSelect();
650
                });
651
            }
652
653
            await Task.Delay(5000);
654
655
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
656
657
            dispatcherTimer.Start();
658
        }
659
660
        private async void SearchTimer_Tick(object sender, EventArgs e)
661
        {
662
            dispatcherTimer.Stop();
663
664
            if (IsAcitve)
665
            {
666
                await App.Current.Dispatcher.InvokeAsync(() =>
667
                {
668
                    DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
669
670
                    RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
671
672
                    AliveDataSelect();
673
                });
674
            }
675
676
            await Task.Delay(5000);
677
678
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
679
680
            dispatcherTimer.Start();
681
        }
682
683
        public override void Closed()
684
        {
685
            if (dispatcherTimer != null)
686
            {
687
                dispatcherTimer.Stop();
688
            }
689
690
            base.Closed();
691
        }
692
693
694
        #endregion
695
696
        #region Function
697
698
        #region Return_FilterConvertSource
699
700
        public static void Return_FilterConvertSource(ObservableCollection<ConvertPDF> convertPDFs)
701
        {
702
            ConvertSource = new ObservableCollection<ConvertPDF>();
703
            ConvertSource = convertPDFs;
704
        }
705
706
        public static ObservableCollection<ConvertPDF> Return_FilterConvertSource()
707
        {
708
            return ConvertSource;
709
        }
710
711
        #endregion
712
713
        #region Data Select
714
715
        /// <summary>
716
        /// 상단 그리드 중앙 그리드 출력 데이터
717
        /// </summary>
718
        private void DataSelect()
719
        {
720
721
            if (FilterConvertSource == null)
722
            {
723
                FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
724
            }
725
726
            if (RealConvertSource == null)
727
            {
728
                RealConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
729
            }
730
731
            /// combobox 에서 선택된 items
732
            if (SelectedStatus != null)
733
            {
734
                DataSelect(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
735
            }
736
737
738
            /// 컨버터중인 items
739
            RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
740
741
        }
742
743
        private async void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
744
        {
745
            try
746
            {
747
                List<ConvertPDF> Listitems = new List<ConvertPDF>();
748
749
                foreach (var coll in collection)
750
                {
751
                    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)
752
                                          let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
753
                                          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,
754
                                      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);
755
756
                    var collectionItem = collectionItems.Cast<ConvertPDF>().ToList();
757
758
                    Listitems.AddRange(collectionItem);
759
                }
760
761
                foreach (var Listitem in Listitems)
762
                {
763
                    collection.UpdateWhere(changeitem =>
764
                    ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
765
                }
766
            }
767
            catch (Exception ex)
768
            {
769
                MessageBox.Show(ex.ToString());
770
            }
771
        }
772
773
        private async void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
774
        {
775
            try
776
            {
777
                int _status = 0;
778
                if (SelectedStatus != null)
779
                {
780
                    _status = (int)SelectedStatus.Value;
781
                }
782
783
                if (ProjectNames.Count() == 0)
784
                {
785
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
786
                    ProjectNames.Add(Clear);
787
788 919dee1b semi
                    var projectList = await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0);
789
790
                    foreach (var x in projectList)
791 5c387707 semi
                    {
792
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
793
                        ProjectNames.Add(projectName);
794
                    }
795
                }
796
797
                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)
798
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
799
                                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,
800
                                                        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);
801
802
                if (collection.Count() == 0)
803
                {
804
                    if (statusCodeTypeList.Count() == 1)
805
                    {
806
                        foreach (var Listitem in Listitems.ToList())
807
                        {
808
                            collection.Add(Listitem);
809
                        }
810
                    }
811
                }
812
                else
813
                {
814
                    foreach (var Listitem in Listitems)
815
                    {
816
                        collection.UpdateWhere(changeitem =>
817
                        ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
818
                    }
819
                    if (statusCodeTypeList.Count() == 1)
820
                    {
821
                        for (int i = collection.Count() - 1; i >= 0; --i)
822
                        {
823
                            var item = collection[i];
824
825
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
826
                            {
827
                                collection.RemoveAt(i);
828
                            }
829
                        }
830
                    }
831
832
                    if (statusCodeTypeList.Count() == 1)
833
                    {
834
                        foreach (var item in Listitems)
835
                        {
836
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
837
                            {
838
                                for (int i = 0; i < 200; i++)
839
                                {
840
                                    if (i < collection.Count() - 1)
841
                                    {
842
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
843
                                        {
844
                                            collection.Insert(i, item);
845
                                            break;
846
                                        }
847
                                    }
848
                                    else
849
                                    {
850
                                        collection.Add(item);
851
                                        break;
852
                                    }
853
                                }
854
855
                            }
856
857
                        }
858
                    }
859
                }
860
            }
861
            catch (Exception ex)
862
            {
863
                MessageBox.Show(ex.ToString());
864
            }
865
        }
866
867
        private async void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
868
        {
869
            try
870
            {
871
                int _status = 0;
872
                if (SelectedStatus != null)
873
                {
874
                    _status = (int)SelectedStatus.Value;
875
                }
876
                DateTime? Start_CreateTime = null;
877
                DateTime? Finish_CreateTime = null;
878
                if (SelectedCreateTimeBegin != DefaultCreateTime)
879
                {
880
                    Start_CreateTime = SelectedCreateTimeBegin;
881
                }
882
                if (SelectedCreateTimeEnd != DefaultCreateTime)
883
                {
884
                    Finish_CreateTime = SelectedCreateTimeEnd;
885
                }
886
887
                if (ProjectNames.Count() == 0)
888
                {
889
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
890
                    ProjectNames.Add(Clear);
891
892
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
893
                    {
894
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
895
                        ProjectNames.Add(projectName);
896
                    }
897
                }
898
899
                var Listitems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(null, ProjectNumberFilter.Project_NO, UniqueKeyFilter, _status, SelectedCount.ValueMember, Start_CreateTime, Finish_CreateTime, null,
900
            null, null, null, GroupNOFilter, Document_NameFilter, Docuemnt_NOFilter, RevisionFilter, Service_IDFilter, ReconverterFilter, DOCUMENT_URLFilter, ExcptionCheck)
901
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
902
                                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,
903
           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);
904
905
                if (collection.Count() == 0)
906
                {
907
                    if (statusCodeTypeList.Count() == 1)
908
                    {
909
                        foreach (var x in Listitems)
910
                        {
911
                            collection.Add(x);
912
                        }
913
                    }
914
                }
915
                else
916
                {
917
                    foreach (var newitem in Listitems)
918
                    {
919
                        collection.UpdateWhere(changeitem =>
920
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
921
                    }
922
923
924
                    if (statusCodeTypeList.Count() == 1)
925
                    {
926
                        for (int i = collection.Count() - 1; i >= 0; --i)
927
                        {
928
                            var item = collection[i];
929
930
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
931
                            {
932 919dee1b semi
                               collection.RemoveAt(i);
933 5c387707 semi
                            }
934
                        }
935
                    }
936
937
                    if (statusCodeTypeList.Count() == 1)
938
                    {
939
                        foreach (var item in Listitems)
940
                        {
941
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
942
                            {
943
                                for (int i = 0; i < 200; i++)
944
                                {
945
                                    if (i < collection.Count() - 1)
946
                                    {
947
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
948
                                        {
949
                                            collection.Insert(i, item);
950
                                            break;
951
                                        }
952
                                    }
953
                                    else
954
                                    {
955 ec1eb4f9 semi
956 5c387707 semi
                                        collection.Add(item);
957
                                        break;
958
                                    }
959
                                }
960
                            }
961
                        }
962
                    }
963
                }
964
            }
965
            catch (Exception ex)
966
            {
967
                MessageBox.Show(ex.ToString());
968
            }
969
        }
970
        /// <summary>
971
        /// 서비스의 실시간 컨버터 Item
972
        /// </summary>
973
        private async void AliveDataSelect()
974
        {
975
            try
976
            {
977
                List<ConvertPDF> newitems = new List<ConvertPDF>();
978
                foreach (var client in App.StationClientList)
979
                {
980
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
981
                    {
982
                        try
983
                        {
984
                            List<ConvertPDF> itemsToList = new List<ConvertPDF>();
985
                            var items = await client.AliveConvertListAsync();
986
                            string result = "";
987
988
                            if (items.Count() > 0)
989
                            {
990
                                AliveShow = true;
991
                            }
992
993
                            foreach (var item in items)
994
                            {
995
                                ConvertPDF itemsToEach = new ConvertPDF();
996
                                itemsToEach.ServiceID = item.ServiceID;
997
                                itemsToEach.ConvertID = item.ConvertID;
998
                                itemsToEach.ProjectNumber = item.ProjectNumber;
999
1000
                                var MarkusLink = "kcom://" + CreateMarkusParam(item.ProjectNumber, item.DocumentID, "doftech");
1001
1002 919dee1b semi
                                if (item.ConvertState != null)
1003
                                {
1004
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
1005
                                }
1006 5c387707 semi
1007
                                if (item.OriginfilePath.Contains("/"))
1008
                                {
1009
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1010
                                }
1011
                                else
1012
                                {
1013
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1014
                                }
1015
                                itemsToEach.FileName = result;
1016
1017
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
1018
                                itemsToEach.TotalPage = item.TotalPage;
1019
                                itemsToEach.OriginfilePath = item.OriginfilePath;
1020
                                itemsToEach.ConvertPath = item.ConvertPath;
1021
                                itemsToEach.MarkusLink = MarkusLink;
1022
                                itemsToEach.UniqueKey = item.UniqueKey;
1023
                                itemsToEach.GroupNo = item.GroupNo;
1024 919dee1b semi
                                itemsToEach.DocumentName = item.DocumnetName;
1025 5c387707 semi
                                itemsToEach.Revision = item.Revision;
1026
                                itemsToEach.Exception = item.Exception;
1027
                                itemsToEach.ConvertPath = item.ConvertPath;
1028
                                itemsToEach.CreateTime = item.CreateTime;
1029
                                itemsToEach.ReConverter = item.ReConverter;
1030
                                itemsToEach.DocumentID = item.DocumentID;
1031
                                itemsToEach.StartTime = item.StartTime;
1032
                                itemsToEach.EndTime = item.EndTime;
1033
1034
                                itemsToList.Add(itemsToEach);
1035
                            }
1036
                            newitems.AddRange(itemsToList);
1037
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1038
1039
                            if (items.Count() == 0)
1040
                            {
1041
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1042
                            }
1043
                        }
1044
                        catch (Exception ex)
1045
                        {
1046
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1047
                        }
1048
                    }
1049
                    else
1050
                    {
1051
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1052
                    }
1053
1054
                }
1055
                ItemsUpdate(newitems);
1056
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1057
            }
1058
            catch (Exception ex)
1059
            {
1060
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1061
            }
1062
        }
1063
1064
        /// <summary>
1065
        /// AliveDataSelect의 Data Update
1066
        /// </summary>
1067
        /// <param name="newitems"></param>
1068
        private void ItemsUpdate(List<ConvertPDF> newitems)
1069
        {
1070
1071
            foreach (var item in newitems)
1072
            {
1073
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1074
            }
1075
1076
            if (AliveItems == null)
1077
            {
1078
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
1079
1080
                foreach (var item in newitems)
1081
                {
1082
                    AliveItems.Add(item);
1083
                }
1084
            }
1085
            else
1086
            {
1087
                newitems.ForEach(newitem =>
1088
                {
1089
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1090
                });
1091
1092
                foreach (var item in newitems)
1093
                {
1094
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1095
                    {
1096
                        AliveItems.Add(item);
1097
                    }
1098
                }
1099
1100
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1101
                {
1102
                    var item = AliveItems[i];
1103
1104
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1105
                    {
1106
                        try
1107
                        {
1108
                            AliveItems.RemoveAt(i);
1109
                        }
1110
                        catch (Exception ex)
1111
                        {
1112
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1113
                        }
1114
                    }
1115
                }
1116
            }
1117
        }
1118
1119
1120
        public static async Task<bool> SimplePingAsync(string uri)
1121
        {
1122
            bool result = false;
1123
1124
            try
1125
            {
1126
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1127
                {
1128
                    Client.Timeout = new TimeSpan(0, 0, 60);
1129
1130
                    var message = await Client.GetAsync(uri);
1131
1132
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1133
1134
                    switch (StatusCode)
1135
                    {
1136
1137
                        case System.Net.HttpStatusCode.Accepted:
1138
                        case System.Net.HttpStatusCode.OK:
1139
                            result = true;
1140
                            break;
1141
                    }
1142
                }
1143
            }
1144
            catch (Exception ex)
1145
            {
1146
                result = false;
1147
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1148
            }
1149
1150
            return result;
1151
        }
1152
1153
        #endregion
1154
1155
        #region Data Convert
1156
1157
        private async void DataConvert(object obj)
1158
        {
1159
            if (obj is ConvertPDF)
1160
            {
1161
1162
                if (obj != null)
1163
                {
1164
                    var convertitem = obj as ConvertPDF;
1165
1166
                    SelectRealConvert = convertitem;
1167
                    SetCleanUpItem(SelectRealConvert);
1168
1169
1170
                    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)
1171
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1172
                                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
1173
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1174
1175
                    foreach (var item in items)
1176
                    {
1177
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1178
                        {
1179
                            RealConvertSource.Add(item);
1180
                        }
1181
                        if (RealConvertSource.Count() == 1)
1182
                        {
1183
                            ConvertShow = true;
1184
                        }
1185
                    }
1186
                }
1187
            }
1188
            else if (SelectFilterConvertList == null)
1189
            {
1190
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1191
            }
1192
            else
1193
            {
1194
                if (SelectFilterConvertList != null)
1195
                {
1196
                    foreach (var SelectFilterConvert in SelectFilterConvertList)
1197
                    {
1198
                        SetCleanUpItem(SelectFilterConvert);
1199
                    }
1200
                }
1201
1202
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1203
                {
1204
1205
                    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)
1206
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1207
                                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
1208
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1209
1210
                    foreach (var item in items)
1211
                    {
1212
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1213
                        {
1214
                            RealConvertSource.Add(item);
1215
                        }
1216
                        if (RealConvertSource.Count() == 1)
1217
                        {
1218
                            ConvertShow = true;
1219
                        }
1220
                    }
1221
                }
1222
            }
1223
        }
1224
1225
1226
        public async void SetCleanUpItem(ConvertPDF _ConvertItem)
1227
        {
1228
1229
            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);
1230
1231
            if (items.Count() > 0)
1232
            {
1233
                var item = items.First();
1234
1235
                var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
1236
                var _CREATE_DATETIME = DateTime.Now;
1237
                var _STATUS = (int)StatusCodeType.None;
1238
1239
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null);
1240
            }
1241
        }
1242
1243
1244
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1245
        {
1246
            ViewInfo viewInfo = new ViewInfo();
1247
1248
            viewInfo.DocumentItemID = documentID;
1249
            viewInfo.ProjectNO = projectNo;
1250
            viewInfo.UserID = userID;
1251
1252
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1253
1254
        }
1255
1256
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1257
        {
1258
1259
            if (oEncoding == null)
1260
                oEncoding = System.Text.Encoding.UTF8;
1261
1262
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1263
1264
        }
1265
1266
1267
        #endregion
1268
1269
        #region Validation
1270
1271
        private void DataValidate(object obj)
1272
        {
1273
            if (obj is ConvertPDF)
1274
            {
1275
1276
                if (obj != null)
1277
                {
1278
                    var convertitem = obj as ConvertPDF;
1279
1280
                    SelectRealConvert = convertitem;
1281
1282
                    bool result = false;
1283
                    WebRequest webRequest = WebRequest.Create(SelectRealConvert.OriginfilePath);
1284
                    webRequest.Timeout = 1200; // miliseconds
1285
                    webRequest.Method = "HEAD";
1286
1287
                    HttpWebResponse response = null;
1288
1289
                    try
1290
                    {
1291
                        response = (HttpWebResponse)webRequest.GetResponse();
1292
                        result = true;
1293
                    }
1294
                    catch (WebException webException)
1295
                    {
1296
                        MessageBox.Show(SelectRealConvert.FileName + " doesn't exist: " + webException.Message);
1297
                        result = true;
1298
                    }
1299
                    finally
1300
                    {
1301
                        if (response != null)
1302
                        {
1303
                            response.Close();
1304
                        }
1305
                    }
1306
                    if (result == true)
1307
                    {
1308
                        MessageBox.Show("File exists");
1309
                    }
1310
                }
1311
            }
1312
            else if (SelectFilterConvertList.Count() > 1)
1313
            {
1314
                MessageBox.Show("하나만 클릭해 주세요");
1315
            }
1316
            else if (SelectFilterConvertList.Count() == 0)
1317
            {
1318
                MessageBox.Show("왼쪽 버튼 클릭 후 Validate 해주세요!");
1319
            }
1320
            else
1321
            {
1322
                bool result = false;
1323
                WebRequest webRequest = WebRequest.Create(SelectFilterConvertList[0].OriginfilePath);
1324
                webRequest.Timeout = 1200; // miliseconds
1325
                webRequest.Method = "HEAD";
1326
1327
                HttpWebResponse response = null;
1328
1329
                try
1330
                {
1331
                    response = (HttpWebResponse)webRequest.GetResponse();
1332
                    result = true;
1333
                }
1334
                catch (WebException webException)
1335
                {
1336
                    MessageBox.Show(SelectFilterConvertList[0].FileName + " doesn't exist: " + webException.Message);
1337
                    result = false;
1338
                }
1339
                finally
1340
                {
1341
                    if (response != null)
1342
                    {
1343
                        response.Close();
1344
                    }
1345
                }
1346
                if (result == true)
1347
                {
1348
                    MessageBox.Show("File exists");
1349
                }
1350
            }
1351
1352
        }
1353
1354
        #endregion
1355
1356
        #region Data Delete
1357
1358
        private void DataDelete(object obj)
1359
        {
1360
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1361
            {
1362
                var result = evt.DialogResult;
1363
1364
                if (result == true)
1365
                {
1366
                    OnClosed(obj);
1367
                }
1368
            };
1369
1370
            RadWindow.Confirm("Do you want to delete it??", handler);
1371
        }
1372
1373
        private async void OnClosed(object obj)
1374
        {
1375
            if (obj is ConvertPDF)
1376
            {
1377
                if (obj != null)
1378
                {
1379
                    var convertitem = obj as ConvertPDF;
1380
1381
                    SelectRealConvert = convertitem;
1382
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1383
1384
                }
1385
            }
1386
            else if (SelectFilterConvertList.Count() > 1)
1387
            {
1388
                MessageBox.Show("하나만 클릭해 주세요!");
1389
            }
1390
            else if (SelectFilterConvertList.Count() == 0)
1391
            {
1392
                MessageBox.Show("왼쪽 버튼 클릭 후 Delete 해주세요!");
1393
            }
1394
            else
1395
            {
1396
                if (SelectFilterConvertList != null)
1397
                {
1398
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectFilterConvertList[0].ConvertID);
1399
                }
1400
            }
1401
        }
1402
        #endregion
1403
1404
        #region Stop Process
1405
1406
        private void Stop_Process(object obj)
1407
        {
1408
1409
            string convertid = "";
1410
1411
            if (obj is ConvertPDF)
1412
            {
1413
1414
                if (obj != null)
1415
                {
1416
                    var convertitem = obj as ConvertPDF;
1417
1418
                    SelectRealConvert = convertitem;
1419
1420
                    SelectAliveConvert = convertitem;
1421
1422
                    convertid = convertitem.ConvertID;
1423
                }
1424
            }
1425
1426
1427
#if DEBUG
1428
            convertid = "TEST";
1429
#endif
1430
1431
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1432
            {
1433
                var result = evt.DialogResult;
1434
1435
                if (result == true)
1436
                {
1437
                    Stop_Process(convertid);
1438
                }
1439
            };
1440
1441
            RadWindow.Confirm("프로세스 종료 할까요??", handler);
1442
        }
1443
1444
        private async void Stop_Process(string convertId)
1445
        {
1446
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10));
1447
1448
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1449
1450
            for (int i = process.Count() - 1; i >= 0; i--)
1451
            {
1452
                try
1453
                {
1454
                    var commandLines = process[i].Arguments().CommandLine;
1455
1456
                    if (commandLines.Count() > 0)
1457
                    {
1458
                        if (commandLines[0] == convertId)
1459
                        {
1460
1461
                            var _CREATE_DATETIME = DateTime.Now;
1462
1463
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 3, null);
1464
                            process[i].WaitForExit(5000);
1465
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 99, null);
1466
                            process[i].Kill();
1467
                        }
1468
                    }
1469
                }
1470
                catch (Exception ex)
1471
                {
1472
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
1473
                }
1474
            }
1475
        }
1476
        #endregion
1477
1478
        #region DataFilter
1479
1480
        public void DataFilter(object obj)
1481
        {
1482
            SearchTimerOn = true;
1483
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1484
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1485
1486
            FilterConvertSource.Clear();
1487
            
1488
            SearchTimer_Tick(null,new EventArgs());
1489
        }
1490
1491
        #endregion
1492
1493
        #region Filter Enter
1494
1495
1496
        /// <summary>
1497
        /// 필터된 상단 그리드 엑셀로 출력
1498
        /// </summary>
1499
1500
        public void Enter(object sender)
1501
        {
1502
            SearchTimerOn = true;
1503
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1504
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1505
1506
            FilterConvertSource.Clear();
1507
1508
            SearchTimer_Tick(null, new EventArgs());
1509
        }
1510
1511
        #endregion
1512
1513
        #region MarkusLink
1514
1515
        private void MarkusLink(object obj)
1516
        {
1517
            if (obj is ConvertPDF)
1518
            {
1519
1520
                if (obj != null)
1521
                {
1522
                    var convertitem = obj as ConvertPDF;
1523
1524
                    SelectFilterConvertList.Add(convertitem);
1525
1526
                    SelectRealConvert = convertitem;
1527
1528
                    SelectAliveConvert = convertitem;
1529
1530
                    ProcessStartInfo startInfo = null;
1531
1532
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1533
1534
                    Process.Start(startInfo);
1535
                }
1536
1537
            }
1538
        }
1539
1540
        #endregion
1541
1542
        #region Data Export
1543
1544
1545
        /// <summary>
1546
        /// 필터된 상단 그리드 엑셀로 출력
1547
        /// </summary>
1548
1549
        public void DataExportData(object obj)
1550
        {
1551
            if (SearchTimerOn == true)
1552
            {
1553
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1554
            }
1555
            else
1556
            {
1557
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1558
            }
1559
1560
            Return_FilterConvertSource(FilterConvertSource);
1561
1562
            Views.ConvertExcelDialog convertExcelDialog = new Views.ConvertExcelDialog();
1563
1564
            convertExcelDialog.Owner = Application.Current.MainWindow;
1565
            convertExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1566
1567
            convertExcelDialog.ShowDialog();
1568
1569
            if (SearchTimerOn == true)
1570
            {
1571
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1572
            }
1573
            else
1574
            {
1575
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1576
            }
1577
        }
1578
1579
        #endregion
1580
1581
        #region Data Search
1582
1583
        public void RemoveCreateTimeFilter(object obj)
1584
        {
1585
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1586
            SelectedCreateTimeBegin = DefaultCreateTime;
1587
            SelectedCreateTimeEnd = DefaultCreateTime;
1588
        }
1589
1590
        #endregion
1591
1592
        #region Reset
1593
1594
        /// <summary>
1595
        /// 그리드 상단 원상복귀 버튼
1596
        /// 필터를 끝낸 후 다시 복귀
1597
        /// </summary>
1598
1599
        public void Reset(object obj)
1600
        {
1601
            SearchTimerOn = false;
1602 aa42c9c1 semi
            ExcptionCheck = null;
1603 5c387707 semi
            SelectedInt = 10;
1604
            ProjectNumberFilter = ProjectNames[0];
1605
            UniqueKeyFilter = null;
1606
            Service_IDFilter = null;
1607
            Document_NameFilter = null;
1608
            Docuemnt_NOFilter = null;
1609
            ReconverterFilter = null;
1610
            RevisionFilter = null;
1611
            GroupNOFilter = null;
1612
            DOCUMENT_URLFilter = null;
1613
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1614
            SelectedCreateTimeBegin = DefaultCreateTime;
1615
            SelectedCreateTimeEnd = DefaultCreateTime;
1616
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1617
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1618
1619
            FilterConvertSource.Clear();
1620
1621
            Timer_Tick(null, new EventArgs());
1622
        }
1623
1624
        #endregion
1625
1626
        #region ConvertAddDialog
1627
1628
        /// <summary>
1629
        /// 그리드 상단 Conver 추가 버튼
1630
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1631
        /// </summary>
1632
1633
        public void ConvertAdd(object obj)
1634
        {
1635
            try
1636
            {
1637
                if (SearchTimerOn == true)
1638
                {
1639
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1640
                }
1641
                else
1642
                {
1643
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1644
                }
1645
1646
                Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1647
1648
                convertAddDialog.Owner = Application.Current.MainWindow;
1649
                convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1650
1651
                convertAddDialog.ShowDialog();
1652
1653
                if (SearchTimerOn == true)
1654
                {
1655
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1656
                }
1657
                else
1658
                {
1659
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1660
                }
1661
            }
1662
            catch (Exception ex)
1663
            {
1664
                MessageBox.Show(ex.ToString());
1665
            }
1666
        }
1667
1668
        #endregion
1669
1670
        #region DocumentFilter
1671
1672
        /// <summary>
1673
        /// 그리드 상단 Conver 추가 버튼
1674
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1675
        /// </summary>
1676
1677
        public void DocumentFilter(object obj)
1678
        {
1679
            try
1680
            {
1681
                if (SearchTimerOn == true)
1682
                {
1683
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1684
                }
1685
                else
1686
                {
1687
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1688
                }
1689
1690
1691
                Views.ConvertDocumentDialog convertDocumentDialog = new Views.ConvertDocumentDialog(SelectedCount.ValueMember, RevisionFilter, Docuemnt_NOFilter, Document_NameFilter, GroupNOFilter, DOCUMENT_URLFilter, UniqueKeyFilter, ProjectNumberFilter.Project_NO);
1692
1693
                convertDocumentDialog.Owner = Application.Current.MainWindow;
1694
                convertDocumentDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1695
                convertDocumentDialog.Width = 1000;
1696
                convertDocumentDialog.Height = 600;
1697
1698
                convertDocumentDialog.ShowDialog();
1699
1700
                if (SearchTimerOn == true)
1701
                {
1702
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1703 64e36f82 semi
                }
1704
                else
1705
                {
1706
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1707
                }
1708
            }
1709
            catch (Exception ex)
1710
            {
1711
                MessageBox.Show(ex.ToString());
1712
            }
1713
        }
1714
1715
        #endregion
1716
1717
        #region Run_Project
1718
1719
        public void Run_Project(object obj)
1720
        {
1721
            try
1722
            {
1723
                if (SearchTimerOn == true)
1724
                {
1725
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1726
                }
1727
                else
1728
                {
1729
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1730
                }
1731
1732
                Views.Run_Property_Dialog run_Property_Dialog = new Views.Run_Property_Dialog();
1733 4a41c345 semi
                
1734 64e36f82 semi
1735
                run_Property_Dialog.Owner = Application.Current.MainWindow;
1736
                run_Property_Dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1737
                run_Property_Dialog.Width = 1000;
1738 4a41c345 semi
                run_Property_Dialog.Height = 350;
1739 64e36f82 semi
1740
                run_Property_Dialog.ShowDialog();
1741
1742
                if (SearchTimerOn == true)
1743
                {
1744
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1745 5c387707 semi
                }
1746
                else
1747
                {
1748
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1749
                }
1750
            }
1751
            catch (Exception ex)
1752
            {
1753
                MessageBox.Show(ex.ToString());
1754
            }
1755
        }
1756
1757
        #endregion
1758
1759
        #region ConvertPathFileSearch
1760
1761
        /// <summary>
1762
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1763
        /// </summary>
1764
1765
        public void ConvertPathFileSearch(object obj)
1766
        {
1767
            if (obj is ConvertPDF)
1768
            {
1769
                if (obj != null)
1770
                {
1771
                    var convertitem = obj as ConvertPDF;
1772
1773
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
1774
                    {
1775
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
1776
                    }
1777
                }
1778
            }
1779
        }
1780
1781
        #endregion
1782
1783
        #endregion
1784
    }
1785
}
클립보드 이미지 추가 (최대 크기: 500 MB)