개정판 bd8c56f0
Fix: FinalService 코드 정리
Change-Id: Ie9fe19bf8de73c03ff348f201bc62f362f6a4031
FinalService/KCOM_FinalService_DL/FinalProcess/Program.cs | ||
---|---|---|
110 | 110 |
using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
111 | 111 |
{ |
112 | 112 |
var items = _entity.FINAL_PDF.Where(x => x.ID == sFinalID && x.PROJECT_NO == sProjectNo); |
113 |
if(items.Count() > 0)
|
|
113 |
if(items.Any())
|
|
114 | 114 |
{ |
115 | 115 |
finalPdf = items.First(); |
116 | 116 |
} |
... | ... | |
132 | 132 |
} |
133 | 133 |
finally |
134 | 134 |
{ |
135 |
//TODO: 메모리 해제? |
|
135 | 136 |
GC.Collect(); |
136 | 137 |
GC.WaitForPendingFinalizers(); |
137 | 138 |
GC.Collect(); |
... | ... | |
140 | 141 |
} |
141 | 142 |
} |
142 | 143 |
|
144 |
/// <summary> |
|
145 |
/// 오류 및 완료 시간을 저장한다. |
|
146 |
/// </summary> |
|
147 |
/// <param name="sender"></param> |
|
148 |
/// <param name="e"></param> |
|
143 | 149 |
private static void _markuptoPDF_EndFinal(object sender, EndFinalEventArgs e) |
144 | 150 |
{ |
145 |
//using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
|
146 |
//{ |
|
147 |
// var items = _entity.FINAL_PDF.Where(x => x.ID == e.FinalPDF.ID); |
|
148 |
// if (items.Count() > 0) |
|
149 |
// { |
|
150 |
// if (string.IsNullOrEmpty(e.Error)) |
|
151 |
// { |
|
152 |
// items.First().STATUS = 4; |
|
153 |
// items.First().END_DATETIME = DateTime.Now; |
|
154 |
// } |
|
155 |
// } |
|
156 |
// _entity.SaveChanges(); |
|
157 |
//} |
|
158 |
|
|
159 | 151 |
logger.Log(CommonLib.ELogLv.info, $"Connection String : {KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()}"); |
160 |
|
|
161 | 152 |
using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
162 | 153 |
{ |
163 | 154 |
var finalList = _entity.FINAL_PDF.Where(final => final.ID == e.FinalPDF.ID && final.PROJECT_NO == e.FinalPDF.PROJECT_NO); |
164 |
|
|
165 |
if (finalList.Count() > 0) |
|
155 |
if (finalList.Any()) |
|
166 | 156 |
{ |
167 | 157 |
if (e.FinalPDF.STATUS == (int)FinalStatus.Create) |
168 | 158 |
{ |
FinalService/KCOM_FinalService_DL/MarkupToPDF/MarkupToPDF.cs | ||
---|---|---|
34 | 34 |
private FileInfo PdfFilePath = null; |
35 | 35 |
private FileInfo FinalPDFPath = null; |
36 | 36 |
private string _FinalPDFStorgeLocal = null; |
37 |
private string _FinalPDFStorgeRemote = null;
|
|
37 |
private string _FinalPDFStorgeRemote { get; set; }
|
|
38 | 38 |
private string OriginFileName = null; |
39 | 39 |
public FINAL_PDF FinalItem; |
40 | 40 |
public DOCINFO DocInfoItem = null; |
... | ... | |
53 | 53 |
|
54 | 54 |
//private const double zoomLevel = 3.0; |
55 | 55 |
private const double zoomLevel = 1.0; // 지금은 3배수로 곱하지 않고 있음 |
56 |
|
|
57 |
private System.Drawing.Color _SetColor { get; set; } = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red); |
|
56 | 58 |
#endregion |
57 | 59 |
|
58 | 60 |
#region 메서드 |
... | ... | |
187 | 189 |
|
188 | 190 |
} |
189 | 191 |
|
192 |
#region 생성자 & 소멸자 |
|
190 | 193 |
/// <summary> |
191 |
/// local에서 final 생성하는 경우 이 함수로 추가 후 실행
|
|
194 |
/// 주어진 _FinalPDF 데이터로 Final PDF를 생성한다.
|
|
192 | 195 |
/// </summary> |
193 |
/// <param name="finalpdf"></param> |
|
194 |
/// <returns></returns> |
|
195 |
public AddFinalPDFResult AddFinalPDF(string ProjectNo,string DocumentID,string UserID) |
|
196 |
{ |
|
197 |
//var list = Markus.Fonts.FontHelper.GetFontStream("Arial Unicode MS"); |
|
198 |
//System.Diagnostics.Debug.WriteLine(list); |
|
199 |
|
|
200 |
AddFinalPDFResult result = new AddFinalPDFResult { Success = false }; |
|
201 |
|
|
202 |
try |
|
203 |
{ |
|
204 |
FINAL_PDF addItem = new FINAL_PDF{ |
|
205 |
ID = CommonLib.Guid.shortGuid(), |
|
206 |
PROJECT_NO = ProjectNo, |
|
207 |
DOCUMENT_ID = DocumentID, |
|
208 |
CREATE_USER_ID = UserID, |
|
209 |
CREATE_DATETIME = DateTime.Now, |
|
210 |
STATUS = 4 |
|
211 |
}; |
|
212 |
|
|
213 |
using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
|
214 |
{ |
|
215 |
var docitems = _entity.DOCINFO.Where(x => x.PROJECT_NO == ProjectNo && x.DOCUMENT_ID == DocumentID); |
|
216 |
|
|
217 |
if(docitems.Count() > 0) |
|
218 |
{ |
|
219 |
addItem.DOCINFO_ID = docitems.First().ID; |
|
220 |
result.Success = true; |
|
221 |
} |
|
222 |
else |
|
223 |
{ |
|
224 |
result.Exception = "docInfo Not Found."; |
|
225 |
result.Success = false; |
|
226 |
} |
|
227 |
|
|
228 |
var markupInfoItems = _entity.MARKUP_INFO.Where(x =>x.DOCINFO_ID == addItem.DOCINFO_ID); |
|
229 |
|
|
230 |
if (markupInfoItems.Count() > 0) |
|
231 |
{ |
|
232 |
addItem.MARKUPINFO_ID = markupInfoItems.First().ID; |
|
233 |
result.Success = true; |
|
234 |
} |
|
235 |
else |
|
236 |
{ |
|
237 |
result.Exception = "Markup Info Not Found."; |
|
238 |
result.Success = false; |
|
239 |
} |
|
240 |
} |
|
241 |
|
|
242 |
if (result.Success) |
|
243 |
{ |
|
244 |
using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
|
245 |
{ |
|
246 |
var finalList = _entity.FINAL_PDF.Where(final => final.ID == addItem.ID); |
|
247 |
|
|
248 |
/// Insrt and Update |
|
249 |
if (finalList.Count() == 0) |
|
250 |
{ |
|
251 |
_entity.FINAL_PDF.AddObject(addItem); |
|
252 |
_entity.SaveChanges(); |
|
253 |
|
|
254 |
result.FinalPDF = addItem; |
|
255 |
result.Success = true; |
|
256 |
} |
|
257 |
} |
|
258 |
} |
|
259 |
} |
|
260 |
catch (Exception ex) |
|
261 |
{ |
|
262 |
System.Diagnostics.Debug.WriteLine(ex); |
|
263 |
result.Success = false; |
|
264 |
} |
|
265 |
|
|
266 |
return result; |
|
267 |
} |
|
268 |
|
|
269 |
#region 생성자 & 소멸자 |
|
196 |
/// <param name="_FinalPDF"></param> |
|
270 | 197 |
public void MakeFinalPDF(object _FinalPDF) |
271 | 198 |
{ |
272 | 199 |
DOCUMENT_ITEM documentItem; |
... | ... | |
274 | 201 |
FinalItem = FinalPDF; |
275 | 202 |
|
276 | 203 |
string PdfFilePathRoot = null; |
277 |
string TestFile = System.IO.Path.GetTempFileName();
|
|
204 |
string TempFile = System.IO.Path.Combine(System.IO.Path.GetTempPath() , System.IO.Path.GetRandomFileName());
|
|
278 | 205 |
|
279 | 206 |
#region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정 |
280 | 207 |
try |
... | ... | |
282 | 209 |
using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
283 | 210 |
{ |
284 | 211 |
var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO); |
285 |
|
|
286 |
if (_properties.Count() > 0) |
|
212 |
if (_properties.Any()) |
|
287 | 213 |
{ |
288 | 214 |
if (_properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).Count() == 0) |
289 | 215 |
{ |
... | ... | |
326 | 252 |
return; |
327 | 253 |
} |
328 | 254 |
|
255 |
#region FinalPDF의 STATUS를 Create로 실행 시간을 저장 |
|
329 | 256 |
var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID); |
330 |
|
|
331 |
if (finalList.Count() > 0) |
|
257 |
if (finalList.Any()) |
|
332 | 258 |
{ |
333 |
finalList.FirstOrDefault().START_DATETIME = DateTime.Now;
|
|
334 |
finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create;
|
|
259 |
finalList.First().START_DATETIME = DateTime.Now; |
|
260 |
finalList.First().STATUS = (int)FinalStatus.Create; |
|
335 | 261 |
_entity.SaveChanges(); |
336 | 262 |
} |
337 |
|
|
263 |
#endregion |
|
338 | 264 |
} |
339 | 265 |
} |
340 | 266 |
catch (Exception ex) |
... | ... | |
345 | 271 |
} |
346 | 272 |
#endregion |
347 | 273 |
|
348 |
#region 문서 복사
|
|
274 |
#region 원본 PDF를 TempFile로 복사
|
|
349 | 275 |
try |
350 | 276 |
{ |
351 | 277 |
using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString())) |
352 | 278 |
{ |
353 | 279 |
var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID); |
354 |
|
|
355 |
if (_DOCINFO.Count() > 0) |
|
280 |
if (_DOCINFO.Any()) |
|
356 | 281 |
{ |
357 | 282 |
DocInfoItem = _DOCINFO.First(); |
358 | 283 |
|
... | ... | |
363 | 288 |
+ @"\" + FinalPDF.DOCUMENT_ID + @"\"; |
364 | 289 |
|
365 | 290 |
var infoItems = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == DocInfoItem.ID && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0); |
366 |
|
|
367 | 291 |
if (infoItems.Count() == 0) |
368 | 292 |
{ |
369 | 293 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다"); |
... | ... | |
374 | 298 |
MarkupInfoItem = infoItems.First(); |
375 | 299 |
|
376 | 300 |
var markupInfoVerItems = _entity.MARKUP_INFO_VERSION.Where(x => x.MARKUPINFO_ID == MarkupInfoItem.ID).ToList(); |
377 |
|
|
378 |
if (markupInfoVerItems.Count() > 0) |
|
301 |
if (markupInfoVerItems.Any()) |
|
379 | 302 |
{ |
380 | 303 |
var markupInfoVerItem = markupInfoVerItems.OrderByDescending(x => x.CREATE_DATE).First(); |
381 | 304 |
|
... | ... | |
401 | 324 |
if (_files.Count() == 1) |
402 | 325 |
{ |
403 | 326 |
/// 문서 관리 시스템의 원본 PDF 파일과 비교 --> 삭제될 예정 |
404 |
//if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower())) |
|
405 |
//{ |
|
327 |
#region 원본 PDF 파일을 Temporary 파일로 복사 |
|
406 | 328 |
OriginFileName = _files.First().Name; |
407 |
PdfFilePath = _files.First().CopyTo(TestFile, true);
|
|
329 |
PdfFilePath = _files.First().CopyTo(TempFile, true);
|
|
408 | 330 |
StatusChange($"Copy File file Count = 1 : {PdfFilePath}", 0); |
409 |
//} |
|
410 |
//else |
|
411 |
//{ |
|
412 |
// throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()); |
|
413 |
//} |
|
331 |
#endregion |
|
414 | 332 |
} |
415 | 333 |
else if (_files.Count() > 1) |
416 | 334 |
{ |
417 |
var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault(); |
|
418 |
|
|
335 |
var originalFile = _files.FirstOrDefault(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))); |
|
419 | 336 |
if (originalFile == null) |
420 | 337 |
{ |
421 | 338 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다"); |
... | ... | |
424 | 341 |
else |
425 | 342 |
{ |
426 | 343 |
OriginFileName = originalFile.Name; |
427 |
PdfFilePath = originalFile.CopyTo(TestFile, true);
|
|
344 |
PdfFilePath = originalFile.CopyTo(TempFile, true);
|
|
428 | 345 |
StatusChange($"Copy File file Count > 1 : {PdfFilePath}", 0); |
429 | 346 |
} |
430 | 347 |
} |
... | ... | |
462 | 379 |
{ |
463 | 380 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다"); |
464 | 381 |
SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다"); |
465 |
//System.Diagnostics.Process process = new System.Diagnostics.Process(); |
|
466 |
//process.StartInfo.FileName = "cmd"; |
|
467 |
//process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\""; |
|
468 |
//process.Start(); |
|
469 | 382 |
} |
470 | 383 |
else |
471 | 384 |
{ |
... | ... | |
475 | 388 |
} |
476 | 389 |
#endregion |
477 | 390 |
|
391 |
#region FinalPDF 생성 후 EndFinal 이벤트 호출 |
|
478 | 392 |
try |
479 | 393 |
{ |
480 |
|
|
481 | 394 |
using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
482 | 395 |
{ |
483 | 396 |
var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID); |
484 |
|
|
485 |
if (finalList.Count() > 0) |
|
397 |
if (finalList.Any()) |
|
486 | 398 |
{ |
487 |
//TestFile = SetFlattingPDF(TestFile); |
|
488 |
//StatusChange($"SetFlattingPDF : {TestFile}", 0); |
|
399 |
string colorTypeName = "FinalColor"; |
|
400 |
#region 색상 적용(기본값은 Red) |
|
401 |
_SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red); |
|
402 |
|
|
403 |
var colorProper = _entity.PROPERTIES.Where(x => x.TYPE == colorTypeName && x.PROPERTY == FinalPDF.PROJECT_NO); |
|
404 |
if (colorProper.Count() > 0) |
|
405 |
{ |
|
406 |
int param = int.Parse(colorProper.First().VALUE, System.Globalization.NumberStyles.AllowHexSpecifier); |
|
407 |
_SetColor = System.Drawing.Color.FromArgb(param); |
|
408 |
} |
|
409 |
else |
|
410 |
{ |
|
411 |
#region Color 속성이 없을 경우 Color 속성을 추가 |
|
412 |
_entity.PROPERTIES.AddObject(new PROPERTIES |
|
413 |
{ |
|
414 |
TYPE = colorTypeName, |
|
415 |
PROPERTY = FinalPDF.PROJECT_NO, |
|
416 |
VALUE = "FFFF0000" |
|
417 |
}); |
|
489 | 418 |
|
490 |
SetStampInPDF(FinalItem, TestFile, MarkupInfoItem); |
|
419 |
_entity.SaveChanges(); |
|
420 |
#endregion |
|
421 |
} |
|
422 |
#endregion |
|
491 | 423 |
|
492 |
StatusChange($"SetStampInPDF : {TestFile}", 0); |
|
424 |
SetStampInPDF(FinalItem, TempFile, MarkupInfoItem); |
|
425 |
StatusChange($"SetStampInPDF : {TempFile}", 0); |
|
493 | 426 |
} |
494 | 427 |
} |
428 |
|
|
495 | 429 |
if (EndFinal != null) |
496 | 430 |
{ |
497 | 431 |
FinalItem.STATUS = (int)FinalStatus.Success; |
498 | 432 |
EndFinal(this, new EndFinalEventArgs |
499 | 433 |
{ |
500 |
FinalPDFRemotePath = _FinalPDFStorgeRemote + @"\" + FinalPDFPath.Name,
|
|
434 |
FinalPDFRemotePath = Path.Combine(_FinalPDFStorgeRemote, FinalPDFPath.Name),
|
|
501 | 435 |
OriginPDFName = OriginFileName, |
502 | 436 |
FinalPDFPath = FinalPDFPath.FullName, |
503 | 437 |
Error = "", |
... | ... | |
511 | 445 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "MarkFinalPDF Error : " + ex.Message); |
512 | 446 |
SetNotice(FinalPDF.ID, "MarkFinalPDF Error : " + ex.Message); |
513 | 447 |
} |
448 |
#endregion |
|
514 | 449 |
} |
515 | 450 |
#endregion |
516 | 451 |
|
... | ... | |
601 | 536 |
} |
602 | 537 |
} |
603 | 538 |
|
604 |
public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo) |
|
539 |
/// <summary> |
|
540 |
/// 원본 PDF에 Markup을 생성한다. |
|
541 |
/// </summary> |
|
542 |
/// <param name="finaldata"></param> |
|
543 |
/// <param name="TempFile"></param> |
|
544 |
/// <param name="markupInfo"></param> |
|
545 |
/// <returns></returns> |
|
546 |
public bool SetStampInPDF(FINAL_PDF finaldata, string TempFile, MARKUP_INFO markupInfo) |
|
605 | 547 |
{ |
606 | 548 |
try |
607 | 549 |
{ |
608 |
|
|
609 |
FileInfo tempFileInfo = new FileInfo(testFile); |
|
610 |
|
|
550 |
FileInfo tempFileInfo = new FileInfo(TempFile); |
|
611 | 551 |
if (!Directory.Exists(_FinalPDFStorgeLocal)) |
612 | 552 |
{ |
613 | 553 |
Directory.CreateDirectory(_FinalPDFStorgeLocal); |
614 | 554 |
} |
615 | 555 |
|
616 |
string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name);
|
|
556 |
string WorkingFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name);
|
|
617 | 557 |
|
618 | 558 |
string colorTypeName = "FinalColor"; |
619 |
|
|
620 | 559 |
using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
621 | 560 |
{ |
622 | 561 |
FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault(); |
623 | 562 |
|
624 |
#region 색상 적용(기본값은 Red) |
|
625 |
System.Drawing.Color _SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red); |
|
626 |
|
|
627 |
var colorProper = _entity.PROPERTIES.Where(x => x.TYPE == colorTypeName && x.PROPERTY == pdfLink.PROJECT_NO); |
|
628 |
if (colorProper.Count() > 0) |
|
629 |
{ |
|
630 |
int param = int.Parse(colorProper.First().VALUE, System.Globalization.NumberStyles.AllowHexSpecifier); |
|
631 |
_SetColor = System.Drawing.Color.FromArgb(param); |
|
632 |
} |
|
633 |
else |
|
634 |
{ |
|
635 |
_entity.PROPERTIES.AddObject(new PROPERTIES |
|
636 |
{ |
|
637 |
TYPE = colorTypeName, |
|
638 |
PROPERTY = pdfLink.PROJECT_NO, |
|
639 |
VALUE = "FFFF0000" |
|
640 |
}); |
|
641 |
|
|
642 |
_entity.SaveChanges(); |
|
643 |
} |
|
644 |
#endregion |
|
645 |
|
|
646 |
#region 코멘트 적용 + 커버시트 |
|
647 |
using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) // |
|
563 |
#region 원본 PDF 파일에 코멘트 적용 + 커버시트 |
|
564 |
using (Stream pdfStream = new FileInfo(TempFile).Open(FileMode.Open, FileAccess.ReadWrite)) |
|
648 | 565 |
{ |
649 | 566 |
StatusChange("comment Cover",0); |
650 | 567 |
|
... | ... | |
672 | 589 |
{ |
673 | 590 |
var memberlist = ObjectQuery.GetMemberQuery(cIEntities, userid); |
674 | 591 |
|
675 |
if(memberlist.Count() > 0)
|
|
592 |
if(memberlist.Any())
|
|
676 | 593 |
{ |
677 |
username = memberlist.First().NAME;
|
|
678 |
userdept = memberlist.First().DEPARTMENT;
|
|
594 |
username = memberlist[0].NAME;
|
|
595 |
userdept = memberlist[0].DEPARTMENT;
|
|
679 | 596 |
} |
680 | 597 |
} |
681 | 598 |
|
... | ... | |
689 | 606 |
|
690 | 607 |
iTextSharp.text.Version.GetInstance(); |
691 | 608 |
|
692 |
using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
|
|
609 |
using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(WorkingFilePath, FileMode.Create)))
|
|
693 | 610 |
{ |
694 | 611 |
try |
695 | 612 |
{ |
... | ... | |
720 | 637 |
/// 2020.11.13 김태성 |
721 | 638 |
/// 원본 PDF의 페이지수가 변경된 경우 이전 markup의 페이지를 찾지 못해 수정함. |
722 | 639 |
var pageitems = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER); |
723 |
|
|
724 |
if (pageitems.Count() > 0) |
|
640 |
if (pageitems.Any()) |
|
725 | 641 |
{ |
726 | 642 |
var currentPage = pageitems.First(); |
727 | 643 |
pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER); |
... | ... | |
761 | 677 |
scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width; |
762 | 678 |
scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height; |
763 | 679 |
|
680 |
#region 현재 작업 중인 페이지를 저장 |
|
764 | 681 |
pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER; |
765 | 682 |
_entity.SaveChanges(); |
683 |
#endregion |
|
766 | 684 |
|
767 | 685 |
string[] markedData = markupItem.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); |
768 | 686 |
|
... | ... | |
1338 | 1256 |
#endif |
1339 | 1257 |
} |
1340 | 1258 |
|
1341 |
if (File.Exists(pdfFilePath)) |
|
1259 |
#region 작업 파일을 원격지 폴더로 이동 |
|
1260 |
if (File.Exists(WorkingFilePath)) |
|
1342 | 1261 |
{ |
1343 | 1262 |
string destfilepath = null; |
1344 | 1263 |
try |
1345 | 1264 |
{ |
1346 |
FinalPDFPath = new FileInfo(pdfFilePath); |
|
1347 |
|
|
1348 |
/// 정리 필요함. DB로 변경 |
|
1349 |
string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", ""); |
|
1350 |
|
|
1351 |
if(!string.IsNullOrEmpty(pdfmovepath)) |
|
1265 |
FinalPDFPath = new FileInfo(WorkingFilePath); |
|
1266 |
if(!string.IsNullOrEmpty(_FinalPDFStorgeRemote)) |
|
1352 | 1267 |
{ |
1353 |
_FinalPDFStorgeLocal = pdfmovepath;
|
|
1268 |
_FinalPDFStorgeLocal = _FinalPDFStorgeRemote;
|
|
1354 | 1269 |
} |
1355 | 1270 |
|
1356 |
destfilepath = Path.Combine(_FinalPDFStorgeLocal, FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
|
1357 |
|
|
1271 |
destfilepath = Path.Combine(_FinalPDFStorgeLocal, $"{Path.GetFileNameWithoutExtension(FinalPDFPath.Name)}.pdf"); |
|
1358 | 1272 |
if (File.Exists(destfilepath)) |
1359 | 1273 |
File.Delete(destfilepath); |
1360 | 1274 |
|
1361 | 1275 |
File.Move(FinalPDFPath.FullName, destfilepath); |
1362 | 1276 |
FinalPDFPath = new FileInfo(destfilepath); |
1363 |
File.Delete(pdfFilePath);
|
|
1277 |
File.Delete(WorkingFilePath);
|
|
1364 | 1278 |
} |
1365 | 1279 |
catch (Exception ex) |
1366 | 1280 |
{ |
... | ... | |
1370 | 1284 |
|
1371 | 1285 |
return true; |
1372 | 1286 |
} |
1287 |
#endregion |
|
1373 | 1288 |
} |
1374 | 1289 |
catch (Exception ex) |
1375 | 1290 |
{ |
내보내기 Unified diff