프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (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 93f5e32a semi
757 037ab674 semi
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
758 2decfbdf alzkakdixm
                    {
759 037ab674 semi
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
760
                        ProjectNames.Add(projectName);
761 2decfbdf alzkakdixm
                    }
762 037ab674 semi
                }
763
764
                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)
765
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
766
                                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,
767 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);
768 2decfbdf alzkakdixm
769 037ab674 semi
                if (collection.Count() == 0)
770
                {
771
                    if (statusCodeTypeList.Count() == 1)
772 3bde451b semi
                    {
773 037ab674 semi
                        //Listitems.ForEach(x => collection.Add(x));
774
                        foreach (var Listitem in Listitems.ToList())
775 e139272d semi
                        {
776 037ab674 semi
                            collection.Add(Listitem);
777 e139272d semi
                        }
778 3bde451b semi
                    }
779 037ab674 semi
                }
780
                else
781
                {
782
                    foreach (var Listitem in Listitems)
783 a6e5055d alzkakdixm
                    {
784 037ab674 semi
                        collection.UpdateWhere(changeitem =>
785
                        ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID);
786 a6e5055d alzkakdixm
                    }
787 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
788 a6e5055d alzkakdixm
                    {
789 037ab674 semi
                        for (int i = collection.Count() - 1; i >= 0; --i)
790 a6e5055d alzkakdixm
                        {
791 037ab674 semi
                            var item = collection[i];
792 a6e5055d alzkakdixm
793 037ab674 semi
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
794
                            {
795
                                collection.RemoveAt(i);
796 2decfbdf alzkakdixm
                            }
797 a6e5055d alzkakdixm
                        }
798 037ab674 semi
                    }
799 a6e5055d alzkakdixm
800 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
801
                    {
802
                        foreach (var item in Listitems)
803 a6e5055d alzkakdixm
                        {
804 037ab674 semi
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
805 2decfbdf alzkakdixm
                            {
806 037ab674 semi
                                for (int i = 0; i < 200; i++)
807 2decfbdf alzkakdixm
                                {
808 037ab674 semi
                                    if (i < collection.Count() - 1)
809 2decfbdf alzkakdixm
                                    {
810 037ab674 semi
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
811 2decfbdf alzkakdixm
                                        {
812 037ab674 semi
                                            collection.Insert(i, item);
813 2decfbdf alzkakdixm
                                            break;
814
                                        }
815
                                    }
816 037ab674 semi
                                    else
817
                                    {
818
                                        collection.Add(item);
819
                                        break;
820
                                    }
821 2decfbdf alzkakdixm
                                }
822 a6e5055d alzkakdixm
823
                            }
824 2decfbdf alzkakdixm
825 037ab674 semi
                        }
826 a6e5055d alzkakdixm
                    }
827
                }
828
            }
829
            catch (Exception ex)
830
            {
831 31beca73 semi
                MessageBox.Show(ex.ToString());
832
                //System.Diagnostics.Debug.WriteLine(ex.ToString());
833 a6e5055d alzkakdixm
            }
834
        }
835
836 037ab674 semi
        private async void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection)
837 b63dcfbb semi
        {
838
            try
839
            {
840 037ab674 semi
                int _status = 0;
841
                if (SelectedStatus != null)
842 b63dcfbb semi
                {
843 037ab674 semi
                    _status = (int)SelectedStatus.Value;
844
                }
845 b63dcfbb semi
846 037ab674 semi
                //DocumentID = unikey
847
                DateTime? Start_CreateTime = null;
848
                DateTime? Finish_CreateTime = null;
849
                if (SelectedCreateTimeBegin != DefaultCreateTime)
850
                {
851
                    Start_CreateTime = SelectedCreateTimeBegin;
852
                }
853
                if (SelectedCreateTimeEnd != DefaultCreateTime)
854
                {
855
                    Finish_CreateTime = SelectedCreateTimeEnd;
856
                }
857 b63dcfbb semi
858 037ab674 semi
                if (ProjectNames.Count() == 0)
859
                {
860
                    foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0))
861 3bde451b semi
                    {
862 037ab674 semi
                        ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME);
863
                        ProjectNames.Add(projectName);
864 3bde451b semi
                    }
865 037ab674 semi
                }
866 218e5002 semi
867 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,
868
            null, null, null, GroupNOFilter, Document_NameFilter, Docuemnt_NOFilter, RevisionFilter, Service_IDFilter, ReconverterFilter, DOCUMENT_URLFilter, ExcptionCheck)
