프로젝트

일반

사용자정보

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

markus / KCOM / Controls / addToFavoriteWindow_Internal.xaml.cs @ 3908a575

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

1
using IKCOM;
2
using KCOMDataModel.DataModel;
3
using System;
4
using System.Collections.Generic;
5
using System.Collections.ObjectModel;
6
using System.Linq;
7
using System.Reflection;
8
using System.Text;
9
using System.Windows;
10
using System.Windows.Controls;
11
using System.Windows.Data;
12
using System.Windows.Documents;
13
using System.Windows.Input;
14
using System.Windows.Media;
15
using System.Windows.Media.Imaging;
16
using System.Windows.Shapes;
17

    
18
namespace KCOM.Controls
19
{
20
    /// <summary>
21
    /// addToFavoriteWindow_Internal.xaml에 대한 상호 작용 논리
22
    /// </summary>
23
    public partial class addToFavoriteWindow_Internal : Window
24
    {
25
        int _typeIdx { get; set; }
26
        bool IsEditMode { get; set; }
27
        FAVORITE_DOC instanceDoc { get; set; }
28
        private ObservableCollection<string> _Favorites { get; set; }
29
        public ObservableCollection<string> Favorites
30
        {
31
            get
32
            {
33
                return _Favorites;
34
            }
35
            set
36
            {
37
                _Favorites = value;
38
            }
39
        }
40

    
41
        public addToFavoriteWindow_Internal(FAVORITE_DOC item, int typeIdx = 1)
42
        {
43
            InitializeComponent();
44
            if (item != null)
45
            {
46
                instanceDoc = item;
47
                IsEditMode = true;
48
            }
49
            this.Loaded += AddToFavoriteWindow_Internal_Loaded;
50
        }
51

    
52
        private void AddToFavoriteWindow_Internal_Loaded(object sender, RoutedEventArgs e)
53
        {
54
            Type typeFavorite = typeof(FAVORITE_FLAG);
55
            FieldInfo[] arrFavoriteValues = typeFavorite.GetFields(BindingFlags.Public | BindingFlags.Static);
56
            Favorites = new ObservableCollection<string>();
57
            foreach (var item in arrFavoriteValues)
58
            {
59
                Favorites.Add(item.GetValue(null).ToString());
60
            }
61

    
62
            Favorites.RemoveAt(0);
63
            this.DataContext = this;
64
            if (IsEditMode)
65
            {
66
                //instanceDoc
67
                tbDescription.Text = instanceDoc.DESCRIPTION;
68
                cbState.SelectedIndex = instanceDoc.FLAG - 1;
69
                btnOK.Content = "MODIFY";
70
                                
71
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.EditFavoriteVPCompleted += BaseClient_EditFavoriteVPCompleted;                
72
            }
73
            else
74
            {
75
                cbState.SelectedIndex = _typeIdx == 2 ? _typeIdx - 1 : _typeIdx;
76
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SetFavoriteVPCompleted += new EventHandler<ServiceDeepView.SetFavoriteVPCompletedEventArgs>(_Client_SetFavoriteVPCompleted);
77
            }
78
            tbDescription.Focus();
79
        }
80

    
81
        private void BaseClient_EditFavoriteVPCompleted(object sender, ServiceDeepView.EditFavoriteVPCompletedEventArgs e)
82
        {
83
            Logger.sendResLog("EditFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);           
84
            this.Close();
85
        }
86

    
87
        void _Client_SetFavoriteVPCompleted(object sender, ServiceDeepView.SetFavoriteVPCompletedEventArgs e)
88
        {
89
            Logger.sendResLog("SetFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
90
            if (e.Error != null || !e.Result)
91
            {
92
                //미입력
93
            }
94
            else
95
            {
96
                Logger.sendReqLog("GetFavoriteVPAsync" ,App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1);                
97
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
98

    
99
            }
100
            this.Close();
101
        }
102

    
103
        private void OKButton_Click(object sender, RoutedEventArgs e)
104
        {
105
            if (instanceDoc == null)
106
            {
107
                FAVORITE_FLAG flag = (FAVORITE_FLAG)Enum.Parse(typeof(FAVORITE_FLAG), cbState.Text, true);
108
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.GROUP_NO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.REVISION,
109
                   Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber, App.ViewInfo.DocumentItemID, tbDescription.Text, flag);
110
            }
111
            else
112
            {
113
                FAVORITE_FLAG flag = (FAVORITE_FLAG)Enum.Parse(typeof(FAVORITE_FLAG), cbState.Text, true);
114

    
115
                Logger.sendReqLog("EditFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," +instanceDoc.ID + "," +Convert.ToInt32(flag) + "," +tbDescription.Text, 1);
116
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.EditFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, instanceDoc.ID, Convert.ToInt32(flag), tbDescription.Text);
117
            }
118
        }
119
    }
120
}
클립보드 이미지 추가 (최대 크기: 500 MB)