프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (55 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 f0ad40d3 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 f0ad40d3 semi
596 50b63148 semi
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 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)
750
                                          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 b6bc5408 semi
                            if (items.Count() > 0)
981
                            {
982
                                AliveShow = true;
983
                            }
984
985 3bde451b semi
                            foreach (var item in items)
986
                            {
987 2f07b70a semi
                                ConvertPDF itemsToEach = new ConvertPDF();
988 3bde451b semi
                                itemsToEach.ServiceID = item.ServiceID;
989
                                itemsToEach.ConvertID = item.ConvertID;
990
                                itemsToEach.ProjectNumber = item.ProjectNumber;
991 8c128693 semi
992 ee910e7f semi
                                var MarkusLink = "kcom://" + CreateMarkusParam(item.ProjectNumber, item.DocumentID, "doftech");
993 8c128693 semi
994 3bde451b semi
                                if (item.ConvertState != null)
995
                                {
996
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
997 e6281033 alzkakdixm
                                }
998
999 3bde451b semi
                                if (item.OriginfilePath.Contains("/"))
1000
                                {
1001
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1002
                                }
1003
                                else
1004 8c128693 semi
                                {
1005 3bde451b semi
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1006 8c128693 semi
                                }
1007 3bde451b semi
                                itemsToEach.FileName = result;
1008
1009
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
1010
                                itemsToEach.TotalPage = item.TotalPage;
1011
                                itemsToEach.OriginfilePath = item.OriginfilePath;
1012
                                itemsToEach.ConvertPath = item.ConvertPath;
1013 ee910e7f semi
                                itemsToEach.MarkusLink = MarkusLink;
1014 cb806a91 semi
                                itemsToEach.UniqueKey = item.UniqueKey;
1015
                                itemsToEach.GroupNo = item.GroupNo;
1016 5feff9f0 semi
                                itemsToEach.DocumentName = item.DocumnetName;
1017 f0ad40d3 semi
                                itemsToEach.Revision = item.Revision;
1018 cb806a91 semi
                                itemsToEach.Exception = item.Exception;
1019 ee910e7f semi
                                itemsToEach.ConvertPath = item.ConvertPath;
1020 3bde451b semi
                                itemsToEach.CreateTime = item.CreateTime;
1021
                                itemsToEach.ReConverter = item.ReConverter;
1022
                                itemsToEach.DocumentID = item.DocumentID;
1023
                                itemsToEach.StartTime = item.StartTime;
1024
                                itemsToEach.EndTime = item.EndTime;
1025
1026
                                itemsToList.Add(itemsToEach);
1027 e6281033 alzkakdixm
                            }
1028 3bde451b semi
                            newitems.AddRange(itemsToList);
1029
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1030
1031
                            if (items.Count() == 0)
1032 e6281033 alzkakdixm
                            {
1033 3bde451b semi
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1034 e6281033 alzkakdixm
                            }
1035
                        }
1036 3bde451b semi
                        catch (Exception ex)
1037 e6281033 alzkakdixm
                        {
1038 3bde451b semi
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1039 e6281033 alzkakdixm
                        }
1040
                    }
1041 3bde451b semi
                    else
1042
                    {
1043
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1044
                    }
1045
1046 e6281033 alzkakdixm
                }
1047
                ItemsUpdate(newitems);
1048
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1049
            }
1050
            catch (Exception ex)
1051
            {
1052
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1053 a6e5055d alzkakdixm
            }
1054
        }
1055
1056 e6281033 alzkakdixm
        /// <summary>
1057
        /// AliveDataSelect의 Data Update
1058
        /// </summary>
1059
        /// <param name="newitems"></param>
1060 2f07b70a semi
        private void ItemsUpdate(List<ConvertPDF> newitems)
