markus / ConvertionWebServiceDefault / Conversion.asmx.cs @ master
이력 | 보기 | 이력해설 | 다운로드 (48.3 KB)
1 | 195f079d | taeseongkim | //using IConverterPDF; |
---|---|---|---|
2 | d21e9c15 | taeseongkim | using KCOMDataModel.DataModel; |
3 | using KCOMDataModel.Common; |
||
4 | using log4net; |
||
5 | using Newtonsoft.Json.Linq; |
||
6 | using System; |
||
7 | using System.IO; |
||
8 | using System.Linq; |
||
9 | using System.Runtime.Remoting.Channels; |
||
10 | using System.Runtime.Remoting.Channels.Tcp; |
||
11 | using System.Text; |
||
12 | using System.Web; |
||
13 | using System.Web.Services; |
||
14 | |||
15 | namespace ConvertionWebService |
||
16 | { |
||
17 | /// <summary> |
||
18 | /// Summary description for Conversio |
||
19 | /// </summary> |
||
20 | [WebService(Namespace = "http://tempuri.org/")] |
||
21 | [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] |
||
22 | [System.ComponentModel.ToolboxItem(false)] |
||
23 | public class Conversion : System.Web.Services.WebService |
||
24 | { |
||
25 | |||
26 | 195f079d | taeseongkim | //RemConverterPDFObject remObj = null; |
27 | d21e9c15 | taeseongkim | protected ILog logger = LogManager.GetLogger(typeof(Conversion)); |
28 | public Conversion() |
||
29 | { |
||
30 | 195f079d | taeseongkim | //try |
31 | //{ |
||
32 | // //System.Runtime.Remoting.Channels.IChannel _ch = ChannelServices.GetChannel("tcp"); |
||
33 | |||
34 | // //if(_ch == null) |
||
35 | // //{ |
||
36 | // // TcpChannel chan = new TcpChannel(); |
||
37 | // // ChannelServices.RegisterChannel(chan, false); |
||
38 | // //} |
||
39 | // //// Create an instance of the remote object |
||
40 | // //remObj = (RemConverterPDFObject)Activator.GetObject(typeof(RemConverterPDFObject), |
||
41 | // // Properties.Settings.Default.ConverterRemotingUrl); |
||
42 | |||
43 | //} |
||
44 | //catch (Exception ex) |
||
45 | //{ |
||
46 | // logger.Error("Conversion Web Service Conversion Error", ex); |
||
47 | // SendNotice(ex.ToString()); |
||
48 | //} |
||
49 | d21e9c15 | taeseongkim | } |
50 | |||
51 | private void SendNotice(string ex) |
||
52 | { |
||
53 | if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.ErrorNoticeID)) |
||
54 | { |
||
55 | var _lstID = Properties.Settings.Default.ErrorNoticeID.Split(';').ToList(); |
||
56 | //EmailClient.EmailClient _client = new EmailClient.EmailClient(_lstID.First()); |
||
57 | StringBuilder _bl = new StringBuilder(); |
||
58 | _bl.AppendLine("Conversion Web Service Error"); |
||
59 | _bl.AppendLine(ex); |
||
60 | //var _emailResult = _client.SendEmail(_lstID, _lstID, "<Conversion Web Service Error>", _bl.ToString(), false); |
||
61 | } |
||
62 | else |
||
63 | { |
||
64 | logger.Error("Conversion Web Service Error",new Exception(ex)); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | [WebMethod] |
||
69 | public string ConvertRun(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
||
70 | { |
||
71 | string _result = null; |
||
72 | try |
||
73 | { |
||
74 | logger.Info($"Conversion Web Service ConvertRun call rev_No :{rev_No} document_No : {document_No} document_Name : {document_Name} group_No : {group_No} prj_No : {prj_No} document_Id : {document_Id} document_Url : {document_Url}"); |
||
75 | |||
76 | using (KCOMEntities deepViewEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
77 | { |
||
78 | //_result = ConnectStringBuilder.DeepViewConnectionString().ToString(); |
||
79 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber && DateTime.Parse(r.RUN_DATETIME)<= DateTime.Now); |
||
80 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber); |
||
81 | var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO != null); |
||
82 | |||
83 | if (_RunProjects.Count() > 0) |
||
84 | { |
||
85 | _result = SendKcom(rev_No, document_No, document_Name, group_No, prj_No, document_Id, document_Url); |
||
86 | } |
||
87 | else |
||
88 | { |
||
89 | _result = false.ToString(); |
||
90 | } |
||
91 | } |
||
92 | } |
||
93 | catch (Exception ex) |
||
94 | { |
||
95 | logger.Error($"Conversion Web Service ConvertRun Error rev_No :{rev_No} document_No : {document_No} document_Name : {document_Name} group_No : {group_No} prj_No : {prj_No} document_Id : {document_Id} document_Url : {document_Url}", ex); |
||
96 | _result = ex.Message.ToString(); |
||
97 | SendNotice("Project NO : " + prj_No + "\r\n DocumentUrl : " + document_Url + "\r\n Error" + ex.ToString()); |
||
98 | } |
||
99 | return _result; |
||
100 | } |
||
101 | |||
102 | [WebMethod] |
||
103 | public string ConvertRunIgnoreComment(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url, string ignoreComment) |
||
104 | { |
||
105 | string _result = null; |
||
106 | try |
||
107 | { |
||
108 | using (KCOMEntities deepViewEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
109 | { |
||
110 | //_result = ConnectStringBuilder.DeepViewConnectionString().ToString(); |
||
111 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber && DateTime.Parse(r.RUN_DATETIME)<= DateTime.Now); |
||
112 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber); |
||
113 | var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO != null); |
||
114 | |||
115 | if (_RunProjects.Count() > 0) |
||
116 | { |
||
117 | _result = SendKcom(rev_No, document_No, document_Name, group_No, prj_No, document_Id, document_Url,ignoreComment); |
||
118 | } |
||
119 | else |
||
120 | { |
||
121 | _result = false.ToString(); |
||
122 | } |
||
123 | } |
||
124 | } |
||
125 | catch (Exception ex) |
||
126 | { |
||
127 | _result = ex.Message.ToString(); |
||
128 | SendNotice("Project NO : " + prj_No + "\r\n DocumentUrl : " + document_Url + "\r\n Error" + ex.ToString()); |
||
129 | } |
||
130 | return _result; |
||
131 | } |
||
132 | private string SendKcom(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url, string ignoreComment) |
||
133 | { |
||
134 | string result = false.ToString(); |
||
135 | |||
136 | 195f079d | taeseongkim | |
137 | d21e9c15 | taeseongkim | //string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
138 | string _id = shortGuid(); |
||
139 | string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
||
140 | |||
141 | using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
142 | { |
||
143 | if (string.IsNullOrEmpty(group_No)) |
||
144 | { |
||
145 | group_No = "0"; |
||
146 | } |
||
147 | if (!document_Url.Contains("http%3a%2f%2f")) |
||
148 | { |
||
149 | document_Url = Base64Decode(document_Url); |
||
150 | document_Url = HttpUtility.UrlEncodeUnicode(document_Url); |
||
151 | } |
||
152 | document_Name = Base64DecodeFromStr(document_Name); |
||
153 | var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
||
154 | if (doc != null) |
||
155 | { |
||
156 | if (bool.Parse(ignoreComment)) |
||
157 | { |
||
158 | try |
||
159 | { |
||
160 | var docinfo = _entity.DOCINFO.Where(x => x.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
||
161 | var markupinfos = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo.ID).ToList(); |
||
162 | foreach (var markupinfo in markupinfos) |
||
163 | { |
||
164 | var markupinfoversions = _entity.MARKUP_INFO_VERSION.Where(x => x.MARKUPINFO_ID == markupinfo.ID).ToList(); |
||
165 | foreach (var markupinfoversion in markupinfoversions) |
||
166 | { |
||
167 | var markupdatas = _entity.MARKUP_DATA.Where(x => x.MARKUPINFO_VERSION_ID == markupinfoversion.ID).ToList(); |
||
168 | foreach (var markupdata in markupdatas) |
||
169 | { |
||
170 | _entity.DeleteObject(markupdata); |
||
171 | } |
||
172 | _entity.DeleteObject(markupinfoversion); |
||
173 | } |
||
174 | _entity.DeleteObject(markupinfo); |
||
175 | } |
||
176 | _entity.SaveChanges(); |
||
177 | } |
||
178 | catch (Exception ex) |
||
179 | { |
||
180 | 195f079d | taeseongkim | result = "deleteobject error:" + ex.ToString(); |
181 | d21e9c15 | taeseongkim | } |
182 | 195f079d | taeseongkim | |
183 | } |
||
184 | else |
||
185 | d21e9c15 | taeseongkim | { |
186 | doc.REVISION = rev_No; |
||
187 | doc.ORIGINAL_FILE = document_Url; |
||
188 | doc.GROUP_NO = group_No; |
||
189 | doc.DOCUMENT_NO = document_No; |
||
190 | doc.DOCUMENT_NAME = document_Name; |
||
191 | 195f079d | taeseongkim | } |
192 | } |
||
193 | else |
||
194 | d21e9c15 | taeseongkim | { |
195 | _entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
||
196 | { |
||
197 | ID = document_Id, |
||
198 | REVISION = rev_No, |
||
199 | DOCUMENT_NO = document_No, |
||
200 | DOCUMENT_NAME = document_Name, |
||
201 | GROUP_NO = group_No, |
||
202 | ORIGINAL_FILE = document_Url, |
||
203 | DOCUMENT_ID = _doc_id, |
||
204 | PROJECT_NO = prj_No, |
||
205 | 195f079d | taeseongkim | }); |
206 | d21e9c15 | taeseongkim | } |
207 | |||
208 | _entity.SaveChanges(); |
||
209 | |||
210 | using (KCOMEntities _kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
211 | { |
||
212 | _kcomEntity.AddToCONVERTER_DOC(new CONVERTER_DOC |
||
213 | { |
||
214 | ID = _id, |
||
215 | CREATE_DATETIME = DateTime.Now, |
||
216 | DOCUMENT_URL = document_Url, |
||
217 | PROJECT_NO = prj_No, |
||
218 | DOCUMENT_ID = _doc_id, |
||
219 | }); |
||
220 | _kcomEntity.SaveChanges(); |
||
221 | } |
||
222 | |||
223 | 195f079d | taeseongkim | try |
224 | d21e9c15 | taeseongkim | { |
225 | 195f079d | taeseongkim | System.Net.WebClient client = new System.Net.WebClient(); |
226 | var convertResult = client.DownloadString($"{Properties.Settings.Default.MARKUS_V3_ADDRESS}/Rest/ConvertAdd?ProjectNo={prj_No}&ConvertID={_id}"); |
||
227 | d21e9c15 | taeseongkim | |
228 | 195f079d | taeseongkim | JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings()); |
229 | result = jObject["ConvertAddResult"].ToString(); |
||
230 | d21e9c15 | taeseongkim | } |
231 | 195f079d | taeseongkim | catch (Exception ex) |
232 | d21e9c15 | taeseongkim | { |
233 | 195f079d | taeseongkim | result = $"Markus V3 Connect Error {ex.Message}"; |
234 | d21e9c15 | taeseongkim | } |
235 | } |
||
236 | |||
237 | return result; |
||
238 | } |
||
239 | 195f079d | taeseongkim | //private string SendKcom(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url, string ignoreComment) |
240 | //{ |
||
241 | // string result = false.ToString(); |
||
242 | |||
243 | // if (remObj == null) |
||
244 | // { |
||
245 | // result = "Window Service Connection Error"; |
||
246 | // } |
||
247 | // else |
||
248 | // { |
||
249 | // //string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
||
250 | // string _id = shortGuid(); |
||
251 | // string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
||
252 | |||
253 | // using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
254 | // { |
||
255 | // if (string.IsNullOrEmpty(group_No)) |
||
256 | // { |
||
257 | // group_No = "0"; |
||
258 | // } |
||
259 | // if (!document_Url.Contains("http%3a%2f%2f")) |
||
260 | // { |
||
261 | // document_Url = Base64Decode(document_Url); |
||
262 | // document_Url = HttpUtility.UrlEncodeUnicode(document_Url); |
||
263 | // } |
||
264 | // document_Name = Base64DecodeFromStr(document_Name); |
||
265 | // var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
||
266 | // if (doc != null) |
||
267 | // { |
||
268 | // if (bool.Parse(ignoreComment)) |
||
269 | // { |
||
270 | // try |
||
271 | // { |
||
272 | // var docinfo = _entity.DOCINFO.Where(x => x.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
||
273 | // var markupinfos = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo.ID).ToList(); |
||
274 | // foreach (var markupinfo in markupinfos) |
||
275 | // { |
||
276 | // var markupinfoversions = _entity.MARKUP_INFO_VERSION.Where(x => x.MARKUPINFO_ID == markupinfo.ID).ToList(); |
||
277 | // foreach (var markupinfoversion in markupinfoversions) |
||
278 | // { |
||
279 | // var markupdatas = _entity.MARKUP_DATA.Where(x => x.MARKUPINFO_VERSION_ID == markupinfoversion.ID).ToList(); |
||
280 | // foreach (var markupdata in markupdatas) |
||
281 | // { |
||
282 | // _entity.DeleteObject(markupdata); |
||
283 | // } |
||
284 | // _entity.DeleteObject(markupinfoversion); |
||
285 | // } |
||
286 | // _entity.DeleteObject(markupinfo); |
||
287 | // } |
||
288 | // _entity.SaveChanges(); |
||
289 | // } |
||
290 | // catch (Exception ex) |
||
291 | // { |
||
292 | // result = "deleteobject error:"+ex.ToString(); |
||
293 | // } |
||
294 | |||
295 | // }else |
||
296 | // { |
||
297 | // doc.REVISION = rev_No; |
||
298 | // doc.ORIGINAL_FILE = document_Url; |
||
299 | // doc.GROUP_NO = group_No; |
||
300 | // doc.DOCUMENT_NO = document_No; |
||
301 | // doc.DOCUMENT_NAME = document_Name; |
||
302 | // } |
||
303 | // }else |
||
304 | // { |
||
305 | // _entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
||
306 | // { |
||
307 | // ID = document_Id, |
||
308 | // REVISION = rev_No, |
||
309 | // DOCUMENT_NO = document_No, |
||
310 | // DOCUMENT_NAME = document_Name, |
||
311 | // GROUP_NO = group_No, |
||
312 | // ORIGINAL_FILE = document_Url, |
||
313 | // DOCUMENT_ID = _doc_id, |
||
314 | // PROJECT_NO = prj_No, |
||
315 | // }); |
||
316 | // } |
||
317 | |||
318 | // _entity.SaveChanges(); |
||
319 | |||
320 | // using (KCOMEntities _kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
321 | // { |
||
322 | // _kcomEntity.AddToCONVERTER_DOC(new CONVERTER_DOC |
||
323 | // { |
||
324 | // ID = _id, |
||
325 | // CREATE_DATETIME = DateTime.Now, |
||
326 | // DOCUMENT_URL = document_Url, |
||
327 | // PROJECT_NO = prj_No, |
||
328 | // DOCUMENT_ID = _doc_id, |
||
329 | // }); |
||
330 | // _kcomEntity.SaveChanges(); |
||
331 | // } |
||
332 | // } |
||
333 | |||
334 | // if (Properties.Settings.Default.MARKUS_V3_PROJECTS.Split(',').Contains(prj_No)) |
||
335 | // { |
||
336 | // try |
||
337 | // { |
||
338 | // System.Net.WebClient client = new System.Net.WebClient(); |
||
339 | // var convertResult = client.DownloadString($"{Properties.Settings.Default.MARKUS_V3_ADDRESS}/Rest/ConvertAdd?ProjectNo={prj_No}&ConvertID={_id}"); |
||
340 | |||
341 | // JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings()); |
||
342 | // result = jObject["ConvertAddResult"].ToString(); |
||
343 | // } |
||
344 | // catch (Exception ex) |
||
345 | // { |
||
346 | // result = $"Markus V3 Connect Error {ex.Message}"; |
||
347 | // } |
||
348 | // } |
||
349 | // else |
||
350 | // { |
||
351 | // var convertResult = remObj.SetConverterPDF(prj_No, _id); |
||
352 | |||
353 | // if (convertResult.Exception != null) |
||
354 | // { |
||
355 | // result = false.ToString(); |
||
356 | // } |
||
357 | // else |
||
358 | // { |
||
359 | // result = true.ToString(); |
||
360 | // } |
||
361 | // } |
||
362 | |||
363 | // } |
||
364 | |||
365 | // return result; |
||
366 | //} |
||
367 | //[WebMethod] |
||
368 | //public string ManualConvert(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
||
369 | //{ |
||
370 | // string _result = null; |
||
371 | // try |
||
372 | // { |
||
373 | // using (KCOMEntities deepViewEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
374 | // { |
||
375 | // //_result = ConnectStringBuilder.DeepViewConnectionString().ToString(); |
||
376 | // //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber && DateTime.Parse(r.RUN_DATETIME)<= DateTime.Now); |
||
377 | // //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber); |
||
378 | // var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO != null); |
||
379 | |||
380 | // if (_RunProjects.Count() > 0) |
||
381 | // { |
||
382 | // _result = ManualSendKcom(rev_No, document_No, document_Name, group_No, prj_No, document_Id, document_Url); |
||
383 | // } |
||
384 | // else |
||
385 | // { |
||
386 | // _result = false.ToString(); |
||
387 | // } |
||
388 | // } |
||
389 | // } |
||
390 | // catch (Exception ex) |
||
391 | // { |
||
392 | // logger.Error("Conversion Web Service ManualConvert Error", ex); |
||
393 | // _result = ex.Message.ToString(); |
||
394 | // SendNotice("Project NO : " + prj_No + "\r\n DocumentUrl : " + document_Url + "\r\n Error" + ex.ToString()); |
||
395 | // } |
||
396 | // return _result; |
||
397 | //} |
||
398 | d21e9c15 | taeseongkim | [WebMethod] |
399 | public string UpdateUrlEncode(string EnsembleId) |
||
400 | { |
||
401 | string _result = null; |
||
402 | try |
||
403 | { |
||
404 | using (CIEntities deepViewEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
405 | { |
||
406 | var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
||
407 | string url = doc.ORIGINAL_FILE; |
||
408 | if (url.Contains("http://")) |
||
409 | { |
||
410 | //기존 url 이 인코딩 안되 있으면 인코딩 작업. |
||
411 | url = HttpUtility.UrlEncodeUnicode(url); |
||
412 | doc.ORIGINAL_FILE = url; |
||
413 | using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
414 | { |
||
415 | var convertdoc = kcomEntity.CONVERTER_DOC.Where(d => d.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
||
416 | |||
417 | if (convertdoc != null) |
||
418 | convertdoc.DOCUMENT_URL = url; |
||
419 | |||
420 | var docinfo = deepViewEntity.DOCINFO.Where(d => d.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
||
421 | if (docinfo != null) |
||
422 | docinfo.ORIGINAL_FILE = url; |
||
423 | |||
424 | } |
||
425 | } |
||
426 | |||
427 | deepViewEntity.SaveChanges(); |
||
428 | } |
||
429 | } |
||
430 | catch (Exception ex) |
||
431 | { |
||
432 | logger.Error("Conversion Web Service UpdateUrlEncode Error", ex); |
||
433 | _result = ex.Message.ToString(); |
||
434 | } |
||
435 | return _result; |
||
436 | } |
||
437 | public string Base64DecodeFromStr(string data) |
||
438 | { |
||
439 | try |
||
440 | { |
||
441 | System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); |
||
442 | System.Text.Decoder utf8Decode = encoder.GetDecoder(); |
||
443 | |||
444 | byte[] todecode_byte = Convert.FromBase64String(data); |
||
445 | |||
446 | int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); |
||
447 | |||
448 | char[] decoded_char = new char[charCount]; |
||
449 | |||
450 | utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); |
||
451 | |||
452 | string result = new String(decoded_char); |
||
453 | |||
454 | return result; |
||
455 | } |
||
456 | catch (Exception) |
||
457 | { |
||
458 | return data; |
||
459 | } |
||
460 | } |
||
461 | public string Base64Decode(string data) |
||
462 | { |
||
463 | try |
||
464 | { |
||
465 | if(data.Contains("http://")) |
||
466 | { |
||
467 | return data; |
||
468 | }else |
||
469 | { |
||
470 | System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); |
||
471 | System.Text.Decoder utf8Decode = encoder.GetDecoder(); |
||
472 | |||
473 | byte[] todecode_byte = Convert.FromBase64String(data); |
||
474 | |||
475 | int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); |
||
476 | |||
477 | char[] decoded_char = new char[charCount]; |
||
478 | |||
479 | utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); |
||
480 | |||
481 | string result = new String(decoded_char); |
||
482 | |||
483 | return result; |
||
484 | } |
||
485 | |||
486 | |||
487 | } |
||
488 | |||
489 | catch (Exception e) |
||
490 | { |
||
491 | throw new Exception("Error in Base64Decode: " + e.Message); |
||
492 | } |
||
493 | } |
||
494 | [WebMethod] |
||
495 | public string UpdateSlip(string EnsembleId, string SlipNo, string slipLink) |
||
496 | { |
||
497 | string _result = null; |
||
498 | try |
||
499 | { |
||
500 | using (CIEntities deepViewEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
501 | { |
||
502 | var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
||
503 | if(!string.IsNullOrEmpty(slipLink)) |
||
504 | doc.GROUP_NO = SlipNo; |
||
505 | if(!string.IsNullOrEmpty(slipLink)) |
||
506 | { |
||
507 | if (!slipLink.Contains("http://")) |
||
508 | slipLink = Base64Decode(slipLink); |
||
509 | throw new Exception("doc.ENSEMBLEINFO_URL not support"); |
||
510 | //doc.ENSEMBLEINFO_URL = slipLink; |
||
511 | } |
||
512 | |||
513 | deepViewEntity.SaveChanges(); |
||
514 | } |
||
515 | } |
||
516 | catch (Exception ex) |
||
517 | { |
||
518 | logger.Error($"Conversion Web Service UpdateSlip Error EnsembleId : {EnsembleId} SlipNo : {SlipNo} slipLink: {slipLink}", ex); |
||
519 | _result = ex.Message.ToString(); |
||
520 | } |
||
521 | return _result; |
||
522 | } |
||
523 | [WebMethod] |
||
524 | public string UpdateResult(string EnsembleId, string Result, string FinalPDFUrl) |
||
525 | { |
||
526 | string _result = null; |
||
527 | try |
||
528 | { |
||
529 | using (CIEntities deepViewEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
530 | { |
||
531 | var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
||
532 | doc.RESULT = Result; |
||
533 | doc.RESULT_FILE = FinalPDFUrl; |
||
534 | deepViewEntity.SaveChanges(); |
||
535 | } |
||
536 | } |
||
537 | catch (Exception ex) |
||
538 | { |
||
539 | logger.Error("Conversion Web Service UpdateResult Error", ex); |
||
540 | _result = ex.Message.ToString(); |
||
541 | } |
||
542 | return _result; |
||
543 | } |
||
544 | [WebMethod] |
||
545 | public string UpdateVP(string EnsembleId, string rev_No, string document_No, string document_Name, string pdf_url) |
||
546 | { |
||
547 | string _result = null; |
||
548 | try |
||
549 | { |
||
550 | using (CIEntities deepViewEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
551 | { |
||
552 | var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
||
553 | if(!string.IsNullOrEmpty(rev_No)) |
||
554 | doc.REVISION = rev_No; |
||
555 | if (!string.IsNullOrEmpty(document_No)) |
||
556 | doc.DOCUMENT_NO = document_No; |
||
557 | if (!string.IsNullOrEmpty(document_Name)) |
||
558 | doc.DOCUMENT_NAME = document_Name; |
||
559 | if (!string.IsNullOrEmpty(pdf_url)) |
||
560 | { |
||
561 | string url = pdf_url; |
||
562 | if (!doc.PROJECT_NO.Equals("150128")) |
||
563 | { |
||
564 | url = HttpUtility.UrlEncodeUnicode(url); |
||
565 | } |
||
566 | doc.ORIGINAL_FILE = url; |
||
567 | } |
||
568 | deepViewEntity.SaveChanges(); |
||
569 | } |
||
570 | } |
||
571 | catch (Exception ex) |
||
572 | { |
||
573 | logger.Error("Conversion Web Service UpdateVP Error", ex); |
||
574 | _result = ex.Message.ToString(); |
||
575 | } |
||
576 | return _result; |
||
577 | } |
||
578 | [WebMethod] |
||
579 | public string UpdatePDFUrl(string EnsembleId, string original_url, string result_url) |
||
580 | { |
||
581 | string _result = null; |
||
582 | try |
||
583 | { |
||
584 | using (CIEntities _kcomEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
585 | { |
||
586 | var doc = _kcomEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
||
587 | |||
588 | if (!string.IsNullOrEmpty(original_url)) |
||
589 | { |
||
590 | string url = original_url; |
||
591 | url = Base64Decode(url); |
||
592 | url = HttpUtility.UrlEncodeUnicode(url); |
||
593 | doc.ORIGINAL_FILE = url; |
||
594 | } |
||
595 | if (!string.IsNullOrEmpty(result_url)) |
||
596 | { |
||
597 | doc.RESULT_FILE = result_url; |
||
598 | } |
||
599 | _kcomEntity.SaveChanges(); |
||
600 | _result = true.ToString(); |
||
601 | } |
||
602 | } |
||
603 | catch (Exception ex) |
||
604 | { |
||
605 | logger.Error("Conversion Web Service UpdateVP Error", ex); |
||
606 | _result = ex.Message.ToString(); |
||
607 | } |
||
608 | return _result; |
||
609 | } |
||
610 | |||
611 | [WebMethod] |
||
612 | public string DeleteVP(string id) |
||
613 | { |
||
614 | string _result = null; |
||
615 | try |
||
616 | { |
||
617 | using (CIEntities _kcomEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
618 | { |
||
619 | var doc = _kcomEntity.DOCUMENT_ITEM.Where(data => data.ID == id).FirstOrDefault(); |
||
620 | |||
621 | if (doc != null) |
||
622 | { |
||
623 | doc.DOCUMENT_NO = "VOID_" + doc.DOCUMENT_NO; |
||
624 | doc.GROUP_NO = "VOID_" + doc.GROUP_NO; |
||
625 | //deepViewEntity.DeleteObject(doc); |
||
626 | _kcomEntity.SaveChanges(); |
||
627 | _result = true.ToString(); |
||
628 | } |
||
629 | else |
||
630 | _result = "document not found."; |
||
631 | } |
||
632 | } |
||
633 | catch (Exception ex) |
||
634 | { |
||
635 | logger.Error("Conversion Web Service DeleteVP Error", ex); |
||
636 | _result = ex.Message.ToString(); |
||
637 | } |
||
638 | return _result; |
||
639 | } |
||
640 | public string getDocumentID(string id) |
||
641 | { |
||
642 | string _doc_id = ((UInt32)id.GetHashCode()).ToString(); |
||
643 | return _doc_id; |
||
644 | } |
||
645 | 195f079d | taeseongkim | //[WebMethod] |
646 | //public string CoverConvert(string prj_No, string _id) |
||
647 | //{ |
||
648 | // string _result = null; |
||
649 | // try |
||
650 | // { |
||
651 | // SendCoverConvert(prj_No, _id); |
||
652 | // } |
||
653 | // catch (Exception ex) |
||
654 | // { |
||
655 | // logger.Error("Conversion Web Service CoverConvert Error", ex); |
||
656 | // _result = ex.Message.ToString(); |
||
657 | // } |
||
658 | // return _result; |
||
659 | //} |
||
660 | //private string SendCoverConvert(string prj_No, string _id) |
||
661 | //{ |
||
662 | // if (remObj == null) |
||
663 | // { |
||
664 | // return "Window Service Connection Error"; |
||
665 | // } |
||
666 | // else |
||
667 | // { |
||
668 | // var _result = remObj.SetConverterCoverPDF(prj_No, _id); |
||
669 | |||
670 | // if (_result.Exception != null) |
||
671 | // { |
||
672 | // return false.ToString(); |
||
673 | // } |
||
674 | // else |
||
675 | // { |
||
676 | // return true.ToString(); |
||
677 | // } |
||
678 | // } |
||
679 | //} |
||
680 | d21e9c15 | taeseongkim | |
681 | private string SendKcom(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
||
682 | { |
||
683 | string result = false.ToString(); |
||
684 | |||
685 | 195f079d | taeseongkim | //string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
686 | string _id = shortGuid(); |
||
687 | string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
||
688 | using (CIEntities _kcomEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
689 | d21e9c15 | taeseongkim | { |
690 | 195f079d | taeseongkim | if (string.IsNullOrEmpty(group_No)) |
691 | d21e9c15 | taeseongkim | { |
692 | 195f079d | taeseongkim | group_No = "0"; |
693 | d21e9c15 | taeseongkim | } |
694 | 195f079d | taeseongkim | if (!document_Url.Contains("http%3a%2f%2f")) |
695 | d21e9c15 | taeseongkim | { |
696 | 195f079d | taeseongkim | document_Url = Base64Decode(document_Url); |
697 | document_Url = System.Net.WebUtility.UrlEncode(document_Url); |
||
698 | d21e9c15 | taeseongkim | } |
699 | 195f079d | taeseongkim | document_Name = Base64DecodeFromStr(document_Name); |
700 | d21e9c15 | taeseongkim | |
701 | 195f079d | taeseongkim | var doc = _kcomEntity.DOCUMENT_ITEM.Where(d => d.PROJECT_NO == prj_No && d.ID == document_Id).FirstOrDefault(); |
702 | if (doc != null) |
||
703 | { |
||
704 | doc.DOCUMENT_ID = _doc_id; |
||
705 | doc.REVISION = rev_No; |
||
706 | doc.GROUP_NO = group_No; |
||
707 | doc.DOCUMENT_NO = document_No; |
||
708 | doc.DOCUMENT_NAME = document_Name; |
||
709 | doc.ORIGINAL_FILE = document_Url; |
||
710 | d21e9c15 | taeseongkim | } |
711 | 195f079d | taeseongkim | else |
712 | d21e9c15 | taeseongkim | { |
713 | 195f079d | taeseongkim | _kcomEntity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
714 | d21e9c15 | taeseongkim | { |
715 | ID = document_Id, |
||
716 | REVISION = rev_No, |
||
717 | DOCUMENT_NO = document_No, |
||
718 | DOCUMENT_NAME = document_Name, |
||
719 | GROUP_NO = group_No, |
||
720 | 195f079d | taeseongkim | ORIGINAL_FILE = document_Url, |
721 | d21e9c15 | taeseongkim | DOCUMENT_ID = _doc_id, |
722 | PROJECT_NO = prj_No, |
||
723 | }); |
||
724 | 195f079d | taeseongkim | } |
725 | d21e9c15 | taeseongkim | |
726 | 195f079d | taeseongkim | _kcomEntity.SaveChanges(); |
727 | d21e9c15 | taeseongkim | |
728 | 195f079d | taeseongkim | using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
729 | { |
||
730 | _entity.AddToCONVERTER_DOC(new CONVERTER_DOC |
||
731 | d21e9c15 | taeseongkim | { |
732 | 195f079d | taeseongkim | ID = _id, |
733 | CREATE_DATETIME = DateTime.Now, |
||
734 | DOCUMENT_URL = document_Url, |
||
735 | PROJECT_NO = prj_No, |
||
736 | DOCUMENT_ID = _doc_id, |
||
737 | }); |
||
738 | d21e9c15 | taeseongkim | |
739 | 195f079d | taeseongkim | _entity.SaveChanges(); |
740 | d21e9c15 | taeseongkim | } |
741 | 195f079d | taeseongkim | } |
742 | d21e9c15 | taeseongkim | |
743 | 195f079d | taeseongkim | |
744 | try |
||
745 | { |
||
746 | System.Net.WebClient client = new System.Net.WebClient(); |
||
747 | var convertResult = client.DownloadString($"{Properties.Settings.Default.MARKUS_V3_ADDRESS}/Rest/ConvertAdd?ProjectNo={prj_No}&ConvertID={_id}"); |
||
748 | |||
749 | JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings()); |
||
750 | result = jObject["ConvertAddResult"].ToString(); |
||
751 | d21e9c15 | taeseongkim | } |
752 | 195f079d | taeseongkim | catch (Exception ex) |
753 | { |
||
754 | logger.Error("Conversion Web Service SendKcom Error", ex); |
||
755 | result = $"Markus V3 Connect Error {ex.Message}"; |
||
756 | } |
||
757 | |||
758 | |||
759 | return result; |
||
760 | d21e9c15 | taeseongkim | } |
761 | |||
762 | 195f079d | taeseongkim | //private string SendKcom(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
763 | //{ |
||
764 | // string result = false.ToString(); |
||
765 | |||
766 | // if (remObj == null) |
||
767 | // { |
||
768 | // result = "Window Service Connection Error"; |
||
769 | // } |
||
770 | // else |
||
771 | // { |
||
772 | // //string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
||
773 | // string _id = shortGuid(); |
||
774 | // string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
||
775 | // using (CIEntities _kcomEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
776 | // { |
||
777 | // if (string.IsNullOrEmpty(group_No)) |
||
778 | // { |
||
779 | // group_No = "0"; |
||
780 | // } |
||
781 | // if (!document_Url.Contains("http%3a%2f%2f")) |
||
782 | // { |
||
783 | // document_Url = Base64Decode(document_Url); |
||
784 | // document_Url = System.Net.WebUtility.UrlEncode(document_Url); |
||
785 | // } |
||
786 | // document_Name = Base64DecodeFromStr(document_Name); |
||
787 | |||
788 | // var doc = _kcomEntity.DOCUMENT_ITEM.Where(d => d.PROJECT_NO == prj_No && d.ID == document_Id).FirstOrDefault(); |
||
789 | // if (doc != null) |
||
790 | // { |
||
791 | // doc.DOCUMENT_ID = _doc_id; |
||
792 | // doc.REVISION = rev_No; |
||
793 | // doc.GROUP_NO = group_No; |
||
794 | // doc.DOCUMENT_NO = document_No; |
||
795 | // doc.DOCUMENT_NAME = document_Name; |
||
796 | // doc.ORIGINAL_FILE = document_Url; |
||
797 | // } |
||
798 | // else |
||
799 | // { |
||
800 | // _kcomEntity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
||
801 | // { |
||
802 | // ID = document_Id, |
||
803 | // REVISION = rev_No, |
||
804 | // DOCUMENT_NO = document_No, |
||
805 | // DOCUMENT_NAME = document_Name, |
||
806 | // GROUP_NO = group_No, |
||
807 | // ORIGINAL_FILE = document_Url, |
||
808 | // DOCUMENT_ID = _doc_id, |
||
809 | // PROJECT_NO = prj_No, |
||
810 | // }); |
||
811 | // } |
||
812 | |||
813 | // _kcomEntity.SaveChanges(); |
||
814 | |||
815 | // using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
816 | // { |
||
817 | // _entity.AddToCONVERTER_DOC(new CONVERTER_DOC |
||
818 | // { |
||
819 | // ID = _id, |
||
820 | // CREATE_DATETIME = DateTime.Now, |
||
821 | // DOCUMENT_URL = document_Url, |
||
822 | // PROJECT_NO = prj_No, |
||
823 | // DOCUMENT_ID = _doc_id, |
||
824 | // }); |
||
825 | |||
826 | // _entity.SaveChanges(); |
||
827 | // } |
||
828 | // } |
||
829 | |||
830 | // if (Properties.Settings.Default.MARKUS_V3_PROJECTS.Split(',').Contains(prj_No)) |
||
831 | // { |
||
832 | // try |
||
833 | // { |
||
834 | // System.Net.WebClient client = new System.Net.WebClient(); |
||
835 | // var convertResult = client.DownloadString($"{Properties.Settings.Default.MARKUS_V3_ADDRESS}/Rest/ConvertAdd?ProjectNo={prj_No}&ConvertID={_id}"); |
||
836 | |||
837 | // JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings()); |
||
838 | // result = jObject["ConvertAddResult"].ToString(); |
||
839 | // } |
||
840 | // catch (Exception ex) |
||
841 | // { |
||
842 | // logger.Error("Conversion Web Service SendKcom Error", ex); |
||
843 | // result = $"Markus V3 Connect Error {ex.Message}"; |
||
844 | // } |
||
845 | // } |
||
846 | // else |
||
847 | // { |
||
848 | // var convertResult = remObj.SetConverterPDF(prj_No, _id); |
||
849 | |||
850 | // if (convertResult.Exception != null) |
||
851 | // { |
||
852 | // result = false.ToString(); |
||
853 | // } |
||
854 | // else |
||
855 | // { |
||
856 | // result = true.ToString(); |
||
857 | // } |
||
858 | // } |
||
859 | |||
860 | // } |
||
861 | |||
862 | // return result; |
||
863 | //} |
||
864 | |||
865 | //private string ManualSendKcom(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
||
866 | //{ |
||
867 | // if (remObj == null) |
||
868 | // { |
||
869 | // return "Window Service Connection Error"; |
||
870 | // } |
||
871 | // else |
||
872 | // { |
||
873 | // //string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
||
874 | // string _id = shortGuid(); |
||
875 | // string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
||
876 | // using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
877 | // { |
||
878 | // var doc = _entity.DOCUMENT_ITEM.Where(d =>d.PROJECT_NO == prj_No && d.ID == document_Id).FirstOrDefault(); |
||
879 | |||
880 | // if (doc != null) |
||
881 | // { |
||
882 | // using (KCOMEntities kCOMEntities = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
883 | // { |
||
884 | // var converterdoc = kCOMEntities.CONVERTER_DOC.Where(c => c.PROJECT_NO == doc.PROJECT_NO && c.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
||
885 | // _entity.DeleteObject(converterdoc); |
||
886 | // _entity.DeleteObject(doc); |
||
887 | // _entity.SaveChanges(); |
||
888 | // } |
||
889 | |||
890 | // document_Url = HttpUtility.UrlDecode(document_Url); |
||
891 | // } |
||
892 | |||
893 | // int cnt = _entity.DOCUMENT_ITEM.ToList().Count; |
||
894 | // if (string.IsNullOrEmpty(group_No)) |
||
895 | // { |
||
896 | // group_No = "0"; |
||
897 | // } |
||
898 | |||
899 | // _entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
||
900 | // { |
||
901 | // ID = document_Id, |
||
902 | // REVISION = rev_No, |
||
903 | // DOCUMENT_NO = document_No, |
||
904 | // DOCUMENT_NAME = document_Name, |
||
905 | // GROUP_NO = group_No, |
||
906 | // ORIGINAL_FILE = HttpUtility.UrlEncodeUnicode(document_Url), |
||
907 | // DOCUMENT_ID = _doc_id, |
||
908 | // PROJECT_NO = prj_No, |
||
909 | // }); |
||
910 | |||
911 | // _entity.SaveChanges(); |
||
912 | |||
913 | // using (KCOMEntities kCOMEntities = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
914 | // { |
||
915 | // kCOMEntities.AddToCONVERTER_DOC(new CONVERTER_DOC |
||
916 | // { |
||
917 | // ID = _id, |
||
918 | // CREATE_DATETIME = DateTime.Now, |
||
919 | // DOCUMENT_URL = HttpUtility.UrlEncodeUnicode(document_Url), |
||
920 | // PROJECT_NO = prj_No, |
||
921 | // DOCUMENT_ID = _doc_id, |
||
922 | // }); |
||
923 | |||
924 | // kCOMEntities.SaveChanges(); |
||
925 | // } |
||
926 | // } |
||
927 | // var _result = remObj.SetConverterPDF(prj_No, _id); |
||
928 | |||
929 | // if (_result.Exception != null) |
||
930 | // { |
||
931 | // return false.ToString(); |
||
932 | // } |
||
933 | // else |
||
934 | // { |
||
935 | // return true.ToString(); |
||
936 | // } |
||
937 | // } |
||
938 | //} |
||
939 | |||
940 | d21e9c15 | taeseongkim | //private Guid GetGuid(int Count,Guid ID) |
941 | //{ |
||
942 | // Guid _ID = ID; |
||
943 | // string _id = _ID.ToString(); |
||
944 | // DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString()); |
||
945 | |||
946 | // if (_entity.CONVERTER_DOC.Where(c => c.ID == _id).Count() > 0) |
||
947 | // { |
||
948 | // _entity.Dispose(); |
||
949 | |||
950 | // if (Count > 10) |
||
951 | // { |
||
952 | // new Exception("GetGuid : Not Generator"); |
||
953 | // } |
||
954 | |||
955 | // if (Count < 3) |
||
956 | // { |
||
957 | // System.Threading.Thread.Sleep(3); |
||
958 | // } |
||
959 | |||
960 | // GetGuid(Count++,GuidGenerator.GetUniqueGuid()); |
||
961 | // } |
||
962 | |||
963 | // return ID; |
||
964 | //} |
||
965 | |||
966 | //GUID생성(최민수 사원 수정) |
||
967 | public string shortGuid() |
||
968 | { |
||
969 | byte[] bytes = new byte[16]; |
||
970 | using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create()) |
||
971 | { |
||
972 | provider.GetBytes(bytes); |
||
973 | } |
||
974 | |||
975 | var guid = new Guid(bytes); |
||
976 | |||
977 | return Convert.ToBase64String(guid.ToByteArray()) |
||
978 | .Substring(0, 10) |
||
979 | .Replace("/", "") |
||
980 | .Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x"); |
||
981 | } |
||
982 | |||
983 | [WebMethod] |
||
984 | public string ExcelExport(string project_no, string slip_no) |
||
985 | { |
||
986 | string _result = "false"; |
||
987 | //FileInfo fileInfo2 = new FileInfo(Path.GetTempFileName()); |
||
988 | //fileInfo2.FullName |
||
989 | try |
||
990 | { |
||
991 | // Excel 첫번째 워크시트 가져오기 |
||
992 | //application = new Excel.Application(); |
||
993 | //workbook = application.Workbooks.Open(xlsxfilepath); |
||
994 | //worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item("Sheet1"); |
||
995 | string xlsxfilepath = @"C:\WebSite\LogView\Doc_Manager\sample.xlsx"; |
||
996 | GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("EXK0-W4HZ-N518-IMEW"); |
||
997 | GemBox.Spreadsheet.ExcelFile excelFile = new GemBox.Spreadsheet.ExcelFile(); |
||
998 | excelFile.LoadXlsx(xlsxfilepath, GemBox.Spreadsheet.XlsxOptions.PreserveMakeCopy); |
||
999 | GemBox.Spreadsheet.ExcelWorksheet ws = excelFile.Worksheets[0]; |
||
1000 | FileInfo fileInfo2 = new FileInfo(Path.GetTempFileName().Replace(".tmp", ".xlsx")); |
||
1001 | |||
1002 | string fileout = @"C:\WebSite\LogView\Doc_Manager\commentexcel_" + DateTime.Now.ToString() + ".xlsx"; |
||
1003 | string naspath = Properties.Settings.Default.Excelfilepath; |
||
1004 | //@"\\172.20.121.220\comment3\TileSource\Excelexport"; |
||
1005 | |||
1006 | // 데이타 넣기 |
||
1007 | int h = 6; |
||
1008 | int w = 1; |
||
1009 | |||
1010 | |||
1011 | //필터 기능 추가 |
||
1012 | //Excel.Range Filter_Range = worksheet.Range["B9:" + Ran + "9"]; |
||
1013 | //Filter_Range.AutoFilter(1, Type.Missing, Excel.XlAutoFilterOperator.xlAnd, Type.Missing, true); |
||
1014 | |||
1015 | using (CIEntities deepViewEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("").ToString())) |
||
1016 | { |
||
1017 | var docs = deepViewEntity.DOCUMENT_ITEM.Where(doc => doc.GROUP_NO == slip_no && doc.PROJECT_NO == project_no).ToList(); |
||
1018 | if (docs.Count > 0) |
||
1019 | { |
||
1020 | foreach (var doc in docs) |
||
1021 | { |
||
1022 | var commentlist = deepViewEntity.MARKUP_DATA.Where(d => d.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO.DOCUMENT_ID == doc.DOCUMENT_ID |
||
1023 | && d.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1).ToList(); |
||
1024 | |||
1025 | string docNo = doc.DOCUMENT_NO; |
||
1026 | string docDesc = doc.DOCUMENT_NAME; |
||
1027 | string docRev = doc.REVISION; |
||
1028 | foreach (var comment in commentlist) |
||
1029 | { |
||
1030 | var member = deepViewEntity.MEMBER.Where(m => m.ID == comment.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID).FirstOrDefault(); |
||
1031 | string docdept = member.DEPARTMENT; |
||
1032 | string doccomment = string.Empty; |
||
1033 | var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(comment.DATA.ToString(),null).ConfigureAwait(false).GetAwaiter().GetResult(); |
||
1034 | switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), comment.DATA_TYPE.ToString())) |
||
1035 | { |
||
1036 | case MarkupToPDF.Controls.Common.ControlType.TextControl: |
||
1037 | case MarkupToPDF.Controls.Common.ControlType.TextBorder: |
||
1038 | case MarkupToPDF.Controls.Common.ControlType.TextCloud: |
||
1039 | { |
||
1040 | MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data); |
||
1041 | doccomment = instance.Text; |
||
1042 | } |
||
1043 | break; |
||
1044 | case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl: |
||
1045 | case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl: |
||
1046 | case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl: |
||
1047 | case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl: |
||
1048 | case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl: |
||
1049 | case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl: |
||
1050 | { |
||
1051 | MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data); |
||
1052 | doccomment = instance.ArrowText; |
||
1053 | } |
||
1054 | break; |
||
1055 | } |
||
1056 | ws.Cells[h, w].Value = string.Format("{0}\n({1})", docNo, docDesc); |
||
1057 | ws.Cells[h, w + 1].Value = docRev; |
||
1058 | ws.Cells[h, w + 2].Value = docdept; |
||
1059 | ws.Cells[h, w + 3].Value = doccomment; |
||
1060 | h++; |
||
1061 | } |
||
1062 | } |
||
1063 | } |
||
1064 | else |
||
1065 | { |
||
1066 | _result = "ERROR : 해당 Slip 의 데이터가 없습니다."; |
||
1067 | } |
||
1068 | |||
1069 | |||
1070 | } |
||
1071 | |||
1072 | int columnCount = ws.CalculateMaxUsedColumns(); |
||
1073 | for (int i = 0; i < columnCount; i++) |
||
1074 | ws.Columns[i].AutoFit(); |
||
1075 | //worksheet.Columns.AutoFit(); |
||
1076 | // 엑셀파일 저장 |
||
1077 | |||
1078 | excelFile.Save(fileInfo2.FullName); |
||
1079 | fileInfo2.MoveTo(naspath + "\\" + fileInfo2.Name); |
||
1080 | //workbook.SaveAs(fileout); |
||
1081 | ////workbook.Save(); |
||
1082 | //workbook.Close(true); |
||
1083 | //application.Quit(); |
||
1084 | _result = Properties.Settings.Default.Excelresulturl + fileInfo2.Name; |
||
1085 | } |
||
1086 | catch (Exception e) |
||
1087 | { |
||
1088 | _result = "ERROR : " + e.ToString(); |
||
1089 | } |
||
1090 | return _result; |
||
1091 | } |
||
1092 | |||
1093 | private static void ReleaseExcelObject(object obj) |
||
1094 | { |
||
1095 | try |
||
1096 | { |
||
1097 | if (obj != null) |
||
1098 | { |
||
1099 | obj = null; |
||
1100 | } |
||
1101 | } |
||
1102 | catch (Exception ex) |
||
1103 | { |
||
1104 | obj = null; |
||
1105 | throw ex; |
||
1106 | } |
||
1107 | finally |
||
1108 | { |
||
1109 | GC.Collect(); |
||
1110 | } |
||
1111 | } |
||
1112 | } |
||
1113 | } |