markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / FinalPDFViewModel.cs @ 3bde451b
이력 | 보기 | 이력해설 | 다운로드 (49.6 KB)
1 | 3bde451b | semi | using Markus.Message; |
---|---|---|---|
2 | using Markus.Service.DataBase; |
||
3 | using Markus.Service.Extensions; |
||
4 | using Markus.Service.StationController.Data; |
||
5 | using Markus.Service.StationController.Behaviors; |
||
6 | using Markus.Service.StationController.Extensions; |
||
7 | using Markus.Service.StationController.Controls; |
||
8 | using Microsoft.Win32; |
||
9 | using System; |
||
10 | using System.Collections.Generic; |
||
11 | using System.ComponentModel; |
||
12 | using System.Linq; |
||
13 | using System.Threading.Tasks; |
||
14 | using System.Web; |
||
15 | using System.Windows; |
||
16 | using Telerik.Windows.Controls; |
||
17 | using Telerik.Windows.Data; |
||
18 | using ConvertItem = Markus.Service.Interface.ConvertItem; |
||
19 | using System.Net; |
||
20 | using System.Windows.Threading; |
||
21 | using System.Diagnostics; |
||
22 | using System.Windows.Input; |
||
23 | using Markus.Mvvm.ToolKit; |
||
24 | using System.Windows.Data; |
||
25 | using System.Windows.Controls; |
||
26 | using System.IO; |
||
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.DocumnetName = 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://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(PROJECT_NO, DOCUMENT_ID, "doftech"); |
||
1178 | |||
1179 | return ConvertPath; |
||
1180 | } |
||
1181 | |||
1182 | #region Convert Path |
||
1183 | |||
1184 | private string GetConvertPath(string ProjectNo, string DocumentID) |
||
1185 | { |
||
1186 | try |
||
1187 | { |
||
1188 | return Path.Combine(BaseStorage(ProjectNo), ProjectNo + "_Tile", (System.Convert.ToInt64(DocumentID) / 100).ToString(), DocumentID); |
||
1189 | } |
||
1190 | catch (Exception) |
||
1191 | { |
||
1192 | throw new Exception("GetConvertPath Error"); |
||
1193 | } |
||
1194 | |||
1195 | } |
||
1196 | |||
1197 | private string BaseStorage(string ProjectNo) |
||
1198 | { |
||
1199 | using (markusEntities entities = new markusEntities()) |
||
1200 | { |
||
1201 | string result = ""; |
||
1202 | |||
1203 | var properties = entities.SELECT_FINAL_PDF_ITEM(null, ProjectNo, null, null, null, null, null, null, null, 1, null, null, null, null, |
||
1204 | null, null, null, null).ToList(); |
||
1205 | |||
1206 | |||
1207 | if (properties.Count() > 0) |
||
1208 | { |
||
1209 | result = properties.First().PROPERTIES_VALUE; |
||
1210 | } |
||
1211 | else |
||
1212 | { |
||
1213 | throw new Exception($"Project {ProjectNo} BaseStorage Not Setting."); |
||
1214 | } |
||
1215 | |||
1216 | return result; |
||
1217 | } |
||
1218 | } |
||
1219 | |||
1220 | #endregion |
||
1221 | |||
1222 | #endregion |
||
1223 | |||
1224 | #region Validation |
||
1225 | |||
1226 | private void DataValidate(object obj) |
||
1227 | { |
||
1228 | |||
1229 | bool result = false; |
||
1230 | |||
1231 | WebRequest webRequest = WebRequest.Create(SelectFilterConvert.OriginfilePath); |
||
1232 | webRequest.Timeout = 1200; // miliseconds |
||
1233 | webRequest.Method = "HEAD"; |
||
1234 | |||
1235 | HttpWebResponse response = null; |
||
1236 | |||
1237 | try |
||
1238 | { |
||
1239 | response = (HttpWebResponse)webRequest.GetResponse(); |
||
1240 | result = true; |
||
1241 | } |
||
1242 | catch (WebException webException) |
||
1243 | { |
||
1244 | MessageBox.Show(SelectFilterConvert.FileName + " doesn't exist: " + webException.Message); |
||
1245 | result = true; |
||
1246 | } |
||
1247 | finally |
||
1248 | { |
||
1249 | if (response != null) |
||
1250 | { |
||
1251 | response.Close(); |
||
1252 | } |
||
1253 | } |
||
1254 | if (result == true) |
||
1255 | { |
||
1256 | MessageBox.Show("File exists"); |
||
1257 | } |
||
1258 | } |
||
1259 | |||
1260 | #endregion |
||
1261 | |||
1262 | #region DataFilter |
||
1263 | |||
1264 | public void DataFilter(object obj) |
||
1265 | { |
||
1266 | dispatcherTimer.Tick -= new EventHandler(Timer_Tick); |
||
1267 | DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource); |
||
1268 | } |
||
1269 | |||
1270 | #endregion |
||
1271 | |||
1272 | #region MarkusLink |
||
1273 | |||
1274 | private void MarkusLink(object obj)///여기서 부터 |
||
1275 | { |
||
1276 | if (obj is ConvertItem) |
||
1277 | { |
||
1278 | if (obj != null) |
||
1279 | { |
||
1280 | var convertitem = obj as ConvertItem; |
||
1281 | |||
1282 | SelectFilterConvert = convertitem; |
||
1283 | |||
1284 | SelectRealConvert = convertitem; |
||
1285 | |||
1286 | ProcessStartInfo startInfo = null; |
||
1287 | |||
1288 | startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink); |
||
1289 | |||
1290 | Process.Start(startInfo); |
||
1291 | } |
||
1292 | } |
||
1293 | } |
||
1294 | |||
1295 | #endregion |
||
1296 | |||
1297 | #region Data Delete |
||
1298 | |||
1299 | private void DataDelete(object obj) |
||
1300 | { |
||
1301 | RadWindow.Alert("do you want to delete it??", this.OnClosed); |
||
1302 | } |
||
1303 | |||
1304 | private void OnClosed(object sender, WindowClosedEventArgs e) |
||
1305 | { |
||
1306 | using (markusEntities entities = new markusEntities()) |
||
1307 | { |
||
1308 | var result = e.DialogResult; |
||
1309 | if (result == true) |
||
1310 | { |
||
1311 | if (SelectRealConvert != null) |
||
1312 | { |
||
1313 | entities.SELECT_FINAL_PDF_DELETE(SelectRealConvert.ConvertID); |
||
1314 | } |
||
1315 | if (SelectFilterConvert != null) |
||
1316 | { |
||
1317 | entities.SELECT_FINAL_PDF_DELETE(SelectFilterConvert.ConvertID); |
||
1318 | } |
||
1319 | } |
||
1320 | } |
||
1321 | } |
||
1322 | |||
1323 | |||
1324 | #endregion |
||
1325 | |||
1326 | #region Data Export |
||
1327 | |||
1328 | |||
1329 | /// <summary> |
||
1330 | /// 필터된 상단 그리드 엑셀로 출력 |
||
1331 | /// </summary> |
||
1332 | |||
1333 | public void DataExportData(object obj) |
||
1334 | { |
||
1335 | SaveFileDialog saveFileDialog = new SaveFileDialog(); |
||
1336 | |||
1337 | saveFileDialog.FileName = "Document"; // Default file name |
||
1338 | saveFileDialog.DefaultExt = ".txt"; // Default file extension |
||
1339 | saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension |
||
1340 | |||
1341 | |||
1342 | if (saveFileDialog.ShowDialog() == true) |
||
1343 | { |
||
1344 | |||
1345 | |||
1346 | if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName)) |
||
1347 | { |
||
1348 | |||
1349 | var extension = new System.IO.FileInfo(saveFileDialog.FileName).Extension; |
||
1350 | |||
1351 | if (extension == ".xlsx" || extension == ".csv") |
||
1352 | { |
||
1353 | |||
1354 | var headers = new List<HeaderMember> |
||
1355 | { |
||
1356 | new HeaderMember{HeaderName = "ServiceID", Property = "ServiceID" }, |
||
1357 | new HeaderMember{HeaderName = "ConvertID", Property = "ConvertID" }, |
||
1358 | new HeaderMember{HeaderName = "ProjectNumber", Property = "ProjectNumber" }, |
||
1359 | new HeaderMember{HeaderName = "ConvertState", Property = "ConvertState" }, |
||
1360 | new HeaderMember{HeaderName = "CurrentPageNo", Property = "CurrentPageNo" }, |
||
1361 | new HeaderMember{HeaderName = "TotalPage", Property = "TotalPage" }, |
||
1362 | new HeaderMember{HeaderName = "OriginfilePath", Property = "OriginfilePath" }, |
||
1363 | new HeaderMember{HeaderName = "ConvertPath", Property = "ConvertPath" }, |
||
1364 | new HeaderMember{HeaderName = "CreateTime", Property = "CreateTime" }, |
||
1365 | new HeaderMember{HeaderName = "Exception", Property = "Exception" }, |
||
1366 | new HeaderMember{HeaderName = "ProcessorAffinity", Property = "ProcessorAffinity" }, |
||
1367 | new HeaderMember{HeaderName = "ReConverter", Property = "ReConverter" }, |
||
1368 | new HeaderMember{HeaderName = "UniqueKey", Property = "UniqueKey" } |
||
1369 | }; |
||
1370 | |||
1371 | |||
1372 | DataExport dataExport = new DataExport(); |
||
1373 | dataExport.DataExportExcel(saveFileDialog.FileName, "Hello world", FilterConvertSource, headers); |
||
1374 | //_dataExport.DataExportExcel(saveFileDialog.FileName, saveFileDialog.FileName.ToString(), Projectsource, headers); |
||
1375 | //GemBoxFileSave(obj); |
||
1376 | } |
||
1377 | } |
||
1378 | } |
||
1379 | } |
||
1380 | |||
1381 | #endregion |
||
1382 | |||
1383 | #region Data Search |
||
1384 | |||
1385 | public void RemoveCreateTimeFilter(object obj) |
||
1386 | { |
||
1387 | DefaultCreateTime = DateTime.Now; |
||
1388 | SelectedCreateTimeBegin = DefaultCreateTime; |
||
1389 | SelectedCreateTimeEnd = DefaultCreateTime; |
||
1390 | |||
1391 | } |
||
1392 | |||
1393 | #endregion |
||
1394 | |||
1395 | #region Reset |
||
1396 | |||
1397 | /// <summary> |
||
1398 | /// 그리드 상단 원상복귀 버튼 |
||
1399 | /// 필터를 끝낸 후 다시 복귀 |
||
1400 | /// </summary> |
||
1401 | |||
1402 | public void Reset(object obj) |
||
1403 | { |
||
1404 | ProjectNumberFilter = null; |
||
1405 | DocumentIDFilter = null; |
||
1406 | MarkupInfo_IDFilter = null; |
||
1407 | DOCINFO_IDFilter = null; |
||
1408 | Document_NameFilter = null; |
||
1409 | Document_NOFilter = null; |
||
1410 | CreateUser_IDFilter = null; |
||
1411 | GROUP_NOFilter = null; |
||
1412 | REVISIONFilter = null; |
||
1413 | |||
1414 | DefaultCreateTime = DateTime.Now; |
||
1415 | SelectedCreateTimeBegin = DefaultCreateTime; |
||
1416 | SelectedCreateTimeEnd = DefaultCreateTime; |
||
1417 | |||
1418 | dispatcherTimer.Tick += new EventHandler(Timer_Tick); |
||
1419 | |||
1420 | } |
||
1421 | |||
1422 | #endregion |
||
1423 | |||
1424 | |||
1425 | #region ConvertAddDialog |
||
1426 | |||
1427 | /// <summary> |
||
1428 | /// 그리드 상단 Conver 추가 버튼 |
||
1429 | /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 |
||
1430 | /// </summary> |
||
1431 | |||
1432 | public void ConverAdd(object obj) |
||
1433 | { |
||
1434 | dispatcherTimer.Tick -= new EventHandler(Timer_Tick); |
||
1435 | |||
1436 | Views.FinalPDFAddDialog convertAddDialog = new Views.FinalPDFAddDialog(); |
||
1437 | |||
1438 | convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; |
||
1439 | |||
1440 | convertAddDialog.ShowDialog(); |
||
1441 | |||
1442 | dispatcherTimer.Tick += new EventHandler(Timer_Tick); |
||
1443 | } |
||
1444 | |||
1445 | #endregion |
||
1446 | |||
1447 | #endregion |
||
1448 | } |
||
1449 | } |