프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / DataBaseItemsModel.cs @ 30680747

이력 | 보기 | 이력해설 | 다운로드 (56.8 KB)

1
using Markus.Message;
2
using Markus.Service.Extensions;
3
using Markus.Service.StationController.Data;
4
using Markus.Service.StationController.Behaviors;
5
using Markus.Service.StationController.Extensions;
6
using Markus.Service.StationController.Controls;
7
using Microsoft.Win32;
8
using System;
9
using System.Collections.Generic;
10
using System.ComponentModel;
11
using System.Linq;
12
using System.Threading.Tasks;
13
using System.Web;
14
using System.Windows;
15
using Telerik.Windows.Controls;
16
using Telerik.Windows.Data;
17
using ConvertItem = Markus.Service.Interface.ConvertItem;
18
using System.Net;
19
using System.Windows.Threading;
20
using System.Diagnostics;
21
using System.Windows.Input;
22
using Markus.Mvvm.ToolKit;
23
using System.Windows.Data;
24
using System.Windows.Controls;
25
using System.IO;
26
using Newtonsoft.Json;
27

    
28
namespace Markus.Service.StationController.ViewModel
29
{
30
    //세미
31
    public class DataBaseItemsModel : Mvvm.ToolKit.ViewModelBase
32
    {
33
        #region Constructor
34

    
35
        /// <summary>
36
        /// 실행하면 처음 들어가는 부분
37
        /// </summary>
38
        public DataBaseItemsModel()
39
        {
40
            DataFilterCommand = new DelegateCommand(DataFilter);
41
            DataSaveFileGemBoxCommand = new DelegateCommand(DataExportData);
42
            ConvertCommand = new DelegateCommand(DataConvert);
43
            DeleteCommand = new DelegateCommand(DataDelete);
44
            ValidateCommand = new DelegateCommand(DataValidate);
45
            MarkusLinkCommand = new DelegateCommand(MarkusLink);
46
            RemoveCreateTimeFilterCommand = new DelegateCommand(RemoveCreateTimeFilter);
47
            ResetCommand = new DelegateCommand(Reset);
48
            ConverAddCommand = new DelegateCommand(ConverAdd);
49
        }
50

    
51
        #endregion
52

    
53
        #region Properties
54

    
55
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _FilterSearch;
56
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> FilterSearch
57
        {
58
            get
59
            {
60
                if (_FilterSearch == null)
61
                {
62
                    _FilterSearch = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>
63
                    {
64
                        new ConvertItem{ProjectNumber = "Filter Search"}
65
                    };
66
                }
67

    
68
                return _FilterSearch;
69
            }
70
        }
71

    
72
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _AliveItems;
73
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> AliveItems
74
        {
75
            get => _AliveItems;
76
            set
77
            {
78
                _AliveItems = value;
79
                OnPropertyChanged(() => AliveItems);
80
            }
81
        }
82

    
83
        public ICollectionView FilterConvertSourceView
84
        {
85
            get
86
            {
87
                var view = CollectionViewSource.GetDefaultView(FilterConvertSource);
88
                return view;
89
            }
90
        }
91

    
92
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _FilterConvertSource;
93
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> FilterConvertSource
94
        {
95
            get
96
            {
97
                if (_FilterConvertSource == null)
98
                {
99
                    _FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
100
                }
101
                return _FilterConvertSource;
102
            }
103
            set
104
            {
105
                _FilterConvertSource = value;
106
                OnPropertyChanged(() => FilterConvertSource);
107
            }
108
        }
109

    
110

    
111
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _RealConvertSource;
112
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> RealConvertSource
113
        {
114
            get => _RealConvertSource;
115
            set
116
            {
117
                _RealConvertSource = value;
118
                OnPropertyChanged(() => RealConvertSource);
119
            }
120
        }
121

    
122

    
123
        private System.Windows.Documents.FlowDocument connectionLog;
124
        public System.Windows.Documents.FlowDocument ConnectionLog
125
        {
126
            get => connectionLog;
127
            set
128
            {
129
                if (connectionLog != value)
130
                {
131
                    connectionLog = value;
132
                    OnPropertyChanged(() => ConnectionLog);
133
                }
134
            }
135
        }
136

    
137

    
138
        private Telerik.Windows.Data.EnumMemberViewModel _SelectedStatus;
139
        public Telerik.Windows.Data.EnumMemberViewModel SelectedStatus
140
        {
141
            get => _SelectedStatus;
142
            set
143
            {
144
                _SelectedStatus = value;
145
                OnPropertyChanged(() => SelectedStatus);
146
            }
147
        }
148

    
149

    
150
        private SelectedCountItem _SelectedCount;
151
        public SelectedCountItem SelectedCount
152
        {
153
            get => _SelectedCount;
154
            set
155
            {
156
                _SelectedCount = value;
157
                OnPropertyChanged(() => SelectedCount);
158
            }
159
        }
160

    
161
        List<SelectedCountItem> _SelectedCountList;
162
        public List<SelectedCountItem> SelectedCountList
163
        {
164
            get
165
            {
166
                if (_SelectedCountList == null)
167
                {
168
                    _SelectedCountList = new List<SelectedCountItem>
169
                    {
170
                        new SelectedCountItem{DisplayMember = "50",ValueMember = 50},
171
                        new SelectedCountItem{DisplayMember = "100",ValueMember = 100},
172
                        new SelectedCountItem{DisplayMember = "150",ValueMember = 150},
173
                        new SelectedCountItem{DisplayMember = "200",ValueMember = 200}
174
                    };
175
                }
176

    
177
                return _SelectedCountList;
178
            }
179
        }
180

    
181
        private ConvertItem _SelectFilterConvert;
182
        public ConvertItem SelectFilterConvert
183
        {
184
            get => _SelectFilterConvert;
185
            set
186
            {
187
                _SelectFilterConvert = value;
188
                OnPropertyChanged(() => SelectFilterConvert);
189
            }
190
        }
191

    
192
        private ConvertItem _SelectRealConvert;
193
        public ConvertItem SelectRealConvert
194
        {
195
            get => _SelectRealConvert;
196
            set
197
            {
198
                _SelectRealConvert = value;
199
                OnPropertyChanged(() => SelectRealConvert);
200
            }
201
        }
202

    
203

    
204
        private ConvertItem _SelectAliveConvert;
205
        public ConvertItem SelectAliveConvert
206
        {
207
            get => _SelectAliveConvert;
208
            set
209
            {
210
                _SelectAliveConvert = value;
211
                OnPropertyChanged(() => SelectAliveConvert);
212
            }
213
        }
214

    
215

    
216
        private StatusTypeList _StatusType;
217
        public StatusTypeList StatusType
218
        {
219
            get => _StatusType;
220
            set
221
            {
222
                _StatusType = value;
223
                OnPropertyChanged(() => StatusType);
224
            }
225
        }
226

    
227
        private bool _IsLoading;
228
        public bool IsLoading
229
        {
230
            get => _IsLoading;
231
            set
232
            {
233
                if (_IsLoading != value)
234
                {
235
                    _IsLoading = value;
236
                    OnPropertyChanged(() => IsLoading);
237
                }
238
            }
239
        }
240

    
241
        IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> _StatusCodeList;
242
        public IEnumerable<Telerik.Windows.Data.EnumMemberViewModel> StatusCodeList
243
        {
244
            get
245
            {
246
                if (_StatusCodeList == null)
247
                {
248
                    _StatusCodeList = Telerik.Windows.Data.EnumDataSource.FromType<StatusCodeType>();
249
                }
250

    
251
                return _StatusCodeList;
252
            }
253
        }
254

    
255
        public string _ProjectNumberFilter;
256
        public string ProjectNumberFilter
257
        {
258
            get { return _ProjectNumberFilter; }
259
            set
260
            {
261
                if (_ProjectNumberFilter == "")
262
                {
263
                    _ProjectNumberFilter = null;
264
                }
265
                else if (_ProjectNumberFilter != value)
266
                {
267
                    _ProjectNumberFilter = value;
268
                    OnPropertyChanged(() => ProjectNumberFilter);
269
                }
270
            }
271
        }
272

    
273
        public string _UniqueKeyFilter;
274
        public string UniqueKeyFilter
275
        {
276
            get
277
            {
278
                return _UniqueKeyFilter;
279
            }
280
            set
281
            {
282
                if (_UniqueKeyFilter == "")
283
                {
284
                    _UniqueKeyFilter = null;
285
                }
286
                else if (_UniqueKeyFilter != value)
287
                {
288
                    _UniqueKeyFilter = value;
289
                    OnPropertyChanged(() => UniqueKeyFilter);
290
                }
291
            }
292
        }
293

    
294
        public StatusCodeType _ConvertStateFilter;
295
        public StatusCodeType ConvertStateFilter
296
        {
297
            get { return _ConvertStateFilter; }
298
            set
299
            {
300
                if (_ConvertStateFilter != value)
301
                {
302
                    _ConvertStateFilter = value;
303
                    OnPropertyChanged(() => ConvertStateFilter);
304
                }
305
            }
306
        }
307

    
308
        public string _Docuemnt_NOFilter;
309
        public string Docuemnt_NOFilter
310
        {
311
            get { return _Docuemnt_NOFilter; }
312
            set
313
            {
314
                if (_Docuemnt_NOFilter == "")
315
                {
316
                    _Docuemnt_NOFilter = null;
317
                }
318
                else if (_Docuemnt_NOFilter != value)
319
                {
320
                    _Docuemnt_NOFilter = value;
321
                    OnPropertyChanged(() => Docuemnt_NOFilter);
322
                }
323
            }
324
        }
325

    
326
        public string _Document_NameFilter;
327
        public string Document_NameFilter
328
        {
329
            get { return _Document_NameFilter; }
330
            set
331
            {
332
                if (_Document_NameFilter == "")
333
                {
334
                    _Document_NameFilter = null;
335
                }
336
                else if (_Document_NameFilter != value)
337
                {
338
                    _Document_NameFilter = value;
339
                    OnPropertyChanged(() => Document_NameFilter);
340
                }
341
            }
342
        }
343

    
344
        public int? _ReconverterFilter = 0;
345
        public int? ReconverterFilter
346
        {
347
            get { return _ReconverterFilter; }
348
            set
349
            {
350
                if (_ReconverterFilter == null)
351
                {
352
                    _ReconverterFilter = 0;
353
                }
354
                else if (_ReconverterFilter != value)
355
                {
356
                    _ReconverterFilter = value;
357
                    OnPropertyChanged(() => ReconverterFilter);
358

    
359
                }
360
            }
361
        }
362

    
363
        public string _Service_IDFilter;
364
        public string Service_IDFilter
365
        {
366
            get { return _Service_IDFilter; }
367
            set
368
            {
369
                if (_Service_IDFilter == "")
370
                {
371
                    _Service_IDFilter = null;
372
                }
373
                else if (_Service_IDFilter != value)
374
                {
375
                    _Service_IDFilter = value;
376
                    OnPropertyChanged(() => Service_IDFilter);
377
                }
378
            }
379
        }
380

    
381
        public string _RevisionFilter;
382
        public string RevisionFilter
383
        {
384
            get { return _RevisionFilter; }
385
            set
386
            {
387
                if (_RevisionFilter == "")
388
                {
389
                    _RevisionFilter = null;
390
                }
391
                else if (_RevisionFilter != value)
392
                {
393
                    _RevisionFilter = value;
394
                    OnPropertyChanged(() => RevisionFilter);
395
                }
396
            }
397
        }
398

    
399
        public string _GroupNOFilter;
400
        public string GroupNOFilter
401
        {
402
            get { return _GroupNOFilter; }
403
            set
404
            {
405
                if (_GroupNOFilter == "")
406
                {
407
                    _GroupNOFilter = null;
408
                }
409
                else if (_GroupNOFilter != value)
410
                {
411
                    _GroupNOFilter = value;
412
                    OnPropertyChanged(() => GroupNOFilter);
413
                }
414
            }
415
        }
416

    
417
        public string _DOCUMENT_URLFilter;
418
        public string DOCUMENT_URLFilter
419
        {
420
            get { return _DOCUMENT_URLFilter; }
421
            set
422
            {
423
                if (_DOCUMENT_URLFilter == "")
424
                {
425
                    _DOCUMENT_URLFilter = null;
426
                }
427
                else if (_DOCUMENT_URLFilter != value)
428
                {
429
                    _DOCUMENT_URLFilter = value;
430
                    OnPropertyChanged(() => DOCUMENT_URLFilter);
431
                }
432
            }
433
        }
434

    
435
        static DateTime DefaultCreateTime = DateTime.Now;
436
        private DateTime _SelectedCreateTimeBegin = DefaultCreateTime;
437
        public DateTime SelectedCreateTimeBegin
438
        {
439

    
440
            get { return _SelectedCreateTimeBegin; }
441
            set
442
            {
443
                if (_SelectedCreateTimeBegin == value)
444
                    return;
445
                _SelectedCreateTimeBegin = value;
446
                OnPropertyChanged(() => SelectedCreateTimeBegin);
447

    
448
            }
449
        }
450

    
451
        private DateTime _SelectedCreateTimeEnd = DefaultCreateTime;
452
        public DateTime SelectedCreateTimeEnd
453
        {
454

    
455
            get { return _SelectedCreateTimeEnd; }
456
            set
457
            {
458
                if (_SelectedCreateTimeEnd == value)
459
                    return;
460
                _SelectedCreateTimeEnd = value;
461
                OnPropertyChanged(() => SelectedCreateTimeEnd);
462
            }
463
        }
464

    
465
        public int _DataBase_ItemsHeight = 800;
466
        public int DataBase_ItemsHeight
467
        {
468
            get { return _DataBase_ItemsHeight; }
469
            set
470
            {
471
                _DataBase_ItemsHeight = value;
472
                OnPropertyChanged(() => DataBase_ItemsHeight);
473
            }
474
        }
475

    
476

    
477
        public int _RealConvert_Height = 80;
478
        public int RealConvert_Height
479
        {
480
            get { return _RealConvert_Height; }
481
            set
482
            {
483
                _RealConvert_Height = value;
484
                OnPropertyChanged(() => RealConvert_Height);
485
            }
486
        }
487

    
488
        public int _Alive_Height = 80;
489
        public int Alive_Height
490
        {
491
            get { return _Alive_Height; }
492
            set
493
            {
494
                _Alive_Height = value;
495
                OnPropertyChanged(() => Alive_Height);
496
            }
497
        }
498

    
499
        public bool _ConvertShow;
500
        public bool ConvertShow
501
        {
502
            get => _ConvertShow;
503
            set
504
            {
505
                if (_ConvertShow = !value)
506
                {
507
                    _ConvertShow = false;
508
                }
509
                _ConvertShow = value;
510
                OnPropertyChanged(() => ConvertShow);
511
            }
512
        }
513

    
514
        #endregion
515

    
516
        #region Command
517

    
518
        public DelegateCommand ConvertCommand { get; private set; }
519
        public DelegateCommand DeleteCommand { get; private set; }
520
        public DelegateCommand ValidateCommand { get; private set; }
521
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
522
        public DelegateCommand MarkusLinkCommand { get; private set; }
523
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
524

    
525
        public DelegateCommand DataFilterCommand { get; private set; }
526
        public DelegateCommand ResetCommand { get; private set; }
527
        public DelegateCommand ConverAddCommand { get; private set; }
528

    
529
        #endregion
530

    
531
        #region Main Logic
532

    
533
        /// <summary>
534
        /// 각각의 Grid row 객체들 업데이트
535
        /// </summary>
536

    
537
        private DispatcherTimer dispatcherTimer;
538
        public override void Loaded()
539
        {
540
            base.Loaded();
541

    
542
            if (!App.IsDesignMode)
543
            {
544
                dispatcherTimer = new DispatcherTimer();
545
                dispatcherTimer.Tick += new EventHandler(Timer_Tick);
546
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
547
                dispatcherTimer.Start();
548
            }
549
        }
550

    
551
        private async void Timer_Tick(object sender, EventArgs e)
552
        {
553
            dispatcherTimer.Stop();
554

    
555
            if (IsAcitve)
556
            {
557
                await App.Current.Dispatcher.InvokeAsync(() =>
558
                {
559
                    DataSelect();
560

    
561
                    AliveDataSelect();
562
                });
563
            }
564

    
565
            //await Task.Delay(5000);
566
            await Task.Delay(10000);
567

    
568
            //System.Threading.Thread.Sleep(new TimeSpan(0,0,0,0,100));
569

    
570
            dispatcherTimer.Start();
571
        }
572

    
573
        public override void Closed()
574
        {
575
            if (dispatcherTimer != null)
576
            {
577
                dispatcherTimer.Stop();
578
            }
579

    
580
            base.Closed();
581
        }
582

    
583

    
584
        #endregion
585

    
586
        #region Function
587

    
588
        #region Data Select
589

    
590
        /// <summary>
591
        /// 상단 그리드 중앙 그리드 출력 데이터
592
        /// </summary>
593
        private void DataSelect()
594
        {
595

    
596
            if (FilterConvertSource == null)
597
            {
598
                FilterConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
599
            }
600

    
601
            if (RealConvertSource == null)
602
            {
603
                RealConvertSource = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
604
            }
605

    
606
            /// combobox 에서 선택된 items
607
            if (SelectedStatus != null)
608
            {
609
                DataSelect(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
610
            }
611

    
612
            /// 컨버터중인 items
613
            RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
614

    
615
        }
616

    
617
        private void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
618
        {
619
            try
620
            {
621
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
622
                {
623
                    List<ConvertItem> Listitems = new List<ConvertItem>();
624

    
625
                    foreach (var coll in collection)
626
                    {
627
                        var items = entities.SELECT_CONVERT_ITEM(coll.ConvertID, coll.ProjectNumber, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null,null).ToList();
628

    
629
                        foreach (var x in items)
630
                        {
631
                            var convertpath = GetSearchConvertPathAndMarkus(x.PROJECT_NO, x.DOCUMENT_ID);
632

    
633
                            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,
634
                                x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.DOCUMENT_URL, convertpath[0], convertpath[1], x.RECONVERTER);
635
                            Listitems.Add(AddItem);
636
 
637
                        }
638
                    }
639

    
640
                    Listitems.ForEach(newitem =>
641
                    {
642
                        collection.UpdateWhere(changeitem =>
643
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ConvertID == newitem.ConvertID && x.ProjectNumber == newitem.ProjectNumber);
644
                    });
645

    
646
                    RealConvert_Height = 80 + (10 * collection.Count());
647
                    DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
648
                }
649
                //using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
650
                //{
651
                //    var items = database.GetConvertProjects(collection)//x:database객체 y:statusCodeTypeList의값  Count()안에 predicator 조건 만족하면 count개수안에 넣음
652
                //                          .Take(SelectedCount.ValueMember).ToList();//
653

    
654
                //    items.ForEach(newitem =>
655
                //    {
656
                //        collection.UpdateWhere(changeitem =>
657
                //        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ConvertID == newitem.ConvertID && x.ProjectNumber == newitem.ProjectNumber);
658
                //    });
659

    
660
                //    RealConvert_Height = 80 + (10 * collection.Count());
661
                //    DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
662
                //}
663
            }
664
            catch (Exception ex)
665
            {
666
                MessageBox.Show(ex.ToString());
667
            }
668
        }
669

    
670
        private void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
671
        {
672
            try
673
            {
674
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
675
                {
676

    
677
                    int _status = 0;
678
                    if (SelectedStatus != null)
679
                    {
680
                        _status = (int)SelectedStatus.Value;
681
                    }
682

    
683
                    var items = entities.SELECT_CONVERT_ITEM(null, null, null, _status, SelectedCount.ValueMember, null, null, null,
684
                        null, null, null, null, null, null, null, null, null, null).ToList();
685
                    //var items = database.GetConvertProjects(_status, ProjectNumberFilter, UniqueKeyFilter, Document_NameFilter, Service_IDFilter, Docuemnt_NOFilter
686
                    //    , ReconverterFilter, RevisionFilter)//x:database객체 y:statusCodeTypeList의값  Count()안에 predicator 조건 만족하면 count개수안에 넣음
687
                    //                      .Take(SelectedCount.ValueMember).ToList();
688

    
689
                    List<ConvertItem> Listitems = new List<ConvertItem>();
690

    
691
                    foreach (var x in items)
692
                    {
693
                        var convertpath = GetSearchConvertPathAndMarkus(x.PROJECT_NO, x.DOCUMENT_ID);
694

    
695
                        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,
696
                            x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.DOCUMENT_URL, convertpath[0], convertpath[1], x.RECONVERTER);
697
                        Listitems.Add(AddItem);
698

    
699
                    }
700

    
701
                    if (collection.Count() == 0)
702
                    {
703
                        if (statusCodeTypeList.Count() == 1)
704
                        {
705
                            Listitems.ForEach(x => collection.Add(x));
706
                        }
707
                    }
708
                    else
709
                    {
710

    
711
                        ////세미 업데이트
712
                        Listitems.ForEach(newitem =>
713
                        {
714
                            collection.UpdateWhere(changeitem =>
715
                            ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
716
                        });
717

    
718
                        if (statusCodeTypeList.Count() == 1)
719
                        {
720
                            //삭제
721
                            for (int i = collection.Count() - 1; i >= 0; --i)
722
                            {
723
                                var item = collection[i];
724

    
725
                                if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)//디비에서 가져온 값과 마지막값부터 차례대로 비교
726
                                {//참=> 0제외한 모든 수
727
                                    collection.RemoveAt(i);
728
                                }
729
                            }
730
                        }
731

    
732
                        if (statusCodeTypeList.Count() == 1)
733
                        {
734
                            //추가 convert 후 추가됨
735
                            foreach (var item in Listitems)
736
                            {
737
                                if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)//그리드와 디비 변동 없으면 안들어감
738
                                {
739
                                    /*for (int i = 0; i < collection.Count()+1; i++)//위 그리드에서 카운드 개수 변함 없고 컨버터 끝난 후 추가할때 createtime 비교 하며 order by 순으로 추가*/
740
                                    for (int i = 0; i < 200; i++)
741
                                    {
742
                                        if (i < collection.Count() - 1)
743
                                        {
744
                                            if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
745
                                            {
746
                                                collection.Insert(i, item);
747
                                                break;
748
                                            }
749
                                        }
750
                                        else
751
                                        {
752
                                            collection.Add(item);
753
                                            break;
754
                                        }
755
                                    }
756

    
757
                                }
758

    
759
                            }
760
                        }
761

    
762
                    }
763
                }
764

    
765
            }
766
            catch (Exception ex)
767
            {
768
                //MessageBox.Show(ex.ToString());
769
                System.Diagnostics.Debug.WriteLine(ex.ToString());
770
            }
771
        }
