프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / ConvertDocumentDialogViewModel.cs @ f85a8cad

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

1
using System;
2
using Markus.Service.StationController.Data;
3
using System.Collections.Generic;
4
using System.Linq;
5
using System.Text;
6
using System.Threading.Tasks;
7
using Telerik.Windows.Controls;
8
using System.Windows;
9
using Newtonsoft.Json;
10
using System.Windows.Threading;
11
using Markus.Service.StationController.Controls;
12

    
13
namespace Markus.Service.StationController.ViewModel
14
{
15
    class ConvertDocumentDialogViewModel : Mvvm.ToolKit.ViewModelBase
16
    {
17
        #region Constructor
18

    
19
        /// <summary>
20
        /// 실행하면 처음 들어가는 부분
21
        /// </summary>
22

    
23
        public ConvertDocumentDialogViewModel()
24
        {
25
            DocumentConvertCommand = new DelegateCommand(DocumentConvert);
26
        }
27

    
28
        #endregion
29

    
30
        #region Properties
31

    
32
        DataService.DataServiceClient WcfClient = new DataService.DataServiceClient();
33

    
34
        private System.Collections.ObjectModel.ObservableCollection<Document_Item> _Document_Items;
35
        public System.Collections.ObjectModel.ObservableCollection<Document_Item> Document_Items
36
        {
37
            get
38
            {
39
                if (_Document_Items == null)
40
                {
41
                    _Document_Items = new System.Collections.ObjectModel.ObservableCollection<Document_Item>();
42
                }
43
                return _Document_Items;
44
            }
45
            set
46
            {
47
                _Document_Items = value;
48
                OnPropertyChanged(() => Document_Items);
49
            }
50
        }
51

    
52
        private Document_Item _SelectedDocument;
53
        public Document_Item SelectedDocument
54
        {
55
            get
56
            {
57
                if (_SelectedDocument == null)
58
                {
59
                    _SelectedDocument = new Document_Item();
60
                }
61
                return _SelectedDocument;
62
            }
63
            set
64
            {
65
                _SelectedDocument = value;
66
                OnPropertyChanged(() => SelectedDocument);
67
            }
68
        }
69

    
70

    
71
        private int _Count;
72
        public int Count
73
        {
74
            get
75
            {
76
                return _Count;
77
            }
78
            set
79
            {
80
                _Count = value;
81
                OnPropertyChanged(() => Count);
82
            }
83
        }
84

    
85
        private string _RevisionFilter;
86
        public string RevisionFilter
87
        {
88
            get
89
            {
90
                return _RevisionFilter;
91
            }
92
            set
93
            {
94
                _RevisionFilter = value;
95
                OnPropertyChanged(() => RevisionFilter);
96
            }
97
        }
98

    
99
        private string _Docuemnt_NOFilter;
100
        public string Docuemnt_NOFilter
101
        {
102
            get
103
            {
104
                return _Docuemnt_NOFilter;
105
            }
106
            set
107
            {
108
                _Docuemnt_NOFilter = value;
109
                OnPropertyChanged(() => Docuemnt_NOFilter);
110
            }
111
        }
112

    
113
        private string _Document_NameFilter;
114
        public string Document_NameFilter
115
        {
116
            get
117
            {
118
                return _Document_NameFilter;
119
            }
120
            set
121
            {
122
                _Document_NameFilter = value;
123
                OnPropertyChanged(() => Document_NameFilter);
124
            }
125
        }
126

    
127
        private string _GroupNOFilter;
128
        public string GroupNOFilter
129
        {
130
            get
131
            {
132
                return _GroupNOFilter;
133
            }
134
            set
135
            {
136
                _GroupNOFilter = value;
137
                OnPropertyChanged(() => GroupNOFilter);
138
            }
139
        }
140

    
141
        private string _DOCUMENT_URLFilter;
142
        public string DOCUMENT_URLFilter
143
        {
144
            get
145
            {
146
                return _DOCUMENT_URLFilter;
147
            }
148
            set
149
            {
150
                _DOCUMENT_URLFilter = value;
151
                OnPropertyChanged(() => DOCUMENT_URLFilter);
152
            }
153
        }
154

    
155
        private string _UniqueKeyFilter;
156
        public string UniqueKeyFilter
157
        {
158
            get
159
            {
160
                return _UniqueKeyFilter;
161
            }
162
            set
163
            {
164
                _UniqueKeyFilter = value;
165
                OnPropertyChanged(() => UniqueKeyFilter);
166
            }
167
        }
168

    
169
        private string _ProjectNumberFilter;
170
        public string ProjectNumberFilter
171
        {
172
            get
173
            {
174
                return _ProjectNumberFilter;
175
            }
176
            set
177
            {
178
                _ProjectNumberFilter = value;
179
                OnPropertyChanged(() => ProjectNumberFilter);
180
            }
181
        }
182
        #endregion
183

    
184
        #region Command
185

    
186
        public DelegateCommand DocumentConvertCommand { get; private set; }
187

    
188
        #endregion
189

    
190
        #region Main Logic
191

    
192
        public async void Search_Document()
193
        {
194

    
195
            var Listitems = from num in await WcfClient.GET_DOCUMENT_ITEMAsync(Count, RevisionFilter, Docuemnt_NOFilter, Document_NameFilter, GroupNOFilter, DOCUMENT_URLFilter,
196
       UniqueKeyFilter, ProjectNumberFilter)
197
                            select new Document_Item(num.GROUP_N0, num.DOCUMENT_N0, num.DOCUMENT_ID, num.DOCUMENTID);
198

    
199
            if (Document_Items.Count() == 0)
200
            {
201
                foreach (var Listitem in Listitems.ToList())
202
                {
203
                    Document_Items.Add(Listitem);
204
                }
205
            }
206
        }
207

    
208
        #endregion
209

    
210

    
211
        #region Function
212

    
213
        #region DocumentConvert
214
        /// <summary>
215
        /// 그리드 상단 Conver 추가 버튼
216
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
217
        /// </summary>
218
        public async void DocumentConvert(object obj)
219
        {
220
            try
221
            {
222
                if (Document_Items != null)
223
                {
224
                    foreach (var Document in Document_Items)
225
                    {
226
                        if (Document.IsChecked == true)
227
                        {
228
                            var items = from x in await WcfClient.GET_SELECT_CONVERT_ITEMAsync(null, null, Document.Document_ID, null, 1, null, null, null, null, null, null, Document.Group_NO, null, Document.Document_NO, null, null, null, null, null)
229
                                        let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech")
230
                                        select new ConvertPDF(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
231
    , x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER);
232

    
233
                            if (items.Count() == 1)
234
                            {
235
                                foreach (var Listitem in items.ToList())
236
                                {
237
                                    SetCleanUpItem(Listitem);
238
                                }
239
                            }
240

    
241
                            MessageBox.Show("Document Item Convert Success");
242
                        }
243
                    }
244
                }
245
            }
246
            catch (Exception ex)
247
            {
248
                MessageBox.Show(ex.ToString());
249
            }
250
        }
251

    
252
        public static string CreateMarkusParam(string projectNo, string documentID, string userID)
253
        {
254
            ViewInfo viewInfo = new ViewInfo();
255

    
256
            viewInfo.DocumentItemID = documentID;
257
            viewInfo.ProjectNO = projectNo;
258
            viewInfo.UserID = userID;
259

    
260
            return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
261

    
262
        }
263

    
264
        public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
265
        {
266

    
267
            if (oEncoding == null)
268
                oEncoding = System.Text.Encoding.UTF8;
269

    
270
            return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
271

    
272
        }
273

    
274
        public async void SetCleanUpItem(ConvertPDF _ConvertItem)
275
        {
276

    
277
            var items = await WcfClient.GET_SELECT_CONVERT_ITEMAsync(_ConvertItem.ConvertID, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
278

    
279
            if (items.Count() > 0)
280
            {
281
                var item = items.First();
282

    
283
                var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
284
                var _CREATE_DATETIME = DateTime.Now;
285
                int _STATUS = 0;
286

    
287
                await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null);
288
            }
289
        }
290
        #endregion
291

    
292
        #endregion
293
    }
294
}
클립보드 이미지 추가 (최대 크기: 500 MB)