프로젝트

일반

사용자정보

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

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

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

1 e6281033 alzkakdixm
using Markus.Message;
2 a6e5055d alzkakdixm
using Markus.Service.Extensions;
3 e6281033 alzkakdixm
using Markus.Service.StationController.Data;
4 a6e5055d alzkakdixm
using Markus.Service.StationController.Behaviors;
5
using Markus.Service.StationController.Extensions;
6 b63dcfbb semi
using Markus.Service.StationController.Controls;
7 a6e5055d alzkakdixm
using Microsoft.Win32;
8
using System;
9
using System.Collections.Generic;
10
using System.ComponentModel;
11
using System.Linq;
12 2decfbdf alzkakdixm
using System.Threading.Tasks;
13
using System.Web;
14 a6e5055d alzkakdixm
using System.Windows;
15
using Telerik.Windows.Controls;
16
using Telerik.Windows.Data;
17
using ConvertItem = Markus.Service.Interface.ConvertItem;
18 e6281033 alzkakdixm
using System.Net;
19
using System.Windows.Threading;
20 e78f0871 alzkakdixm
using System.Diagnostics;
21
using System.Windows.Input;
22
using Markus.Mvvm.ToolKit;
23 902f397c semi
using System.Windows.Data;
24 85f68fef semi
using System.Windows.Controls;
25 3bde451b semi
using System.IO;
26 2c634aed semi
using Newtonsoft.Json;
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 int _DataBase_ItemsHeight = 800;
466 85f68fef semi
        public int DataBase_ItemsHeight
467 8c128693 semi
        {
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 218e5002 semi
        {
480 8c128693 semi
            get { return _RealConvert_Height; }
481 218e5002 semi
            set
482
            {
483 8c128693 semi
                _RealConvert_Height = value;
484
                OnPropertyChanged(() => RealConvert_Height);
485 218e5002 semi
            }
486
        }
487
488 8c128693 semi
        public int _Alive_Height = 80;
489
        public int Alive_Height
490 b63dcfbb semi
        {
491 8c128693 semi
            get { return _Alive_Height; }
492
            set
493
            {
494
                _Alive_Height = value;
495
                OnPropertyChanged(() => Alive_Height);
496
            }
497
        }
498 b63dcfbb semi
499 8c128693 semi
        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 b63dcfbb semi
        }
513 8c128693 semi
514 e6281033 alzkakdixm
        #endregion
515
516
        #region Command
517 a6e5055d alzkakdixm
518 0cb12397 alzkakdixm
        public DelegateCommand ConvertCommand { get; private set; }
519
        public DelegateCommand DeleteCommand { get; private set; }
520
        public DelegateCommand ValidateCommand { get; private set; }
521 e6281033 alzkakdixm
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
522 e78f0871 alzkakdixm
        public DelegateCommand MarkusLinkCommand { get; private set; }
523 b63dcfbb semi
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
524
525
        public DelegateCommand DataFilterCommand { get; private set; }
526
        public DelegateCommand ResetCommand { get; private set; }
527 218e5002 semi
        public DelegateCommand ConverAddCommand { get; private set; }
528 5a954acc semi
529 e6281033 alzkakdixm
        #endregion
530 a6e5055d alzkakdixm
531 e6281033 alzkakdixm
        #region Main Logic
532 a6e5055d alzkakdixm
533 e6281033 alzkakdixm
        /// <summary>
534
        /// 각각의 Grid row 객체들 업데이트
535
        /// </summary>
536
537
        private DispatcherTimer dispatcherTimer;
538 8c128693 semi
        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 a6e5055d alzkakdixm
551 b119eeaa taeseongkim
        private async void Timer_Tick(object sender, EventArgs e)
552 a6e5055d alzkakdixm
        {
553 e6281033 alzkakdixm
            dispatcherTimer.Stop();
554
555
            if (IsAcitve)
556 a6e5055d alzkakdixm
            {
557 b119eeaa taeseongkim
                await App.Current.Dispatcher.InvokeAsync(() =>
558 a6e5055d alzkakdixm
                {
559 e6281033 alzkakdixm
                    DataSelect();
560
561
                    AliveDataSelect();
562
                });
563
            }
564
565 30680747 semi
            //await Task.Delay(5000);
566
            await Task.Delay(10000);
567 b119eeaa taeseongkim
568
            //System.Threading.Thread.Sleep(new TimeSpan(0,0,0,0,100));
569 e6281033 alzkakdixm
570
            dispatcherTimer.Start();
571
        }
572 a6e5055d alzkakdixm
573 e6281033 alzkakdixm
        public override void Closed()
574
        {
575
            if (dispatcherTimer != null)
576
            {
577
                dispatcherTimer.Stop();
578 a6e5055d alzkakdixm
            }
579 e6281033 alzkakdixm
580
            base.Closed();
581 a6e5055d alzkakdixm
        }
582 0cb12397 alzkakdixm
583 2decfbdf alzkakdixm
584 e6281033 alzkakdixm
        #endregion
585 a6e5055d alzkakdixm
586 e6281033 alzkakdixm
        #region Function
587 a6e5055d alzkakdixm
588 e6281033 alzkakdixm
        #region Data Select
589
590
        /// <summary>
591
        /// 상단 그리드 중앙 그리드 출력 데이터
592
        /// </summary>
593
        private void DataSelect()
594
        {
595 a6e5055d alzkakdixm
596 e6281033 alzkakdixm
            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 a6e5055d alzkakdixm
            }
611
612 e6281033 alzkakdixm
            /// 컨버터중인 items
613
            RealDataSelect(new[] { StatusCodeType.None, StatusCodeType.Wait, StatusCodeType.PageLoading, StatusCodeType.Saving }, RealConvertSource);
