markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / ConvertDocumentDialogViewModel.cs @ f047c8bf
이력 | 보기 | 이력해설 | 다운로드 (8.29 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 |
|
12 |
namespace Markus.Service.StationController.ViewModel |
13 |
{ |
14 |
class ConvertDocumentDialogViewModel : Mvvm.ToolKit.ViewModelBase |
15 |
{ |
16 |
#region Constructor |
17 |
|
18 |
/// <summary> |
19 |
/// 실행하면 처음 들어가는 부분 |
20 |
/// </summary> |
21 |
|
22 |
public ConvertDocumentDialogViewModel() |
23 |
{ |
24 |
DocumentConvertCommand = new DelegateCommand(DocumentConvert); |
25 |
} |
26 |
|
27 |
#endregion |
28 |
|
29 |
#region Properties |
30 |
|
31 |
DataService.DataServiceClient WcfClient = new DataService.DataServiceClient(); |
32 |
|
33 |
private System.Collections.ObjectModel.ObservableCollection<Document_Item> _Document_Items; |
34 |
public System.Collections.ObjectModel.ObservableCollection<Document_Item> Document_Items |
35 |
{ |
36 |
get |
37 |
{ |
38 |
if (_Document_Items == null) |
39 |
{ |
40 |
_Document_Items = new System.Collections.ObjectModel.ObservableCollection<Document_Item>(); |
41 |
} |
42 |
return _Document_Items; |
43 |
} |
44 |
set |
45 |
{ |
46 |
_Document_Items = value; |
47 |
OnPropertyChanged(() => Document_Items); |
48 |
} |
49 |
} |
50 |
|
51 |
private List<Document_Item> _SelectedDocument; |
52 |
public List<Document_Item> SelectedDocument |
53 |
{ |
54 |
get |
55 |
{ |
56 |
if (_SelectedDocument == null) |
57 |
{ |
58 |
_SelectedDocument = new List<Document_Item>(); |
59 |
} |
60 |
return _SelectedDocument; |
61 |
} |
62 |
set |
63 |
{ |
64 |
_SelectedDocument = value; |
65 |
OnPropertyChanged(() => SelectedDocument); |
66 |
} |
67 |
} |
68 |
|
69 |
|
70 |
private int _Count; |
71 |
public int Count |
72 |
{ |
73 |
get |
74 |
{ |
75 |
return _Count; |
76 |
} |
77 |
set |
78 |
{ |
79 |
_Count = value; |
80 |
OnPropertyChanged(() => Count); |
81 |
} |
82 |
} |
83 |
|
84 |
private string _RevisionFilter; |
85 |
public string RevisionFilter |
86 |
{ |
87 |
get |
88 |
{ |
89 |
return _RevisionFilter; |
90 |
} |
91 |
set |
92 |
{ |
93 |
_RevisionFilter = value; |
94 |
OnPropertyChanged(() => RevisionFilter); |
95 |
} |
96 |
} |
97 |
|
98 |
private string _Docuemnt_NOFilter; |
99 |
public string Docuemnt_NOFilter |
100 |
{ |
101 |
get |
102 |
{ |
103 |
return _Docuemnt_NOFilter; |
104 |
} |
105 |
set |
106 |
{ |
107 |
_Docuemnt_NOFilter = value; |
108 |
OnPropertyChanged(() => Docuemnt_NOFilter); |
109 |
} |
110 |
} |
111 |
|
112 |
private string _Document_NameFilter; |
113 |
public string Document_NameFilter |
114 |
{ |
115 |
get |
116 |
{ |
117 |
return _Document_NameFilter; |
118 |
} |
119 |
set |
120 |
{ |
121 |
_Document_NameFilter = value; |
122 |
OnPropertyChanged(() => Document_NameFilter); |
123 |
} |
124 |
} |
125 |
|
126 |
private string _GroupNOFilter; |
127 |
public string GroupNOFilter |
128 |
{ |
129 |
get |
130 |
{ |
131 |
return _GroupNOFilter; |
132 |
} |
133 |
set |
134 |
{ |
135 |
_GroupNOFilter = value; |
136 |
OnPropertyChanged(() => GroupNOFilter); |
137 |
} |
138 |
} |
139 |
|
140 |
private string _DOCUMENT_URLFilter; |
141 |
public string DOCUMENT_URLFilter |
142 |
{ |
143 |
get |
144 |
{ |
145 |
return _DOCUMENT_URLFilter; |
146 |
} |
147 |
set |
148 |
{ |
149 |
_DOCUMENT_URLFilter = value; |
150 |
OnPropertyChanged(() => DOCUMENT_URLFilter); |
151 |
} |
152 |
} |
153 |
|
154 |
private string _UniqueKeyFilter; |
155 |
public string UniqueKeyFilter |
156 |
{ |
157 |
get |
158 |
{ |
159 |
return _UniqueKeyFilter; |
160 |
} |
161 |
set |
162 |
{ |
163 |
_UniqueKeyFilter = value; |
164 |
OnPropertyChanged(() => UniqueKeyFilter); |
165 |
} |
166 |
} |
167 |
|
168 |
private string _ProjectNumberFilter; |
169 |
public string ProjectNumberFilter |
170 |
{ |
171 |
get |
172 |
{ |
173 |
return _ProjectNumberFilter; |
174 |
} |
175 |
set |
176 |
{ |
177 |
_ProjectNumberFilter = value; |
178 |
OnPropertyChanged(() => ProjectNumberFilter); |
179 |
} |
180 |
} |
181 |
#endregion |
182 |
|
183 |
#region Command |
184 |
|
185 |
public DelegateCommand DocumentConvertCommand { get; private set; } |
186 |
|
187 |
#endregion |
188 |
|
189 |
#region Main Logic |
190 |
|
191 |
public async void Search_Document() |
192 |
{ |
193 |
|
194 |
var Listitems = from num in await WcfClient.GET_DOCUMENT_ITEMAsync(Count, RevisionFilter, Docuemnt_NOFilter, Document_NameFilter, GroupNOFilter, DOCUMENT_URLFilter, |
195 |
UniqueKeyFilter, ProjectNumberFilter) |
196 |
select new Document_Item(num.GROUP_N0, num.DOCUMENT_N0, num.DOCUMENT_ID, num.DOCUMENTID); |
197 |
|
198 |
if (Document_Items.Count() == 0) |
199 |
{ |
200 |
foreach (var Listitem in Listitems.ToList()) |
201 |
{ |
202 |
Document_Items.Add(Listitem); |
203 |
} |
204 |
} |
205 |
} |
206 |
|
207 |
#endregion |
208 |
|
209 |
|
210 |
#region Function |
211 |
|
212 |
#region DocumentConvert |
213 |
/// <summary> |
214 |
/// 그리드 상단 Conver 추가 버튼 |
215 |
/// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 |
216 |
/// </summary> |
217 |
public async void DocumentConvert(object obj) |
218 |
{ |
219 |
try |
220 |
{ |
221 |
if (SelectedDocument != null) |
222 |
{ |
223 |
foreach (var Document in SelectedDocument) |
224 |
{ |
225 |
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) |
226 |
let MarkusLink = "kcom://" + CreateMarkusParam(x.PROJECT_NO, x.DOCUMENT_ID, "doftech") |
227 |
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 |
228 |
, x.DOCUMENT_URL, x.CONVERT_PATH, MarkusLink, x.RECONVERTER); |
229 |
|
230 |
if (items.Count() == 1) |
231 |
{ |
232 |
foreach (var Listitem in items.ToList()) |
233 |
{ |
234 |
SetCleanUpItem(Listitem); |
235 |
} |
236 |
} |
237 |
} |
238 |
} |
239 |
} |
240 |
catch (Exception ex) |
241 |
{ |
242 |
MessageBox.Show(ex.ToString()); |
243 |
} |
244 |
} |
245 |
|
246 |
public static string CreateMarkusParam(string projectNo, string documentID, string userID) |
247 |
{ |
248 |
ViewInfo viewInfo = new ViewInfo(); |
249 |
|
250 |
viewInfo.DocumentItemID = documentID; |
251 |
viewInfo.ProjectNO = projectNo; |
252 |
viewInfo.UserID = userID; |
253 |
|
254 |
return ParamEncoding(JsonConvert.SerializeObject(viewInfo)); |
255 |
|
256 |
} |
257 |
|
258 |
public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null) |
259 |
{ |
260 |
|
261 |
if (oEncoding == null) |
262 |
oEncoding = System.Text.Encoding.UTF8; |
263 |
|
264 |
return Convert.ToBase64String(oEncoding.GetBytes(EncodingText)); |
265 |
|
266 |
} |
267 |
|
268 |
public async void SetCleanUpItem(ConvertPDF _ConvertItem) |
269 |
{ |
270 |
|
271 |
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); |
272 |
|
273 |
if (items.Count() > 0) |
274 |
{ |
275 |
var item = items.First(); |
276 |
|
277 |
var _RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter; |
278 |
var _CREATE_DATETIME = DateTime.Now; |
279 |
int _STATUS = 0; |
280 |
|
281 |
await WcfClient.GET_SELECT_RERECONVERT_ITEMAsync(_ConvertItem.ConvertID, _RECONVERTER, _CREATE_DATETIME, _STATUS, null); |
282 |
} |
283 |
} |
284 |
#endregion |
285 |
|
286 |
#endregion |
287 |
} |
288 |
} |