개정판 6c9fec59
issue #1022: doc info & markup data select service add
Change-Id: I77fd616bd76835bf2ce490bf3a35a8ccb4824935
FinalService/KCOM_FinalService/MarkupToPDF/MarkupToPDF.cs | ||
---|---|---|
2 | 2 |
using iTextSharp.text.pdf; |
3 | 3 |
using KCOMDataModel.Common; |
4 | 4 |
using KCOMDataModel.DataModel; |
5 |
using MarkupToPDF.Common; |
|
5 | 6 |
using MarkupToPDF.Controls.Common; |
6 | 7 |
using MarkupToPDF.Serialize.Core; |
7 | 8 |
using MarkupToPDF.Serialize.S_Control; |
... | ... | |
29 | 30 |
private string _FinalPDFStorgeRemote = null; |
30 | 31 |
private string OriginFileName = null; |
31 | 32 |
public FINAL_PDF FinalItem; |
32 |
public DOCINFO DocInfoItem = null; |
|
33 |
public List<DOCPAGE> DocPageItem = null; |
|
34 |
public MARKUP_INFO MarkupInfoItem = null; |
|
35 |
public List<MARKUP_DATA> MarkupDataSet = null; |
|
33 |
public CommonLib.MARKUS_API.DOCINFO DocInfoItem = null;
|
|
34 |
public List<CommonLib.MARKUS_API.DOCPAGE> DocPageItem = null;
|
|
35 |
public CommonLib.MARKUS_API.MARKUP_INFO MarkupInfoItem = null;
|
|
36 |
public List<CommonLib.MARKUS_API.MARKUP_DATA> MarkupDataSet = null;
|
|
36 | 37 |
//private string _PrintPDFStorgeLocal = null; |
37 | 38 |
//private string _PrintPDFStorgeRemote = null; |
38 | 39 |
public event EventHandler<MakeFinalErrorArgs> FinalMakeError; |
... | ... | |
138 | 139 |
public void MakeFinalPDF(object _FinalPDF) |
139 | 140 |
{ |
140 | 141 |
|
141 |
DOCUMENT_ITEM documentItem; |
|
142 |
CommonLib.MARKUS_API.DOCUMENT_ITEM documentItem;
|
|
142 | 143 |
FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF; |
143 | 144 |
FinalItem = FinalPDF; |
144 | 145 |
|
... | ... | |
185 | 186 |
#region 문서 복사 |
186 | 187 |
try |
187 | 188 |
{ |
188 |
using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
|
|
189 |
using (DataController dc = new DataController())
|
|
189 | 190 |
{ |
190 |
var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID); |
|
191 |
//var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID); |
|
192 |
string project_no = FinalPDF.PROJECT_NO; |
|
193 |
string docinfo_id = FinalPDF.DOCINFO_ID; |
|
191 | 194 |
|
192 |
if (_DOCINFO.Count() > 0) |
|
195 |
var _DOCINFO = dc.GetDocInfo(project_no, docinfo_id); |
|
196 |
if (_DOCINFO != null) |
|
193 | 197 |
{ |
194 |
DocInfoItem = _DOCINFO.FirstOrDefault();
|
|
195 |
DocPageItem = DocInfoItem.DOCPAGE.ToList();
|
|
198 |
DocInfoItem = _DOCINFO; |
|
199 |
DocPageItem = dc.GetDocpage(project_no, docinfo_id);
|
|
196 | 200 |
|
197 | 201 |
PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\" |
198 | 202 |
+ (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() |
199 | 203 |
+ @"\" + FinalPDF.DOCUMENT_ID + @"\"; |
200 | 204 |
|
201 |
MarkupInfoItem = DocInfoItem.MARKUP_INFO.Where(data => data.CONSOLIDATE == 1 && data.AVOID_CONSOLIDATE == 0 && data.PART_CONSOLIDATE == 0).FirstOrDefault();
|
|
205 |
MarkupInfoItem = dc.GetMarkupInfo(project_no, docinfo_id);
|
|
202 | 206 |
|
203 | 207 |
if (MarkupInfoItem == null) |
204 | 208 |
{ |
... | ... | |
206 | 210 |
} |
207 | 211 |
else |
208 | 212 |
{ |
209 |
if (MarkupInfoItem.MARKUP_INFO_VERSION.Count > 0) |
|
213 |
if (MarkupInfoItem.MARKUP_INFO_VERSION.Count() > 0)
|
|
210 | 214 |
{ |
211 |
MarkupDataSet = MarkupInfoItem.MARKUP_INFO_VERSION.OrderBy(d => d.CREATE_DATE).LastOrDefault().MARKUP_DATA.ToList().OrderBy(d=>d.PAGENUMBER).ToList();
|
|
215 |
MarkupDataSet = dc.GetMarkupData(project_no, docinfo_id);
|
|
212 | 216 |
} |
213 | 217 |
else |
214 | 218 |
{ |
215 | 219 |
throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다"); |
216 | 220 |
} |
217 | 221 |
} |
218 |
|
|
219 |
using (CIEntities _ci_Internal = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
|
|
222 |
documentItem = dc.GetDocumentItem(project_no, DocInfoItem.DOCUMENT_ID); |
|
223 |
if (documentItem == null)
|
|
220 | 224 |
{ |
221 |
documentItem = _ci_Internal.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID).FirstOrDefault(); |
|
222 |
if (documentItem == null) |
|
223 |
{ |
|
224 |
throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요"); |
|
225 |
} |
|
226 |
|
|
227 |
var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 |
|
225 |
throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요"); |
|
226 |
} |
|
227 |
var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 |
|
228 | 228 |
|
229 |
#region 파일 체크 |
|
230 |
if (_files.Count() == 1) |
|
231 |
{ |
|
232 |
if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower())) |
|
233 |
{ |
|
234 |
OriginFileName = _files.First().Name; |
|
235 |
PdfFilePath = _files.First().CopyTo(TestFile, true); |
|
236 |
} |
|
237 |
else |
|
238 |
{ |
|
239 |
throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()); |
|
240 |
} |
|
241 |
} |
|
242 |
else if (_files.Count() > 1) |
|
229 |
#region 파일 체크 |
|
230 |
if (_files.Count() == 1) |
|
231 |
{ |
|
232 |
if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower())) |
|
243 | 233 |
{ |
244 |
var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault(); |
|
245 |
|
|
246 |
if (originalFile == null) |
|
247 |
{ |
|
248 |
throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다"); |
|
249 |
} |
|
250 |
else |
|
251 |
{ |
|
252 |
OriginFileName = originalFile.Name; |
|
253 |
PdfFilePath = originalFile.CopyTo(TestFile, true); |
|
254 |
} |
|
234 |
OriginFileName = _files.First().Name; |
|
235 |
PdfFilePath = _files.First().CopyTo(TestFile, true); |
|
255 | 236 |
} |
256 | 237 |
else |
257 | 238 |
{ |
258 |
throw new Exception("PDF를 찾지 못하였습니다");
|
|
239 |
throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower());
|
|
259 | 240 |
} |
260 |
#endregion |
|
241 |
} |
|
242 |
else if (_files.Count() > 1) |
|
243 |
{ |
|
244 |
var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault(); |
|
261 | 245 |
|
262 |
#region 예외처리 |
|
263 |
if (PdfFilePath == null) |
|
246 |
if (originalFile == null) |
|
264 | 247 |
{ |
265 |
throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다");
|
|
248 |
throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다");
|
|
266 | 249 |
} |
267 |
if (!PdfFilePath.Exists)
|
|
250 |
else
|
|
268 | 251 |
{ |
269 |
throw new Exception("PDF원본이 존재하지 않습니다"); |
|
252 |
OriginFileName = originalFile.Name; |
|
253 |
PdfFilePath = originalFile.CopyTo(TestFile, true); |
|
270 | 254 |
} |
271 |
#endregion |
|
272 | 255 |
} |
256 |
else |
|
257 |
{ |
|
258 |
throw new Exception("PDF를 찾지 못하였습니다"); |
|
259 |
} |
|
260 |
#endregion |
|
261 |
|
|
262 |
#region 예외처리 |
|
263 |
if (PdfFilePath == null) |
|
264 |
{ |
|
265 |
throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다"); |
|
266 |
} |
|
267 |
if (!PdfFilePath.Exists) |
|
268 |
{ |
|
269 |
throw new Exception("PDF원본이 존재하지 않습니다"); |
|
270 |
} |
|
271 |
#endregion |
|
273 | 272 |
} |
274 | 273 |
else |
275 | 274 |
{ |
276 | 275 |
throw new Exception("일치하는 DocInfo가 없습니다"); |
277 | 276 |
} |
278 | 277 |
} |
278 |
|
|
279 |
|
|
279 | 280 |
} |
280 | 281 |
catch (Exception ex) |
281 | 282 |
{ |
... | ... | |
408 | 409 |
File.WriteAllBytes(dest, array); |
409 | 410 |
} |
410 | 411 |
|
411 |
public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo) |
|
412 |
public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, CommonLib.MARKUS_API.MARKUP_INFO markupInfo)
|
|
412 | 413 |
{ |
413 | 414 |
string pdfFilePath = null; |
414 |
List<MEMBER> memberlist = null; |
|
415 |
|
|
415 | 416 |
FileInfo tempFileInfo = new FileInfo(testFile); |
416 | 417 |
|
417 | 418 |
if (!Directory.Exists(_FinalPDFStorgeLocal)) |
... | ... | |
419 | 420 |
Directory.CreateDirectory(_FinalPDFStorgeLocal); |
420 | 421 |
} |
421 | 422 |
pdfFilePath = _FinalPDFStorgeLocal + @"\" + tempFileInfo.Name; |
422 |
using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString())) |
|
423 |
{ |
|
424 |
memberlist = cIEntities.MEMBER.ToList(); |
|
425 |
} |
|
423 |
|
|
426 | 424 |
using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
427 | 425 |
{ |
428 | 426 |
FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault(); |
... | ... | |
440 | 438 |
var dic = new Dictionary<string, object>(); |
441 | 439 |
foreach (var data in MarkupDataSet) |
442 | 440 |
{ |
443 |
|
|
441 |
|
|
444 | 442 |
string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID; |
445 |
|
|
446 |
var member = memberlist.Where(u => u.ID == userid).FirstOrDefault(); |
|
447 |
string username = member.NAME; |
|
448 |
string userdept = member.DEPARTMENT; |
|
443 |
string username = string.Empty; |
|
444 |
string userdept = string.Empty; |
|
445 |
using (DataController dataController = new DataController()) |
|
446 |
{ |
|
447 |
var member = dataController.GetMemberInfo(markupInfo.DOCINFO.PROJECT_NO, userid); |
|
448 |
username = member.NAME; |
|
449 |
userdept = member.DEPARTMENT; |
|
450 |
} |
|
451 |
|
|
449 | 452 |
bookmark = new Dictionary<string, object>(); |
450 | 453 |
bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER)); |
451 | 454 |
bookmark.Add("Page", data.PAGENUMBER + " Fit"); |
내보내기 Unified diff