614 2decfbdf alzkakdixm
615 e6281033 alzkakdixm
        }
616 2decfbdf alzkakdixm
617
        private void RealDataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
618
        {
619
            try
620
            {
621 30680747 semi
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
622 2decfbdf alzkakdixm
                {
623 3bde451b semi
                    List<ConvertItem> Listitems = new List<ConvertItem>();
624 2decfbdf alzkakdixm
625 3bde451b semi
                    foreach (var coll in collection)
626
                    {
627 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();
628 3bde451b semi
629
                        foreach (var x in items)
630
                        {
631
                            var convertpath = GetSearchConvertPathAndMarkus(x.PROJECT_NO, x.DOCUMENT_ID);
632
633
                            ConvertItem AddItem = new ConvertItem(x.SERVICE_ID, x.ID, x.PROJECT_NO, x.STATUS, x.DOCUMENT_ID, x.DOCUMENT_NAME, x.DOCUMENT_NO, x.DOCUMENT_URL, x.REVISION, x.CURRENT_PAGE,
634
                                x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.DOCUMENT_URL, convertpath[0], convertpath[1], x.RECONVERTER);
635
                            Listitems.Add(AddItem);
636
 
637
                        }
638
                    }
639
640
                    Listitems.ForEach(newitem =>
641 2decfbdf alzkakdixm
                    {
642
                        collection.UpdateWhere(changeitem =>
643
                        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ConvertID == newitem.ConvertID && x.ProjectNumber == newitem.ProjectNumber);
644
                    });
645 8c128693 semi
646 85f68fef semi
                    RealConvert_Height = 80 + (10 * collection.Count());
647 8c128693 semi
                    DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
648 2decfbdf alzkakdixm
                }
649 3bde451b semi
                //using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
650
                //{
651
                //    var items = database.GetConvertProjects(collection)//x:database객체 y:statusCodeTypeList의값  Count()안에 predicator 조건 만족하면 count개수안에 넣음
652
                //                          .Take(SelectedCount.ValueMember).ToList();//
653
654
                //    items.ForEach(newitem =>
655
                //    {
656
                //        collection.UpdateWhere(changeitem =>
657
                //        ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ConvertID == newitem.ConvertID && x.ProjectNumber == newitem.ProjectNumber);
658
                //    });
659
660
                //    RealConvert_Height = 80 + (10 * collection.Count());
661
                //    DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
662
                //}
663 2decfbdf alzkakdixm
            }
664
            catch (Exception ex)
665
            {
666
                MessageBox.Show(ex.ToString());
667
            }
668
        }
669
670 a6e5055d alzkakdixm
        private void DataSelect(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
671
        {
672
            try
673
            {
674 30680747 semi
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
675 a6e5055d alzkakdixm
                {
676
677 2decfbdf alzkakdixm
                    int _status = 0;
678
                    if (SelectedStatus != null)
679
                    {
680
                        _status = (int)SelectedStatus.Value;
681
                    }
682
683 3bde451b semi
                    var items = entities.SELECT_CONVERT_ITEM(null, null, null, _status, SelectedCount.ValueMember, null, null, null,
684 30680747 semi
                        null, null, null, null, null, null, null, null, null, null).ToList();
685 3bde451b semi
                    //var items = database.GetConvertProjects(_status, ProjectNumberFilter, UniqueKeyFilter, Document_NameFilter, Service_IDFilter, Docuemnt_NOFilter
686
                    //    , ReconverterFilter, RevisionFilter)//x:database객체 y:statusCodeTypeList의값  Count()안에 predicator 조건 만족하면 count개수안에 넣음
687
                    //                      .Take(SelectedCount.ValueMember).ToList();
688 218e5002 semi
689 3bde451b semi
                    List<ConvertItem> Listitems = new List<ConvertItem>();
690
691
                    foreach (var x in items)
692
                    {
693
                        var convertpath = GetSearchConvertPathAndMarkus(x.PROJECT_NO, x.DOCUMENT_ID);
694
695
                        ConvertItem AddItem = new ConvertItem(x.SERVICE_ID, x.ID, x.PROJECT_NO, x.STATUS, x.DOCUMENT_ID, x.DOCUMENT_NAME, x.DOCUMENT_NO, x.DOCUMENT_URL, x.REVISION, x.CURRENT_PAGE,
696
                            x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.DOCUMENT_URL, convertpath[0], convertpath[1], x.RECONVERTER);
697
                        Listitems.Add(AddItem);
698
699
                    }
700 2decfbdf alzkakdixm
701 a6e5055d alzkakdixm
                    if (collection.Count() == 0)
702
                    {
703 2decfbdf alzkakdixm
                        if (statusCodeTypeList.Count() == 1)
704
                        {
705 3bde451b semi
                            Listitems.ForEach(x => collection.Add(x));
706 2decfbdf alzkakdixm
                        }
707 a6e5055d alzkakdixm
                    }
708
                    else
709
                    {
710 2decfbdf alzkakdixm
711
                        ////세미 업데이트
712 3bde451b semi
                        Listitems.ForEach(newitem =>
713 a6e5055d alzkakdixm
                        {
714
                            collection.UpdateWhere(changeitem =>
715 2decfbdf alzkakdixm
                            ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
716 a6e5055d alzkakdixm
                        });
717
718 2decfbdf alzkakdixm
                        if (statusCodeTypeList.Count() == 1)
719 a6e5055d alzkakdixm
                        {
720 2decfbdf alzkakdixm
                            //삭제
721
                            for (int i = collection.Count() - 1; i >= 0; --i)
722 a6e5055d alzkakdixm
                            {
723 2decfbdf alzkakdixm
                                var item = collection[i];
724 a6e5055d alzkakdixm
725 3bde451b semi
                                if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)//디비에서 가져온 값과 마지막값부터 차례대로 비교
726 2decfbdf alzkakdixm
                                {//참=> 0제외한 모든 수
727
                                    collection.RemoveAt(i);
728
                                }
729
                            }
730 a6e5055d alzkakdixm
                        }
731
732 2decfbdf alzkakdixm
                        if (statusCodeTypeList.Count() == 1)
733 a6e5055d alzkakdixm
                        {
734 2decfbdf alzkakdixm
                            //추가 convert 후 추가됨
735 3bde451b semi
                            foreach (var item in Listitems)
736 2decfbdf alzkakdixm
                            {
737
                                if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)//그리드와 디비 변동 없으면 안들어감
738
                                {
739
                                    /*for (int i = 0; i < collection.Count()+1; i++)//위 그리드에서 카운드 개수 변함 없고 컨버터 끝난 후 추가할때 createtime 비교 하며 order by 순으로 추가*/
740
                                    for (int i = 0; i < 200; i++)
741
                                    {
742
                                        if (i < collection.Count() - 1)
743
                                        {
744
                                            if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
745
                                            {
746
                                                collection.Insert(i, item);
747
                                                break;
748
                                            }
749
                                        }
750
                                        else
751
                                        {
752
                                            collection.Add(item);
753
                                            break;
754
                                        }
755
                                    }
756
757
                                }
758 a6e5055d alzkakdixm
759
                            }
760
                        }
761 2decfbdf alzkakdixm
762 a6e5055d alzkakdixm
                    }
763
                }
764 2decfbdf alzkakdixm
765 a6e5055d alzkakdixm
            }
766
            catch (Exception ex)
767
            {
768 b63dcfbb semi
                //MessageBox.Show(ex.ToString());
769
                System.Diagnostics.Debug.WriteLine(ex.ToString());
770 a6e5055d alzkakdixm
            }
771
        }
