프로젝트

일반

사용자정보

개정판 b63dcfbb

IDb63dcfbb07762fe4064d4368bafc3b5fb0380f89
상위 87d56836
하위 bf5f463c, 5b372dc6

semi 이(가) 약 5년 전에 추가함

markusEntities 추가

Change-Id: Iac863d0665e1d7e6ef8ceb0f709348cfb30966a2

차이점 보기:

ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/DataBaseItemsModel.cs
4 4
using Markus.Service.StationController.Data;
5 5
using Markus.Service.StationController.Behaviors;
6 6
using Markus.Service.StationController.Extensions;
7
using Markus.Service.StationController.Controls;
7 8
using Microsoft.Win32;
8 9
using System;
9 10
using System.Collections.Generic;
......
34 35
        /// </summary>
35 36
        public DataBaseItemsModel()
36 37
        {
38
            DataFilterCommand = new DelegateCommand(DataFilter);
37 39
            DataSaveFileGemBoxCommand = new DelegateCommand(DataExportData);
38 40
            ConvertCommand = new DelegateCommand(DataConvert);
39 41
            DeleteCommand = new DelegateCommand(DataDelete);
......
41 43
            MarkusLinkCommand = new DelegateCommand(MarkusLink);
42 44
            RemoveCreateTimeFilterCommand = new DelegateCommand(RemoveCreateTimeFilter);
43 45
            FilterConvertSourceView.Filter = new Predicate<object>(o => DetailFilter(o as ConvertItem));
46
            ResetCommand = new DelegateCommand(Reset);
44 47
        }
45 48

  
46 49
        #endregion
47 50

  
48 51
        #region Properties
49 52

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

  
66
                return _FilterSearch;
67
            }
68
        }
