개정판 3c71b3a5
issue #000: merged master
Change-Id: Id7e766c44e158848f168c86ae220da1700fa36ad
ConvertService/ServiceBase/ConvertionWebService/Conversion.asmx.cs | ||
---|---|---|
10 | 10 |
using DeepViewDataModel.DataModel; |
11 | 11 |
using DeepViewDataModel.Common; |
12 | 12 |
using DeepView.Toolkit.GuidGenerator; |
13 |
using Excel = Microsoft.Office.Interop.Excel; |
|
14 | 13 |
using MarkupToPDF; |
15 | 14 |
using System.IO; |
16 | 15 |
using Newtonsoft.Json; |
... | ... | |
151 | 150 |
|
152 | 151 |
using (DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
153 | 152 |
{ |
153 |
if (string.IsNullOrEmpty(group_No)) |
|
154 |
{ |
|
155 |
group_No = "0"; |
|
156 |
} |
|
157 |
if (!prj_No.Equals("150128")) |
|
158 |
{ |
|
159 |
//Omsk 는 웹서비스 호출 시 인코딩 |
|
160 |
//Omsk 제외는 Markus 에서 인코딩 |
|
161 |
document_Url = Base64Decode(document_Url); |
|
162 |
} |
|
154 | 163 |
var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
155 | 164 |
if (doc != null) |
156 | 165 |
{ |
... | ... | |
181 | 190 |
result = "deleteobject error:"+ex.ToString(); |
182 | 191 |
} |
183 | 192 |
|
184 |
} |
|
185 |
var converterdoc = _entity.CONVERTER_DOC.Where(c => c.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
|
186 |
_entity.DeleteObject(converterdoc); |
|
187 |
_entity.DeleteObject(doc); |
|
188 |
_entity.SaveChanges(); |
|
189 |
document_Url = HttpUtility.UrlDecode(document_Url); |
|
190 |
} |
|
191 |
int cnt = _entity.DOCUMENT_ITEM.ToList().Count; |
|
192 |
if (string.IsNullOrEmpty(group_No)) |
|
193 |
{ |
|
194 |
group_No = "0"; |
|
195 |
} |
|
196 |
if (!prj_No.Equals("150128")) |
|
197 |
{ |
|
198 |
//Omsk 는 웹서비스 호출 시 인코딩 |
|
199 |
//Omsk 제외는 Markus 에서 인코딩 |
|
200 |
document_Url = HttpUtility.UrlEncodeUnicode(document_Url); |
|
201 |
} |
|
202 |
_entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
|
203 |
{ |
|
204 |
ID = document_Id, |
|
205 |
REVISION = rev_No, |
|
206 |
DOCUMENT_NO = document_No, |
|
207 |
DOCUMENT_NAME = document_Name, |
|
208 |
GROUP_NO = group_No, |
|
209 |
ORIGINAL_FILE = document_Url, |
|
210 |
DOCUMENT_ID = _doc_id, |
|
211 |
PROJECT_NO = prj_No, |
|
212 |
}); |
|
193 |
}else |
|
194 |
{ |
|
195 |
doc.REVISION = rev_No; |
|
196 |
doc.ORIGINAL_FILE = document_Url; |
|
197 |
doc.GROUP_NO = group_No; |
|
198 |
doc.DOCUMENT_NO = document_No; |
|
199 |
doc.DOCUMENT_NAME = document_Name; |
|
200 |
} |
|
201 |
}else |
|
202 |
{ |
|
203 |
_entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
|
204 |
{ |
|
205 |
ID = document_Id, |
|
206 |
REVISION = rev_No, |
|
207 |
DOCUMENT_NO = document_No, |
|
208 |
DOCUMENT_NAME = document_Name, |
|
209 |
GROUP_NO = group_No, |
|
210 |
ORIGINAL_FILE = document_Url, |
|
211 |
DOCUMENT_ID = _doc_id, |
|
212 |
PROJECT_NO = prj_No, |
|
213 |
}); |
|
214 |
} |
|
215 |
|
|
213 | 216 |
_entity.AddToCONVERTER_DOC(new CONVERTER_DOC |
214 | 217 |
{ |
215 | 218 |
ID = _id, |
... | ... | |
478 | 481 |
string _id = shortGuid(); |
479 | 482 |
string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
480 | 483 |
using (DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
481 |
{ |
|
482 |
var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
|
483 |
if(doc != null) |
|
484 |
{ |
|
485 |
var converterdoc = _entity.CONVERTER_DOC.Where(c => c.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
|
486 |
_entity.DeleteObject(converterdoc); |
|
487 |
_entity.DeleteObject(doc); |
|
488 |
_entity.SaveChanges(); |
|
489 |
document_Url = HttpUtility.UrlDecode(document_Url); |
|
490 |
} |
|
491 |
int cnt = _entity.DOCUMENT_ITEM.ToList().Count; |
|
492 |
if(string.IsNullOrEmpty(group_No)) |
|
484 |
{ |
|
485 |
if (string.IsNullOrEmpty(group_No)) |
|
493 | 486 |
{ |
494 | 487 |
group_No = "0"; |
495 | 488 |
} |
... | ... | |
497 | 490 |
{ |
498 | 491 |
//Omsk 는 웹서비스 호출 시 인코딩 |
499 | 492 |
//Omsk 제외는 Markus 에서 인코딩 |
500 |
document_Url = HttpUtility.UrlEncodeUnicode(document_Url);
|
|
493 |
document_Url = Base64Decode(document_Url);
|
|
501 | 494 |
} |
502 |
_entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
|
495 |
var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
|
496 |
if(doc != null) |
|
503 | 497 |
{ |
504 |
ID = document_Id, |
|
505 |
REVISION = rev_No, |
|
506 |
DOCUMENT_NO = document_No, |
|
507 |
DOCUMENT_NAME = document_Name, |
|
508 |
GROUP_NO = group_No, |
|
509 |
ORIGINAL_FILE = document_Url, |
|
510 |
DOCUMENT_ID = _doc_id, |
|
511 |
PROJECT_NO = prj_No, |
|
512 |
}); |
|
498 |
doc.REVISION = rev_No; |
|
499 |
doc.ORIGINAL_FILE = document_Url; |
|
500 |
doc.GROUP_NO = group_No; |
|
501 |
doc.DOCUMENT_NO = document_No; |
|
502 |
doc.DOCUMENT_NAME = document_Name; |
|
503 |
}else |
|
504 |
{ |
|
505 |
_entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
|
506 |
{ |
|
507 |
ID = document_Id, |
|
508 |
REVISION = rev_No, |
|
509 |
DOCUMENT_NO = document_No, |
|
510 |
DOCUMENT_NAME = document_Name, |
|
511 |
GROUP_NO = group_No, |
|
512 |
ORIGINAL_FILE = document_Url, |
|
513 |
DOCUMENT_ID = _doc_id, |
|
514 |
PROJECT_NO = prj_No, |
|
515 |
}); |
|
516 |
} |
|
517 |
|
|
513 | 518 |
_entity.AddToCONVERTER_DOC(new CONVERTER_DOC |
514 | 519 |
{ |
515 | 520 |
ID = _id, |
... | ... | |
662 | 667 |
} |
663 | 668 |
|
664 | 669 |
[WebMethod] |
665 |
public string ExcelExport(string project_no,string slip_no) |
|
670 |
public string ExcelExport(string project_no, string slip_no)
|
|
666 | 671 |
{ |
667 | 672 |
string _result = "false"; |
668 |
Excel.Application application = null; |
|
669 |
Excel.Workbook workbook = null; |
|
670 |
Excel.Worksheet worksheet = null; |
|
671 |
string xlsxfilepath = @"D:\sample.xlsx"; |
|
672 |
|
|
673 |
string fileout = @"D:\CommentExport_" + DateTime.Now.ToString() + ".xlsx"; |
|
674 |
|
|
673 |
//FileInfo fileInfo2 = new FileInfo(Path.GetTempFileName()); |
|
674 |
//fileInfo2.FullName |
|
675 | 675 |
try |
676 | 676 |
{ |
677 | 677 |
// Excel 첫번째 워크시트 가져오기 |
678 |
application = new Excel.Application(); |
|
679 |
workbook = application.Workbooks.Open(xlsxfilepath); |
|
680 |
worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item("Sheet1"); |
|
678 |
//application = new Excel.Application(); |
|
679 |
//workbook = application.Workbooks.Open(xlsxfilepath); |
|
680 |
//worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item("Sheet1"); |
|
681 |
string xlsxfilepath = @"C:\WebSite\LogView\Doc_Manager\sample.xlsx"; |
|
682 |
GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("EXK0-W4HZ-N518-IMEW"); |
|
683 |
GemBox.Spreadsheet.ExcelFile excelFile = new GemBox.Spreadsheet.ExcelFile(); |
|
684 |
excelFile.LoadXlsx(xlsxfilepath, GemBox.Spreadsheet.XlsxOptions.PreserveMakeCopy); |
|
685 |
GemBox.Spreadsheet.ExcelWorksheet ws = excelFile.Worksheets[0]; |
|
686 |
FileInfo fileInfo2 = new FileInfo(Path.GetTempFileName().Replace(".tmp", ".xlsx")); |
|
687 |
|
|
688 |
string fileout = @"C:\WebSite\LogView\Doc_Manager\commentexcel_" + DateTime.Now.ToString() + ".xlsx"; |
|
689 |
string naspath = Properties.Settings.Default.Excelfilepath; |
|
690 |
//@"\\172.20.121.220\comment3\TileSource\Excelexport"; |
|
681 | 691 |
|
682 | 692 |
// 데이타 넣기 |
683 | 693 |
int h = 6; |
684 |
int w = 2;
|
|
694 |
int w = 1;
|
|
685 | 695 |
|
686 | 696 |
|
687 | 697 |
//필터 기능 추가 |
688 | 698 |
//Excel.Range Filter_Range = worksheet.Range["B9:" + Ran + "9"]; |
689 | 699 |
//Filter_Range.AutoFilter(1, Type.Missing, Excel.XlAutoFilterOperator.xlAnd, Type.Missing, true); |
690 | 700 |
|
691 |
|
|
701 |
|
|
692 | 702 |
using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
693 | 703 |
{ |
694 | 704 |
var docs = deepViewEntity.DOCUMENT_ITEM.Where(doc => doc.GROUP_NO == slip_no && doc.PROJECT_NO == project_no).ToList(); |
695 |
foreach(var doc in docs)
|
|
705 |
if (docs.Count > 0)
|
|
696 | 706 |
{ |
697 |
var commentlist = deepViewEntity.MARKUP_DATA.Where(d => d.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO.DOCUMENT_ID == doc.DOCUMENT_ID |
|
698 |
&& d.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1).ToList(); |
|
699 |
|
|
700 |
string docNo = doc.DOCUMENT_NO; |
|
701 |
string docDesc = doc.DOCUMENT_NAME; |
|
702 |
string docRev = doc.REVISION; |
|
703 |
foreach(var comment in commentlist) |
|
707 |
foreach (var doc in docs) |
|
704 | 708 |
{ |
705 |
var member = deepViewEntity.MEMBER.Where(m => m.ID == comment.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID).FirstOrDefault(); |
|
706 |
string docdept = member.DEPARTMENT; |
|
707 |
string doccomment = string.Empty; |
|
708 |
var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(comment.DATA.ToString()); |
|
709 |
switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), comment.DATA_TYPE.ToString())) |
|
709 |
var commentlist = deepViewEntity.MARKUP_DATA.Where(d => d.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO.DOCUMENT_ID == doc.DOCUMENT_ID |
|
710 |
&& d.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1).ToList(); |
|
711 |
|
|
712 |
string docNo = doc.DOCUMENT_NO; |
|
713 |
string docDesc = doc.DOCUMENT_NAME; |
|
714 |
string docRev = doc.REVISION; |
|
715 |
foreach (var comment in commentlist) |
|
710 | 716 |
{ |
711 |
case MarkupToPDF.Controls.Common.ControlType.TextControl: |
|
712 |
case MarkupToPDF.Controls.Common.ControlType.TextBorder: |
|
713 |
case MarkupToPDF.Controls.Common.ControlType.TextCloud: |
|
714 |
{ |
|
715 |
MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data); |
|
716 |
doccomment = instance.Text; |
|
717 |
} |
|
718 |
break; |
|
719 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl: |
|
720 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl: |
|
721 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl: |
|
722 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl: |
|
723 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl: |
|
724 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl: |
|
725 |
{ |
|
726 |
MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data); |
|
727 |
doccomment = instance.ArrowText; |
|
728 |
} |
|
729 |
break; |
|
717 |
var member = deepViewEntity.MEMBER.Where(m => m.ID == comment.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID).FirstOrDefault(); |
|
718 |
string docdept = member.DEPARTMENT; |
|
719 |
string doccomment = string.Empty; |
|
720 |
var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(comment.DATA.ToString()); |
|
721 |
switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), comment.DATA_TYPE.ToString())) |
|
722 |
{ |
|
723 |
case MarkupToPDF.Controls.Common.ControlType.TextControl: |
|
724 |
case MarkupToPDF.Controls.Common.ControlType.TextBorder: |
|
725 |
case MarkupToPDF.Controls.Common.ControlType.TextCloud: |
|
726 |
{ |
|
727 |
MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data); |
|
728 |
doccomment = instance.Text; |
|
729 |
} |
|
730 |
break; |
|
731 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl: |
|
732 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl: |
|
733 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl: |
|
734 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl: |
|
735 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl: |
|
736 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl: |
|
737 |
{ |
|
738 |
MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data); |
|
739 |
doccomment = instance.ArrowText; |
|
740 |
} |
|
741 |
break; |
|
742 |
} |
|
743 |
ws.Cells[h, w].Value = string.Format("{0}\n({1})", docNo, docDesc); |
|
744 |
ws.Cells[h, w + 1].Value = docRev; |
|
745 |
ws.Cells[h, w + 2].Value = docdept; |
|
746 |
ws.Cells[h, w + 3].Value = doccomment; |
|
747 |
h++; |
|
730 | 748 |
} |
731 |
worksheet.Cells[h, w] = string.Format("{0}\n({1})",docNo,docDesc); |
|
732 |
worksheet.Cells[h, w + 1] = docRev; |
|
733 |
worksheet.Cells[h, w + 2] = docdept; |
|
734 |
worksheet.Cells[h, w + 3] = doccomment; |
|
735 |
h++; |
|
736 | 749 |
} |
737 | 750 |
} |
738 |
|
|
739 |
} |
|
751 |
else |
|
752 |
{ |
|
753 |
_result = "ERROR : 해당 Slip 의 데이터가 없습니다."; |
|
754 |
} |
|
740 | 755 |
|
741 | 756 |
|
742 |
worksheet.Columns.AutoFit(); |
|
757 |
} |
|
758 |
|
|
759 |
int columnCount = ws.CalculateMaxUsedColumns(); |
|
760 |
for (int i = 0; i < columnCount; i++) |
|
761 |
ws.Columns[i].AutoFit(); |
|
762 |
//worksheet.Columns.AutoFit(); |
|
743 | 763 |
// 엑셀파일 저장 |
744 |
|
|
745 |
|
|
746 |
workbook.SaveAs(fileout); |
|
747 |
//workbook.Save(); |
|
748 |
workbook.Close(true); |
|
749 |
application.Quit(); |
|
750 |
_result = fileout; |
|
751 |
} |
|
752 |
catch(Exception e) |
|
753 |
{ |
|
754 |
_result = e.Message; |
|
764 |
|
|
765 |
excelFile.Save(fileInfo2.FullName); |
|
766 |
fileInfo2.MoveTo(naspath + "\\" + fileInfo2.Name); |
|
767 |
//workbook.SaveAs(fileout); |
|
768 |
////workbook.Save(); |
|
769 |
//workbook.Close(true); |
|
770 |
//application.Quit(); |
|
771 |
_result = Properties.Settings.Default.Excelresulturl + fileInfo2.Name; |
|
755 | 772 |
} |
756 |
finally
|
|
773 |
catch (Exception e)
|
|
757 | 774 |
{ |
758 |
System.Diagnostics.Process[] ExCel = System.Diagnostics.Process.GetProcessesByName("EXCEL"); |
|
759 |
if (ExCel.Count() != 0) |
|
760 |
{ |
|
761 |
ExCel[0].Kill(); |
|
762 |
} |
|
763 |
|
|
764 |
// Clean up |
|
765 |
ReleaseExcelObject(worksheet); |
|
766 |
ReleaseExcelObject(workbook); |
|
767 |
ReleaseExcelObject(application); |
|
768 |
|
|
775 |
_result = "ERROR : " + e.ToString(); |
|
769 | 776 |
} |
770 | 777 |
return _result; |
771 | 778 |
} |
내보내기 Unified diff