1061 a6e5055d alzkakdixm
        {
1062
1063 e6281033 alzkakdixm
            foreach (var item in newitems)
1064
            {
1065
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1066
            }
1067
1068
            if (AliveItems == null)
1069
            {
1070 2f07b70a semi
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
1071 e6281033 alzkakdixm
1072
                foreach (var item in newitems)
1073
                {
1074
                    AliveItems.Add(item);
1075
                }
1076
            }
1077
            else
1078 a6e5055d alzkakdixm
            {
1079 e6281033 alzkakdixm
                newitems.ForEach(newitem =>
1080
                {
1081
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1082
                });
1083
1084
                foreach (var item in newitems)
1085
                {
1086
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1087
                    {
1088
                        AliveItems.Add(item);
1089
                    }
1090
                }
1091 a6e5055d alzkakdixm
1092 e6281033 alzkakdixm
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1093
                {
1094
                    var item = AliveItems[i];
1095 a6e5055d alzkakdixm
1096 e6281033 alzkakdixm
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1097
                    {
1098
                        try
1099
                        {
1100
                            AliveItems.RemoveAt(i);
1101
                        }
1102
                        catch (Exception ex)
1103
                        {
1104
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1105
                        }
1106
                    }
1107
                }
1108 2decfbdf alzkakdixm
            }
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 472d507b semi
            if (obj is ConvertPDF)
1152
            {
1153
1154
                if (obj != null)
1155
                {
1156
                    var convertitem = obj as ConvertPDF;
1157
1158
                    SelectRealConvert = convertitem;
1159
                    SetCleanUpItem(SelectRealConvert);
1160
1161
1162
                    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)
1163
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1164
                                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
1165
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1166
1167
                    foreach (var item in items)
1168
                    {
1169
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1170
                        {
1171
                            RealConvertSource.Add(item);
1172
                        }
1173
                        if (RealConvertSource.Count() == 1)
1174
                        {
1175
                            ConvertShow = true;
1176
                        }
1177
                    }
1178
                }
1179
            }
1180
            else if (SelectFilterConvertList == null)
1181 e6281033 alzkakdixm
            {
1182
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1183
            }
1184
            else
1185 a6e5055d alzkakdixm
            {
1186 80391351 semi
                if (SelectFilterConvertList != null)
1187 a6e5055d alzkakdixm
                {
1188 80391351 semi
                    foreach (var SelectFilterConvert in SelectFilterConvertList)
1189
                    {
1190 59a29a3b semi
                        SetCleanUpItem(SelectFilterConvert);
1191 80391351 semi
                    }
1192 e6281033 alzkakdixm
                }
1193 3bde451b semi
1194 037ab674 semi
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1195
                {
1196 3bde451b semi
1197 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)
1198
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1199
                                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
1200
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1201 3bde451b semi
1202 037ab674 semi
                    foreach (var item in items)
1203
                    {
1204 b6bc5408 semi
                        if (RealConvertSource.Count(x => x.ConvertID == item.ConvertID) < 1)
1205
                        {
1206
                            RealConvertSource.Add(item);
1207
                        }
1208 037ab674 semi
                        if (RealConvertSource.Count() == 1)
1209
                        {
1210
                            ConvertShow = true;
1211 3bde451b semi
                        }
1212 8c7d1ea1 alzkakdixm
                    }
1213 a6e5055d alzkakdixm
                }
1214 3bde451b semi
            }
1215
        }
1216
1217
1218 59a29a3b semi
        public async void SetCleanUpItem(ConvertPDF _ConvertItem)
1219 3bde451b semi
        {
1220 f0ad40d3 semi
1221 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);
1222 f0ad40d3 semi
1223 037ab674 semi
            if (items.Count() > 0)
1224
            {
1225
                var item = items.First();
1226 3bde451b semi
1227 037ab674 semi
                var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
1228
                var _CREATE_DATETIME = DateTime.Now;
1229
                var _STATUS = (int)StatusCodeType.None;
1230 3bde451b semi
1231 cb806a91 semi
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null);
1232 3bde451b semi
            }
