프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (52.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 MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech");
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, x.CONVERT_PATH, MarkusLink, 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
            }
650
            catch (Exception ex)
651
            {
652
                MessageBox.Show(ex.ToString());
653
            }
654
        }
655

    
656
        private void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
657
        {
658
            try
659
            {
660
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
661
                {
662

    
663
                    int _status = 0;
664
                    if (SelectedStatus != null)
665
                    {
666
                        _status = (int)SelectedStatus.Value;
667
                    }
668

    
669
                    var items = entities.SELECT_CONVERT_ITEM(null, null, null, _status, SelectedCount.ValueMember, null, null, null,
670
                        null, null, null, null, null, null, null, null, null, null).ToList();
671

    
672
                    List<ConvertItem> Listitems = new List<ConvertItem>();
673

    
674
                    foreach (var x in items)
675
                    {
676
                        var MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech");
677

    
678
                        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,
679
                            x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
680
                        Listitems.Add(AddItem);
681

    
682
                    }
683

    
684
                    if (collection.Count() == 0)
685
                    {
686
                        if (statusCodeTypeList.Count() == 1)
687
                        {
688
                            Listitems.ForEach(x => collection.Add(x));
689
                        }
690
                    }
691
                    else
692
                    {
693

    
694
                        ////세미 업데이트
695
                        Listitems.ForEach(newitem =>
696
                        {
697
                            collection.UpdateWhere(changeitem =>
698
                            ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
699
                        });
700

    
701
                        if (statusCodeTypeList.Count() == 1)
702
                        {
703
                            //삭제
704
                            for (int i = collection.Count() - 1; i >= 0; --i)
705
                            {
706
                                var item = collection[i];
707

    
708
                                if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)//디비에서 가져온 값과 마지막값부터 차례대로 비교
709
                                {//참=> 0제외한 모든 수
710
                                    collection.RemoveAt(i);
711
                                }
712
                            }
713
                        }
714

    
715
                        if (statusCodeTypeList.Count() == 1)
716
                        {
717
                            //추가 convert 후 추가됨
718
                            foreach (var item in Listitems)
719
                            {
720
                                if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)//그리드와 디비 변동 없으면 안들어감
721
                                {
722
                                    /*for (int i = 0; i < collection.Count()+1; i++)//위 그리드에서 카운드 개수 변함 없고 컨버터 끝난 후 추가할때 createtime 비교 하며 order by 순으로 추가*/
723
                                    for (int i = 0; i < 200; i++)
724
                                    {
725
                                        if (i < collection.Count() - 1)
726
                                        {
727
                                            if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
728
                                            {
729
                                                collection.Insert(i, item);
730
                                                break;
731
                                            }
732
                                        }
733
                                        else
734
                                        {
735
                                            collection.Add(item);
736
                                            break;
737
                                        }
738
                                    }
739

    
740
                                }
741

    
742
                            }
743
                        }
744

    
745
                    }
746
                }
747

    
748
            }
749
            catch (Exception ex)
750
            {
751
                //MessageBox.Show(ex.ToString());
752
                System.Diagnostics.Debug.WriteLine(ex.ToString());
753
            }
754
        }
755

    
756
        private void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