772
773 b63dcfbb semi
        private void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
774
        {
775
            try
776
            {
777 30680747 semi
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
778 b63dcfbb semi
                {
779 3bde451b semi
                    int _status = 0;
780
                    if (SelectedStatus != null)
781 218e5002 semi
                    {
782 3bde451b semi
                        _status = (int)SelectedStatus.Value;
783
                    }
784 b63dcfbb semi
785 3bde451b semi
                    //DocumentID = unikey
786
                    DateTime? Start_CreateTime = null;
787
                    DateTime? Finish_CreateTime = null;
788
                    if(SelectedCreateTimeBegin != DefaultCreateTime)
789
                    {
790
                        Start_CreateTime = SelectedCreateTimeBegin;
791
                    }
792
                    if(SelectedCreateTimeEnd != DefaultCreateTime)
793
                    {
794
                        Finish_CreateTime = SelectedCreateTimeEnd;
795
                    }
796 b63dcfbb semi
797 3bde451b semi
                    var items = entities.SELECT_CONVERT_ITEM(null, ProjectNumberFilter, UniqueKeyFilter, _status, SelectedCount.ValueMember, Start_CreateTime, Finish_CreateTime, null,
798 30680747 semi
                        null, null, null, GroupNOFilter, Document_NameFilter, Docuemnt_NOFilter, RevisionFilter, Service_IDFilter, ReconverterFilter, DOCUMENT_URLFilter).ToList();
799 b63dcfbb semi
800 3bde451b semi
                    List<ConvertItem> Listitems = new List<ConvertItem>();
801 b63dcfbb semi
802 3bde451b semi
                    foreach (var x in items)
803
                    {
804
                        var convertpath = GetSearchConvertPathAndMarkus(x.PROJECT_NO, x.DOCUMENT_ID);
805 b63dcfbb semi
806 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,
807
                            x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME, x.DOCUMENT_URL, convertpath[0], convertpath[1], x.RECONVERTER);
808
                        Listitems.Add(AddItem);
809 b63dcfbb semi
810 3bde451b semi
                    }
811 218e5002 semi
812 3bde451b semi
                    if (collection.Count() == 0)
813
                    {
814
                        if (statusCodeTypeList.Count() == 1)
815 b63dcfbb semi
                        {
816 3bde451b semi
                            foreach (var x in Listitems)
817 b63dcfbb semi
                            {
818 3bde451b semi
                                collection.Add(x);
819 b63dcfbb semi
                            }
820
                        }
821 3bde451b semi
                    }
822
                    else
823
                    {
824
825
                        ////세미 업데이트
826
                        foreach (var newitem in Listitems)
827 b63dcfbb semi
                        {
828 3bde451b semi
                            collection.UpdateWhere(changeitem =>
829
                            ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
830
                        }
831 b63dcfbb semi
832
833 3bde451b semi
                        if (statusCodeTypeList.Count() == 1)
834
                        {
835 b63dcfbb semi
836 3bde451b semi
                            //삭제
837
                            for (int i = collection.Count() - 1; i >= 0; --i)
838 b63dcfbb semi
                            {
839 3bde451b semi
                                var item = collection[i];
840 b63dcfbb semi
841 3bde451b semi
                                if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
842 b63dcfbb semi
                                {
843 3bde451b semi
                                    collection.RemoveAt(i);
844 b63dcfbb semi
                                }
845
                            }
846 3bde451b semi
                        }
847 b63dcfbb semi
848 3bde451b semi
                        if (statusCodeTypeList.Count() == 1)
849
                        {
850
                            //추가 convert 후 추가됨
851
                            foreach (var item in Listitems)
852 b63dcfbb semi
                            {
853 3bde451b semi
                                if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
854 b63dcfbb semi
                                {
855 3bde451b semi
                                    for (int i = 0; i < 200; i++)
856 b63dcfbb semi
                                    {
857 3bde451b semi
                                        if (i < collection.Count() - 1)
858 b63dcfbb semi
                                        {
859 3bde451b semi
                                            if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
860 218e5002 semi
                                            {
861 3bde451b semi
                                                collection.Insert(i, item);
862 b63dcfbb semi
                                                break;
863
                                            }
864
                                        }
865 3bde451b semi
                                        else
866
                                        {
867
                                            collection.Add(item);
868
                                            break;
869
                                        }
870 b63dcfbb semi
                                    }
871
872
                                }
873
874 3bde451b semi
                            }
875 218e5002 semi
                        }
876 3bde451b semi
877 b63dcfbb semi
                    }
878 3bde451b semi
879 b63dcfbb semi
                }
880
881
            }
882
            catch (Exception ex)
883
            {
884
                //MessageBox.Show(ex.ToString());
885
                System.Diagnostics.Debug.WriteLine(ex.ToString());
886
            }
887
        }