1233
        }
1234
1235 e6281033 alzkakdixm
1236 2c634aed semi
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1237
        {
1238
            ViewInfo viewInfo = new ViewInfo();
1239
1240
            viewInfo.DocumentItemID = documentID;
1241
            viewInfo.ProjectNO = projectNo;
1242
            viewInfo.UserID = userID;
1243
1244
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1245
1246
        }
1247
1248
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1249
        {
1250
1251
            if (oEncoding == null)
1252
                oEncoding = System.Text.Encoding.UTF8;
1253
1254
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1255
1256
        }
1257
1258 e6281033 alzkakdixm
1259 3bde451b semi
        #endregion
1260
1261 e6281033 alzkakdixm
        #region Validation
1262 a6e5055d alzkakdixm
1263 e6281033 alzkakdixm
        private void DataValidate(object obj)
1264
        {
1265 472d507b semi
            if (obj is ConvertPDF)
1266
            {
1267
1268
                if (obj != null)
1269
                {
1270
                    var convertitem = obj as ConvertPDF;
1271
1272
                    SelectRealConvert = convertitem;
1273
1274
                    bool result = false;
1275
                    WebRequest webRequest = WebRequest.Create(SelectRealConvert.OriginfilePath);
1276
                    webRequest.Timeout = 1200; // miliseconds
1277
                    webRequest.Method = "HEAD";
1278
1279
                    HttpWebResponse response = null;
1280
1281
                    try
1282
                    {
1283
                        response = (HttpWebResponse)webRequest.GetResponse();
1284
                        result = true;
1285
                    }
1286
                    catch (WebException webException)
1287
                    {
1288
                        MessageBox.Show(SelectRealConvert.FileName + " doesn't exist: " + webException.Message);
1289
                        result = true;
1290
                    }
1291
                    finally
1292
                    {
1293
                        if (response != null)
1294
                        {
1295
                            response.Close();
1296
                        }
1297
                    }
1298
                    if (result == true)
1299
                    {
1300
                        MessageBox.Show("File exists");
1301
                    }
1302
                }
1303
            }
1304
            else if (SelectFilterConvertList.Count() > 1)
1305 e6281033 alzkakdixm
            {
1306 80391351 semi
                MessageBox.Show("하나만 클릭해 주세요");
1307 e6281033 alzkakdixm
            }
1308 472d507b semi
            else if (SelectFilterConvertList.Count() == 0)
1309
            {
1310
                MessageBox.Show("왼쪽 버튼 클릭 후 Validate 해주세요!");
1311
            }
1312 80391351 semi
            else
1313 a6e5055d alzkakdixm
            {
1314 80391351 semi
                bool result = false;
1315
                WebRequest webRequest = WebRequest.Create(SelectFilterConvertList[0].OriginfilePath);
1316
                webRequest.Timeout = 1200; // miliseconds
1317
                webRequest.Method = "HEAD";
1318
1319
                HttpWebResponse response = null;
1320
1321
                try
1322 a6e5055d alzkakdixm
                {
1323 80391351 semi
                    response = (HttpWebResponse)webRequest.GetResponse();
1324
                    result = true;
1325
                }
1326
                catch (WebException webException)
1327
                {
1328
                    MessageBox.Show(SelectFilterConvert.FileName + " doesn't exist: " + webException.Message);
1329
                    result = true;
1330
                }
1331
                finally
1332
                {
1333
                    if (response != null)
1334
                    {
1335
                        response.Close();
1336
                    }
1337
                }
1338
                if (result == true)
1339
                {
1340
                    MessageBox.Show("File exists");
1341 a6e5055d alzkakdixm
                }
1342 2decfbdf alzkakdixm
            }
1343 80391351 semi
1344 e6281033 alzkakdixm
        }
1345
1346
        #endregion
1347
1348 f5ec88b8 semi
        #region Data Delete
1349
1350
        private void DataDelete(object obj)