757
        {
758
            try
759
            {
760
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
761
                {
762
                    int _status = 0;
763
                    if (SelectedStatus != null)
764
                    {
765
                        _status = (int)SelectedStatus.Value;
766
                    }
767

    
768
                    //DocumentID = unikey
769
                    DateTime? Start_CreateTime = null;
770
                    DateTime? Finish_CreateTime = null;
771
                    if(SelectedCreateTimeBegin != DefaultCreateTime)
772
                    {
773
                        Start_CreateTime = SelectedCreateTimeBegin;
774
                    }
775
                    if(SelectedCreateTimeEnd != DefaultCreateTime)
776
                    {
777
                        Finish_CreateTime = SelectedCreateTimeEnd;
778
                    }
779

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

    
783
                    List<ConvertItem> Listitems = new List<ConvertItem>();
784

    
785
                    foreach (var x in items)
786
                    {
787
                        var MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech");
788

    
789
                        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,
790
                            x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
791
                        Listitems.Add(AddItem);
792

    
793
                    }
794

    
795
                    if (collection.Count() == 0)
796
                    {
797
                        if (statusCodeTypeList.Count() == 1)
798
                        {
799
                            foreach (var x in Listitems)
800
                            {
801
                                collection.Add(x);
802
                            }
803
                        }
804
                    }
805
                    else
806
                    {
807

    
808
                        ////세미 업데이트
809
                        foreach (var newitem in Listitems)
810
                        {
811
                            collection.UpdateWhere(changeitem =>
812
                            ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
813
                        }
814

    
815

    
816
                        if (statusCodeTypeList.Count() == 1)
817
                        {
818

    
819
                            //삭제
820
                            for (int i = collection.Count() - 1; i >= 0; --i)
821
                            {
822
                                var item = collection[i];
823

    
824
                                if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
825
                                {
826
                                    collection.RemoveAt(i);
827
                                }
828
                            }
829
                        }
830

    
831
                        if (statusCodeTypeList.Count() == 1)
832
                        {
833
                            //추가 convert 후 추가됨
834
                            foreach (var item in Listitems)
835
                            {
836
                                if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
837
                                {
838
                                    for (int i = 0; i < 200; i++)
839
                                    {
840
                                        if (i < collection.Count() - 1)
841
                                        {
842
                                            if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
843
                                            {
844
                                                collection.Insert(i, item);
845
                                                break;
846
                                            }
847
                                        }
848
                                        else
849
                                        {
850
                                            collection.Add(item);
851
                                            break;
852
                                        }
853
                                    }
854

    
855
                                }
856

    
857
                            }
858
                        }
859

    
860
                    }
861

    
862
                }
863

    
864
            }
865
            catch (Exception ex)
866
            {
867
                //MessageBox.Show(ex.ToString());
868
                System.Diagnostics.Debug.WriteLine(ex.ToString());
869
            }
870
        }
871
        /// <summary>
872
        /// 서비스의 실시간 컨버터 Item
873
        /// </summary>
874
        private async void AliveDataSelect()
875
        {
876
            try
877
            {
878
                List<ConvertItem> newitems = new List<ConvertItem>();
879
                foreach (var client in App.StationClientList)
880
                {
881
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
882
                    {
883
                        try
884
                        {
885
                            List<ConvertItem> itemsToList = new List<ConvertItem>();
886
                            var items = await client.AliveConvertListAsync();
887
                            string result = "";
888

    
889
                            foreach (var item in items)
890
                            {
891
                                ConvertItem itemsToEach = new ConvertItem();
892
                                itemsToEach.ServiceID = item.ServiceID;
893
                                itemsToEach.ConvertID = item.ConvertID;
894
                                itemsToEach.ProjectNumber = item.ProjectNumber;
895

    
896
                                var MarkusLink = "kcom://" + CreateMarkusParam(item.ProjectNumber, item.DocumentID, "doftech");
897

    
898
                                if (item.ConvertState != null)
899
                                {
900
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
901
                                }
902

    
903
                                if (item.OriginfilePath.Contains("/"))
904
                                {
905
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
906
                                }
907
                                else
908
                                {
909
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
910
                                }
911
                                itemsToEach.FileName = result;
912

    
913
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
914
                                itemsToEach.TotalPage = item.TotalPage;
915
                                itemsToEach.OriginfilePath = item.OriginfilePath;
916
                                itemsToEach.ConvertPath = item.ConvertPath;
917
                                itemsToEach.MarkusLink = MarkusLink;
918
                                itemsToEach.UniqueKey = item.UniqueKey;//DocumentNO 없음
919
                                itemsToEach.GroupNo = item.GroupNo;//없음 
920
                                itemsToEach.ProcessorAffinity = item.ProcessorAffinity;
921
                                itemsToEach.DocumentName = item.DocumnetName;
922
                                itemsToEach.Revision = item.Revision; //없음 
923
                                itemsToEach.Exception = item.Exception;//없음
924
                                itemsToEach.ConvertPath = item.ConvertPath;
925
                                itemsToEach.CreateTime = item.CreateTime;
926
                                itemsToEach.ReConverter = item.ReConverter;
927
                                itemsToEach.DocumentID = item.DocumentID;
928
                                itemsToEach.StartTime = item.StartTime;
929
                                itemsToEach.EndTime = item.EndTime;
930

    
931
                                itemsToList.Add(itemsToEach);
932
                            }
933
                            newitems.AddRange(itemsToList);
934
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
935

    
936
                            if (items.Count() == 0)
937
                            {
938
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
939
                            }
940
                        }
941
                        catch (Exception ex)
942
                        {
943
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
944
                        }
945
                    }
946
                    else
947
                    {
948
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
949
                    }
950

    
951
                }
952
                ItemsUpdate(newitems);
953
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
954

    
955
                //List<ConvertItem> newitems = new List<ConvertItem>();
956
                //using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
957
                //{
958
                //    foreach (var client in App.StationClientList)
959
                //    {
960
                //        if (await SimplePingAsync(client.Endpoint.Address.ToString()))
961
                //        {
962
                //            try
963
                //            {
964
                //                List<ConvertItem> itemsToList = new List<ConvertItem>();
965
                //                var items = await client.AliveConvertListAsync();
966
                //                string result = "";
967

    
968
                //                foreach (var item in items)
969
                //                {
970
                //                    ConvertItem itemsToEach = new ConvertItem();
971
                //                    itemsToEach.ServiceID = item.ServiceID;
972
                //                    itemsToEach.ConvertID = item.ConvertID;
973
                //                    itemsToEach.ProjectNumber = item.ProjectNumber;
974

    
975
                //                    var convertpath = database.GetSearchConvertPathAndMarkus(item.ProjectNumber, item.UniqueKey);
976

    
977
                //                    if (item.ConvertState != null)
978
                //                    {
979
                //                        itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
980
                //                    }
981

    
982
                //                    if (item.OriginfilePath.Contains("/"))
983
                //                    {
984
                //                        result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
985
                //                    }
986
                //                    else
987
                //                    {
988
                //                        result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
989
                //                    }
990
                //                    itemsToEach.FileName = result;
991

    
992
                //                    itemsToEach.CurrentPageNo = item.CurrentPageNo;
993
                //                    itemsToEach.TotalPage = item.TotalPage;
994
                //                    itemsToEach.OriginfilePath = item.OriginfilePath;
995
                //                    itemsToEach.ConvertPath = item.ConvertPath;
996
                //                    itemsToEach.MarkusLink = convertpath[1];
997
                //                    itemsToEach.UniqueKey = item.UniqueKey;
998
                //                    itemsToEach.GroupNo = item.GroupNo;
999
                //                    itemsToEach.ProcessorAffinity = item.ProcessorAffinity;
1000
                //                    itemsToEach.DocumnetName = item.DocumnetName;
1001
                //                    itemsToEach.Revision = item.Revision;
1002
                //                    itemsToEach.Exception = item.Exception;
1003
                //                    itemsToEach.ConvertPath = convertpath[0];
1004
                //                    itemsToEach.CreateTime = item.CreateTime;
1005
                //                    itemsToEach.ReConverter = item.ReConverter;
1006
                //                    itemsToEach.DocumentID = item.DocumentID;
1007
                //                    itemsToEach.StartTime = item.StartTime;
1008
                //                    itemsToEach.EndTime = item.EndTime;
1009

    
1010
                //                    itemsToList.Add(itemsToEach);
1011
                //                }
1012
                //                newitems.AddRange(itemsToList);
1013
                //                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1014

    
1015
                //                if (items.Count() == 0)
1016
                //                {
1017
                //                    System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1018
                //                }
1019
                //            }
1020
                //            catch (Exception ex)
1021
                //            {
1022
                //                System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1023
                //            }
1024
                //        }
1025
                //        else
1026
                //        {
1027
                //            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1028
                //        }
1029
                //    }
1030
                //}
1031
                //ItemsUpdate(newitems);
1032
                //await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1033
            }
1034
            catch (Exception ex)
1035
            {
1036
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1037
            }
1038
        }
1039

    
1040
        /// <summary>
1041
        /// AliveDataSelect의 Data Update
1042
        /// </summary>
1043
        /// <param name="newitems"></param>
1044
        private void ItemsUpdate(List<ConvertItem> newitems)
1045
        {
1046

    
1047
            foreach (var item in newitems)
1048
            {
1049
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1050
            }
1051

    
1052
            if (AliveItems == null)
1053
            {
1054
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
1055

    
1056
                foreach (var item in newitems)
1057
                {
1058
                    AliveItems.Add(item);
1059
                }
1060
            }
1061
            else
1062
            {
1063
                /// 데이터 업데이트
1064
                newitems.ForEach(newitem =>
1065
                {
1066
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1067
                });
1068

    
1069
                // 추가
1070
                foreach (var item in newitems)
1071
                {
1072
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1073
                    {
1074
                        AliveItems.Add(item);
1075
                    }
1076
                }
1077

    
1078
                /// 삭제
1079

    
1080
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1081
                {
1082
                    var item = AliveItems[i];
1083

    
1084
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1085
                    {
1086
                        try
1087
                        {
1088
                            AliveItems.RemoveAt(i);
1089
                        }
1090
                        catch (Exception ex)
1091
                        {
1092
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1093
                        }
1094
                    }
1095
                }
1096
            }
1097

    
1098
            Alive_Height = 80 + (newitems.Count() * 10);
1099
            DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
1100
        }
1101

    
1102

    
1103
        public static async Task<bool> SimplePingAsync(string uri)
1104
        {
1105
            bool result = false;
1106

    
1107
            try
1108
            {
1109
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1110
                {
1111
                    Client.Timeout = new TimeSpan(0, 0, 60);
1112

    
1113
                    var message = await Client.GetAsync(uri);
1114

    
1115
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1116

    
1117
                    switch (StatusCode)
1118
                    {
1119

    
1120
                        case System.Net.HttpStatusCode.Accepted:
1121
                        case System.Net.HttpStatusCode.OK:
1122
                            result = true;
1123
                            break;
1124
                    }
1125
                }
1126
            }
1127
            catch (Exception ex)
1128
            {
1129
                result = false;
1130
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1131
            }
1132

    
1133
            return result;
1134
        }
1135

    
1136
        #endregion
1137

    
1138
        #region Data Convert
1139

    
1140
        private void DataConvert(object obj)
1141
        {
1142
            if (SelectFilterConvert == null && SelectRealConvert == null)
1143
            {
1144
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1145
            }
1146
            else
1147
            {
1148
                var resultRealConvert = 0;
1149
                var resultFiltertConvert = 0;
1150

    
1151
                if (SelectRealConvert != null)
1152
                {
1153
                    resultRealConvert = SetCleanUpItem(SelectRealConvert);//ConvertDataBase
1154
                }
1155
                else if (SelectFilterConvert != null)
1156
                {
1157
                    resultFiltertConvert = SetCleanUpItem(SelectFilterConvert);
1158
                }
1159
                System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
1160

    
1161
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1162
                {
1163

    
1164
                    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); //프로시저 이용
1165

    
1166

    
1167
                    foreach (var x in items)
1168
                    {
1169
                        var MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech");
1170

    
1171
                        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
1172
                             , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
1173

    
1174
                        RealConvertSource.Add(AddItem);
1175

    
1176
                        if (RealConvertSource.Count() == 1)
1177
                        {
1178
                            ConvertShow = true;
1179
                        }
1180
                    }
1181

    
1182
                }
1183
            }
1184
        }