69

  
50 70
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _AliveItems;
51 71
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> AliveItems
52 72
        {
......
60 80

  
61 81
        public ICollectionView FilterConvertSourceView
62 82
        {
63
            get { return CollectionViewSource.GetDefaultView(FilterConvertSource); }
83
            get
84
            {
85
                var view = CollectionViewSource.GetDefaultView(FilterConvertSource);
86
                //if (view.CanFilter)
87
                //{
88
                //    view.Filter = DetailFilter;
89
                //    view.Filter = o => String.IsNullOrEmpty(ProjectNumberFilter) ? true : ((string)o).Contains(ProjectNumberFilter);
90
                //    view.Filter = o => String.IsNullOrEmpty(UniqueKeyFilter) ? true : ((string)o).Contains(UniqueKeyFilter);
91
                //}
92
                return view;
93
            }
64 94
        }
65 95

  
66 96
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> _FilterConvertSource;
......
229 259
            get => _ConvertShow;
230 260
            set
231 261
            {
232
                if(_ConvertShow =! value)
262
                if (_ConvertShow = !value)
233 263
                {
234 264
                    _ConvertShow = false;
235 265
                }
......
244 274
            get { return _ProjectNumberFilter; }
245 275
            set
246 276
            {
247
                if (_ProjectNumberFilter != value)
277
                if(_ProjectNumberFilter == "")
278
                {
279
                    _ProjectNumberFilter = null;
280
                }
281
                else if (_ProjectNumberFilter != value)
248 282
                {
249 283
                    _ProjectNumberFilter = value;
250 284
                    OnPropertyChanged(() => ProjectNumberFilter);
......
257 291
        public string _UniqueKeyFilter;
258 292
        public string UniqueKeyFilter
259 293
        {
260
            get { return _UniqueKeyFilter; }
294
            get
295
            {
296
                return _UniqueKeyFilter;
297
            }
261 298
            set
262 299
            {
263
                if (_UniqueKeyFilter != value)
300
                if (_UniqueKeyFilter == "")
301
                {
302
                    _UniqueKeyFilter = null;
303
                }
304
                else if (_UniqueKeyFilter != value)
264 305
                {
265 306
                    _UniqueKeyFilter = value;
266 307
                    OnPropertyChanged(() => UniqueKeyFilter);
......
292 333
            get { return _Docuemnt_NOFilter; }
293 334
            set
294 335
            {
295
                if (_Docuemnt_NOFilter != value)
336
                if (_Docuemnt_NOFilter == "")
337
                {
338
                    _Docuemnt_NOFilter = null;
339
                }
340
                else if (_Docuemnt_NOFilter != value)
296 341
                {
297 342
                    _Docuemnt_NOFilter = value;
298 343
                    OnPropertyChanged(() => Docuemnt_NOFilter);
......
308 353
            get { return _Docuemnt_NameFilter; }
309 354
            set
310 355
            {
311
                if (_Docuemnt_NameFilter != value)
356
                if (_Docuemnt_NameFilter == "")
357
                {
358
                    _Docuemnt_NameFilter = null;
359
                }
360
                else if (_Docuemnt_NameFilter != value)
312 361
                {
313 362
                    _Docuemnt_NameFilter = value;
314 363
                    OnPropertyChanged(() => Docuemnt_NameFilter);
......
318 367
            }
319 368
        }
320 369

  
321
        public int? _ReconverterFilter;
370
        public int? _ReconverterFilter = 0;
322 371
        public int? ReconverterFilter
323 372
        {
324 373
            get { return _ReconverterFilter; }
325 374
            set
326 375
            {
327
                if (_ReconverterFilter != value)
376
                if (_ReconverterFilter ==  null)
377
                {
378
                    _ReconverterFilter = 0;
379
                }
380
                else if (_ReconverterFilter != value)
328 381
                {
329 382
                    _ReconverterFilter = value;
330 383
                    OnPropertyChanged(() => ReconverterFilter);
......
341 394
            get { return _Service_IDFilter; }
342 395
            set
343 396
            {
344
                if (_Service_IDFilter != value)
397
                if (_Service_IDFilter == "")
398
                {
399
                    _Service_IDFilter = null;
400
                }
401
                else  if (_Service_IDFilter != value)
345 402
                {
346 403
                    _Service_IDFilter = value;
347 404
                    OnPropertyChanged(() => Service_IDFilter);
......
357 414
            get { return _RevisionFilter; }
358 415
            set
359 416
            {
360
                if (_RevisionFilter != value)
417
                if (_RevisionFilter == "")
418
                {
419
                    _RevisionFilter = null ;
420
                }
421
                else if (_RevisionFilter != value)
361 422
                {
362 423
                    _RevisionFilter = value;
363 424
                    OnPropertyChanged(() => RevisionFilter);
......
367 428
            }
368 429
        }
369 430

  
370
        private DateTime _SelectedCreateTimeBegin = DateTime.Now;
431
        static DateTime DefaultCreateTime = DateTime.Now;
432
        private DateTime _SelectedCreateTimeBegin = DefaultCreateTime;
371 433
        public DateTime SelectedCreateTimeBegin
372 434
        {
373 435

  
......
385 447
            }
386 448
        }
387 449

  
388
        private DateTime _SelectedCreateTimeEnd = DateTime.Now;
450
        private DateTime _SelectedCreateTimeEnd = DefaultCreateTime;
389 451
        public DateTime SelectedCreateTimeEnd
390 452
        {
391 453

  
......
403 465
            }
404 466
        }
405 467

  
468
        private string _Click = "Click";
469
        public string Click
470
        {
471

  
472
            get { return _Click; }
473
        }
406 474
        #endregion
407 475

  
408 476
        #region Command
......
412 480
        public DelegateCommand ValidateCommand { get; private set; }
413 481
        public DelegateCommand DataSaveFileGemBoxCommand { get; private set; }
414 482
        public DelegateCommand MarkusLinkCommand { get; private set; }
415
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set;}
483
        public DelegateCommand RemoveCreateTimeFilterCommand { get; private set; }
484

  
485
        public DelegateCommand DataFilterCommand { get; private set; }
486
        public DelegateCommand ResetCommand { get; private set; }
416 487

  
417 488
        #endregion
418 489

  
......
536 607
                        _status = (int)SelectedStatus.Value;
537 608
                    }
538 609

  
539
                    //var items = database.GetConvertProjects(_status)//x:database객체 y:statusCodeTypeList의값  Count()안에 predicator 조건 만족하면 count개수안에 넣음
540
                    //                      .Take(SelectedCount.ValueMember).ToList();
541
                    var items = database.GetConvertProjects(_status).ToList();
542
                    if (ProjectNumberFilter != null)
543
                    {
544
                        items.Where(x => x.ProjectNumber.Contains("/" + ProjectNumberFilter + "/"));
545
                    }
546
                    if (Docuemnt_NameFilter != null)
547
                    {
548
                        items.Where(x => x.DocumnetName.Contains("/" + Docuemnt_NameFilter + "/"));
549
                    }
550
                    if (Service_IDFilter != null)
551
                    {
552
                        items.Where(x => x.ServiceID.Contains("/" + Service_IDFilter + "/"));
553
                    }
554
                    if (UniqueKeyFilter != null)
555
                    {
556
                        items.Where(x => x.UniqueKey.Contains("/" + UniqueKeyFilter + "/"));
557
                    }
558
                    if (Docuemnt_NOFilter != null)
559
                    {
560
                        items.Where(x => x.DocumnetNo.Contains("/" + Docuemnt_NOFilter + "/"));
561
                    }
562
                    if (ReconverterFilter.HasValue)
563
                    {
564
                        items.Where(x => x.ReConverter == ReconverterFilter.Value);
565
                    }
566
                    if (RevisionFilter != null)
567
                    {
568
                        items.Where(x => x.Revision.Contains("/" + RevisionFilter + "/"));
569
                    }
570
                    items = items.Take(SelectedCount.ValueMember).ToList();
610
                    var items = database.GetConvertProjects(_status, ProjectNumberFilter, UniqueKeyFilter, Docuemnt_NameFilter, Service_IDFilter, Docuemnt_NOFilter
611
                        , ReconverterFilter, RevisionFilter)//x:database객체 y:statusCodeTypeList의값  Count()안에 predicator 조건 만족하면 count개수안에 넣음
612
                                          .Take(SelectedCount.ValueMember).ToList();
571 613

  
572 614
                    if (collection.Count() == 0)
573 615
                    {
......
586 628
                            ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
587 629
                        });
588 630

  
589

  
590 631
                        if (statusCodeTypeList.Count() == 1)
591 632
                        {
592 633
                            //삭제
......
637 678
            }
638 679
            catch (Exception ex)
639 680
            {
640
                MessageBox.Show(ex.ToString());
681
                //MessageBox.Show(ex.ToString());
682
                System.Diagnostics.Debug.WriteLine(ex.ToString());
641 683
            }
642 684
        }
643 685

  
686
        private void DataSearch(IEnumerable<StatusCodeType> statusCodeTypeList, System.Collections.ObjectModel.ObservableCollection<ConvertItem> collection)
687
        {
688
            try
689
            {
690
                using (markusEntities entities = new markusEntities())
691
                {
692

  
693

  
694
                    int _status = 0;
695
                    if (SelectedStatus != null)
696
                    {
697
                        _status = (int)SelectedStatus.Value;
698
                    }
699

  
700
                    //DocumentID = unikey
701

  
702
                    //null 왼쪽에서 부터 p_BEGIN_START_DATETIE, p_Finish_START_DATETIE, BEGIN_END_DATETIME, Finish_END_DATETIME, Group_No = 11로 해놈 없음 (전에 없애라고 하셔서..)
703
                    //오류떠서  [Model].Context.tt File에서  288줄  Function.Name to edmFunction.FullName바꿨더니 오류 안남
704
                    var items = entities.SELECT_CONVERT_ITEM(ProjectNumberFilter, UniqueKeyFilter, _status, SelectedCount.ValueMember, SelectedCreateTimeBegin, SelectedCreateTimeEnd, null, null, null, null,  11.ToString(),
705
                        Docuemnt_NameFilter, Docuemnt_NOFilter, RevisionFilter);//이대로 그냥 쓰면 쿼리 -> 쿼리 결과는 두 번 이상 열거할 수 없습니다 뜸
706

  
707
                    //SEARCH 할때 최소한 프로젝트 넘버랑 유니크키(다큐먼트 넘버) 크레이트타임 시작 끝 줘야함
708

  
709
                    List<ConvertItem> Listitems = new List<ConvertItem>();
710

  
711
                    foreach (var x in items)
712
                    {
713
                        ConvertItem AddItem = new ConvertItem(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);
714
                        Listitems.Add(AddItem);
715
                    }
716

  
717
                    if (collection.Count() == 0)
718
                    {
719
                        if (statusCodeTypeList.Count() == 1)
720
                        {
721
                            foreach (var x in Listitems)
722
                            {
723
                                collection.Add(x);
724
                            }
725
                        }
726
                    }
727
                    else
728
                    {
729

  
730
                        ////세미 업데이트
731
                        foreach (var newitem in Listitems)
732
                        {
733
                            collection.UpdateWhere(changeitem =>
734
                            ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
735
                        }
736

  
737

  
738
                        if (statusCodeTypeList.Count() == 1)
739
                        {
740

  
741
                            //삭제
742
                            for (int i = collection.Count() - 1; i >= 0; --i)
743
                            {
744
                                var item = collection[i];
745

  
746
                                if (Listitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
747
                                {
748
                                    collection.RemoveAt(i);
749
                                }
750
                            }
751
                        }
752

  
753
                        if (statusCodeTypeList.Count() == 1)
754
                        {
755
                            //추가 convert 후 추가됨
756
                            foreach (var item in Listitems)
757
                            {
758
                                if (collection.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
759
                                {
760
                                    for (int i = 0; i < 200; i++)
761
                                    {
762
                                        if (i < collection.Count() - 1)
763
                                        {
764
                                            if (DateTime.Compare(collection[i].CreateTime, item.CreateTime) < 0)
765
                                            {
766
                                                collection.Insert(i, item);
767
                                                break;
768
                                            }
769
                                        }
770
                                        else
771
                                        {
772
                                            collection.Add(item);
773
                                            break;
774
                                        }
775
                                    }
776

  
777
                                }
778

  
779
                            }
780
                        }
781

  
782
                    }
783
                }
784

  
785
            }
786
            catch (Exception ex)
787
            {
788
                //MessageBox.Show(ex.ToString());
789
                System.Diagnostics.Debug.WriteLine(ex.ToString());
790
            }
791
        }
644 792
        /// <summary>
645 793
        /// 서비스의 실시간 컨버터 Item
646 794
        /// </summary>
......
895 1043

  
896 1044
        #endregion
897 1045

  
1046
        #region DataFilter
1047

  
1048
        public void DataFilter(object obj)
1049
        {
1050
            dispatcherTimer.Tick -= new EventHandler(Timer_Tick);
1051
            DataSearch(new[] { (StatusCodeType)(SelectedStatus.Value) }, FilterConvertSource);
1052
            //dispatcherTimer.Start();
1053
        }
1054

  
1055
        #endregion
1056

  
898 1057
        #region MarkusLink
899 1058

  
900 1059
        private void MarkusLink(object obj)///여기서 부터 
......
999 1158

  
1000 1159
        #endregion
1001 1160

  
1002
        #region DetailFilter
1161
        #region Data Search
1003 1162

  
1004 1163

  
1005 1164
        /// <summary>
......
1029 1188
            return false;
1030 1189
        }
1031 1190

  
1032
        public void RemoveCreateTimeFilter(object obj)//미완성
1191
        public void RemoveCreateTimeFilter(object obj)
1192
        {
1193
            DefaultCreateTime = DateTime.Now;
1194
            SelectedCreateTimeBegin = DefaultCreateTime;
1195
            SelectedCreateTimeEnd = DefaultCreateTime;
1196

  
1197
        }
1198

  
1199
        #endregion
1200

  
1201
        #region Reset
1202

  
1203
        /// <summary>
1204
        /// 그리드 상단 원상복귀 버튼
1205
        /// 필터를 끝낸 후 다시 복귀
1206
        /// </summary>
1207

  
1208
        public void Reset(object obj)
1033 1209
        {
1034
            SelectedCreateTimeBegin = DateTime.Now;
1035
            SelectedCreateTimeEnd = DateTime.Now;
1210
            dispatcherTimer.Tick += new EventHandler(Timer_Tick);
1036 1211
        }
1037 1212

  
1038 1213
        #endregion

내보내기 Unified diff

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