markus / ConvertService / ServiceBase / ConvertionWebService / Conversion.asmx.cs @ 53c9637d
이력 | 보기 | 이력해설 | 다운로드 (25.1 KB)
1 |
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 Excel = Microsoft.Office.Interop.Excel; |
14 |
using MarkupToPDF; |
15 |
using System.IO; |
16 |
using Newtonsoft.Json; |
17 |
using Newtonsoft.Json.Linq; |
18 |
using log4net; |
19 |
|
20 |
namespace ConvertionWebService |
21 |
{ |
22 |
/// <summary> |
23 |
/// Summary description for Conversio |
24 |
/// </summary> |
25 |
[WebService(Namespace = "http://tempuri.org/")] |
26 |
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] |
27 |
[System.ComponentModel.ToolboxItem(false)] |
28 |
public class Conversion : System.Web.Services.WebService |
29 |
{ |
30 |
|
31 |
RemConverterPDFObject remObj = null; |
32 |
protected ILog logger = LogManager.GetLogger(typeof(Conversion)); |
33 |
public Conversion() |
34 |
{ |
35 |
try |
36 |
{ |
37 |
System.Runtime.Remoting.Channels.IChannel _ch = ChannelServices.GetChannel("tcp"); |
38 |
|
39 |
if(_ch == null) |
40 |
{ |
41 |
TcpChannel chan = new TcpChannel(); |
42 |
ChannelServices.RegisterChannel(chan, false); |
43 |
} |
44 |
// Create an instance of the remote object |
45 |
remObj = (RemConverterPDFObject)Activator.GetObject(typeof(RemConverterPDFObject), |
46 |
Properties.Settings.Default.ConverterRemotingUrl); |
47 |
|
48 |
} |
49 |
catch (Exception ex) |
50 |
{ |
51 |
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 |
using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
79 |
{ |
80 |
//_result = ConnectStringBuilder.DeepViewConnectionString().ToString(); |
81 |
//var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber && DateTime.Parse(r.RUN_DATETIME)<= DateTime.Now); |
82 |
//var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber); |
83 |
var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO != null); |
84 |
|
85 |
if (_RunProjects.Count() > 0) |
86 |
{ |
87 |
_result = SendKcom(rev_No, document_No, document_Name, group_No, prj_No, document_Id, document_Url); |
88 |
} |
89 |
else |
90 |
{ |
91 |
_result = false.ToString(); |
92 |
} |
93 |
} |
94 |
} |
95 |
catch (Exception ex) |
96 |
{ |
97 |
_result = ex.Message.ToString(); |
98 |
SendNotice("Project NO : " + prj_No + "\r\n DocumentUrl : " + document_Url + "\r\n Error" + ex.ToString()); |
99 |
} |
100 |
return _result; |
101 |
} |
102 |
|
103 |
[WebMethod] |
104 |
public string ManualConvert(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
105 |
{ |
106 |
string _result = null; |
107 |
try |
108 |
{ |
109 |
using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
110 |
{ |
111 |
//_result = ConnectStringBuilder.DeepViewConnectionString().ToString(); |
112 |
//var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber && DateTime.Parse(r.RUN_DATETIME)<= DateTime.Now); |
113 |
//var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO == projNumber); |
114 |
var _RunProjects = deepViewEntity.RUN_PROJECTS.Where(r => r.PROJECT_NO != null); |
115 |
|
116 |
if (_RunProjects.Count() > 0) |
117 |
{ |
118 |
_result = ManualSendKcom(rev_No, document_No, document_Name, group_No, prj_No, document_Id, document_Url); |
119 |
} |
120 |
else |
121 |
{ |
122 |
_result = false.ToString(); |
123 |
} |
124 |
} |
125 |
} |
126 |
catch (Exception ex) |
127 |
{ |
128 |
_result = ex.Message.ToString(); |
129 |
SendNotice("Project NO : " + prj_No + "\r\n DocumentUrl : " + document_Url + "\r\n Error" + ex.ToString()); |
130 |
} |
131 |
return _result; |
132 |
} |
133 |
[WebMethod] |
134 |
public string UpdateUrlEncode(string EnsembleId) |
135 |
{ |
136 |
string _result = null; |
137 |
try |
138 |
{ |
139 |
using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
140 |
{ |
141 |
var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
142 |
string url = doc.ORIGINAL_FILE; |
143 |
if (url.Contains("http://")) |
144 |
{ |
145 |
//기존 url 이 인코딩 안되 있으면 인코딩 작업. |
146 |
url = HttpUtility.UrlEncodeUnicode(url); |
147 |
doc.ORIGINAL_FILE = url; |
148 |
|
149 |
var convertdoc = deepViewEntity.CONVERTER_DOC.Where(d => d.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
150 |
if(convertdoc != null) |
151 |
convertdoc.DOCUMENT_URL = url; |
152 |
var docinfo = deepViewEntity.DOCINFO.Where(d => d.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
153 |
if(docinfo != null) |
154 |
docinfo.ORIGINAL_FILE = url; |
155 |
} |
156 |
|
157 |
deepViewEntity.SaveChanges(); |
158 |
} |
159 |
} |
160 |
catch (Exception ex) |
161 |
{ |
162 |
_result = ex.Message.ToString(); |
163 |
} |
164 |
return _result; |
165 |
} |
166 |
public string Base64Decode(string data) |
167 |
{ |
168 |
try |
169 |
{ |
170 |
|
171 |
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); |
172 |
System.Text.Decoder utf8Decode = encoder.GetDecoder(); |
173 |
|
174 |
byte[] todecode_byte = Convert.FromBase64String(data); |
175 |
|
176 |
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); |
177 |
|
178 |
char[] decoded_char = new char[charCount]; |
179 |
|
180 |
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); |
181 |
|
182 |
string result = new String(decoded_char); |
183 |
|
184 |
return result; |
185 |
|
186 |
} |
187 |
|
188 |
catch (Exception e) |
189 |
{ |
190 |
throw new Exception("Error in Base64Decode: " + e.Message); |
191 |
} |
192 |
} |
193 |
[WebMethod] |
194 |
public string UpdateSlip(string EnsembleId, string SlipNo, string slipLink) |
195 |
{ |
196 |
string _result = null; |
197 |
try |
198 |
{ |
199 |
using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
200 |
{ |
201 |
var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
202 |
if(!string.IsNullOrEmpty(slipLink)) |
203 |
doc.GROUP_NO = SlipNo; |
204 |
if(!string.IsNullOrEmpty(slipLink)) |
205 |
{ |
206 |
if (!slipLink.Contains("http://")) |
207 |
slipLink = Base64Decode(slipLink); |
208 |
doc.ENSEMBLEINFO_URL = slipLink; |
209 |
} |
210 |
|
211 |
deepViewEntity.SaveChanges(); |
212 |
} |
213 |
} |
214 |
catch (Exception ex) |
215 |
{ |
216 |
_result = ex.Message.ToString(); |
217 |
} |
218 |
return _result; |
219 |
} |
220 |
[WebMethod] |
221 |
public string UpdateResult(string EnsembleId, string Result, string FinalPDFUrl) |
222 |
{ |
223 |
string _result = null; |
224 |
try |
225 |
{ |
226 |
using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
227 |
{ |
228 |
var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
229 |
doc.RESULT = Result; |
230 |
doc.RESULT_FILE = FinalPDFUrl; |
231 |
deepViewEntity.SaveChanges(); |
232 |
} |
233 |
} |
234 |
catch (Exception ex) |
235 |
{ |
236 |
_result = ex.Message.ToString(); |
237 |
} |
238 |
return _result; |
239 |
} |
240 |
[WebMethod] |
241 |
public string UpdateVP(string EnsembleId, string rev_No, string document_No, string document_Name) |
242 |
{ |
243 |
string _result = null; |
244 |
try |
245 |
{ |
246 |
using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
247 |
{ |
248 |
var doc = deepViewEntity.DOCUMENT_ITEM.Where(data => data.ID == EnsembleId).FirstOrDefault(); |
249 |
if(!string.IsNullOrEmpty(rev_No)) |
250 |
doc.REVISION = rev_No; |
251 |
if (!string.IsNullOrEmpty(document_No)) |
252 |
doc.DOCUMENT_NO = document_No; |
253 |
if (!string.IsNullOrEmpty(document_Name)) |
254 |
doc.DOCUMENT_NAME = document_Name; |
255 |
deepViewEntity.SaveChanges(); |
256 |
} |
257 |
} |
258 |
catch (Exception ex) |
259 |
{ |
260 |
_result = ex.Message.ToString(); |
261 |
} |
262 |
return _result; |
263 |
} |
264 |
[WebMethod] |
265 |
public string CoverConvert(string prj_No, string _id) |
266 |
{ |
267 |
string _result = null; |
268 |
try |
269 |
{ |
270 |
SendCoverConvert(prj_No, _id); |
271 |
} |
272 |
catch (Exception ex) |
273 |
{ |
274 |
_result = ex.Message.ToString(); |
275 |
} |
276 |
return _result; |
277 |
} |
278 |
private string SendCoverConvert(string prj_No, string _id) |
279 |
{ |
280 |
if (remObj == null) |
281 |
{ |
282 |
return "Window Service Connection Error"; |
283 |
} |
284 |
else |
285 |
{ |
286 |
var _result = remObj.SetConverterCoverPDF(prj_No, _id); |
287 |
|
288 |
if (_result.Exception != null) |
289 |
{ |
290 |
return false.ToString(); |
291 |
} |
292 |
else |
293 |
{ |
294 |
return true.ToString(); |
295 |
} |
296 |
} |
297 |
} |
298 |
private string SendKcom(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
299 |
{ |
300 |
string result = false.ToString(); |
301 |
|
302 |
if (remObj == null) |
303 |
{ |
304 |
result = "Window Service Connection Error"; |
305 |
} |
306 |
else |
307 |
{ |
308 |
//string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
309 |
string _id = shortGuid(); |
310 |
string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
311 |
using (DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
312 |
{ |
313 |
var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
314 |
if(doc != null) |
315 |
{ |
316 |
var converterdoc = _entity.CONVERTER_DOC.Where(c => c.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
317 |
_entity.DeleteObject(converterdoc); |
318 |
_entity.DeleteObject(doc); |
319 |
_entity.SaveChanges(); |
320 |
document_Url = HttpUtility.UrlDecode(document_Url); |
321 |
} |
322 |
int cnt = _entity.DOCUMENT_ITEM.ToList().Count; |
323 |
if(string.IsNullOrEmpty(group_No)) |
324 |
{ |
325 |
group_No = "0"; |
326 |
} |
327 |
if (!prj_No.Equals("150128")) |
328 |
{ |
329 |
//Omsk 는 웹서비스 호출 시 인코딩 |
330 |
//Omsk 제외는 Markus 에서 인코딩 |
331 |
document_Url = HttpUtility.UrlEncodeUnicode(document_Url); |
332 |
} |
333 |
_entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
334 |
{ |
335 |
ID = document_Id, |
336 |
REVISION = rev_No, |
337 |
DOCUMENT_NO = document_No, |
338 |
DOCUMENT_NAME = document_Name, |
339 |
GROUP_NO = group_No, |
340 |
ORIGINAL_FILE = document_Url, |
341 |
DOCUMENT_ID = _doc_id, |
342 |
PROJECT_NO = prj_No, |
343 |
}); |
344 |
_entity.AddToCONVERTER_DOC(new CONVERTER_DOC |
345 |
{ |
346 |
ID = _id, |
347 |
CREATE_DATETIME = DateTime.Now, |
348 |
DOCUMENT_URL = document_Url, |
349 |
PROJECT_NO = prj_No, |
350 |
DOCUMENT_ID = _doc_id, |
351 |
}); |
352 |
_entity.SaveChanges(); |
353 |
} |
354 |
|
355 |
if (Properties.Settings.Default.MARKUS_V3_PROJECTS.Split(',').Contains(prj_No)) |
356 |
{ |
357 |
try |
358 |
{ |
359 |
System.Net.WebClient client = new System.Net.WebClient(); |
360 |
var convertResult = client.DownloadString($"{Properties.Settings.Default.MARKUS_V3_ADDRESS}/Rest/ConvertAdd?ProjectNo={prj_No}&DocumentID={_id}"); |
361 |
|
362 |
JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings()); |
363 |
result = jObject["ConvertAddResult"].ToString(); |
364 |
} |
365 |
catch (Exception ex) |
366 |
{ |
367 |
result = $"Markus V3 Connect Error {ex.Message}"; |
368 |
} |
369 |
} |
370 |
else |
371 |
{ |
372 |
var convertResult = remObj.SetConverterPDF(prj_No, _id); |
373 |
|
374 |
if (convertResult.Exception != null) |
375 |
{ |
376 |
result = false.ToString(); |
377 |
} |
378 |
else |
379 |
{ |
380 |
result = true.ToString(); |
381 |
} |
382 |
} |
383 |
|
384 |
} |
385 |
|
386 |
return result; |
387 |
} |
388 |
private string ManualSendKcom(string rev_No, string document_No, string document_Name, string group_No, string prj_No, string document_Id, string document_Url) |
389 |
{ |
390 |
if (remObj == null) |
391 |
{ |
392 |
return "Window Service Connection Error"; |
393 |
} |
394 |
else |
395 |
{ |
396 |
//string _id = GetGuid(0, GuidGenerator.GetUniqueGuid()).ToString(); |
397 |
string _id = shortGuid(); |
398 |
string _doc_id = ((UInt32)document_Id.GetHashCode()).ToString(); |
399 |
using (DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
400 |
{ |
401 |
var doc = _entity.DOCUMENT_ITEM.Where(d => d.ID == document_Id).FirstOrDefault(); |
402 |
if (doc != null) |
403 |
{ |
404 |
var converterdoc = _entity.CONVERTER_DOC.Where(c => c.DOCUMENT_ID == doc.DOCUMENT_ID).FirstOrDefault(); |
405 |
_entity.DeleteObject(converterdoc); |
406 |
_entity.DeleteObject(doc); |
407 |
_entity.SaveChanges(); |
408 |
document_Url = HttpUtility.UrlDecode(document_Url); |
409 |
} |
410 |
int cnt = _entity.DOCUMENT_ITEM.ToList().Count; |
411 |
if (string.IsNullOrEmpty(group_No)) |
412 |
{ |
413 |
group_No = "0"; |
414 |
} |
415 |
|
416 |
_entity.AddToDOCUMENT_ITEM(new DOCUMENT_ITEM |
417 |
{ |
418 |
ID = document_Id, |
419 |
REVISION = rev_No, |
420 |
DOCUMENT_NO = document_No, |
421 |
DOCUMENT_NAME = document_Name, |
422 |
GROUP_NO = group_No, |
423 |
ORIGINAL_FILE = HttpUtility.UrlEncodeUnicode(document_Url), |
424 |
DOCUMENT_ID = _doc_id, |
425 |
PROJECT_NO = prj_No, |
426 |
}); |
427 |
_entity.AddToCONVERTER_DOC(new CONVERTER_DOC |
428 |
{ |
429 |
ID = _id, |
430 |
CREATE_DATETIME = DateTime.Now, |
431 |
DOCUMENT_URL = HttpUtility.UrlEncodeUnicode(document_Url), |
432 |
PROJECT_NO = prj_No, |
433 |
DOCUMENT_ID = _doc_id, |
434 |
}); |
435 |
_entity.SaveChanges(); |
436 |
} |
437 |
var _result = remObj.SetConverterPDF(prj_No, _id); |
438 |
|
439 |
if (_result.Exception != null) |
440 |
{ |
441 |
return false.ToString(); |
442 |
} |
443 |
else |
444 |
{ |
445 |
return true.ToString(); |
446 |
} |
447 |
} |
448 |
} |
449 |
|
450 |
//private Guid GetGuid(int Count,Guid ID) |
451 |
//{ |
452 |
// Guid _ID = ID; |
453 |
// string _id = _ID.ToString(); |
454 |
// DeepView_Entity _entity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString()); |
455 |
|
456 |
// if (_entity.CONVERTER_DOC.Where(c => c.ID == _id).Count() > 0) |
457 |
// { |
458 |
// _entity.Dispose(); |
459 |
|
460 |
// if (Count > 10) |
461 |
// { |
462 |
// new Exception("GetGuid : Not Generator"); |
463 |
// } |
464 |
|
465 |
// if (Count < 3) |
466 |
// { |
467 |
// System.Threading.Thread.Sleep(3); |
468 |
// } |
469 |
|
470 |
// GetGuid(Count++,GuidGenerator.GetUniqueGuid()); |
471 |
// } |
472 |
|
473 |
// return ID; |
474 |
//} |
475 |
|
476 |
//GUID생성(최민수 사원 수정) |
477 |
public string shortGuid() |
478 |
{ |
479 |
byte[] bytes = new byte[16]; |
480 |
using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create()) |
481 |
{ |
482 |
provider.GetBytes(bytes); |
483 |
} |
484 |
|
485 |
var guid = new Guid(bytes); |
486 |
|
487 |
return Convert.ToBase64String(guid.ToByteArray()) |
488 |
.Substring(0, 10) |
489 |
.Replace("/", "") |
490 |
.Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x"); |
491 |
} |
492 |
|
493 |
[WebMethod] |
494 |
public string ExcelExport(string project_no,string slip_no) |
495 |
{ |
496 |
string _result = "false"; |
497 |
Excel.Application application = null; |
498 |
Excel.Workbook workbook = null; |
499 |
Excel.Worksheet worksheet = null; |
500 |
string xlsxfilepath = @"D:\sample.xlsx"; |
501 |
|
502 |
string fileout = @"D:\CommentExport_" + DateTime.Now.ToString() + ".xlsx"; |
503 |
|
504 |
try |
505 |
{ |
506 |
// Excel 첫번째 워크시트 가져오기 |
507 |
application = new Excel.Application(); |
508 |
workbook = application.Workbooks.Open(xlsxfilepath); |
509 |
worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item("Sheet1"); |
510 |
|
511 |
// 데이타 넣기 |
512 |
int h = 6; |
513 |
int w = 2; |
514 |
|
515 |
|
516 |
//필터 기능 추가 |
517 |
//Excel.Range Filter_Range = worksheet.Range["B9:" + Ran + "9"]; |
518 |
//Filter_Range.AutoFilter(1, Type.Missing, Excel.XlAutoFilterOperator.xlAnd, Type.Missing, true); |
519 |
|
520 |
|
521 |
using (DeepView_Entity deepViewEntity = new DeepView_Entity(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
522 |
{ |
523 |
var docs = deepViewEntity.DOCUMENT_ITEM.Where(doc => doc.GROUP_NO == slip_no && doc.PROJECT_NO == project_no).ToList(); |
524 |
foreach(var doc in docs) |
525 |
{ |
526 |
var commentlist = deepViewEntity.MARKUP_DATA.Where(d => d.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO.DOCUMENT_ID == doc.DOCUMENT_ID |
527 |
&& d.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1).ToList(); |
528 |
|
529 |
string docNo = doc.DOCUMENT_NO; |
530 |
string docDesc = doc.DOCUMENT_NAME; |
531 |
string docRev = doc.REVISION; |
532 |
foreach(var comment in commentlist) |
533 |
{ |
534 |
var member = deepViewEntity.MEMBER.Where(m => m.ID == comment.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID).FirstOrDefault(); |
535 |
string docdept = member.DEPARTMENT; |
536 |
string doccomment = string.Empty; |
537 |
var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(comment.DATA.ToString()); |
538 |
switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), comment.DATA_TYPE.ToString())) |
539 |
{ |
540 |
case MarkupToPDF.Controls.Common.ControlType.TextControl: |
541 |
case MarkupToPDF.Controls.Common.ControlType.TextBorder: |
542 |
case MarkupToPDF.Controls.Common.ControlType.TextCloud: |
543 |
{ |
544 |
MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data); |
545 |
doccomment = instance.Text; |
546 |
} |
547 |
break; |
548 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl: |
549 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl: |
550 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl: |
551 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl: |
552 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl: |
553 |
case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl: |
554 |
{ |
555 |
MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data); |
556 |
doccomment = instance.ArrowText; |
557 |
} |
558 |
break; |
559 |
} |
560 |
worksheet.Cells[h, w] = string.Format("{0}\n({1})",docNo,docDesc); |
561 |
worksheet.Cells[h, w + 1] = docRev; |
562 |
worksheet.Cells[h, w + 2] = docdept; |
563 |
worksheet.Cells[h, w + 3] = doccomment; |
564 |
h++; |
565 |
} |
566 |
} |
567 |
|
568 |
} |
569 |
|
570 |
|
571 |
worksheet.Columns.AutoFit(); |
572 |
// 엑셀파일 저장 |
573 |
|
574 |
|
575 |
workbook.SaveAs(fileout); |
576 |
//workbook.Save(); |
577 |
workbook.Close(true); |
578 |
application.Quit(); |
579 |
_result = fileout; |
580 |
} |
581 |
catch(Exception e) |
582 |
{ |
583 |
_result = e.Message; |
584 |
} |
585 |
finally |
586 |
{ |
587 |
System.Diagnostics.Process[] ExCel = System.Diagnostics.Process.GetProcessesByName("EXCEL"); |
588 |
if (ExCel.Count() != 0) |
589 |
{ |
590 |
ExCel[0].Kill(); |
591 |
} |
592 |
|
593 |
// Clean up |
594 |
ReleaseExcelObject(worksheet); |
595 |
ReleaseExcelObject(workbook); |
596 |
ReleaseExcelObject(application); |
597 |
|
598 |
} |
599 |
return _result; |
600 |
} |
601 |
|
602 |
private static void ReleaseExcelObject(object obj) |
603 |
{ |
604 |
try |
605 |
{ |
606 |
if (obj != null) |
607 |
{ |
608 |
obj = null; |
609 |
} |
610 |
} |
611 |
catch (Exception ex) |
612 |
{ |
613 |
obj = null; |
614 |
throw ex; |
615 |
} |
616 |
finally |
617 |
{ |
618 |
GC.Collect(); |
619 |
} |
620 |
} |
621 |
} |
622 |
} |