프로젝트

일반

사용자정보

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

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

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