프로젝트

일반

사용자정보

개정판 36ce0d02

ID36ce0d02ba067ac3775c94b5272d53527e78111f
상위 bc28fe10
하위 48542366, 38ad53e3

김동진이(가) 5년 이상 전에 추가함

issue #000: convert web service excel dll 수정 interop => gembox,

Change-Id: I7b3d2b3d8847716fcd036aa359007ff8fb0819f7

차이점 보기:

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;
......
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
        }
ConvertService/ServiceBase/ConvertionWebService/ConvertionWebService.csproj
61 61
      <SpecificVersion>False</SpecificVersion>
62 62
      <HintPath>..\Old_lib\DeepViewDataModel.dll</HintPath>
63 63
    </Reference>
64
    <Reference Include="GemBox.Spreadsheet, Version=39.3.30.1215, Culture=neutral, PublicKeyToken=b1b72c69714d4847, processorArchitecture=MSIL">
65
      <HintPath>..\packages\GemBox.Spreadsheet.39.3.30.1215\lib\net30\GemBox.Spreadsheet.dll</HintPath>
66
    </Reference>
64 67
    <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
65 68
      <HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
66 69
    </Reference>
67 70
    <Reference Include="MarkupToPDF">
68
      <HintPath>..\..\..\..\MarkUS_deploy\MarkupToPDF\bin\x64\Debug\MarkupToPDF.dll</HintPath>
71
      <HintPath>..\Old_lib\MarkupToPDF.dll</HintPath>
69 72
    </Reference>
70 73
    <Reference Include="Microsoft.CSharp" />
71
    <Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
72
      <EmbedInteropTypes>True</EmbedInteropTypes>
73
      <HintPath>..\Main\PDFConverter\packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
74
      <Private>True</Private>
75
    </Reference>
76 74
    <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
77 75
      <HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
78 76
    </Reference>
ConvertService/ServiceBase/ConvertionWebService/Properties/Settings.Designer.cs
58 58
                return ((string)(this["MARKUS_V3_ADDRESS"]));
59 59
            }
60 60
        }
61
        
62
        [global::System.Configuration.ApplicationScopedSettingAttribute()]
63
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
64
        [global::System.Configuration.DefaultSettingValueAttribute("http://172.20.120.141:5977/TileSource/Excelexport/")]
65
        public string Excelresulturl {
66
            get {
67
                return ((string)(this["Excelresulturl"]));
68
            }
69
        }
70
        
71
        [global::System.Configuration.ApplicationScopedSettingAttribute()]
72
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
73
        [global::System.Configuration.DefaultSettingValueAttribute("\\\\172.20.121.220\\comment3\\TileSource\\Excelexport")]
74
        public string Excelfilepath {
75
            get {
76
                return ((string)(this["Excelfilepath"]));
77
            }
78
        }
61 79
    }
62 80
}
ConvertService/ServiceBase/ConvertionWebService/Properties/Settings.settings
14 14
    <Setting Name="MARKUS_V3_ADDRESS" Type="System.String" Scope="Application">
15 15
      <Value Profile="(Default)">http://localhost:9101/StationService</Value>
16 16
    </Setting>
17
    <Setting Name="Excelresulturl" Type="System.String" Scope="Application">
18
      <Value Profile="(Default)">http://172.20.120.141:5977/TileSource/Excelexport/</Value>
19
    </Setting>
20
    <Setting Name="Excelfilepath" Type="System.String" Scope="Application">
21
      <Value Profile="(Default)">\\172.20.121.220\comment3\TileSource\Excelexport</Value>
22
    </Setting>
17 23
  </Settings>
18 24
</SettingsFile>
ConvertService/ServiceBase/ConvertionWebService/Web.config
35 35
      <setting name="MARKUS_V3_ADDRESS" serializeAs="String">
36 36
        <value>http://localhost:9101/StationService</value>
37 37
      </setting>
38
      <setting name="Excelresulturl" serializeAs="String">
39
        <value>http://172.20.120.141:5977/TileSource/Excelexport/</value>
40
      </setting>
41
      <setting name="Excelfilepath" serializeAs="String">
42
        <value>\\172.20.121.220\comment3\TileSource\Excelexport</value>
43
      </setting>
38 44
    </ConvertionWebService.Properties.Settings>
39 45
  </applicationSettings>
40 46
  <system.serviceModel>
ConvertService/ServiceBase/ConvertionWebService/packages.config
1 1
<?xml version="1.0" encoding="utf-8"?>
2 2
<packages>
3
  <package id="GemBox.Spreadsheet" version="39.3.30.1215" targetFramework="net452" />
3 4
  <package id="log4net" version="2.0.8" targetFramework="net452" />
4 5
  <package id="Newtonsoft.Json" version="12.0.2" targetFramework="net40" requireReinstallation="true" />
5 6
</packages>

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)