프로젝트

일반

사용자정보

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

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

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

1 31beca73 semi
using Markus.Service.Extensions;
2 e6281033 alzkakdixm
using Markus.Service.StationController.Data;
3 a6e5055d alzkakdixm
using Markus.Service.StationController.Behaviors;
4
using Markus.Service.StationController.Extensions;
5 b63dcfbb semi
using Markus.Service.StationController.Controls;
6 a6e5055d alzkakdixm
using Microsoft.Win32;
7
using System;
8
using System.Collections.Generic;
9
using System.ComponentModel;
10
using System.Linq;
11 2decfbdf alzkakdixm
using System.Threading.Tasks;
12
using System.Web;
13 a6e5055d alzkakdixm
using System.Windows;
14
using Telerik.Windows.Controls;
15
using Telerik.Windows.Data;
16 e6281033 alzkakdixm
using System.Net;
17
using System.Windows.Threading;
18 e78f0871 alzkakdixm
using System.Diagnostics;
19
using System.Windows.Input;
20
using Markus.Mvvm.ToolKit;
21 902f397c semi
using System.Windows.Data;
22 85f68fef semi
using System.Windows.Controls;
23 3bde451b semi
using System.IO;
24 2c634aed semi
using Newtonsoft.Json;
25 2f07b70a semi
using static Markus.Service.StationController.Data.ConvertPDF;
26 80391351 semi
using System.Collections.ObjectModel;
27 f5ec88b8 semi
using Markus.Service;
28 a6e5055d alzkakdixm
29
namespace Markus.Service.StationController.ViewModel
30
{
31
    //세미
32 dfc86b71 taeseongkim
    public class DataBaseItemsModel : Mvvm.ToolKit.ViewModelBase
33 a6e5055d alzkakdixm
    {
34 e6281033 alzkakdixm
        #region Constructor
35
36
        /// <summary>
37
        /// 실행하면 처음 들어가는 부분
38
        /// </summary>
39
        public DataBaseItemsModel()
40
        {
41 b63dcfbb semi
            DataFilterCommand = new DelegateCommand(DataFilter);
42 e6281033 alzkakdixm
            DataSaveFileGemBoxCommand = new DelegateCommand(DataExportData);
43
            ConvertCommand = new DelegateCommand(DataConvert);
44
            DeleteCommand = new DelegateCommand(DataDelete);
45
            ValidateCommand = new DelegateCommand(DataValidate);
46 e78f0871 alzkakdixm
            MarkusLinkCommand = new DelegateCommand(MarkusLink);
47 5a954acc semi
            RemoveCreateTimeFilterCommand = new DelegateCommand(RemoveCreateTimeFilter);
48 b63dcfbb semi
            ResetCommand = new DelegateCommand(Reset);
49 037ab674 semi
            ConvertAddCommand = new DelegateCommand(ConvertAdd);
50 78683624 semi
            ConvertPathFileSearchCommand = new DelegateCommand(ConvertPathFileSearch);
51 f5ec88b8 semi
            Stop_ProcessCommand = new DelegateCommand(Stop_Process);
52 aaed7be2 semi
            EnterCommand = new DelegateCommand(Enter);
53 e6281033 alzkakdixm
        }
54
55
        #endregion
56
57
        #region Properties
58
59 037ab674 semi
        DataService.DataServiceClient WcfClient = new DataService.DataServiceClient();
60
61 e139272d semi
        public ObservableCollection<ProjectName> _ProjectNames;
62
        public ObservableCollection<ProjectName> ProjectNames
63
        {
64
            get
65
            {
66
                if (_ProjectNames == null)
67
                {
68
                    _ProjectNames = new System.Collections.ObjectModel.ObservableCollection<ProjectName>();
69
                }
70
71
                return _ProjectNames;
72
            }
73
            set
74
            {
75
                _ProjectNames = value;
76
                OnPropertyChanged(() => ProjectNames);
77
            }
78
        }
79
80 037ab674 semi
        private bool _ExcptionCheck = false;
81
        public bool ExcptionCheck
82
        {
83
            get
84
            {
85
                return _ExcptionCheck;
86
            }
87
            set
88
            {
89
                _ExcptionCheck = value;
90
                OnPropertyChanged(() => ExcptionCheck);
91
            }
92
        }
93
94 2f07b70a semi
        private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _FilterSearch;
95
        public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> FilterSearch
96 b63dcfbb semi
        {
97
            get
98
            {
99
                if (_FilterSearch == null)
100
                {
101 2f07b70a semi
                    _FilterSearch = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>
102 b63dcfbb semi
                    {
103 2f07b70a semi
                        new ConvertPDF{ProjectNumber = "Filter Search"}
104 b63dcfbb semi
                    };
105
                }
106
107
                return _FilterSearch;
108
            }
109
        }
110
111 2f07b70a semi
        private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _AliveItems;
112
        public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> AliveItems
113 2decfbdf alzkakdixm
        {
114 e6281033 alzkakdixm
            get => _AliveItems;
115
            set
116 2decfbdf alzkakdixm
            {
117 0cb12397 alzkakdixm
                _AliveItems = value;
118 2decfbdf alzkakdixm
                OnPropertyChanged(() => AliveItems);
119
            }
120
        }
121
122 5a954acc semi
        public ICollectionView FilterConvertSourceView
123
        {
124 b63dcfbb semi
            get
125
            {
126
                var view = CollectionViewSource.GetDefaultView(FilterConvertSource);
127
                return view;
128
            }
129 5a954acc semi
        }
130
131 037ab674 semi
        private static System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _ConvertSource;
132
        public static System.Collections.ObjectModel.ObservableCollection<ConvertPDF> ConvertSource
133
        {
134
            get
135
            {
136
                if (_ConvertSource == null)
137
                {
138
                    _ConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
139
                }
140
                return _ConvertSource;
141
            }
142
            set
143
            {
144
                _ConvertSource = value;
145
            }
146
        }
147
148 2f07b70a semi
        private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _FilterConvertSource;
149
        public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> FilterConvertSource
150 dfc86b71 taeseongkim
        {
151 902f397c semi
            get
152
            {
153 5a954acc semi
                if (_FilterConvertSource == null)
154
                {
155 2f07b70a semi
                    _FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
156 5a954acc semi
                }
157 902f397c semi
                return _FilterConvertSource;
158
            }
159 dfc86b71 taeseongkim
            set
160
            {
161
                _FilterConvertSource = value;
162 f0ad40d3 semi
                OnPropertyChanged(() => FilterConvertSource);
163 dfc86b71 taeseongkim
            }
164
        }
165
166 2f07b70a semi
        private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _RealConvertSource;
167
        public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> RealConvertSource
168 dfc86b71 taeseongkim
        {
169
            get => _RealConvertSource;
170
            set
171
            {
172
                _RealConvertSource = value;
173
                OnPropertyChanged(() => RealConvertSource);
174
            }
175
        }
176
177 2decfbdf alzkakdixm
178 0cb12397 alzkakdixm
        private System.Windows.Documents.FlowDocument connectionLog;
179 2decfbdf alzkakdixm
        public System.Windows.Documents.FlowDocument ConnectionLog
180
        {
181
            get => connectionLog;
182
            set
183
            {
184
                if (connectionLog != value)
185
                {
186
                    connectionLog = value;
187
                    OnPropertyChanged(() => ConnectionLog);
188
                }
189
            }
190
        }
191
192 a6e5055d alzkakdixm
193 037ab674 semi
        private int _SelectedInt = 4;
194
        public int SelectedInt
195
        {
196
            get => _SelectedInt;
197
            set
198
            {
199
                _SelectedInt = value;
200
                OnPropertyChanged(() => SelectedInt);
201
            }
202
        }
203
204 a6e5055d alzkakdixm
        private Telerik.Windows.Data.EnumMemberViewModel _SelectedStatus;
205
        public Telerik.Windows.Data.EnumMemberViewModel SelectedStatus
206
        {
207
            get => _SelectedStatus;
208
            set
209
            {
210
                _SelectedStatus = value;
211 0cb12397 alzkakdixm
                OnPropertyChanged(() => SelectedStatus);
212 a6e5055d alzkakdixm
            }
213
        }
214
215
216
        private SelectedCountItem _SelectedCount;
217
        public SelectedCountItem SelectedCount
218
        {
219
            get => _SelectedCount;
220
            set
221
            {
222
                _SelectedCount = value;
223 dfc86b71 taeseongkim
                OnPropertyChanged(() => SelectedCount);
224 a6e5055d alzkakdixm
            }
225
        }
226
227 e6281033 alzkakdixm
        List<SelectedCountItem> _SelectedCountList;
228
        public List<SelectedCountItem> SelectedCountList
229 a6e5055d alzkakdixm
        {
230 e6281033 alzkakdixm
            get
231 2decfbdf alzkakdixm
            {
232 e6281033 alzkakdixm
                if (_SelectedCountList == null)
233 2decfbdf alzkakdixm
                {
234 e6281033 alzkakdixm
                    _SelectedCountList = new List<SelectedCountItem>
235 2decfbdf alzkakdixm
                    {
236 e6281033 alzkakdixm
                        new SelectedCountItem{DisplayMember = "50",ValueMember = 50},
237
                        new SelectedCountItem{DisplayMember = "100",ValueMember = 100},
238
                        new SelectedCountItem{DisplayMember = "150",ValueMember = 150},
239
                        new SelectedCountItem{DisplayMember = "200",ValueMember = 200}
240
                    };
241 2decfbdf alzkakdixm
                }
242 a6e5055d alzkakdixm
243 e6281033 alzkakdixm
                return _SelectedCountList;
244 2decfbdf alzkakdixm
            }
245
        }
246 a6e5055d alzkakdixm
247 2f07b70a semi
        private ConvertPDF _SelectFilterConvert;
248
        public ConvertPDF SelectFilterConvert
249 a6e5055d alzkakdixm
        {
250 80391351 semi
            get
251
            {
252
                return _SelectFilterConvert;
253
            }
254 a6e5055d alzkakdixm
            set
255
            {
256
                _SelectFilterConvert = value;
257 dfc86b71 taeseongkim
                OnPropertyChanged(() => SelectFilterConvert);
258 a6e5055d alzkakdixm
            }
259
        }
260 0cb12397 alzkakdixm
261 80391351 semi
262
        private ObservableCollection<ConvertPDF> _SelectFilterConvertList;
263
        public ObservableCollection<ConvertPDF> SelectFilterConvertList
264
        {
265
            get
266
            {
267
                if (_SelectFilterConvertList == null)
268
                {
269
                    _SelectFilterConvertList = new ObservableCollection<ConvertPDF>();
270
                }
271
                return _SelectFilterConvertList;
272
            }
273
            set
274
            {
275
                _SelectFilterConvertList = value;
276
                OnPropertyChanged(() => SelectFilterConvertList);
277
            }
278
        }
279
280
281
282 2f07b70a semi
        private ConvertPDF _SelectRealConvert;
283
        public ConvertPDF SelectRealConvert
284 a6e5055d alzkakdixm
        {
285
            get => _SelectRealConvert;
286
            set
287
            {
288
                _SelectRealConvert = value;
289 dfc86b71 taeseongkim
                OnPropertyChanged(() => SelectRealConvert);
290 a6e5055d alzkakdixm
            }
291
        }
292
293 0cb12397 alzkakdixm
294 2f07b70a semi
        private ConvertPDF _SelectAliveConvert;
295
        public ConvertPDF SelectAliveConvert
296 8c128693 semi
        {
297
            get => _SelectAliveConvert;
298
            set
299
            {
300
                _SelectAliveConvert = value;
301
                OnPropertyChanged(() => SelectAliveConvert);
302
            }
303
        }
304
305
306 0cb12397 alzkakdixm
        private StatusTypeList _StatusType;
307 a6e5055d alzkakdixm
        public StatusTypeList StatusType
308
        {
309
            get => _StatusType;
310
            set
311
            {
312
                _StatusType = value;
313 dfc86b71 taeseongkim
                OnPropertyChanged(() => StatusType);
314 a6e5055d alzkakdixm
            }
315
        }
316
317 0cb12397 alzkakdixm
        private bool _IsLoading;
318 a6e5055d alzkakdixm
        public bool IsLoading
319
        {
320
            get => _IsLoading;
321
            set
322
            {
323
                if (_IsLoading != value)
324
                {
325
                    _IsLoading = value;
326 dfc86b71 taeseongkim
                    OnPropertyChanged(() => IsLoading);
327 a6e5055d alzkakdixm
                }
328
            }
329
        }
330
331 e6281033 alzkakdixm
        IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> _StatusCodeList;
332
        public IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> StatusCodeList
333 a6e5055d alzkakdixm
        {
334
            get
335
            {
336 e6281033 alzkakdixm
                if (_StatusCodeList == null)
337 a6e5055d alzkakdixm
                {
338 e6281033 alzkakdixm
                    _StatusCodeList = Telerik.Windows.Data.EnumDataSource.FromType<StatusCodeType>();
339 a6e5055d alzkakdixm
                }
340
341 e6281033 alzkakdixm
                return _StatusCodeList;
342 a6e5055d alzkakdixm
            }
343
        }
344 8c7d1ea1 alzkakdixm
345 e139272d semi
        public ProjectName _ProjectNumberFilter;
346
        public ProjectName ProjectNumberFilter
347 902f397c semi
        {
348 e139272d semi
            get
349 902f397c semi
            {
350 e139272d semi
                if (_ProjectNumberFilter == null)
351 902f397c semi
                {
352 e139272d semi
                    _ProjectNumberFilter = new ProjectName();
353 902f397c semi
                }
354 e139272d semi
                return _ProjectNumberFilter;
355
            }
356
            set
357
            {
358
                _ProjectNumberFilter = value;
359
                OnPropertyChanged(() => ProjectNumberFilter);
360 902f397c semi
            }
361
        }
362
363
        public string _UniqueKeyFilter;
364
        public string UniqueKeyFilter
365
        {
366 b63dcfbb semi
            get
367
            {
368
                return _UniqueKeyFilter;
369
            }
370 902f397c semi
            set
371
            {
372 b63dcfbb semi
                if (_UniqueKeyFilter == "")
373
                {
374
                    _UniqueKeyFilter = null;
375
                }
376
                else if (_UniqueKeyFilter != value)
377 902f397c semi
                {
378
                    _UniqueKeyFilter = value;
379
                    OnPropertyChanged(() => UniqueKeyFilter);
380
                }
381
            }
382
        }
383
384 5a954acc semi
        public StatusCodeType _ConvertStateFilter;
385
        public StatusCodeType ConvertStateFilter
386 902f397c semi
        {
387
            get { return _ConvertStateFilter; }
388
            set
389
            {
390
                if (_ConvertStateFilter != value)
391
                {
392
                    _ConvertStateFilter = value;
393
                    OnPropertyChanged(() => ConvertStateFilter);
394
                }
395
            }
396
        }
397
398
        public string _Docuemnt_NOFilter;
399
        public string Docuemnt_NOFilter
400
        {
401
            get { return _Docuemnt_NOFilter; }
402
            set
403
            {
404 b63dcfbb semi
                if (_Docuemnt_NOFilter == "")
405
                {
406
                    _Docuemnt_NOFilter = null;
407
                }
408
                else if (_Docuemnt_NOFilter != value)
409 902f397c semi
                {
410
                    _Docuemnt_NOFilter = value;
411
                    OnPropertyChanged(() => Docuemnt_NOFilter);
412
                }
413
            }
414
        }
415
416 3bde451b semi
        public string _Document_NameFilter;
417
        public string Document_NameFilter
418 902f397c semi
        {
419 3bde451b semi
            get { return _Document_NameFilter; }
420 902f397c semi
            set
421
            {
422 3bde451b semi
                if (_Document_NameFilter == "")
423 b63dcfbb semi
                {
424 3bde451b semi
                    _Document_NameFilter = null;
425 b63dcfbb semi
                }
426 3bde451b semi
                else if (_Document_NameFilter != value)
427 902f397c semi
                {
428 3bde451b semi
                    _Document_NameFilter = value;
429
                    OnPropertyChanged(() => Document_NameFilter);
430 902f397c semi
                }
431
            }
432
        }
433
434 b63dcfbb semi
        public int? _ReconverterFilter = 0;
435 5a954acc semi
        public int? ReconverterFilter
436 902f397c semi
        {
437
            get { return _ReconverterFilter; }
438
            set
439
            {
440 85f68fef semi
                if (_ReconverterFilter == null)
441 b63dcfbb semi
                {
442
                    _ReconverterFilter = 0;
443
                }
444
                else if (_ReconverterFilter != value)
445 902f397c semi
                {
446
                    _ReconverterFilter = value;
447
                    OnPropertyChanged(() => ReconverterFilter);
448 5a954acc semi
449 902f397c semi
                }
450
            }
451
        }
452
453
        public string _Service_IDFilter;
454
        public string Service_IDFilter
455
        {
456
            get { return _Service_IDFilter; }
457
            set
458
            {
459 b63dcfbb semi
                if (_Service_IDFilter == "")
460
                {
461
                    _Service_IDFilter = null;
462
                }
463 85f68fef semi
                else if (_Service_IDFilter != value)
464 902f397c semi
                {
465
                    _Service_IDFilter = value;
466
                    OnPropertyChanged(() => Service_IDFilter);
467
                }
468
            }
469
        }
470
471
        public string _RevisionFilter;
472
        public string RevisionFilter
473
        {
474
            get { return _RevisionFilter; }
475
            set
476
            {
477 b63dcfbb semi
                if (_RevisionFilter == "")
478
                {
479 85f68fef semi
                    _RevisionFilter = null;
480 b63dcfbb semi
                }
481
                else if (_RevisionFilter != value)
482 902f397c semi
                {
483
                    _RevisionFilter = value;
484
                    OnPropertyChanged(() => RevisionFilter);
485 218e5002 semi
                }
486
            }
487
        }
488
489
        public string _GroupNOFilter;
490
        public string GroupNOFilter
491
        {
492
            get { return _GroupNOFilter; }
493
            set
494
            {
495
                if (_GroupNOFilter == "")
496
                {
497
                    _GroupNOFilter = null;
498
                }
499
                else if (_GroupNOFilter != value)
500
                {
501
                    _GroupNOFilter = value;
502
                    OnPropertyChanged(() => GroupNOFilter);
503 902f397c semi
                }
504
            }
505
        }
506 5a954acc semi
507 30680747 semi
        public string _DOCUMENT_URLFilter;
508
        public string DOCUMENT_URLFilter
509
        {
510
            get { return _DOCUMENT_URLFilter; }
511
            set
512
            {
513
                if (_DOCUMENT_URLFilter == "")
514
                {
515
                    _DOCUMENT_URLFilter = null;
516
                }
517
                else if (_DOCUMENT_URLFilter != value)
518
                {
519
                    _DOCUMENT_URLFilter = value;
520
                    OnPropertyChanged(() => DOCUMENT_URLFilter);
521
                }
522
            }
523
        }
524
525 95e7bd84 semi
        static DateTime DefaultCreateTime = DateTime.Now.AddHours(-1);
526 b63dcfbb semi
        private DateTime _SelectedCreateTimeBegin = DefaultCreateTime;
527 5a954acc semi
        public DateTime SelectedCreateTimeBegin
528
        {
529
530
            get { return _SelectedCreateTimeBegin; }
531
            set
532
            {
533
                if (_SelectedCreateTimeBegin == value)
534
                    return;
535
                _SelectedCreateTimeBegin = value;
536
                OnPropertyChanged(() => SelectedCreateTimeBegin);
537
538
            }
539
        }
540
541 b63dcfbb semi
        private DateTime _SelectedCreateTimeEnd = DefaultCreateTime;
542 5a954acc semi
        public DateTime SelectedCreateTimeEnd
543
        {
544
545
            get { return _SelectedCreateTimeEnd; }
546
            set
547
            {
548
                if (_SelectedCreateTimeEnd == value)
549
                    return;
550
                _SelectedCreateTimeEnd = value;
551
                OnPropertyChanged(() => SelectedCreateTimeEnd);
552
            }
553
        }
554
555 8c128693 semi
        public bool _ConvertShow;
556
        public bool ConvertShow
557
        {
558
            get => _ConvertShow;
559
            set
560
            {
561
                if (_ConvertShow = !value)
562
                {
563
                    _ConvertShow = false;
564
                }
565
                _ConvertShow = value;
566
                OnPropertyChanged(() => ConvertShow);
567
            }
568 b63dcfbb semi
        }
569 8c128693 semi
570 c68259ac semi
        public bool _AliveShow = false;
571 cb806a91 semi
        public bool AliveShow
572
        {
573
            get => _AliveShow;
574
            set
575
            {
576
                _AliveShow = value;
577
                OnPropertyChanged(() => AliveShow);
578
            }
579
        }
580
581 50b63148 semi
        public bool _SearchTimerOn = false;
582
        public bool SearchTimerOn
583
        {
584
            get => _SearchTimerOn;
585
            set
586
            {
587
                if (_SearchTimerOn = !value)
588
                {
589
                    _SearchTimerOn = false;
590
                }
591
                _SearchTimerOn = value;
592
                OnPropertyChanged(() => SearchTimerOn);
593
            }
594
        }
595
596 f0ad40d3 semi
597 50b63148 semi
598 e6281033 alzkakdixm
        #endregion
599
600
        #region Command
601 a6e5055d alzkakdixm
602 0cb12397 alzkakdixm
        public DelegateCommand ConvertCommand { get; private set; }
603
        public DelegateCommand DeleteCommand { get; private set; }
604
        public DelegateCommand ValidateCommand { get; private set; }
605 e6281033 alzkakdixm
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
606 e78f0871 alzkakdixm
        public DelegateCommand MarkusLinkCommand { get; private set; }
607 b63dcfbb semi
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
608
609
        public DelegateCommand DataFilterCommand { get; private set; }
610
        public DelegateCommand ResetCommand { get; private set; }
611 037ab674 semi
        public DelegateCommand ConvertAddCommand { get; private set; }
612 78683624 semi
        public DelegateCommand ConvertPathFileSearchCommand { get; private set; }
613 f5ec88b8 semi
        public DelegateCommand Stop_ProcessCommand { get; private set; }
614 aaed7be2 semi
        public DelegateCommand EnterCommand { get; private set; }
615 5a954acc semi
616 e6281033 alzkakdixm
        #endregion
617 a6e5055d alzkakdixm
618 e6281033 alzkakdixm
        #region Main Logic
619 a6e5055d alzkakdixm
620 e6281033 alzkakdixm
        /// <summary>
621
        /// 각각의 Grid row 객체들 업데이트
622
        /// </summary>
623
624
        private DispatcherTimer dispatcherTimer;
625 8c128693 semi
        public override void Loaded()
626
        {
627
            base.Loaded();
628
629
            if (!App.IsDesignMode)
630
            {
631
                dispatcherTimer = new DispatcherTimer();
632
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
633
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
634
                dispatcherTimer.Start();
635
            }
636
        }
637 a6e5055d alzkakdixm
638 b119eeaa taeseongkim
        private async void Timer_Tick(object sender, EventArgs e)
639 a6e5055d alzkakdixm
        {
640 e6281033 alzkakdixm
            dispatcherTimer.Stop();
641
642
            if (IsAcitve)
643 a6e5055d alzkakdixm
            {
644 b119eeaa taeseongkim
                await App.Current.Dispatcher.InvokeAsync(() =>
645 a6e5055d alzkakdixm
                {
646 e6281033 alzkakdixm
                    DataSelect();
647
648
                    AliveDataSelect();
649
                });
650
            }
651
652 e139272d semi
            await Task.Delay(5000);
653 b119eeaa taeseongkim
654 037ab674 semi
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
655 e6281033 alzkakdixm
656
            dispatcherTimer.Start();
657
        }
658 a6e5055d alzkakdixm
659 c7955b40 semi
        private async void SearchTimer_Tick(object sender, EventArgs e)
660
        {
661
            dispatcherTimer.Stop();
662
663
            if (IsAcitve)
664
            {
665
                await App.Current.Dispatcher.InvokeAsync(() =>
666
                {
667
                    DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
668
669
                    RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
670
671
                    AliveDataSelect();
672
                });
673
            }
674
675 e139272d semi
            await Task.Delay(5000);
676 c7955b40 semi
677 72862ad1 semi
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100));
678 c7955b40 semi
679
            dispatcherTimer.Start();
680
        }
