개정판 95e7bd84
수정사항 & Add Dialog validation 하는 중
Change-Id: Id53bbd718ea1cc5aebfc97f0216fe6a3f464ee00
ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/DashBoardViewModel.cs | ||
---|---|---|
14 | 14 |
using System.Windows.Threading; |
15 | 15 |
using ConverCOUNT = Markus.Service.StationController.Data.ConvertCOUNT; |
16 | 16 |
using System.Collections.ObjectModel; |
17 |
using System.ComponentModel; |
|
18 |
using System.Windows.Data; |
|
19 |
using System.Diagnostics; |
|
20 |
using Microsoft.Win32; |
|
21 |
using System.Windows.Controls; |
|
17 | 22 |
|
18 | 23 |
namespace Markus.Service.StationController.ViewModel |
19 | 24 |
{ |
... | ... | |
25 | 30 |
public DashBoardViewModel() |
26 | 31 |
{ |
27 | 32 |
RemoveCreateTimeFilterCommand = new DelegateCommand(RemoveCreateTimeFilter); |
33 |
ConvertPDFMarkusLinkCommand = new DelegateCommand(ConvertPDFMarkusLink); |
|
34 |
FinalPDFMarkusLinkCommand = new DelegateCommand(FinalPDFMarkusLink); |
|
35 |
ConvertPathFileSearchCommand = new DelegateCommand(ConvertPathFileSearch); |
|
28 | 36 |
} |
29 | 37 |
|
30 | 38 |
#endregion |
... | ... | |
161 | 169 |
} |
162 | 170 |
} |
163 | 171 |
|
172 |
public ICollectionView DashBoard_Convert |
|
173 |
{ |
|
174 |
get |
|
175 |
{ |
|
176 |
var view = CollectionViewSource.GetDefaultView(ConvertView); |
|
177 |
return view; |
|
178 |
} |
|
179 |
} |
|
180 |
|
|
181 |
private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _ConvertView; |
|
182 |
public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> ConvertView |
|
183 |
{ |
|
184 |
get |
|
185 |
{ |
|
186 |
if (_ConvertView == null) |
|
187 |
{ |
|
188 |
_ConvertView = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>(); |
|
189 |
} |
|
190 |
return _ConvertView; |
|
191 |
} |
|
192 |
set |
|
193 |
{ |
|
194 |
_ConvertView = value; |
|
195 |
OnPropertyChanged(() => ConvertView); |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
public ICollectionView DashBoard_FinalPDF |
|
200 |
{ |
|
201 |
get |
|
202 |
{ |
|
203 |
var view = CollectionViewSource.GetDefaultView(FinalPDFView); |
|
204 |
return view; |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
private System.Collections.ObjectModel.ObservableCollection<FinalPDF> _FinalPDFView; |
|
209 |
public System.Collections.ObjectModel.ObservableCollection<FinalPDF> FinalPDFView |
|
210 |
{ |
|
211 |
get |
|
212 |
{ |
|
213 |
if (_FinalPDFView == null) |
|
214 |
{ |
|
215 |
_FinalPDFView = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>(); |
|
216 |
} |
|
217 |
return _FinalPDFView; |
|
218 |
} |
|
219 |
set |
|
220 |
{ |
|
221 |
_FinalPDFView = value; |
|
222 |
OnPropertyChanged(() => FinalPDFView); |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
private ObservableCollection<FinalPDF> _SelectedFinalPDFList; |
|
227 |
public ObservableCollection<FinalPDF> SelectedFinalPDFList |
|
228 |
{ |
|
229 |
get |
|
230 |
{ |
|
231 |
if (_SelectedFinalPDFList == null) |
|
232 |
{ |
|
233 |
_SelectedFinalPDFList = new ObservableCollection<FinalPDF>(); |
|
234 |
} |
|
235 |
return _SelectedFinalPDFList; |
|
236 |
} |
|
237 |
set |
|
238 |
{ |
|
239 |
_SelectedFinalPDFList = value; |
|
240 |
OnPropertyChanged(() => SelectedFinalPDFList); |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
private ObservableCollection<ConvertPDF> _SelectedConvertList; |
|
245 |
public ObservableCollection<ConvertPDF> SelectedConvertList |
|
246 |
{ |
|
247 |
get |
|
248 |
{ |
|
249 |
if (_SelectedConvertList == null) |
|
250 |
{ |
|
251 |
_SelectedConvertList = new ObservableCollection<ConvertPDF>(); |
|
252 |
} |
|
253 |
return _SelectedConvertList; |
|
254 |
} |
|
255 |
set |
|
256 |
{ |
|
257 |
_SelectedConvertList = value; |
|
258 |
OnPropertyChanged(() => SelectedConvertList); |
|
259 |
} |
|
260 |
} |
|
164 | 261 |
#endregion |
165 | 262 |
|
166 | 263 |
#region Command |
167 | 264 |
|
168 | 265 |
public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; } |
266 |
public DelegateCommand ConvertPDFMarkusLinkCommand { get; private set; } |
|
267 |
public DelegateCommand FinalPDFMarkusLinkCommand { get; private set; } |
|
268 |
public DelegateCommand ConvertPathFileSearchCommand { get; private set; } |
|
169 | 269 |
|
170 | 270 |
#endregion |
171 | 271 |
|
... | ... | |
221 | 321 |
|
222 | 322 |
#region Function |
223 | 323 |
|
324 |
#region ConvertPathFileSearch |
|
325 |
|
|
326 |
/// <summary> |
|
327 |
/// ConvertPath 파일 탐색기로 열리는 아이콘 |
|
328 |
/// </summary> |
|
329 |
|
|
330 |
public void ConvertPathFileSearch(object obj) |
|
331 |
{ |
|
332 |
if (obj is ConvertPDF) |
|
333 |
{ |
|
334 |
if (obj != null) |
|
335 |
{ |
|
336 |
var convertitem = obj as ConvertPDF; |
|
337 |
|
|
338 |
if (!string.IsNullOrEmpty(convertitem.ConvertPath)) |
|
339 |
{ |
|
340 |
System.Diagnostics.Process.Start("explorer.exe", convertitem.ConvertPath); |
|
341 |
} |
|
342 |
} |
|
343 |
} |
|
344 |
} |
|
345 |
|
|
346 |
#endregion |
|
347 |
|
|
348 |
#region FinalPDFPathFileSearch |
|
349 |
|
|
350 |
/// <summary> |
|
351 |
/// ConvertPath 파일 탐색기로 열리는 아이콘 |
|
352 |
/// </summary> |
|
353 |
|
|
354 |
public void FinalPDFPathFileSearch(object obj) |
|
355 |
{ |
|
356 |
if (obj is FinalPDF) |
|
357 |
{ |
|
358 |
if (obj != null) |
|
359 |
{ |
|
360 |
var convertitem = obj as FinalPDF; |
|
361 |
|
|
362 |
SaveFileDialog saveFileDialog = new SaveFileDialog(); |
|
363 |
|
|
364 |
saveFileDialog.FileName = "Document"; // Default file name |
|
365 |
saveFileDialog.DefaultExt = ".txt"; // Default file extension |
|
366 |
saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension |
|
367 |
|
|
368 |
|
|
369 |
if (saveFileDialog.ShowDialog() == true) |
|
370 |
{ |
|
371 |
} |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
375 |
|
|
376 |
#endregion |
|
377 |
|
|
378 |
#region MarkusLink |
|
379 |
|
|
380 |
private void ConvertPDFMarkusLink(object obj) |
|
381 |
{ |
|
382 |
if (obj is ConvertPDF) |
|
383 |
{ |
|
384 |
|
|
385 |
if (obj != null) |
|
386 |
{ |
|
387 |
var convertitem = obj as ConvertPDF; |
|
388 |
|
|
389 |
SelectedConvertList.Add(convertitem); |
|
390 |
|
|
391 |
ProcessStartInfo startInfo = null; |
|
392 |
|
|
393 |
startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink); |
|
394 |
|
|
395 |
Process.Start(startInfo); |
|
396 |
} |
|
397 |
|
|
398 |
} |
|
399 |
} |
|
400 |
|
|
401 |
private void FinalPDFMarkusLink(object obj) |
|
402 |
{ |
|
403 |
if (obj is FinalPDF) |
|
404 |
{ |
|
405 |
|
|
406 |
if (obj != null) |
|
407 |
{ |
|
408 |
var convertitem = obj as FinalPDF; |
|
409 |
|
|
410 |
SelectedFinalPDFList.Add(convertitem); |
|
411 |
|
|
412 |
ProcessStartInfo startInfo = null; |
|
413 |
|
|
414 |
startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink); |
|
415 |
|
|
416 |
Process.Start(startInfo); |
|
417 |
} |
|
418 |
|
|
419 |
} |
|
420 |
} |
|
421 |
|
|
422 |
#endregion |
|
423 |
|
|
424 |
|
|
224 | 425 |
#region RemoveCreateTimeFilter |
225 | 426 |
|
226 | 427 |
public void RemoveCreateTimeFilter(object obj) |
... | ... | |
240 | 441 |
/// </summary> |
241 | 442 |
private void DataSelect() |
242 | 443 |
{ |
444 |
if (ConvertView == null) |
|
445 |
{ |
|
446 |
ConvertView = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>(); |
|
447 |
} |
|
448 |
|
|
449 |
ConvertView_DataSelect(new[] { (ConvertPDF.StatusCodeType)(SelectedStatus.Value) }, ConvertView); |
|
450 |
|
|
451 |
if (FinalPDFView == null) |
|
452 |
{ |
|
453 |
FinalPDFView = new System.Collections.ObjectModel.ObservableCollection<FinalPDF>(); |
|
454 |
} |
|
455 |
|
|
456 |
FinalPDFView_DataSelect(new[] { (FinalPDF.StatusCodeType)(SelectedStatus.Value) }, FinalPDFView); |
|
457 |
|
|
243 | 458 |
if (ConvertCOUNTDashBoard == null) |
244 | 459 |
{ |
245 | 460 |
ConvertCOUNTDashBoard = new ObservableCollection<ConvertCOUNT>(); |
... | ... | |
252 | 467 |
if (SelectedStatus != null) |
253 | 468 |
{ |
254 | 469 |
ConvertDataSelect(new[] { (ConvertPDF.StatusCodeType)(SelectedStatus.Value) }, ConvertCOUNTDashBoard); |
255 |
FinalPDFDataSelect(new[] { (ConvertPDF.StatusCodeType)(SelectedStatus.Value) }, FinalPDFCOUNTDashBoard); |
|
470 |
FinalPDFDataSelect(new[] { (FinalPDF.StatusCodeType)(SelectedStatus.Value) }, FinalPDFCOUNTDashBoard); |
|
471 |
} |
|
472 |
} |
|
473 |
|
|
474 |
private async void FinalPDFView_DataSelect(IEnumerable<FinalPDF.StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<FinalPDF> collection) |
|
475 |
{ |
|
476 |
try |
|
477 |
{ |
|
478 |
int _status = 0; |
|
479 |
if (SelectedStatus != null) |
|
480 |
{ |
|
481 |
_status = (int)SelectedStatus.Value; |
|
482 |
} |
|
483 |
|
|
484 |
var Listitems = from x in await WcfClient.GET_SELECT_FINAL_PDF_ITEMAsync(null, null, null, null, null, null, null, null, _status, 5, null, null, null, null, null, null, null, null, null, null) |
|
485 |
let MarkusLink = "kcom://" + CreateMarkusParam(x.ID, x.DOCUMENT_ID, "doftech") |
|
486 |
select new FinalPDF(x.ID, x.PROJECT_NO, x.STATUS, x.DOCUMENT_ID, x.MARKUPINFO_ID, x.DOCINFO_ID, x.DOCUMENT_NAME, x.DOCUMENT_NO, x.CREATE_USER_ID, |
|
487 |
x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME |
|
488 |
, x.ORIGINAL_FILE, x.CONVERT_PATH, MarkusLink); |
|
489 |
|
|
490 |
if (collection.Count() == 0) |
|
491 |
{ |
|
492 |
if (statusCodeTypeList.Count() == 1) |
|
493 |
{ |
|
494 |
foreach (var x in Listitems) |
|
495 |
{ |
|
496 |
collection.Add(x); |
|
497 |
} |
|
498 |
} |
|
499 |
} |
|
500 |
else |
|
501 |
{ |
|
502 |
foreach (var newitem in Listitems) |
|
503 |
{ |
|
504 |
collection.UpdateWhere(changeitem => |
|
505 |
ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID); |
|
506 |
} |
|
507 |
|
|
508 |
if (statusCodeTypeList.Count() == 1) |
|
509 |
{ |
|
510 |
for (int i = collection.Count() - 1; i >= 0; --i) |
|
511 |
{ |
|
512 |
var item = collection[i]; |
|
513 |
|
|
514 |
if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0) |
|
515 |
{ |
|
516 |
collection.RemoveAt(i); |
|
517 |
} |
|
518 |
} |
|
519 |
} |
|
520 |
|
|
521 |
if (statusCodeTypeList.Count() == 1) |
|
522 |
{ |
|
523 |
foreach (var item in Listitems) |
|
524 |
{ |
|
525 |
if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0) |
|
526 |
{ |
|
527 |
for (int i = 0; i < 5; i++) |
|
528 |
{ |
|
529 |
if (i < collection.Count() - 1) |
|
530 |
{ |
|
531 |
if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0) |
|
532 |
{ |
|
533 |
collection.Insert(i, item); |
|
534 |
break; |
|
535 |
} |
|
536 |
} |
|
537 |
else |
|
538 |
{ |
|
539 |
collection.Add(item); |
|
540 |
break; |
|
541 |
} |
|
542 |
} |
|
543 |
|
|
544 |
} |
|
545 |
|
|
546 |
} |
|
547 |
} |
|
548 |
} |
|
549 |
} |
|
550 |
catch (Exception ex) |
|
551 |
{ |
|
552 |
MessageBox.Show(ex.ToString()); |
|
553 |
System.Diagnostics.Debug.WriteLine(ex.ToString()); |
|
554 |
} |
|
555 |
} |
|
556 |
|
|
557 |
private async void ConvertView_DataSelect(IEnumerable<ConvertPDF.StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertPDF> collection) |
|
558 |
{ |
|
559 |
try |
|
560 |
{ |
|
561 |
int _status = 0; |
|
562 |
if (SelectedStatus != null) |
|
563 |
{ |
|
564 |
_status = (int)SelectedStatus.Value; |
|
565 |
} |
|
566 |
|
|
567 |
var Listitems = from num in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(null, null, null, _status, 5, null, null, null, null, null, null, null, null, null, null, null, null, null, null) |
|
568 |
let MarkusLink = "kcom://" + CreateMarkusParam(num.PROJECT_NO, num.DOCUMENT_ID, "doftech") |
|
569 |
select new ConvertPDF(num.SERVICE_ID, num.ID, num.PROJECT_NO, num.STATUS, num.DOCUMENT_ID, num.DOCUMENT_NAME, num.DOCUMENT_NO, num.DOCUMENT_URL, num.REVISION, num.CURRENT_PAGE, |
|
570 |
num.TOTAL_PAGE, num.EXCEPTION, num.GROUP_NO, num.CREATE_DATETIME, num.START_DATETIME, num.END_DATETIME, num.DOCUMENT_URL, num.CONVERT_PATH, MarkusLink, num.RECONVERTER); |
|
571 |
|
|
572 |
if (collection.Count() == 0) |
|
573 |
{ |
|
574 |
if (statusCodeTypeList.Count() == 1) |
|
575 |
{ |
|
576 |
foreach (var Listitem in Listitems.ToList()) |
|
577 |
{ |
|
578 |
collection.Add(Listitem); |
|
579 |
} |
|
580 |
} |
|
581 |
} |
|
582 |
else |
|
583 |
{ |
|
584 |
foreach (var Listitem in Listitems) |
|
585 |
{ |
|
586 |
collection.UpdateWhere(changeitem => |
|
587 |
ConvertItemEx.ChangeValues(changeitem, Listitem), x => x.ProjectNumber == Listitem.ProjectNumber && x.ConvertID == Listitem.ConvertID); |
|
588 |
} |
|
589 |
if (statusCodeTypeList.Count() == 1) |
|
590 |
{ |
|
591 |
for (int i = collection.Count() - 1; i >= 0; --i) |
|
592 |
{ |
|
593 |
var item = collection[i]; |
|
594 |
|
|
595 |
if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0) |
|
596 |
{ |
|
597 |
collection.RemoveAt(i); |
|
598 |
} |
|
599 |
} |
|
600 |
} |
|
601 |
|
|
602 |
if (statusCodeTypeList.Count() == 1) |
|
603 |
{ |
|
604 |
foreach (var item in Listitems) |
|
605 |
{ |
|
606 |
if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0) |
|
607 |
{ |
|
608 |
for (int i = 0; i < 5; i++) |
|
609 |
{ |
|
610 |
if (i < collection.Count() - 1) |
|
611 |
{ |
|
612 |
if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0) |
|
613 |
{ |
|
614 |
collection.Insert(i, item); |
|
615 |
break; |
|
616 |
} |
|
617 |
} |
|
618 |
else |
|
619 |
{ |
|
620 |
collection.Add(item); |
|
621 |
break; |
|
622 |
} |
|
623 |
} |
|
624 |
|
|
625 |
} |
|
626 |
|
|
627 |
} |
|
628 |
} |
|
629 |
} |
|
630 |
} |
|
631 |
catch (Exception ex) |
|
632 |
{ |
|
633 |
MessageBox.Show(ex.ToString()); |
|
256 | 634 |
} |
257 | 635 |
} |
258 | 636 |
|
637 |
public static string CreateMarkusParam(string projectNo, string documentID, string userID) |
|
638 |
{ |
|
639 |
ViewInfo viewInfo = new ViewInfo(); |
|
640 |
|
|
641 |
viewInfo.DocumentItemID = documentID; |
|
642 |
viewInfo.ProjectNO = projectNo; |
|
643 |
viewInfo.UserID = userID; |
|
644 |
|
|
645 |
return ParamEncoding(JsonConvert.SerializeObject(viewInfo)); |
|
646 |
|
|
647 |
} |
|
648 |
|
|
649 |
public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null) |
|
650 |
{ |
|
651 |
|
|
652 |
if (oEncoding == null) |
|
653 |
oEncoding = System.Text.Encoding.UTF8; |
|
654 |
|
|
655 |
return Convert.ToBase64String(oEncoding.GetBytes(EncodingText)); |
|
656 |
|
|
657 |
} |
|
658 |
|
|
259 | 659 |
private async void ConvertDataSelect(IEnumerable<ConvertPDF.StatusCodeType> statusCodeTypeList, ObservableCollection<ConvertCOUNT> collection) |
260 | 660 |
{ |
261 | 661 |
try |
... | ... | |
336 | 736 |
} |
337 | 737 |
} |
338 | 738 |
|
339 |
private async void FinalPDFDataSelect(IEnumerable<ConvertPDF.StatusCodeType> statusCodeTypeList, ObservableCollection<FinalPDFCOUNT> collection)
|
|
739 |
private async void FinalPDFDataSelect(IEnumerable<FinalPDF.StatusCodeType> statusCodeTypeList, ObservableCollection<FinalPDFCOUNT> collection)
|
|
340 | 740 |
{ |
341 | 741 |
try |
342 | 742 |
{ |
... | ... | |
420 | 820 |
#endregion |
421 | 821 |
} |
422 | 822 |
} |
823 |
|
|
824 |
public class NameValidator : ValidationRule |
|
825 |
{ |
|
826 |
public override ValidationResult Validate |
|
827 |
(object value, System.Globalization.CultureInfo cultureInfo) |
|
828 |
{ |
|
829 |
if (value == null) |
|
830 |
return new ValidationResult(false, "value cannot be empty."); |
|
831 |
else |
|
832 |
{ |
|
833 |
if (value.ToString().Length > 3) |
|
834 |
return new ValidationResult |
|
835 |
(false, "Name cannot be more than 3 characters long."); |
|
836 |
} |
|
837 |
return ValidationResult.ValidResult; |
|
838 |
} |
|
839 |
} |
내보내기 Unified diff