772

    
773
        private void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
774
        {
775
            try
776
            {
777
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
778
                {
779
                    int _status = 0;
780
                    if (SelectedStatus != null)
781
                    {
782
                        _status = (int)SelectedStatus.Value;
783
                    }
784

    
785
                    //DocumentID = unikey
786
                    DateTime? Start_CreateTime = null;
787
                    DateTime? Finish_CreateTime = null;
788
                    if(SelectedCreateTimeBegin != DefaultCreateTime)
789
                    {
790
                        Start_CreateTime = SelectedCreateTimeBegin;
791
                    }
792
                    if(SelectedCreateTimeEnd != DefaultCreateTime)
793
                    {
794
                        Finish_CreateTime = SelectedCreateTimeEnd;
795
                    }
796

    
797
                    var items = entities.SELECT_CONVERT_ITEM(null, ProjectNumberFilter, UniqueKeyFilter, _status, SelectedCount.ValueMember, Start_CreateTime, Finish_CreateTime, null,
798
                        null, null, null, GroupNOFilter, Document_NameFilter, Docuemnt_NOFilter, RevisionFilter, Service_IDFilter, ReconverterFilter, DOCUMENT_URLFilter).ToList();
799

    
800
                    List<ConvertItem> Listitems = new List<ConvertItem>();
801

    
802
                    foreach (var x in items)
803
                    {
804
                        var convertpath = GetSearchConvertPathAndMarkus(x.PROJECT_NO, x.DOCUMENT_ID);
805

    
806
                        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,
807
                            x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.DOCUMENT_URL, convertpath[0], convertpath[1], x.RECONVERTER);
808
                        Listitems.Add(AddItem);
809

    
810
                    }
811

    
812
                    if (collection.Count() == 0)
813
                    {
814
                        if (statusCodeTypeList.Count() == 1)
815
                        {
816
                            foreach (var x in Listitems)
817
                            {
818
                                collection.Add(x);
819
                            }
820
                        }
821
                    }
822
                    else
823
                    {
824

    
825
                        ////세미 업데이트
826
                        foreach (var newitem in Listitems)
827
                        {
828
                            collection.UpdateWhere(changeitem =>
829
                            ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
830
                        }
831

    
832

    
833
                        if (statusCodeTypeList.Count() == 1)
834
                        {
835

    
836
                            //삭제
837
                            for (int i = collection.Count() - 1; i >= 0; --i)
838
                            {
839
                                var item = collection[i];
840

    
841
                                if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
842
                                {
843
                                    collection.RemoveAt(i);
844
                                }
845
                            }
846
                        }
847

    
848
                        if (statusCodeTypeList.Count() == 1)
849
                        {
850
                            //추가 convert 후 추가됨
851
                            foreach (var item in Listitems)
852
                            {
853
                                if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
854
                                {
855
                                    for (int i = 0; i < 200; i++)
856
                                    {
857
                                        if (i < collection.Count() - 1)
858
                                        {
859
                                            if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
860
                                            {
861
                                                collection.Insert(i, item);
862
                                                break;
863
                                            }
864
                                        }
865
                                        else
866
                                        {
867
                                            collection.Add(item);
868
                                            break;
869
                                        }
870
                                    }
871

    
872
                                }
873

    
874
                            }
875
                        }
876

    
877
                    }
878

    
879
                }
880

    
881
            }
882
            catch (Exception ex)
883
            {
884
                //MessageBox.Show(ex.ToString());
885
                System.Diagnostics.Debug.WriteLine(ex.ToString());
886
            }
887
        }