681
682 e6281033 alzkakdixm
        public override void Closed()
683
        {
684
            if (dispatcherTimer != null)
685
            {
686
                dispatcherTimer.Stop();
687 a6e5055d alzkakdixm
            }
688 e6281033 alzkakdixm
689
            base.Closed();
690 a6e5055d alzkakdixm
        }
691 0cb12397 alzkakdixm
692 2decfbdf alzkakdixm
693 e6281033 alzkakdixm
        #endregion
694 a6e5055d alzkakdixm
695 e6281033 alzkakdixm
        #region Function
696 a6e5055d alzkakdixm
697 037ab674 semi
        #region Return_FilterConvertSource
698
699
        public static void Return_FilterConvertSource(ObservableCollection<ConvertPDF> convertPDFs)
700
        {
701
            ConvertSource = new ObservableCollection<ConvertPDF>();
702
            ConvertSource = convertPDFs;
703
        }
704
705
        public static ObservableCollection<ConvertPDF> Return_FilterConvertSource()
706
        {
707
            return ConvertSource;
708
        }
709
710
        #endregion
711
712 e6281033 alzkakdixm
        #region Data Select
713
714
        /// <summary>
715
        /// 상단 그리드 중앙 그리드 출력 데이터
716
        /// </summary>
717
        private void DataSelect()
