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