markus / MarkusLogview / MARKUS_LOGVIEW / Controllers / ProjectAPIController.cs @ 84578b97
이력 | 보기 | 이력해설 | 다운로드 (5.33 KB)
1 |
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.Linq; |
9 |
using System.Net; |
10 |
using System.Net.Http; |
11 |
using System.Net.Http.Headers; |
12 |
using System.Threading.Tasks; |
13 |
using System.Web; |
14 |
using System.Web.Http; |
15 |
using static ServiceInterface.LogView_Interface; |
16 |
|
17 |
namespace MARKUS_LOGVIEW.Controllers |
18 |
{ |
19 |
|
20 |
public class ProjectAPIController : ApiController |
21 |
{ |
22 |
private string companyProjectNO; |
23 |
|
24 |
[HttpGet, Route("~/api/GetProjectList")] |
25 |
public async Task<HttpResponseMessage> GetProjectList( string pType) |
26 |
{ |
27 |
#region Get Project List |
28 |
HttpResponseMessage resp = new HttpResponseMessage(); |
29 |
List<RunProjectsList> runProjectList = new List<RunProjectsList>(); |
30 |
GET_PROJECT_TYPE getProjType = new GET_PROJECT_TYPE(); |
31 |
|
32 |
// 사용자 인증 |
33 |
CookieHeaderValue cookie = Request.Headers.GetCookies("MarkusCookie").FirstOrDefault(); |
34 |
|
35 |
if (!AuthorizationController.UserAuthorization(Request.Headers.Authorization.ToString())) |
36 |
{ |
37 |
return CommonController.Forbidden(resp); |
38 |
} |
39 |
else |
40 |
{ |
41 |
// Session 에 저장된 값을 가지고 프로젝트 리스트를 구별해서 가져옴. |
42 |
|
43 |
|
44 |
using (markusEntities entity = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString())) |
45 |
{ |
46 |
|
47 |
// 실행 프로젝트에 대해서 가져옴 ( IsActivity 가 1 인 프로젝트 ) |
48 |
var runProject = entity |
49 |
.RUN_PROJECTS |
50 |
.Where(run => run.IS_ACTIVITY.Equals(1)) |
51 |
.OrderBy(order => order.RUN_DATETIME) |
52 |
.ToList(); |
53 |
|
54 |
if (runProject.Count > 1) |
55 |
runProject = runProject.Where(info => info.PROJECT_NO != "000004").ToList(); |
56 |
|
57 |
|
58 |
if (runProject.Count > 0) |
59 |
{ |
60 |
// 프로젝트 리스트 불러오기 |
61 |
var projectList = runProject.Select(ret => new RunProjectsList() |
62 |
{ |
63 |
ProjectNO = ret.PROJECT_NO, |
64 |
ProjectName = ret.PROJECT_NAME, |
65 |
RunDateTime = ret.RUN_DATETIME, |
66 |
IsActivity = ret.IS_ACTIVITY |
67 |
}).ToList(); |
68 |
|
69 |
projectList.ForEach(proj => |
70 |
{ |
71 |
|
72 |
var statusCount = (pType == getProjType.Convert) ? |
73 |
entity.CONVERTER_DOC |
74 |
.Where(cd => cd.PROJECT_NO == proj.ProjectNO) |
75 |
.GroupBy(g => g.STATUS).OrderBy(g => g.Key) |
76 |
.Select(docStatus => new ConvertingStatus() |
77 |
{ |
78 |
Key = docStatus.Key, |
79 |
Count = docStatus.Count(), |
80 |
}) |
81 |
: |
82 |
entity.FINAL_PDF |
83 |
.Where(cd => cd.PROJECT_NO == proj.ProjectNO) |
84 |
.GroupBy(g => g.STATUS) |
85 |
.OrderBy(g => g.Key) |
86 |
.Select(docStatus => new ConvertingStatus() |
87 |
{ |
88 |
Key = docStatus.Key, |
89 |
Count = docStatus.Count(), |
90 |
}); |
91 |
|
92 |
// Status 별로 분류 |
93 |
statusCount.ToList().ForEach(stat => |
94 |
{ |
95 |
|
96 |
switch (stat.Key) |
97 |
{ |
98 |
case (int)PDFStatus.Insert: |
99 |
proj.Insert = stat.Count; |
100 |
break; |
101 |
case (int)PDFStatus.Wait: |
102 |
proj.Wait = stat.Count; |
103 |
break; |
104 |
case (int)PDFStatus.Crop: |
105 |
proj.Crop = stat.Count; |
106 |
break; |
107 |
case (int)PDFStatus.Success: |
108 |
proj.Success = stat.Count; |
109 |
break; |
110 |
case (int)PDFStatus.Error: |
111 |
proj.Error = stat.Count; |
112 |
break; |
113 |
} |
114 |
|
115 |
proj.Entire += stat.Count; |
116 |
|
117 |
}); |
118 |
|
119 |
runProjectList.Add(proj); |
120 |
|
121 |
}); |
122 |
|
123 |
resp = await CommonController.OK<List<RunProjectsList>>(resp, runProjectList); |
124 |
|
125 |
} |
126 |
else |
127 |
{ |
128 |
resp = await CommonController.NotFound(resp, String.Empty); |
129 |
} |
130 |
|
131 |
return resp; |
132 |
|
133 |
} |
134 |
|
135 |
} |
136 |
|
137 |
#endregion |
138 |
} |
139 |
} |
140 |
} |