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;
|
... | ... | |
186 |
185 |
_entity.DeleteObject(converterdoc);
|
187 |
186 |
_entity.DeleteObject(doc);
|
188 |
187 |
_entity.SaveChanges();
|
189 |
|
document_Url = HttpUtility.UrlDecode(document_Url);
|
|
188 |
//document_Url = HttpUtility.UrlDecode(document_Url);
|
190 |
189 |
}
|
191 |
190 |
int cnt = _entity.DOCUMENT_ITEM.ToList().Count;
|
192 |
191 |
if (string.IsNullOrEmpty(group_No))
|
... | ... | |
486 |
485 |
_entity.DeleteObject(converterdoc);
|
487 |
486 |
_entity.DeleteObject(doc);
|
488 |
487 |
_entity.SaveChanges();
|
489 |
|
document_Url = HttpUtility.UrlDecode(document_Url);
|
|
488 |
//document_Url = HttpUtility.UrlDecode(document_Url);
|
490 |
489 |
}
|
491 |
490 |
int cnt = _entity.DOCUMENT_ITEM.ToList().Count;
|
492 |
491 |
if(string.IsNullOrEmpty(group_No))
|
... | ... | |
662 |
661 |
}
|
663 |
662 |
|
664 |
663 |
[WebMethod]
|
665 |
|
public string ExcelExport(string project_no,string slip_no)
|
|
664 |
public string ExcelExport(string project_no, string slip_no)
|
666 |
665 |
{
|
667 |
666 |
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 |
|
|
|
667 |
//FileInfo fileInfo2 = new FileInfo(Path.GetTempFileName());
|
|
668 |
//fileInfo2.FullName
|
675 |
669 |
try
|
676 |
670 |
{
|
677 |
671 |
// Excel 첫번째 워크시트 가져오기
|
678 |
|
application = new Excel.Application();
|
679 |
|
workbook = application.Workbooks.Open(xlsxfilepath);
|
680 |
|
worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item("Sheet1");
|
|
672 |
//application = new Excel.Application();
|
|
673 |
//workbook = application.Workbooks.Open(xlsxfilepath);
|
|
674 |
//worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item("Sheet1");
|
|
675 |
string xlsxfilepath = @"C:\WebSite\LogView\Doc_Manager\sample.xlsx";
|
|
676 |
GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("EXK0-W4HZ-N518-IMEW");
|
|
677 |
GemBox.Spreadsheet.ExcelFile excelFile = new GemBox.Spreadsheet.ExcelFile();
|
|
678 |
excelFile.LoadXlsx(xlsxfilepath, GemBox.Spreadsheet.XlsxOptions.PreserveMakeCopy);
|
|
679 |
GemBox.Spreadsheet.ExcelWorksheet ws = excelFile.Worksheets[0];
|
|
680 |
FileInfo fileInfo2 = new FileInfo(Path.GetTempFileName().Replace(".tmp", ".xlsx"));
|
|
681 |
|
|
682 |
string fileout = @"C:\WebSite\LogView\Doc_Manager\commentexcel_" + DateTime.Now.ToString() + ".xlsx";
|
|
683 |
string naspath = Properties.Settings.Default.Excelfilepath;
|
|
684 |
//@"\\172.20.121.220\comment3\TileSource\Excelexport";
|
681 |
685 |
|
682 |
686 |
// 데이타 넣기
|
683 |
687 |
int h = 6;
|
684 |
|
int w = 2;
|
|
688 |
int w = 1;
|
685 |
689 |
|
686 |
690 |
|
687 |
691 |
//필터 기능 추가
|
688 |
692 |
//Excel.Range Filter_Range = worksheet.Range["B9:" + Ran + "9"];
|
689 |
693 |
//Filter_Range.AutoFilter(1, Type.Missing, Excel.XlAutoFilterOperator.xlAnd, Type.Missing, true);
|
690 |
694 |
|
691 |
|
|
|
695 |
|
692 |
696 |
using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString()))
|
693 |
697 |
{
|
694 |
698 |
var docs = deepViewEntity.DOCUMENT_ITEM.Where(doc => doc.GROUP_NO == slip_no && doc.PROJECT_NO == project_no).ToList();
|
695 |
|
foreach(var doc in docs)
|
|
699 |
if (docs.Count > 0)
|
696 |
700 |
{
|
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)
|
|
701 |
foreach (var doc in docs)
|
704 |
702 |
{
|
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()))
|
|
703 |
var commentlist = deepViewEntity.MARKUP_DATA.Where(d => d.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO.DOCUMENT_ID == doc.DOCUMENT_ID
|
|
704 |
&& d.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1).ToList();
|
|
705 |
|
|
706 |
string docNo = doc.DOCUMENT_NO;
|
|
707 |
string docDesc = doc.DOCUMENT_NAME;
|
|
708 |
string docRev = doc.REVISION;
|
|
709 |
foreach (var comment in commentlist)
|
710 |
710 |
{
|
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;
|
|
711 |
var member = deepViewEntity.MEMBER.Where(m => m.ID == comment.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID).FirstOrDefault();
|
|
712 |
string docdept = member.DEPARTMENT;
|
|
713 |
string doccomment = string.Empty;
|
|
714 |
var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(comment.DATA.ToString());
|
|
715 |
switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), comment.DATA_TYPE.ToString()))
|
|
716 |
{
|
|
717 |
case MarkupToPDF.Controls.Common.ControlType.TextControl:
|
|
718 |
case MarkupToPDF.Controls.Common.ControlType.TextBorder:
|
|
719 |
case MarkupToPDF.Controls.Common.ControlType.TextCloud:
|
|
720 |
{
|
|
721 |
MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
|
|
722 |
doccomment = instance.Text;
|
|
723 |
}
|
|
724 |
break;
|
|
725 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
|
|
726 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
|
|
727 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
|
|
728 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
|
|
729 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
|
|
730 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
|
|
731 |
{
|
|
732 |
MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
|
|
733 |
doccomment = instance.ArrowText;
|
|
734 |
}
|
|
735 |
break;
|
|
736 |
}
|
|
737 |
ws.Cells[h, w].Value = string.Format("{0}\n({1})", docNo, docDesc);
|
|
738 |
ws.Cells[h, w + 1].Value = docRev;
|
|
739 |
ws.Cells[h, w + 2].Value = docdept;
|
|
740 |
ws.Cells[h, w + 3].Value = doccomment;
|
|
741 |
h++;
|
730 |
742 |
}
|
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 |
743 |
}
|
737 |
744 |
}
|
738 |
|
|
739 |
|
}
|
|
745 |
else
|
|
746 |
{
|
|
747 |
_result = "ERROR : 해당 Slip 의 데이터가 없습니다.";
|
|
748 |
}
|
740 |
749 |
|
741 |
750 |
|
742 |
|
worksheet.Columns.AutoFit();
|
|
751 |
}
|
|
752 |
|
|
753 |
int columnCount = ws.CalculateMaxUsedColumns();
|
|
754 |
for (int i = 0; i < columnCount; i++)
|
|
755 |
ws.Columns[i].AutoFit();
|
|
756 |
//worksheet.Columns.AutoFit();
|
743 |
757 |
// 엑셀파일 저장
|
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;
|
|
758 |
|
|
759 |
excelFile.Save(fileInfo2.FullName);
|
|
760 |
fileInfo2.MoveTo(naspath + "\\" + fileInfo2.Name);
|
|
761 |
//workbook.SaveAs(fileout);
|
|
762 |
////workbook.Save();
|
|
763 |
//workbook.Close(true);
|
|
764 |
//application.Quit();
|
|
765 |
_result = Properties.Settings.Default.Excelresulturl + fileInfo2.Name;
|
755 |
766 |
}
|
756 |
|
finally
|
|
767 |
catch (Exception e)
|
757 |
768 |
{
|
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 |
|
|
|
769 |
_result = "ERROR : " + e.ToString();
|
769 |
770 |
}
|
770 |
771 |
return _result;
|
771 |
772 |
}
|