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