1185

    
1186

    
1187
        public int SetCleanUpItem(ConvertItem _ConvertItem)
1188
        {
1189
            using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1190
            {
1191
                int result = 0;
1192

    
1193
                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();
1194

    
1195
                if (items.Count() > 0)
1196
                {
1197
                    var item = items.First();
1198

    
1199
                    var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
1200
                    var _CREATE_DATETIME = DateTime.Now;
1201
                    var _STATUS = (int)StatusCodeType.None;
1202

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

    
1205
                }
1206

    
1207
                return result;
1208
            }
1209
        }
1210

    
1211

    
1212
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1213
        {
1214
            ViewInfo viewInfo = new ViewInfo();
1215

    
1216
            viewInfo.DocumentItemID = documentID;
1217
            viewInfo.ProjectNO = projectNo;
1218
            viewInfo.UserID = userID;
1219

    
1220
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1221

    
1222
        }
1223

    
1224
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1225
        {
1226

    
1227
            if (oEncoding == null)
1228
                oEncoding = System.Text.Encoding.UTF8;
1229

    
1230
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1231

    
1232
        }
1233

    
1234

    
1235
        #endregion
1236

    
1237
        #region Validation
1238

    
1239
        private void DataValidate(object obj)
1240
        {
1241

    
1242
            bool result = false;
1243

    
1244
            WebRequest webRequest = WebRequest.Create(SelectFilterConvert.OriginfilePath);
1245
            webRequest.Timeout = 1200; // miliseconds
1246
            webRequest.Method = "HEAD";
1247

    
1248
            HttpWebResponse response = null;
1249

    
1250
            try
1251
            {
1252
                response = (HttpWebResponse)webRequest.GetResponse();
1253
                result = true;
1254
            }
1255
            catch (WebException webException)
1256
            {
1257
                MessageBox.Show(SelectFilterConvert.FileName + " doesn't exist: " + webException.Message);
1258
                result = true;
1259
            }
1260
            finally
1261
            {
1262
                if (response != null)
1263
                {
1264
                    response.Close();
1265
                }
1266
            }
1267
            if (result == true)
1268
            {
1269
                MessageBox.Show("File exists");
1270
            }
1271
        }