869
                                let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech")
870
                                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,
871
           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);
872 e139272d semi
873 037ab674 semi
                if (collection.Count() == 0)
874
                {
875
                    if (statusCodeTypeList.Count() == 1)
876 3bde451b semi
                    {
877 037ab674 semi
                        foreach (var x in Listitems)
878 b63dcfbb semi
                        {
879 037ab674 semi
                            collection.Add(x);
880 b63dcfbb semi
                        }
881 3bde451b semi
                    }
882 037ab674 semi
                }
883
                else
884
                {
885
886
                    ////세미 업데이트
887
                    foreach (var newitem in Listitems)
888 3bde451b semi
                    {
889 037ab674 semi
                        collection.UpdateWhere(changeitem =>
890
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
891
                    }
892 3bde451b semi
893 b63dcfbb semi
894 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
895
                    {
896 b63dcfbb semi
897 037ab674 semi
                        //삭제
898
                        for (int i = collection.Count() - 1; i >= 0; --i)
899 3bde451b semi
                        {
900 037ab674 semi
                            var item = collection[i];
901 b63dcfbb semi
902 037ab674 semi
                            if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
903 b63dcfbb semi
                            {
904 037ab674 semi
                                collection.RemoveAt(i);
905 b63dcfbb semi
                            }
906 3bde451b semi
                        }
907 037ab674 semi
                    }
908 b63dcfbb semi
909 037ab674 semi
                    if (statusCodeTypeList.Count() == 1)
910
                    {
911
                        //추가 convert 후 추가됨
912
                        foreach (var item in Listitems)
913 3bde451b semi
                        {
914 037ab674 semi
                            if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
915 b63dcfbb semi
                            {
916 037ab674 semi
                                for (int i = 0; i < 200; i++)
917 b63dcfbb semi
                                {
918 037ab674 semi
                                    if (i < collection.Count() - 1)
919 b63dcfbb semi
                                    {
920 037ab674 semi
                                        if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
921 3bde451b semi
                                        {
922 037ab674 semi
                                            collection.Insert(i, item);
923 3bde451b semi
                                            break;
924
                                        }
925 b63dcfbb semi
                                    }
926 037ab674 semi
                                    else
927
                                    {
928
                                        collection.Add(item);
929
                                        break;
930
                                    }
931 b63dcfbb semi
                                }
932 3bde451b semi
                            }
933 218e5002 semi
                        }
934 b63dcfbb semi
                    }
935
                }
936
            }
937
            catch (Exception ex)
938
            {
939 31beca73 semi
                MessageBox.Show(ex.ToString());
940
                //System.Diagnostics.Debug.WriteLine(ex.ToString());
941 b63dcfbb semi
            }
942
        }
943 e6281033 alzkakdixm
        /// <summary>
944
        /// 서비스의 실시간 컨버터 Item
945
        /// </summary>
946
        private async void AliveDataSelect()
