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 |
|
|
|
9 |
|
|
namespace Markus.Service.DataBase
|
10 |
|
|
{
|
11 |
|
|
public class ConvertDatabase : IDisposable
|
12 |
|
|
{
|
13 |
ff4b1e6e
|
taeseongkim
|
Markus.EntityModel.MarkusModel entities;
|
14 |
53c9637d
|
taeseongkim
|
|
15 |
|
|
public ConvertDatabase(string ConnectionString)
|
16 |
|
|
{
|
17 |
|
|
try
|
18 |
|
|
{
|
19 |
|
|
//해당 프로젝트의 데이터베이스 연결
|
20 |
ff4b1e6e
|
taeseongkim
|
entities = new Markus.EntityModel.MarkusModel(ConnectionString);
|
21 |
53c9637d
|
taeseongkim
|
}
|
22 |
|
|
catch (Exception ex)
|
23 |
|
|
{
|
24 |
|
|
System.Diagnostics.Debug.WriteLine(ex.ToString());
|
25 |
06f13e11
|
taeseongkim
|
throw ex;
|
26 |
53c9637d
|
taeseongkim
|
}
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
public void Dispose()
|
30 |
|
|
{
|
31 |
|
|
entities.Dispose();
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
/// <summary>
|
35 |
|
|
/// 컨버터서비스를 이용하는 문서 정보 저장
|
36 |
|
|
/// UniqueID
|
37 |
|
|
/// using Markus.Service.Extensions; new Guid().CreateUniqueGuid().ToString();
|
38 |
|
|
/// </summary>
|
39 |
|
|
/// <param name="ProjectNo">프로젝트</param>
|
40 |
|
|
/// <param name="UniqueID">컨버터 서비스의 아이템 ID</param>
|
41 |
|
|
/// <param name="originfilePath"></param>
|
42 |
|
|
/// <param name="DocumentID"></param>
|
43 |
|
|
/// <returns></returns>
|
44 |
|
|
public bool SetConvertDoc(string ProjectNo, string UniqueID, string originfilePath, string DocumentID)
|
45 |
|
|
{
|
46 |
|
|
bool result = false;
|
47 |
|
|
|
48 |
|
|
if (ProjectNo.IsNullOrEmpty())
|
49 |
|
|
{
|
50 |
|
|
throw new Exception("ProjectNo is Null");
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
if (UniqueID.IsNullOrEmpty())
|
54 |
|
|
{
|
55 |
|
|
throw new Exception("UniqueID is Null");
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
if (originfilePath.IsNullOrEmpty())
|
59 |
|
|
{
|
60 |
|
|
throw new Exception("originfilePath is Null");
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
if (DocumentID.IsNullOrEmpty())
|
64 |
|
|
{
|
65 |
|
|
throw new Exception("DocumentID is Null");
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
if (DocumentID.IsNullOrEmpty())
|
69 |
|
|
{
|
70 |
|
|
long _lastDocId = 0;
|
71 |
|
|
|
72 |
|
|
if (entities.CONVERTER_DOC.Count() > 0)
|
73 |
|
|
{
|
74 |
|
|
try
|
75 |
|
|
{
|
76 |
|
|
string qry = @"SELECT * FROM CONVERTER_DOC order by CAST(DOCUMENT_ID as int) desc";
|
77 |
|
|
var _item = entities.CONVERTER_DOC.SqlQuery(qry).FirstOrDefault();
|
78 |
|
|
|
79 |
|
|
if (_item != null)
|
80 |
|
|
{
|
81 |
|
|
_lastDocId = Convert.ToInt64(_item.DOCUMENT_ID) + 1;
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
catch (Exception)
|
85 |
|
|
{
|
86 |
|
|
|
87 |
|
|
throw;
|
88 |
|
|
}
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
DocumentID = _lastDocId.ToString();
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
CONVERTER_DOC convert_doc = new CONVERTER_DOC
|
95 |
|
|
{
|
96 |
|
|
ID = UniqueID,
|
97 |
|
|
PROJECT_NO = ProjectNo,
|
98 |
|
|
DOCUMENT_URL = originfilePath,
|
99 |
|
|
DOCUMENT_ID = DocumentID,
|
100 |
|
|
CREATE_DATETIME = DateTime.Now,
|
101 |
|
|
STATUS = 0,
|
102 |
|
|
TOTAL_PAGE = 0,
|
103 |
|
|
CURRENT_PAGE = 0,
|
104 |
|
|
RECONVERTER = 0
|
105 |
|
|
};
|
106 |
|
|
|
107 |
|
|
entities.CONVERTER_DOC.Add(convert_doc);
|
108 |
|
|
|
109 |
|
|
if (entities.SaveChanges() == 1)
|
110 |
|
|
{
|
111 |
|
|
result = true;
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
return result;
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
/// <summary>
|
118 |
|
|
/// 컨버터서비스를 이용하는 문서 정보 저장
|
119 |
|
|
/// UniqueID
|
120 |
|
|
/// using Markus.Service.Extensions; new Guid().CreateUniqueGuid().ToString();
|
121 |
|
|
/// </summary>
|
122 |
|
|
/// <param name="ProjectNo">프로젝트</param>
|
123 |
|
|
/// <param name="UniqueID">컨버터 서비스의 아이템 ID</param>
|
124 |
|
|
/// <param name="originfilePath"></param>
|
125 |
|
|
/// <param name="DocumentID"></param>
|
126 |
|
|
/// <returns></returns>
|
127 |
|
|
public bool SetDocumentInfo(string ConvertID, int totalPage, List<DOCPAGE> pageinfo)
|
128 |
|
|
{
|
129 |
|
|
bool result = false;
|
130 |
|
|
|
131 |
|
|
var convertDocItems = entities.CONVERTER_DOC.Where(f => f.ID == ConvertID);
|
132 |
|
|
|
133 |
|
|
if (convertDocItems.Count() > 0)
|
134 |
|
|
{
|
135 |
|
|
var convertDoc = convertDocItems.First();
|
136 |
|
|
|
137 |
c47f358b
|
taeseongkim
|
string docId = new Guid().CreateUniqueGuid().ToString();
|
138 |
53c9637d
|
taeseongkim
|
|
139 |
|
|
var docinfo = entities.DOCINFO.FirstOrDefault(x => x.PROJECT_NO == convertDoc.PROJECT_NO && x.DOCUMENT_ID == convertDoc.DOCUMENT_ID);
|
140 |
41fa3d98
|
djkim
|
|
141 |
53c9637d
|
taeseongkim
|
if (docinfo != null)
|
142 |
|
|
{
|
143 |
41fa3d98
|
djkim
|
// 기존 Docpage 삭제.
|
144 |
53c9637d
|
taeseongkim
|
entities.DOCPAGE.RemoveRange(docinfo.DOCPAGE);
|
145 |
41fa3d98
|
djkim
|
|
146 |
|
|
// 기존 코멘트 유지를 위한 Docinfo update
|
147 |
|
|
docinfo.PROJECT_NO = convertDoc.PROJECT_NO;
|
148 |
|
|
docinfo.ORIGINAL_FILE = convertDoc.DOCUMENT_URL;
|
149 |
|
|
docinfo.PAGE_COUNT = totalPage;
|
150 |
|
|
docinfo.DOCPAGE = pageinfo;
|
151 |
53c9637d
|
taeseongkim
|
entities.SaveChanges();
|
152 |
41fa3d98
|
djkim
|
result = true;
|
153 |
53c9637d
|
taeseongkim
|
}
|
154 |
41fa3d98
|
djkim
|
else
|
155 |
53c9637d
|
taeseongkim
|
{
|
156 |
41fa3d98
|
djkim
|
DOCINFO instace = new DOCINFO
|
157 |
|
|
{
|
158 |
|
|
ID = docId,
|
159 |
|
|
PROJECT_NO = convertDoc.PROJECT_NO,
|
160 |
|
|
ORIGINAL_FILE = convertDoc.DOCUMENT_URL,
|
161 |
|
|
DOCUMENT_ID = convertDoc.DOCUMENT_ID,
|
162 |
|
|
PAGE_COUNT = totalPage,
|
163 |
|
|
DOCPAGE = pageinfo
|
164 |
|
|
};
|
165 |
|
|
|
166 |
|
|
entities.DOCINFO.Add(instace);
|
167 |
|
|
var save = entities.SaveChanges();
|
168 |
|
|
|
169 |
|
|
if (save == pageinfo.Count() + 1)
|
170 |
|
|
{
|
171 |
|
|
result = true;
|
172 |
|
|
}
|
173 |
53c9637d
|
taeseongkim
|
}
|
174 |
41fa3d98
|
djkim
|
|
175 |
|
|
|
176 |
|
|
|
177 |
53c9637d
|
taeseongkim
|
}
|
178 |
|
|
|
179 |
|
|
return result;
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
public Interface.ConvertItem GetConvertItem(string ProjectNo, string UniqueID)
|
183 |
|
|
{
|
184 |
|
|
Interface.ConvertItem result = null;
|
185 |
|
|
|
186 |
|
|
//var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID);
|
187 |
|
|
var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == ProjectNo && f.ID == UniqueID);
|
188 |
|
|
|
189 |
|
|
if (items.Count() > 0)
|
190 |
|
|
{
|
191 |
|
|
var convertItem = items.First();
|
192 |
a0341bef
|
taeseongkim
|
|
193 |
53c9637d
|
taeseongkim
|
string convertPath = Path.Combine(BaseStorage(convertItem.PROJECT_NO), convertItem.PROJECT_NO + "_Tile", (System.Convert.ToInt64(convertItem.DOCUMENT_ID) / 100).ToString(), convertItem.DOCUMENT_ID);
|
194 |
|
|
|
195 |
|
|
result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath);
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
return result;
|
199 |
|
|
}
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
public Interface.ConvertItem GetConvertItembyDocumentID(string ProjectNo, string DocumentID)
|
203 |
|
|
{
|
204 |
|
|
Interface.ConvertItem result = null;
|
205 |
|
|
|
206 |
|
|
//var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID);
|
207 |
|
|
var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == ProjectNo && f.DOCUMENT_ID == DocumentID);
|
208 |
|
|
|
209 |
|
|
if (items.Count() > 0)
|
210 |
|
|
{
|
211 |
|
|
var convertItem = items.First();
|
212 |
|
|
string convertPath = Path.Combine(BaseStorage(convertItem.PROJECT_NO), convertItem.PROJECT_NO + "_Tile", (System.Convert.ToInt64(convertItem.DOCUMENT_ID) / 100).ToString(), convertItem.DOCUMENT_ID);
|
213 |
|
|
|
214 |
|
|
if (convertItem.STATUS == (int)StatusCodeType.Completed)
|
215 |
|
|
{
|
216 |
|
|
result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath,
|
217 |
|
|
convertItem.STATUS.ToString(), convertItem.CURRENT_PAGE, convertItem.TOTAL_PAGE, convertItem.EXCEPTION);
|
218 |
|
|
}
|
219 |
|
|
else
|
220 |
|
|
{
|
221 |
|
|
result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath);
|
222 |
|
|
}
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
return result;
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
/// <summary>
|
229 |
|
|
/// service에서 대기중이거나 오류인 아이템을 가져가서 컨버터 프로세스를 호출한다.
|
230 |
|
|
/// 컨버터 상태가 에러이거나 2보다 작은 경우
|
231 |
|
|
/// UniqueKey는 각 데이터베이스의 문서 정보에서 유일한 키이며 컨버터저장에서 같은 폴더로의 저장을 방지 한다.
|
232 |
|
|
///
|
233 |
|
|
/// </summary>
|
234 |
|
|
/// <param name="aliveItems"></param>
|
235 |
|
|
/// <param name="TakeCount"></param>
|
236 |
|
|
/// <returns></returns>
|
237 |
ff4b1e6e
|
taeseongkim
|
public IEnumerable<CONVERTER_DOC> GetWaitConvertItems(List<string> projectList, int TakeCount)
|
238 |
53c9637d
|
taeseongkim
|
{
|
239 |
|
|
var convertWaitingItems = entities.CONVERTER_DOC.OrderBy(x => x.CREATE_DATETIME).Where(
|
240 |
|
|
x =>
|
241 |
b92f142f
|
taeseongkim
|
//projectList.Contains(x.PROJECT_NO) && x.RECONVERTER < 2 &&
|
242 |
|
|
x.RECONVERTER < 2 &&
|
243 |
1ae729e4
|
taeseongkim
|
(x.STATUS == (int)StatusCodeType.None || x.STATUS == (int)StatusCodeType.FileError || x.STATUS == (int)StatusCodeType.Error))
|
244 |
6f6e7dbf
|
taeseongkim
|
.GroupBy(x=>x.DOCUMENT_ID).Select(x => x.FirstOrDefault())
|
245 |
|
|
.Take(TakeCount);
|
246 |
53c9637d
|
taeseongkim
|
|
247 |
ff4b1e6e
|
taeseongkim
|
return convertWaitingItems;
|
248 |
0157b158
|
taeseongkim
|
}
|
249 |
53c9637d
|
taeseongkim
|
|
250 |
0157b158
|
taeseongkim
|
public List<CONVERTER_DOC> GetConvertingItems(List<string> projectList)
|
251 |
|
|
{
|
252 |
|
|
var convertWaitingItems = entities.CONVERTER_DOC.OrderBy(x => x.CREATE_DATETIME).Where(
|
253 |
|
|
x =>
|
254 |
|
|
projectList.Contains(x.PROJECT_NO) &&
|
255 |
60723dc9
|
taeseongkim
|
(x.STATUS > (int)StatusCodeType.None && x.STATUS < (int)StatusCodeType.Completed) && x.RECONVERTER < 2);
|
256 |
53c9637d
|
taeseongkim
|
|
257 |
0157b158
|
taeseongkim
|
return convertWaitingItems.ToList();
|
258 |
53c9637d
|
taeseongkim
|
}
|
259 |
|
|
|
260 |
|
|
private string GetConvertPath(string ProjectNo,string DocumentID)
|
261 |
|
|
{
|
262 |
|
|
try
|
263 |
|
|
{
|
264 |
|
|
return Path.Combine(BaseStorage(ProjectNo), ProjectNo + "_Tile", (System.Convert.ToInt64(DocumentID) / 100).ToString(), DocumentID);
|
265 |
|
|
}
|
266 |
|
|
catch (Exception)
|
267 |
|
|
{
|
268 |
|
|
throw new Exception("GetConvertPath Error");
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
/// <summary>
|
275 |
|
|
/// 오류나 wait으로 남아 있는 데이터베이스의 Item을 StatusCodeType.None으로 복구
|
276 |
|
|
/// </summary>
|
277 |
2bbea412
|
taeseongkim
|
/// <param name="convertID">StatusCodeType을 변경하고자 하는 ConvertItem의 ID</param>
|
278 |
|
|
/// <param name="ReConvert">ReConvert가 2이면 다시 Convert를 시도 안하기 때문에 기존 값으로 유지 하고 계속 시도 할수 있도록 0을 주는 경우가 있다.</param>
|
279 |
53c9637d
|
taeseongkim
|
/// <returns></returns>
|
280 |
1ae729e4
|
taeseongkim
|
public int SetCleanUpItem(string convertID,int ReConvert)
|
281 |
53c9637d
|
taeseongkim
|
{
|
282 |
|
|
int result = 0;
|
283 |
|
|
|
284 |
0157b158
|
taeseongkim
|
var items = entities.CONVERTER_DOC.Where(x=> x.ID == convertID);
|
285 |
53c9637d
|
taeseongkim
|
|
286 |
|
|
result = items.Count();
|
287 |
|
|
|
288 |
|
|
if (items.Count() > 0)
|
289 |
|
|
{
|
290 |
0157b158
|
taeseongkim
|
var item = items.First();
|
291 |
|
|
|
292 |
a6e5055d
|
alzkakdixm
|
item.RECONVERTER = item.RECONVERTER - ReConvert;
|
293 |
0157b158
|
taeseongkim
|
item.CREATE_DATETIME = DateTime.Now;
|
294 |
a0341bef
|
taeseongkim
|
//item.START_DATETIME = null;
|
295 |
0157b158
|
taeseongkim
|
item.END_DATETIME = null;
|
296 |
|
|
item.STATUS = (int)StatusCodeType.None;
|
297 |
53c9637d
|
taeseongkim
|
|
298 |
0157b158
|
taeseongkim
|
result = entities.SaveChanges();
|
299 |
53c9637d
|
taeseongkim
|
}
|
300 |
|
|
|
301 |
|
|
return result;
|
302 |
|
|
}
|
303 |
|
|
|
304 |
5d863c06
|
taeseongkim
|
|
305 |
|
|
/// <summary>
|
306 |
|
|
/// Item 삭제
|
307 |
|
|
/// </summary>
|
308 |
|
|
/// <returns></returns>
|
309 |
|
|
public int RemoveItem(string convertID)
|
310 |
|
|
{
|
311 |
|
|
int result = 0;
|
312 |
|
|
|
313 |
|
|
var items = entities.CONVERTER_DOC.Where(x => x.ID == convertID);
|
314 |
|
|
|
315 |
|
|
if (items.Count() > 0)
|
316 |
|
|
{
|
317 |
|
|
CONVERTER_DOC item = items.First();
|
318 |
|
|
entities.CONVERTER_DOC.Remove(item);
|
319 |
|
|
|
320 |
|
|
result = entities.SaveChanges();
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
return result;
|
324 |
|
|
}
|
325 |
|
|
|
326 |
53c9637d
|
taeseongkim
|
/// <summary>
|
327 |
|
|
/// 전체 컨버터를 가져온다. 비동기로 변경하여야 한다.
|
328 |
|
|
/// </summary>
|
329 |
|
|
/// <returns></returns>
|
330 |
|
|
public List<Interface.ConvertItem> GetConvertItems( StatusCodeType statusCodeType)
|
331 |
|
|
{
|
332 |
|
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
333 |
|
|
|
334 |
|
|
var items = entities.CONVERTER_DOC.Where(x=>x.STATUS == (int)statusCodeType).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
|
335 |
|
|
|
336 |
|
|
if (items.Count() > 0)
|
337 |
|
|
{
|
338 |
|
|
foreach (var item in items)
|
339 |
|
|
{
|
340 |
06f13e11
|
taeseongkim
|
var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
341 |
|
|
{
|
342 |
|
|
ReConverter = item.RECONVERTER,
|
343 |
|
|
ServiceID = item.SERVICE_ID,
|
344 |
|
|
ConvertState = ((StatusCodeType)item.STATUS).ToString(),
|
345 |
|
|
CreateTime = item.CREATE_DATETIME,
|
346 |
|
|
TotalPage = item.TOTAL_PAGE,
|
347 |
|
|
CurrentPageNo = item.CURRENT_PAGE,
|
348 |
|
|
|
349 |
|
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
|
350 |
|
|
};
|
351 |
|
|
|
352 |
53c9637d
|
taeseongkim
|
|
353 |
|
|
convertItems.Add(convertitem);
|
354 |
|
|
}
|
355 |
|
|
}
|
356 |
|
|
return convertItems;
|
357 |
|
|
}
|
358 |
|
|
|
359 |
0157b158
|
taeseongkim
|
/// <summary>
|
360 |
b92f142f
|
taeseongkim
|
/// 전체 컨버터를 가져온다. 비동기로 변경하여야 한다.
|
361 |
|
|
/// </summary>
|
362 |
|
|
/// <returns></returns>
|
363 |
|
|
public List<Interface.ConvertItem> GetConvertItems(StatusCodeType statusCodeType,Func<CONVERTER_DOC, bool> @where,int takeCount = 100)
|
364 |
|
|
{
|
365 |
|
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
366 |
|
|
|
367 |
60723dc9
|
taeseongkim
|
|
368 |
|
|
var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).Take(takeCount).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
|
369 |
b92f142f
|
taeseongkim
|
|
370 |
|
|
if (items.Count() > 0)
|
371 |
|
|
{
|
372 |
|
|
foreach (var item in items)
|
373 |
|
|
{
|
374 |
|
|
var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
375 |
|
|
{
|
376 |
|
|
ReConverter = item.RECONVERTER,
|
377 |
|
|
ServiceID = item.SERVICE_ID,
|
378 |
|
|
ConvertState = ((StatusCodeType)item.STATUS).ToString(),
|
379 |
|
|
CreateTime = item.CREATE_DATETIME,
|
380 |
|
|
TotalPage = item.TOTAL_PAGE,
|
381 |
|
|
CurrentPageNo = item.CURRENT_PAGE,
|
382 |
|
|
|
383 |
|
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
|
384 |
|
|
};
|
385 |
|
|
|
386 |
|
|
|
387 |
|
|
convertItems.Add(convertitem);
|
388 |
|
|
}
|
389 |
|
|
}
|
390 |
|
|
return convertItems;
|
391 |
|
|
}
|
392 |
|
|
|
393 |
a6e5055d
|
alzkakdixm
|
public IEnumerable<Interface.ConvertItem> GetConvertProjects(Func<CONVERTER_DOC, bool> @where)
|
394 |
|
|
{
|
395 |
|
|
var items = entities.CONVERTER_DOC.Where(@where);
|
396 |
|
|
|
397 |
|
|
if (items.Count() > 0)
|
398 |
|
|
{
|
399 |
|
|
foreach (var item in items)
|
400 |
|
|
{
|
401 |
|
|
|
402 |
|
|
yield return new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
403 |
|
|
{
|
404 |
|
|
ReConverter = item.RECONVERTER,
|
405 |
|
|
ServiceID = item.SERVICE_ID,
|
406 |
|
|
//ConvertState = ((StatusCodeType)item.STATUS).ToString(),
|
407 |
|
|
ConvertState = (item.STATUS).ToString(),
|
408 |
|
|
CreateTime = item.CREATE_DATETIME,
|
409 |
|
|
TotalPage = item.TOTAL_PAGE,
|
410 |
|
|
CurrentPageNo = item.CURRENT_PAGE,
|
411 |
|
|
Exception = item.EXCEPTION,
|
412 |
|
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
|
413 |
|
|
};
|
414 |
|
|
|
415 |
|
|
}
|
416 |
|
|
}
|
417 |
|
|
}
|
418 |
|
|
|
419 |
|
|
public List<Interface.ConvertItem> GetConvertProjects(Func<CONVERTER_DOC, bool> @where, StatusCodeType status)
|
420 |
|
|
{
|
421 |
|
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
422 |
|
|
|
423 |
|
|
|
424 |
|
|
//var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).Take(takeCount).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
|
425 |
|
|
var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)status).ToList();
|
426 |
|
|
|
427 |
|
|
if (items.Count() > 0)
|
428 |
|
|
{
|
429 |
|
|
foreach (var item in items)
|
430 |
|
|
{
|
431 |
|
|
|
432 |
|
|
var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
433 |
|
|
{
|
434 |
|
|
ReConverter = item.RECONVERTER,
|
435 |
|
|
ServiceID = item.SERVICE_ID,
|
436 |
|
|
//ConvertState = ((StatusCodeType)item.STATUS).ToString(),
|
437 |
|
|
ConvertState = (item.STATUS).ToString(),
|
438 |
|
|
CreateTime = item.CREATE_DATETIME,
|
439 |
|
|
TotalPage = item.TOTAL_PAGE,
|
440 |
|
|
CurrentPageNo = item.CURRENT_PAGE,
|
441 |
|
|
Exception = item.EXCEPTION,
|
442 |
|
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
|
443 |
|
|
};
|
444 |
|
|
|
445 |
|
|
|
446 |
|
|
}
|
447 |
|
|
}
|
448 |
|
|
|
449 |
|
|
return convertItems;
|
450 |
|
|
}
|
451 |
|
|
|
452 |
|
|
public List<Interface.ConvertItem> GetConvertProjectsStatus(Func<CONVERTER_DOC, bool> @where)
|
453 |
|
|
{
|
454 |
|
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
//var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).Take(takeCount).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
|
458 |
|
|
var items = entities.CONVERTER_DOC.Where(x => x.STATUS<= 4);
|
459 |
|
|
|
460 |
|
|
if (items.Count() > 0)
|
461 |
|
|
{
|
462 |
|
|
foreach (var item in items)
|
463 |
|
|
{
|
464 |
|
|
var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
465 |
|
|
{
|
466 |
|
|
ReConverter = item.RECONVERTER,
|
467 |
|
|
ServiceID = item.SERVICE_ID,
|
468 |
|
|
//ConvertState = ((StatusCodeType)item.STATUS).ToString(),
|
469 |
|
|
ConvertState = (item.STATUS).ToString(),
|
470 |
|
|
CreateTime = item.CREATE_DATETIME,
|
471 |
|
|
TotalPage = item.TOTAL_PAGE,
|
472 |
|
|
CurrentPageNo = item.CURRENT_PAGE,
|
473 |
|
|
Exception = item.EXCEPTION,
|
474 |
|
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
|
475 |
|
|
};
|
476 |
|
|
|
477 |
|
|
|
478 |
|
|
convertItems.Add(convertitem);
|
479 |
|
|
}
|
480 |
|
|
}
|
481 |
|
|
|
482 |
|
|
return convertItems;
|
483 |
|
|
}
|
484 |
|
|
|
485 |
b92f142f
|
taeseongkim
|
|
486 |
|
|
/// <summary>
|
487 |
0157b158
|
taeseongkim
|
/// 현재 서비스에서 컨버터중인 아이템.
|
488 |
|
|
/// </summary>
|
489 |
|
|
/// <returns></returns>
|
490 |
|
|
public List<Interface.ConvertItem> GetServiceAliveItems(string ServiceID)
|
491 |
|
|
{
|
492 |
|
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
493 |
|
|
|
494 |
|
|
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);
|
495 |
|
|
|
496 |
|
|
if (items.Count() > 0)
|
497 |
|
|
{
|
498 |
|
|
foreach (var item in items)
|
499 |
|
|
{
|
500 |
|
|
var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL);
|
501 |
|
|
convertItems.Add(convertitem);
|
502 |
|
|
}
|
503 |
|
|
}
|
504 |
|
|
return convertItems;
|
505 |
|
|
}
|
506 |
|
|
|
507 |
|
|
public SERVICE_PROPERTIES GetServiceProperties(string ServiceID)
|
508 |
|
|
{
|
509 |
|
|
SERVICE_PROPERTIES result = null;
|
510 |
|
|
|
511 |
|
|
var items = entities.SERVICE_PROPERTIES.Where(x => x.ID == ServiceID);
|
512 |
|
|
|
513 |
|
|
if(items.Count() > 0)
|
514 |
|
|
{
|
515 |
|
|
result = items.First();
|
516 |
|
|
}
|
517 |
|
|
|
518 |
|
|
return result;
|
519 |
|
|
}
|
520 |
53c9637d
|
taeseongkim
|
|
521 |
0157b158
|
taeseongkim
|
public bool SetConvertState(string ServiceID, string UniqueID,int State,int CurrentPage,int TotalPage,string Error)
|
522 |
53c9637d
|
taeseongkim
|
{
|
523 |
|
|
bool result = false;
|
524 |
|
|
|
525 |
|
|
try
|
526 |
|
|
{
|
527 |
|
|
var items = entities.CONVERTER_DOC.SingleOrDefault(f => f.ID == UniqueID);
|
528 |
|
|
//var items = entities.CONVERTER_DOC.SingleOrDefault(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID);
|
529 |
|
|
|
530 |
|
|
if (items != null)
|
531 |
|
|
{
|
532 |
0157b158
|
taeseongkim
|
items.SERVICE_ID = ServiceID;
|
533 |
53c9637d
|
taeseongkim
|
items.STATUS = State;
|
534 |
|
|
items.CURRENT_PAGE = CurrentPage;
|
535 |
|
|
items.TOTAL_PAGE = TotalPage;
|
536 |
|
|
|
537 |
|
|
StatusCodeType statusCode = (StatusCodeType)State;
|
538 |
|
|
|
539 |
65fbe3cb
|
taeseongkim
|
if (items.START_DATETIME == null)
|
540 |
a8f1a865
|
taeseongkim
|
{
|
541 |
|
|
items.START_DATETIME = DateTime.Now;
|
542 |
|
|
}
|
543 |
|
|
|
544 |
53c9637d
|
taeseongkim
|
switch (statusCode)
|
545 |
|
|
{
|
546 |
|
|
case StatusCodeType.None:
|
547 |
|
|
break;
|
548 |
|
|
case StatusCodeType.Wait:
|
549 |
|
|
items.START_DATETIME = DateTime.Now;
|
550 |
|
|
break;
|
551 |
|
|
case StatusCodeType.PageLoading:
|
552 |
|
|
break;
|
553 |
|
|
case StatusCodeType.Saving:
|
554 |
|
|
break;
|
555 |
|
|
case StatusCodeType.Completed:
|
556 |
a0341bef
|
taeseongkim
|
items.CURRENT_PAGE = items.TOTAL_PAGE;
|
557 |
53c9637d
|
taeseongkim
|
items.END_DATETIME= DateTime.Now;
|
558 |
|
|
break;
|
559 |
|
|
case StatusCodeType.FileError:
|
560 |
|
|
Error = $" file Error :" + Error;
|
561 |
|
|
items.END_DATETIME = DateTime.Now;
|
562 |
|
|
break;
|
563 |
|
|
case StatusCodeType.PageError:
|
564 |
|
|
Error = $" Page No {CurrentPage} Error :" + Error;
|
565 |
|
|
break;
|
566 |
|
|
case StatusCodeType.NeedsPassword:
|
567 |
|
|
break;
|
568 |
|
|
case StatusCodeType.Error:
|
569 |
|
|
Error = $" Error :" + Error;
|
570 |
|
|
items.END_DATETIME = DateTime.Now;
|
571 |
|
|
break;
|
572 |
|
|
default:
|
573 |
|
|
break;
|
574 |
|
|
}
|
575 |
|
|
|
576 |
|
|
if(items.EXCEPTION == null)
|
577 |
|
|
{
|
578 |
|
|
items.EXCEPTION = "";
|
579 |
|
|
}
|
580 |
|
|
|
581 |
|
|
if (items.EXCEPTION.Length < 255)
|
582 |
|
|
{
|
583 |
|
|
items.EXCEPTION = items.EXCEPTION + Error;
|
584 |
|
|
}
|
585 |
|
|
|
586 |
|
|
entities.SaveChanges();
|
587 |
|
|
result = true;
|
588 |
|
|
}
|
589 |
|
|
}
|
590 |
|
|
catch (Exception ex)
|
591 |
|
|
{
|
592 |
|
|
throw new Exception("SetConvertState",ex);
|
593 |
|
|
}
|
594 |
|
|
|
595 |
|
|
return result;
|
596 |
|
|
}
|
597 |
|
|
|
598 |
|
|
private string BaseStorage(string ProjectNo)
|
599 |
|
|
{
|
600 |
|
|
string result = "";
|
601 |
|
|
|
602 |
|
|
var properties = entities.PROPERTIES.Where(f => f.PROPERTY == ProjectNo && f.TYPE == PROPERTIES_DEFINE.TILE_SOURCE_STORAGE);
|
603 |
|
|
|
604 |
|
|
if(properties.Count() > 0)
|
605 |
|
|
{
|
606 |
|
|
result = properties.First().VALUE;
|
607 |
|
|
}
|
608 |
|
|
else
|
609 |
|
|
{
|
610 |
|
|
throw new Exception($"Project {ProjectNo} BaseStorage Not Setting.");
|
611 |
|
|
}
|
612 |
|
|
|
613 |
|
|
return result;
|
614 |
|
|
}
|
615 |
|
|
|
616 |
|
|
}
|
617 |
|
|
} |