1272

    
1273
        #endregion
1274

    
1275
        #region DataFilter
1276

    
1277
        public void DataFilter(object obj)
1278
        {
1279
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1280
            DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
1281
            //dispatcherTimer.Start();
1282
        }
1283

    
1284
        #endregion
1285

    
1286
        #region MarkusLink
1287

    
1288
        private void MarkusLink(object obj)///여기서 부터 
1289
        {
1290
            if (obj is ConvertItem)
1291
            {
1292
                if (obj != null)
1293
                {
1294
                    var convertitem = obj as ConvertItem;
1295

    
1296
                    SelectFilterConvert = convertitem;
1297

    
1298
                    SelectRealConvert = convertitem;
1299

    
1300
                    ProcessStartInfo startInfo = null;
1301

    
1302
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1303

    
1304
                    Process.Start(startInfo);
1305
                }
1306
            }
1307
        }
1308

    
1309
        #endregion
1310

    
1311
        #region Data Delete
1312

    
1313
        private void DataDelete(object obj)
1314
        {
1315
            RadWindow.Alert("do you want to delete it??", this.OnClosed);
1316
        }
1317

    
1318
        private void OnClosed(object sender, WindowClosedEventArgs e)
1319
        {
1320
            using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1321
            {
1322
                var result = e.DialogResult;
1323
                if (result == true)
1324
                {
1325
                    if (SelectRealConvert != null)
1326
                    {
1327
                        entities.SELECT_CONVERT_DELETE(SelectRealConvert.ConvertID);
1328
                    }
1329
                    if (SelectFilterConvert != null)
1330
                    {
1331
                        entities.SELECT_CONVERT_DELETE(SelectFilterConvert.ConvertID);
1332
                    }
1333
                    //System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
1334

    
1335
                    //ConvertDatabase _DataConvert = new ConvertDatabase(App.MarkusDataBaseConnecitonString);
1336
                    //var resultRealConvert = _DataConvert.RemoveItem(SelectRealConvert.ConvertID);
1337
                    //var resultFiltertConvert = _DataConvert.RemoveItem(SelectFilterConvert.ConvertID);
1338
                    //System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
1339
                }
1340
            }
1341
        }
