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