개정판 0cb12397
DataBaseItemsModel 정리
Change-Id: I2d6439710ff4c9a93263897d2c47f8f3c37f0f33
ConvertService/ServiceBase/Markus.Service.StationController/Markus.Service.StationController.csproj | ||
---|---|---|
164 | 164 |
<Compile Include="Data\MenuItem.cs" /> |
165 | 165 |
<Compile Include="Data\StatusViewItem.cs" /> |
166 | 166 |
<Compile Include="Extensions\ConvertItemChangeValue.cs" /> |
167 |
<Compile Include="Extensions\DataExport.cs" /> |
|
167 | 168 |
<Compile Include="Extensions\GetStatusTypeEnums.cs" /> |
168 | 169 |
<Compile Include="Extensions\VisualTreeHelper.cs" /> |
169 | 170 |
<Compile Include="ViewModel\AliveViewModel.cs" /> |
ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/DataBaseItemsModel.cs | ||
---|---|---|
2 | 2 |
using Markus.Message; |
3 | 3 |
using Markus.Service.DataBase; |
4 | 4 |
using Markus.Service.Extensions; |
5 |
//using Markus.Service.Interface; |
|
6 |
using Markus.Service.StationController; |
|
7 | 5 |
using Markus.Service.StationController.Behaviors; |
8 | 6 |
using Markus.Service.StationController.Extensions; |
9 | 7 |
using Microsoft.Win32; |
10 | 8 |
using System; |
11 | 9 |
using System.Collections.Generic; |
12 |
using System.Collections.ObjectModel; |
|
13 | 10 |
using System.ComponentModel; |
14 |
using System.Diagnostics; |
|
15 | 11 |
using System.Linq; |
16 | 12 |
using System.Threading.Tasks; |
17 | 13 |
using System.Web; |
... | ... | |
19 | 15 |
using Telerik.Windows.Controls; |
20 | 16 |
using Telerik.Windows.Data; |
21 | 17 |
using ConvertItem = Markus.Service.Interface.ConvertItem; |
22 |
//using AliveConvertItem = Markus.Service.WcfClient.StationServiceTask.ConvertItem; |
|
23 |
using Markus.Service.WcfClient.StationServiceTask; |
|
24 |
using System.Text; |
|
25 |
using Markus.Service.Helper; |
|
26 | 18 |
|
27 | 19 |
namespace Markus.Service.StationController.ViewModel |
28 | 20 |
{ |
29 | 21 |
//세미 |
30 | 22 |
public class DataBaseItemsModel : Mvvm.ToolKit.ViewModelBase |
31 | 23 |
{ |
32 |
//alive |
|
33 |
private BackgroundWorker AlivebackgroundWorker; |
|
34 |
|
|
35 |
private System.Windows.Documents.FlowDocument connectionLog; |
|
36 |
|
|
37 | 24 |
private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _AliveItems; |
38 |
|
|
39 | 25 |
public System.Collections.ObjectModel.ObservableCollection<ConvertItem> AliveItems |
40 | 26 |
{ |
41 | 27 |
get => _AliveItems; set |
42 | 28 |
{ |
43 |
_AliveItems = value; |
|
29 |
_AliveItems = value;
|
|
44 | 30 |
OnPropertyChanged(() => AliveItems); |
45 | 31 |
} |
46 | 32 |
} |
47 | 33 |
|
48 | 34 |
private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _FilterConvertSource; |
49 |
|
|
50 | 35 |
public System.Collections.ObjectModel.ObservableCollection<ConvertItem> FilterConvertSource |
51 | 36 |
{ |
52 | 37 |
get => _FilterConvertSource; |
... | ... | |
69 | 54 |
} |
70 | 55 |
} |
71 | 56 |
|
72 |
private bool isLoading; |
|
73 |
|
|
74 |
public bool AliveIsLoading |
|
75 |
{ |
|
76 |
get => isLoading; set |
|
77 |
{ |
|
78 |
if (isLoading != value) |
|
79 |
{ |
|
80 |
isLoading = value; |
|
81 |
OnPropertyChanged(() => AliveIsLoading); |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 | 57 |
|
58 |
private System.Windows.Documents.FlowDocument connectionLog; |
|
87 | 59 |
public System.Windows.Documents.FlowDocument ConnectionLog |
88 | 60 |
{ |
89 | 61 |
get => connectionLog; |
... | ... | |
122 | 94 |
{ |
123 | 95 |
while (IsAcitve) |
124 | 96 |
{ |
125 |
//System.Threading.Thread.Sleep(new TimeSpan(0, 0, 3)); |
|
126 | 97 |
|
127 | 98 |
if (!IsLoading) |
128 | 99 |
{ |
... | ... | |
141 | 112 |
{ |
142 | 113 |
List<ConvertItem> itemsToList = new List<ConvertItem>(); |
143 | 114 |
var items = await client.AliveConvertListAsync(); |
144 |
//int i = 0; |
|
115 |
|
|
145 | 116 |
foreach (var item in items) |
146 | 117 |
{ |
147 | 118 |
ConvertItem itemsToEach = new ConvertItem(); |
148 | 119 |
itemsToEach.ServiceID = item.ServiceID; |
149 | 120 |
itemsToEach.ConvertID = item.ConvertID; |
150 | 121 |
itemsToEach.ProjectNumber = item.ProjectNumber; |
151 |
//itemsToEach.ConvertState = (StatusCodeType.)item.ConvertState;// (StatusCodeType) item.ConvertState; |
|
152 |
itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState); |
|
122 |
try |
|
123 |
{ |
|
124 |
itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState); |
|
125 |
} |
|
126 |
catch (Exception ex) |
|
127 |
{ |
|
128 |
|
|
129 |
throw ex; |
|
130 |
} |
|
131 |
|
|
132 |
//itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState); |
|
153 | 133 |
itemsToEach.CurrentPageNo = item.CurrentPageNo; |
154 | 134 |
itemsToEach.TotalPage = item.TotalPage; |
155 | 135 |
itemsToEach.OriginfilePath = item.OriginfilePath; |
156 | 136 |
itemsToEach.ConvertPath = item.ConvertPath; |
157 | 137 |
|
158 | 138 |
itemsToList.Add(itemsToEach); |
159 |
//i++; |
|
160 | 139 |
} |
161 | 140 |
newitems.AddRange(itemsToList); |
162 |
//System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
|
|
141 |
System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping"); |
|
163 | 142 |
|
164 | 143 |
if (items.Count() == 0) |
165 | 144 |
{ |
166 |
//System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
|
|
145 |
System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero."); |
|
167 | 146 |
} |
168 | 147 |
} |
169 | 148 |
catch (Exception ex) |
170 | 149 |
{ |
171 |
//System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
|
|
150 |
System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}"); |
|
172 | 151 |
} |
173 | 152 |
} |
174 | 153 |
else |
175 | 154 |
{ |
176 |
//System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
|
|
155 |
System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error"); |
|
177 | 156 |
} |
178 | 157 |
} |
179 |
|
|
180 |
// ItemsUpdate(newitems); |
|
181 | 158 |
await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems)); |
182 | 159 |
} |
183 | 160 |
catch (Exception ex) |
... | ... | |
206 | 183 |
{ |
207 | 184 |
List<ConvertItem> itemsToList = new List<ConvertItem>(); |
208 | 185 |
var items = await client.AliveConvertListAsync(); |
209 |
//int i = 0; |
|
210 | 186 |
foreach (var item in items) |
211 | 187 |
{ |
212 | 188 |
ConvertItem itemsToEach = new ConvertItem(); |
213 | 189 |
itemsToEach.ServiceID = item.ServiceID; |
214 | 190 |
itemsToEach.ConvertID = item.ConvertID; |
215 | 191 |
itemsToEach.ProjectNumber = item.ProjectNumber; |
216 |
//itemsToEach.ConvertState = (StatusCodeType.)item.ConvertState;// (StatusCodeType) item.ConvertState; |
|
217 | 192 |
try |
218 | 193 |
{ |
219 | 194 |
itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState); |
... | ... | |
223 | 198 |
|
224 | 199 |
throw ex; |
225 | 200 |
} |
226 |
|
|
201 |
|
|
227 | 202 |
itemsToEach.CurrentPageNo = item.CurrentPageNo; |
228 | 203 |
itemsToEach.TotalPage = item.TotalPage; |
229 | 204 |
itemsToEach.OriginfilePath = item.OriginfilePath; |
230 | 205 |
itemsToEach.ConvertPath = item.ConvertPath; |
231 | 206 |
|
232 | 207 |
itemsToList.Add(itemsToEach); |
233 |
//i++; |
|
234 | 208 |
} |
235 | 209 |
newitems.AddRange(itemsToList); |
236 | 210 |
System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping"); |
... | ... | |
251 | 225 |
} |
252 | 226 |
} |
253 | 227 |
|
254 |
ItemsUpdate(newitems);
|
|
228 |
ItemsUpdate(newitems); |
|
255 | 229 |
await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems)); |
256 | 230 |
} |
257 | 231 |
catch (Exception ex) |
... | ... | |
269 | 243 |
item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath); |
270 | 244 |
} |
271 | 245 |
|
272 |
if (AliveItems == null) |
|
246 |
if (AliveItems == null)
|
|
273 | 247 |
{ |
274 | 248 |
AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>(); |
275 | 249 |
|
... | ... | |
362 | 336 |
return result; |
363 | 337 |
} |
364 | 338 |
|
365 |
//public override void Loaded() |
|
366 |
//{ |
|
367 |
// base.Loaded(); |
|
368 |
|
|
369 |
// if (!App.IsDesignMode) |
|
370 |
// { |
|
371 |
// backgroundWorker = new BackgroundWorker(); |
|
372 |
// backgroundWorker.DoWork += backgroundWorker_DoWork; |
|
373 |
// backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; |
|
374 |
// backgroundWorker.WorkerReportsProgress = false; |
|
375 |
// backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged); |
|
376 |
|
|
377 |
// backgroundWorker.RunWorkerAsync(); |
|
378 |
// } |
|
379 |
//} |
|
380 |
|
|
381 |
//public override void AliveClosed() |
|
382 |
//{ |
|
383 |
// if (backgroundWorker != null) |
|
384 |
// { |
|
385 |
// backgroundWorker.DoWork -= backgroundWorker_DoWork; |
|
386 |
// backgroundWorker.RunWorkerCompleted -= backgroundWorker_RunWorkerCompleted; |
|
387 |
// backgroundWorker.WorkerReportsProgress = false; |
|
388 |
// backgroundWorker.ProgressChanged -= new ProgressChangedEventHandler(backgroundWorker_ProgressChanged); |
|
389 |
|
|
390 |
// backgroundWorker.Dispose(); |
|
391 |
// } |
|
392 |
|
|
393 |
// base.Closed(); |
|
394 |
//} |
|
395 |
//alive |
|
396 |
|
|
397 | 339 |
BackgroundWorker backgroundWorker; |
340 |
private BackgroundWorker AlivebackgroundWorker; |
|
398 | 341 |
|
399 | 342 |
Random rnd = new Random(); |
400 | 343 |
|
401 |
private ConvertItem _SelectRealConvert; |
|
402 |
private ConvertItem _SelectFilterConvert; |
|
403 |
|
|
404 |
private StatusTypeList _StatusType; |
|
405 |
private bool _IsLoading; |
|
406 |
|
|
407 | 344 |
private Telerik.Windows.Data.EnumMemberViewModel _SelectedStatus; |
408 |
|
|
409 | 345 |
public Telerik.Windows.Data.EnumMemberViewModel SelectedStatus |
410 | 346 |
{ |
411 | 347 |
get => _SelectedStatus; |
412 | 348 |
set |
413 | 349 |
{ |
414 | 350 |
_SelectedStatus = value; |
415 |
OnPropertyChanged(()=> SelectedStatus); |
|
351 |
OnPropertyChanged(() => SelectedStatus);
|
|
416 | 352 |
} |
417 | 353 |
} |
418 | 354 |
|
419 | 355 |
|
420 | 356 |
private SelectedCountItem _SelectedCount; |
421 |
|
|
422 | 357 |
public SelectedCountItem SelectedCount |
423 | 358 |
{ |
424 | 359 |
get => _SelectedCount; |
... | ... | |
429 | 364 |
} |
430 | 365 |
} |
431 | 366 |
|
432 |
|
|
433 |
public DelegateCommand ConvertCommand { get; private set; } |
|
434 |
public DelegateCommand DeleteCommand { get; private set; } |
|
435 |
public DelegateCommand ValidateCommand { get; private set; } |
|
436 |
|
|
437 |
|
|
438 | 367 |
private void DataConvert(object obj) |
439 | 368 |
{ |
440 | 369 |
if (SelectFilterConvert == null && SelectRealConvert == null) |
... | ... | |
449 | 378 |
|
450 | 379 |
if (SelectRealConvert != null) |
451 | 380 |
{ |
452 |
/*resultRealConvert = _DataConvert.SetCleanUpItem(SelectRealConvert.ConvertID, SelectRealConvert.ReConverter);*/ |
|
453 | 381 |
resultRealConvert = _DataConvert.SetCleanUpItem(SelectRealConvert); |
454 | 382 |
} |
455 | 383 |
else if (SelectFilterConvert != null) |
456 | 384 |
{ |
457 |
//resultFiltertConvert = _DataConvert.SetCleanUpItem(SelectFilterConvert.ConvertID, SelectFilterConvert.ReConverter); |
|
458 | 385 |
resultFiltertConvert = _DataConvert.SetCleanUpItem(SelectFilterConvert); |
459 | 386 |
} |
460 | 387 |
System.Diagnostics.Debug.WriteLine(resultRealConvert + " " + resultFiltertConvert); |
... | ... | |
495 | 422 |
} |
496 | 423 |
|
497 | 424 |
|
498 |
|
|
425 |
private ConvertItem _SelectFilterConvert; |
|
499 | 426 |
public ConvertItem SelectFilterConvert |
500 | 427 |
{ |
501 | 428 |
get => _SelectFilterConvert; |
... | ... | |
505 | 432 |
OnPropertyChanged(() => SelectFilterConvert); |
506 | 433 |
} |
507 | 434 |
} |
435 |
|
|
436 |
private ConvertItem _SelectRealConvert; |
|
508 | 437 |
public ConvertItem SelectRealConvert |
509 | 438 |
{ |
510 | 439 |
get => _SelectRealConvert; |
... | ... | |
515 | 444 |
} |
516 | 445 |
} |
517 | 446 |
|
447 |
|
|
448 |
private StatusTypeList _StatusType; |
|
518 | 449 |
public StatusTypeList StatusType |
519 | 450 |
{ |
520 | 451 |
get => _StatusType; |
... | ... | |
525 | 456 |
} |
526 | 457 |
} |
527 | 458 |
|
459 |
private bool _IsLoading; |
|
528 | 460 |
public bool IsLoading |
529 | 461 |
{ |
530 | 462 |
get => _IsLoading; |
... | ... | |
539 | 471 |
} |
540 | 472 |
|
541 | 473 |
List<SelectedCountItem> _SelectedCountList; |
542 |
|
|
543 | 474 |
public List<SelectedCountItem> SelectedCountList |
544 | 475 |
{ |
545 | 476 |
get |
... | ... | |
559 | 490 |
} |
560 | 491 |
} |
561 | 492 |
|
493 |
public DelegateCommand ConvertCommand { get; private set; } |
|
494 |
public DelegateCommand DeleteCommand { get; private set; } |
|
495 |
public DelegateCommand ValidateCommand { get; private set; } |
|
496 |
|
|
562 | 497 |
public DataBaseItemsModel() |
563 | 498 |
{ |
564 |
|
|
565 |
DataSaveFileGemBoxCommand = new DelegateCommand(DataExport); |
|
499 |
DataSaveFileGemBoxCommand = new DelegateCommand(DataExportData); |
|
566 | 500 |
ConvertCommand = new DelegateCommand(DataConvert); |
567 | 501 |
DeleteCommand = new DelegateCommand(DataDelete); |
568 | 502 |
ValidateCommand = new DelegateCommand(DataValidate); |
569 |
//Loaded(); |
|
570 | 503 |
} |
571 | 504 |
|
572 | 505 |
// 진행률에 변화가 있을때 이벤트가 발생 |
... | ... | |
582 | 515 |
} |
583 | 516 |
|
584 | 517 |
IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> _StatusCodeList; |
585 |
|
|
586 | 518 |
public IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> StatusCodeList |
587 | 519 |
{ |
588 | 520 |
get |
... | ... | |
598 | 530 |
// BackgroundWorker에서 수행할 일을 정의. |
599 | 531 |
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) |
600 | 532 |
{ |
601 |
|
|
533 |
|
|
602 | 534 |
while (IsAcitve) |
603 | 535 |
{ |
604 | 536 |
|
... | ... | |
623 | 555 |
} |
624 | 556 |
} |
625 | 557 |
|
626 |
System.Windows.Threading.DispatcherTimer DispatcherTimer = new System.Windows.Threading.DispatcherTimer(); |
|
627 | 558 |
|
628 | 559 |
|
629 | 560 |
private void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection) |
630 | 561 |
{ |
631 |
|
|
632 | 562 |
try |
633 | 563 |
{ |
634 | 564 |
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString)) |
635 | 565 |
{ |
636 |
|
|
637 |
|
|
638 |
|
|
639 |
//var items = database.GetConvertProjects(x => statusCodeTypeList.Count(y => (int)y == x.STATUS) > 0)//x:database객체 y:statusCodeTypeList의값 Count()안에 predicator 조건 만족하면 count개수안에 넣음 |
|
640 |
// .OrderByDescending(x => x.CreateTime).Take(SelectedCount.ValueMember).ToList(); |
|
641 |
|
|
642 |
//var items = database.GetConvertProjects(x => statusCodeTypeList.Count(y => ((int)y).ToString() == x.ConvertState) > 0)//x:database객체 y:statusCodeTypeList의값 Count()안에 predicator 조건 만족하면 count개수안에 넣음 |
|
643 |
// .OrderByDescending(x => x.CreateTime).Take(SelectedCount.ValueMember).ToList(); |
|
644 |
//int _status = 0; |
|
645 |
//if (SelectedStatus != null) |
|
646 |
//{ |
|
647 |
// _status = (int)SelectedStatus.Value; |
|
648 |
//} |
|
649 |
|
|
650 | 566 |
var items = database.GetConvertProjects(collection)//x:database객체 y:statusCodeTypeList의값 Count()안에 predicator 조건 만족하면 count개수안에 넣음 |
651 | 567 |
.Take(SelectedCount.ValueMember).ToList();// |
652 | 568 |
|
653 |
//if (statusCodeTypeList.Count() == 4) |
|
654 |
//{ |
|
655 |
// items.Clear(); |
|
656 |
|
|
657 |
// //items = database.GetConvertProjects(x => statusCodeTypeList.Count(y => (int)y == x.STATUS) > 0)//연습용 |
|
658 |
// // .OrderByDescending(x => x.CreateTime).Take(SelectedCount.ValueMember).ToList();//실행시킨 날 보다 createtime이 최신 일때 |
|
659 |
|
|
660 |
// //items = database.GetConvertProjects(x => DateTime.Compare(x.CREATE_DATETIME, now) > 0 && statusCodeTypeList.Count(y => (int)y == x.STATUS) > 0) |
|
661 |
// // .OrderByDescending(x => x.CreateTime).Take(SelectedCount.ValueMember).ToList();//실행시킨 날 보다 createtime이 최신 일때 |
|
662 |
|
|
663 |
// items = database.GetConvertProjects(x => DateTime.Compare(x.CreateTime, now) > 0 , _status)//statusCodeTypeList.Count(y => ((int)y).ToString() == x.ConvertState) > 0 |
|
664 |
// .Take(SelectedCount.ValueMember).ToList(); //아래그리드는 양이 적어서 원래 대로 해도 됨 |
|
665 |
//} |
|
666 |
//if (collection.Count() == 0) |
|
667 |
//{ |
|
668 |
// if (statusCodeTypeList.Count() == 1) |
|
669 |
// { |
|
670 |
// items.ForEach(x => collection.Add(x)); |
|
671 |
// } |
|
672 |
//} |
|
673 |
|
|
674 |
//else |
|
675 |
//{ |
|
676 |
////세미 업데이트 |
|
677 | 569 |
items.ForEach(newitem => |
678 | 570 |
{ |
679 | 571 |
collection.UpdateWhere(changeitem => |
680 | 572 |
ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ConvertID == newitem.ConvertID && x.ProjectNumber == newitem.ProjectNumber); |
681 | 573 |
}); |
682 |
|
|
683 |
|
|
684 |
//if (statusCodeTypeList.Count() == 1) |
|
685 |
//{ |
|
686 |
// //추가 convert 후 추가됨 |
|
687 |
// foreach (var item in items) |
|
688 |
// { |
|
689 |
// if (collection.Count(x => x.DocumentID == item.DocumentID && x.ProjectNumber == item.ProjectNumber) == 0)//그리드와 디비 변동 없으면 안들어감 |
|
690 |
// { |
|
691 |
// for (int i = 0; i < collection.Count() - 1; i++)//위 그리드에서 카운드 개수 변함 없고 컨버터 끝난 후 추가할때 createtime 비교 하며 order by 순으로 추가 |
|
692 |
// { |
|
693 |
// if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0) |
|
694 |
// { |
|
695 |
// collection.Insert(i, item); |
|
696 |
// } |
|
697 |
// } |
|
698 |
// } |
|
699 |
|
|
700 |
// } |
|
701 |
//} |
|
702 |
|
|
703 |
//if (statusCodeTypeList.Count() == 1) |
|
704 |
//{ |
|
705 |
// //추가 convert 후 추가됨 |
|
706 |
// foreach (var item in items) |
|
707 |
// { |
|
708 |
// if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)//그리드와 디비 변동 없으면 안들어감 |
|
709 |
// { |
|
710 |
// for (int i = 0; i < collection.Count() - 1; i++)//위 그리드에서 카운드 개수 변함 없고 컨버터 끝난 후 추가할때 createtime 비교 하며 order by 순으로 추가 |
|
711 |
// { |
|
712 |
// if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0) |
|
713 |
// { |
|
714 |
// collection.Insert(i, item); |
|
715 |
// } |
|
716 |
// } |
|
717 |
// } |
|
718 |
|
|
719 |
// } |
|
720 |
//} |
|
721 |
|
|
722 |
//} |
|
723 | 574 |
} |
724 |
|
|
725 | 575 |
} |
726 | 576 |
catch (Exception ex) |
727 | 577 |
{ |
728 | 578 |
MessageBox.Show(ex.ToString()); |
729 | 579 |
} |
730 |
|
|
731 |
|
|
732 | 580 |
} |
733 |
|
|
734 | 581 |
//<>쓸때는 IEnumerable |
735 | 582 |
|
736 | 583 |
private void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection) |
737 | 584 |
{ |
738 |
|
|
739 | 585 |
try |
740 | 586 |
{ |
741 | 587 |
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString)) |
742 | 588 |
{ |
743 | 589 |
|
744 |
|
|
745 |
|
|
746 |
//var items = database.GetConvertProjects(x => statusCodeTypeList.Count(y => (int)y == x.STATUS) > 0)//x:database객체 y:statusCodeTypeList의값 Count()안에 predicator 조건 만족하면 count개수안에 넣음 |
|
747 |
// .OrderByDescending(x => x.CreateTime).Take(SelectedCount.ValueMember).ToList(); |
|
748 |
|
|
749 |
//var items = database.GetConvertProjects(x => statusCodeTypeList.Count(y => ((int)y).ToString() == x.ConvertState) > 0)//x:database객체 y:statusCodeTypeList의값 Count()안에 predicator 조건 만족하면 count개수안에 넣음 |
|
750 |
// .OrderByDescending(x => x.CreateTime).Take(SelectedCount.ValueMember).ToList(); |
|
751 | 590 |
int _status = 0; |
752 | 591 |
if (SelectedStatus != null) |
753 | 592 |
{ |
... | ... | |
755 | 594 |
} |
756 | 595 |
|
757 | 596 |
var items = database.GetConvertProjects(_status)//x:database객체 y:statusCodeTypeList의값 Count()안에 predicator 조건 만족하면 count개수안에 넣음 |
758 |
.Take(SelectedCount.ValueMember).ToList();// |
|
759 |
|
|
760 |
//if (statusCodeTypeList.Count() == 4) |
|
761 |
//{ |
|
762 |
// items.Clear(); |
|
763 |
|
|
764 |
// //items = database.GetConvertProjects(x => statusCodeTypeList.Count(y => (int)y == x.STATUS) > 0)//연습용 |
|
765 |
// // .OrderByDescending(x => x.CreateTime).Take(SelectedCount.ValueMember).ToList();//실행시킨 날 보다 createtime이 최신 일때 |
|
597 |
.Take(SelectedCount.ValueMember).ToList(); |
|
766 | 598 |
|
767 |
// //items = database.GetConvertProjects(x => DateTime.Compare(x.CREATE_DATETIME, now) > 0 && statusCodeTypeList.Count(y => (int)y == x.STATUS) > 0) |
|
768 |
// // .OrderByDescending(x => x.CreateTime).Take(SelectedCount.ValueMember).ToList();//실행시킨 날 보다 createtime이 최신 일때 |
|
769 |
|
|
770 |
// items = database.GetConvertProjects(x => DateTime.Compare(x.CreateTime, now) > 0 , _status)//statusCodeTypeList.Count(y => ((int)y).ToString() == x.ConvertState) > 0 |
|
771 |
// .Take(SelectedCount.ValueMember).ToList(); //아래그리드는 양이 적어서 원래 대로 해도 됨 |
|
772 |
//} |
|
773 | 599 |
if (collection.Count() == 0) |
774 | 600 |
{ |
775 | 601 |
if (statusCodeTypeList.Count() == 1) |
... | ... | |
777 | 603 |
items.ForEach(x => collection.Add(x)); |
778 | 604 |
} |
779 | 605 |
} |
780 |
|
|
781 | 606 |
else |
782 | 607 |
{ |
783 |
////세미 업데이트 |
|
784 |
//items.ForEach(newitem => |
|
785 |
//{ |
|
786 |
// collection.UpdateWhere(changeitem => |
|
787 |
// ConvertItemEx.ChangeValues(changeitem, newitem), x => x.DocumentID == newitem.DocumentID && x.ProjectNumber == newitem.ProjectNumber); |
|
788 |
//}); |
|
789 | 608 |
|
790 | 609 |
////세미 업데이트 |
791 | 610 |
items.ForEach(newitem => |
... | ... | |
794 | 613 |
ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID); |
795 | 614 |
}); |
796 | 615 |
|
797 |
//if (statusCodeTypeList.Count() == 1) |
|
798 |
//{ |
|
799 |
// //삭제 |
|
800 |
// for (int i = collection.Count() - 1; i >= 0; --i) |
|
801 |
// { |
|
802 |
// var item = collection[i]; |
|
803 |
|
|
804 |
// if (items.Count(x => x.DocumentID == item.DocumentID && x.ProjectNumber == item.ProjectNumber) == 0)//디비에서 가져온 값과 마지막값부터 차례대로 비교 |
|
805 |
// {//참=> 0제외한 모든 수 |
|
806 |
// collection.RemoveAt(i); |
|
807 |
// } |
|
808 |
// } |
|
809 |
//} |
|
810 |
|
|
811 |
//if (statusCodeTypeList.Count() == 1) |
|
812 |
//{ |
|
813 |
// //추가 convert 후 추가됨 |
|
814 |
// foreach (var item in items) |
|
815 |
// { |
|
816 |
// if (collection.Count(x => x.DocumentID == item.DocumentID && x.ProjectNumber == item.ProjectNumber) == 0)//그리드와 디비 변동 없으면 안들어감 |
|
817 |
// { |
|
818 |
// for (int i = 0; i < collection.Count() - 1; i++)//위 그리드에서 카운드 개수 변함 없고 컨버터 끝난 후 추가할때 createtime 비교 하며 order by 순으로 추가 |
|
819 |
// { |
|
820 |
// if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0) |
|
821 |
// { |
|
822 |
// collection.Insert(i, item); |
|
823 |
// } |
|
824 |
// } |
|
825 |
// } |
|
826 |
|
|
827 |
// } |
|
828 |
//} |
|
829 | 616 |
|
830 | 617 |
if (statusCodeTypeList.Count() == 1) |
831 | 618 |
{ |
... | ... | |
878 | 665 |
catch (Exception ex) |
879 | 666 |
{ |
880 | 667 |
MessageBox.Show(ex.ToString()); |
881 |
//System.Diagnostics.Debug.WriteLine(ex.ToString()); |
|
882 | 668 |
} |
883 |
|
|
884 |
|
|
885 | 669 |
} |
886 | 670 |
|
887 |
|
|
888 | 671 |
public override void Loaded() |
889 | 672 |
{ |
890 | 673 |
base.Loaded(); |
... | ... | |
932 | 715 |
|
933 | 716 |
|
934 | 717 |
public DelegateCommand DataSaveFileGemBoxCommand { get; private set; } |
935 |
|
|
936 |
public class HeaderMember |
|
718 |
public void DataExportData(object obj) |
|
937 | 719 |
{ |
938 |
public string HeaderName { get; set; }
|
|
939 |
public string Property { get; set; }
|
|
720 |
DataExport dataExport = new DataExport();
|
|
721 |
dataExport.DataExportData(FilterConvertSource);
|
|
940 | 722 |
} |
941 |
//public void DataExport<T>(IEnumerable<T> AliveItems) |
|
942 |
public void DataExport(object obj) |
|
943 |
{ |
|
944 |
SaveFileDialog saveFileDialog = new SaveFileDialog(); |
|
945 |
|
|
946 |
saveFileDialog.FileName = "Document"; // Default file name |
|
947 |
saveFileDialog.DefaultExt = ".txt"; // Default file extension |
|
948 |
saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension |
|
949 | 723 |
|
724 |
public class SelectedCountItem : INotifyPropertyChanged |
|
725 |
{ |
|
726 |
public event PropertyChangedEventHandler PropertyChanged; |
|
950 | 727 |
|
951 |
if (saveFileDialog.ShowDialog() == true)
|
|
728 |
private void NotifyPropertyChanged(String info)
|
|
952 | 729 |
{ |
953 |
|
|
954 |
|
|
955 |
if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName)) |
|
730 |
if (PropertyChanged != null) |
|
956 | 731 |
{ |
957 |
|
|
958 |
var extension = new System.IO.FileInfo(saveFileDialog.FileName).Extension; |
|
959 |
|
|
960 |
if (extension == ".xlsx" || extension == ".csv") |
|
961 |
{ |
|
962 |
|
|
963 |
var headers = new List<HeaderMember> |
|
964 |
{ |
|
965 |
new HeaderMember{HeaderName = "ServiceID", Property = "ServiceID" }, |
|
966 |
new HeaderMember{HeaderName = "ConvertID", Property = "ConvertID" }, |
|
967 |
new HeaderMember{HeaderName = "ProjectNumber", Property = "ProjectNumber" }, |
|
968 |
new HeaderMember{HeaderName = "ConvertState", Property = "ConvertState" }, |
|
969 |
new HeaderMember{HeaderName = "CurrentPageNo", Property = "CurrentPageNo" }, |
|
970 |
new HeaderMember{HeaderName = "TotalPage", Property = "TotalPage" }, |
|
971 |
new HeaderMember{HeaderName = "OriginfilePath", Property = "OriginfilePath" }, |
|
972 |
new HeaderMember{HeaderName = "ConvertPath", Property = "ConvertPath" }, |
|
973 |
new HeaderMember{HeaderName = "CreateTime", Property = "CreateTime" }, |
|
974 |
new HeaderMember{HeaderName = "Exception", Property = "Exception" }, |
|
975 |
new HeaderMember{HeaderName = "ProcessorAffinity", Property = "ProcessorAffinity" }, |
|
976 |
new HeaderMember{HeaderName = "ReConverter", Property = "ReConverter" }, |
|
977 |
new HeaderMember{HeaderName = "UniqueKey", Property = "UniqueKey" } |
|
978 |
}; |
|
979 |
|
|
980 |
|
|
981 |
|
|
982 |
DataExportExcel(saveFileDialog.FileName, "Hello world", FilterConvertSource, headers); |
|
983 |
//_dataExport.DataExportExcel(saveFileDialog.FileName, saveFileDialog.FileName.ToString(), Projectsource, headers); |
|
984 |
//GemBoxFileSave(obj); |
|
985 |
} |
|
732 |
PropertyChanged(this, new PropertyChangedEventArgs(info)); |
|
986 | 733 |
} |
987 | 734 |
} |
988 |
} |
|
989 | 735 |
|
736 |
//public string DisplayMember { get; set; } |
|
737 |
public string _DisplayMember; |
|
990 | 738 |
|
991 |
public void DataExportExcel<T>(string SaveFile, string SheetName, IEnumerable<T> collections, List<HeaderMember> headerMembers) |
|
992 |
{ |
|
993 |
|
|
994 |
try |
|
739 |
public string DisplayMember |
|
995 | 740 |
{ |
996 |
SpreadsheetInfo.SetLicense("EXK0-W4HZ-N518-IMEW"); |
|
997 |
// SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");//프리버전은 15줄까지만 가능 |
|
998 |
|
|
999 |
var workbook = new ExcelFile(); |
|
1000 |
var worksheet = workbook.Worksheets.Add(SheetName); |
|
1001 |
|
|
1002 |
// IEnumerable<T> collections를 for문 |
|
1003 |
for (int rowNumber = 0; rowNumber < collections.Count(); rowNumber++)//1857 양이 너무 많아서 빨리 엑셀출력 누르면 숫자가 감소됨 차분히 기다리면 숫자 늘어남 |
|
741 |
get => _DisplayMember; |
|
742 |
set |
|
1004 | 743 |
{ |
1005 |
// index에 해당하는 row를 가져온다. |
|
1006 |
object row = collections.ElementAt(rowNumber);//우왕좌왕하게 모든 프로퍼티 있음 생성자 프로퍼티도 있음 |
|
1007 |
|
|
1008 |
//row의 properties를 가져옴. |
|
1009 |
var rowPropInfos = row.GetType().GetProperties();//행렬로 보기좋게 프로퍼티 나옴 |
|
744 |
_DisplayMember = value; |
|
1010 | 745 |
|
1011 |
/// 지정된 header에 대해서 프로퍼티에 해당하는 값을 가져와서 cell에 출력 |
|
1012 |
for (int i = 0; i < headerMembers.Count(); i++)//13 |
|
1013 |
{ |
|
1014 |
var prop = rowPropInfos.Where(x => x.Name == headerMembers[i].Property);//prop 0으로 나옴 |
|
1015 |
if (headerMembers[i].Property == "CreateTime") |
|
1016 |
{ |
|
1017 |
worksheet.Cells[rowNumber + 1, i].Value = prop.First().GetValue(row).ToString(); |
|
1018 |
} |
|
1019 |
else if (prop.Count() > 0) |
|
1020 |
{ |
|
1021 |
worksheet.Cells[rowNumber + 1, i].Value = prop.First().GetValue(row); |
|
1022 |
} |
|
1023 |
} |
|
746 |
NotifyPropertyChanged("DisplayMember"); |
|
1024 | 747 |
} |
1025 |
|
|
1026 |
int k = 0; |
|
1027 |
foreach (var HeadInfo in headerMembers) |
|
1028 |
{ |
|
1029 |
worksheet.Cells[0, k].Value = HeadInfo.HeaderName; |
|
1030 |
k++; |
|
1031 |
} |
|
1032 |
|
|
1033 |
int columnCount = worksheet.CalculateMaxUsedColumns(); |
|
1034 |
for (int i = 0; i < columnCount; i++) |
|
1035 |
{ |
|
1036 |
worksheet.Columns[i].AutoFit(); |
|
1037 |
} |
|
1038 |
|
|
1039 |
|
|
1040 |
|
|
1041 |
var header = new CellStyle();//헤더 |
|
1042 |
|
|
1043 |
header.FillPattern.SetSolid(SpreadsheetColor.FromArgb(0, 100, 220)); |
|
1044 |
header.Font.Weight = ExcelFont.BoldWeight; |
|
1045 |
header.HorizontalAlignment = HorizontalAlignmentStyle.Center; |
|
1046 |
header.VerticalAlignment = VerticalAlignmentStyle.Center; |
|
1047 |
//worksheet.Cells.GetSubrange("A1:M1").Style = header; |
|
1048 |
worksheet.Cells.GetSubrangeAbsolute(0, 0, collections.Count(), headerMembers.Count() - 1).Style = header; |
|
1049 |
|
|
1050 |
|
|
1051 |
|
|
1052 |
var style = new CellStyle(); |
|
1053 |
//style.Borders.SetBorders(MultipleBorders.Right | MultipleBorders.Top | MultipleBorders.Left | MultipleBorders.Bottom, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thick);//바깥쪽 border 두껍게 성공 |
|
1054 |
style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thick);//바깥쪽 border 두껍게 성공 |
|
1055 |
|
|
1056 |
|
|
1057 |
|
|
1058 |
style.HorizontalAlignment = HorizontalAlignmentStyle.Center; |
|
1059 |
style.VerticalAlignment = VerticalAlignmentStyle.Center; |
|
1060 |
style.Font.Color = SpreadsheetColor.FromArgb(75, 60, 50);//글자 색갈 |
|
1061 |
style.FillPattern.SetSolid(SpreadsheetColor.FromArgb(126, 239, 239));//cell 색갈 |
|
1062 |
style.Font.Name = "맑은 고딕"; |
|
1063 |
style.Font.Size = 9 * 20; |
|
1064 |
worksheet.Cells.GetSubrangeAbsolute(0, 0, collections.Count(), headerMembers.Count() - 1).Style = style; |
|
1065 |
//worksheet.Cells.GetSubrange("A1:M1858").Style = style; |
|
1066 |
|
|
1067 |
for (int line = 0; line < collections.Count() - 1; line++) //바깥border과 안쪽 얇은 border 같이 쓰면 안됨 |
|
1068 |
{ |
|
1069 |
//for (int j = 0; j < 14 - 1 - 1; j++) |
|
1070 |
for (int j = 0; j < headerMembers.Count() - 1 - 1; j++) |
|
1071 |
{ |
|
1072 |
worksheet.Cells[line + 1, j + 1].Style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin);//안쪽 (1,1) ~ (마지막-1,마지막-1) 가운데 성공 |
|
1073 |
} |
|
1074 |
} |
|
1075 |
|
|
1076 |
|
|
1077 |
for (int line = 0; line < collections.Count(); line++) //바깥border과 안쪽 얇은 border 같이 쓰면 안됨 |
|
1078 |
{//Projectsource.Count() = 761개 ( 0 ~ 760 ) |
|
1079 |
for (int j = 0; j < headerMembers.Count() - 1; j++) |
|
1080 |
{ |
|
1081 |
worksheet.Cells[0, j].Style.Borders.SetBorders(MultipleBorders.Right, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin);//(0,0) ~ (0,마지막-1) 위 성공 |
|
1082 |
|
|
1083 |
worksheet.Cells[collections.Count(), j].Style.Borders.SetBorders(MultipleBorders.Right, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin);//(마지막,0) ~ (마지막,마지막-1) 아래 성공 |
|
1084 |
} |
|
1085 |
|
|
1086 |
worksheet.Cells[line, 0].Style.Borders.SetBorders(MultipleBorders.Bottom, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin);//(0,0) ~ (마지막-1,0) 왼쪽 성공 |
|
1087 |
|
|
1088 |
worksheet.Cells[line, headerMembers.Count() - 1].Style.Borders.SetBorders(MultipleBorders.Bottom, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin);//(0,마지막) ~ (마지막-1,마지막) 오른쪽 성공 |
|
1089 |
|
|
1090 |
} |
|
1091 |
|
|
1092 |
workbook.Save(SaveFile);//파일 열었던 파일로 저장 성공 |
|
1093 |
MessageBox.Show("성공"); |
|
1094 |
} |
|
1095 |
|
|
1096 |
catch (Exception ex) |
|
1097 |
{ |
|
1098 |
Console.WriteLine("예외 발생!! 메세지: {0}", ex.Message); |
|
1099 |
} |
|
1100 |
} |
|
1101 |
|
|
1102 |
} |
|
1103 |
|
|
1104 |
|
|
1105 |
public class SelectedCountItem : INotifyPropertyChanged |
|
1106 |
{ |
|
1107 |
public event PropertyChangedEventHandler PropertyChanged; |
|
1108 |
|
|
1109 |
private void NotifyPropertyChanged(String info) |
|
1110 |
{ |
|
1111 |
if (PropertyChanged != null) |
|
1112 |
{ |
|
1113 |
PropertyChanged(this, new PropertyChangedEventArgs(info)); |
|
1114 | 748 |
} |
1115 |
} |
|
1116 |
|
|
1117 |
//public string DisplayMember { get; set; } |
|
1118 |
public string _DisplayMember; |
|
1119 |
|
|
1120 |
public string DisplayMember |
|
1121 |
{ |
|
1122 |
get => _DisplayMember; |
|
1123 |
set |
|
1124 |
{ |
|
1125 |
_DisplayMember = value; |
|
1126 |
|
|
1127 |
NotifyPropertyChanged("DisplayMember"); |
|
1128 |
} |
|
1129 |
} |
|
1130 |
//public int ValueMember { get; set; } |
|
1131 |
public int _ValueMember; |
|
1132 |
public int ValueMember |
|
1133 |
{ |
|
1134 |
get => _ValueMember; |
|
1135 |
set |
|
749 |
//public int ValueMember { get; set; } |
|
750 |
public int _ValueMember; |
|
751 |
public int ValueMember |
|
1136 | 752 |
{ |
1137 |
_ValueMember = value; |
|
1138 |
NotifyPropertyChanged("ValueMember"); |
|
753 |
get => _ValueMember; |
|
754 |
set |
|
755 |
{ |
|
756 |
_ValueMember = value; |
|
757 |
NotifyPropertyChanged("ValueMember"); |
|
758 |
} |
|
1139 | 759 |
} |
1140 | 760 |
} |
1141 | 761 |
} |
1142 |
|
|
1143 | 762 |
} |
1144 | 763 |
|
1145 |
//public class AliveViewModel : Markus.Mvvm.ToolKit.ViewModelBase |
|
1146 |
//{ |
|
1147 |
// BackgroundWorker backgroundWorker; |
|
1148 |
|
|
1149 |
// private System.Collections.ObjectModel.ObservableCollection<Markus.Service.WcfClient.StationServiceTask.ConvertItem> aliveItems; |
|
1150 |
// private bool isLoading; |
|
1151 |
// private System.Windows.Documents.FlowDocument connectionLog; |
|
1152 |
|
|
1153 |
// public System.Collections.ObjectModel.ObservableCollection<Markus.Service.WcfClient.StationServiceTask.ConvertItem> AliveItems |
|
1154 |
// { |
|
1155 |
// get => aliveItems; set |
|
1156 |
// { |
|
1157 |
// aliveItems = value; |
|
1158 |
// OnPropertyChanged(() => AliveItems); |
|
1159 |
// } |
|
1160 |
// } |
|
1161 |
|
|
1162 |
// public bool IsLoading |
|
1163 |
// { |
|
1164 |
// get => isLoading; set |
|
1165 |
// { |
|
1166 |
// if (isLoading != value) |
|
1167 |
// { |
|
1168 |
// isLoading = value; |
|
1169 |
// OnPropertyChanged(() => IsLoading); |
|
1170 |
// } |
|
1171 |
// } |
|
1172 |
// } |
|
1173 |
|
|
1174 |
|
|
1175 |
// public System.Windows.Documents.FlowDocument ConnectionLog |
|
1176 |
// { |
|
1177 |
// get => connectionLog; |
|
1178 |
// set |
|
1179 |
// { |
|
1180 |
// if (connectionLog != value) |
|
1181 |
// { |
|
1182 |
// connectionLog = value; |
|
1183 |
// OnPropertyChanged(() => ConnectionLog); |
|
1184 |
// } |
|
1185 |
// } |
|
1186 |
// } |
|
1187 |
|
|
1188 |
// public AliveViewModel() |
|
1189 |
// { |
|
1190 |
// } |
|
1191 |
|
|
1192 |
// // 진행률에 변화가 있을때 이벤트가 발생 |
|
1193 |
// private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) |
|
1194 |
// { |
|
1195 |
// } |
|
1196 |
|
|
1197 |
// // 일이 모두 마쳤을때 수행되어야할 코드 |
|
1198 |
// private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) |
|
1199 |
// { |
|
1200 |
// } |
|
1201 |
|
|
1202 |
// // BackgroundWorker에서 수행할 일을 정의. |
|
1203 |
// private async void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) |
|
1204 |
// { |
|
1205 |
// while (IsAcitve) |
|
1206 |
// { |
|
1207 |
// System.Threading.Thread.Sleep(new TimeSpan(0, 0, 3)); |
|
1208 |
|
|
1209 |
// if (!IsLoading) |
|
1210 |
// { |
|
1211 |
// IsLoading = true; |
|
1212 |
|
|
1213 |
// try |
|
1214 |
// { |
|
1215 |
|
|
1216 |
// List<Markus.Service.WcfClient.StationServiceTask.ConvertItem> newitems = new List<Markus.Service.WcfClient.StationServiceTask.ConvertItem>(); |
|
1217 |
|
|
1218 |
// foreach (var client in App.StationClientList) |
|
1219 |
// { |
|
1220 |
// if (await SimplePingAsync(client.Endpoint.Address.ToString())) |
|
1221 |
// { |
|
1222 |
// try |
|
1223 |
// { |
|
1224 |
// Markus.Service.WcfClient.StationServiceTask.ConvertItem[] items = await client.AliveConvertListAsync(); |
|
1225 |
// newitems.AddRange(items); |
|
1226 |
// //System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping"); |
|
1227 |
|
|
1228 |
// if (items.Count() == 0) |
|
1229 |
// { |
|
1230 |
// //System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero."); |
|
1231 |
// } |
|
1232 |
// } |
|
1233 |
// catch (Exception ex) |
|
1234 |
// { |
|
1235 |
// //System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}"); |
|
1236 |
// } |
|
1237 |
// } |
|
1238 |
// else |
|
1239 |
// { |
|
1240 |
// //System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error"); |
|
1241 |
// } |
|
1242 |
// } |
|
1243 |
|
|
1244 |
// await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems)); |
|
1245 |
// } |
|
1246 |
// catch (Exception ex) |
|
1247 |
// { |
|
1248 |
// System.Diagnostics.Debug.WriteLine(ex.ToString()); |
|
1249 |
// } |
|
1250 |
|
|
1251 |
// IsLoading = false; |
|
1252 |
// } |
|
1253 |
|
|
1254 |
// } |
|
1255 |
// } |
|
1256 |
|
|
1257 |
|
|
1258 |
|
|
1259 |
// private void ItemsUpdate(List<Markus.Service.WcfClient.StationServiceTask.ConvertItem> newitems) |
|
1260 |
// { |
|
1261 |
|
|
1262 |
// foreach (var item in newitems) |
|
1263 |
// { |
|
1264 |
// item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath); |
|
1265 |
// } |
|
1266 |
|
|
1267 |
// if (AliveItems == null) |
|
1268 |
// { |
|
1269 |
// AliveItems = new System.Collections.ObjectModel.ObservableCollection<Markus.Service.WcfClient.StationServiceTask.ConvertItem>(); |
|
1270 |
|
|
1271 |
// foreach (var item in newitems) |
|
1272 |
// { |
|
1273 |
// AliveItems.Add(item); |
|
1274 |
// } |
|
1275 |
// } |
|
1276 |
// else |
|
1277 |
// { |
|
1278 |
// /// 데이터 업데이트 |
|
1279 |
// newitems.ForEach(newitem => |
|
1280 |
// { |
|
1281 |
// AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID); |
|
1282 |
// }); |
|
1283 |
|
|
1284 |
// // 추가 |
|
1285 |
// foreach (var item in newitems) |
|
1286 |
// { |
|
1287 |
// if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0) |
|
1288 |
// { |
|
1289 |
// AliveItems.Add(item); |
|
1290 |
// } |
|
1291 |
// } |
|
1292 |
|
|
1293 |
// /// 삭제 |
|
1294 |
|
|
1295 |
// for (int i = AliveItems.Count() - 1; i > -1; --i) |
|
1296 |
// { |
|
1297 |
// var item = AliveItems[i]; |
|
1298 |
|
|
1299 |
// if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0) |
|
1300 |
// { |
|
1301 |
// try |
|
1302 |
// { |
|
1303 |
// AliveItems.RemoveAt(i); |
|
1304 |
// } |
|
1305 |
// catch (Exception ex) |
|
1306 |
// { |
|
1307 |
// System.Diagnostics.Debug.WriteLine(ex.ToString()); |
|
1308 |
// } |
|
1309 |
// } |
|
1310 |
// } |
|
1311 |
// } |
|
1312 |
// } |
|
1313 |
|
|
1314 |
// private void LogWrite(string log, bool IsError) |
|
1315 |
// { |
|
1316 |
// if (IsError) |
|
1317 |
// { |
|
1318 |
// //System.Diagnostics.Trace.Fail(log); |
|
1319 |
// } |
|
1320 |
// else |
|
1321 |
// { |
|
1322 |
// //System.Diagnostics.Trace.TraceInformation(log); |
|
1323 |
// } |
|
1324 |
// } |
|
1325 |
|
|
1326 |
|
|
1327 |
// public static async Task<bool> SimplePingAsync(string uri) |
|
1328 |
// { |
|
1329 |
// bool result = false; |
|
1330 |
|
|
1331 |
// try |
|
1332 |
// { |
|
1333 |
// using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient()) |
|
1334 |
// { |
|
1335 |
// Client.Timeout = new TimeSpan(0, 0, 60); |
|
1336 |
|
|
1337 |
// var message = await Client.GetAsync(uri); |
|
1338 |
|
|
1339 |
// System.Net.HttpStatusCode StatusCode = message.StatusCode; |
|
1340 |
|
|
1341 |
// switch (StatusCode) |
|
1342 |
// { |
|
1343 |
|
|
1344 |
// case System.Net.HttpStatusCode.Accepted: |
|
1345 |
// case System.Net.HttpStatusCode.OK: |
|
1346 |
// result = true; |
|
1347 |
// break; |
|
1348 |
// } |
|
1349 |
// } |
|
1350 |
// } |
|
1351 |
// catch (Exception ex) |
|
1352 |
// { |
|
1353 |
// result = false; |
|
1354 |
// System.Diagnostics.Debug.WriteLine(ex.ToString()); |
|
1355 |
// } |
|
1356 |
|
|
1357 |
// return result; |
|
1358 |
// } |
|
1359 |
|
|
1360 |
// public override void Loaded() |
|
1361 |
// { |
|
1362 |
// base.Loaded(); |
|
1363 |
|
|
1364 |
// if (!App.IsDesignMode) |
|
1365 |
// { |
|
1366 |
// backgroundWorker = new BackgroundWorker(); |
|
1367 |
// backgroundWorker.DoWork += backgroundWorker_DoWork; |
|
1368 |
// backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; |
|
1369 |
// backgroundWorker.WorkerReportsProgress = false; |
|
1370 |
// backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged); |
|
1371 |
|
|
1372 |
// backgroundWorker.RunWorkerAsync(); |
|
1373 |
// } |
|
1374 |
// } |
|
1375 |
|
|
1376 |
// public override void Closed() |
|
1377 |
// { |
|
1378 |
// if (backgroundWorker != null) |
|
1379 |
// { |
|
1380 |
// backgroundWorker.DoWork -= backgroundWorker_DoWork; |
|
1381 |
// backgroundWorker.RunWorkerCompleted -= backgroundWorker_RunWorkerCompleted; |
|
1382 |
// backgroundWorker.WorkerReportsProgress = false; |
|
1383 |
// backgroundWorker.ProgressChanged -= new ProgressChangedEventHandler(backgroundWorker_ProgressChanged); |
|
1384 |
|
|
1385 |
// backgroundWorker.Dispose(); |
|
1386 |
// } |
|
1387 |
|
|
1388 |
// base.Closed(); |
|
1389 |
// } |
|
1390 |
//} |
ConvertService/ServiceBase/Markus.Service.StationController/Views/DataBaseView.xaml | ||
---|---|---|
12 | 12 |
d:DesignHeight="450" d:DesignWidth="800"> |
13 | 13 |
|
14 | 14 |
<UserControl.Resources> |
15 |
<!--<CollectionViewSource Source="{Binding AliveItems}" x:Key="AliveViewModel"/>--> |
|
16 |
<!--<VM:AliveViewModel x:Key="AliveViewModel" d:IsDataSource="True"/>--> |
|
17 | 15 |
<Style TargetType="{x:Type telerik:GridViewHeaderCell}"> |
18 | 16 |
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
19 | 17 |
<Setter Property="Background" Value="Gray"/> |
내보내기 Unified diff