1342

    
1343

    
1344
        #endregion
1345

    
1346
        #region Data Export
1347

    
1348

    
1349
        /// <summary>
1350
        /// 필터된 상단 그리드 엑셀로 출력
1351
        /// </summary>
1352

    
1353
        public void DataExportData(object obj)
1354
        {
1355
            SaveFileDialog saveFileDialog = new SaveFileDialog();
1356

    
1357
            saveFileDialog.FileName = "Document"; // Default file name
1358
            saveFileDialog.DefaultExt = ".txt"; // Default file extension
1359
            saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension
1360

    
1361

    
1362
            if (saveFileDialog.ShowDialog() == true)
1363
            {
1364

    
1365

    
1366
                if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName))
1367
                {
1368

    
1369
                    var extension = new System.IO.FileInfo(saveFileDialog.FileName).Extension;
1370

    
1371
                    if (extension == ".xlsx" || extension == ".csv")
1372
                    {
1373

    
1374
                        var headers = new List<HeaderMember>
1375
                        {
1376
                            new HeaderMember{HeaderName = "ServiceID", Property = "ServiceID" },
1377
                            new HeaderMember{HeaderName = "ConvertID", Property = "ConvertID" },
1378
                            new HeaderMember{HeaderName = "ProjectNumber", Property = "ProjectNumber" },
1379
                            new HeaderMember{HeaderName = "ConvertState", Property = "ConvertState" },
1380
                            new HeaderMember{HeaderName = "CurrentPageNo", Property = "CurrentPageNo" },
1381
                            new HeaderMember{HeaderName = "TotalPage", Property = "TotalPage" },
1382
                            new HeaderMember{HeaderName = "OriginfilePath", Property = "OriginfilePath" },
1383
                            new HeaderMember{HeaderName = "ConvertPath", Property = "ConvertPath" },
1384
                            new HeaderMember{HeaderName = "CreateTime", Property = "CreateTime" },
1385
                            new HeaderMember{HeaderName = "Exception", Property = "Exception" },
1386
                            new HeaderMember{HeaderName = "ProcessorAffinity", Property = "ProcessorAffinity" },
1387
                            new HeaderMember{HeaderName = "ReConverter", Property = "ReConverter" },
1388
                            new HeaderMember{HeaderName = "UniqueKey", Property = "UniqueKey" }
1389
                        };
1390

    
1391

    
1392
                        DataExport dataExport = new DataExport();
1393
                        dataExport.DataExportExcel(saveFileDialog.FileName, "Hello world", FilterConvertSource, headers);
1394
                        //_dataExport.DataExportExcel(saveFileDialog.FileName, saveFileDialog.FileName.ToString(),  Projectsource, headers);
1395
                        //GemBoxFileSave(obj);
1396
                    }
1397
                }