1351
        {
1352 e6c570d5 semi
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1353
            {
1354
                var result = evt.DialogResult;
1355
1356
                if (result == true)
1357
                {
1358
                    OnClosed(obj);
1359
                }
1360
            };
1361
1362
            RadWindow.Confirm("Do you want to delete it??",  handler);
1363 f5ec88b8 semi
        }
1364
1365 e6c570d5 semi
        private async void OnClosed(object obj)
1366 f5ec88b8 semi
        {
1367 e6c570d5 semi
            if (obj is ConvertPDF)
1368 f5ec88b8 semi
            {
1369 e6c570d5 semi
                if (obj != null)
1370 f5ec88b8 semi
                {
1371 e6c570d5 semi
                    var convertitem = obj as ConvertPDF;
1372 472d507b semi
1373 e6c570d5 semi
                    SelectRealConvert = convertitem;
1374
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1375 472d507b semi
1376 e6c570d5 semi
                }
1377
            }
1378
            else if (SelectFilterConvertList.Count() > 1)
1379
            {
1380
                MessageBox.Show("하나만 클릭해 주세요!");
1381
            }
1382
            else if (SelectFilterConvertList.Count() == 0)
1383
            {
1384
                MessageBox.Show("왼쪽 버튼 클릭 후 Delete 해주세요!");
1385
            }
1386
            else
1387
            {
1388
                if (SelectFilterConvertList != null)
1389
                {
1390
                    await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectFilterConvertList[0].ConvertID);
1391 f5ec88b8 semi
                }
1392
            }
1393
        }
1394
        #endregion
1395
1396
        #region Stop Process
1397
1398
        private void Stop_Process(object obj)
1399
        {
1400 f0ad40d3 semi
1401 b6bc5408 semi
            string convertid = "";
1402
1403 472d507b semi
            if (obj is ConvertPDF)
1404 f5ec88b8 semi
            {
1405 472d507b semi
1406
                if (obj != null)
1407 f0ad40d3 semi
                {
1408 472d507b semi
                    var convertitem = obj as ConvertPDF;
1409
1410
                    SelectRealConvert = convertitem;
1411
1412
                    SelectAliveConvert = convertitem;
1413
1414
                    convertid = convertitem.ConvertID;
1415 b6bc5408 semi
                }
1416 f5ec88b8 semi
            }
1417 472d507b semi
1418
1419
#if DEBUG
1420
            convertid = "TEST";
1421
#endif
1422 b6bc5408 semi
1423
            EventHandler<WindowClosedEventArgs> handler = (snd, evt) =>
1424 f5ec88b8 semi
            {
1425 b6bc5408 semi
                var result = evt.DialogResult;
1426 f5ec88b8 semi
1427 b6bc5408 semi
                if (result == true)
1428
                {
1429
                    Stop_Process(convertid);
1430
                }
1431
            };
1432 f5ec88b8 semi
1433 b6bc5408 semi
            RadWindow.Confirm("프로세스 종료 할까요??", handler);
1434 f5ec88b8 semi
        }
1435
1436 fa6a4690 semi
        private async void Stop_Process(string convertId)
1437 f5ec88b8 semi
        {
1438 e6c570d5 semi
            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10));
1439 f5ec88b8 semi
1440 b6bc5408 semi
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
1441
1442
            for (int i = process.Count() - 1; i >= 0; i--)
1443
            {
1444
                try
1445 c68259ac semi
                {
1446 b6bc5408 semi
                    var commandLines = process[i].Arguments().CommandLine;
1447 e6c570d5 semi
1448 b6bc5408 semi
                    if (commandLines.Count() > 0)
1449
                    {
1450
                        if (commandLines[0] == convertId)
1451 c68259ac semi
                        {
1452 472d507b semi
1453 fa6a4690 semi
                            var _CREATE_DATETIME = DateTime.Now;
1454
1455
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 3, null);
1456 472d507b semi
                            process[i].WaitForExit(5000);
1457
                            await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(convertId, 2, _CREATE_DATETIME, 99, null);
1458
                            process[i].Kill();
1459 f5ec88b8 semi
                        }
1460 c68259ac semi
                    }
1461 b6bc5408 semi
                }
