markus / ConvertService / ServiceBase / ConvertionWebService / Conversion.asmx.cs @ 8f3829bd
이력 | 보기 | 이력해설 | 다운로드 (35.3 KB)
1 | 53c9637d | taeseongkim | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Web; |
||
5 | using System.Web.Services; |
||
6 | using System.Runtime.Remoting.Channels; |
||
7 | using System.Runtime.Remoting.Channels.Tcp; |
||
8 | using IConverterPDF; |
||
9 | using System.Text; |
||
10 | using DeepViewDataModel.DataModel; |
||
11 | using DeepViewDataModel.Common; |
||
12 | using DeepView.Toolkit.GuidGenerator; |
||
13 | using MarkupToPDF; |
||
14 | using System.IO; |
||
15 | using Newtonsoft.Json; |
||
16 | using Newtonsoft.Json.Linq; |
||
17 | using log4net; |
||
18 | |||
19 | namespace ConvertionWebService |
||
20 | { |
||
21 | /// <summary> |
||
22 | /// Summary description for Conversio |
||
23 | /// </summary> |
||
24 | [WebService(Namespace = "http://tempuri.org/")] |
||
25 | [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] |
||
26 | [System.ComponentModel.ToolboxItem(false)] |
||
27 | public class Conversion : System.Web.Services.WebService |
||
28 | { |
||
29 | |||
30 | RemConverterPDFObject remObj = null; |
||
31 | protected ILog logger = LogManager.GetLogger(typeof(Conversion)); |
||
32 | public Conversion() |
||
33 | { |
||
34 | try |
||
35 | { |
||
36 | System.Runtime.Remoting.Channels.IChannel _ch = ChannelServices.GetChannel("tcp"); |
||
37 | |||
38 | if(_ch == null) |
||
39 | { |
||
40 | TcpChannel chan = new TcpChannel(); |
||
41 | ChannelServices.RegisterChannel(chan, false); |
||
42 | } |
||
43 | // Create an instance of the remote object |
||
44 | remObj = (RemConverterPDFObject)Activator.GetObject(typeof(RemConverterPDFObject), |
||
45 | Properties.Settings.Default.ConverterRemotingUrl); |
||
46 | |||
47 | } |
||
48 | catch (Exception ex) |
||
49 | { |
||
50 | dbc1e5b6 | taeseongkim | logger.Error("Conversion Web Service Conversion Error", ex); |
51 | 53c9637d | taeseongkim | SendNotice(ex.ToString()); |
52 | } |
||
53 | } |
||
54 | |||
55 | private void SendNotice(string ex) |
||
56 | { |
||
57 | if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.ErrorNoticeID)) |
||
58 | { |
||
59 | var _lstID = Properties.Settings.Default.ErrorNoticeID.Split(';').ToList(); |
||
60 | //EmailClient.EmailClient _client = new EmailClient.EmailClient(_lstID.First()); |
||
61 | StringBuilder _bl = new StringBuilder(); |
||
62 | _bl.AppendLine("Conversion Web Service Error"); |
||
63 | _bl.AppendLine(ex); |
||
64 | //var _emailResult = _client.SendEmail(_lstID, _lstID, "<Conversion Web Service Error>", _bl.ToString(), false); |
||
65 | } |
||
66 | else |
||
67 | { |
||
68 | logger.Error("Conversion Web Service Error",new Exception(ex)); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | [WebMethod] |
||
73 | public string ConvertRun(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
||
74 | { |
||
75 | string _result = null; |
||
76 | try |
||
77 | { |
||
78 | cdfb57ff | taeseongkim | 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}"); |
79 | |||
80 | 53c9637d | taeseongkim | using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
81 | { |
||
82 | //_result = ConnectStringBuilder.DeepViewConnectionString().ToString(); |
||
83 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber && DateTime.Parse(r.RUN_DATETIME)<= DateTime.Now); |
||
84 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber); |
||
85 | var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO != null); |
||
86 | |||
87 | if (_RunProjects.Count() > 0) |
||
88 | { |
||
89 | _result = SendKcom(rev_No, document_No, document_Name, group_No, prj_No, document_Id, document_Url); |
||
90 | } |
||
91 | else |
||
92 | { |
||
93 | _result = false.ToString(); |
||
94 | } |
||
95 | } |
||
96 | } |
||
97 | catch (Exception ex) |
||
98 | { |
||
99 | cdfb57ff | taeseongkim | 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); |
100 | 53c9637d | taeseongkim | _result = ex.Message.ToString(); |
101 | SendNotice("Project NO : " + prj_No + "\r\n DocumentUrl : " + document_Url + "\r\n Error" + ex.ToString()); |
||
102 | } |
||
103 | return _result; |
||
104 | } |
||
105 | |||
106 | [WebMethod] |
||
107 | 41fa3d98 | djkim | 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) |
108 | { |
||
109 | string _result = null; |
||
110 | try |
||
111 | { |
||
112 | using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
||
113 | { |
||
114 | //_result = ConnectStringBuilder.DeepViewConnectionString().ToString(); |
||
115 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber && DateTime.Parse(r.RUN_DATETIME)<= DateTime.Now); |
||
116 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber); |
||
117 | var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO != null); |
||
118 | |||
119 | if (_RunProjects.Count() > 0) |
||
120 | { |
||
121 | _result = SendKcom(rev_No, document_No, document_Name, group_No, prj_No, document_Id, document_Url,ignoreComment); |
||
122 | } |
||
123 | else |
||
124 | { |
||
125 | _result = false.ToString(); |
||
126 | } |
||
127 | } |
||
128 | } |
||
129 | catch (Exception ex) |
||
130 | { |
||
131 | _result = ex.Message.ToString(); |
||
132 | SendNotice("Project NO : " + prj_No + "\r\n DocumentUrl : " + document_Url + "\r\n Error" + ex.ToString()); |
||
133 | } |
||
134 | return _result; |
||
135 | } |
||
136 | |||
137 | 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) |
||
138 | { |
||
139 | string result = false.ToString(); |
||
140 | |||
141 | if (remObj == null) |
||
142 | { |
||
143 | result = "Window Service Connection Error"; |
||
144 | } |
||
145 | else |
||
146 | { |
||
147 | //string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
||
148 | string _id = shortGuid(); |
||
149 | string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
||
150 | |||
151 | using (DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
||
152 | { |
||
153 | 3c71b3a5 | taeseongkim | if (string.IsNullOrEmpty(group_No)) |
154 | { |
||
155 | group_No = "0"; |
||
156 | } |
||
157 | if (!prj_No.Equals("150128")) |
||
158 | { |
||
159 | //Omsk 는 웹서비스 호출 시 인코딩 |
||
160 | //Omsk 제외는 Markus 에서 인코딩 |
||
161 | e3fe2bd4 | djkim | if(!document_Url.Contains("http%3a%2f%2f")) |
162 | { |
||
163 | document_Url = Base64Decode(document_Url); |
||
164 | document_Url = HttpUtility.UrlEncodeUnicode(document_Url); |
||
165 | } |
||
166 | 3c71b3a5 | taeseongkim | } |
167 | 41fa3d98 | djkim | var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
168 | if (doc != null) |
||
169 | { |
||
170 | if (bool.Parse(ignoreComment)) |
||
171 | { |
||
172 | try |
||
173 | { |
||
174 | var docinfo = _entity.DOCINFO.Where(x => x.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
||
175 | var markupinfos = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo.ID).ToList(); |
||
176 | foreach (var markupinfo in markupinfos) |
||
177 | { |
||
178 | var markupinfoversions = _entity.MARKUP_INFO_VERSION.Where(x => x.MARKUPINFO_ID == markupinfo.ID).ToList(); |
||
179 | foreach (var markupinfoversion in markupinfoversions) |
||
180 | { |
||
181 | var markupdatas = _entity.MARKUP_DATA.Where(x => x.MARKUPINFO_VERSION_ID == markupinfoversion.ID).ToList(); |
||
182 | foreach (var markupdata in markupdatas) |
||
183 | { |
||
184 | _entity.DeleteObject(markupdata); |
||
185 | } |
||
186 | _entity.DeleteObject(markupinfoversion); |
||
187 | } |
||
188 | _entity.DeleteObject(markupinfo); |
||
189 | } |
||
190 | _entity.SaveChanges(); |
||
191 | } |
||
192 | catch (Exception ex) |
||
193 | { |
||
194 | result = "deleteobject error:"+ex.ToString(); |
||
195 | } |
||
196 | |||
197 | 3c71b3a5 | taeseongkim | }else |
198 | { |
||
199 | doc.REVISION = rev_No; |
||
200 | doc.ORIGINAL_FILE = document_Url; |
||
201 | doc.GROUP_NO = group_No; |
||
202 | doc.DOCUMENT_NO = document_No; |
||
203 | doc.DOCUMENT_NAME = document_Name; |
||
204 | } |
||
205 | }else |
||
206 | { |
||
207 | _entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
||
208 | { |
||
209 | ID = document_Id, |
||
210 | REVISION = rev_No, |
||
211 | DOCUMENT_NO = document_No, |
||
212 | DOCUMENT_NAME = document_Name, |
||
213 | GROUP_NO = group_No, |
||
214 | ORIGINAL_FILE = document_Url, |
||
215 | DOCUMENT_ID = _doc_id, |
||
216 | PROJECT_NO = prj_No, |
||
217 | }); |
||
218 | } |
||
219 | |||
220 | 41fa3d98 | djkim | _entity.AddToCONVERTER_DOC(new CONVERTER_DOC |
221 | { |
||
222 | ID = _id, |
||
223 | CREATE_DATETIME = DateTime.Now, |
||
224 | DOCUMENT_URL = document_Url, |
||
225 | PROJECT_NO = prj_No, |
||
226 | DOCUMENT_ID = _doc_id, |
||
227 | }); |
||
228 | _entity.SaveChanges(); |
||
229 | } |
||
230 | |||
231 | if (Properties.Settings.Default.MARKUS_V3_PROJECTS.Split(',').Contains(prj_No)) |
||
232 | { |
||
233 | try |
||
234 | { |
||
235 | System.Net.WebClient client = new System.Net.WebClient(); |
||
236 | var convertResult = client.DownloadString($"{Properties.Settings.Default.MARKUS_V3_ADDRESS}/Rest/ConvertAdd?ProjectNo={prj_No}&DocumentID={_id}"); |
||
237 | |||
238 | JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings()); |
||
239 | result = jObject["ConvertAddResult"].ToString(); |
||
240 | } |
||
241 | catch (Exception ex) |
||
242 | { |
||
243 | result = $"Markus V3 Connect Error {ex.Message}"; |
||
244 | } |
||
245 | } |
||
246 | else |
||
247 | { |
||
248 | var convertResult = remObj.SetConverterPDF(prj_No, _id); |
||
249 | |||
250 | if (convertResult.Exception != null) |
||
251 | { |
||
252 | result = false.ToString(); |
||
253 | } |
||
254 | else |
||
255 | { |
||
256 | result = true.ToString(); |
||
257 | } |
||
258 | } |
||
259 | |||
260 | } |
||
261 | |||
262 | return result; |
||
263 | } |
||
264 | [WebMethod] |
||
265 | 53c9637d | taeseongkim | public string ManualConvert(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
266 | { |
||
267 | string _result = null; |
||
268 | try |
||
269 | { |
||
270 | using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
||
271 | { |
||
272 | //_result = ConnectStringBuilder.DeepViewConnectionString().ToString(); |
||
273 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber && DateTime.Parse(r.RUN_DATETIME)<= DateTime.Now); |
||
274 | //var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber); |
||
275 | var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO != null); |
||
276 | |||
277 | if (_RunProjects.Count() > 0) |
||
278 | { |
||
279 | _result = ManualSendKcom(rev_No, document_No, document_Name, group_No, prj_No, document_Id, document_Url); |
||
280 | } |
||
281 | else |
||
282 | { |
||
283 | _result = false.ToString(); |
||
284 | } |
||
285 | } |
||
286 | } |
||
287 | catch (Exception ex) |
||
288 | { |
||
289 | dbc1e5b6 | taeseongkim | logger.Error("Conversion Web Service ManualConvert Error", ex); |
290 | 53c9637d | taeseongkim | _result = ex.Message.ToString(); |
291 | SendNotice("Project NO : " + prj_No + "\r\n DocumentUrl : " + document_Url + "\r\n Error" + ex.ToString()); |
||
292 | } |
||
293 | return _result; |
||
294 | } |
||
295 | [WebMethod] |
||
296 | public string UpdateUrlEncode(string EnsembleId) |
||
297 | { |
||
298 | string _result = null; |
||
299 | try |
||
300 | { |
||
301 | using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
||
302 | { |
||
303 | var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
||
304 | string url = doc.ORIGINAL_FILE; |
||
305 | if (url.Contains("http://")) |
||
306 | { |
||
307 | //기존 url 이 인코딩 안되 있으면 인코딩 작업. |
||
308 | url = HttpUtility.UrlEncodeUnicode(url); |
||
309 | doc.ORIGINAL_FILE = url; |
||
310 | |||
311 | var convertdoc = deepViewEntity.CONVERTER_DOC.Where(d => d.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
||
312 | if(convertdoc != null) |
||
313 | convertdoc.DOCUMENT_URL = url; |
||
314 | var docinfo = deepViewEntity.DOCINFO.Where(d => d.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
||
315 | if(docinfo != null) |
||
316 | docinfo.ORIGINAL_FILE = url; |
||
317 | } |
||
318 | |||
319 | deepViewEntity.SaveChanges(); |
||
320 | } |
||
321 | } |
||
322 | catch (Exception ex) |
||
323 | { |
||
324 | dbc1e5b6 | taeseongkim | logger.Error("Conversion Web Service UpdateUrlEncode Error", ex); |
325 | 53c9637d | taeseongkim | _result = ex.Message.ToString(); |
326 | } |
||
327 | return _result; |
||
328 | } |
||
329 | public string Base64Decode(string data) |
||
330 | { |
||
331 | try |
||
332 | { |
||
333 | 4d009db9 | djkim | if(data.Contains("http://")) |
334 | { |
||
335 | return data; |
||
336 | }else |
||
337 | { |
||
338 | System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); |
||
339 | System.Text.Decoder utf8Decode = encoder.GetDecoder(); |
||
340 | 53c9637d | taeseongkim | |
341 | 4d009db9 | djkim | byte[] todecode_byte = Convert.FromBase64String(data); |
342 | 53c9637d | taeseongkim | |
343 | 4d009db9 | djkim | int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); |
344 | 53c9637d | taeseongkim | |
345 | 4d009db9 | djkim | char[] decoded_char = new char[charCount]; |
346 | 53c9637d | taeseongkim | |
347 | 4d009db9 | djkim | utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); |
348 | 53c9637d | taeseongkim | |
349 | 4d009db9 | djkim | string result = new String(decoded_char); |
350 | 53c9637d | taeseongkim | |
351 | 4d009db9 | djkim | return result; |
352 | } |
||
353 | |||
354 | 53c9637d | taeseongkim | |
355 | } |
||
356 | |||
357 | catch (Exception e) |
||
358 | { |
||
359 | throw new Exception("Error in Base64Decode: " + e.Message); |
||
360 | } |
||
361 | } |
||
362 | [WebMethod] |
||
363 | public string UpdateSlip(string EnsembleId, string SlipNo, string slipLink) |
||
364 | { |
||
365 | string _result = null; |
||
366 | try |
||
367 | { |
||
368 | using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
||
369 | { |
||
370 | var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
||
371 | if(!string.IsNullOrEmpty(slipLink)) |
||
372 | doc.GROUP_NO = SlipNo; |
||
373 | if(!string.IsNullOrEmpty(slipLink)) |
||
374 | { |
||
375 | if (!slipLink.Contains("http://")) |
||
376 | slipLink = Base64Decode(slipLink); |
||
377 | doc.ENSEMBLEINFO_URL = slipLink; |
||
378 | } |
||
379 | |||
380 | deepViewEntity.SaveChanges(); |
||
381 | } |
||
382 | } |
||
383 | catch (Exception ex) |
||
384 | { |
||
385 | cdfb57ff | taeseongkim | logger.Error($"Conversion Web Service UpdateSlip Error EnsembleId : {EnsembleId} SlipNo : {SlipNo} slipLink: {slipLink}", ex); |
386 | 53c9637d | taeseongkim | _result = ex.Message.ToString(); |
387 | } |
||
388 | return _result; |
||
389 | } |
||
390 | [WebMethod] |
||
391 | public string UpdateResult(string EnsembleId, string Result, string FinalPDFUrl) |
||
392 | { |
||
393 | string _result = null; |
||
394 | try |
||
395 | { |
||
396 | using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
||
397 | { |
||
398 | var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
||
399 | doc.RESULT = Result; |
||
400 | doc.RESULT_FILE = FinalPDFUrl; |
||
401 | deepViewEntity.SaveChanges(); |
||
402 | } |
||
403 | } |
||
404 | catch (Exception ex) |
||
405 | { |
||
406 | dbc1e5b6 | taeseongkim | logger.Error("Conversion Web Service UpdateResult Error", ex); |
407 | 53c9637d | taeseongkim | _result = ex.Message.ToString(); |
408 | } |
||
409 | return _result; |
||
410 | } |
||
411 | [WebMethod] |
||
412 | 41fa3d98 | djkim | public string UpdateVP(string EnsembleId, string rev_No, string document_No, string document_Name, string pdf_url) |
413 | 53c9637d | taeseongkim | { |
414 | string _result = null; |
||
415 | try |
||
416 | { |
||
417 | using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
||
418 | { |
||
419 | var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
||
420 | if(!string.IsNullOrEmpty(rev_No)) |
||
421 | doc.REVISION = rev_No; |
||
422 | if (!string.IsNullOrEmpty(document_No)) |
||
423 | doc.DOCUMENT_NO = document_No; |
||
424 | if (!string.IsNullOrEmpty(document_Name)) |
||
425 | doc.DOCUMENT_NAME = document_Name; |
||
426 | 41fa3d98 | djkim | if (!string.IsNullOrEmpty(pdf_url)) |
427 | { |
||
428 | string url = pdf_url; |
||
429 | if (!doc.PROJECT_NO.Equals("150128")) |
||
430 | { |
||
431 | url = HttpUtility.UrlEncodeUnicode(url); |
||
432 | } |
||
433 | doc.ORIGINAL_FILE = url; |
||
434 | } |
||
435 | 53c9637d | taeseongkim | deepViewEntity.SaveChanges(); |
436 | } |
||
437 | } |
||
438 | catch (Exception ex) |
||
439 | { |
||
440 | dbc1e5b6 | taeseongkim | logger.Error("Conversion Web Service UpdateVP Error", ex); |
441 | 53c9637d | taeseongkim | _result = ex.Message.ToString(); |
442 | } |
||
443 | return _result; |
||
444 | } |
||
445 | [WebMethod] |
||
446 | public string CoverConvert(string prj_No, string _id) |
||
447 | { |
||
448 | string _result = null; |
||
449 | try |
||
450 | { |
||
451 | SendCoverConvert(prj_No, _id); |
||
452 | } |
||
453 | catch (Exception ex) |
||
454 | { |
||
455 | dbc1e5b6 | taeseongkim | logger.Error("Conversion Web Service CoverConvert Error", ex); |
456 | 53c9637d | taeseongkim | _result = ex.Message.ToString(); |
457 | } |
||
458 | return _result; |
||
459 | } |
||
460 | private string SendCoverConvert(string prj_No, string _id) |
||
461 | { |
||
462 | if (remObj == null) |
||
463 | { |
||
464 | return "Window Service Connection Error"; |
||
465 | } |
||
466 | else |
||
467 | { |
||
468 | var _result = remObj.SetConverterCoverPDF(prj_No, _id); |
||
469 | |||
470 | if (_result.Exception != null) |
||
471 | { |
||
472 | return false.ToString(); |
||
473 | } |
||
474 | else |
||
475 | { |
||
476 | return true.ToString(); |
||
477 | } |
||
478 | } |
||
479 | } |
||
480 | private string SendKcom(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
||
481 | { |
||
482 | string result = false.ToString(); |
||
483 | |||
484 | if (remObj == null) |
||
485 | { |
||
486 | result = "Window Service Connection Error"; |
||
487 | } |
||
488 | else |
||
489 | { |
||
490 | //string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
||
491 | string _id = shortGuid(); |
||
492 | string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
||
493 | using (DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
||
494 | 3c71b3a5 | taeseongkim | { |
495 | if (string.IsNullOrEmpty(group_No)) |
||
496 | 53c9637d | taeseongkim | { |
497 | group_No = "0"; |
||
498 | } |
||
499 | if (!prj_No.Equals("150128")) |
||
500 | { |
||
501 | //Omsk 는 웹서비스 호출 시 인코딩 |
||
502 | //Omsk 제외는 Markus 에서 인코딩 |
||
503 | e3fe2bd4 | djkim | if (!document_Url.Contains("http%3a%2f%2f")) |
504 | { |
||
505 | document_Url = Base64Decode(document_Url); |
||
506 | document_Url = HttpUtility.UrlEncodeUnicode(document_Url); |
||
507 | } |
||
508 | 53c9637d | taeseongkim | } |
509 | 3c71b3a5 | taeseongkim | var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
510 | if(doc != null) |
||
511 | 53c9637d | taeseongkim | { |
512 | 4d009db9 | djkim | doc.REVISION = rev_No; |
513 | 3c71b3a5 | taeseongkim | doc.GROUP_NO = group_No; |
514 | doc.DOCUMENT_NO = document_No; |
||
515 | 4d009db9 | djkim | doc.DOCUMENT_NAME = document_Name; |
516 | doc.ORIGINAL_FILE = document_Url; |
||
517 | } |
||
518 | else |
||
519 | { |
||
520 | 3c71b3a5 | taeseongkim | _entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
521 | { |
||
522 | ID = document_Id, |
||
523 | REVISION = rev_No, |
||
524 | DOCUMENT_NO = document_No, |
||
525 | DOCUMENT_NAME = document_Name, |
||
526 | GROUP_NO = group_No, |
||
527 | ORIGINAL_FILE = document_Url, |
||
528 | DOCUMENT_ID = _doc_id, |
||
529 | PROJECT_NO = prj_No, |
||
530 | }); |
||
531 | } |
||
532 | |||
533 | 53c9637d | taeseongkim | _entity.AddToCONVERTER_DOC(new CONVERTER_DOC |
534 | { |
||
535 | ID = _id, |
||
536 | CREATE_DATETIME = DateTime.Now, |
||
537 | DOCUMENT_URL = document_Url, |
||
538 | PROJECT_NO = prj_No, |
||
539 | DOCUMENT_ID = _doc_id, |
||
540 | }); |
||
541 | _entity.SaveChanges(); |
||
542 | } |
||
543 | |||
544 | if (Properties.Settings.Default.MARKUS_V3_PROJECTS.Split(',').Contains(prj_No)) |
||
545 | { |
||
546 | try |
||
547 | { |
||
548 | System.Net.WebClient client = new System.Net.WebClient(); |
||
549 | var convertResult = client.DownloadString($"{Properties.Settings.Default.MARKUS_V3_ADDRESS}/Rest/ConvertAdd?ProjectNo={prj_No}&DocumentID={_id}"); |
||
550 | |||
551 | JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings()); |
||
552 | result = jObject["ConvertAddResult"].ToString(); |
||
553 | } |
||
554 | catch (Exception ex) |
||
555 | { |
||
556 | dbc1e5b6 | taeseongkim | logger.Error("Conversion Web Service SendKcom Error", ex); |
557 | 53c9637d | taeseongkim | result = $"Markus V3 Connect Error {ex.Message}"; |
558 | } |
||
559 | } |
||
560 | else |
||
561 | { |
||
562 | var convertResult = remObj.SetConverterPDF(prj_No, _id); |
||
563 | |||
564 | if (convertResult.Exception != null) |
||
565 | { |
||
566 | result = false.ToString(); |
||
567 | } |
||
568 | else |
||
569 | { |
||
570 | result = true.ToString(); |
||
571 | } |
||
572 | } |
||
573 | |||
574 | } |
||
575 | |||
576 | return result; |
||
577 | } |
||
578 | 41fa3d98 | djkim | |
579 | 53c9637d | taeseongkim | private string ManualSendKcom(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
580 | { |
||
581 | if (remObj == null) |
||
582 | { |
||
583 | return "Window Service Connection Error"; |
||
584 | } |
||
585 | else |
||
586 | { |
||
587 | //string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
||
588 | string _id = shortGuid(); |
||
589 | string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
||
590 | using (DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
||
591 | { |
||
592 | var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
||
593 | if (doc != null) |
||
594 | { |
||
595 | var converterdoc = _entity.CONVERTER_DOC.Where(c => c.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
||
596 | _entity.DeleteObject(converterdoc); |
||
597 | _entity.DeleteObject(doc); |
||
598 | _entity.SaveChanges(); |
||
599 | document_Url = HttpUtility.UrlDecode(document_Url); |
||
600 | } |
||
601 | int cnt = _entity.DOCUMENT_ITEM.ToList().Count; |
||
602 | if (string.IsNullOrEmpty(group_No)) |
||
603 | { |
||
604 | group_No = "0"; |
||
605 | } |
||
606 | |||
607 | _entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
||
608 | { |
||
609 | ID = document_Id, |
||
610 | REVISION = rev_No, |
||
611 | DOCUMENT_NO = document_No, |
||
612 | DOCUMENT_NAME = document_Name, |
||
613 | GROUP_NO = group_No, |
||
614 | ORIGINAL_FILE = HttpUtility.UrlEncodeUnicode(document_Url), |
||
615 | DOCUMENT_ID = _doc_id, |
||
616 | PROJECT_NO = prj_No, |
||
617 | }); |
||
618 | _entity.AddToCONVERTER_DOC(new CONVERTER_DOC |
||
619 | { |
||
620 | ID = _id, |
||
621 | CREATE_DATETIME = DateTime.Now, |
||
622 | DOCUMENT_URL = HttpUtility.UrlEncodeUnicode(document_Url), |
||
623 | PROJECT_NO = prj_No, |
||
624 | DOCUMENT_ID = _doc_id, |
||
625 | }); |
||
626 | _entity.SaveChanges(); |
||
627 | } |
||
628 | var _result = remObj.SetConverterPDF(prj_No, _id); |
||
629 | |||
630 | if (_result.Exception != null) |
||
631 | { |
||
632 | return false.ToString(); |
||
633 | } |
||
634 | else |
||
635 | { |
||
636 | return true.ToString(); |
||
637 | } |
||
638 | } |
||
639 | } |
||
640 | |||
641 | //private Guid GetGuid(int Count,Guid ID) |
||
642 | //{ |
||
643 | // Guid _ID = ID; |
||
644 | // string _id = _ID.ToString(); |
||
645 | // DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString()); |
||
646 | |||
647 | // if (_entity.CONVERTER_DOC.Where(c => c.ID == _id).Count() > 0) |
||
648 | // { |
||
649 | // _entity.Dispose(); |
||
650 | |||
651 | // if (Count > 10) |
||
652 | // { |
||
653 | // new Exception("GetGuid : Not Generator"); |
||
654 | // } |
||
655 | |||
656 | // if (Count < 3) |
||
657 | // { |
||
658 | // System.Threading.Thread.Sleep(3); |
||
659 | // } |
||
660 | |||
661 | // GetGuid(Count++,GuidGenerator.GetUniqueGuid()); |
||
662 | // } |
||
663 | |||
664 | // return ID; |
||
665 | //} |
||
666 | |||
667 | //GUID생성(최민수 사원 수정) |
||
668 | public string shortGuid() |
||
669 | { |
||
670 | byte[] bytes = new byte[16]; |
||
671 | using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create()) |
||
672 | { |
||
673 | provider.GetBytes(bytes); |
||
674 | } |
||
675 | |||
676 | var guid = new Guid(bytes); |
||
677 | |||
678 | return Convert.ToBase64String(guid.ToByteArray()) |
||
679 | .Substring(0, 10) |
||
680 | .Replace("/", "") |
||
681 | .Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x"); |
||
682 | } |
||
683 | |||
684 | [WebMethod] |
||
685 | 3c71b3a5 | taeseongkim | public string ExcelExport(string project_no, string slip_no) |
686 | 53c9637d | taeseongkim | { |
687 | string _result = "false"; |
||
688 | 3c71b3a5 | taeseongkim | //FileInfo fileInfo2 = new FileInfo(Path.GetTempFileName()); |
689 | //fileInfo2.FullName |
||
690 | 53c9637d | taeseongkim | try |
691 | { |
||
692 | // Excel 첫번째 워크시트 가져오기 |
||
693 | 3c71b3a5 | taeseongkim | //application = new Excel.Application(); |
694 | //workbook = application.Workbooks.Open(xlsxfilepath); |
||
695 | //worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item("Sheet1"); |
||
696 | string xlsxfilepath = @"C:\WebSite\LogView\Doc_Manager\sample.xlsx"; |
||
697 | GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("EXK0-W4HZ-N518-IMEW"); |
||
698 | GemBox.Spreadsheet.ExcelFile excelFile = new GemBox.Spreadsheet.ExcelFile(); |
||
699 | excelFile.LoadXlsx(xlsxfilepath, GemBox.Spreadsheet.XlsxOptions.PreserveMakeCopy); |
||
700 | GemBox.Spreadsheet.ExcelWorksheet ws = excelFile.Worksheets[0]; |
||
701 | FileInfo fileInfo2 = new FileInfo(Path.GetTempFileName().Replace(".tmp", ".xlsx")); |
||
702 | |||
703 | string fileout = @"C:\WebSite\LogView\Doc_Manager\commentexcel_" + DateTime.Now.ToString() + ".xlsx"; |
||
704 | string naspath = Properties.Settings.Default.Excelfilepath; |
||
705 | //@"\\172.20.121.220\comment3\TileSource\Excelexport"; |
||
706 | 53c9637d | taeseongkim | |
707 | // 데이타 넣기 |
||
708 | int h = 6; |
||
709 | 3c71b3a5 | taeseongkim | int w = 1; |
710 | 53c9637d | taeseongkim | |
711 | |||
712 | //필터 기능 추가 |
||
713 | //Excel.Range Filter_Range = worksheet.Range["B9:" + Ran + "9"]; |
||
714 | //Filter_Range.AutoFilter(1, Type.Missing, Excel.XlAutoFilterOperator.xlAnd, Type.Missing, true); |
||
715 | |||
716 | 3c71b3a5 | taeseongkim | |
717 | 53c9637d | taeseongkim | using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
718 | { |
||
719 | var docs = deepViewEntity.DOCUMENT_ITEM.Where(doc => doc.GROUP_NO == slip_no && doc.PROJECT_NO == project_no).ToList(); |
||
720 | 3c71b3a5 | taeseongkim | if (docs.Count > 0) |
721 | 53c9637d | taeseongkim | { |
722 | 3c71b3a5 | taeseongkim | foreach (var doc in docs) |
723 | 53c9637d | taeseongkim | { |
724 | 3c71b3a5 | taeseongkim | var commentlist = deepViewEntity.MARKUP_DATA.Where(d => d.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO.DOCUMENT_ID == doc.DOCUMENT_ID |
725 | && d.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1).ToList(); |
||
726 | |||
727 | string docNo = doc.DOCUMENT_NO; |
||
728 | string docDesc = doc.DOCUMENT_NAME; |
||
729 | string docRev = doc.REVISION; |
||
730 | foreach (var comment in commentlist) |
||
731 | 53c9637d | taeseongkim | { |
732 | 3c71b3a5 | taeseongkim | var member = deepViewEntity.MEMBER.Where(m => m.ID == comment.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID).FirstOrDefault(); |
733 | string docdept = member.DEPARTMENT; |
||
734 | string doccomment = string.Empty; |
||
735 | var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(comment.DATA.ToString()); |
||
736 | switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), comment.DATA_TYPE.ToString())) |
||
737 | { |
||
738 | case MarkupToPDF.Controls.Common.ControlType.TextControl: |
||
739 | case MarkupToPDF.Controls.Common.ControlType.TextBorder: |
||
740 | case MarkupToPDF.Controls.Common.ControlType.TextCloud: |
||
741 | { |
||
742 | MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data); |
||
743 | doccomment = instance.Text; |
||
744 | } |
||
745 | break; |
||
746 | case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl: |
||
747 | case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl: |
||
748 | case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl: |
||
749 | case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl: |
||
750 | case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl: |
||
751 | case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl: |
||
752 | { |
||
753 | MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data); |
||
754 | doccomment = instance.ArrowText; |
||
755 | } |
||
756 | break; |
||
757 | } |
||
758 | ws.Cells[h, w].Value = string.Format("{0}\n({1})", docNo, docDesc); |
||
759 | ws.Cells[h, w + 1].Value = docRev; |
||
760 | ws.Cells[h, w + 2].Value = docdept; |
||
761 | ws.Cells[h, w + 3].Value = doccomment; |
||
762 | h++; |
||
763 | 53c9637d | taeseongkim | } |
764 | } |
||
765 | } |
||
766 | 3c71b3a5 | taeseongkim | else |
767 | { |
||
768 | _result = "ERROR : 해당 Slip 의 데이터가 없습니다."; |
||
769 | } |
||
770 | 53c9637d | taeseongkim | |
771 | |||
772 | 3c71b3a5 | taeseongkim | } |
773 | |||
774 | int columnCount = ws.CalculateMaxUsedColumns(); |
||
775 | for (int i = 0; i < columnCount; i++) |
||
776 | ws.Columns[i].AutoFit(); |
||
777 | //worksheet.Columns.AutoFit(); |
||
778 | 53c9637d | taeseongkim | // 엑셀파일 저장 |
779 | 3c71b3a5 | taeseongkim | |
780 | excelFile.Save(fileInfo2.FullName); |
||
781 | fileInfo2.MoveTo(naspath + "\\" + fileInfo2.Name); |
||
782 | //workbook.SaveAs(fileout); |
||
783 | ////workbook.Save(); |
||
784 | //workbook.Close(true); |
||
785 | //application.Quit(); |
||
786 | _result = Properties.Settings.Default.Excelresulturl + fileInfo2.Name; |
||
787 | 53c9637d | taeseongkim | } |
788 | 3c71b3a5 | taeseongkim | catch (Exception e) |
789 | 53c9637d | taeseongkim | { |
790 | 3c71b3a5 | taeseongkim | _result = "ERROR : " + e.ToString(); |
791 | 53c9637d | taeseongkim | } |
792 | return _result; |
||
793 | } |
||
794 | |||
795 | private static void ReleaseExcelObject(object obj) |
||
796 | { |
||
797 | try |
||
798 | { |
||
799 | if (obj != null) |
||
800 | { |
||
801 | obj = null; |
||
802 | } |
||
803 | } |
||
804 | catch (Exception ex) |
||
805 | { |
||
806 | obj = null; |
||
807 | throw ex; |
||
808 | } |
||
809 | finally |
||
810 | { |
||
811 | GC.Collect(); |
||
812 | } |
||
813 | } |
||
814 | } |
||
815 | } |