947 a6e5055d alzkakdixm
        {
948 e6281033 alzkakdixm
            try
949 a6e5055d alzkakdixm
            {
950 2f07b70a semi
                List<ConvertPDF> newitems = new List<ConvertPDF>();
951 3bde451b semi
                foreach (var client in App.StationClientList)
952 e6281033 alzkakdixm
                {
953 3bde451b semi
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
954 e6281033 alzkakdixm
                    {
955 3bde451b semi
                        try
956 e6281033 alzkakdixm
                        {
957 2f07b70a semi
                            List<ConvertPDF> itemsToList = new List<ConvertPDF>();
958 3bde451b semi
                            var items = await client.AliveConvertListAsync();
959
                            string result = "";
960 8c128693 semi
961 3bde451b semi
                            foreach (var item in items)
962
                            {
963 2f07b70a semi
                                ConvertPDF itemsToEach = new ConvertPDF();
964 3bde451b semi
                                itemsToEach.ServiceID = item.ServiceID;
965
                                itemsToEach.ConvertID = item.ConvertID;
966
                                itemsToEach.ProjectNumber = item.ProjectNumber;
967 8c128693 semi
968 ee910e7f semi
                                var MarkusLink = "kcom://" + CreateMarkusParam(item.ProjectNumber, item.DocumentID, "doftech");
969 8c128693 semi
970 3bde451b semi
                                if (item.ConvertState != null)
971
                                {
972
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
973 e6281033 alzkakdixm
                                }
974
975 3bde451b semi
                                if (item.OriginfilePath.Contains("/"))
976
                                {
977
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
978
                                }
979
                                else
980 8c128693 semi
                                {
981 3bde451b semi
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
982 8c128693 semi
                                }
983 3bde451b semi
                                itemsToEach.FileName = result;
984
985
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
986
                                itemsToEach.TotalPage = item.TotalPage;
987
                                itemsToEach.OriginfilePath = item.OriginfilePath;
988
                                itemsToEach.ConvertPath = item.ConvertPath;
989 ee910e7f semi
                                itemsToEach.MarkusLink = MarkusLink;
990 3bde451b semi
                                itemsToEach.UniqueKey = item.UniqueKey;//DocumentNO 없음
991
                                itemsToEach.GroupNo = item.GroupNo;//없음 
992 78683624 semi
                                //itemsToEach.ProcessorAffinity = item.ProcessorAffinity;
993 5feff9f0 semi
                                itemsToEach.DocumentName = item.DocumnetName;
994 ee910e7f semi
                                itemsToEach.Revision = item.Revision; //없음 
995 3bde451b semi
                                itemsToEach.Exception = item.Exception;//없음
996 ee910e7f semi
                                itemsToEach.ConvertPath = item.ConvertPath;
997 3bde451b semi
                                itemsToEach.CreateTime = item.CreateTime;
998
                                itemsToEach.ReConverter = item.ReConverter;
999
                                itemsToEach.DocumentID = item.DocumentID;
1000
                                itemsToEach.StartTime = item.StartTime;
1001
                                itemsToEach.EndTime = item.EndTime;
1002
1003
                                itemsToList.Add(itemsToEach);
1004 e6281033 alzkakdixm
                            }
1005 3bde451b semi
                            newitems.AddRange(itemsToList);
1006
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1007
1008
                            if (items.Count() == 0)
1009 e6281033 alzkakdixm
                            {
1010 3bde451b semi
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1011 e6281033 alzkakdixm
                            }
1012
                        }
1013 3bde451b semi
                        catch (Exception ex)
1014 e6281033 alzkakdixm
                        {
1015 3bde451b semi
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1016 e6281033 alzkakdixm
                        }
1017
                    }
1018 3bde451b semi
                    else
1019
                    {
1020
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1021
                    }
1022
1023 e6281033 alzkakdixm
                }
1024
                ItemsUpdate(newitems);
1025
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1026
            }
1027
            catch (Exception ex)
1028
            {
1029
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1030 a6e5055d alzkakdixm
            }
1031
        }
1032
1033 e6281033 alzkakdixm
        /// <summary>
1034
        /// AliveDataSelect의 Data Update
1035
        /// </summary>
1036
        /// <param name="newitems"></param>
1037 2f07b70a semi
        private void ItemsUpdate(List<ConvertPDF> newitems)
1038 a6e5055d alzkakdixm
        {
1039
1040 e6281033 alzkakdixm
            foreach (var item in newitems)
1041
            {
1042
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1043
            }
1044
1045
            if (AliveItems == null)
1046
            {
1047 2f07b70a semi
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>();
1048 e6281033 alzkakdixm
1049
                foreach (var item in newitems)
1050
                {
1051
                    AliveItems.Add(item);
1052
                }
1053
            }
1054
            else
1055 a6e5055d alzkakdixm
            {
1056 e6281033 alzkakdixm
                /// 데이터 업데이트
1057
                newitems.ForEach(newitem =>
1058
                {
1059
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1060
                });
1061
1062
                // 추가
1063
                foreach (var item in newitems)
1064
                {
1065
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1066
                    {
1067
                        AliveItems.Add(item);
1068
                    }
1069
                }
1070 a6e5055d alzkakdixm
1071 e6281033 alzkakdixm
                /// 삭제
1072 2decfbdf alzkakdixm
1073 e6281033 alzkakdixm
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1074
                {
1075
                    var item = AliveItems[i];
1076 a6e5055d alzkakdixm
1077 e6281033 alzkakdixm
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1078
                    {
1079
                        try
1080
                        {
1081
                            AliveItems.RemoveAt(i);
1082
                        }
1083
                        catch (Exception ex)
1084
                        {
1085
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1086
                        }
1087
                    }
1088
                }
1089 2decfbdf alzkakdixm
            }
1090 a6e5055d alzkakdixm
        }