1462
                catch (Exception ex)
1463
                {
1464
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
1465 f5ec88b8 semi
                }
1466
            }
1467
        }
1468 472d507b semi
#endregion
1469 f5ec88b8 semi
1470 472d507b semi
#region DataFilter
1471 b63dcfbb semi
1472
        public void DataFilter(object obj)
1473
        {
1474 50b63148 semi
            SearchTimerOn = true; 
1475 b63dcfbb semi
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1476 c7955b40 semi
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1477 b63dcfbb semi
        }
1478
1479 b6bc5408 semi
#endregion
1480 b63dcfbb semi
1481 b6bc5408 semi
#region MarkusLink
1482 e78f0871 alzkakdixm
1483 80391351 semi
        private void MarkusLink(object obj)
1484 e78f0871 alzkakdixm
        {
1485 2f07b70a semi
            if (obj is ConvertPDF)
1486 e78f0871 alzkakdixm
            {
1487 80391351 semi
1488 e78f0871 alzkakdixm
                if (obj != null)
1489
                {
1490 2f07b70a semi
                    var convertitem = obj as ConvertPDF;
1491 e78f0871 alzkakdixm
1492 9b2f01e1 semi
                    SelectFilterConvertList.Add(convertitem);
1493 e78f0871 alzkakdixm
1494
                    SelectRealConvert = convertitem;
1495
1496 6466bd2d semi
                    SelectAliveConvert = convertitem;
1497
1498 e78f0871 alzkakdixm
                    ProcessStartInfo startInfo = null;
1499
1500
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1501
1502
                    Process.Start(startInfo);
1503
                }
1504 80391351 semi
1505 e78f0871 alzkakdixm
            }
1506
        }
1507
1508 b6bc5408 semi
#endregion
1509 e78f0871 alzkakdixm
1510 b6bc5408 semi
#region Data Export
1511 e6281033 alzkakdixm
1512
1513
        /// <summary>
1514
        /// 필터된 상단 그리드 엑셀로 출력
1515
        /// </summary>
1516
1517
        public void DataExportData(object obj)
1518
        {
1519 50b63148 semi
            if(SearchTimerOn == true)
1520
            {
1521
                dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1522
            }
1523
            else
1524
            {
1525
                dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1526
            }
1527 e6281033 alzkakdixm
1528 037ab674 semi
            Return_FilterConvertSource(FilterConvertSource);
1529 e6281033 alzkakdixm
1530 037ab674 semi
            Views.ConvertExcelDialog convertExcelDialog = new Views.ConvertExcelDialog();
1531 e6281033 alzkakdixm
1532 19d6b221 semi
            convertExcelDialog.Owner = Application.Current.MainWindow;
1533 037ab674 semi
            convertExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1534 e6281033 alzkakdixm
1535 037ab674 semi
            convertExcelDialog.ShowDialog();
1536 e6281033 alzkakdixm
1537 50b63148 semi
            if (SearchTimerOn == true)
1538
            {
1539
                dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1540
            }
1541
            else
1542
            {
1543
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1544
            }
1545 2decfbdf alzkakdixm
        }
1546 e6281033 alzkakdixm
1547 b6bc5408 semi
#endregion
1548 e6281033 alzkakdixm
1549 b6bc5408 semi
#region Data Search
1550 902f397c semi
1551 b63dcfbb semi
        public void RemoveCreateTimeFilter(object obj)
1552
        {
1553 95e7bd84 semi
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1554 b63dcfbb semi
            SelectedCreateTimeBegin = DefaultCreateTime;
1555
            SelectedCreateTimeEnd = DefaultCreateTime;
1556
        }