718
        {
719 a6e5055d alzkakdixm
720 e6281033 alzkakdixm
            if (FilterConvertSource == null)
721
            {
722 2f07b70a semi
                FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
723 e6281033 alzkakdixm
            }
724
725
            if (RealConvertSource == null)
726
            {
727 2f07b70a semi
                RealConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
728 e6281033 alzkakdixm
            }
729
730
            /// combobox 에서 선택된 items
731
            if (SelectedStatus != null)
732
            {
733
                DataSelect(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
734 a6e5055d alzkakdixm
            }
735
736 e139272d semi
737 e6281033 alzkakdixm
            /// 컨버터중인 items
738
            RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
739 2decfbdf alzkakdixm
740 e6281033 alzkakdixm
        }
741 2decfbdf alzkakdixm
742 037ab674 semi
        private async void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
743 2decfbdf alzkakdixm
        {
744
            try
745
            {
746 59a29a3b semi
                List<ConvertPDF> Listitems = new List<ConvertPDF>();
747 2decfbdf alzkakdixm
748 037ab674 semi
                foreach (var coll in collection)
749
                {
750 b6bc5408 semi
                    var collectionItems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(coll.ConvertID, coll.ProjectNumber, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
751
                                          let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
752
                                          select new ConvertPDF(num.SERVICE_ID, num.ID, num.PROJECT_NO, num.STATUS, num.DOCUMENT_ID, num.DOCUMENT_NAME, num.DOCUMENT_NO, num.DOCUMENT_URL, num.REVISION, num.CURRENT_PAGE,
753
                                      num.TOTAL_PAGE, num.EXCEPTION, num.GROUP_NO, num.CREATE_DATETIME, num.START_DATETIME, num.END_DATETIME, num.DOCUMENT_URL, num.CONVERT_PATH, MarkusLink, num.RECONVERTER);
754 59a29a3b semi
755
                    var collectionItem = collectionItems.Cast<ConvertPDF>().ToList();
756
757
                    Listitems.AddRange(collectionItem);
758 037ab674 semi
                }
759 8c128693 semi
760 037ab674 semi
                foreach (var Listitem in Listitems)
761
                {
762
                    collection.UpdateWhere(changeitem =>
763
                    ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
764 2decfbdf alzkakdixm
                }
765
            }
766
            catch (Exception ex)
767
            {
768
                MessageBox.Show(ex.ToString());
769
            }
770
        }
771
772 037ab674 semi
        private async void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
773 a6e5055d alzkakdixm
        {
774
            try
775
            {
776 037ab674 semi
                int _status = 0;
777
                if (SelectedStatus != null)
778 a6e5055d alzkakdixm
                {
779 037ab674 semi
                    _status = (int)SelectedStatus.Value;
780
                }
781 a6e5055d alzkakdixm
782 037ab674 semi
                if (ProjectNames.Count() == 0)
783
                {
784 aaed7be2 semi
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
785 037ab674 semi
                    ProjectNames.Add(Clear);
786 93f5e32a semi
787 037ab674 semi
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
788 2decfbdf alzkakdixm
                    {
789 037ab674 semi
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
790
                        ProjectNames.Add(projectName);
791 2decfbdf alzkakdixm
                    }
792 037ab674 semi
                }
793
794
                var Listitems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(null, null, null, _status, SelectedCount.ValueMember, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
795
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
796
                                select new ConvertPDF(num.SERVICE_ID, num.ID, num.PROJECT_NO, num.STATUS, num.DOCUMENT_ID, num.DOCUMENT_NAME, num.DOCUMENT_NO, num.DOCUMENT_URL, num.REVISION, num.CURRENT_PAGE,
797 59a29a3b semi
                                                        num.TOTAL_PAGE, num.EXCEPTION, num.GROUP_NO, num.CREATE_DATETIME, num.START_DATETIME, num.END_DATETIME, num.DOCUMENT_URL, num.CONVERT_PATH, MarkusLink, num.RECONVERTER);
798 2decfbdf alzkakdixm
799 037ab674 semi
                if (collection.Count() == 0)
800
                {
801
                    if (statusCodeTypeList.Count() == 1)
802 3bde451b semi
                    {
803 037ab674 semi
                        foreach (var Listitem in Listitems.ToList())
804 e139272d semi
                        {
805 037ab674 semi
                            collection.Add(Listitem);
806 e139272d semi
                        }
807 3bde451b semi
                    }
808 037ab674 semi
                }
809
                else
810
                {
811
                    foreach (var Listitem in Listitems)
812 a6e5055d alzkakdixm
                    {
813 037ab674 semi
                        collection.UpdateWhere(changeitem =>
814
                        ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
815 a6e5055d alzkakdixm
                    }
816 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
817 a6e5055d alzkakdixm
                    {
818 037ab674 semi
                        for (int i = collection.Count() - 1; i >= 0; --i)
819 a6e5055d alzkakdixm
                        {
820 037ab674 semi
                            var item = collection[i];
821 a6e5055d alzkakdixm
822 037ab674 semi
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
823
                            {
824
                                collection.RemoveAt(i);
825 2decfbdf alzkakdixm
                            }
826 a6e5055d alzkakdixm
                        }
827 037ab674 semi
                    }
828 a6e5055d alzkakdixm
829 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
830
                    {
831
                        foreach (var item in Listitems)
832 a6e5055d alzkakdixm
                        {
833 037ab674 semi
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
834 2decfbdf alzkakdixm
                            {
835 037ab674 semi
                                for (int i = 0; i < 200; i++)
836 2decfbdf alzkakdixm
                                {
837 037ab674 semi
                                    if (i < collection.Count() - 1)
838 2decfbdf alzkakdixm
                                    {
839 037ab674 semi
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
840 2decfbdf alzkakdixm
                                        {
841 037ab674 semi
                                            collection.Insert(i, item);
842 2decfbdf alzkakdixm
                                            break;
843
                                        }
844
                                    }
845 037ab674 semi
                                    else
846
                                    {
847
                                        collection.Add(item);
848
                                        break;
849
                                    }
850 2decfbdf alzkakdixm
                                }
851 a6e5055d alzkakdixm
852
                            }
853 2decfbdf alzkakdixm
854 037ab674 semi
                        }
855 a6e5055d alzkakdixm
                    }
856
                }
857
            }
858
            catch (Exception ex)
859
            {
860 31beca73 semi
                MessageBox.Show(ex.ToString());
861 a6e5055d alzkakdixm
            }
862
        }
863
864 037ab674 semi
        private async void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
865 b63dcfbb semi
        {
866
            try
867
            {
868 037ab674 semi
                int _status = 0;
869
                if (SelectedStatus != null)
870 b63dcfbb semi
                {
871 037ab674 semi
                    _status = (int)SelectedStatus.Value;
872
                }
873
                DateTime? Start_CreateTime = null;
874
                DateTime? Finish_CreateTime = null;
875
                if (SelectedCreateTimeBegin != DefaultCreateTime)
876
                {
877
                    Start_CreateTime = SelectedCreateTimeBegin;
878
                }
879
                if (SelectedCreateTimeEnd != DefaultCreateTime)
880
                {
881
                    Finish_CreateTime = SelectedCreateTimeEnd;
882
                }
883 b63dcfbb semi
884 037ab674 semi
                if (ProjectNames.Count() == 0)
885
                {
886 aaed7be2 semi
                    ProjectName Clear = new ProjectName("Selected All", "Selected All");
887
                    ProjectNames.Add(Clear);
888
889 037ab674 semi
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
890 3bde451b semi
                    {
891 037ab674 semi
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
892
                        ProjectNames.Add(projectName);
893 3bde451b semi
                    }
894 037ab674 semi
                }
895 218e5002 semi
896 037ab674 semi
                var Listitems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(null, ProjectNumberFilter.Project_NO, UniqueKeyFilter, _status, SelectedCount.ValueMember, Start_CreateTime, Finish_CreateTime, null,
897
            null, null, null, GroupNOFilter, Document_NameFilter, Docuemnt_NOFilter, RevisionFilter, Service_IDFilter, ReconverterFilter, DOCUMENT_URLFilter, ExcptionCheck)
898
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
899
                                select new ConvertPDF(num.SERVICE_ID, num.ID, num.PROJECT_NO, num.STATUS, num.DOCUMENT_ID, num.DOCUMENT_NAME, num.DOCUMENT_NO, num.DOCUMENT_URL, num.REVISION, num.CURRENT_PAGE,
900
           num.TOTAL_PAGE, num.EXCEPTION, num.GROUP_NO, num.CREATE_DATETIME, num.START_DATETIME, num.END_DATETIME, num.DOCUMENT_URL, num.CONVERT_PATH, MarkusLink, num.RECONVERTER);
901 e139272d semi
902 037ab674 semi
                if (collection.Count() == 0)
903
                {
904
                    if (statusCodeTypeList.Count() == 1)
905 3bde451b semi
                    {
906 037ab674 semi
                        foreach (var x in Listitems)
907 b63dcfbb semi
                        {
908 037ab674 semi
                            collection.Add(x);
909 b63dcfbb semi
                        }
910 3bde451b semi
                    }
911 037ab674 semi
                }
912
                else
913
                {
914
                    foreach (var newitem in Listitems)
915 3bde451b semi
                    {
916 037ab674 semi
                        collection.UpdateWhere(changeitem =>
917
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
918
                    }
919 3bde451b semi
920 b63dcfbb semi
921 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
922
                    {
923
                        for (int i = collection.Count() - 1; i >= 0; --i)
924 3bde451b semi
                        {
925 037ab674 semi
                            var item = collection[i];
926 b63dcfbb semi
927 037ab674 semi
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
928 b63dcfbb semi
                            {
929 037ab674 semi
                                collection.RemoveAt(i);
930 b63dcfbb semi
                            }
931 3bde451b semi
                        }
932 037ab674 semi
                    }
933 b63dcfbb semi
934 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
935
                    {
936
                        foreach (var item in Listitems)
937 3bde451b semi
                        {
938 037ab674 semi
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
939 b63dcfbb semi
                            {
940 037ab674 semi
                                for (int i = 0; i < 200; i++)
941 b63dcfbb semi
                                {
942 037ab674 semi
                                    if (i < collection.Count() - 1)
943 b63dcfbb semi
                                    {
944 037ab674 semi
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
945 3bde451b semi
                                        {
946 037ab674 semi
                                            collection.Insert(i, item);
947 3bde451b semi
                                            break;
948
                                        }
949 b63dcfbb semi
                                    }
950 037ab674 semi
                                    else
951
                                    {
952
                                        collection.Add(item);
953
                                        break;
954
                                    }
955 b63dcfbb semi
                                }
956 3bde451b semi
                            }
957 218e5002 semi
                        }
958 b63dcfbb semi
                    }
959
                }
960
            }
961
            catch (Exception ex)
962
            {
963 31beca73 semi
                MessageBox.Show(ex.ToString());
964 b63dcfbb semi
            }
965
        }
966 e6281033 alzkakdixm
        /// <summary>
967
        /// 서비스의 실시간 컨버터 Item
968
        /// </summary>
969
        private async void AliveDataSelect()
970 a6e5055d alzkakdixm
        {
971 e6281033 alzkakdixm
            try
972 a6e5055d alzkakdixm
            {
973 2f07b70a semi
                List<ConvertPDF> newitems = new List<ConvertPDF>();
974 3bde451b semi
                foreach (var client in App.StationClientList)
975 e6281033 alzkakdixm
                {
976 3bde451b semi
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
977 e6281033 alzkakdixm
                    {
978 3bde451b semi
                        try
979 e6281033 alzkakdixm
                        {
980 2f07b70a semi
                            List<ConvertPDF> itemsToList = new List<ConvertPDF>();
981 3bde451b semi
                            var items = await client.AliveConvertListAsync();
982
                            string result = "";
983 8c128693 semi
984 b6bc5408 semi
                            if (items.Count() > 0)
985
                            {
986
                                AliveShow = true;
987
                            }
988
989 3bde451b semi
                            foreach (var item in items)
990
                            {
991 2f07b70a semi
                                ConvertPDF itemsToEach = new ConvertPDF();
992 3bde451b semi
                                itemsToEach.ServiceID = item.ServiceID;
993
                                itemsToEach.ConvertID = item.ConvertID;
994
                                itemsToEach.ProjectNumber = item.ProjectNumber;
995 8c128693 semi
996 ee910e7f semi
                                var MarkusLink = "kcom://" + CreateMarkusParam(item.ProjectNumber, item.DocumentID, "doftech");
997 8c128693 semi
998 3bde451b semi
                                if (item.ConvertState != null)
999
                                {
1000
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
1001 e6281033 alzkakdixm
                                }
1002
1003 3bde451b semi
                                if (item.OriginfilePath.Contains("/"))
1004
                                {
1005
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1006
                                }
1007
                                else
1008 8c128693 semi
                                {
1009 3bde451b semi
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1010 8c128693 semi
                                }
1011 3bde451b semi
                                itemsToEach.FileName = result;
1012
1013
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
1014
                                itemsToEach.TotalPage = item.TotalPage;
1015
                                itemsToEach.OriginfilePath = item.OriginfilePath;
1016
                                itemsToEach.ConvertPath = item.ConvertPath;
1017 ee910e7f semi
                                itemsToEach.MarkusLink = MarkusLink;
1018 cb806a91 semi
                                itemsToEach.UniqueKey = item.UniqueKey;
1019
                                itemsToEach.GroupNo = item.GroupNo;
1020 5feff9f0 semi
                                itemsToEach.DocumentName = item.DocumnetName;
1021 f0ad40d3 semi
                                itemsToEach.Revision = item.Revision;
1022 cb806a91 semi
                                itemsToEach.Exception = item.Exception;
1023 ee910e7f semi
                                itemsToEach.ConvertPath = item.ConvertPath;
1024 3bde451b semi
                                itemsToEach.CreateTime = item.CreateTime;
1025
                                itemsToEach.ReConverter = item.ReConverter;
1026
                                itemsToEach.DocumentID = item.DocumentID;
1027
                                itemsToEach.StartTime = item.StartTime;
1028
                                itemsToEach.EndTime = item.EndTime;
1029
1030
                                itemsToList.Add(itemsToEach);
1031 e6281033 alzkakdixm
                            }
1032 3bde451b semi
                            newitems.AddRange(itemsToList);
1033
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1034
1035
                            if (items.Count() == 0)
1036 e6281033 alzkakdixm
                            {
1037 3bde451b semi
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1038 e6281033 alzkakdixm
                            }
1039
                        }
1040 3bde451b semi
                        catch (Exception ex)
1041 e6281033 alzkakdixm
                        {
1042 3bde451b semi
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1043 e6281033 alzkakdixm
                        }
1044
                    }
1045 3bde451b semi
                    else
1046
                    {
1047
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1048
                    }
1049
1050 e6281033 alzkakdixm
                }
1051
                ItemsUpdate(newitems);
1052
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1053
            }
1054
            catch (Exception ex)
1055
            {
1056
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1057 a6e5055d alzkakdixm
            }
1058
        }
1059
1060 e6281033 alzkakdixm
        /// <summary>
1061
        /// AliveDataSelect의 Data Update
1062
        /// </summary>
1063
        /// <param name="newitems"></param>
1064 2f07b70a semi
        private void ItemsUpdate(List<ConvertPDF> newitems)
1065 a6e5055d alzkakdixm
        {
1066
1067 e6281033 alzkakdixm
            foreach (var item in newitems)
1068
            {
1069
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1070
            }
1071
1072
            if (AliveItems == null)
1073
            {
1074 2f07b70a semi
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
1075 e6281033 alzkakdixm
1076
                foreach (var item in newitems)
1077
                {
1078
                    AliveItems.Add(item);
1079
                }
1080
            }
1081
            else
1082 a6e5055d alzkakdixm
            {
1083 e6281033 alzkakdixm
                newitems.ForEach(newitem =>
1084
                {
1085
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1086
                });
1087
1088
                foreach (var item in newitems)
1089
                {
1090
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1091
                    {
1092
                        AliveItems.Add(item);
1093
                    }
1094
                }
1095 a6e5055d alzkakdixm
1096 e6281033 alzkakdixm
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1097
                {
1098
                    var item = AliveItems[i];
1099 a6e5055d alzkakdixm
1100 e6281033 alzkakdixm
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1101
                    {
1102
                        try
1103
                        {
1104
                            AliveItems.RemoveAt(i);
1105
                        }
1106
                        catch (Exception ex)
1107
                        {
1108
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1109
                        }
1110
                    }
1111
                }
1112 2decfbdf alzkakdixm
            }
1113 a6e5055d alzkakdixm
        }
1114
1115
1116 e6281033 alzkakdixm
        public static async Task<bool> SimplePingAsync(string uri)
1117 a6e5055d alzkakdixm
        {
1118 e6281033 alzkakdixm
            bool result = false;
1119
1120
            try
1121
            {
1122
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1123
                {
1124
                    Client.Timeout = new TimeSpan(0, 0, 60);
1125
1126
                    var message = await Client.GetAsync(uri);
1127
1128
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1129
1130
                    switch (StatusCode)
1131
                    {
1132
1133
                        case System.Net.HttpStatusCode.Accepted:
1134
                        case System.Net.HttpStatusCode.OK:
1135
                            result = true;
1136
                            break;
1137
                    }
1138
                }
1139
            }
1140
            catch (Exception ex)
1141
            {
1142
                result = false;
1143
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1144
            }
1145
1146
            return result;
1147 a6e5055d alzkakdixm
        }
1148
1149 e6281033 alzkakdixm
        #endregion
1150
1151
        #region Data Convert
1152 a6e5055d alzkakdixm
1153 037ab674 semi
        private async void DataConvert(object obj)
1154 e6281033 alzkakdixm
        {
1155 472d507b semi
            if (obj is ConvertPDF)
1156
            {
1157
1158
                if (obj != null)
1159
                {
1160
                    var convertitem = obj as ConvertPDF;
1161
1162
                    SelectRealConvert = convertitem;
1163
                    SetCleanUpItem(SelectRealConvert);
1164
1165
1166
                    var items = from x in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(SelectRealConvert.ConvertID, null, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
1167
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1168
                                select new ConvertPDF(x.SERVICE_ID, x.ID, x.PROJECT_NO, x.STATUS, x.DOCUMENT_ID, x.DOCUMENT_NAME, x.DOCUMENT_NO, x.DOCUMENT_URL, x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1169
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1170
1171
                    foreach (var item in items)
1172
                    {
1173
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1174
                        {
1175
                            RealConvertSource.Add(item);
1176
                        }
1177
                        if (RealConvertSource.Count() == 1)
1178
                        {
1179
                            ConvertShow = true;
1180
                        }
1181
                    }
1182
                }
1183
            }
1184
            else if (SelectFilterConvertList == null)
1185 e6281033 alzkakdixm
            {
1186
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1187
            }
1188
            else
1189 a6e5055d alzkakdixm
            {
1190 80391351 semi
                if (SelectFilterConvertList != null)
1191 a6e5055d alzkakdixm
                {
1192 80391351 semi
                    foreach (var SelectFilterConvert in SelectFilterConvertList)
1193
                    {
1194 59a29a3b semi
                        SetCleanUpItem(SelectFilterConvert);
1195 80391351 semi
                    }
1196 e6281033 alzkakdixm
                }
1197 3bde451b semi
1198 037ab674 semi
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1199
                {
1200 3bde451b semi
1201 037ab674 semi
                    var items = from x in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(SelectFilterConvert.ConvertID, null, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
1202
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1203
                                select new ConvertPDF(x.SERVICE_ID, x.ID, x.PROJECT_NO, x.STATUS, x.DOCUMENT_ID, x.DOCUMENT_NAME, x.DOCUMENT_NO, x.DOCUMENT_URL, x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1204
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1205 3bde451b semi
1206 037ab674 semi
                    foreach (var item in items)
1207
                    {
1208 b6bc5408 semi
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1209
                        {
1210
                            RealConvertSource.Add(item);
1211
                        }
1212 037ab674 semi
                        if (RealConvertSource.Count() == 1)
1213
                        {
1214
                            ConvertShow = true;
1215 3bde451b semi
                        }
1216 8c7d1ea1 alzkakdixm
                    }
1217 a6e5055d alzkakdixm
                }
1218 3bde451b semi
            }
1219
        }
1220
1221
1222 59a29a3b semi
        public async void SetCleanUpItem(ConvertPDF _ConvertItem)
1223 3bde451b semi
        {
1224 f0ad40d3 semi
1225 59a29a3b semi
            var items = await WcfClient.GET_SELECT_CONVERT_ITEMAsync(_ConvertItem.ConvertID, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
1226 f0ad40d3 semi
1227 037ab674 semi
            if (items.Count() > 0)
1228
            {
1229
                var item = items.First();
1230 3bde451b semi
1231 037ab674 semi
                var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
1232
                var _CREATE_DATETIME = DateTime.Now;
1233
                var _STATUS = (int)StatusCodeType.None;
1234 3bde451b semi
1235 cb806a91 semi
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null);
1236 3bde451b semi
            }
1237
        }
1238
1239 e6281033 alzkakdixm
1240 2c634aed semi
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1241
        {
1242
            ViewInfo viewInfo = new ViewInfo();
1243
1244
            viewInfo.DocumentItemID = documentID;
1245
            viewInfo.ProjectNO = projectNo;
1246
            viewInfo.UserID = userID;
1247
1248
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1249
1250
        }
1251
1252
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1253
        {
1254
1255
            if (oEncoding == null)
1256
                oEncoding = System.Text.Encoding.UTF8;
1257
1258
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1259
1260
        }
1261
1262 e6281033 alzkakdixm
1263 3bde451b semi
        #endregion
1264
1265 e6281033 alzkakdixm
        #region Validation
1266 a6e5055d alzkakdixm
1267 e6281033 alzkakdixm
        private void DataValidate(object obj)
1268
        {
1269 472d507b semi
            if (obj is ConvertPDF)
1270
            {
1271
1272
                if (obj != null)
1273
                {
1274
                    var convertitem = obj as ConvertPDF;
1275
1276
                    SelectRealConvert = convertitem;
1277
1278
                    bool result = false;
1279
                    WebRequest webRequest = WebRequest.Create(SelectRealConvert.OriginfilePath);
1280
                    webRequest.Timeout = 1200; // miliseconds
1281
                    webRequest.Method = "HEAD";
1282
1283
                    HttpWebResponse response = null;
1284
1285
                    try
1286
                    {
1287
                        response = (HttpWebResponse)webRequest.GetResponse();
1288
                        result = true;
1289
                    }
1290
                    catch (WebException webException)
1291
                    {
1292
                        MessageBox.Show(SelectRealConvert.FileName + " doesn't exist: " + webException.Message);
1293
                        result = true;
1294
                    }
1295
                    finally
1296
                    {
1297
                        if (response != null)
1298
                        {
1299
                            response.Close();
1300
                        }
1301
                    }
1302
                    if (result == true)
1303
                    {
1304
                        MessageBox.Show("File exists");
1305
                    }
1306
                }
1307
            }
1308
            else if (SelectFilterConvertList.Count() > 1)
1309 e6281033 alzkakdixm
            {
1310 80391351 semi
                MessageBox.Show("하나만 클릭해 주세요");
1311 e6281033 alzkakdixm
            }
1312 472d507b semi
            else if (SelectFilterConvertList.Count() == 0)
1313
            {
1314
                MessageBox.Show("왼쪽 버튼 클릭 후 Validate 해주세요!");
1315
            }
1316 80391351 semi
            else
1317 a6e5055d alzkakdixm
            {
1318 80391351 semi
                bool result = false;
1319
                WebRequest webRequest = WebRequest.Create(SelectFilterConvertList[0].OriginfilePath);
1320
                webRequest.Timeout = 1200; // miliseconds
1321
                webRequest.Method = "HEAD";
1322
1323
                HttpWebResponse response = null;
1324
1325
                try
1326 a6e5055d alzkakdixm
                {
1327 80391351 semi
                    response = (HttpWebResponse)webRequest.GetResponse();
1328
                    result = true;
1329
                }
1330
                catch (WebException webException)
1331
                {
1332
                    MessageBox.Show(SelectFilterConvert.FileName + " doesn't exist: " + webException.Message);
1333
                    result = true;
1334
                }
1335
                finally
1336
                {
1337
                    if (response != null)
1338
                    {
1339
                        response.Close();
1340
                    }
1341
                }
1342
                if (result == true)
1343
                {
1344
                    MessageBox.Show("File exists");
1345 a6e5055d alzkakdixm
                }
1346 2decfbdf alzkakdixm
            }
1347 80391351 semi
1348 e6281033 alzkakdixm
        }
1349
1350
        #endregion
1351
1352 f5ec88b8 semi
        #region Data Delete
1353
1354
        private void DataDelete(object obj)
1355
        {
1356 e6c570d5 semi
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1357
            {
1358
                var result = evt.DialogResult;
1359
1360
                if (result == true)
1361
                {
1362
                    OnClosed(obj);
1363
                }
1364
            };
1365
1366 aaed7be2 semi
            RadWindow.Confirm("Do you want to delete it??", handler);
1367 f5ec88b8 semi
        }
1368
1369 e6c570d5 semi
        private async void OnClosed(object obj)
1370 f5ec88b8 semi
        {
1371 e6c570d5 semi
            if (obj is ConvertPDF)
1372 f5ec88b8 semi
            {
1373 e6c570d5 semi
                if (obj != null)
1374 f5ec88b8 semi
                {
1375 e6c570d5 semi
                    var convertitem = obj as ConvertPDF;
1376 472d507b semi
1377 e6c570d5 semi
                    SelectRealConvert = convertitem;
1378
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1379 472d507b semi
1380 e6c570d5 semi
                }
1381
            }
1382
            else if (SelectFilterConvertList.Count() > 1)
1383
            {
1384
                MessageBox.Show("하나만 클릭해 주세요!");
1385
            }
1386
            else if (SelectFilterConvertList.Count() == 0)
1387
            {
1388
                MessageBox.Show("왼쪽 버튼 클릭 후 Delete 해주세요!");
1389
            }
1390
            else
1391
            {
1392
                if (SelectFilterConvertList != null)
1393
                {
1394
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectFilterConvertList[0].ConvertID);
1395 f5ec88b8 semi
                }
1396
            }
1397
        }
1398
        #endregion
1399
1400
        #region Stop Process
1401
1402
        private void Stop_Process(object obj)
1403
        {
1404 f0ad40d3 semi
1405 b6bc5408 semi
            string convertid = "";
1406
1407 472d507b semi
            if (obj is ConvertPDF)
1408 f5ec88b8 semi
            {
1409 472d507b semi
1410
                if (obj != null)
1411 f0ad40d3 semi
                {
1412 472d507b semi
                    var convertitem = obj as ConvertPDF;
1413
1414
                    SelectRealConvert = convertitem;
1415
1416
                    SelectAliveConvert = convertitem;
1417
1418
                    convertid = convertitem.ConvertID;
1419 b6bc5408 semi
                }
1420 f5ec88b8 semi
            }
1421 472d507b semi
1422
1423
#if DEBUG
1424
            convertid = "TEST";
1425
#endif
1426 b6bc5408 semi
1427
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1428 f5ec88b8 semi
            {
1429 b6bc5408 semi
                var result = evt.DialogResult;
1430 f5ec88b8 semi
1431 b6bc5408 semi
                if (result == true)
1432
                {
1433
                    Stop_Process(convertid);
1434
                }
1435
            };
1436 f5ec88b8 semi
1437 b6bc5408 semi
            RadWindow.Confirm("프로세스 종료 할까요??", handler);
1438 f5ec88b8 semi
        }
1439
1440 fa6a4690 semi
        private async void Stop_Process(string convertId)
1441 f5ec88b8 semi
        {
1442 e6c570d5 semi
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10));
1443 f5ec88b8 semi
1444 b6bc5408 semi
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1445
1446
            for (int i = process.Count() - 1; i >= 0; i--)
1447
            {
1448
                try
1449 c68259ac semi
                {
1450 b6bc5408 semi
                    var commandLines = process[i].Arguments().CommandLine;
1451 e6c570d5 semi
1452 b6bc5408 semi
                    if (commandLines.Count() > 0)
1453
                    {
1454
                        if (commandLines[0] == convertId)
1455 c68259ac semi
                        {
1456 472d507b semi
1457 fa6a4690 semi
                            var _CREATE_DATETIME = DateTime.Now;
1458
1459
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 3, null);
1460 472d507b semi
                            process[i].WaitForExit(5000);
1461
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 99, null);
1462
                            process[i].Kill();
1463 f5ec88b8 semi
                        }
1464 c68259ac semi
                    }
1465 b6bc5408 semi
                }
1466
                catch (Exception ex)
1467
                {
1468
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
1469 f5ec88b8 semi
                }
1470
            }
1471
        }
1472 aaed7be2 semi
        #endregion
1473 f5ec88b8 semi
1474 aaed7be2 semi
        #region DataFilter
1475 b63dcfbb semi
1476
        public void DataFilter(object obj)
1477
        {
1478 aaed7be2 semi
            SearchTimerOn = true;
1479 b63dcfbb semi
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1480 c7955b40 semi
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1481 b63dcfbb semi
        }
1482
1483 aaed7be2 semi
        #endregion
1484
1485
        #region Filter Enter
1486
1487 b63dcfbb semi
1488 aaed7be2 semi
        /// <summary>
1489
        /// 필터된 상단 그리드 엑셀로 출력
1490
        /// </summary>
1491
1492
        public void Enter(object sender)
1493
        {
1494
            SearchTimerOn = true;
1495
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1496
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1497
        }
1498
1499
        #endregion
1500
1501
        #region MarkusLink
1502 e78f0871 alzkakdixm
1503 80391351 semi
        private void MarkusLink(object obj)
1504 e78f0871 alzkakdixm
        {
1505 2f07b70a semi
            if (obj is ConvertPDF)
1506 e78f0871 alzkakdixm
            {
1507 80391351 semi
1508 e78f0871 alzkakdixm
                if (obj != null)
1509
                {
1510 2f07b70a semi
                    var convertitem = obj as ConvertPDF;
1511 e78f0871 alzkakdixm
1512 9b2f01e1 semi
                    SelectFilterConvertList.Add(convertitem);
1513 e78f0871 alzkakdixm
1514
                    SelectRealConvert = convertitem;
1515
1516 6466bd2d semi
                    SelectAliveConvert = convertitem;
1517
1518 e78f0871 alzkakdixm
                    ProcessStartInfo startInfo = null;
1519
1520
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1521
1522
                    Process.Start(startInfo);
1523
                }
1524 80391351 semi
1525 e78f0871 alzkakdixm
            }
1526
        }
1527
1528 aaed7be2 semi
        #endregion
1529 e78f0871 alzkakdixm
1530 aaed7be2 semi
        #region Data Export
1531 e6281033 alzkakdixm
1532
1533
        /// <summary>
1534
        /// 필터된 상단 그리드 엑셀로 출력
1535
        /// </summary>
1536
1537
        public void DataExportData(object obj)
1538
        {
1539 aaed7be2 semi
            if (SearchTimerOn == true)
1540 50b63148 semi
            {
1541
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1542
            }
1543
            else
1544
            {
1545
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1546
            }
1547 e6281033 alzkakdixm
1548 037ab674 semi
            Return_FilterConvertSource(FilterConvertSource);
1549 e6281033 alzkakdixm
1550 037ab674 semi
            Views.ConvertExcelDialog convertExcelDialog = new Views.ConvertExcelDialog();
1551 e6281033 alzkakdixm
1552 19d6b221 semi
            convertExcelDialog.Owner = Application.Current.MainWindow;
1553 037ab674 semi
            convertExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1554 e6281033 alzkakdixm
1555 037ab674 semi
            convertExcelDialog.ShowDialog();
1556 e6281033 alzkakdixm
1557 50b63148 semi
            if (SearchTimerOn == true)
1558
            {
1559
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1560
            }
1561
            else
1562
            {
1563
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1564
            }
1565 2decfbdf alzkakdixm
        }
1566 e6281033 alzkakdixm
1567 aaed7be2 semi
        #endregion
1568 e6281033 alzkakdixm
1569 aaed7be2 semi
        #region Data Search
1570 902f397c semi
1571 b63dcfbb semi
        public void RemoveCreateTimeFilter(object obj)
1572
        {
1573 95e7bd84 semi
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1574 b63dcfbb semi
            SelectedCreateTimeBegin = DefaultCreateTime;
1575
            SelectedCreateTimeEnd = DefaultCreateTime;
1576
        }
1577
1578 aaed7be2 semi
        #endregion
1579 b63dcfbb semi
1580 aaed7be2 semi
        #region Reset
1581 b63dcfbb semi
1582
        /// <summary>
1583
        /// 그리드 상단 원상복귀 버튼
1584
        /// 필터를 끝낸 후 다시 복귀
1585
        /// </summary>
1586
1587
        public void Reset(object obj)
1588 5a954acc semi
        {
1589 50b63148 semi
            SearchTimerOn = false;
1590 93f5e32a semi
            ExcptionCheck = false;
1591 037ab674 semi
            SelectedInt = 10;
1592
            ProjectNumberFilter = ProjectNames[0];
1593 3bde451b semi
            UniqueKeyFilter = null;
1594
            Service_IDFilter = null;
1595
            Document_NameFilter = null;
1596
            Docuemnt_NOFilter = null;
1597
            ReconverterFilter = null;
1598
            RevisionFilter = null;
1599
            GroupNOFilter = null;
1600 30680747 semi
            DOCUMENT_URLFilter = null;
1601 95e7bd84 semi
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1602 3bde451b semi
            SelectedCreateTimeBegin = DefaultCreateTime;
1603
            SelectedCreateTimeEnd = DefaultCreateTime;
1604 c7955b40 semi
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1605 b63dcfbb semi
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1606 5a954acc semi
        }
1607
1608 aaed7be2 semi
        #endregion
1609 902f397c semi
1610 aaed7be2 semi
        #region ConvertAddDialog
1611 218e5002 semi
1612
        /// <summary>
1613
        /// 그리드 상단 Conver 추가 버튼
1614
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1615
        /// </summary>
1616
1617 037ab674 semi
        public void ConvertAdd(object obj)
1618 218e5002 semi
        {
1619 95e7bd84 semi
            try
1620 50b63148 semi
            {
1621 95e7bd84 semi
                if (SearchTimerOn == true)
1622
                {
1623
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1624
                }
1625
                else
1626
                {
1627
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1628
                }
1629 43b2e236 semi
1630 95e7bd84 semi
                Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1631 8c128693 semi
1632 95e7bd84 semi
                convertAddDialog.Owner = Application.Current.MainWindow;
1633
                convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1634 3bde451b semi
1635 95e7bd84 semi
                convertAddDialog.ShowDialog();
1636 218e5002 semi
1637 95e7bd84 semi
                if (SearchTimerOn == true)
1638
                {
1639
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1640
                }
1641
                else
1642
                {
1643
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1644
                }
1645 50b63148 semi
            }
1646 aaed7be2 semi
            catch (Exception ex)
1647 50b63148 semi
            {
1648 95e7bd84 semi
                MessageBox.Show(ex.ToString());
1649 50b63148 semi
            }
1650 218e5002 semi
        }
1651
1652 aaed7be2 semi
        #endregion
1653 218e5002 semi
1654 aaed7be2 semi
        #region ConvertPathFileSearch
1655 78683624 semi
1656
        /// <summary>
1657
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1658
        /// </summary>
1659
1660
        public void ConvertPathFileSearch(object obj)
1661
        {
1662 2f07b70a semi
            if (obj is ConvertPDF)
1663 78683624 semi
            {
1664
                if (obj != null)
1665
                {
1666 2f07b70a semi
                    var convertitem = obj as ConvertPDF;
1667 78683624 semi
1668 cab4a0e1 semi
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
1669
                    {
1670
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
1671
                    }
1672 78683624 semi
                }
1673
            }
1674
        }
1675
1676 aaed7be2 semi
        #endregion
1677 78683624 semi
1678 aaed7be2 semi
        #endregion
1679 a6e5055d alzkakdixm
    }
1680
}
클립보드 이미지 추가 (최대 크기: 500 MB)