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