markus / MarkusLogview / MARKUS_LOGVIEW / Controllers / DeleteFileAPIController.cs @ c854511f
이력 | 보기 | 이력해설 | 다운로드 (3.35 KB)
1 |
using IKCOM; |
---|---|
2 |
using MARKUS_LOGVIEW.Common; |
3 |
using MarkusDataModel.Common; |
4 |
using MarkusDataModel.DataModel; |
5 |
using System; |
6 |
using System.Collections.Generic; |
7 |
using System.Linq; |
8 |
using System.Net; |
9 |
using System.Net.Http; |
10 |
using System.Threading.Tasks; |
11 |
using System.Web.Http; |
12 |
|
13 |
namespace MARKUS_LOGVIEW.Controllers |
14 |
{ |
15 |
|
16 |
public class DeleteFileAPIController : ApiController |
17 |
{ |
18 |
/// <summary> |
19 |
/// 해당 도큐먼트 데이터를 삭제 하는 API ( PDF, Image 는 삭제하지 않음 ) |
20 |
/// </summary> |
21 |
/// <param name="DeleteData"></param> |
22 |
/// <returns></returns> |
23 |
[HttpPost,Route("~/api/delete/document")] |
24 |
public async Task<HttpResponseMessage> DeleteDocument(pDeleteDocumentList DeleteData ) |
25 |
{ |
26 |
#region convert, final 구별하여 해당 도큐먼트 데이터 삭제 |
27 |
HttpResponseMessage resp = new HttpResponseMessage(); |
28 |
var PageType = new GET_PROJECT_TYPE(); |
29 |
|
30 |
if (!AuthorizationController.UserAuthorization(Request.Headers.Authorization.ToString())) |
31 |
{ |
32 |
return CommonController.Forbidden(resp); |
33 |
} |
34 |
else |
35 |
{ |
36 |
|
37 |
try |
38 |
{ |
39 |
|
40 |
using (markusEntities entity = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString())) |
41 |
{ |
42 |
|
43 |
for (int i = 0; i < DeleteData.DocList.Length; i++) |
44 |
{ |
45 |
|
46 |
string documentID = DeleteData.DocList[i]; |
47 |
// DB에서 해당 테이블의 데이터 삭제 |
48 |
if (DeleteData.PageName == PageType.Convert) |
49 |
{ |
50 |
|
51 |
var DeleteConvertDocument = entity.CONVERTER_DOC.Where(doc => doc.PROJECT_NO == DeleteData.ProjectNO && doc.ID == documentID).FirstOrDefault(); |
52 |
if (DeleteConvertDocument != null) |
53 |
{ |
54 |
entity.CONVERTER_DOC.DeleteObject(DeleteConvertDocument); |
55 |
} |
56 |
|
57 |
} |
58 |
else if (DeleteData.PageName == PageType.Merge) |
59 |
{ |
60 |
|
61 |
var DeleteMergeDocument = entity.FINAL_PDF.Where(doc => doc.PROJECT_NO == DeleteData.ProjectNO && doc.ID == documentID).FirstOrDefault(); |
62 |
if (DeleteMergeDocument != null) |
63 |
{ |
64 |
entity.FINAL_PDF.DeleteObject(DeleteMergeDocument); |
65 |
} |
66 |
|
67 |
} |
68 |
|
69 |
entity.SaveChanges(); |
70 |
|
71 |
} |
72 |
|
73 |
} |
74 |
|
75 |
} |
76 |
catch (Exception ex) |
77 |
{ |
78 |
throw ex; |
79 |
} |
80 |
|
81 |
} |
82 |
|
83 |
return resp; |
84 |
#endregion |
85 |
} |
86 |
} |
87 |
} |
88 |
|
89 |
// 파일 삭제까지 하는 웹 서비스 ( 테스트 용도 ) |
90 |
//DeleteService.Run(DeleteData.ProjectNO.ToString(), DeleteData.DocList[i].ToString()); |
91 |
|
92 |
//using (DeleteWebService.FileDelete DeleteService = new DeleteWebService.FileDelete()) |
93 |
//{ |
94 |
// for (int i = 0; i < DeleteData.DocList.Length; i++) |
95 |
// { |
96 |
// DeleteService.Run(DeleteData.ProjectNO.ToString(), DeleteData.DocList[i].ToString()); |
97 |
// } |
98 |
//} |