프로젝트

일반

사용자정보

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

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

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

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