888 e6281033 alzkakdixm
        /// <summary>
889
        /// 서비스의 실시간 컨버터 Item
890
        /// </summary>
891
        private async void AliveDataSelect()
892 a6e5055d alzkakdixm
        {
893 e6281033 alzkakdixm
            try
894 a6e5055d alzkakdixm
            {
895 e6281033 alzkakdixm
                List<ConvertItem> newitems = new List<ConvertItem>();
896 3bde451b semi
                foreach (var client in App.StationClientList)
897 e6281033 alzkakdixm
                {
898 3bde451b semi
                    if (await SimplePingAsync(client.Endpoint.Address.ToString()))
899 e6281033 alzkakdixm
                    {
900 3bde451b semi
                        try
901 e6281033 alzkakdixm
                        {
902 3bde451b semi
                            List<ConvertItem> itemsToList = new List<ConvertItem>();
903
                            var items = await client.AliveConvertListAsync();
904
                            string result = "";
905 8c128693 semi
906 3bde451b semi
                            foreach (var item in items)
907
                            {
908
                                ConvertItem itemsToEach = new ConvertItem();
909
                                itemsToEach.ServiceID = item.ServiceID;
910
                                itemsToEach.ConvertID = item.ConvertID;
911
                                itemsToEach.ProjectNumber = item.ProjectNumber;
912 8c128693 semi
913 3bde451b semi
                                var convertpath = GetSearchConvertPathAndMarkus(item.ProjectNumber, item.UniqueKey);
914 8c128693 semi
915 3bde451b semi
                                if (item.ConvertState != null)
916
                                {
917
                                    itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
918 e6281033 alzkakdixm
                                }
919
920 3bde451b semi
                                if (item.OriginfilePath.Contains("/"))
921
                                {
922
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
923
                                }
924
                                else
925 8c128693 semi
                                {
926 3bde451b semi
                                    result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
927 8c128693 semi
                                }
928 3bde451b semi
                                itemsToEach.FileName = result;
929
930
                                itemsToEach.CurrentPageNo = item.CurrentPageNo;
931
                                itemsToEach.TotalPage = item.TotalPage;
932
                                itemsToEach.OriginfilePath = item.OriginfilePath;
933
                                itemsToEach.ConvertPath = item.ConvertPath;
934
                                itemsToEach.MarkusLink = convertpath[1];
935
                                itemsToEach.UniqueKey = item.UniqueKey;//DocumentNO 없음
936
                                itemsToEach.GroupNo = item.GroupNo;//없음 
937
                                itemsToEach.ProcessorAffinity = item.ProcessorAffinity;
938 5feff9f0 semi
                                itemsToEach.DocumentName = item.DocumnetName;
939 3bde451b semi
                                itemsToEach.Revision = item.Revision;//없음
940
                                itemsToEach.Exception = item.Exception;//없음
941
                                itemsToEach.ConvertPath = convertpath[0];
942
                                itemsToEach.CreateTime = item.CreateTime;
943
                                itemsToEach.ReConverter = item.ReConverter;
944
                                itemsToEach.DocumentID = item.DocumentID;
945
                                itemsToEach.StartTime = item.StartTime;
946
                                itemsToEach.EndTime = item.EndTime;
947
948
                                itemsToList.Add(itemsToEach);
949 e6281033 alzkakdixm
                            }
950 3bde451b semi
                            newitems.AddRange(itemsToList);
951
                            System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
952
953
                            if (items.Count() == 0)
954 e6281033 alzkakdixm
                            {
955 3bde451b semi
                                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
956 e6281033 alzkakdixm
                            }
957
                        }
958 3bde451b semi
                        catch (Exception ex)
959 e6281033 alzkakdixm
                        {
960 3bde451b semi
                            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
961 e6281033 alzkakdixm
                        }
962
                    }
963 3bde451b semi
                    else
964
                    {
965
                        System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
966
                    }
967
968 e6281033 alzkakdixm
                }
969
                ItemsUpdate(newitems);
970
                await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
971 3bde451b semi
972
                //List<ConvertItem> newitems = new List<ConvertItem>();
973
                //using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
974
                //{
975
                //    foreach (var client in App.StationClientList)
976
                //    {
977
                //        if (await SimplePingAsync(client.Endpoint.Address.ToString()))
978
                //        {
979
                //            try
980
                //            {
981
                //                List<ConvertItem> itemsToList = new List<ConvertItem>();
982
                //                var items = await client.AliveConvertListAsync();
983
                //                string result = "";
984
985
                //                foreach (var item in items)
986
                //                {
987
                //                    ConvertItem itemsToEach = new ConvertItem();
988
                //                    itemsToEach.ServiceID = item.ServiceID;
989
                //                    itemsToEach.ConvertID = item.ConvertID;
990
                //                    itemsToEach.ProjectNumber = item.ProjectNumber;
991
992
                //                    var convertpath = database.GetSearchConvertPathAndMarkus(item.ProjectNumber, item.UniqueKey);
993
994
                //                    if (item.ConvertState != null)
995
                //                    {
996
                //                        itemsToEach.ConvertState = (StatusCodeType)Enum.Parse(typeof(StatusCodeType), item.ConvertState);
997
                //                    }
998
999
                //                    if (item.OriginfilePath.Contains("/"))
1000
                //                    {
1001
                //                        result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("/") + 1);
1002
                //                    }
1003
                //                    else
1004
                //                    {
1005
                //                        result = item.OriginfilePath.Substring(item.OriginfilePath.LastIndexOf("%") + 1);
1006
                //                    }
1007
                //                    itemsToEach.FileName = result;
1008
1009
                //                    itemsToEach.CurrentPageNo = item.CurrentPageNo;
1010
                //                    itemsToEach.TotalPage = item.TotalPage;
1011
                //                    itemsToEach.OriginfilePath = item.OriginfilePath;
1012
                //                    itemsToEach.ConvertPath = item.ConvertPath;
1013
                //                    itemsToEach.MarkusLink = convertpath[1];
1014
                //                    itemsToEach.UniqueKey = item.UniqueKey;
1015
                //                    itemsToEach.GroupNo = item.GroupNo;
1016
                //                    itemsToEach.ProcessorAffinity = item.ProcessorAffinity;
1017
                //                    itemsToEach.DocumnetName = item.DocumnetName;
1018
                //                    itemsToEach.Revision = item.Revision;
1019
                //                    itemsToEach.Exception = item.Exception;
1020
                //                    itemsToEach.ConvertPath = convertpath[0];
1021
                //                    itemsToEach.CreateTime = item.CreateTime;
1022
                //                    itemsToEach.ReConverter = item.ReConverter;
1023
                //                    itemsToEach.DocumentID = item.DocumentID;
1024
                //                    itemsToEach.StartTime = item.StartTime;
1025
                //                    itemsToEach.EndTime = item.EndTime;
1026
1027
                //                    itemsToList.Add(itemsToEach);
1028
                //                }
1029
                //                newitems.AddRange(itemsToList);
1030
                //                System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
1031
1032
                //                if (items.Count() == 0)
1033
                //                {
1034
                //                    System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
1035
                //                }
1036
                //            }
1037
                //            catch (Exception ex)
1038
                //            {
1039
                //                System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} {ex.Message}");
1040
                //            }
1041
                //        }
1042
                //        else
1043
                //        {
1044
                //            System.Diagnostics.Trace.Fail($"{client.Endpoint.Address} ping Error");
1045
                //        }
1046
                //    }
1047
                //}
1048
                //ItemsUpdate(newitems);
1049
                //await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => ItemsUpdate(newitems));
1050 e6281033 alzkakdixm
            }
1051
            catch (Exception ex)
1052
            {
1053
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1054 a6e5055d alzkakdixm
            }
1055
        }
