프로젝트

일반

사용자정보

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

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

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

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