888
        /// <summary>
889
        /// 서비스의 실시간 컨버터 Item
890
        /// </summary>
891
        private async void AliveDataSelect()
892
        {
893
            try
894
            {
895
                List<ConvertItem> newitems = new List<ConvertItem>();
896
                foreach (var client in App.StationClientList)
897
                {
898
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
899
                    {
900
                        try
901
                        {
902
                            List<ConvertItem> itemsToList = new List<ConvertItem>();
903
                            var items = await client.AliveConvertListAsync();
904
                            string result = "";
905

    
906
                            foreach (var item in items)
907
                            {
908
                                ConvertItem itemsToEach = new ConvertItem();
909
                                itemsToEach.ServiceID = item.ServiceID;
910
                                itemsToEach.ConvertID = item.ConvertID;
911
                                itemsToEach.ProjectNumber = item.ProjectNumber;
912

    
913
                                var convertpath = GetSearchConvertPathAndMarkus(item.ProjectNumber, item.UniqueKey);
914

    
915
                                if (item.ConvertState != null)
916
                                {
917
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
918
                                }
919

    
920
                                if (item.OriginfilePath.Contains("/"))
921
                                {
922
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
923
                                }
924
                                else
925
                                {
926
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
927
                                }
928
                                itemsToEach.FileName = result;
929

    
930
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
931
                                itemsToEach.TotalPage = item.TotalPage;
932
                                itemsToEach.OriginfilePath = item.OriginfilePath;
933
                                itemsToEach.ConvertPath = item.ConvertPath;
934
                                itemsToEach.MarkusLink = convertpath[1];
935
                                itemsToEach.UniqueKey = item.UniqueKey;//DocumentNO 없음
936
                                itemsToEach.GroupNo = item.GroupNo;//없음 
937
                                itemsToEach.ProcessorAffinity = item.ProcessorAffinity;
938
                                itemsToEach.DocumentName = item.DocumnetName;
939
                                itemsToEach.Revision = item.Revision;//없음
940
                                itemsToEach.Exception = item.Exception;//없음
941
                                itemsToEach.ConvertPath = convertpath[0];
942
                                itemsToEach.CreateTime = item.CreateTime;
943
                                itemsToEach.ReConverter = item.ReConverter;
944
                                itemsToEach.DocumentID = item.DocumentID;
945
                                itemsToEach.StartTime = item.StartTime;
946
                                itemsToEach.EndTime = item.EndTime;
947

    
948
                                itemsToList.Add(itemsToEach);
949
                            }
950
                            newitems.AddRange(itemsToList);
951
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
952

    
953
                            if (items.Count() == 0)
954
                            {
955
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
956
                            }
957
                        }
958
                        catch (Exception ex)
959
                        {
960
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
961
                        }
962
                    }
963
                    else
964
                    {
965
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
966
                    }
967

    
968
                }
969
                ItemsUpdate(newitems);
970
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
971

    
972
                //List<ConvertItem> newitems = new List<ConvertItem>();
973
                //using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
974
                //{
975
                //    foreach (var client in App.StationClientList)
976
                //    {
977
                //        if (await SimplePingAsync(client.Endpoint.Address.ToString()))
978
                //        {
979
                //            try
980
                //            {
981
                //                List<ConvertItem> itemsToList = new List<ConvertItem>();
982
                //                var items = await client.AliveConvertListAsync();
983
                //                string result = "";
984

    
985
                //                foreach (var item in items)
986
                //                {
987
                //                    ConvertItem itemsToEach = new ConvertItem();
988
                //                    itemsToEach.ServiceID = item.ServiceID;
989
                //                    itemsToEach.ConvertID = item.ConvertID;
990
                //                    itemsToEach.ProjectNumber = item.ProjectNumber;
991

    
992
                //                    var convertpath = database.GetSearchConvertPathAndMarkus(item.ProjectNumber, item.UniqueKey);
993

    
994
                //                    if (item.ConvertState != null)
995
                //                    {
996
                //                        itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
997
                //                    }
998

    
999
                //                    if (item.OriginfilePath.Contains("/"))
1000
                //                    {
1001
                //                        result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1002
                //                    }
1003
                //                    else
1004
                //                    {
1005
                //                        result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1006
                //                    }
1007
                //                    itemsToEach.FileName = result;
1008

    
1009
                //                    itemsToEach.CurrentPageNo = item.CurrentPageNo;
1010
                //                    itemsToEach.TotalPage = item.TotalPage;
1011
                //                    itemsToEach.OriginfilePath = item.OriginfilePath;
1012
                //                    itemsToEach.ConvertPath = item.ConvertPath;
1013
                //                    itemsToEach.MarkusLink = convertpath[1];
1014
                //                    itemsToEach.UniqueKey = item.UniqueKey;
1015
                //                    itemsToEach.GroupNo = item.GroupNo;
1016
                //                    itemsToEach.ProcessorAffinity = item.ProcessorAffinity;
1017
                //                    itemsToEach.DocumnetName = item.DocumnetName;
1018
                //                    itemsToEach.Revision = item.Revision;
1019
                //                    itemsToEach.Exception = item.Exception;
1020
                //                    itemsToEach.ConvertPath = convertpath[0];
1021
                //                    itemsToEach.CreateTime = item.CreateTime;
1022
                //                    itemsToEach.ReConverter = item.ReConverter;
1023
                //                    itemsToEach.DocumentID = item.DocumentID;
1024
                //                    itemsToEach.StartTime = item.StartTime;
1025
                //                    itemsToEach.EndTime = item.EndTime;
1026

    
1027
                //                    itemsToList.Add(itemsToEach);
1028
                //                }
1029
                //                newitems.AddRange(itemsToList);
1030
                //                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1031

    
1032
                //                if (items.Count() == 0)
1033
                //                {
1034
                //                    System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1035
                //                }
1036
                //            }
1037
                //            catch (Exception ex)
1038
                //            {
1039
                //                System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1040
                //            }
1041
                //        }
1042
                //        else
1043
                //        {
1044
                //            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1045
                //        }
1046
                //    }
1047
                //}
1048
                //ItemsUpdate(newitems);
1049
                //await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1050
            }
1051
            catch (Exception ex)
1052
            {
1053
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1054
            }
1055
        }