1091
1092
1093 e6281033 alzkakdixm
        public static async Task<bool> SimplePingAsync(string uri)
1094 a6e5055d alzkakdixm
        {
1095 e6281033 alzkakdixm
            bool result = false;
1096
1097
            try
1098
            {
1099
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1100
                {
1101
                    Client.Timeout = new TimeSpan(0, 0, 60);
1102
1103
                    var message = await Client.GetAsync(uri);
1104
1105
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1106
1107
                    switch (StatusCode)
1108
                    {
1109
1110
                        case System.Net.HttpStatusCode.Accepted:
1111
                        case System.Net.HttpStatusCode.OK:
1112
                            result = true;
1113
                            break;
1114
                    }
1115
                }
1116
            }
1117
            catch (Exception ex)
1118
            {
1119
                result = false;
1120
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1121
            }
1122
1123
            return result;
1124 a6e5055d alzkakdixm
        }
1125
1126 e6281033 alzkakdixm
        #endregion
1127
1128
        #region Data Convert
1129 a6e5055d alzkakdixm
1130 037ab674 semi
        private async void DataConvert(object obj)
1131 e6281033 alzkakdixm
        {
1132 80391351 semi
            if (SelectFilterConvertList == null)
1133 e6281033 alzkakdixm
            {
1134
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1135
            }
1136
            else
1137 a6e5055d alzkakdixm
            {
1138 e6281033 alzkakdixm
                if (SelectRealConvert != null)
1139
                {
1140 59a29a3b semi
                    SetCleanUpItem(SelectRealConvert);//ConvertDataBase
1141 e6281033 alzkakdixm
                }
1142 80391351 semi
                if (SelectFilterConvertList != null)
1143 a6e5055d alzkakdixm
                {
1144 80391351 semi
                    foreach (var SelectFilterConvert in SelectFilterConvertList)
1145
                    {
1146 59a29a3b semi
                        SetCleanUpItem(SelectFilterConvert);
1147 80391351 semi
                    }
1148 e6281033 alzkakdixm
                }
1149 3bde451b semi
1150 037ab674 semi
                foreach (var SelectFilterConvert in SelectFilterConvertList)
1151
                {
1152 3bde451b semi
1153 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)
1154
                                let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
1155
                                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
1156
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1157 3bde451b semi
1158 037ab674 semi
                    foreach (var item in items)
1159
                    {
1160
                        RealConvertSource.Add(item);
1161 3bde451b semi
1162 037ab674 semi
                        if (RealConvertSource.Count() == 1)
1163
                        {
1164
                            ConvertShow = true;
1165 3bde451b semi
                        }
1166 8c7d1ea1 alzkakdixm
                    }
1167 a6e5055d alzkakdixm
                }
1168 3bde451b semi
            }
1169
        }
1170
1171
1172 59a29a3b semi
        public async void SetCleanUpItem(ConvertPDF _ConvertItem)
1173 3bde451b semi
        {
1174 59a29a3b semi
        
1175
            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);
1176
       
1177 037ab674 semi
            if (items.Count() > 0)
1178
            {
1179
                var item = items.First();
1180 3bde451b semi
1181 037ab674 semi
                var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
1182
                var _CREATE_DATETIME = DateTime.Now;
1183
                var _STATUS = (int)StatusCodeType.None;
1184 3bde451b semi
1185 037ab674 semi
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null);//_END_DATETIME = null 에러
1186 3bde451b semi
            }
1187
        }
1188
1189 e6281033 alzkakdixm
1190 2c634aed semi
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1191
        {
1192
            ViewInfo viewInfo = new ViewInfo();
1193
1194
            viewInfo.DocumentItemID = documentID;
1195
            viewInfo.ProjectNO = projectNo;
1196
            viewInfo.UserID = userID;
1197
1198
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1199
1200
        }
1201
1202
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1203
        {
1204
1205
            if (oEncoding == null)
1206
                oEncoding = System.Text.Encoding.UTF8;
1207
1208
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1209
1210
        }
1211
1212 e6281033 alzkakdixm
1213 3bde451b semi
        #endregion
1214
1215 e6281033 alzkakdixm
        #region Validation
1216 a6e5055d alzkakdixm
1217 e6281033 alzkakdixm
        private void DataValidate(object obj)
