1
|
using Markus.EntityModel;
|
2
|
using Markus.Message;
|
3
|
using Markus.Service.Extensions;
|
4
|
using System;
|
5
|
using System.Collections.Generic;
|
6
|
using System.IO;
|
7
|
using System.Linq;
|
8
|
using System.Windows;
|
9
|
using System.Linq.Expressions;
|
10
|
using Markus.Service.Interface;
|
11
|
using Markus.Service.DataBase.Data;
|
12
|
using Markus.Service.DataBase.Extensions;
|
13
|
|
14
|
|
15
|
namespace Markus.Service.DataBase
|
16
|
{
|
17
|
public class ConvertDatabase : IDisposable
|
18
|
{
|
19
|
#region Constructor
|
20
|
/// <summary>
|
21
|
///해당 프로젝트의 데이터베이스 연결
|
22
|
/// </summary>
|
23
|
|
24
|
Markus.EntityModel.MarkusModel entities;
|
25
|
|
26
|
public ConvertDatabase(string ConnectionString)
|
27
|
{
|
28
|
try
|
29
|
{
|
30
|
entities = new Markus.EntityModel.MarkusModel(ConnectionString);
|
31
|
}
|
32
|
catch (Exception ex)
|
33
|
{
|
34
|
System.Diagnostics.Debug.WriteLine(ex.ToString());
|
35
|
throw ex;
|
36
|
}
|
37
|
}
|
38
|
|
39
|
public void Dispose()
|
40
|
{
|
41
|
entities.Dispose();
|
42
|
}
|
43
|
|
44
|
#endregion
|
45
|
|
46
|
#region DataBaseItemsModel Function
|
47
|
|
48
|
#region Get WaitConvertItems
|
49
|
|
50
|
/// <summary>
|
51
|
/// service에서 대기중이거나 오류인 아이템을 가져가서 컨버터 프로세스를 호출한다.
|
52
|
/// 컨버터 상태가 에러이거나 2보다 작은 경우
|
53
|
/// UniqueKey는 각 데이터베이스의 문서 정보에서 유일한 키이며 컨버터저장에서 같은 폴더로의 저장을 방지 한다.
|
54
|
///
|
55
|
/// </summary>
|
56
|
/// <param name="aliveItems"></param>
|
57
|
/// <param name="TakeCount"></param>
|
58
|
/// <returns></returns>
|
59
|
public IEnumerable<CONVERTER_DOC> GetWaitConvertItems(List<string> projectList, int TakeCount)
|
60
|
{
|
61
|
var convertWaitingItems = entities.CONVERTER_DOC.OrderBy(x => x.CREATE_DATETIME).Where(
|
62
|
x =>
|
63
|
//projectList.Contains(x.PROJECT_NO) && x.RECONVERTER < 2 &&
|
64
|
x.RECONVERTER < 2 &&
|
65
|
(x.STATUS == (int)StatusCodeType.None || x.STATUS > (int)StatusCodeType.Completed))
|
66
|
.GroupBy(x => x.DOCUMENT_ID).Select(x => x.FirstOrDefault())
|
67
|
.Take(TakeCount);
|
68
|
|
69
|
return convertWaitingItems;
|
70
|
}
|
71
|
|
72
|
#endregion
|
73
|
|
74
|
#region Get FilterConvertItems
|
75
|
|
76
|
/// <summary>
|
77
|
/// 상단 그리드 선택된 Status에 따라 DB에서 값 가져온다.
|
78
|
/// </summary>
|
79
|
public IEnumerable<Interface.ConvertItem> GetConvertProjects(int status,string ProjectNumberFilter, string UniqueKeyFilter, string Document_NameFilter, string Service_IDFilter, string Docuemnt_NOFilter, int? ReconverterFilter
|
80
|
, string RevisionFilter)
|
81
|
{
|
82
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
83
|
var query = from items in entities.CONVERTER_DOC
|
84
|
join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
|
85
|
from subpet in GroupItems.DefaultIfEmpty()
|
86
|
where items.STATUS == status &&
|
87
|
//
|
88
|
(
|
89
|
items.PROJECT_NO.Contains(ProjectNumberFilter)
|
90
|
|| subpet.DOCUMENT_NAME.Contains(Document_NameFilter)
|
91
|
|| items.SERVICE_ID.Contains(Service_IDFilter)
|
92
|
|| subpet.ID.Contains(UniqueKeyFilter)
|
93
|
|| subpet.DOCUMENT_NO.Contains(Docuemnt_NOFilter)
|
94
|
|| items.RECONVERTER == ReconverterFilter
|
95
|
|| subpet.REVISION.Contains(RevisionFilter)
|
96
|
)
|
97
|
//
|
98
|
orderby items.CREATE_DATETIME descending
|
99
|
select new
|
100
|
{
|
101
|
ID = items.ID,
|
102
|
DOCUMENT_URL = items.DOCUMENT_URL,
|
103
|
RECONVERTER = items.RECONVERTER,
|
104
|
SERVICE_ID = items.SERVICE_ID,
|
105
|
STATUS = items.STATUS,
|
106
|
CREATE_DATETIME = items.CREATE_DATETIME,
|
107
|
START_DATETIME = items.START_DATETIME,
|
108
|
END_DATETIME = items.END_DATETIME,
|
109
|
TOTAL_PAGE = items.TOTAL_PAGE,
|
110
|
CURRENT_PAGE = items.CURRENT_PAGE,
|
111
|
EXCEPTION = items.EXCEPTION,
|
112
|
PROJECT_NO = items.PROJECT_NO,
|
113
|
DOCUMENT_ID = items.DOCUMENT_ID,
|
114
|
REVISION = subpet.REVISION,
|
115
|
DOCUMENT_NO = subpet.DOCUMENT_NO,
|
116
|
DOCUMENT_NAME = subpet.DOCUMENT_NAME,
|
117
|
GROUP_NO = subpet.GROUP_NO,
|
118
|
};
|
119
|
|
120
|
if (query.Count() > 0)
|
121
|
{
|
122
|
foreach (var item in query)
|
123
|
{
|
124
|
Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
125
|
{
|
126
|
|
127
|
ReConverter = item.RECONVERTER,
|
128
|
ServiceID = item.SERVICE_ID,
|
129
|
ConvertState = (StatusCodeType)item.STATUS,
|
130
|
CreateTime = item.CREATE_DATETIME,
|
131
|
// StartTime = (DateTime)item.START_DATETIME,
|
132
|
//EndTime = (DateTime)item.END_DATETIME,
|
133
|
TotalPage = item.TOTAL_PAGE,
|
134
|
CurrentPageNo = item.CURRENT_PAGE,
|
135
|
Exception = item.EXCEPTION,
|
136
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
|
137
|
|
138
|
Revision = item.REVISION,
|
139
|
DocumentNo = item.DOCUMENT_NO,
|
140
|
DocumentName = item.DOCUMENT_NAME,
|
141
|
GroupNo = item.GROUP_NO,
|
142
|
DocumentID = item.DOCUMENT_ID,
|
143
|
|
144
|
MarkusLink = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech")
|
145
|
};
|
146
|
if(item.START_DATETIME == null)
|
147
|
{
|
148
|
convertitem.StartTime = null;
|
149
|
}
|
150
|
else
|
151
|
{
|
152
|
convertitem.StartTime = (DateTime)item.START_DATETIME;
|
153
|
}
|
154
|
if (item.END_DATETIME == null)
|
155
|
{
|
156
|
convertitem.EndTime = null;
|
157
|
}
|
158
|
else
|
159
|
{
|
160
|
convertitem.EndTime = (DateTime)item.END_DATETIME;
|
161
|
}
|
162
|
convertItems.Add(convertitem);
|
163
|
}
|
164
|
}
|
165
|
return convertItems;
|
166
|
|
167
|
}
|
168
|
|
169
|
/// <summary>Final PDF
|
170
|
/// 상단 그리드 선택된 Status에 따라 DB에서 값 가져온다.
|
171
|
/// </summary>
|
172
|
public IEnumerable<Interface.ConvertItem> GetFinalPDFProjects(int status, string ProjectNumberFilter, string DocumentIDFIlter, string MarkupInfo_IDFilter, string DOCINFO_IDFilter, string Document_NameFilter,
|
173
|
string Docuemnt_NOFilter, string CreateUser_IDFilter)
|
174
|
{
|
175
|
var MarkupInfo_IDFilter_Int = 0;
|
176
|
if (MarkupInfo_IDFilter != null)
|
177
|
{
|
178
|
MarkupInfo_IDFilter_Int = int.Parse(MarkupInfo_IDFilter);
|
179
|
}
|
180
|
|
181
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
182
|
var query = from items in entities.FINAL_PDF
|
183
|
join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
|
184
|
from subpet in GroupItems.DefaultIfEmpty()
|
185
|
where items.STATUS == status &&
|
186
|
//
|
187
|
(
|
188
|
items.PROJECT_NO.Contains(ProjectNumberFilter)
|
189
|
|| subpet.DOCUMENT_ID.Contains(DocumentIDFIlter)
|
190
|
|| items.MARKUPINFO_ID == MarkupInfo_IDFilter_Int
|
191
|
|| items.DOCINFO_ID.Contains(DOCINFO_IDFilter)
|
192
|
|| subpet.DOCUMENT_NAME.Contains(Document_NameFilter)
|
193
|
|| subpet.DOCUMENT_NO.Contains(Docuemnt_NOFilter)
|
194
|
|| items.CREATE_USER_ID.Contains(CreateUser_IDFilter)
|
195
|
)
|
196
|
//
|
197
|
orderby items.CREATE_DATETIME descending
|
198
|
select new
|
199
|
{
|
200
|
ID = items.ID,
|
201
|
PROJECT_NO = items.PROJECT_NO,
|
202
|
DOCINFO_ID = items.DOCINFO_ID,
|
203
|
MARKUPINFO_ID = items.MARKUPINFO_ID,
|
204
|
CREATE_USER_ID = items.CREATE_USER_ID,
|
205
|
CREATE_DATETIME = items.CREATE_DATETIME,
|
206
|
STATUS = items.STATUS,
|
207
|
TOTAL_PAGE = items.TOTAL_PAGE,
|
208
|
CURRENT_PAGE = items.CURRENT_PAGE,
|
209
|
EXCEPTION = items.EXCEPTION,
|
210
|
END_DATETIME = items.END_DATETIME,
|
211
|
START_DATETIME = items.START_DATETIME,
|
212
|
DOCUMENT_ID = items.DOCUMENT_ID,
|
213
|
DOCUMENT_URL = subpet.ORIGINAL_FILE,
|
214
|
|
215
|
REVISION = subpet.REVISION,
|
216
|
GROUP_NO = subpet.GROUP_NO,
|
217
|
RESULT_FILE = subpet.RESULT_FILE,
|
218
|
RESULT = subpet.RESULT,
|
219
|
|
220
|
|
221
|
DOCUMENT_NO = subpet.DOCUMENT_NO,
|
222
|
DOCUMENT_NAME = subpet.DOCUMENT_NAME
|
223
|
};
|
224
|
|
225
|
if (query.Count() > 0)//세미
|
226
|
{
|
227
|
foreach (var item in query)
|
228
|
{
|
229
|
Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
230
|
{
|
231
|
ConvertID = item.ID,
|
232
|
DocInfo_ID = item.DOCINFO_ID,
|
233
|
MarkupInfo_ID = item.MARKUPINFO_ID.ToString(),
|
234
|
Create_User_ID = item.CREATE_USER_ID,
|
235
|
CreateTime = item.CREATE_DATETIME,
|
236
|
ConvertState = (StatusCodeType)item.STATUS,
|
237
|
TotalPage = item.TOTAL_PAGE,
|
238
|
CurrentPageNo = item.CURRENT_PAGE,
|
239
|
Exception = item.EXCEPTION,
|
240
|
EndTime = (DateTime)item.END_DATETIME,
|
241
|
StartTime = (DateTime)item.START_DATETIME,
|
242
|
DocumentNo = item.DOCUMENT_NO,
|
243
|
DocumentName = item.DOCUMENT_NAME,
|
244
|
GroupNo = item.GROUP_NO,
|
245
|
Revision = item.REVISION,
|
246
|
|
247
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
|
248
|
MarkusLink = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech")
|
249
|
};
|
250
|
|
251
|
convertItems.Add(convertitem);
|
252
|
}
|
253
|
}
|
254
|
return convertItems;
|
255
|
|
256
|
}
|
257
|
|
258
|
|
259
|
public IEnumerable<Interface.ConvertItem> GetConvertProjects(int status)
|
260
|
{
|
261
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
262
|
var query = from items in entities.CONVERTER_DOC
|
263
|
join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
|
264
|
from subpet in GroupItems.DefaultIfEmpty()
|
265
|
where items.STATUS == status
|
266
|
orderby items.CREATE_DATETIME descending
|
267
|
select new
|
268
|
{
|
269
|
ID = items.ID,
|
270
|
DOCUMENT_URL = items.DOCUMENT_URL,
|
271
|
RECONVERTER = items.RECONVERTER,
|
272
|
SERVICE_ID = items.SERVICE_ID,
|
273
|
STATUS = items.STATUS,
|
274
|
CREATE_DATETIME = items.CREATE_DATETIME,
|
275
|
START_DATETIME = items.START_DATETIME,
|
276
|
END_DATETIME = items.END_DATETIME,
|
277
|
TOTAL_PAGE = items.TOTAL_PAGE,
|
278
|
CURRENT_PAGE = items.CURRENT_PAGE,
|
279
|
EXCEPTION = items.EXCEPTION,
|
280
|
PROJECT_NO = items.PROJECT_NO,
|
281
|
DOCUMENT_ID = items.DOCUMENT_ID,
|
282
|
REVISION = subpet.REVISION,
|
283
|
DOCUMENT_NO = subpet.DOCUMENT_NO,
|
284
|
DOCUMENT_NAME = subpet.DOCUMENT_NAME,
|
285
|
GROUP_NO = subpet.GROUP_NO
|
286
|
};
|
287
|
|
288
|
if (query.Count() > 0)//세미
|
289
|
{
|
290
|
foreach (var item in query)
|
291
|
{
|
292
|
Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
293
|
{
|
294
|
|
295
|
ReConverter = item.RECONVERTER,
|
296
|
ServiceID = item.SERVICE_ID,
|
297
|
ConvertState = (StatusCodeType)item.STATUS,
|
298
|
CreateTime = item.CREATE_DATETIME,
|
299
|
StartTime = (DateTime)item.START_DATETIME,
|
300
|
EndTime = (DateTime)item.END_DATETIME,
|
301
|
TotalPage = item.TOTAL_PAGE,
|
302
|
CurrentPageNo = item.CURRENT_PAGE,
|
303
|
Exception = item.EXCEPTION,
|
304
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
|
305
|
|
306
|
Revision = item.REVISION,
|
307
|
DocumentNo = item.DOCUMENT_NO,
|
308
|
DocumentName = item.DOCUMENT_NAME,
|
309
|
GroupNo = item.GROUP_NO,
|
310
|
DocumentID = item.DOCUMENT_ID,
|
311
|
|
312
|
|
313
|
MarkusLink = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech")
|
314
|
};
|
315
|
convertItems.Add(convertitem);
|
316
|
}
|
317
|
}
|
318
|
return convertItems;
|
319
|
|
320
|
}
|
321
|
|
322
|
public string[] GetSearchConvertPathAndMarkus(string PROJECT_NO, string DOCUMENT_ID)
|
323
|
{
|
324
|
string[] ConvertPath = new string[2];
|
325
|
ConvertPath[0] = GetConvertPath(PROJECT_NO, DOCUMENT_ID);
|
326
|
ConvertPath[1] = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(PROJECT_NO, DOCUMENT_ID, "doftech");
|
327
|
|
328
|
return ConvertPath;
|
329
|
}
|
330
|
|
331
|
#endregion
|
332
|
|
333
|
#region Update RealDataSelect
|
334
|
|
335
|
/// <summary>
|
336
|
/// 상단 그리드에서 선택된 RealDataSelect
|
337
|
/// 용도: 중앙그리드 Items Update
|
338
|
/// </summary>
|
339
|
|
340
|
|
341
|
public IEnumerable<Interface.ConvertItem> GetConvertFinalPDFProjects(System.Collections.ObjectModel.ObservableCollection<Interface.ConvertItem> selectedConvert)
|
342
|
{
|
343
|
List<Interface.ConvertItem> StatusKeep = new List<Interface.ConvertItem>();
|
344
|
|
345
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
346
|
|
347
|
foreach (var selectedConvertItem in selectedConvert)
|
348
|
{
|
349
|
var query = from items in entities.FINAL_PDF //세미
|
350
|
join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
|
351
|
from subpet in GroupItems.DefaultIfEmpty()
|
352
|
where items.PROJECT_NO == selectedConvertItem.ProjectNumber && items.ID == selectedConvertItem.ConvertID
|
353
|
select new
|
354
|
{
|
355
|
ID = items.ID,
|
356
|
PROJECT_NO = items.PROJECT_NO,
|
357
|
DOCINFO_ID = items.DOCINFO_ID,
|
358
|
MARKUPINFO_ID = items.MARKUPINFO_ID,
|
359
|
CREATE_USER_ID = items.CREATE_USER_ID,
|
360
|
CREATE_DATETIME = items.CREATE_DATETIME,
|
361
|
STATUS = items.STATUS,
|
362
|
TOTAL_PAGE = items.TOTAL_PAGE,
|
363
|
CURRENT_PAGE = items.CURRENT_PAGE,
|
364
|
EXCEPTION = items.EXCEPTION,
|
365
|
END_DATETIME = items.END_DATETIME,
|
366
|
START_DATETIME = items.START_DATETIME,
|
367
|
DOCUMENT_ID = items.DOCUMENT_ID,
|
368
|
|
369
|
DOCUMENT_URL = subpet.ORIGINAL_FILE,
|
370
|
DOCUMENT_NO = subpet.DOCUMENT_NO,
|
371
|
DOCUMENT_NAME = subpet.DOCUMENT_NAME
|
372
|
};
|
373
|
|
374
|
|
375
|
if (query.Count() > 0)//세미
|
376
|
{
|
377
|
foreach (var item in query)
|
378
|
{
|
379
|
Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
380
|
{
|
381
|
|
382
|
DocInfo_ID = item.DOCINFO_ID,
|
383
|
MarkupInfo_ID = item.MARKUPINFO_ID.ToString(),
|
384
|
Create_User_ID = item.CREATE_USER_ID,
|
385
|
CreateTime = item.CREATE_DATETIME,
|
386
|
ConvertState = (StatusCodeType)item.STATUS,
|
387
|
TotalPage = item.TOTAL_PAGE,
|
388
|
CurrentPageNo = item.CURRENT_PAGE,
|
389
|
Exception = item.EXCEPTION,
|
390
|
EndTime = (DateTime)item.END_DATETIME,
|
391
|
StartTime = (DateTime)item.START_DATETIME,
|
392
|
DocumentNo = item.DOCUMENT_NO,
|
393
|
DocumentName = item.DOCUMENT_NAME,
|
394
|
|
395
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
|
396
|
MarkusLink = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech")
|
397
|
};
|
398
|
|
399
|
StatusKeep.Add(convertitem);
|
400
|
|
401
|
}
|
402
|
}
|
403
|
}
|
404
|
return StatusKeep;
|
405
|
}
|
406
|
|
407
|
|
408
|
public IEnumerable<Interface.ConvertItem> GetConvertProjects(System.Collections.ObjectModel.ObservableCollection<Interface.ConvertItem> selectedConvert)
|
409
|
{
|
410
|
List<Interface.ConvertItem> StatusKeep = new List<Interface.ConvertItem>();
|
411
|
|
412
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
413
|
|
414
|
foreach (var selectedConvertItem in selectedConvert)
|
415
|
{
|
416
|
var query = from items in entities.CONVERTER_DOC //세미
|
417
|
join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
|
418
|
from subpet in GroupItems.DefaultIfEmpty()
|
419
|
where items.PROJECT_NO == selectedConvertItem.ProjectNumber && items.ID == selectedConvertItem.ConvertID
|
420
|
select new
|
421
|
{
|
422
|
ID = items.ID,
|
423
|
DOCUMENT_URL = items.DOCUMENT_URL,
|
424
|
RECONVERTER = items.RECONVERTER,
|
425
|
SERVICE_ID = items.SERVICE_ID,
|
426
|
STATUS = items.STATUS,
|
427
|
CREATE_DATETIME = items.CREATE_DATETIME,
|
428
|
START_DATETIME = items.START_DATETIME,
|
429
|
END_DATETIME = items.END_DATETIME,
|
430
|
TOTAL_PAGE = items.TOTAL_PAGE,
|
431
|
CURRENT_PAGE = items.CURRENT_PAGE,
|
432
|
EXCEPTION = items.EXCEPTION,
|
433
|
PROJECT_NO = items.PROJECT_NO,
|
434
|
DOCUMENT_ID = items.DOCUMENT_ID,
|
435
|
REVISION = subpet.REVISION,
|
436
|
DOCUMENT_NO = subpet.DOCUMENT_NO,
|
437
|
DOCUMENT_NAME = subpet.DOCUMENT_NAME,
|
438
|
GROUP_NO = subpet.GROUP_NO
|
439
|
};
|
440
|
|
441
|
|
442
|
if (query.Count() > 0)//세미
|
443
|
{
|
444
|
foreach (var item in query)
|
445
|
{
|
446
|
Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
447
|
{
|
448
|
|
449
|
ReConverter = item.RECONVERTER,
|
450
|
ServiceID = item.SERVICE_ID,
|
451
|
ConvertState = (StatusCodeType)item.STATUS,
|
452
|
CreateTime = item.CREATE_DATETIME,
|
453
|
StartTime = item.START_DATETIME,
|
454
|
EndTime = item.END_DATETIME,
|
455
|
TotalPage = item.TOTAL_PAGE,
|
456
|
CurrentPageNo = item.CURRENT_PAGE,
|
457
|
Exception = item.EXCEPTION,
|
458
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
|
459
|
|
460
|
Revision = item.REVISION,
|
461
|
DocumentNo = item.DOCUMENT_NO,
|
462
|
DocumentName = item.DOCUMENT_NAME,
|
463
|
GroupNo = item.GROUP_NO,
|
464
|
|
465
|
MarkusLink = "kcom://" + MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech")
|
466
|
};
|
467
|
|
468
|
StatusKeep.Add(convertitem);
|
469
|
|
470
|
}
|
471
|
}
|
472
|
}
|
473
|
return StatusKeep;
|
474
|
}
|
475
|
|
476
|
#endregion
|
477
|
|
478
|
#region Data Convert
|
479
|
|
480
|
/// <summary>
|
481
|
/// 상단 그리드에서 선택된 Convert 버튼
|
482
|
/// 용도: 중앙 그리드로 Convert된 row 값 저장 하기 위해서 입니다.
|
483
|
/// </summary>
|
484
|
|
485
|
public IEnumerable<Interface.ConvertItem> GetConvertFinalPDFProjects(Markus.Service.Interface.ConvertItem selectedConvert)
|
486
|
{
|
487
|
List<Interface.ConvertItem> StatusKeep = new List<Interface.ConvertItem>();
|
488
|
|
489
|
|
490
|
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
|
491
|
|
492
|
stopwatch.Start();
|
493
|
|
494
|
|
495
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();//디비 다 조인 후 조건 비교 후 그리드 출력
|
496
|
var query = from items in entities.FINAL_PDF //세미
|
497
|
join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
|
498
|
from subpet in GroupItems.DefaultIfEmpty()
|
499
|
where items.PROJECT_NO == selectedConvert.ProjectNumber && items.DOCUMENT_ID == selectedConvert.DocumentID
|
500
|
orderby items.CREATE_DATETIME descending
|
501
|
select new
|
502
|
{
|
503
|
ID = items.ID,
|
504
|
PROJECT_NO = items.PROJECT_NO,
|
505
|
DOCINFO_ID = items.DOCINFO_ID,
|
506
|
MARKUPINFO_ID = items.MARKUPINFO_ID,
|
507
|
CREATE_USER_ID = items.CREATE_USER_ID,
|
508
|
CREATE_DATETIME = items.CREATE_DATETIME,
|
509
|
STATUS = items.STATUS,
|
510
|
TOTAL_PAGE = items.TOTAL_PAGE,
|
511
|
CURRENT_PAGE = items.CURRENT_PAGE,
|
512
|
EXCEPTION = items.EXCEPTION,
|
513
|
END_DATETIME = items.END_DATETIME,
|
514
|
START_DATETIME = items.START_DATETIME,
|
515
|
DOCUMENT_ID = items.DOCUMENT_ID,
|
516
|
|
517
|
DOCUMENT_URL = subpet.ORIGINAL_FILE,
|
518
|
DOCUMENT_NO = subpet.DOCUMENT_NO,
|
519
|
DOCUMENT_NAME = subpet.DOCUMENT_NAME
|
520
|
};
|
521
|
|
522
|
if (query.Count() > 0)//세미
|
523
|
{
|
524
|
foreach (var item in query)
|
525
|
{
|
526
|
Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
527
|
{
|
528
|
|
529
|
DocInfo_ID = item.DOCINFO_ID,
|
530
|
MarkupInfo_ID = item.MARKUPINFO_ID.ToString(),
|
531
|
Create_User_ID = item.CREATE_USER_ID,
|
532
|
CreateTime = item.CREATE_DATETIME,
|
533
|
ConvertState = (StatusCodeType)item.STATUS,
|
534
|
TotalPage = item.TOTAL_PAGE,
|
535
|
CurrentPageNo = item.CURRENT_PAGE,
|
536
|
Exception = item.EXCEPTION,
|
537
|
EndTime = (DateTime)item.END_DATETIME,
|
538
|
StartTime = (DateTime)item.START_DATETIME,
|
539
|
DocumentNo = item.DOCUMENT_NO,
|
540
|
DocumentName = item.DOCUMENT_NAME,
|
541
|
|
542
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
|
543
|
MarkusLink = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech")
|
544
|
};
|
545
|
StatusKeep.Add(convertitem);
|
546
|
}
|
547
|
}
|
548
|
System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks).ToString());
|
549
|
return StatusKeep;
|
550
|
|
551
|
}
|
552
|
|
553
|
public IEnumerable<Interface.ConvertItem> GetConvertProjects(Markus.Service.Interface.ConvertItem selectedConvert)
|
554
|
{
|
555
|
List<Interface.ConvertItem> StatusKeep = new List<Interface.ConvertItem>();
|
556
|
|
557
|
|
558
|
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
|
559
|
|
560
|
stopwatch.Start();
|
561
|
|
562
|
|
563
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();//디비 다 조인 후 조건 비교 후 그리드 출력
|
564
|
var query = from items in entities.CONVERTER_DOC //세미
|
565
|
join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
|
566
|
from subpet in GroupItems.DefaultIfEmpty()
|
567
|
where items.PROJECT_NO == selectedConvert.ProjectNumber && items.DOCUMENT_ID == selectedConvert.DocumentID
|
568
|
orderby items.CREATE_DATETIME descending
|
569
|
select new
|
570
|
{
|
571
|
ID = items.ID,
|
572
|
DOCUMENT_URL = items.DOCUMENT_URL,
|
573
|
RECONVERTER = items.RECONVERTER,
|
574
|
SERVICE_ID = items.SERVICE_ID,
|
575
|
STATUS = items.STATUS,
|
576
|
CREATE_DATETIME = items.CREATE_DATETIME,
|
577
|
START_DATETIME = items.START_DATETIME,
|
578
|
END_DATETIME = items.END_DATETIME,
|
579
|
TOTAL_PAGE = items.TOTAL_PAGE,
|
580
|
CURRENT_PAGE = items.CURRENT_PAGE,
|
581
|
EXCEPTION = items.EXCEPTION,
|
582
|
PROJECT_NO = items.PROJECT_NO,
|
583
|
DOCUMENT_ID = items.DOCUMENT_ID,
|
584
|
REVISION = subpet.REVISION,
|
585
|
DOCUMENT_NO = subpet.DOCUMENT_NO,
|
586
|
DOCUMENT_NAME = subpet.DOCUMENT_NAME,
|
587
|
GROUP_NO = subpet.GROUP_NO
|
588
|
};
|
589
|
|
590
|
if (query.Count() > 0)//세미
|
591
|
{
|
592
|
foreach (var item in query)
|
593
|
{
|
594
|
Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
595
|
{
|
596
|
|
597
|
ReConverter = item.RECONVERTER,
|
598
|
ServiceID = item.SERVICE_ID,
|
599
|
ConvertState = (StatusCodeType)item.STATUS,
|
600
|
CreateTime = item.CREATE_DATETIME,
|
601
|
StartTime = item.START_DATETIME,
|
602
|
EndTime = item.END_DATETIME,
|
603
|
TotalPage = item.TOTAL_PAGE,
|
604
|
CurrentPageNo = item.CURRENT_PAGE,
|
605
|
Exception = item.EXCEPTION,
|
606
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
|
607
|
Revision = item.REVISION,
|
608
|
DocumentNo = item.DOCUMENT_NO,
|
609
|
DocumentName = item.DOCUMENT_NAME,
|
610
|
GroupNo = item.GROUP_NO,
|
611
|
|
612
|
MarkusLink = "kcom://" + Markus.Service.DataBase.Extensions.MarkusAPI.CreateMarkusParam(item.PROJECT_NO, item.DOCUMENT_ID, "doftech")
|
613
|
};
|
614
|
StatusKeep.Add(convertitem);
|
615
|
}
|
616
|
}
|
617
|
System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks).ToString());
|
618
|
return StatusKeep;
|
619
|
|
620
|
}
|
621
|
|
622
|
|
623
|
#endregion
|
624
|
|
625
|
#region SetCleanUpItem
|
626
|
/// <summary>
|
627
|
/// 오류나 wait으로 남아 있는 데이터베이스의 Item을 StatusCodeType.None으로 복구
|
628
|
/// </summary>
|
629
|
/// <param name="convertID">StatusCodeType을 변경하고자 하는 ConvertItem의 ID</param>
|
630
|
/// <param name="ReConvert">ReConvert가 2이면 다시 Convert를 시도 안하기 때문에 기존 값으로 유지 하고 계속 시도 할수 있도록 0을 주는 경우가 있다.</param>
|
631
|
/// <returns></returns>
|
632
|
///
|
633
|
public int SetCleanUpFinalPDFItem(ConvertItem _ConvertItem)
|
634
|
{
|
635
|
int result = 0;
|
636
|
|
637
|
var items = entities.FINAL_PDF.Where(x => x.ID == _ConvertItem.ConvertID);
|
638
|
|
639
|
result = items.Count();
|
640
|
|
641
|
if (items.Count() > 0)
|
642
|
{
|
643
|
var item = items.First();
|
644
|
|
645
|
//item.RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
|
646
|
|
647
|
item.CREATE_DATETIME = DateTime.Now;
|
648
|
item.STATUS = (int)StatusCodeType.None;
|
649
|
item.END_DATETIME = null;
|
650
|
|
651
|
|
652
|
var waiter = entities.SaveChangesAsync().GetAwaiter();
|
653
|
result = waiter.GetResult();
|
654
|
}
|
655
|
|
656
|
return result;
|
657
|
}
|
658
|
|
659
|
//public int SetCleanUpItem(ConvertItem _ConvertItem)
|
660
|
//{
|
661
|
// int result = 0;
|
662
|
|
663
|
// var items = entities.CONVERTER_DOC.Where(x => x.ID == _ConvertItem.ConvertID);
|
664
|
|
665
|
// result = items.Count();
|
666
|
|
667
|
// if (items.Count() > 0)
|
668
|
// {
|
669
|
// var item = items.First();
|
670
|
|
671
|
// item.RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
|
672
|
|
673
|
// item.CREATE_DATETIME = DateTime.Now;
|
674
|
// item.STATUS = (int)StatusCodeType.None;
|
675
|
// item.END_DATETIME = null;
|
676
|
|
677
|
// result = entities.SaveChanges();
|
678
|
// }
|
679
|
|
680
|
// return result;
|
681
|
//}
|
682
|
|
683
|
public int SetCleanUpItem(string convertID, int ReConvert)
|
684
|
{
|
685
|
int result = 0;
|
686
|
|
687
|
var items = entities.CONVERTER_DOC.Where(x => x.ID == convertID);
|
688
|
|
689
|
result = items.Count();
|
690
|
|
691
|
if (items.Count() > 0)
|
692
|
{
|
693
|
var item = items.First();
|
694
|
|
695
|
item.RECONVERTER = item.RECONVERTER + ReConvert;
|
696
|
item.CREATE_DATETIME = DateTime.Now;
|
697
|
//item.START_DATETIME = null;
|
698
|
item.END_DATETIME = null;
|
699
|
item.STATUS = (int)StatusCodeType.None;
|
700
|
|
701
|
var waiter = entities.SaveChangesAsync().GetAwaiter();
|
702
|
result = waiter.GetResult();
|
703
|
}
|
704
|
|
705
|
return result;
|
706
|
}
|
707
|
#endregion
|
708
|
|
709
|
#region Convert Path
|
710
|
|
711
|
private string GetConvertPath(string ProjectNo, string DocumentID)
|
712
|
{
|
713
|
try
|
714
|
{
|
715
|
|
716
|
return Path.Combine(BaseStorage(ProjectNo), ProjectNo + "_Tile", (System.Convert.ToInt64(DocumentID) / 100).ToString(), DocumentID);
|
717
|
return Path.Combine(BaseStorage(ProjectNo), ProjectNo + "_Tile",DocumentID.Substring(0, 5).ToString(), DocumentID);
|
718
|
}
|
719
|
catch (Exception)
|
720
|
{
|
721
|
throw new Exception("GetConvertPath Error");
|
722
|
}
|
723
|
|
724
|
}
|
725
|
|
726
|
private string BaseStorage(string ProjectNo)
|
727
|
{
|
728
|
string result = "";
|
729
|
|
730
|
var properties = entities.PROPERTIES.Where(f => f.PROPERTY == ProjectNo && f.TYPE == PROPERTIES_DEFINE.TILE_SOURCE_STORAGE);
|
731
|
|
732
|
if (properties.Count() > 0)
|
733
|
{
|
734
|
result = properties.First().VALUE;
|
735
|
}
|
736
|
else
|
737
|
{
|
738
|
throw new Exception($"Project {ProjectNo} BaseStorage Not Setting.");
|
739
|
}
|
740
|
|
741
|
return result;
|
742
|
}
|
743
|
|
744
|
#endregion
|
745
|
|
746
|
#region Remove
|
747
|
|
748
|
/// <summary>
|
749
|
/// Item 삭제
|
750
|
/// </summary>
|
751
|
/// <returns></returns>
|
752
|
///
|
753
|
|
754
|
public int RemoveFinalPDFItem(string convertID)
|
755
|
{
|
756
|
int result = 0;
|
757
|
|
758
|
var items = entities.FINAL_PDF.Where(x => x.ID == convertID);
|
759
|
|
760
|
if (items.Count() > 0)
|
761
|
{
|
762
|
FINAL_PDF item = items.First();
|
763
|
entities.FINAL_PDF.Remove(item);
|
764
|
|
765
|
|
766
|
var waiter = entities.SaveChangesAsync().GetAwaiter();
|
767
|
result = waiter.GetResult();
|
768
|
}
|
769
|
|
770
|
return result;
|
771
|
}
|
772
|
|
773
|
public int RemoveItem(string convertID)
|
774
|
{
|
775
|
int result = 0;
|
776
|
|
777
|
var items = entities.CONVERTER_DOC.Where(x => x.ID == convertID);
|
778
|
|
779
|
if (items.Count() > 0)
|
780
|
{
|
781
|
CONVERTER_DOC item = items.First();
|
782
|
entities.CONVERTER_DOC.Remove(item);
|
783
|
|
784
|
|
785
|
var waiter = entities.SaveChangesAsync().GetAwaiter();
|
786
|
result = waiter.GetResult();
|
787
|
}
|
788
|
|
789
|
return result;
|
790
|
}
|
791
|
|
792
|
|
793
|
#endregion
|
794
|
|
795
|
#region MarkusLink
|
796
|
|
797
|
|
798
|
////// userID는 관리자 계정인 doftech
|
799
|
////string markusLink = "kcom://" + MarkusAPI.CreateMarkusParam(projectNo, documentID, userID);
|
800
|
//public static string CreateMarkusParam(string projectNo, string documentID, string userID)
|
801
|
//{
|
802
|
// ViewInfo viewInfo = new ViewInfo();
|
803
|
|
804
|
// viewInfo.DocumentItemID = documentID;
|
805
|
// viewInfo.ProjectNO = projectNo;
|
806
|
// viewInfo.UserID = userID;
|
807
|
|
808
|
// return ParamEncoding(JsonConvert.SerializeObject(viewInfo));
|
809
|
|
810
|
//}
|
811
|
|
812
|
//public static string ParamEncoding(string EncodingText, System.Text.Encoding oEncoding = null)
|
813
|
//{
|
814
|
|
815
|
// if (oEncoding == null)
|
816
|
// oEncoding = System.Text.Encoding.UTF8;
|
817
|
|
818
|
// return Convert.ToBase64String(oEncoding.GetBytes(EncodingText));
|
819
|
|
820
|
//}
|
821
|
|
822
|
|
823
|
#endregion
|
824
|
|
825
|
#endregion
|
826
|
|
827
|
#region DataBaseByStatusViewModel Function
|
828
|
/// <summary>
|
829
|
/// 전체 컨버터를 가져온다. 비동기로 변경하여야 한다.
|
830
|
/// </summary>
|
831
|
/// <returns></returns>
|
832
|
public List<Interface.ConvertItem> GetConvertItems(StatusCodeType statusCodeType, Func<CONVERTER_DOC, bool> @where, int takeCount = 100)
|
833
|
{
|
834
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
835
|
|
836
|
|
837
|
var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).Take(takeCount).ToList();
|
838
|
|
839
|
if (items.Count() > 0)
|
840
|
{
|
841
|
foreach (var item in items)
|
842
|
{
|
843
|
var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
844
|
{
|
845
|
ReConverter = item.RECONVERTER,
|
846
|
ServiceID = item.SERVICE_ID,
|
847
|
ConvertState = ((StatusCodeType)item.STATUS),
|
848
|
CreateTime = item.CREATE_DATETIME,
|
849
|
TotalPage = item.TOTAL_PAGE,
|
850
|
CurrentPageNo = item.CURRENT_PAGE,
|
851
|
|
852
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
|
853
|
};
|
854
|
|
855
|
convertItems.Add(convertitem);
|
856
|
}
|
857
|
}
|
858
|
return convertItems;
|
859
|
}
|
860
|
#endregion
|
861
|
|
862
|
#region No 참조
|
863
|
|
864
|
/// <summary>
|
865
|
/// 컨버터서비스를 이용하는 문서 정보 저장
|
866
|
/// UniqueID
|
867
|
/// using Markus.Service.Extensions; new Guid().CreateUniqueGuid().ToString();
|
868
|
/// </summary>
|
869
|
/// <param name="ProjectNo">프로젝트</param>
|
870
|
/// <param name="UniqueID">컨버터 서비스의 아이템 ID</param>
|
871
|
/// <param name="originfilePath"></param>
|
872
|
/// <param name="DocumentID"></param>
|
873
|
/// <returns></returns>
|
874
|
public bool SetConvertDoc(string ProjectNo, string UniqueID, string originfilePath, string DocumentID)
|
875
|
{
|
876
|
bool result = false;
|
877
|
|
878
|
if (ProjectNo.IsNullOrEmpty())
|
879
|
{
|
880
|
throw new Exception("ProjectNo is Null");
|
881
|
}
|
882
|
|
883
|
if (UniqueID.IsNullOrEmpty())
|
884
|
{
|
885
|
throw new Exception("UniqueID is Null");
|
886
|
}
|
887
|
|
888
|
if (originfilePath.IsNullOrEmpty())
|
889
|
{
|
890
|
throw new Exception("originfilePath is Null");
|
891
|
}
|
892
|
|
893
|
if (DocumentID.IsNullOrEmpty())
|
894
|
{
|
895
|
throw new Exception("DocumentID is Null");
|
896
|
}
|
897
|
|
898
|
if (DocumentID.IsNullOrEmpty())
|
899
|
{
|
900
|
long _lastDocId = 0;
|
901
|
|
902
|
if (entities.CONVERTER_DOC.Count() > 0)
|
903
|
{
|
904
|
try
|
905
|
{
|
906
|
string qry = @"SELECT * FROM CONVERTER_DOC order by CAST(DOCUMENT_ID as int) desc";
|
907
|
var _item = entities.CONVERTER_DOC.SqlQuery(qry).FirstOrDefault();
|
908
|
|
909
|
if (_item != null)
|
910
|
{
|
911
|
_lastDocId = Convert.ToInt64(_item.DOCUMENT_ID) + 1;
|
912
|
}
|
913
|
}
|
914
|
catch (Exception)
|
915
|
{
|
916
|
|
917
|
throw;
|
918
|
}
|
919
|
}
|
920
|
|
921
|
DocumentID = _lastDocId.ToString();
|
922
|
}
|
923
|
|
924
|
CONVERTER_DOC convert_doc = new CONVERTER_DOC
|
925
|
{
|
926
|
ID = UniqueID,
|
927
|
PROJECT_NO = ProjectNo,
|
928
|
DOCUMENT_URL = originfilePath,
|
929
|
DOCUMENT_ID = DocumentID,
|
930
|
CREATE_DATETIME = DateTime.Now,
|
931
|
STATUS = 0,
|
932
|
TOTAL_PAGE = 0,
|
933
|
CURRENT_PAGE = 0,
|
934
|
RECONVERTER = 0
|
935
|
};
|
936
|
|
937
|
|
938
|
entities.CONVERTER_DOC.Add(convert_doc);
|
939
|
|
940
|
|
941
|
var waiter = entities.SaveChangesAsync().GetAwaiter();
|
942
|
|
943
|
if (waiter.GetResult() == 1)
|
944
|
{
|
945
|
result = true;
|
946
|
}
|
947
|
|
948
|
return result;
|
949
|
}
|
950
|
|
951
|
/// <summary>
|
952
|
/// 컨버터서비스를 이용하는 문서 정보 저장
|
953
|
/// UniqueID
|
954
|
/// using Markus.Service.Extensions; new Guid().CreateUniqueGuid().ToString();
|
955
|
/// </summary>
|
956
|
/// <param name="ProjectNo">프로젝트</param>
|
957
|
/// <param name="UniqueID">컨버터 서비스의 아이템 ID</param>
|
958
|
/// <param name="originfilePath"></param>
|
959
|
/// <param name="DocumentID"></param>
|
960
|
/// <returns></returns>
|
961
|
public bool SetDocumentInfo(string ConvertID, int totalPage, List<DOCPAGE> pageinfo)
|
962
|
{
|
963
|
bool result = false;
|
964
|
|
965
|
var convertDocItems = entities.CONVERTER_DOC.Where(f => f.ID == ConvertID);
|
966
|
|
967
|
if (convertDocItems.Count() > 0)
|
968
|
{
|
969
|
var convertDoc = convertDocItems.First();
|
970
|
|
971
|
string docId = new Guid().CreateUniqueGuid().ToString();
|
972
|
|
973
|
var docinfo = entities.DOCINFO.FirstOrDefault(x => x.PROJECT_NO == convertDoc.PROJECT_NO && x.DOCUMENT_ID == convertDoc.DOCUMENT_ID);
|
974
|
|
975
|
if (docinfo != null)
|
976
|
{
|
977
|
// 기존 Docpage 삭제.
|
978
|
entities.DOCPAGE.RemoveRange(docinfo.DOCPAGE);
|
979
|
|
980
|
// 기존 코멘트 유지를 위한 Docinfo update
|
981
|
docinfo.PROJECT_NO = convertDoc.PROJECT_NO;
|
982
|
docinfo.ORIGINAL_FILE = convertDoc.DOCUMENT_URL;
|
983
|
docinfo.PAGE_COUNT = totalPage;
|
984
|
docinfo.DOCPAGE = pageinfo;
|
985
|
var waiter = entities.SaveChangesAsync().GetAwaiter();
|
986
|
|
987
|
if(waiter.GetResult() > 0)
|
988
|
{
|
989
|
result = true;
|
990
|
}
|
991
|
}
|
992
|
else
|
993
|
{
|
994
|
DOCINFO instace = new DOCINFO
|
995
|
{
|
996
|
ID = docId,
|
997
|
PROJECT_NO = convertDoc.PROJECT_NO,
|
998
|
ORIGINAL_FILE = convertDoc.DOCUMENT_URL,
|
999
|
DOCUMENT_ID = convertDoc.DOCUMENT_ID,
|
1000
|
PAGE_COUNT = totalPage,
|
1001
|
DOCPAGE = pageinfo
|
1002
|
};
|
1003
|
|
1004
|
entities.DOCINFO.Add(instace);
|
1005
|
var waiter = entities.SaveChangesAsync().GetAwaiter();
|
1006
|
|
1007
|
var save = waiter.GetResult();
|
1008
|
|
1009
|
if (save == pageinfo.Count() + 1)
|
1010
|
{
|
1011
|
result = true;
|
1012
|
}
|
1013
|
}
|
1014
|
|
1015
|
|
1016
|
|
1017
|
}
|
1018
|
else
|
1019
|
{
|
1020
|
throw new Exception($"SetDocumentInfo :{ConvertID} CONVERTER_DOC not found ");
|
1021
|
}
|
1022
|
|
1023
|
return result;
|
1024
|
}
|
1025
|
|
1026
|
public Interface.ConvertItem GetConvertItem(string ProjectNo, string UniqueID)
|
1027
|
{
|
1028
|
Interface.ConvertItem result = null;
|
1029
|
|
1030
|
//var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID);
|
1031
|
var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == ProjectNo && f.ID == UniqueID);
|
1032
|
|
1033
|
if (items.Count() > 0)
|
1034
|
{
|
1035
|
var convertItem = items.First();
|
1036
|
|
1037
|
#if XI_C_AND_A
|
1038
|
string convertPath = GetConvertPath(convertItem.PROJECT_NO, convertItem.DOCUMENT_ID);
|
1039
|
#else
|
1040
|
|
1041
|
string convertPath = Path.Combine(BaseStorage(convertItem.PROJECT_NO), convertItem.PROJECT_NO + "_Tile", (System.Convert.ToInt64(convertItem.DOCUMENT_ID) / 100).ToString(), convertItem.DOCUMENT_ID);
|
1042
|
#endif
|
1043
|
result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath);
|
1044
|
}
|
1045
|
|
1046
|
return result;
|
1047
|
}
|
1048
|
|
1049
|
|
1050
|
public Interface.ConvertItem GetConvertItembyDocumentID(string ProjectNo, string DocumentID)
|
1051
|
{
|
1052
|
Interface.ConvertItem result = null;
|
1053
|
|
1054
|
//var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID);
|
1055
|
var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == ProjectNo && f.DOCUMENT_ID == DocumentID);
|
1056
|
|
1057
|
if (items.Count() > 0)
|
1058
|
{
|
1059
|
var convertItem = items.First();
|
1060
|
|
1061
|
#if XI_C_AND_A
|
1062
|
string convertPath = GetConvertPath(convertItem.PROJECT_NO, convertItem.DOCUMENT_ID);
|
1063
|
#else
|
1064
|
string convertPath = Path.Combine(BaseStorage(convertItem.PROJECT_NO), convertItem.PROJECT_NO + "_Tile", (System.Convert.ToInt64(convertItem.DOCUMENT_ID) / 100).ToString(), convertItem.DOCUMENT_ID);
|
1065
|
#endif
|
1066
|
if (convertItem.STATUS == (int)StatusCodeType.Completed)
|
1067
|
{
|
1068
|
result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath,
|
1069
|
(StatusCodeType)convertItem.STATUS, convertItem.CURRENT_PAGE, convertItem.TOTAL_PAGE, convertItem.EXCEPTION);
|
1070
|
}
|
1071
|
else
|
1072
|
{
|
1073
|
result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath);
|
1074
|
}
|
1075
|
}
|
1076
|
|
1077
|
return result;
|
1078
|
}
|
1079
|
|
1080
|
public List<CONVERTER_DOC> GetConvertingItems(List<string> projectList)
|
1081
|
{
|
1082
|
var convertWaitingItems = entities.CONVERTER_DOC.OrderBy(x => x.CREATE_DATETIME).Where(
|
1083
|
x =>
|
1084
|
projectList.Contains(x.PROJECT_NO) &&
|
1085
|
(x.STATUS > (int)StatusCodeType.None && x.STATUS < (int)StatusCodeType.Completed) && x.RECONVERTER < 2);
|
1086
|
|
1087
|
return convertWaitingItems.ToList();
|
1088
|
}
|
1089
|
|
1090
|
/// <summary>
|
1091
|
/// 전체 컨버터를 가져온다. 비동기로 변경하여야 한다.
|
1092
|
/// </summary>
|
1093
|
/// <returns></returns>
|
1094
|
public List<Interface.ConvertItem> GetConvertItems(StatusCodeType statusCodeType)
|
1095
|
{
|
1096
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
1097
|
|
1098
|
var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
|
1099
|
|
1100
|
if (items.Count() > 0)
|
1101
|
{
|
1102
|
foreach (var item in items)
|
1103
|
{
|
1104
|
var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
1105
|
{
|
1106
|
ReConverter = item.RECONVERTER,
|
1107
|
ServiceID = item.SERVICE_ID,
|
1108
|
ConvertState = ((StatusCodeType)item.STATUS),
|
1109
|
CreateTime = item.CREATE_DATETIME,
|
1110
|
TotalPage = item.TOTAL_PAGE,
|
1111
|
CurrentPageNo = item.CURRENT_PAGE,
|
1112
|
|
1113
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
|
1114
|
};
|
1115
|
|
1116
|
|
1117
|
convertItems.Add(convertitem);
|
1118
|
}
|
1119
|
}
|
1120
|
return convertItems;
|
1121
|
}
|
1122
|
|
1123
|
public List<Interface.ConvertItem> GetConvertProjectsStatus(Func<CONVERTER_DOC, bool> @where)
|
1124
|
{
|
1125
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
1126
|
|
1127
|
|
1128
|
//var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).Take(takeCount).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
|
1129
|
var items = entities.CONVERTER_DOC.Where(x => x.STATUS <= 4);
|
1130
|
|
1131
|
if (items.Count() > 0)
|
1132
|
{
|
1133
|
foreach (var item in items)
|
1134
|
{
|
1135
|
var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
|
1136
|
{
|
1137
|
ReConverter = item.RECONVERTER,
|
1138
|
ServiceID = item.SERVICE_ID,
|
1139
|
//ConvertState = ((StatusCodeType)item.STATUS).ToString(),
|
1140
|
//ConvertState = (item.STATUS).ToString(),
|
1141
|
ConvertState = (StatusCodeType)item.STATUS,
|
1142
|
CreateTime = item.CREATE_DATETIME,
|
1143
|
TotalPage = item.TOTAL_PAGE,
|
1144
|
CurrentPageNo = item.CURRENT_PAGE,
|
1145
|
Exception = item.EXCEPTION,
|
1146
|
ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
|
1147
|
};
|
1148
|
|
1149
|
|
1150
|
convertItems.Add(convertitem);
|
1151
|
}
|
1152
|
}
|
1153
|
|
1154
|
return convertItems;
|
1155
|
}
|
1156
|
|
1157
|
|
1158
|
public bool SetConvertState(string ServiceID, string UniqueID, int State, int CurrentPage, int TotalPage, string Error)
|
1159
|
{
|
1160
|
bool result = false;
|
1161
|
|
1162
|
try
|
1163
|
{
|
1164
|
var items = entities.CONVERTER_DOC.SingleOrDefault(f => f.ID == UniqueID);
|
1165
|
//var items = entities.CONVERTER_DOC.SingleOrDefault(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID);
|
1166
|
|
1167
|
if (items != null)
|
1168
|
{
|
1169
|
items.SERVICE_ID = ServiceID;
|
1170
|
items.STATUS = State;
|
1171
|
items.CURRENT_PAGE = CurrentPage;
|
1172
|
items.TOTAL_PAGE = TotalPage;
|
1173
|
|
1174
|
StatusCodeType statusCode = (StatusCodeType)State;
|
1175
|
|
1176
|
if (items.START_DATETIME == null)
|
1177
|
{
|
1178
|
items.START_DATETIME = DateTime.Now;
|
1179
|
}
|
1180
|
|
1181
|
switch (statusCode)
|
1182
|
{
|
1183
|
case StatusCodeType.None:
|
1184
|
break;
|
1185
|
case StatusCodeType.Wait:
|
1186
|
items.START_DATETIME = DateTime.Now;
|
1187
|
break;
|
1188
|
case StatusCodeType.PageLoading:
|
1189
|
break;
|
1190
|
case StatusCodeType.Saving:
|
1191
|
break;
|
1192
|
case StatusCodeType.Completed:
|
1193
|
items.CURRENT_PAGE = items.TOTAL_PAGE;
|
1194
|
items.END_DATETIME = DateTime.Now;
|
1195
|
break;
|
1196
|
case StatusCodeType.FileError:
|
1197
|
Error = $" file Error :" + Error;
|
1198
|
items.END_DATETIME = DateTime.Now;
|
1199
|
break;
|
1200
|
case StatusCodeType.PageError:
|
1201
|
Error = $" Page No {CurrentPage} Error :" + Error;
|
1202
|
break;
|
1203
|
case StatusCodeType.NeedsPassword:
|
1204
|
break;
|
1205
|
case StatusCodeType.Error:
|
1206
|
Error = $" Error :" + Error;
|
1207
|
items.END_DATETIME = DateTime.Now;
|
1208
|
break;
|
1209
|
default:
|
1210
|
break;
|
1211
|
}
|
1212
|
|
1213
|
if (items.EXCEPTION == null)
|
1214
|
{
|
1215
|
items.EXCEPTION = "";
|
1216
|
}
|
1217
|
|
1218
|
if (items.EXCEPTION.Length < 255)
|
1219
|
{
|
1220
|
if (items.EXCEPTION.Length > 0 && Error?.Length > 0)
|
1221
|
{
|
1222
|
items.EXCEPTION = items.EXCEPTION + ";" + Environment.NewLine;
|
1223
|
}
|
1224
|
|
1225
|
items.EXCEPTION = items.EXCEPTION + Error;
|
1226
|
}
|
1227
|
|
1228
|
var waiter = entities.SaveChangesAsync().GetAwaiter();
|
1229
|
var save = waiter.GetResult();
|
1230
|
result = true;
|
1231
|
}
|
1232
|
}
|
1233
|
catch (Exception ex)
|
1234
|
{
|
1235
|
throw new Exception("SetConvertState", ex);
|
1236
|
}
|
1237
|
|
1238
|
return result;
|
1239
|
}
|
1240
|
|
1241
|
public SERVICE_PROPERTIES GetServiceProperties(string ServiceID)
|
1242
|
{
|
1243
|
SERVICE_PROPERTIES result = null;
|
1244
|
|
1245
|
var items = entities.SERVICE_PROPERTIES.Where(x => x.ID == ServiceID);
|
1246
|
|
1247
|
if (items.Count() > 0)
|
1248
|
{
|
1249
|
result = items.First();
|
1250
|
}
|
1251
|
|
1252
|
return result;
|
1253
|
}
|
1254
|
|
1255
|
|
1256
|
/// <summary>
|
1257
|
/// 현재 서비스에서 컨버터중인 아이템.
|
1258
|
/// </summary>
|
1259
|
/// <returns></returns>
|
1260
|
public List<Interface.ConvertItem> GetServiceAliveItems(string ServiceID)
|
1261
|
{
|
1262
|
List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
|
1263
|
|
1264
|
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);
|
1265
|
|
1266
|
if (items.Count() > 0)
|
1267
|
{
|
1268
|
foreach (var item in items)
|
1269
|
{
|
1270
|
var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL);
|
1271
|
convertItems.Add(convertitem);
|
1272
|
}
|
1273
|
}
|
1274
|
return convertItems;
|
1275
|
}
|
1276
|
|
1277
|
#endregion
|
1278
|
|
1279
|
}
|
1280
|
}
|