1056

    
1057
        /// <summary>
1058
        /// AliveDataSelect의 Data Update
1059
        /// </summary>
1060
        /// <param name="newitems"></param>
1061
        private void ItemsUpdate(List<ConvertItem> newitems)
1062
        {
1063

    
1064
            foreach (var item in newitems)
1065
            {
1066
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1067
            }
1068

    
1069
            if (AliveItems == null)
1070
            {
1071
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
1072

    
1073
                foreach (var item in newitems)
1074
                {
1075
                    AliveItems.Add(item);
1076
                }
1077
            }
1078
            else
1079
            {
1080
                /// 데이터 업데이트
1081
                newitems.ForEach(newitem =>
1082
                {
1083
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1084
                });
1085

    
1086
                // 추가
1087
                foreach (var item in newitems)
1088
                {
1089
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1090
                    {
1091
                        AliveItems.Add(item);
1092
                    }
1093
                }
1094

    
1095
                /// 삭제
1096

    
1097
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1098
                {
1099
                    var item = AliveItems[i];
1100

    
1101
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1102
                    {
1103
                        try
1104
                        {
1105
                            AliveItems.RemoveAt(i);
1106
                        }
1107
                        catch (Exception ex)
1108
                        {
1109
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1110
                        }
1111
                    }
1112
                }
1113
            }
1114

    
1115
            Alive_Height = 80 + (newitems.Count() * 10);
1116
            DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
1117
        }