1557
1558 b6bc5408 semi
#endregion
1559 b63dcfbb semi
1560 b6bc5408 semi
#region Reset
1561 b63dcfbb semi
1562
        /// <summary>
1563
        /// 그리드 상단 원상복귀 버튼
1564
        /// 필터를 끝낸 후 다시 복귀
1565
        /// </summary>
1566
1567
        public void Reset(object obj)
1568 5a954acc semi
        {
1569 50b63148 semi
            SearchTimerOn = false;
1570 93f5e32a semi
            ExcptionCheck = false;
1571 037ab674 semi
            SelectedInt = 10;
1572
            ProjectNumberFilter = ProjectNames[0];
1573 3bde451b semi
            UniqueKeyFilter = null;
1574
            Service_IDFilter = null;
1575
            Document_NameFilter = null;
1576
            Docuemnt_NOFilter = null;
1577
            ReconverterFilter = null;
1578
            RevisionFilter = null;
1579
            GroupNOFilter = null;
1580 30680747 semi
            DOCUMENT_URLFilter = null;
1581 95e7bd84 semi
            DefaultCreateTime = DateTime.Now.AddHours(-1);
1582 3bde451b semi
            SelectedCreateTimeBegin = DefaultCreateTime;
1583
            SelectedCreateTimeEnd = DefaultCreateTime;
1584 c7955b40 semi
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1585 b63dcfbb semi
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1586 5a954acc semi
        }
1587
1588 b6bc5408 semi
#endregion
1589 902f397c semi
1590 b6bc5408 semi
#region ConvertAddDialog
1591 218e5002 semi
1592
        /// <summary>
1593
        /// 그리드 상단 Conver 추가 버튼
1594
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1595
        /// </summary>
1596
1597 037ab674 semi
        public void ConvertAdd(object obj)
1598 218e5002 semi
        {
1599 95e7bd84 semi
            try
1600 50b63148 semi
            {
1601 95e7bd84 semi
                if (SearchTimerOn == true)
1602
                {
1603
                    dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1604
                }
1605
                else
1606
                {
1607
                    dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1608
                }
1609 43b2e236 semi
1610 95e7bd84 semi
                Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1611 8c128693 semi
1612 95e7bd84 semi
                convertAddDialog.Owner = Application.Current.MainWindow;
1613
                convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1614 3bde451b semi
1615 95e7bd84 semi
                convertAddDialog.ShowDialog();
1616 218e5002 semi
1617 95e7bd84 semi
                if (SearchTimerOn == true)
1618
                {
1619
                    dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1620
                }
1621
                else
1622
                {
1623
                    dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1624
                }
1625 50b63148 semi
            }
1626 95e7bd84 semi
            catch(Exception ex)
1627 50b63148 semi
            {
1628 95e7bd84 semi
                MessageBox.Show(ex.ToString());
1629 50b63148 semi
            }
1630 218e5002 semi
        }
1631
1632 b6bc5408 semi
#endregion
1633 218e5002 semi
1634 b6bc5408 semi
#region ConvertPathFileSearch
1635 78683624 semi
1636
        /// <summary>
1637
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1638
        /// </summary>
1639
1640
        public void ConvertPathFileSearch(object obj)
1641
        {
1642 2f07b70a semi
            if (obj is ConvertPDF)
1643 78683624 semi
            {
1644
                if (obj != null)
1645
                {
1646 2f07b70a semi
                    var convertitem = obj as ConvertPDF;
1647 78683624 semi
1648 cab4a0e1 semi
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
1649
                    {
1650
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
1651
                    }
1652 78683624 semi
                }
1653
            }
1654
        }
1655
1656 b6bc5408 semi
#endregion
1657 78683624 semi
1658 b6bc5408 semi
#endregion
1659 a6e5055d alzkakdixm
    }
1660
}
클립보드 이미지 추가 (최대 크기: 500 MB)