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