1118

    
1119

    
1120
        public static async Task<bool> SimplePingAsync(string uri)
1121
        {
1122
            bool result = false;
1123

    
1124
            try
1125
            {
1126
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1127
                {
1128
                    Client.Timeout = new TimeSpan(0, 0, 60);
1129

    
1130
                    var message = await Client.GetAsync(uri);
1131

    
1132
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1133

    
1134
                    switch (StatusCode)
1135
                    {
1136

    
1137
                        case System.Net.HttpStatusCode.Accepted:
1138
                        case System.Net.HttpStatusCode.OK:
1139
                            result = true;
1140
                            break;
1141
                    }
1142
                }
1143
            }
1144
            catch (Exception ex)
1145
            {
1146
                result = false;
1147
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1148
            }
1149

    
1150
            return result;
1151
        }
1152

    
1153
        #endregion
1154

    
1155
        #region Data Convert
1156

    
1157
        private void DataConvert(object obj)
1158
        {
1159
            if (SelectFilterConvert == null && SelectRealConvert == null)
1160
            {
1161
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1162
            }
1163
            else
1164
            {
1165
                //ConvertDatabase _DataConvert = new ConvertDatabase(App.MarkusDataBaseConnecitonString);
1166
                var resultRealConvert = 0;
1167
                var resultFiltertConvert = 0;
1168

    
1169
                if (SelectRealConvert != null)
1170
                {
1171
                    //resultRealConvert = _DataConvert.SetCleanUpItem(SelectRealConvert);//ConvertDataBase
1172
                    resultRealConvert = SetCleanUpItem(SelectRealConvert);//ConvertDataBase
1173
                }
1174
                else if (SelectFilterConvert != null)
1175
                {
1176
                    //resultFiltertConvert = _DataConvert.SetCleanUpItem(SelectFilterConvert);//ConvertDataBase
1177
                    resultFiltertConvert = SetCleanUpItem(SelectFilterConvert);
1178
                }
1179
                System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
1180

    
1181
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1182
                {
1183

    
1184
                    var items = entities.SELECT_CONVERT_ITEM(SelectFilterConvert.ConvertID, null, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null, null); //프로시저 이용
1185

    
1186

    
1187
                    foreach (var x in items)
1188
                    {
1189
                        var convertpath = GetSearchConvertPathAndMarkus(x.PROJECT_NO, x.DOCUMENT_ID);
1190

    
1191
                        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
1192
                         , x.DOCUMENT_URL, convertpath[0], convertpath[1], x.RECONVERTER);
1193

    
1194
                        RealConvertSource.Add(AddItem);
1195

    
1196
                        if (RealConvertSource.Count() == 1)
1197
                        {
1198
                            ConvertShow = true;
1199
                        }
1200
                    }
1201

    
1202
                }
1203

    
1204
                //ConvertDataBase
1205
                //using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
1206
                //{
1207
                //    var items = database.GetConvertProjects(SelectFilterConvert);
1208

    
1209
                //    foreach (var item in items)
1210
                //    {
1211
                //        RealConvertSource.Add(item);
1212
                //    }
1213
                //    if (RealConvertSource.Count() == 1)
1214
                //    {
1215
                //        ConvertShow = true;
1216
                //    }
1217
                //}
1218
            }