1218
        {
1219 80391351 semi
            if (SelectFilterConvertList.Count() > 1)
1220 e6281033 alzkakdixm
            {
1221 80391351 semi
                MessageBox.Show("하나만 클릭해 주세요");
1222 e6281033 alzkakdixm
            }
1223 80391351 semi
            else
1224 a6e5055d alzkakdixm
            {
1225 80391351 semi
                bool result = false;
1226
                WebRequest webRequest = WebRequest.Create(SelectFilterConvertList[0].OriginfilePath);
1227
                webRequest.Timeout = 1200; // miliseconds
1228
                webRequest.Method = "HEAD";
1229
1230
                HttpWebResponse response = null;
1231
1232
                try
1233 a6e5055d alzkakdixm
                {
1234 80391351 semi
                    response = (HttpWebResponse)webRequest.GetResponse();
1235
                    result = true;
1236
                }
1237
                catch (WebException webException)
1238
                {
1239
                    MessageBox.Show(SelectFilterConvert.FileName + " doesn't exist: " + webException.Message);
1240
                    result = true;
1241
                }
1242
                finally
1243
                {
1244
                    if (response != null)
1245
                    {
1246
                        response.Close();
1247
                    }
1248
                }
1249
                if (result == true)
1250
                {
1251
                    MessageBox.Show("File exists");
1252 a6e5055d alzkakdixm
                }
1253 2decfbdf alzkakdixm
            }
1254 80391351 semi
1255 e6281033 alzkakdixm
        }
1256
1257
        #endregion
1258
1259 b63dcfbb semi
        #region DataFilter
1260
1261
        public void DataFilter(object obj)
1262
        {
1263
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1264 c7955b40 semi
            dispatcherTimer.Tick += new EventHandler(SearchTimer_Tick);
1265 72862ad1 semi
            //DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
1266 b63dcfbb semi
        }
1267
1268
        #endregion
1269
1270 e78f0871 alzkakdixm
        #region MarkusLink
1271
1272 80391351 semi
        private void MarkusLink(object obj)
1273 e78f0871 alzkakdixm
        {
1274 2f07b70a semi
            if (obj is ConvertPDF)
1275 e78f0871 alzkakdixm
            {
1276 80391351 semi
1277 e78f0871 alzkakdixm
                if (obj != null)
1278
                {
1279 2f07b70a semi
                    var convertitem = obj as ConvertPDF;
1280 e78f0871 alzkakdixm
1281 9b2f01e1 semi
                    SelectFilterConvertList.Add(convertitem);
1282 e78f0871 alzkakdixm
1283
                    SelectRealConvert = convertitem;
1284
1285
                    ProcessStartInfo startInfo = null;
1286
1287
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1288
1289
                    Process.Start(startInfo);
1290
                }
1291 80391351 semi
1292 e78f0871 alzkakdixm
            }
1293
        }
1294
1295
        #endregion
1296
1297 e6281033 alzkakdixm
        #region Data Delete
1298
1299
        private void DataDelete(object obj)
1300
        {
1301 80391351 semi
            RadWindow.Alert("Do you want to delete it??", this.OnClosed);
1302 e6281033 alzkakdixm
        }
1303
1304 037ab674 semi
        private async void OnClosed(object sender, WindowClosedEventArgs e)
1305 e6281033 alzkakdixm
        {
1306
            {
1307 3bde451b semi
                var result = e.DialogResult;
1308
                if (result == true)
1309
                {
1310 80391351 semi
                    if (SelectFilterConvertList.Count() > 1)
1311 3bde451b semi
                    {
1312 80391351 semi
                        MessageBox.Show("하나만 클릭해 주세요!");
1313 3bde451b semi
                    }
1314 80391351 semi
                    else
1315 3bde451b semi
                    {
1316 80391351 semi
                        if (SelectRealConvert != null)
1317
                        {
1318 037ab674 semi
                            await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectRealConvert.ConvertID);
1319 80391351 semi
                        }
1320
                        if (SelectFilterConvertList != null)
1321
                        {
1322 037ab674 semi
                            await WcfClient.GET_SELECT_CONVERT_DELETEAsync(SelectFilterConvertList[0].ConvertID);
1323 80391351 semi
                        }
1324 3bde451b semi
                    }
1325
                }
1326 e6281033 alzkakdixm
            }
1327
        }
1328
        #endregion
1329
1330
        #region Data Export
1331
1332
1333
        /// <summary>
