프로젝트

일반

사용자정보

개정판 52889f5e

ID52889f5ef9eb2a2e35a4eb57e7dccea749d90a77
상위 0177db7a

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

issue #1188: finalservice 에서 pdf 생성 후 업로드 하는 Web Service merged

Change-Id: Ib05510a51cb9d9f3f21bd14adcbed1f0ff65df2d

차이점 보기:

FinalService/KCOM_FinalService/KCOM_FinalService/FinalService.ini
12 12
NAME=FinalService
13 13
[UpLoadServiceUrl]
14 14
URL=
15
[FinalPDFRootUrl]
16
URL=http://192.168.0.67:5977/finalpdf/
15 17
[ConnectionString]
16 18
STRING=EVCOYxwadMNh7qzjMvRTwOacwyFatXgWjx//sssrSKTsvMkdvpdBa3Sj3mmhwABTiweSqNnWYgsIxUWXaBe8XE8G1CLaux2zPbyBWvqxJruTX0H5MqABZSEXXG82XaGL
17 19
[MARKUS_API]
FinalService/KCOM_FinalService/KCOM_FinalService/Remoting/RemFinalPDFStation.cs
215 215
                try
216 216
                {
217 217
                    string soapurl = CommonLib.Common.GetConfigString("UpLoadServiceUrl", "URL", "");
218
                    string finalpdfroot = CommonLib.Common.GetConfigString("FinalPDFRootUrl", "URL", "");
218 219
                    string filename = Path.GetFileName(e.FinalPDFPath);
220
                    string pdfpath = !string.IsNullOrEmpty(finalpdfroot) ? finalpdfroot + filename : filename;
219 221
                    if (!string.IsNullOrEmpty(soapurl))
220 222
                    {
221 223
                        //Legacy IF
222
                        KeyValuePair<bool, string> result = UploadFinal.UploadFinal.UploadFinalPDF(filename, e.OriginPDFName, e.FinalPDF, soapurl);
224
                        KeyValuePair<bool, string> result = UploadFinal.UploadFinal.UploadFinalPDF(pdfpath, e.OriginPDFName, e.FinalPDF, soapurl);
223 225
                        if (result.Key)
224 226
                        {
225 227
                            SetFinalState(_item.ID, FinalStatus.Success);
FinalService/KCOM_FinalService/UploadFinal/UploadPDF.cs
16 16
    {
17 17
        
18 18
        public static KeyValuePair<bool, string> UploadFinalPDF(string PdfFilePath, string OriginFileName, FINAL_PDF FinalPDF, string UploadServiceUrl)
19
        {            
20
            string _vendorItemId = null;
21
            string _objid = null;
22
            string _SharepointItemID = null;
23
            string _slipNO = null;
24
            bool _ResultFlag = false;
25
            string _ResultMsg = "";
19
        {    
26 20

  
27 21
            try
28 22
            {
29
                string docurl = string.Empty;
30

  
31
                using (CIEntities dc = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
32
                {
33
                    var _docInfoList = dc.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID);
34

  
35
                    if (_docInfoList.Count() > 0)
36
                        _SharepointItemID = _docInfoList.First().DOCUMENT_ID;
37

  
38
                    var _vendoritems = dc.DOCUMENT_ITEM.Where(item => item.DOCUMENT_ID == _SharepointItemID && item.PROJECT_NO == FinalPDF.PROJECT_NO);
39

  
40
                    if (_vendoritems.Count() > 0)
41
                    {
42
                        _objid = _vendoritems.First().ID;
43
                        _slipNO = _vendoritems.First().GROUP_NO;
44
                        docurl = _vendoritems.First().ORIGINAL_FILE;
45
                    }
46
                }
47

  
48
                //EnsemblePlusWebService.DLMWebServiceClient client = new EnsemblePlusWebService.DLMWebServiceClient();
49
                //var result = client.fnFinalPDFCheckInService(FinalPDF.PROJECT_NO, _objid, _slipNO, PdfFilePath);
50

  
51 23
                WebClient webClient = new WebClient();
52 24
                string data = string.Empty;
53
                if (docurl.ToUpper().Contains("VPCS_DOCLIB"))
25
                data = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tem=\"http://tempuri.org/\"><soap:Header/><soap:Body><tem:CreateFinalPDF>"
26
                    + "<tem:userID>"+ FinalPDF.CREATE_USER_ID +"</tem:userID>"
27
                    + "<tem:objectID>"+FinalPDF.DOCUMENT_ID+"</tem:objectID>"
28
                    + "<tem:filePath>"+ PdfFilePath+"</tem:filePath>"
29
                    + " </tem:CreateFinalPDF></soap:Body></soap:Envelope>";
30

  
31
                webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
32
                webClient.Headers.Add("SOAPAction", "http://tempuri.org/CreateFinalPDF");
33

  
34
                var result = webClient.UploadString(new Uri(UploadServiceUrl), data);
35
                XmlDocument xmlDoc = new XmlDocument();
36
                xmlDoc.LoadXml(result);
37
                XmlNodeList list = xmlDoc.GetElementsByTagName("CreateFinalPDFResult");
38
                if (list.Count > 0)
54 39
                {
55
                    string connectionString = "data source=ESB-DB;Initial Catalog=markus;uid=ProjectPortalDBConn;password=ProjectPortalDBConn";
56
                    SqlConnection sqlConn = new SqlConnection(connectionString);
57
                    SqlCommand sqlComm = new SqlCommand();
58
                    sqlComm.Connection = sqlConn;
59
                    sqlComm.CommandText = string.Format("SELECT [DBConnectString]  FROM [PortalEV].[dbo].[Setting]  where [ProjectNumber] = '{0}'", FinalPDF.PROJECT_NO);
60
                    string ciconnectionStr = string.Empty;
61

  
62
                    sqlConn.Open();
63
                    using (SqlDataReader SqlRs = sqlComm.ExecuteReader())
64
                    {
65

  
66
                        while (SqlRs.Read())
67
                        {
68
                            ciconnectionStr = SqlRs[0].ToString();
69
                        }
70
                    }
71
                    sqlConn.Close();
72
                    sqlConn = new SqlConnection(ciconnectionStr);
73
                    sqlComm.Connection = sqlConn;
74
                    sqlComm.CommandText = string.Format("SELECT [vendor_item_id]  FROM [vendor_item]  where [sharepoint_itemid] = '{0}'", _objid);
75
                    sqlConn.Open();
76
                    using (SqlDataReader SqlRs = sqlComm.ExecuteReader())
40
                    if (!string.IsNullOrEmpty(list[0].InnerText))
77 41
                    {
78

  
79
                        while (SqlRs.Read())
80
                        {
81
                            _objid = SqlRs[0].ToString();
82
                        }
42
                        return new KeyValuePair<bool, string>(true, "Success");
83 43
                    }
84
                    sqlConn.Close();
85
                    UploadServiceUrl = "http://esb-vpcs-new.daelimplant.com/ProjectPortal/UserControls/DaelimCI2/FinalPDFUpload/UploadVpcsFile.asmx";
86

  
87
                    data = "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\" ><soap12:Body><UploadFinalPDF xmlns=\"http://FinalPDFUpload\">"
88
                                     + "<ProjectNo>" + FinalPDF.PROJECT_NO + "</ProjectNo>"
89
                                     + "<VendorItemID>" + _objid + "</VendorItemID>"
90
                                     + "<SlipNumber>" + _slipNO + "</SlipNumber>"
91
                                     + "<filePath>" + @"\\172.20.121.220\comment3\finalPDF\" + PdfFilePath + "</filePath>"
92
                                     + "<OriginFileName>" + OriginFileName + "</OriginFileName></UploadFinalPDF></soap12:Body></soap12:Envelope>";
93
                                       
94
                    //WriteLog(data);
95
                    webClient.Headers.Add(HttpRequestHeader.ContentType, "application/soap+xml; charset=utf-8");
96
                    webClient.Headers.Add("SOAPAction", "http://FinalPDFUpload/UploadFinalPDF");
97
                    string _result = webClient.UploadString(new Uri(UploadServiceUrl), data);
98
                    XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(_result));
99

  
100
                    while (reader.Read())
44
                    else
101 45
                    {
102
                        switch (reader.NodeType)
103
                        {
104
                            case XmlNodeType.Element:
105
                                if (reader.Name == "Seccess")
106
                                {
107
                                    reader.Read();
108

  
109
                                    if (!string.IsNullOrWhiteSpace(reader.Value))
110
                                        _ResultFlag = Convert.ToBoolean(reader.Value);
111
                                }
112

  
113
                                if (reader.Name == "Message")
114
                                {
115
                                    reader.Read();
116

  
117
                                    if (!string.IsNullOrWhiteSpace(reader.Value))
118
                                        _ResultMsg = reader.Value;
119
                                }
120

  
121
                                if (reader.Name == "FinalPDFUrl")
122
                                {
123
                                    reader.Read();
124

  
125
                                    if (!string.IsNullOrWhiteSpace(reader.Value))
126
                                        _ResultMsg = reader.Value;
127
                                }
128

  
129
                                break;                                
130
                        }
46
                        return new KeyValuePair<bool, string>(false, "Fail");
131 47
                    }
132
                    return new KeyValuePair<bool, string>(_ResultFlag, _ResultMsg);
133 48
                }
134 49
                else
135 50
                {
136
                    data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ens=\"http://EnsemblePlus.Webservice\"> <soapenv:Header/> <soapenv:Body> <ens:fnFinalPDFCheckInService>"
137
                    + "<ens:ProjectNo>" + FinalPDF.PROJECT_NO + "</ens:ProjectNo>"
138
                    + "<ens:ObjectId>" + _objid + "</ens:ObjectId>"
139
                    + "<ens:SlipNumber>" + _slipNO + "</ens:SlipNumber>"
140
                    + "<ens:filePath>" + PdfFilePath + "</ens:filePath>"
141
                    + "<ens:OriginalFileName>" + OriginFileName + "</ens:OriginalFileName>"
142
                    + "</ens:fnFinalPDFCheckInService> </soapenv:Body></soapenv:Envelope>";
51
                    return new KeyValuePair<bool, string>(false, "Not Completed");
52
                }
53

  
54

  
143 55

  
144
                    webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
145
                    webClient.Headers.Add("SOAPAction", "http://EnsemblePlus.Webservice");
146 56

  
147
                    var result = webClient.UploadString(new Uri(UploadServiceUrl), data);
148
                    XmlDocument xmlDoc = new XmlDocument();
149
                    xmlDoc.LoadXml(result);
150
                    XmlNodeList list = xmlDoc.GetElementsByTagName("fnFinalPDFCheckInServiceReturn");
151
                    if (list.Count > 0)
152
                    {
153
                        if (list[0].InnerText == "Success")
154
                        {
155
                            return new KeyValuePair<bool, string>(true, "Success");
156
                        }
157
                        else
158
                        {
159
                            return new KeyValuePair<bool, string>(false, "Fail");
160
                        }
161
                    }
162
                    else
163
                    {
164
                        return new KeyValuePair<bool, string>(false, "Not Completed");
165
                    }
166
                }
167
               
168
               
169
                
170
                
171 57
            }
172 58
            catch (Exception ex)
173 59
            {

내보내기 Unified diff

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