1219
        }
1220

    
1221

    
1222
        public int SetCleanUpItem(ConvertItem _ConvertItem)
1223
        {
1224
            using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1225
            {
1226
                int result = 0;
1227

    
1228
                var items = entities.SELECT_CONVERT_ITEM(_ConvertItem.ConvertID, null, null, null, 1, null, null, null, null, null, null, null, null, null, null, null, null, null).ToList();
1229

    
1230
                if (items.Count() > 0)
1231
                {
1232
                    var item = items.First();
1233

    
1234
                    var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
1235
                    var _CREATE_DATETIME = DateTime.Now;
1236
                    var _STATUS = (int)StatusCodeType.None;
1237

    
1238
                  entities.SELECT_RERECONVERT_ITEM(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null);//_END_DATETIME = null 에러
1239

    
1240
                }
1241

    
1242
                return result;
1243
            }
1244
        }
1245

    
1246
        public string[] GetSearchConvertPathAndMarkus(string PROJECT_NO, string DOCUMENT_ID)
1247
        {
1248
            string[] ConvertPath = new string[2];
1249
            ConvertPath[0] = GetConvertPath(PROJECT_NO, DOCUMENT_ID);
1250
            ConvertPath[1] = "kcom://" + CreateMarkusParam(PROJECT_NO, DOCUMENT_ID, "doftech");
1251

    
1252
            return ConvertPath;
1253
        }
