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