1398
            }
1399
        }
1400

    
1401
        #endregion
1402

    
1403
        #region Data Search
1404

    
1405
        public void RemoveCreateTimeFilter(object obj)
1406
        {
1407
            DefaultCreateTime = DateTime.Now;
1408
            SelectedCreateTimeBegin = DefaultCreateTime;
1409
            SelectedCreateTimeEnd = DefaultCreateTime;
1410

    
1411
        }
1412

    
1413
        #endregion
1414

    
1415
        #region Reset
1416

    
1417
        /// <summary>
1418
        /// 그리드 상단 원상복귀 버튼
1419
        /// 필터를 끝낸 후 다시 복귀
1420
        /// </summary>
1421

    
1422
        public void Reset(object obj)
1423
        {
1424
            ProjectNumberFilter = null;
1425
            UniqueKeyFilter = null;
1426
            Service_IDFilter = null;
1427
            Document_NameFilter = null;
1428
            Docuemnt_NOFilter = null;
1429
            ReconverterFilter = null;
1430
            RevisionFilter = null;
1431
            GroupNOFilter = null;
1432
            DOCUMENT_URLFilter = null;
1433
            DefaultCreateTime = DateTime.Now;
1434
            SelectedCreateTimeBegin = DefaultCreateTime;
1435
            SelectedCreateTimeEnd = DefaultCreateTime;
1436
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1437
        }
1438

    
1439
        #endregion
1440

    
1441

    
1442
        #region ConvertAddDialog
1443

    
1444
        /// <summary>
1445
        /// 그리드 상단 Conver 추가 버튼
1446
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1447
        /// </summary>
1448

    
1449
        public void ConverAdd(object obj)
1450
        {
1451
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1452

    
1453
            Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1454

    
1455
            convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1456

    
1457
            convertAddDialog.ShowDialog();
1458

    
1459
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1460
        }
1461

    
1462
        #endregion
1463

    
1464
        #endregion
1465
    }
1466
}
1467

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