1254

    
1255
        #region Convert Path
1256

    
1257
        private string GetConvertPath(string ProjectNo, string DocumentID)
1258
        {
1259
            try
1260
            {
1261
                return Path.Combine(BaseStorage(ProjectNo), ProjectNo + "_Tile", (System.Convert.ToInt64(DocumentID) / 100).ToString(), DocumentID);
1262
            }
1263
            catch (Exception)
1264
            {
1265
                throw new Exception("GetConvertPath Error");
1266
            }
1267

    
1268
        }
1269

    
1270
        private string BaseStorage(string ProjectNo)
1271
        {
1272
            using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1273
            {
1274
                string result = "";
1275

    
1276
                var properties = entities.SELECT_CONVERT_ITEM(null, ProjectNo, null, null, 1, null, null, null, null, null, null, null, null,  null, null, null, null, null).ToList();
1277
                //var properties = entities.PROPERTIES.Where(f => f.PROPERTY == ProjectNo && f.TYPE == PROPERTIES_DEFINE.TILE_SOURCE_STORAGE);//
1278

    
1279

    
1280
                if (properties.Count() > 0)
1281
                {
1282
                    result = properties.First().PROPERTIES_VALUE;
1283
                }
1284
                else
1285
                {
1286
                    throw new Exception($"Project {ProjectNo} BaseStorage Not Setting.");
1287
                }
1288

    
1289
                return result;
1290
            }
1291
        }
1292

    
1293
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1294
        {
1295
            ViewInfo viewInfo = new ViewInfo();
1296

    
1297
            viewInfo.DocumentItemID = documentID;
1298
            viewInfo.ProjectNO = projectNo;
1299
            viewInfo.UserID = userID;
1300

    
1301
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1302

    
1303
        }
1304

    
1305
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1306
        {
1307

    
1308
            if (oEncoding == null)
1309
                oEncoding = System.Text.Encoding.UTF8;
1310

    
1311
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1312

    
1313
        }
1314

    
1315
        #endregion
1316

    
1317
        #endregion
1318

    
1319
        #region Validation
1320

    
1321
        private void DataValidate(object obj)
1322
        {
1323

    
1324
            bool result = false;
1325

    
1326
            WebRequest webRequest = WebRequest.Create(SelectFilterConvert.OriginfilePath);
1327
            webRequest.Timeout = 1200; // miliseconds
1328
            webRequest.Method = "HEAD";
1329

    
1330
            HttpWebResponse response = null;
1331

    
1332
            try
1333
            {
1334
                response = (HttpWebResponse)webRequest.GetResponse();
1335
                result = true;
1336
            }
1337
            catch (WebException webException)
1338
            {
1339
                MessageBox.Show(SelectFilterConvert.FileName + " doesn't exist: " + webException.Message);
1340
                result = true;
1341
            }
1342
            finally
1343
            {
1344
                if (response != null)
1345
                {
1346
                    response.Close();
1347
                }
1348
            }
1349
            if (result == true)
1350
            {
1351
                MessageBox.Show("File exists");
1352
            }
1353
        }
1354

    
1355
        #endregion
1356

    
1357
        #region DataFilter
1358

    
1359
        public void DataFilter(object obj)
1360
        {
1361
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1362
            DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
1363
            //dispatcherTimer.Start();
1364
        }
1365

    
1366
        #endregion
1367

    
1368
        #region MarkusLink
1369

    
1370
        private void MarkusLink(object obj)///여기서 부터 
1371
        {
1372
            if (obj is ConvertItem)
1373
            {
1374
                if (obj != null)
1375
                {
1376
                    var convertitem = obj as ConvertItem;
1377

    
1378
                    SelectFilterConvert = convertitem;
1379

    
1380
                    SelectRealConvert = convertitem;
1381

    
1382
                    ProcessStartInfo startInfo = null;
1383

    
1384
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1385

    
1386
                    Process.Start(startInfo);
1387
                }
1388
            }
1389
        }
