markus / ConvertService / ServiceBase / Markus.Service.DataBase / ConvertDatabase.cs @ 218e5002
이력 | 보기 | 이력해설 | 다운로드 (37.7 KB)
1 | ff4b1e6e | taeseongkim | using Markus.EntityModel; |
---|---|---|---|
2 | using Markus.Message; |
||
3 | 53c9637d | taeseongkim | using Markus.Service.Extensions; |
4 | using System; |
||
5 | using System.Collections.Generic; |
||
6 | using System.IO; |
||
7 | using System.Linq; |
||
8 | 2decfbdf | alzkakdixm | using static Markus.Service.DataBase.ConvertDatabase; |
9 | using System.Windows; |
||
10 | using System.Linq.Expressions; |
||
11 | using Markus.Service.Interface; |
||
12 | 05fd750b | alzkakdixm | using Markus.Service.DataBase.Data; |
13 | using Markus.Service.DataBase.Extensions; |
||
14 | |||
15 | 53c9637d | taeseongkim | |
16 | namespace Markus.Service.DataBase |
||
17 | { |
||
18 | public class ConvertDatabase : IDisposable |
||
19 | { |
||
20 | e6281033 | alzkakdixm | #region Constructor |
21 | /// <summary> |
||
22 | ///해당 프로젝트의 데이터베이스 연결 |
||
23 | /// </summary> |
||
24 | |||
25 | ff4b1e6e | taeseongkim | Markus.EntityModel.MarkusModel entities; |
26 | 53c9637d | taeseongkim | |
27 | public ConvertDatabase(string ConnectionString) |
||
28 | { |
||
29 | try |
||
30 | { |
||
31 | ff4b1e6e | taeseongkim | entities = new Markus.EntityModel.MarkusModel(ConnectionString); |
32 | 53c9637d | taeseongkim | } |
33 | catch (Exception ex) |
||
34 | { |
||
35 | System.Diagnostics.Debug.WriteLine(ex.ToString()); |
||
36 | 06f13e11 | taeseongkim | throw ex; |
37 | 53c9637d | taeseongkim | } |
38 | } |
||
39 | |||
40 | public void Dispose() |
||
41 | { |
||
42 | entities.Dispose(); |
||
43 | } |
||
44 | |||
45 | e6281033 | alzkakdixm | #endregion |
46 | |||
47 | #region DataBaseItemsModel Function |
||
48 | |||
49 | #region Get WaitConvertItems |
||
50 | |||
51 | 53c9637d | taeseongkim | /// <summary> |
52 | e6281033 | alzkakdixm | /// service에서 대기중이거나 오류인 아이템을 가져가서 컨버터 프로세스를 호출한다. |
53 | /// 컨버터 상태가 에러이거나 2보다 작은 경우 |
||
54 | /// UniqueKey는 각 데이터베이스의 문서 정보에서 유일한 키이며 컨버터저장에서 같은 폴더로의 저장을 방지 한다. |
||
55 | /// |
||
56 | 53c9637d | taeseongkim | /// </summary> |
57 | e6281033 | alzkakdixm | /// <param name="aliveItems"></param> |
58 | /// <param name="TakeCount"></param> |
||
59 | 53c9637d | taeseongkim | /// <returns></returns> |
60 | e6281033 | alzkakdixm | public IEnumerable<CONVERTER_DOC> GetWaitConvertItems(List<string> projectList, int TakeCount) |
61 | 53c9637d | taeseongkim | { |
62 | e6281033 | alzkakdixm | var convertWaitingItems = entities.CONVERTER_DOC.OrderBy(x => x.CREATE_DATETIME).Where( |
63 | x => |
||
64 | //projectList.Contains(x.PROJECT_NO) && x.RECONVERTER < 2 && |
||
65 | x.RECONVERTER < 2 && |
||
66 | (x.STATUS == (int)StatusCodeType.None || x.STATUS == (int)StatusCodeType.FileError || x.STATUS == (int)StatusCodeType.Error)) |
||
67 | .GroupBy(x => x.DOCUMENT_ID).Select(x => x.FirstOrDefault()) |
||
68 | .Take(TakeCount); |
||
69 | 53c9637d | taeseongkim | |
70 | e6281033 | alzkakdixm | return convertWaitingItems; |
71 | } |
||
72 | 53c9637d | taeseongkim | |
73 | e6281033 | alzkakdixm | #endregion |
74 | 53c9637d | taeseongkim | |
75 | e6281033 | alzkakdixm | #region Get FilterConvertItems |
76 | 53c9637d | taeseongkim | |
77 | e6281033 | alzkakdixm | /// <summary> |
78 | /// 상단 그리드 선택된 Status에 따라 DB에서 값 가져온다. |
||
79 | /// </summary> |
||
80 | b63dcfbb | semi | public IEnumerable<Interface.ConvertItem> GetConvertProjects(int status,string ProjectNumberFilter, string UniqueKeyFilter, string Docuemnt_NameFilter, string Service_IDFilter, string Docuemnt_NOFilter, int? ReconverterFilter |
81 | , string RevisionFilter) |
||
82 | { |
||
83 | List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>(); |
||
84 | var query = from items in entities.CONVERTER_DOC |
||
85 | join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems |
||
86 | from subpet in GroupItems.DefaultIfEmpty() |
||
87 | where items.STATUS == status && |
||
88 | // |
||
89 | ( |
||
90 | items.PROJECT_NO.Contains(ProjectNumberFilter) |
||
91 | || subpet.DOCUMENT_NAME.Contains(Docuemnt_NameFilter) |
||
92 | || items.SERVICE_ID.Contains(Service_IDFilter) |
||
93 | || subpet.ID.Contains(UniqueKeyFilter) |
||
94 | || subpet.DOCUMENT_NO.Contains(Docuemnt_NOFilter) |
||
95 | || items.RECONVERTER == ReconverterFilter |
||
96 | || subpet.REVISION.Contains(RevisionFilter) |
||
97 | ) |
||
98 | // |
||
99 | orderby items.CREATE_DATETIME descending |
||
100 | select new |
||
101 | { |
||
102 | ID = items.ID, |
||
103 | DOCUMENT_URL = items.DOCUMENT_URL, |
||
104 | RECONVERTER = items.RECONVERTER, |
||
105 | SERVICE_ID = items.SERVICE_ID, |
||
106 | STATUS = items.STATUS, |
||
107 | CREATE_DATETIME = items.CREATE_DATETIME, |
||
108 | START_DATETIME = items.START_DATETIME, |
||
109 | END_DATETIME = items.END_DATETIME, |
||
110 | TOTAL_PAGE = items.TOTAL_PAGE, |
||
111 | CURRENT_PAGE = items.CURRENT_PAGE, |
||
112 | EXCEPTION = items.EXCEPTION, |
||
113 | PROJECT_NO = items.PROJECT_NO, |
||
114 | DOCUMENT_ID = items.DOCUMENT_ID, |
||
115 | REVISION = subpet.REVISION, |
||
116 | DOCUMENT_NO = subpet.DOCUMENT_NO, |
||
117 | DOCUMENT_NAME = subpet.DOCUMENT_NAME, |
||
118 | GROUP_NO = subpet.GROUP_NO, |
||
119 | }; |
||
120 | |||
121 | if (query.Count() > 0)//세미 |
||
122 | { |
||
123 | foreach (var item in query) |
||
124 | { |
||
125 | Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL) |
||
126 | { |
||
127 | |||
128 | ReConverter = item.RECONVERTER, |
||
129 | ServiceID = item.SERVICE_ID, |
||
130 | ConvertState = (StatusCodeType)item.STATUS, |
||
131 | CreateTime = item.CREATE_DATETIME, |
||
132 | StartTime = (DateTime)item.START_DATETIME, |
||
133 | EndTime = (DateTime)item.END_DATETIME, |
||
134 | TotalPage = item.TOTAL_PAGE, |
||
135 | CurrentPageNo = item.CURRENT_PAGE, |
||
136 | Exception = item.EXCEPTION, |
||
137 | ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID), |
||
138 | |||
139 | Revision = item.REVISION, |
||
140 | DocumnetNo = item.DOCUMENT_NO, |
||
141 | DocumnetName = item.DOCUMENT_NAME, |
||
142 | GroupNo = item.GROUP_NO, |
||
143 | DocumentID = item.DOCUMENT_ID, |
||
144 | |||
145 | MarkusLink = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech") |
||
146 | }; |
||
147 | convertItems.Add(convertitem); |
||
148 | } |
||
149 | } |
||
150 | return convertItems; |
||
151 | |||
152 | } |
||
153 | |||
154 | 218e5002 | semi | |
155 | e6281033 | alzkakdixm | public IEnumerable<Interface.ConvertItem> GetConvertProjects(int status) |
156 | { |
||
157 | List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>(); |
||
158 | var query = from items in entities.CONVERTER_DOC |
||
159 | join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems |
||
160 | from subpet in GroupItems.DefaultIfEmpty() |
||
161 | where items.STATUS == status |
||
162 | b63dcfbb | semi | orderby items.CREATE_DATETIME descending |
163 | 5a954acc | semi | select new |
164 | { |
||
165 | ID = items.ID, |
||
166 | DOCUMENT_URL = items.DOCUMENT_URL, |
||
167 | RECONVERTER = items.RECONVERTER, |
||
168 | SERVICE_ID = items.SERVICE_ID, |
||
169 | STATUS = items.STATUS, |
||
170 | CREATE_DATETIME = items.CREATE_DATETIME, |
||
171 | START_DATETIME = items.START_DATETIME, |
||
172 | END_DATETIME = items.END_DATETIME, |
||
173 | TOTAL_PAGE = items.TOTAL_PAGE, |
||
174 | CURRENT_PAGE = items.CURRENT_PAGE, |
||
175 | EXCEPTION = items.EXCEPTION, |
||
176 | PROJECT_NO = items.PROJECT_NO, |
||
177 | DOCUMENT_ID = items.DOCUMENT_ID, |
||
178 | REVISION = subpet.REVISION, |
||
179 | DOCUMENT_NO = subpet.DOCUMENT_NO, |
||
180 | DOCUMENT_NAME = subpet.DOCUMENT_NAME, |
||
181 | GROUP_NO = subpet.GROUP_NO, |
||
182 | }; |
||
183 | 53c9637d | taeseongkim | |
184 | e6281033 | alzkakdixm | if (query.Count() > 0)//세미 |
185 | 53c9637d | taeseongkim | { |
186 | e6281033 | alzkakdixm | foreach (var item in query) |
187 | 53c9637d | taeseongkim | { |
188 | e6281033 | alzkakdixm | Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL) |
189 | 53c9637d | taeseongkim | { |
190 | |||
191 | e6281033 | alzkakdixm | ReConverter = item.RECONVERTER, |
192 | ServiceID = item.SERVICE_ID, |
||
193 | ConvertState = (StatusCodeType)item.STATUS, |
||
194 | CreateTime = item.CREATE_DATETIME, |
||
195 | 344ac7ed | alzkakdixm | StartTime = (DateTime)item.START_DATETIME, |
196 | EndTime = (DateTime)item.END_DATETIME, |
||
197 | e6281033 | alzkakdixm | TotalPage = item.TOTAL_PAGE, |
198 | CurrentPageNo = item.CURRENT_PAGE, |
||
199 | Exception = item.EXCEPTION, |
||
200 | e78f0871 | alzkakdixm | ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID), |
201 | 53c9637d | taeseongkim | |
202 | e6281033 | alzkakdixm | Revision = item.REVISION, |
203 | DocumnetNo = item.DOCUMENT_NO, |
||
204 | DocumnetName = item.DOCUMENT_NAME, |
||
205 | GroupNo = item.GROUP_NO, |
||
206 | 05fd750b | alzkakdixm | DocumentID = item.DOCUMENT_ID, |
207 | |||
208 | e78f0871 | alzkakdixm | MarkusLink = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech") |
209 | e6281033 | alzkakdixm | }; |
210 | convertItems.Add(convertitem); |
||
211 | 53c9637d | taeseongkim | } |
212 | } |
||
213 | e6281033 | alzkakdixm | return convertItems; |
214 | 53c9637d | taeseongkim | |
215 | e6281033 | alzkakdixm | } |
216 | 53c9637d | taeseongkim | |
217 | 218e5002 | semi | public string[] GetSearchConvertPathAndMarkus(string PROJECT_NO, string DOCUMENT_ID) |
218 | { |
||
219 | string[] ConvertPath = new string[2]; |
||
220 | ConvertPath[0] = GetConvertPath(PROJECT_NO, DOCUMENT_ID); |
||
221 | ConvertPath[1] = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(PROJECT_NO, DOCUMENT_ID, "doftech"); |
||
222 | |||
223 | return ConvertPath; |
||
224 | } |
||
225 | |||
226 | e6281033 | alzkakdixm | #endregion |
227 | 53c9637d | taeseongkim | |
228 | e6281033 | alzkakdixm | #region Update RealDataSelect |
229 | 53c9637d | taeseongkim | |
230 | /// <summary> |
||
231 | e6281033 | alzkakdixm | /// 상단 그리드에서 선택된 RealDataSelect |
232 | /// 용도: 중앙그리드 Items Update |
||
233 | 53c9637d | taeseongkim | /// </summary> |
234 | e6281033 | alzkakdixm | public IEnumerable<Interface.ConvertItem> GetConvertProjects(System.Collections.ObjectModel.ObservableCollection<Interface.ConvertItem> selectedConvert) |
235 | 53c9637d | taeseongkim | { |
236 | e6281033 | alzkakdixm | List<Interface.ConvertItem> StatusKeep = new List<Interface.ConvertItem>(); |
237 | 53c9637d | taeseongkim | |
238 | e6281033 | alzkakdixm | List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>(); |
239 | 53c9637d | taeseongkim | |
240 | e6281033 | alzkakdixm | foreach (var selectedConvertItem in selectedConvert) |
241 | 53c9637d | taeseongkim | { |
242 | e6281033 | alzkakdixm | var query = from items in entities.CONVERTER_DOC //세미 |
243 | join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems |
||
244 | from subpet in GroupItems.DefaultIfEmpty() |
||
245 | where items.PROJECT_NO == selectedConvertItem.ProjectNumber && items.ID == selectedConvertItem.ConvertID |
||
246 | select new |
||
247 | { |
||
248 | ID = items.ID, |
||
249 | DOCUMENT_URL = items.DOCUMENT_URL, |
||
250 | RECONVERTER = items.RECONVERTER, |
||
251 | SERVICE_ID = items.SERVICE_ID, |
||
252 | STATUS = items.STATUS, |
||
253 | CREATE_DATETIME = items.CREATE_DATETIME, |
||
254 | 344ac7ed | alzkakdixm | START_DATETIME = items.START_DATETIME, |
255 | END_DATETIME = items.END_DATETIME, |
||
256 | e6281033 | alzkakdixm | TOTAL_PAGE = items.TOTAL_PAGE, |
257 | CURRENT_PAGE = items.CURRENT_PAGE, |
||
258 | EXCEPTION = items.EXCEPTION, |
||
259 | PROJECT_NO = items.PROJECT_NO, |
||
260 | DOCUMENT_ID = items.DOCUMENT_ID, |
||
261 | REVISION = subpet.REVISION, |
||
262 | DOCUMENT_NO = subpet.DOCUMENT_NO, |
||
263 | DOCUMENT_NAME = subpet.DOCUMENT_NAME, |
||
264 | GROUP_NO = subpet.GROUP_NO |
||
265 | }; |
||
266 | 53c9637d | taeseongkim | |
267 | 41fa3d98 | djkim | |
268 | e6281033 | alzkakdixm | if (query.Count() > 0)//세미 |
269 | 53c9637d | taeseongkim | { |
270 | e6281033 | alzkakdixm | foreach (var item in query) |
271 | 41fa3d98 | djkim | { |
272 | e6281033 | alzkakdixm | Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL) |
273 | { |
||
274 | 53c9637d | taeseongkim | |
275 | e6281033 | alzkakdixm | ReConverter = item.RECONVERTER, |
276 | ServiceID = item.SERVICE_ID, |
||
277 | ConvertState = (StatusCodeType)item.STATUS, |
||
278 | CreateTime = item.CREATE_DATETIME, |
||
279 | 344ac7ed | alzkakdixm | StartTime = item.START_DATETIME, |
280 | EndTime = item.END_DATETIME, |
||
281 | e6281033 | alzkakdixm | TotalPage = item.TOTAL_PAGE, |
282 | CurrentPageNo = item.CURRENT_PAGE, |
||
283 | Exception = item.EXCEPTION, |
||
284 | ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID), |
||
285 | 53c9637d | taeseongkim | |
286 | e6281033 | alzkakdixm | Revision = item.REVISION, |
287 | DocumnetNo = item.DOCUMENT_NO, |
||
288 | DocumnetName = item.DOCUMENT_NAME, |
||
289 | 05fd750b | alzkakdixm | GroupNo = item.GROUP_NO, |
290 | |||
291 | e78f0871 | alzkakdixm | MarkusLink = "kcom://" + MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech") |
292 | e6281033 | alzkakdixm | }; |
293 | 53c9637d | taeseongkim | |
294 | e6281033 | alzkakdixm | StatusKeep.Add(convertitem); |
295 | 53c9637d | taeseongkim | |
296 | e6281033 | alzkakdixm | } |
297 | } |
||
298 | } |
||
299 | return StatusKeep; |
||
300 | 0157b158 | taeseongkim | } |
301 | 53c9637d | taeseongkim | |
302 | e6281033 | alzkakdixm | #endregion |
303 | 53c9637d | taeseongkim | |
304 | e6281033 | alzkakdixm | #region Data Convert |
305 | 53c9637d | taeseongkim | |
306 | e6281033 | alzkakdixm | /// <summary> |
307 | /// 상단 그리드에서 선택된 Convert 버튼 |
||
308 | /// 용도: 중앙 그리드로 Convert된 row 값 저장 하기 위해서 입니다. |
||
309 | /// </summary> |
||
310 | public IEnumerable<Interface.ConvertItem> GetConvertProjects(Markus.Service.Interface.ConvertItem selectedConvert) |
||
311 | 53c9637d | taeseongkim | { |
312 | e6281033 | alzkakdixm | List<Interface.ConvertItem> StatusKeep = new List<Interface.ConvertItem>(); |
313 | |||
314 | |||
315 | System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); |
||
316 | |||
317 | stopwatch.Start(); |
||
318 | |||
319 | |||
320 | List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();//디비 다 조인 후 조건 비교 후 그리드 출력 |
||
321 | var query = from items in entities.CONVERTER_DOC //세미 |
||
322 | join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems |
||
323 | from subpet in GroupItems.DefaultIfEmpty() |
||
324 | where items.PROJECT_NO == selectedConvert.ProjectNumber && items.DOCUMENT_ID == selectedConvert.DocumentID |
||
325 | orderby items.CREATE_DATETIME descending |
||
326 | select new |
||
327 | { |
||
328 | ID = items.ID, |
||
329 | DOCUMENT_URL = items.DOCUMENT_URL, |
||
330 | RECONVERTER = items.RECONVERTER, |
||
331 | SERVICE_ID = items.SERVICE_ID, |
||
332 | STATUS = items.STATUS, |
||
333 | CREATE_DATETIME = items.CREATE_DATETIME, |
||
334 | 344ac7ed | alzkakdixm | START_DATETIME = items.START_DATETIME, |
335 | END_DATETIME = items.END_DATETIME, |
||
336 | e6281033 | alzkakdixm | TOTAL_PAGE = items.TOTAL_PAGE, |
337 | CURRENT_PAGE = items.CURRENT_PAGE, |
||
338 | EXCEPTION = items.EXCEPTION, |
||
339 | PROJECT_NO = items.PROJECT_NO, |
||
340 | DOCUMENT_ID = items.DOCUMENT_ID, |
||
341 | REVISION = subpet.REVISION, |
||
342 | DOCUMENT_NO = subpet.DOCUMENT_NO, |
||
343 | DOCUMENT_NAME = subpet.DOCUMENT_NAME, |
||
344 | GROUP_NO = subpet.GROUP_NO |
||
345 | }; |
||
346 | |||
347 | if (query.Count() > 0)//세미 |
||
348 | 53c9637d | taeseongkim | { |
349 | e6281033 | alzkakdixm | foreach (var item in query) |
350 | { |
||
351 | Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL) |
||
352 | { |
||
353 | |||
354 | ReConverter = item.RECONVERTER, |
||
355 | ServiceID = item.SERVICE_ID, |
||
356 | ConvertState = (StatusCodeType)item.STATUS, |
||
357 | CreateTime = item.CREATE_DATETIME, |
||
358 | 344ac7ed | alzkakdixm | StartTime = item.START_DATETIME, |
359 | EndTime = item.END_DATETIME, |
||
360 | e6281033 | alzkakdixm | TotalPage = item.TOTAL_PAGE, |
361 | CurrentPageNo = item.CURRENT_PAGE, |
||
362 | Exception = item.EXCEPTION, |
||
363 | ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID), |
||
364 | Revision = item.REVISION, |
||
365 | DocumnetNo = item.DOCUMENT_NO, |
||
366 | DocumnetName = item.DOCUMENT_NAME, |
||
367 | 05fd750b | alzkakdixm | GroupNo = item.GROUP_NO, |
368 | |||
369 | e78f0871 | alzkakdixm | MarkusLink = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech") |
370 | e6281033 | alzkakdixm | }; |
371 | StatusKeep.Add(convertitem); |
||
372 | } |
||
373 | 53c9637d | taeseongkim | } |
374 | e6281033 | alzkakdixm | System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks).ToString()); |
375 | return StatusKeep; |
||
376 | 53c9637d | taeseongkim | |
377 | } |
||
378 | |||
379 | e6281033 | alzkakdixm | #endregion |
380 | 53c9637d | taeseongkim | |
381 | e6281033 | alzkakdixm | #region SetCleanUpItem |
382 | 53c9637d | taeseongkim | /// <summary> |
383 | /// 오류나 wait으로 남아 있는 데이터베이스의 Item을 StatusCodeType.None으로 복구 |
||
384 | /// </summary> |
||
385 | 2bbea412 | taeseongkim | /// <param name="convertID">StatusCodeType을 변경하고자 하는 ConvertItem의 ID</param> |
386 | /// <param name="ReConvert">ReConvert가 2이면 다시 Convert를 시도 안하기 때문에 기존 값으로 유지 하고 계속 시도 할수 있도록 0을 주는 경우가 있다.</param> |
||
387 | 53c9637d | taeseongkim | /// <returns></returns> |
388 | 2decfbdf | alzkakdixm | /// |
389 | public int SetCleanUpItem(ConvertItem _ConvertItem) |
||
390 | 53c9637d | taeseongkim | { |
391 | int result = 0; |
||
392 | |||
393 | 2decfbdf | alzkakdixm | var items = entities.CONVERTER_DOC.Where(x => x.ID == _ConvertItem.ConvertID); |
394 | 53c9637d | taeseongkim | |
395 | result = items.Count(); |
||
396 | |||
397 | if (items.Count() > 0) |
||
398 | { |
||
399 | 0157b158 | taeseongkim | var item = items.First(); |
400 | |||
401 | 2decfbdf | alzkakdixm | item.RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter; |
402 | 508debb1 | taeseongkim | |
403 | e6281033 | alzkakdixm | item.CREATE_DATETIME = DateTime.Now; |
404 | item.STATUS = (int)StatusCodeType.None; |
||
405 | 508debb1 | taeseongkim | item.END_DATETIME = null; |
406 | 53c9637d | taeseongkim | |
407 | 0157b158 | taeseongkim | result = entities.SaveChanges(); |
408 | 53c9637d | taeseongkim | } |
409 | |||
410 | return result; |
||
411 | } |
||
412 | 2decfbdf | alzkakdixm | |
413 | 508debb1 | taeseongkim | public int SetCleanUpItem(string convertID, int ReConvert) |
414 | { |
||
415 | int result = 0; |
||
416 | |||
417 | var items = entities.CONVERTER_DOC.Where(x => x.ID == convertID); |
||
418 | |||
419 | result = items.Count(); |
||
420 | |||
421 | if (items.Count() > 0) |
||
422 | { |
||
423 | var item = items.First(); |
||
424 | |||
425 | item.RECONVERTER = item.RECONVERTER + ReConvert; |
||
426 | item.CREATE_DATETIME = DateTime.Now; |
||
427 | //item.START_DATETIME = null; |
||
428 | item.END_DATETIME = null; |
||
429 | item.STATUS = (int)StatusCodeType.None; |
||
430 | |||
431 | result = entities.SaveChanges(); |
||
432 | } |
||
433 | |||
434 | return result; |
||
435 | } |
||
436 | e6281033 | alzkakdixm | #endregion |
437 | |||
438 | #region Convert Path |
||
439 | |||
440 | private string GetConvertPath(string ProjectNo, string DocumentID) |
||
441 | { |
||
442 | try |
||
443 | { |
||
444 | return Path.Combine(BaseStorage(ProjectNo), ProjectNo + "_Tile", (System.Convert.ToInt64(DocumentID) / 100).ToString(), DocumentID); |
||
445 | } |
||
446 | catch (Exception) |
||
447 | { |
||
448 | throw new Exception("GetConvertPath Error"); |
||
449 | } |
||
450 | 2decfbdf | alzkakdixm | |
451 | e6281033 | alzkakdixm | } |
452 | 2decfbdf | alzkakdixm | |
453 | e6281033 | alzkakdixm | private string BaseStorage(string ProjectNo) |
454 | { |
||
455 | string result = ""; |
||
456 | 2decfbdf | alzkakdixm | |
457 | e6281033 | alzkakdixm | var properties = entities.PROPERTIES.Where(f => f.PROPERTY == ProjectNo && f.TYPE == PROPERTIES_DEFINE.TILE_SOURCE_STORAGE); |
458 | 2decfbdf | alzkakdixm | |
459 | e6281033 | alzkakdixm | if (properties.Count() > 0) |
460 | { |
||
461 | result = properties.First().VALUE; |
||
462 | } |
||
463 | else |
||
464 | { |
||
465 | throw new Exception($"Project {ProjectNo} BaseStorage Not Setting."); |
||
466 | } |
||
467 | 2decfbdf | alzkakdixm | |
468 | e6281033 | alzkakdixm | return result; |
469 | } |
||
470 | 2decfbdf | alzkakdixm | |
471 | e6281033 | alzkakdixm | #endregion |
472 | 53c9637d | taeseongkim | |
473 | e6281033 | alzkakdixm | #region Remove |
474 | 5d863c06 | taeseongkim | |
475 | /// <summary> |
||
476 | /// Item 삭제 |
||
477 | /// </summary> |
||
478 | /// <returns></returns> |
||
479 | public int RemoveItem(string convertID) |
||
480 | { |
||
481 | int result = 0; |
||
482 | |||
483 | var items = entities.CONVERTER_DOC.Where(x => x.ID == convertID); |
||
484 | |||
485 | if (items.Count() > 0) |
||
486 | { |
||
487 | CONVERTER_DOC item = items.First(); |
||
488 | entities.CONVERTER_DOC.Remove(item); |
||
489 | |||
490 | result = entities.SaveChanges(); |
||
491 | } |
||
492 | |||
493 | return result; |
||
494 | } |
||
495 | |||
496 | e6281033 | alzkakdixm | |
497 | #endregion |
||
498 | |||
499 | 05fd750b | alzkakdixm | #region MarkusLink |
500 | |||
501 | |||
502 | ////// userID는 관리자 계정인 doftech |
||
503 | ////string markusLink = "kcom://" + MarkusAPI.CreateMarkusParam(projectNo, documentID, userID); |
||
504 | //public static string CreateMarkusParam(string projectNo, string documentID, string userID) |
||
505 | //{ |
||
506 | // ViewInfo viewInfo = new ViewInfo(); |
||
507 | |||
508 | // viewInfo.DocumentItemID = documentID; |
||
509 | // viewInfo.ProjectNO = projectNo; |
||
510 | // viewInfo.UserID = userID; |
||
511 | |||
512 | // return ParamEncoding(JsonConvert.SerializeObject(viewInfo)); |
||
513 | |||
514 | //} |
||
515 | |||
516 | //public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null) |
||
517 | //{ |
||
518 | |||
519 | // if (oEncoding == null) |
||
520 | // oEncoding = System.Text.Encoding.UTF8; |
||
521 | |||
522 | // return Convert.ToBase64String(oEncoding.GetBytes(EncodingText)); |
||
523 | |||
524 | //} |
||
525 | |||
526 | |||
527 | #endregion |
||
528 | |||
529 | e6281033 | alzkakdixm | #endregion |
530 | |||
531 | #region DataBaseByStatusViewModel Function |
||
532 | 53c9637d | taeseongkim | /// <summary> |
533 | /// 전체 컨버터를 가져온다. 비동기로 변경하여야 한다. |
||
534 | /// </summary> |
||
535 | /// <returns></returns> |
||
536 | e6281033 | alzkakdixm | public List<Interface.ConvertItem> GetConvertItems(StatusCodeType statusCodeType, Func<CONVERTER_DOC, bool> @where, int takeCount = 100) |
537 | 53c9637d | taeseongkim | { |
538 | List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>(); |
||
539 | |||
540 | e6281033 | alzkakdixm | |
541 | var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).Take(takeCount).ToList(); |
||
542 | 53c9637d | taeseongkim | |
543 | if (items.Count() > 0) |
||
544 | { |
||
545 | foreach (var item in items) |
||
546 | { |
||
547 | 06f13e11 | taeseongkim | var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL) |
548 | { |
||
549 | ReConverter = item.RECONVERTER, |
||
550 | ServiceID = item.SERVICE_ID, |
||
551 | 2decfbdf | alzkakdixm | ConvertState = ((StatusCodeType)item.STATUS), |
552 | 06f13e11 | taeseongkim | CreateTime = item.CREATE_DATETIME, |
553 | TotalPage = item.TOTAL_PAGE, |
||
554 | CurrentPageNo = item.CURRENT_PAGE, |
||
555 | |||
556 | ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID) |
||
557 | }; |
||
558 | |||
559 | 53c9637d | taeseongkim | convertItems.Add(convertitem); |
560 | } |
||
561 | } |
||
562 | return convertItems; |
||
563 | } |
||
564 | e6281033 | alzkakdixm | #endregion |
565 | |||
566 | #region No 참조 |
||
567 | 53c9637d | taeseongkim | |
568 | 0157b158 | taeseongkim | /// <summary> |
569 | e6281033 | alzkakdixm | /// 컨버터서비스를 이용하는 문서 정보 저장 |
570 | /// UniqueID |
||
571 | /// using Markus.Service.Extensions; new Guid().CreateUniqueGuid().ToString(); |
||
572 | b92f142f | taeseongkim | /// </summary> |
573 | e6281033 | alzkakdixm | /// <param name="ProjectNo">프로젝트</param> |
574 | /// <param name="UniqueID">컨버터 서비스의 아이템 ID</param> |
||
575 | /// <param name="originfilePath"></param> |
||
576 | /// <param name="DocumentID"></param> |
||
577 | b92f142f | taeseongkim | /// <returns></returns> |
578 | e6281033 | alzkakdixm | public bool SetConvertDoc(string ProjectNo, string UniqueID, string originfilePath, string DocumentID) |
579 | b92f142f | taeseongkim | { |
580 | e6281033 | alzkakdixm | bool result = false; |
581 | b92f142f | taeseongkim | |
582 | e6281033 | alzkakdixm | if (ProjectNo.IsNullOrEmpty()) |
583 | { |
||
584 | throw new Exception("ProjectNo is Null"); |
||
585 | } |
||
586 | 60723dc9 | taeseongkim | |
587 | e6281033 | alzkakdixm | if (UniqueID.IsNullOrEmpty()) |
588 | { |
||
589 | throw new Exception("UniqueID is Null"); |
||
590 | } |
||
591 | b92f142f | taeseongkim | |
592 | e6281033 | alzkakdixm | if (originfilePath.IsNullOrEmpty()) |
593 | b92f142f | taeseongkim | { |
594 | e6281033 | alzkakdixm | throw new Exception("originfilePath is Null"); |
595 | } |
||
596 | |||
597 | if (DocumentID.IsNullOrEmpty()) |
||
598 | { |
||
599 | throw new Exception("DocumentID is Null"); |
||
600 | } |
||
601 | |||
602 | if (DocumentID.IsNullOrEmpty()) |
||
603 | { |
||
604 | long _lastDocId = 0; |
||
605 | |||
606 | if (entities.CONVERTER_DOC.Count() > 0) |
||
607 | b92f142f | taeseongkim | { |
608 | e6281033 | alzkakdixm | try |
609 | b92f142f | taeseongkim | { |
610 | e6281033 | alzkakdixm | string qry = @"SELECT * FROM CONVERTER_DOC order by CAST(DOCUMENT_ID as int) desc"; |
611 | var _item = entities.CONVERTER_DOC.SqlQuery(qry).FirstOrDefault(); |
||
612 | b92f142f | taeseongkim | |
613 | e6281033 | alzkakdixm | if (_item != null) |
614 | { |
||
615 | _lastDocId = Convert.ToInt64(_item.DOCUMENT_ID) + 1; |
||
616 | } |
||
617 | } |
||
618 | catch (Exception) |
||
619 | { |
||
620 | b92f142f | taeseongkim | |
621 | e6281033 | alzkakdixm | throw; |
622 | } |
||
623 | b92f142f | taeseongkim | } |
624 | e6281033 | alzkakdixm | |
625 | DocumentID = _lastDocId.ToString(); |
||
626 | b92f142f | taeseongkim | } |
627 | |||
628 | e6281033 | alzkakdixm | CONVERTER_DOC convert_doc = new CONVERTER_DOC |
629 | { |
||
630 | ID = UniqueID, |
||
631 | PROJECT_NO = ProjectNo, |
||
632 | DOCUMENT_URL = originfilePath, |
||
633 | DOCUMENT_ID = DocumentID, |
||
634 | CREATE_DATETIME = DateTime.Now, |
||
635 | STATUS = 0, |
||
636 | TOTAL_PAGE = 0, |
||
637 | CURRENT_PAGE = 0, |
||
638 | RECONVERTER = 0 |
||
639 | }; |
||
640 | |||
641 | |||
642 | entities.CONVERTER_DOC.Add(convert_doc); |
||
643 | a6e5055d | alzkakdixm | |
644 | e6281033 | alzkakdixm | if (entities.SaveChanges() == 1) |
645 | { |
||
646 | result = true; |
||
647 | } |
||
648 | |||
649 | return result; |
||
650 | } |
||
651 | |||
652 | /// <summary> |
||
653 | /// 컨버터서비스를 이용하는 문서 정보 저장 |
||
654 | /// UniqueID |
||
655 | /// using Markus.Service.Extensions; new Guid().CreateUniqueGuid().ToString(); |
||
656 | /// </summary> |
||
657 | /// <param name="ProjectNo">프로젝트</param> |
||
658 | /// <param name="UniqueID">컨버터 서비스의 아이템 ID</param> |
||
659 | /// <param name="originfilePath"></param> |
||
660 | /// <param name="DocumentID"></param> |
||
661 | /// <returns></returns> |
||
662 | public bool SetDocumentInfo(string ConvertID, int totalPage, List<DOCPAGE> pageinfo) |
||
663 | 2decfbdf | alzkakdixm | { |
664 | e6281033 | alzkakdixm | bool result = false; |
665 | 2decfbdf | alzkakdixm | |
666 | e6281033 | alzkakdixm | var convertDocItems = entities.CONVERTER_DOC.Where(f => f.ID == ConvertID); |
667 | |||
668 | if (convertDocItems.Count() > 0) |
||
669 | a6e5055d | alzkakdixm | { |
670 | e6281033 | alzkakdixm | var convertDoc = convertDocItems.First(); |
671 | |||
672 | string docId = new Guid().CreateUniqueGuid().ToString(); |
||
673 | |||
674 | var docinfo = entities.DOCINFO.FirstOrDefault(x => x.PROJECT_NO == convertDoc.PROJECT_NO && x.DOCUMENT_ID == convertDoc.DOCUMENT_ID); |
||
675 | |||
676 | if (docinfo != null) |
||
677 | { |
||
678 | // 기존 Docpage 삭제. |
||
679 | entities.DOCPAGE.RemoveRange(docinfo.DOCPAGE); |
||
680 | |||
681 | // 기존 코멘트 유지를 위한 Docinfo update |
||
682 | docinfo.PROJECT_NO = convertDoc.PROJECT_NO; |
||
683 | docinfo.ORIGINAL_FILE = convertDoc.DOCUMENT_URL; |
||
684 | docinfo.PAGE_COUNT = totalPage; |
||
685 | docinfo.DOCPAGE = pageinfo; |
||
686 | entities.SaveChanges(); |
||
687 | result = true; |
||
688 | } |
||
689 | else |
||
690 | a6e5055d | alzkakdixm | { |
691 | e6281033 | alzkakdixm | DOCINFO instace = new DOCINFO |
692 | a6e5055d | alzkakdixm | { |
693 | e6281033 | alzkakdixm | ID = docId, |
694 | PROJECT_NO = convertDoc.PROJECT_NO, |
||
695 | ORIGINAL_FILE = convertDoc.DOCUMENT_URL, |
||
696 | DOCUMENT_ID = convertDoc.DOCUMENT_ID, |
||
697 | PAGE_COUNT = totalPage, |
||
698 | DOCPAGE = pageinfo |
||
699 | a6e5055d | alzkakdixm | }; |
700 | |||
701 | e6281033 | alzkakdixm | entities.DOCINFO.Add(instace); |
702 | var save = entities.SaveChanges(); |
||
703 | |||
704 | if (save == pageinfo.Count() + 1) |
||
705 | { |
||
706 | result = true; |
||
707 | } |
||
708 | a6e5055d | alzkakdixm | } |
709 | 2decfbdf | alzkakdixm | |
710 | e6281033 | alzkakdixm | |
711 | |||
712 | } |
||
713 | a6e5055d | alzkakdixm | |
714 | e6281033 | alzkakdixm | return result; |
715 | 2decfbdf | alzkakdixm | } |
716 | e6281033 | alzkakdixm | |
717 | public Interface.ConvertItem GetConvertItem(string ProjectNo, string UniqueID) |
||
718 | a6e5055d | alzkakdixm | { |
719 | e6281033 | alzkakdixm | Interface.ConvertItem result = null; |
720 | a6e5055d | alzkakdixm | |
721 | e6281033 | alzkakdixm | //var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID); |
722 | var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == ProjectNo && f.ID == UniqueID); |
||
723 | |||
724 | if (items.Count() > 0) |
||
725 | 2decfbdf | alzkakdixm | { |
726 | e6281033 | alzkakdixm | var convertItem = items.First(); |
727 | 2decfbdf | alzkakdixm | |
728 | e6281033 | alzkakdixm | string convertPath = Path.Combine(BaseStorage(convertItem.PROJECT_NO), convertItem.PROJECT_NO + "_Tile", (System.Convert.ToInt64(convertItem.DOCUMENT_ID) / 100).ToString(), convertItem.DOCUMENT_ID); |
729 | 2decfbdf | alzkakdixm | |
730 | e6281033 | alzkakdixm | result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath); |
731 | } |
||
732 | a6e5055d | alzkakdixm | |
733 | e6281033 | alzkakdixm | return result; |
734 | } |
||
735 | 2decfbdf | alzkakdixm | |
736 | a6e5055d | alzkakdixm | |
737 | e6281033 | alzkakdixm | public Interface.ConvertItem GetConvertItembyDocumentID(string ProjectNo, string DocumentID) |
738 | { |
||
739 | Interface.ConvertItem result = null; |
||
740 | |||
741 | //var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID); |
||
742 | var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == ProjectNo && f.DOCUMENT_ID == DocumentID); |
||
743 | |||
744 | if (items.Count() > 0) |
||
745 | { |
||
746 | var convertItem = items.First(); |
||
747 | string convertPath = Path.Combine(BaseStorage(convertItem.PROJECT_NO), convertItem.PROJECT_NO + "_Tile", (System.Convert.ToInt64(convertItem.DOCUMENT_ID) / 100).ToString(), convertItem.DOCUMENT_ID); |
||
748 | |||
749 | if (convertItem.STATUS == (int)StatusCodeType.Completed) |
||
750 | { |
||
751 | result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath, |
||
752 | (StatusCodeType)convertItem.STATUS, convertItem.CURRENT_PAGE, convertItem.TOTAL_PAGE, convertItem.EXCEPTION); |
||
753 | } |
||
754 | else |
||
755 | { |
||
756 | result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath); |
||
757 | 2decfbdf | alzkakdixm | } |
758 | } |
||
759 | |||
760 | e6281033 | alzkakdixm | return result; |
761 | } |
||
762 | |||
763 | public List<CONVERTER_DOC> GetConvertingItems(List<string> projectList) |
||
764 | { |
||
765 | var convertWaitingItems = entities.CONVERTER_DOC.OrderBy(x => x.CREATE_DATETIME).Where( |
||
766 | x => |
||
767 | projectList.Contains(x.PROJECT_NO) && |
||
768 | (x.STATUS > (int)StatusCodeType.None && x.STATUS < (int)StatusCodeType.Completed) && x.RECONVERTER < 2); |
||
769 | 2decfbdf | alzkakdixm | |
770 | e6281033 | alzkakdixm | return convertWaitingItems.ToList(); |
771 | 2decfbdf | alzkakdixm | } |
772 | e6281033 | alzkakdixm | |
773 | /// <summary> |
||
774 | /// 전체 컨버터를 가져온다. 비동기로 변경하여야 한다. |
||
775 | /// </summary> |
||
776 | /// <returns></returns> |
||
777 | public List<Interface.ConvertItem> GetConvertItems(StatusCodeType statusCodeType) |
||
778 | 2decfbdf | alzkakdixm | { |
779 | e6281033 | alzkakdixm | List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>(); |
780 | 2decfbdf | alzkakdixm | |
781 | e6281033 | alzkakdixm | var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo); |
782 | |||
783 | if (items.Count() > 0) |
||
784 | a6e5055d | alzkakdixm | { |
785 | e6281033 | alzkakdixm | foreach (var item in items) |
786 | a6e5055d | alzkakdixm | { |
787 | e6281033 | alzkakdixm | var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL) |
788 | a6e5055d | alzkakdixm | { |
789 | ReConverter = item.RECONVERTER, |
||
790 | ServiceID = item.SERVICE_ID, |
||
791 | e6281033 | alzkakdixm | ConvertState = ((StatusCodeType)item.STATUS), |
792 | a6e5055d | alzkakdixm | CreateTime = item.CREATE_DATETIME, |
793 | TotalPage = item.TOTAL_PAGE, |
||
794 | CurrentPageNo = item.CURRENT_PAGE, |
||
795 | |||
796 | e6281033 | alzkakdixm | ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID) |
797 | 2decfbdf | alzkakdixm | }; |
798 | e6281033 | alzkakdixm | |
799 | |||
800 | convertItems.Add(convertitem); |
||
801 | a6e5055d | alzkakdixm | } |
802 | } |
||
803 | e6281033 | alzkakdixm | return convertItems; |
804 | a6e5055d | alzkakdixm | } |
805 | |||
806 | public List<Interface.ConvertItem> GetConvertProjectsStatus(Func<CONVERTER_DOC, bool> @where) |
||
807 | { |
||
808 | List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>(); |
||
809 | |||
810 | |||
811 | //var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).Take(takeCount).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo); |
||
812 | e6281033 | alzkakdixm | var items = entities.CONVERTER_DOC.Where(x => x.STATUS <= 4); |
813 | a6e5055d | alzkakdixm | |
814 | if (items.Count() > 0) |
||
815 | { |
||
816 | foreach (var item in items) |
||
817 | { |
||
818 | var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL) |
||
819 | { |
||
820 | ReConverter = item.RECONVERTER, |
||
821 | ServiceID = item.SERVICE_ID, |
||
822 | //ConvertState = ((StatusCodeType)item.STATUS).ToString(), |
||
823 | 2decfbdf | alzkakdixm | //ConvertState = (item.STATUS).ToString(), |
824 | ConvertState = (StatusCodeType)item.STATUS, |
||
825 | a6e5055d | alzkakdixm | CreateTime = item.CREATE_DATETIME, |
826 | TotalPage = item.TOTAL_PAGE, |
||
827 | CurrentPageNo = item.CURRENT_PAGE, |
||
828 | Exception = item.EXCEPTION, |
||
829 | ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID) |
||
830 | }; |
||
831 | |||
832 | |||
833 | convertItems.Add(convertitem); |
||
834 | } |
||
835 | } |
||
836 | |||
837 | return convertItems; |
||
838 | } |
||
839 | |||
840 | b92f142f | taeseongkim | |
841 | e6281033 | alzkakdixm | public bool SetConvertState(string ServiceID, string UniqueID, int State, int CurrentPage, int TotalPage, string Error) |
842 | 53c9637d | taeseongkim | { |
843 | bool result = false; |
||
844 | |||
845 | try |
||
846 | { |
||
847 | var items = entities.CONVERTER_DOC.SingleOrDefault(f => f.ID == UniqueID); |
||
848 | //var items = entities.CONVERTER_DOC.SingleOrDefault(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID); |
||
849 | |||
850 | if (items != null) |
||
851 | { |
||
852 | 0157b158 | taeseongkim | items.SERVICE_ID = ServiceID; |
853 | 53c9637d | taeseongkim | items.STATUS = State; |
854 | items.CURRENT_PAGE = CurrentPage; |
||
855 | items.TOTAL_PAGE = TotalPage; |
||
856 | |||
857 | StatusCodeType statusCode = (StatusCodeType)State; |
||
858 | |||
859 | 65fbe3cb | taeseongkim | if (items.START_DATETIME == null) |
860 | a8f1a865 | taeseongkim | { |
861 | items.START_DATETIME = DateTime.Now; |
||
862 | } |
||
863 | |||
864 | 53c9637d | taeseongkim | switch (statusCode) |
865 | { |
||
866 | case StatusCodeType.None: |
||
867 | break; |
||
868 | case StatusCodeType.Wait: |
||
869 | items.START_DATETIME = DateTime.Now; |
||
870 | break; |
||
871 | case StatusCodeType.PageLoading: |
||
872 | break; |
||
873 | case StatusCodeType.Saving: |
||
874 | break; |
||
875 | case StatusCodeType.Completed: |
||
876 | a0341bef | taeseongkim | items.CURRENT_PAGE = items.TOTAL_PAGE; |
877 | e6281033 | alzkakdixm | items.END_DATETIME = DateTime.Now; |
878 | 53c9637d | taeseongkim | break; |
879 | case StatusCodeType.FileError: |
||
880 | Error = $" file Error :" + Error; |
||
881 | items.END_DATETIME = DateTime.Now; |
||
882 | break; |
||
883 | case StatusCodeType.PageError: |
||
884 | Error = $" Page No {CurrentPage} Error :" + Error; |
||
885 | break; |
||
886 | case StatusCodeType.NeedsPassword: |
||
887 | break; |
||
888 | case StatusCodeType.Error: |
||
889 | Error = $" Error :" + Error; |
||
890 | items.END_DATETIME = DateTime.Now; |
||
891 | break; |
||
892 | default: |
||
893 | break; |
||
894 | } |
||
895 | |||
896 | e6281033 | alzkakdixm | if (items.EXCEPTION == null) |
897 | 53c9637d | taeseongkim | { |
898 | items.EXCEPTION = ""; |
||
899 | } |
||
900 | |||
901 | if (items.EXCEPTION.Length < 255) |
||
902 | { |
||
903 | items.EXCEPTION = items.EXCEPTION + Error; |
||
904 | } |
||
905 | |||
906 | entities.SaveChanges(); |
||
907 | result = true; |
||
908 | } |
||
909 | } |
||
910 | catch (Exception ex) |
||
911 | { |
||
912 | e6281033 | alzkakdixm | throw new Exception("SetConvertState", ex); |
913 | 53c9637d | taeseongkim | } |
914 | |||
915 | return result; |
||
916 | } |
||
917 | |||
918 | e6281033 | alzkakdixm | public SERVICE_PROPERTIES GetServiceProperties(string ServiceID) |
919 | 53c9637d | taeseongkim | { |
920 | e6281033 | alzkakdixm | SERVICE_PROPERTIES result = null; |
921 | 53c9637d | taeseongkim | |
922 | e6281033 | alzkakdixm | var items = entities.SERVICE_PROPERTIES.Where(x => x.ID == ServiceID); |
923 | 53c9637d | taeseongkim | |
924 | e6281033 | alzkakdixm | if (items.Count() > 0) |
925 | 53c9637d | taeseongkim | { |
926 | e6281033 | alzkakdixm | result = items.First(); |
927 | 53c9637d | taeseongkim | } |
928 | |||
929 | return result; |
||
930 | } |
||
931 | |||
932 | e6281033 | alzkakdixm | |
933 | /// <summary> |
||
934 | /// 현재 서비스에서 컨버터중인 아이템. |
||
935 | /// </summary> |
||
936 | /// <returns></returns> |
||
937 | public List<Interface.ConvertItem> GetServiceAliveItems(string ServiceID) |
||
938 | { |
||
939 | List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>(); |
||
940 | |||
941 | var items = entities.CONVERTER_DOC.Where(x => x.SERVICE_ID == ServiceID && x.STATUS > (int)StatusCodeType.None && x.STATUS < (int)StatusCodeType.Completed).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo); |
||
942 | |||
943 | if (items.Count() > 0) |
||
944 | { |
||
945 | foreach (var item in items) |
||
946 | { |
||
947 | var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL); |
||
948 | convertItems.Add(convertitem); |
||
949 | } |
||
950 | } |
||
951 | return convertItems; |
||
952 | } |
||
953 | |||
954 | #endregion |
||
955 | |||
956 | 53c9637d | taeseongkim | } |
957 | } |