1056
1057 e6281033 alzkakdixm
        /// <summary>
1058
        /// AliveDataSelect의 Data Update
1059
        /// </summary>
1060
        /// <param name="newitems"></param>
1061
        private void ItemsUpdate(List<ConvertItem> newitems)
1062 a6e5055d alzkakdixm
        {
1063
1064 e6281033 alzkakdixm
            foreach (var item in newitems)
1065
            {
1066
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
1067
            }
1068
1069
            if (AliveItems == null)
1070
            {
1071
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
1072
1073
                foreach (var item in newitems)
1074
                {
1075
                    AliveItems.Add(item);
1076
                }
1077
            }
1078
            else
1079 a6e5055d alzkakdixm
            {
1080 e6281033 alzkakdixm
                /// 데이터 업데이트
1081
                newitems.ForEach(newitem =>
1082
                {
1083
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
1084
                });
1085
1086
                // 추가
1087
                foreach (var item in newitems)
1088
                {
1089
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1090
                    {
1091
                        AliveItems.Add(item);
1092
                    }
1093
                }
1094 a6e5055d alzkakdixm
1095 e6281033 alzkakdixm
                /// 삭제
1096 2decfbdf alzkakdixm
1097 e6281033 alzkakdixm
                for (int i = AliveItems.Count() - 1; i > -1; --i)
1098
                {
1099
                    var item = AliveItems[i];
1100 a6e5055d alzkakdixm
1101 e6281033 alzkakdixm
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
1102
                    {
1103
                        try
1104
                        {
1105
                            AliveItems.RemoveAt(i);
1106
                        }
1107
                        catch (Exception ex)
1108
                        {
1109
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
1110
                        }
1111
                    }
1112
                }
1113 2decfbdf alzkakdixm
            }
1114 8c128693 semi
1115 85f68fef semi
            Alive_Height = 80 + (newitems.Count() * 10);
1116
            DataBase_ItemsHeight = 800 - (RealConvert_Height + Alive_Height);
1117 a6e5055d alzkakdixm
        }
1118
1119
1120 e6281033 alzkakdixm
        public static async Task<bool> SimplePingAsync(string uri)
