프로젝트

일반

사용자정보

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

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

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