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