프로젝트

일반

사용자정보

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

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

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