1 |
84578b97
|
djkim
|
using IKCOM;
|
2 |
|
|
using MARKUS_LOGVIEW.Common;
|
3 |
|
|
using MarkusDataModel.Common;
|
4 |
|
|
using MarkusDataModel.DataModel;
|
5 |
|
|
using MarkusDataModel.DTOs;
|
6 |
|
|
using System;
|
7 |
|
|
using System.Collections.Generic;
|
8 |
|
|
using System.IO;
|
9 |
|
|
using System.Linq;
|
10 |
|
|
using System.Net;
|
11 |
|
|
using System.Net.Http;
|
12 |
|
|
using System.Net.Http.Headers;
|
13 |
|
|
using System.Threading.Tasks;
|
14 |
|
|
using System.Web;
|
15 |
|
|
using System.Web.Http;
|
16 |
|
|
using System.Web.Services;
|
17 |
|
|
|
18 |
|
|
namespace MARKUS_LOGVIEW.Controllers
|
19 |
|
|
{
|
20 |
|
|
|
21 |
|
|
public class ConvertAPIController : ApiController
|
22 |
|
|
{
|
23 |
|
|
|
24 |
|
|
/// <summary>
|
25 |
|
|
/// 컨버팅 데이블 데이터 반환
|
26 |
|
|
/// </summary>
|
27 |
|
|
/// <param name="filter"></param>
|
28 |
|
|
/// <returns></returns>
|
29 |
|
|
[HttpPost, Route("~/api/project/GetConvertDocument")]
|
30 |
|
|
public async Task<ConvertTableData> GetConvertDocument([FromBody] DataTableParameters filter)
|
31 |
|
|
{
|
32 |
|
|
#region Convert Table data 반환
|
33 |
|
|
ConvertTableData dto = new ConvertTableData();
|
34 |
|
|
List<TableData_Convert> tableData = new List<TableData_Convert>();
|
35 |
|
|
|
36 |
|
|
DateTime prjDocStartDate = Convert.ToDateTime(filter.startDate);
|
37 |
|
|
DateTime prjDocEndDate = Convert.ToDateTime(filter.endDate).AddHours(23).AddMinutes(59).AddSeconds(59);
|
38 |
|
|
|
39 |
|
|
if (!AuthorizationController.UserAuthorization(Request.Headers.Authorization.ToString()))
|
40 |
|
|
{
|
41 |
|
|
dto.statusCode = 403;
|
42 |
|
|
return dto;
|
43 |
|
|
}
|
44 |
|
|
else
|
45 |
|
|
{
|
46 |
|
|
|
47 |
|
|
try
|
48 |
|
|
{
|
49 |
|
|
|
50 |
|
|
string token = Request.Headers.Authorization.ToString();
|
51 |
|
|
|
52 |
|
|
using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
|
53 |
|
|
{
|
54 |
|
|
|
55 |
|
|
var convDocList = ent.CONVERTER_DOC
|
56 |
|
|
.Where(
|
57 |
|
|
cd => cd.CREATE_DATETIME >= prjDocStartDate &&
|
58 |
|
|
cd.CREATE_DATETIME <= prjDocEndDate &&
|
59 |
|
|
cd.PROJECT_NO == filter.projectNo &&
|
60 |
|
|
(string.IsNullOrEmpty(filter.Search.Value)) ? string.IsNullOrEmpty(filter.Search.Value) : cd.DOCUMENT_ID.Contains(filter.Search.Value)
|
61 |
|
|
)
|
62 |
|
|
.OrderByDescending(t => t.CREATE_DATETIME)
|
63 |
|
|
.ToList();
|
64 |
|
|
|
65 |
|
|
if (convDocList.Count > 0)
|
66 |
|
|
{
|
67 |
|
|
|
68 |
|
|
int count = convDocList.Count;
|
69 |
|
|
int index = filter.start;
|
70 |
|
|
|
71 |
|
|
var limitList = convDocList.Skip(filter.start).Take(filter.Length).ToList();
|
72 |
|
|
|
73 |
|
|
limitList.ForEach(ret =>
|
74 |
|
|
{
|
75 |
|
|
tableData.Add(new TableData_Convert()
|
76 |
|
|
{
|
77 |
|
|
ID = ret.ID,
|
78 |
|
|
DeleteDocument = "<input type=\"checkbox\" name=\"deleteDocument[]\" value=\"" + ret.DOCUMENT_ID + "\" />",
|
79 |
|
|
OpenMarkusURL = "<a href=\"kcom://" + CommonController.CreateMarkusParam(ret.PROJECT_NO, ret.DOCUMENT_ID, token) + "\">open</a>",
|
80 |
|
|
DocumentID = ret.DOCUMENT_ID,
|
81 |
|
|
InterfaceID = ent.DOCUMENT_ITEM.Where(d =>d.DOCUMENT_ID == ret.DOCUMENT_ID).FirstOrDefault().ID,
|
82 |
|
|
CurrentPage = ret.CURRENT_PAGE,
|
83 |
|
|
TotalPage = ret.TOTAL_PAGE,
|
84 |
|
|
CreateDate = ret.CREATE_DATETIME,
|
85 |
|
|
StartDateTime = ret.START_DATETIME,
|
86 |
|
|
EndDateTime = ret.END_DATETIME,
|
87 |
|
|
ConvertTime = null,
|
88 |
|
|
Status = CommonController.GetStatusName(ret.STATUS),
|
89 |
|
|
DocumentURL = "<a href=\"" + ret.DOCUMENT_URL + "\" target=\"_blank\">PDF</a>",
|
90 |
|
|
});
|
91 |
|
|
|
92 |
|
|
});
|
93 |
|
|
|
94 |
|
|
dto.draw = filter.Draw;
|
95 |
|
|
dto.recordsTotal = count;
|
96 |
|
|
dto.recordsFiltered = count;
|
97 |
|
|
dto.length = filter.Length;
|
98 |
|
|
dto.data = tableData;
|
99 |
|
|
|
100 |
|
|
return dto;
|
101 |
|
|
|
102 |
|
|
}
|
103 |
|
|
else
|
104 |
|
|
{
|
105 |
|
|
dto.draw = filter.Draw;
|
106 |
|
|
dto.recordsFiltered = 0;
|
107 |
|
|
dto.recordsTotal = 0;
|
108 |
|
|
dto.length = 0;
|
109 |
|
|
dto.data = new List<TableData_Convert>();
|
110 |
|
|
|
111 |
|
|
return dto;
|
112 |
|
|
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
}
|
119 |
|
|
catch (Exception)
|
120 |
|
|
{
|
121 |
|
|
dto.statusCode = 500;
|
122 |
|
|
return dto;
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
}
|
126 |
|
|
#endregion
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
/// <summary>
|
130 |
|
|
/// Get Revision Document List
|
131 |
|
|
/// </summary>
|
132 |
|
|
/// <param name="param"></param>
|
133 |
|
|
/// <returns></returns>
|
134 |
|
|
[HttpPost,Route("~/api/GetDocumentItemList")]
|
135 |
|
|
public async Task<HttpResponseMessage> GetDocumentItemList(pGetDocumentItemList param)
|
136 |
|
|
{
|
137 |
|
|
#region 해당 프로젝트의 DocumentItem 가져오기 ( 파일 업로드 시 - 리비전 업 )
|
138 |
|
|
HttpResponseMessage resp = new HttpResponseMessage();
|
139 |
|
|
List<DocumentItemInfoList> docItemList = new List<DocumentItemInfoList>();
|
140 |
|
|
|
141 |
|
|
if (!AuthorizationController.UserAuthorization(Request.Headers.Authorization.ToString()))
|
142 |
|
|
{
|
143 |
|
|
return CommonController.Forbidden(resp);
|
144 |
|
|
}
|
145 |
|
|
else
|
146 |
|
|
{
|
147 |
|
|
try
|
148 |
|
|
{
|
149 |
|
|
|
150 |
|
|
using (markusEntities entity = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
|
151 |
|
|
{
|
152 |
|
|
|
153 |
|
|
var docItems = entity.DOCUMENT_ITEM
|
154 |
|
|
.Where(doc => doc.PROJECT_NO.Equals(param.ProjectNO))
|
155 |
|
|
.GroupBy(g => g.DOCUMENT_NO, (key, docNO) => docNO.FirstOrDefault())
|
156 |
|
|
.Select(ret => new DocumentItemInfoList()
|
157 |
|
|
{
|
158 |
|
|
DocumentItemNO = ret.DOCUMENT_NO,
|
159 |
|
|
DocumentItemID = ret.DOCUMENT_ID,
|
160 |
|
|
DocumentItemName = ret.DOCUMENT_NAME
|
161 |
|
|
|
162 |
|
|
}).ToList();
|
163 |
|
|
|
164 |
|
|
if (docItems.Count > 0)
|
165 |
|
|
{
|
166 |
|
|
resp = await CommonController.OK<List<DocumentItemInfoList>>(resp, docItems);
|
167 |
|
|
}
|
168 |
|
|
else
|
169 |
|
|
{
|
170 |
|
|
resp = await CommonController.NotFound<pGetDocumentItemList>(resp, new pGetDocumentItemList()
|
171 |
|
|
{
|
172 |
|
|
ProjectNO = param.ProjectNO
|
173 |
|
|
});
|
174 |
|
|
}
|
175 |
|
|
|
176 |
|
|
return resp;
|
177 |
|
|
}
|
178 |
|
|
}
|
179 |
|
|
catch (Exception ex)
|
180 |
|
|
{
|
181 |
|
|
resp = CommonController.InternalServerError(resp, ex.Message);
|
182 |
|
|
return resp;
|
183 |
|
|
}
|
184 |
|
|
}
|
185 |
|
|
#endregion
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
/// <summary>
|
189 |
|
|
/// Get Document Message and Original URL
|
190 |
|
|
/// </summary>
|
191 |
|
|
/// <param name="pDocInfo"></param>
|
192 |
|
|
/// <returns></returns>
|
193 |
|
|
[HttpPost,Route("~/api/convert/GetDocumentMessage")]
|
194 |
|
|
public async Task<HttpResponseMessage> GetDocumentItemMessage([FromBody] pDocumentMessage pDocInfo)
|
195 |
|
|
{
|
196 |
|
|
#region 도큐먼트 Message, Original URL 가져오기
|
197 |
|
|
HttpResponseMessage resp = new HttpResponseMessage();
|
198 |
|
|
|
199 |
|
|
if (!AuthorizationController.UserAuthorization(Request.Headers.Authorization.ToString()))
|
200 |
|
|
{
|
201 |
|
|
return CommonController.Forbidden(resp);
|
202 |
|
|
}
|
203 |
|
|
else
|
204 |
|
|
{
|
205 |
|
|
try
|
206 |
|
|
{
|
207 |
|
|
|
208 |
|
|
ViewInfo getDocument = CommonController.ParamDecoding(pDocInfo.pDocumentInfo);
|
209 |
|
|
|
210 |
|
|
using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
|
211 |
|
|
{
|
212 |
|
|
|
213 |
|
|
var convMessage = ent.CONVERTER_DOC.Where(cd => cd.DOCUMENT_ID == getDocument.DocumentItemID).Select(ret => ret.EXCEPTION).FirstOrDefault();
|
214 |
|
|
|
215 |
|
|
DocumentMessage docMessage = ent.DOCUMENT_ITEM
|
216 |
|
|
.Where(di => di.DOCUMENT_ID == getDocument.DocumentItemID)
|
217 |
|
|
.Select(ret => new DocumentMessage()
|
218 |
|
|
{
|
219 |
|
|
OriginalURL = ret.ORIGINAL_FILE,
|
220 |
|
|
Message = convMessage
|
221 |
|
|
})
|
222 |
|
|
.FirstOrDefault();
|
223 |
|
|
|
224 |
|
|
return await CommonController.OK<DocumentMessage>(resp, docMessage);
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
}
|
230 |
|
|
catch (Exception ex)
|
231 |
|
|
{
|
232 |
|
|
|
233 |
|
|
Console.WriteLine(ex.Message);
|
234 |
|
|
throw ex;
|
235 |
|
|
|
236 |
|
|
}
|
237 |
|
|
}
|
238 |
|
|
#endregion
|
239 |
|
|
}
|
240 |
|
|
|
241 |
|
|
/// <summary>
|
242 |
|
|
/// Upload PDF File
|
243 |
|
|
/// </summary>
|
244 |
|
|
private string folder_increaseNumber;
|
245 |
|
|
[HttpPost]
|
246 |
|
|
[Route("~/api/pdf/upload")]
|
247 |
|
|
public async Task<HttpResponseMessage> UploadFile()
|
248 |
|
|
{
|
249 |
|
|
#region 파일 리비전 메서드
|
250 |
|
|
int uploadType = 0;
|
251 |
|
|
string initFolderName = "40000000";
|
252 |
|
|
|
253 |
|
|
// 파일 저장 경로
|
254 |
|
|
// Web Server 000000_app/VPCS_DOCLIB/
|
255 |
|
|
string serverPath = "../../Doc_Manager/";
|
256 |
|
|
string originalFileDefaultURL = "/Doc_Manager/";
|
257 |
|
|
|
258 |
|
|
// Local Test
|
259 |
|
|
//string serverPath = "/pdfUpload/";
|
260 |
|
|
//string originalFileDefaultURL = "/pdfUpload/";
|
261 |
|
|
|
262 |
|
|
HttpResponseMessage resp = new HttpResponseMessage();
|
263 |
|
|
DocumentItemDTO revDoc = new DocumentItemDTO();
|
264 |
|
|
|
265 |
|
|
if (!AuthorizationController.UserAuthorization(Request.Headers.Authorization.ToString()))
|
266 |
|
|
{
|
267 |
|
|
return CommonController.Forbidden(resp);
|
268 |
|
|
}
|
269 |
|
|
else
|
270 |
|
|
{
|
271 |
|
|
|
272 |
|
|
if (!Request.Content.IsMimeMultipartContent())
|
273 |
|
|
{
|
274 |
|
|
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
|
275 |
|
|
}
|
276 |
|
|
|
277 |
|
|
try
|
278 |
|
|
{
|
279 |
|
|
|
280 |
|
|
string defaultSaveFilePath = HttpContext.Current.Server.MapPath(serverPath);
|
281 |
|
|
|
282 |
|
|
if (!Directory.Exists(defaultSaveFilePath))
|
283 |
|
|
{
|
284 |
|
|
Directory.CreateDirectory(defaultSaveFilePath);
|
285 |
|
|
}
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
var provider = new MultipartFormDataStreamProvider(HttpContext.Current.Server.MapPath(serverPath));
|
289 |
|
|
|
290 |
|
|
await Request.Content.ReadAsMultipartAsync(provider);
|
291 |
|
|
|
292 |
|
|
foreach (var key in provider.FormData.AllKeys)
|
293 |
|
|
{
|
294 |
|
|
foreach (var val in provider.FormData.GetValues(key))
|
295 |
|
|
{
|
296 |
|
|
|
297 |
|
|
switch (key)
|
298 |
|
|
{
|
299 |
|
|
case "ProjectNO":
|
300 |
|
|
revDoc.ProjectNO = val;
|
301 |
|
|
break;
|
302 |
|
|
case "DocumentID":
|
303 |
|
|
revDoc.DocumentID = (val != "") ? val : null;
|
304 |
|
|
break;
|
305 |
|
|
case "DocumentName":
|
306 |
|
|
revDoc.DocumentName = (val != "") ? val : null;
|
307 |
|
|
break;
|
308 |
|
|
case "DocumentNO":
|
309 |
|
|
revDoc.DocumentNO = (val != "") ? val : null;
|
310 |
|
|
break;
|
311 |
|
|
case "UploadType":
|
312 |
|
|
uploadType = Convert.ToInt32(val);
|
313 |
|
|
break;
|
314 |
|
|
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
}
|
318 |
|
|
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
string storagePath = HttpContext.Current.Server.MapPath(serverPath);
|
322 |
|
|
storagePath = storagePath + revDoc.ProjectNO + "_app/VPCS_DOCLIB/";
|
323 |
|
|
// 해당 폴더가 없으면 + initFolderName
|
324 |
|
|
if (!Directory.Exists(storagePath + initFolderName))
|
325 |
|
|
{
|
326 |
|
|
// 폴더 생성
|
327 |
|
|
storagePath += initFolderName;
|
328 |
|
|
Directory.CreateDirectory(storagePath);
|
329 |
|
|
|
330 |
|
|
}
|
331 |
|
|
else
|
332 |
|
|
{
|
333 |
|
|
// 폴더 정보를 가져와서 내림차순으로 정렬
|
334 |
|
|
DirectoryInfo[] dicInfo = new DirectoryInfo(storagePath).GetDirectories();
|
335 |
|
|
Array.Sort(dicInfo, (x, y) => y.Name.CompareTo(x.Name));
|
336 |
|
|
|
337 |
|
|
// 저장경로에 폴더명 가져오기 ( 제일 높은 숫자의 폴더명 + 1 하여 폴더 생성 )
|
338 |
|
|
folder_increaseNumber = (Convert.ToInt32(dicInfo[0].Name) + 1).ToString();
|
339 |
|
|
storagePath += folder_increaseNumber;
|
340 |
|
|
|
341 |
|
|
Directory.CreateDirectory(storagePath);
|
342 |
|
|
|
343 |
|
|
}
|
344 |
|
|
|
345 |
|
|
// project revision setting 가져오기
|
346 |
|
|
string strRevision;
|
347 |
|
|
using (markusEntities entity = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
|
348 |
|
|
{
|
349 |
|
|
strRevision = entity.PROJECT_SETTING.Where(ps => ps.PROJECT_NO.Equals(revDoc.ProjectNO)).Select(ret => ret.REVISION).FirstOrDefault();
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
// 리비전 업을 또는 생성을 위한 로직
|
353 |
|
|
// GroupNo은 해당 프로젝트의 GroupNo 의 마지막 값에서 증가.
|
354 |
|
|
var grouping = entity.DOCUMENT_ITEM.Where(di => di.PROJECT_NO.Equals(revDoc.ProjectNO)).ToList();
|
355 |
|
|
|
356 |
|
|
if (grouping.Count() > 0)
|
357 |
|
|
{
|
358 |
|
|
|
359 |
|
|
string descGroupNo = entity.DOCUMENT_ITEM.Where(di => di.PROJECT_NO.Equals(revDoc.ProjectNO)).OrderByDescending(x => x.GROUP_NO).Select(ret => ret).ToList().First().GROUP_NO;
|
360 |
|
|
revDoc.GroupNO = (Int32.Parse(descGroupNo) + 1).ToString();
|
361 |
|
|
|
362 |
|
|
}
|
363 |
|
|
else
|
364 |
|
|
{
|
365 |
|
|
revDoc.GroupNO = "1";
|
366 |
|
|
}
|
367 |
|
|
|
368 |
|
|
if (uploadType == (int)UPLOAD_TYPE.NEWDOCUMENT)
|
369 |
|
|
{
|
370 |
|
|
// 새로운 리비전 파라미터 DocumentItemNO, DocumentItemName
|
371 |
|
|
// 해당 이름이 먼저 있는지 체크를 해야함.
|
372 |
|
|
var checkDocumentItem = entity.DOCUMENT_ITEM.Where(di => di.DOCUMENT_NO.Equals(revDoc.DocumentNO) && di.PROJECT_NO == revDoc.ProjectNO).ToList();
|
373 |
|
|
|
374 |
|
|
if (checkDocumentItem.Count > 0)
|
375 |
|
|
{
|
376 |
|
|
|
377 |
|
|
resp.StatusCode = HttpStatusCode.InternalServerError;
|
378 |
|
|
resp.Content = await CommonController.JsonSerialize<string>("The same document number exists");
|
379 |
|
|
|
380 |
|
|
return resp;
|
381 |
|
|
|
382 |
|
|
}
|
383 |
|
|
else
|
384 |
|
|
{
|
385 |
|
|
revDoc.Revision = strRevision.Split(',')[0].ToString();
|
386 |
|
|
}
|
387 |
|
|
}
|
388 |
|
|
else if (uploadType == (int)UPLOAD_TYPE.REVISIONUP)
|
389 |
|
|
{
|
390 |
|
|
|
391 |
|
|
// 기존 리비전 업 파라미터 DocumentItemNO
|
392 |
|
|
var selectedDocumentItem = entity.DOCUMENT_ITEM
|
393 |
|
|
.Where(di => di.DOCUMENT_ID.Equals(revDoc.DocumentID))
|
394 |
|
|
.OrderByDescending(x => x.REVISION)
|
395 |
|
|
.Select(ret => ret)
|
396 |
|
|
.ToList();
|
397 |
|
|
|
398 |
|
|
if (selectedDocumentItem.Count > 0)
|
399 |
|
|
{
|
400 |
|
|
|
401 |
|
|
var getDocument = selectedDocumentItem.First();
|
402 |
|
|
if (strRevision.Split(',').Last() == getDocument.REVISION)
|
403 |
|
|
{
|
404 |
|
|
resp.StatusCode = HttpStatusCode.InternalServerError;
|
405 |
|
|
resp.Content = await CommonController.JsonSerialize<string>("Can not make any more revisions.");
|
406 |
|
|
|
407 |
|
|
return resp;
|
408 |
|
|
}
|
409 |
|
|
else
|
410 |
|
|
{
|
411 |
|
|
revDoc.Revision = ((char)(Convert.ToInt32((getDocument.REVISION.ToCharArray()[0])) + 1)).ToString();
|
412 |
|
|
revDoc.DocumentName = getDocument.DOCUMENT_NAME;
|
413 |
|
|
}
|
414 |
|
|
|
415 |
|
|
revDoc.DocumentNO = getDocument.DOCUMENT_NO;
|
416 |
|
|
|
417 |
|
|
}
|
418 |
|
|
|
419 |
|
|
}
|
420 |
|
|
else
|
421 |
|
|
{
|
422 |
|
|
|
423 |
|
|
resp.StatusCode = HttpStatusCode.InternalServerError;
|
424 |
|
|
resp.Content = await CommonController.JsonSerialize<string>("PDF File Upload Error");
|
425 |
|
|
|
426 |
|
|
return resp;
|
427 |
|
|
|
428 |
|
|
}
|
429 |
|
|
|
430 |
|
|
}
|
431 |
|
|
|
432 |
|
|
MultipartFileData fileData = provider.FileData[0];
|
433 |
|
|
|
434 |
|
|
if (string.IsNullOrEmpty(fileData.Headers.ContentDisposition.FileName))
|
435 |
|
|
{
|
436 |
|
|
// type이 다르다.
|
437 |
|
|
}
|
438 |
|
|
|
439 |
|
|
if (string.IsNullOrEmpty(fileData.Headers.ContentDisposition.FileName))
|
440 |
|
|
{
|
441 |
|
|
return Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted");
|
442 |
|
|
}
|
443 |
|
|
string fileName = fileData.Headers.ContentDisposition.FileName;
|
444 |
|
|
if (fileName.StartsWith("\"") && fileName.EndsWith("\""))
|
445 |
|
|
{
|
446 |
|
|
fileName = fileName.Trim('"');
|
447 |
|
|
}
|
448 |
|
|
if (fileName.Contains(@"/") || fileName.Contains(@"\"))
|
449 |
|
|
{
|
450 |
|
|
fileName = Path.GetFileName(fileName);
|
451 |
|
|
}
|
452 |
|
|
|
453 |
|
|
// 파일 저장
|
454 |
|
|
File.Move(fileData.LocalFileName, Path.Combine(storagePath, fileName));
|
455 |
|
|
|
456 |
|
|
// 파일 저장을 성공하면 ConvertWebService 로 전송
|
457 |
|
|
using (ConvertWebService.Conversion convertService = new ConvertWebService.Conversion())
|
458 |
|
|
{
|
459 |
|
|
|
460 |
|
|
|
461 |
|
|
revDoc.DocumentID = (folder_increaseNumber != null) ? folder_increaseNumber : initFolderName;
|
462 |
|
|
revDoc.OriginalFile = "http://" + Request.Headers.Host + originalFileDefaultURL + revDoc.ProjectNO + "_app/VPCS_DOCLIB/" + revDoc.DocumentID + "/" + fileName;
|
463 |
|
|
revDoc.ID = CommonController.shortGuid();
|
464 |
|
|
|
465 |
|
|
// 디비에 저장
|
466 |
|
|
using (markusEntities entity = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
|
467 |
|
|
{
|
468 |
|
|
|
469 |
|
|
entity.DOCUMENT_ITEM.AddObject(new DOCUMENT_ITEM()
|
470 |
|
|
{
|
471 |
|
|
ID = revDoc.ID,
|
472 |
|
|
REVISION = revDoc.Revision,
|
473 |
|
|
DOCUMENT_NO = revDoc.DocumentNO,
|
474 |
|
|
DOCUMENT_NAME = revDoc.DocumentName,
|
475 |
|
|
GROUP_NO = revDoc.GroupNO,
|
476 |
|
|
ORIGINAL_FILE = revDoc.OriginalFile,
|
477 |
|
|
DOCUMENT_ID = revDoc.DocumentID,
|
478 |
|
|
PROJECT_NO = revDoc.ProjectNO
|
479 |
|
|
});
|
480 |
|
|
|
481 |
|
|
entity.SaveChanges();
|
482 |
|
|
|
483 |
|
|
}
|
484 |
|
|
|
485 |
|
|
|
486 |
|
|
// 웹 서비스 호출 ( 컨버팅 서비스 호출 )
|
487 |
|
|
//convertService.Run(revDoc.ProjectNO, revDoc.OriginalFile, revDoc.DocumentID);
|
488 |
|
|
|
489 |
|
|
resp.StatusCode = HttpStatusCode.OK;
|
490 |
|
|
resp.Content = await CommonController.JsonSerialize<string>("Upload Success");
|
491 |
|
|
|
492 |
|
|
}
|
493 |
|
|
|
494 |
|
|
return resp;
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
|
498 |
|
|
}
|
499 |
|
|
catch (Exception ex)
|
500 |
|
|
{
|
501 |
|
|
|
502 |
|
|
Console.WriteLine(ex.Message);
|
503 |
|
|
resp.StatusCode = HttpStatusCode.InternalServerError;
|
504 |
|
|
resp.Content = await CommonController.JsonSerialize<string>("Upload Failed");
|
505 |
|
|
|
506 |
|
|
return resp;
|
507 |
|
|
|
508 |
|
|
}
|
509 |
|
|
|
510 |
|
|
}
|
511 |
|
|
#endregion
|
512 |
|
|
}
|
513 |
|
|
|
514 |
|
|
/// <summary>
|
515 |
|
|
/// Update Complete Convert Documnet URL, ViewInfo
|
516 |
|
|
/// </summary>
|
517 |
|
|
/// <param name="pComplete"></param>
|
518 |
|
|
/// <returns></returns>
|
519 |
|
|
[HttpPost, Route("~/api/convert/complete")]
|
520 |
|
|
public async Task<HttpResponseMessage> Complete(CONVERTER_DOC pComplete)
|
521 |
|
|
{
|
522 |
|
|
#region 컨버팅이 완료되면 ConvertURL , ViewInfo 데이터 생성
|
523 |
|
|
HttpResponseMessage resp = new HttpResponseMessage();
|
524 |
|
|
CompleteConvertDTO completeInfo = new CompleteConvertDTO();
|
525 |
|
|
|
526 |
|
|
if (!AuthorizationController.UserAuthorization(Request.Headers.Authorization.ToString()))
|
527 |
|
|
{
|
528 |
|
|
return CommonController.Forbidden(resp);
|
529 |
|
|
}
|
530 |
|
|
else
|
531 |
|
|
{
|
532 |
|
|
|
533 |
|
|
using (markusEntities entity = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
|
534 |
|
|
{
|
535 |
|
|
|
536 |
|
|
var convertDocument = entity.CONVERTER_DOC.Where(doc => doc.PROJECT_NO == pComplete.PROJECT_NO && doc.ID == pComplete.ID).FirstOrDefault();
|
537 |
|
|
if (convertDocument != null)
|
538 |
|
|
{
|
539 |
|
|
|
540 |
|
|
completeInfo = new CompleteConvertDTO()
|
541 |
|
|
{
|
542 |
|
|
ID = convertDocument.ID,
|
543 |
|
|
ConvertURL = convertDocument.DOCUMENT_URL.ToString(),
|
544 |
|
|
ViewInfo = CommonController.CreateMarkusParam(convertDocument.PROJECT_NO, convertDocument.DOCUMENT_ID, Request.Headers.Authorization.ToString())
|
545 |
|
|
};
|
546 |
|
|
|
547 |
|
|
resp = await CommonController.OK<CompleteConvertDTO>(resp, completeInfo);
|
548 |
|
|
|
549 |
|
|
}
|
550 |
|
|
else
|
551 |
|
|
{
|
552 |
|
|
resp = await CommonController.NotFound<CompleteConvertDTO>(resp, completeInfo);
|
553 |
|
|
}
|
554 |
|
|
|
555 |
|
|
}
|
556 |
|
|
|
557 |
|
|
}
|
558 |
|
|
|
559 |
|
|
return resp;
|
560 |
|
|
|
561 |
|
|
#endregion
|
562 |
|
|
}
|
563 |
|
|
|
564 |
|
|
/// <summary>
|
565 |
|
|
/// 컨버팅 재시작
|
566 |
|
|
/// </summary>
|
567 |
|
|
/// <param name="doc"></param>
|
568 |
|
|
/// <returns></returns>
|
569 |
|
|
[HttpPost, Route("~/api/retry/convert")]
|
570 |
|
|
public async Task<HttpResponseMessage> Reconvert([FromBody] pRetryDocument doc)
|
571 |
|
|
{
|
572 |
|
|
#region 컨버팅 재시작
|
573 |
|
|
|
574 |
|
|
HttpResponseMessage resp = new HttpResponseMessage();
|
575 |
|
|
|
576 |
|
|
if (!AuthorizationController.UserAuthorization(Request.Headers.Authorization.ToString()))
|
577 |
|
|
{
|
578 |
|
|
return CommonController.Forbidden(resp);
|
579 |
|
|
}
|
580 |
|
|
else
|
581 |
|
|
{
|
582 |
|
|
try
|
583 |
|
|
{
|
584 |
|
|
using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
|
585 |
|
|
{
|
586 |
|
|
// 웹 서비스 호출 ( 컨버팅 서비스 호출 )
|
587 |
|
|
var documentCount = doc.documentID.Count();
|
588 |
|
|
|
589 |
|
|
for (int i = 0; i < documentCount; i++)
|
590 |
|
|
{
|
591 |
|
|
|
592 |
|
|
// 선택한 도큐먼트 아이디를 통해 정보 찾기
|
593 |
|
|
string targetDocumentID = doc.documentID[i].ToString();
|
594 |
|
|
// DOCUMENT_ITEM 에서 찾는 이유는 오리지널 파일 URL 을 찾기 위해서이다.
|
595 |
|
|
var targetDocument = ent.DOCUMENT_ITEM.Where(di => di.PROJECT_NO == doc.projectNO && di.DOCUMENT_ID == targetDocumentID).FirstOrDefault();
|
596 |
|
|
|
597 |
|
|
if (targetDocument != null)
|
598 |
|
|
{
|
599 |
|
|
using (ConvertWebService.Conversion convertService = new ConvertWebService.Conversion())
|
600 |
|
|
{
|
601 |
|
|
convertService.ConvertRun(targetDocument.REVISION, targetDocument.DOCUMENT_NO, targetDocument.DOCUMENT_NAME, targetDocument.GROUP_NO, targetDocument.PROJECT_NO, targetDocument.ID, targetDocument.ORIGINAL_FILE);
|
602 |
|
|
}
|
603 |
|
|
|
604 |
|
|
}
|
605 |
|
|
else
|
606 |
|
|
{
|
607 |
|
|
return await CommonController.NotFound<string>(resp, "Not found");
|
608 |
|
|
}
|
609 |
|
|
|
610 |
|
|
}
|
611 |
|
|
|
612 |
|
|
return await CommonController.OK<bool>(resp, true);
|
613 |
|
|
|
614 |
|
|
}
|
615 |
|
|
|
616 |
|
|
}
|
617 |
|
|
catch (Exception ex)
|
618 |
|
|
{
|
619 |
|
|
Console.WriteLine(ex.Message);
|
620 |
|
|
return CommonController.InternalServerError(resp, "server error");
|
621 |
|
|
throw;
|
622 |
|
|
}
|
623 |
|
|
|
624 |
|
|
}
|
625 |
|
|
|
626 |
|
|
#endregion
|
627 |
|
|
}
|
628 |
|
|
|
629 |
|
|
/// <summary>
|
630 |
|
|
/// 컨버팅 재시작
|
631 |
|
|
/// </summary>
|
632 |
|
|
/// <param name="doc"></param>
|
633 |
|
|
/// <returns></returns>
|
634 |
|
|
[HttpPost, Route("~/api/retry/coverconvert")]
|
635 |
|
|
public async Task<HttpResponseMessage> Coverconvert([FromBody] pRetryDocument doc)
|
636 |
|
|
{
|
637 |
|
|
#region 커버컨버팅
|
638 |
|
|
|
639 |
|
|
HttpResponseMessage resp = new HttpResponseMessage();
|
640 |
|
|
|
641 |
|
|
if (!AuthorizationController.UserAuthorization(Request.Headers.Authorization.ToString()))
|
642 |
|
|
{
|
643 |
|
|
return CommonController.Forbidden(resp);
|
644 |
|
|
}
|
645 |
|
|
else
|
646 |
|
|
{
|
647 |
|
|
try
|
648 |
|
|
{
|
649 |
|
|
using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
|
650 |
|
|
{
|
651 |
|
|
// 웹 서비스 호출 ( 컨버팅 서비스 호출 )
|
652 |
|
|
var documentCount = doc.documentID.Count();
|
653 |
|
|
|
654 |
|
|
for (int i = 0; i < documentCount; i++)
|
655 |
|
|
{
|
656 |
|
|
|
657 |
|
|
// 선택한 도큐먼트 아이디를 통해 정보 찾기
|
658 |
|
|
string targetDocumentID = doc.documentID[i].ToString();
|
659 |
|
|
// DOCUMENT_ITEM 에서 찾는 이유는 오리지널 파일 URL 을 찾기 위해서이다.
|
660 |
|
|
var targetDocument = ent.CONVERTER_DOC.Where(di => di.PROJECT_NO == doc.projectNO && di.DOCUMENT_ID == targetDocumentID).FirstOrDefault();
|
661 |
|
|
|
662 |
|
|
if (targetDocument != null)
|
663 |
|
|
{
|
664 |
|
|
using (ConvertWebService.Conversion convertService = new ConvertWebService.Conversion())
|
665 |
|
|
{
|
666 |
|
|
convertService.CoverConvert(targetDocument.PROJECT_NO, targetDocument.ID);// (targetDocument.REVISION, targetDocument.DOCUMENT_NO, targetDocument.DOCUMENT_NAME, targetDocument.GROUP_NO, targetDocument.PROJECT_NO, targetDocument.ID, targetDocument.ORIGINAL_FILE);
|
667 |
|
|
}
|
668 |
|
|
|
669 |
|
|
}
|
670 |
|
|
else
|
671 |
|
|
{
|
672 |
|
|
return await CommonController.NotFound<string>(resp, "Not found");
|
673 |
|
|
}
|
674 |
|
|
|
675 |
|
|
}
|
676 |
|
|
|
677 |
|
|
return await CommonController.OK<bool>(resp, true);
|
678 |
|
|
|
679 |
|
|
}
|
680 |
|
|
|
681 |
|
|
}
|
682 |
|
|
catch (Exception ex)
|
683 |
|
|
{
|
684 |
|
|
Console.WriteLine(ex.Message);
|
685 |
|
|
return CommonController.InternalServerError(resp, "server error");
|
686 |
|
|
throw;
|
687 |
|
|
}
|
688 |
|
|
|
689 |
|
|
}
|
690 |
|
|
|
691 |
|
|
#endregion
|
692 |
|
|
}
|
693 |
|
|
}
|
694 |
|
|
|
695 |
|
|
} |