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