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