1390

    
1391
        #endregion
1392

    
1393
        #region Data Delete
1394

    
1395
        private void DataDelete(object obj)
1396
        {
1397
            RadWindow.Alert("do you want to delete it??", this.OnClosed);
1398
        }
1399

    
1400
        private void OnClosed(object sender, WindowClosedEventArgs e)
1401
        {
1402
            using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1403
            {
1404
                var result = e.DialogResult;
1405
                if (result == true)
1406
                {
1407
                    if (SelectRealConvert != null)
1408
                    {
1409
                        entities.SELECT_CONVERT_DELETE(SelectRealConvert.ConvertID);
1410
                    }
1411
                    if (SelectFilterConvert != null)
1412
                    {
1413
                        entities.SELECT_CONVERT_DELETE(SelectFilterConvert.ConvertID);
1414
                    }
1415
                    //System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
1416

    
1417
                    //ConvertDatabase _DataConvert = new ConvertDatabase(App.MarkusDataBaseConnecitonString);
1418
                    //var resultRealConvert = _DataConvert.RemoveItem(SelectRealConvert.ConvertID);
1419
                    //var resultFiltertConvert = _DataConvert.RemoveItem(SelectFilterConvert.ConvertID);
1420
                    //System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
1421
                }
1422
            }
1423
        }
1424

    
1425

    
1426
        #endregion
1427

    
1428
        #region Data Export
1429

    
1430

    
1431
        /// <summary>
1432
        /// 필터된 상단 그리드 엑셀로 출력
1433
        /// </summary>
1434

    
1435
        public void DataExportData(object obj)
1436
        {
1437
            SaveFileDialog saveFileDialog = new SaveFileDialog();
1438

    
1439
            saveFileDialog.FileName = "Document"; // Default file name
1440
            saveFileDialog.DefaultExt = ".txt"; // Default file extension
1441
            saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension
1442

    
1443

    
1444
            if (saveFileDialog.ShowDialog() == true)
1445
            {
1446

    
1447

    
1448
                if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName))
1449
                {
1450

    
1451
                    var extension = new System.IO.FileInfo(saveFileDialog.FileName).Extension;
1452

    
1453
                    if (extension == ".xlsx" || extension == ".csv")
1454
                    {
1455

    
1456
                        var headers = new List<HeaderMember>
1457
                        {
1458
                            new HeaderMember{HeaderName = "ServiceID", Property = "ServiceID" },
1459
                            new HeaderMember{HeaderName = "ConvertID", Property = "ConvertID" },
1460
                            new HeaderMember{HeaderName = "ProjectNumber", Property = "ProjectNumber" },
1461
                            new HeaderMember{HeaderName = "ConvertState", Property = "ConvertState" },
1462
                            new HeaderMember{HeaderName = "CurrentPageNo", Property = "CurrentPageNo" },
1463
                            new HeaderMember{HeaderName = "TotalPage", Property = "TotalPage" },
1464
                            new HeaderMember{HeaderName = "OriginfilePath", Property = "OriginfilePath" },
1465
                            new HeaderMember{HeaderName = "ConvertPath", Property = "ConvertPath" },
1466
                            new HeaderMember{HeaderName = "CreateTime", Property = "CreateTime" },
1467
                            new HeaderMember{HeaderName = "Exception", Property = "Exception" },
1468
                            new HeaderMember{HeaderName = "ProcessorAffinity", Property = "ProcessorAffinity" },
1469
                            new HeaderMember{HeaderName = "ReConverter", Property = "ReConverter" },
1470
                            new HeaderMember{HeaderName = "UniqueKey", Property = "UniqueKey" }
1471
                        };
1472

    
1473

    
1474
                        DataExport dataExport = new DataExport();
1475
                        dataExport.DataExportExcel(saveFileDialog.FileName, "Hello world", FilterConvertSource, headers);
1476
                        //_dataExport.DataExportExcel(saveFileDialog.FileName, saveFileDialog.FileName.ToString(),  Projectsource, headers);
1477
                        //GemBoxFileSave(obj);
1478
                    }
1479
                }
1480
            }
1481
        }
1482

    
1483
        #endregion
1484

    
1485
        #region Data Search
1486

    
1487
        public void RemoveCreateTimeFilter(object obj)
1488
        {
1489
            DefaultCreateTime = DateTime.Now;
1490
            SelectedCreateTimeBegin = DefaultCreateTime;
1491
            SelectedCreateTimeEnd = DefaultCreateTime;
1492

    
1493
        }
1494

    
1495
        #endregion
1496

    
1497
        #region Reset
1498

    
1499
        /// <summary>
1500
        /// 그리드 상단 원상복귀 버튼
1501
        /// 필터를 끝낸 후 다시 복귀
1502
        /// </summary>
1503

    
1504
        public void Reset(object obj)
1505
        {
1506
            ProjectNumberFilter = null;
1507
            UniqueKeyFilter = null;
1508
            Service_IDFilter = null;
1509
            Document_NameFilter = null;
1510
            Docuemnt_NOFilter = null;
1511
            ReconverterFilter = null;
1512
            RevisionFilter = null;
1513
            GroupNOFilter = null;
1514
            DOCUMENT_URLFilter = null;
1515
            DefaultCreateTime = DateTime.Now;
1516
            SelectedCreateTimeBegin = DefaultCreateTime;
1517
            SelectedCreateTimeEnd = DefaultCreateTime;
1518
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1519
        }
1520

    
1521
        #endregion
1522

    
1523

    
1524
        #region ConvertAddDialog
1525

    
1526
        /// <summary>
1527
        /// 그리드 상단 Conver 추가 버튼
1528
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1529
        /// </summary>
1530

    
1531
        public void ConverAdd(object obj)
1532
        {
1533
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1534

    
1535
            Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1536

    
1537
            convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1538

    
1539
            convertAddDialog.ShowDialog();
1540

    
1541
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1542
        }
1543

    
1544
        #endregion
1545

    
1546
        #endregion
1547
    }
1548
}
1549

    
클립보드 이미지 추가 (최대 크기: 500 MB)