1121 a6e5055d alzkakdixm
        {
1122 e6281033 alzkakdixm
            bool result = false;
1123
1124
            try
1125
            {
1126
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
1127
                {
1128
                    Client.Timeout = new TimeSpan(0, 0, 60);
1129
1130
                    var message = await Client.GetAsync(uri);
1131
1132
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
1133
1134
                    switch (StatusCode)
1135
                    {
1136
1137
                        case System.Net.HttpStatusCode.Accepted:
1138
                        case System.Net.HttpStatusCode.OK:
1139
                            result = true;
1140
                            break;
1141
                    }
1142
                }
1143
            }
1144
            catch (Exception ex)
1145
            {
1146
                result = false;
1147
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1148
            }
1149
1150
            return result;
1151 a6e5055d alzkakdixm
        }
1152
1153 e6281033 alzkakdixm
        #endregion
1154
1155
        #region Data Convert
1156 a6e5055d alzkakdixm
1157 e6281033 alzkakdixm
        private void DataConvert(object obj)
1158
        {
1159
            if (SelectFilterConvert == null && SelectRealConvert == null)
1160
            {
1161
                MessageBox.Show("왼쪽 버튼 클릭 후 Converter 해주세요!");
1162
            }
1163
            else
1164 a6e5055d alzkakdixm
            {
1165 3bde451b semi
                //ConvertDatabase _DataConvert = new ConvertDatabase(App.MarkusDataBaseConnecitonString);
1166 e6281033 alzkakdixm
                var resultRealConvert = 0;
1167
                var resultFiltertConvert = 0;
1168
1169
                if (SelectRealConvert != null)
1170
                {
1171 3bde451b semi
                    //resultRealConvert = _DataConvert.SetCleanUpItem(SelectRealConvert);//ConvertDataBase
1172
                    resultRealConvert = SetCleanUpItem(SelectRealConvert);//ConvertDataBase
1173 e6281033 alzkakdixm
                }
1174
                else if (SelectFilterConvert != null)
1175 a6e5055d alzkakdixm
                {
1176 3bde451b semi
                    //resultFiltertConvert = _DataConvert.SetCleanUpItem(SelectFilterConvert);//ConvertDataBase
1177
                    resultFiltertConvert = SetCleanUpItem(SelectFilterConvert);
1178 e6281033 alzkakdixm
                }
1179
                System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
1180
1181 30680747 semi
                using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1182 e6281033 alzkakdixm
                {
1183
1184 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); //프로시저 이용
1185 3bde451b semi
1186
1187
                    foreach (var x in items)
1188 8c7d1ea1 alzkakdixm
                    {
1189 3bde451b semi
                        var convertpath = GetSearchConvertPathAndMarkus(x.PROJECT_NO, x.DOCUMENT_ID);
1190
1191
                        ConvertItem AddItem = new ConvertItem(x.SERVICE_ID, x.ID, x.PROJECT_NO, x.STATUS, x.DOCUMENT_ID, x.DOCUMENT_NAME, x.DOCUMENT_NO, x.DOCUMENT_URL, x.REVISION, x.CURRENT_PAGE, x.TOTAL_PAGE, x.EXCEPTION, x.GROUP_NO, x.CREATE_DATETIME, x.START_DATETIME, x.END_DATETIME
1192
                         , x.DOCUMENT_URL, convertpath[0], convertpath[1], x.RECONVERTER);
1193
1194
                        RealConvertSource.Add(AddItem);
1195
1196
                        if (RealConvertSource.Count() == 1)
1197
                        {
1198
                            ConvertShow = true;
1199
                        }
1200 8c7d1ea1 alzkakdixm
                    }
1201 3bde451b semi
1202 a6e5055d alzkakdixm
                }
1203 3bde451b semi
1204
                //ConvertDataBase
1205
                //using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(App.MarkusDataBaseConnecitonString))
1206
                //{
1207
                //    var items = database.GetConvertProjects(SelectFilterConvert);
1208
1209
                //    foreach (var item in items)
1210
                //    {
1211
                //        RealConvertSource.Add(item);
1212
                //    }
1213
                //    if (RealConvertSource.Count() == 1)
1214
                //    {
1215
                //        ConvertShow = true;
1216
                //    }
1217
                //}
1218
            }
1219
        }
1220
1221
1222
        public int SetCleanUpItem(ConvertItem _ConvertItem)
1223
        {
1224 30680747 semi
            using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1225 3bde451b semi
            {
1226
                int result = 0;
1227
1228 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();
1229 3bde451b semi
1230
                if (items.Count() > 0)
1231
                {
1232
                    var item = items.First();
1233
1234
                    var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
1235
                    var _CREATE_DATETIME = DateTime.Now;
1236
                    var _STATUS = (int)StatusCodeType.None;
1237
1238
                  entities.SELECT_RERECONVERT_ITEM(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null);//_END_DATETIME = null 에러
1239
1240
                }
1241
1242
                return result;
1243
            }
1244
        }
1245
1246
        public string[] GetSearchConvertPathAndMarkus(string PROJECT_NO, string DOCUMENT_ID)
1247
        {
1248
            string[] ConvertPath = new string[2];
1249
            ConvertPath[0] = GetConvertPath(PROJECT_NO, DOCUMENT_ID);
1250 2c634aed semi
            ConvertPath[1] = "kcom://" + CreateMarkusParam(PROJECT_NO, DOCUMENT_ID, "doftech");
1251 3bde451b semi
1252
            return ConvertPath;
1253
        }
1254
1255
        #region Convert Path
1256
1257
        private string GetConvertPath(string ProjectNo, string DocumentID)
1258
        {
1259
            try
1260
            {
1261
                return Path.Combine(BaseStorage(ProjectNo), ProjectNo + "_Tile", (System.Convert.ToInt64(DocumentID) / 100).ToString(), DocumentID);
1262
            }
1263
            catch (Exception)
1264
            {
1265
                throw new Exception("GetConvertPath Error");
1266
            }
1267
1268
        }
