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