1334
        /// 필터된 상단 그리드 엑셀로 출력
1335
        /// </summary>
1336
1337
        public void DataExportData(object obj)
1338
        {
1339 037ab674 semi
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1340 e6281033 alzkakdixm
1341 037ab674 semi
            Return_FilterConvertSource(FilterConvertSource);
1342 e6281033 alzkakdixm
1343 037ab674 semi
            Views.ConvertExcelDialog convertExcelDialog = new Views.ConvertExcelDialog();
1344 e6281033 alzkakdixm
1345 19d6b221 semi
            convertExcelDialog.Owner = Application.Current.MainWindow;
1346 037ab674 semi
            convertExcelDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1347 e6281033 alzkakdixm
1348 037ab674 semi
            convertExcelDialog.ShowDialog();
1349 e6281033 alzkakdixm
1350
1351 037ab674 semi
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1352 2decfbdf alzkakdixm
        }
1353 e6281033 alzkakdixm
1354
        #endregion
1355
1356 b63dcfbb semi
        #region Data Search
1357 902f397c semi
1358 b63dcfbb semi
        public void RemoveCreateTimeFilter(object obj)
1359
        {
1360
            DefaultCreateTime = DateTime.Now;
1361
            SelectedCreateTimeBegin = DefaultCreateTime;
1362
            SelectedCreateTimeEnd = DefaultCreateTime;
1363
        }
1364
1365
        #endregion
1366
1367
        #region Reset
1368
1369
        /// <summary>
1370
        /// 그리드 상단 원상복귀 버튼
1371
        /// 필터를 끝낸 후 다시 복귀
1372
        /// </summary>
1373
1374
        public void Reset(object obj)
1375 5a954acc semi
        {
1376 93f5e32a semi
            ExcptionCheck = false;
1377 037ab674 semi
            SelectedInt = 10;
1378
            ProjectNumberFilter = ProjectNames[0];
1379 3bde451b semi
            UniqueKeyFilter = null;
1380
            Service_IDFilter = null;
1381
            Document_NameFilter = null;
1382
            Docuemnt_NOFilter = null;
1383
            ReconverterFilter = null;
1384
            RevisionFilter = null;
1385
            GroupNOFilter = null;
1386 30680747 semi
            DOCUMENT_URLFilter = null;
1387 3bde451b semi
            DefaultCreateTime = DateTime.Now;
1388
            SelectedCreateTimeBegin = DefaultCreateTime;
1389
            SelectedCreateTimeEnd = DefaultCreateTime;
1390 c7955b40 semi
            dispatcherTimer.Tick -= new EventHandler(SearchTimer_Tick);
1391 b63dcfbb semi
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1392 5a954acc semi
        }
1393
1394 902f397c semi
        #endregion
1395
1396 8c128693 semi
        #region ConvertAddDialog
1397 218e5002 semi
1398
        /// <summary>
1399
        /// 그리드 상단 Conver 추가 버튼
1400
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1401
        /// </summary>
1402
1403 037ab674 semi
        public void ConvertAdd(object obj)
1404 218e5002 semi
        {
1405 8c128693 semi
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1406 43b2e236 semi
1407
            Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1408 8c128693 semi
1409 3bde451b semi
            convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1410
1411 43b2e236 semi
            convertAddDialog.ShowDialog();
1412 218e5002 semi
1413 8c128693 semi
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1414 218e5002 semi
        }
1415
1416
        #endregion
1417
1418 78683624 semi
1419
        #region ConvertPathFileSearch
1420
1421
        /// <summary>
1422
        ///  ConvertPath 파일 탐색기로 열리는 아이콘
1423
        /// </summary>
1424
1425
        public void ConvertPathFileSearch(object obj)
1426
        {
1427 2f07b70a semi
            if (obj is ConvertPDF)
1428 78683624 semi
            {
1429
                if (obj != null)
1430
                {
1431 2f07b70a semi
                    var convertitem = obj as ConvertPDF;
1432 78683624 semi
1433 cab4a0e1 semi
                    if (!string.IsNullOrEmpty(convertitem.ConvertPath))
1434
                    {
1435
                        System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath);
1436
                    }
1437 78683624 semi
                }
1438
            }
1439
        }
1440
1441
        #endregion
1442
1443 e6281033 alzkakdixm
        #endregion
1444 a6e5055d alzkakdixm
    }
1445
}
클립보드 이미지 추가 (최대 크기: 500 MB)