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