1269
1270
        private string BaseStorage(string ProjectNo)
1271
        {
1272 30680747 semi
            using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1273 3bde451b semi
            {
1274
                string result = "";
1275
1276 30680747 semi
                var properties = entities.SELECT_CONVERT_ITEM(null, ProjectNo, null, null, 1, null, null, null, null, null, null, null, null,  null, null, null, null, null).ToList();
1277 3bde451b semi
                //var properties = entities.PROPERTIES.Where(f => f.PROPERTY == ProjectNo && f.TYPE == PROPERTIES_DEFINE.TILE_SOURCE_STORAGE);//
1278
1279
1280
                if (properties.Count() > 0)
1281
                {
1282
                    result = properties.First().PROPERTIES_VALUE;
1283
                }
1284
                else
1285
                {
1286
                    throw new Exception($"Project {ProjectNo} BaseStorage Not Setting.");
1287
                }
1288
1289
                return result;
1290 a6e5055d alzkakdixm
            }
1291 e6281033 alzkakdixm
        }
1292
1293 2c634aed semi
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
1294
        {
1295
            ViewInfo viewInfo = new ViewInfo();
1296
1297
            viewInfo.DocumentItemID = documentID;
1298
            viewInfo.ProjectNO = projectNo;
1299
            viewInfo.UserID = userID;
1300
1301
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
1302
1303
        }
1304
1305
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
1306
        {
1307
1308
            if (oEncoding == null)
1309
                oEncoding = System.Text.Encoding.UTF8;
1310
1311
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
1312
1313
        }
1314
1315 e6281033 alzkakdixm
        #endregion
1316
1317 3bde451b semi
        #endregion
1318
1319 e6281033 alzkakdixm
        #region Validation
1320 a6e5055d alzkakdixm
1321 e6281033 alzkakdixm
        private void DataValidate(object obj)
1322
        {
1323
1324
            bool result = false;
1325 a6e5055d alzkakdixm
1326 e6281033 alzkakdixm
            WebRequest webRequest = WebRequest.Create(SelectFilterConvert.OriginfilePath);
1327
            webRequest.Timeout = 1200; // miliseconds
1328
            webRequest.Method = "HEAD";
1329
1330
            HttpWebResponse response = null;
1331
1332
            try
1333
            {
1334
                response = (HttpWebResponse)webRequest.GetResponse();
1335
                result = true;
1336
            }
1337
            catch (WebException webException)
1338
            {
1339
                MessageBox.Show(SelectFilterConvert.FileName + " doesn't exist: " + webException.Message);
1340
                result = true;
1341
            }
1342
            finally
1343 a6e5055d alzkakdixm
            {
1344 e6281033 alzkakdixm
                if (response != null)
1345 a6e5055d alzkakdixm
                {
1346 e6281033 alzkakdixm
                    response.Close();
1347 a6e5055d alzkakdixm
                }
1348 2decfbdf alzkakdixm
            }
1349 e6281033 alzkakdixm
            if (result == true)
1350
            {
1351
                MessageBox.Show("File exists");
1352
            }
1353
        }
1354
1355
        #endregion
1356
1357 b63dcfbb semi
        #region DataFilter
1358
1359
        public void DataFilter(object obj)
1360
        {
1361
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1362
            DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
1363
            //dispatcherTimer.Start();
1364
        }
1365
1366
        #endregion
1367
1368 e78f0871 alzkakdixm
        #region MarkusLink
1369
1370
        private void MarkusLink(object obj)///여기서 부터 
1371
        {
1372
            if (obj is ConvertItem)
1373
            {
1374
                if (obj != null)
1375
                {
1376
                    var convertitem = obj as ConvertItem;
1377
1378
                    SelectFilterConvert = convertitem;
1379
1380
                    SelectRealConvert = convertitem;
1381
1382
                    ProcessStartInfo startInfo = null;
1383
1384
                    startInfo = new ProcessStartInfo("iexplore.exe", convertitem.MarkusLink);
1385
1386
                    Process.Start(startInfo);
1387
                }
1388
            }
1389
        }
1390
1391
        #endregion
1392
1393 e6281033 alzkakdixm
        #region Data Delete
1394
1395
        private void DataDelete(object obj)
1396
        {
1397 8c7d1ea1 alzkakdixm
            RadWindow.Alert("do you want to delete it??", this.OnClosed);
1398 e6281033 alzkakdixm
        }
1399
1400
        private void OnClosed(object sender, WindowClosedEventArgs e)
1401
        {
1402 30680747 semi
            using (markusEntities entities = new markusEntities(App.MarkusDataBaseConnecitonString))
1403 e6281033 alzkakdixm
            {
1404 3bde451b semi
                var result = e.DialogResult;
1405
                if (result == true)
1406
                {
1407
                    if (SelectRealConvert != null)
1408
                    {
1409
                        entities.SELECT_CONVERT_DELETE(SelectRealConvert.ConvertID);
1410
                    }
1411
                    if (SelectFilterConvert != null)
1412
                    {
1413
                        entities.SELECT_CONVERT_DELETE(SelectFilterConvert.ConvertID);
1414
                    }
1415
                    //System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
1416
1417
                    //ConvertDatabase _DataConvert = new ConvertDatabase(App.MarkusDataBaseConnecitonString);
1418
                    //var resultRealConvert = _DataConvert.RemoveItem(SelectRealConvert.ConvertID);
1419
                    //var resultFiltertConvert = _DataConvert.RemoveItem(SelectFilterConvert.ConvertID);
1420
                    //System.Diagnostics.Debug.WriteLine(resultRealConvert + "  " + resultFiltertConvert);
1421
                }
1422 e6281033 alzkakdixm
            }
1423
        }
1424
1425
1426
        #endregion
1427
1428
        #region Data Export
1429
1430
1431
        /// <summary>
1432
        /// 필터된 상단 그리드 엑셀로 출력
1433
        /// </summary>
1434
1435
        public void DataExportData(object obj)
1436
        {
1437
            SaveFileDialog saveFileDialog = new SaveFileDialog();
1438
1439
            saveFileDialog.FileName = "Document"; // Default file name
1440
            saveFileDialog.DefaultExt = ".txt"; // Default file extension
1441
            saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; // Filter files by extension
1442
1443
1444
            if (saveFileDialog.ShowDialog() == true)
1445 2decfbdf alzkakdixm
            {
1446 e6281033 alzkakdixm
1447
1448
                if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName))
1449 0cb12397 alzkakdixm
                {
1450 e6281033 alzkakdixm
1451
                    var extension = new System.IO.FileInfo(saveFileDialog.FileName).Extension;
1452
1453
                    if (extension == ".xlsx" || extension == ".csv")
1454
                    {
1455
1456
                        var headers = new List<HeaderMember>
1457
                        {
1458
                            new HeaderMember{HeaderName = "ServiceID", Property = "ServiceID" },
1459
                            new HeaderMember{HeaderName = "ConvertID", Property = "ConvertID" },
1460
                            new HeaderMember{HeaderName = "ProjectNumber", Property = "ProjectNumber" },
1461
                            new HeaderMember{HeaderName = "ConvertState", Property = "ConvertState" },
1462
                            new HeaderMember{HeaderName = "CurrentPageNo", Property = "CurrentPageNo" },
1463
                            new HeaderMember{HeaderName = "TotalPage", Property = "TotalPage" },
1464
                            new HeaderMember{HeaderName = "OriginfilePath", Property = "OriginfilePath" },
1465
                            new HeaderMember{HeaderName = "ConvertPath", Property = "ConvertPath" },
1466
                            new HeaderMember{HeaderName = "CreateTime", Property = "CreateTime" },
1467
                            new HeaderMember{HeaderName = "Exception", Property = "Exception" },
1468
                            new HeaderMember{HeaderName = "ProcessorAffinity", Property = "ProcessorAffinity" },
1469
                            new HeaderMember{HeaderName = "ReConverter", Property = "ReConverter" },
1470
                            new HeaderMember{HeaderName = "UniqueKey", Property = "UniqueKey" }
1471
                        };
1472
1473
1474
                        DataExport dataExport = new DataExport();
1475
                        dataExport.DataExportExcel(saveFileDialog.FileName, "Hello world", FilterConvertSource, headers);
1476
                        //_dataExport.DataExportExcel(saveFileDialog.FileName, saveFileDialog.FileName.ToString(),  Projectsource, headers);
1477
                        //GemBoxFileSave(obj);
1478
                    }
1479 0cb12397 alzkakdixm
                }
1480 2decfbdf alzkakdixm
            }
1481
        }
1482 e6281033 alzkakdixm
1483
        #endregion
1484
1485 b63dcfbb semi
        #region Data Search
1486 902f397c semi
1487 b63dcfbb semi
        public void RemoveCreateTimeFilter(object obj)
1488
        {
1489
            DefaultCreateTime = DateTime.Now;
1490
            SelectedCreateTimeBegin = DefaultCreateTime;
1491
            SelectedCreateTimeEnd = DefaultCreateTime;
1492
1493
        }
1494
1495
        #endregion
1496
1497
        #region Reset
1498
1499
        /// <summary>
1500
        /// 그리드 상단 원상복귀 버튼
1501
        /// 필터를 끝낸 후 다시 복귀
1502
        /// </summary>
1503
1504
        public void Reset(object obj)
1505 5a954acc semi
        {
1506 3bde451b semi
            ProjectNumberFilter = null;
1507
            UniqueKeyFilter = null;
1508
            Service_IDFilter = null;
1509
            Document_NameFilter = null;
1510
            Docuemnt_NOFilter = null;
1511
            ReconverterFilter = null;
1512
            RevisionFilter = null;
1513
            GroupNOFilter = null;
1514 30680747 semi
            DOCUMENT_URLFilter = null;
1515 3bde451b semi
            DefaultCreateTime = DateTime.Now;
1516
            SelectedCreateTimeBegin = DefaultCreateTime;
1517
            SelectedCreateTimeEnd = DefaultCreateTime;
1518 b63dcfbb semi
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1519 5a954acc semi
        }
1520
1521 902f397c semi
        #endregion
1522
1523 218e5002 semi
1524 8c128693 semi
        #region ConvertAddDialog
1525 218e5002 semi
1526
        /// <summary>
1527
        /// 그리드 상단 Conver 추가 버튼
1528
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
1529
        /// </summary>
1530
1531
        public void ConverAdd(object obj)
1532
        {
1533 8c128693 semi
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1534 43b2e236 semi
1535
            Views.ConvertAddDialog convertAddDialog = new Views.ConvertAddDialog();
1536 8c128693 semi
1537 3bde451b semi
            convertAddDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
1538
1539 43b2e236 semi
            convertAddDialog.ShowDialog();
1540 218e5002 semi
1541 8c128693 semi
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1542 218e5002 semi
        }
1543
1544
        #endregion
1545
1546 e6281033 alzkakdixm
        #endregion
1547 a6e5055d alzkakdixm
    }
1548
}
클립보드 이미지 추가 (최대 크기: 500 MB)