1 |
0f6604ce
|
taeseongkim
|
using Newtonsoft.Json.Linq;
|
2 |
|
|
using System;
|
3 |
|
|
using System.Collections.Generic;
|
4 |
|
|
using System.Linq;
|
5 |
|
|
using System.Web;
|
6 |
|
|
using PemssAPI.DataModel;
|
7 |
84190963
|
taeseongkim
|
using System.Collections.Specialized;
|
8 |
|
|
using System.Net.Http;
|
9 |
c47493ca
|
taeseongkim
|
using System.Net.Http.Headers;
|
10 |
0b75c341
|
taeseongkim
|
using System.Net;
|
11 |
|
|
using Newtonsoft.Json;
|
12 |
0f6604ce
|
taeseongkim
|
|
13 |
|
|
namespace KCOM_API
|
14 |
|
|
{
|
15 |
84190963
|
taeseongkim
|
/// <summary>
|
16 |
|
|
/// 등록은 POST, 삭제시 DELETE , LIST 는 GET 으로 호출해야 합니다.
|
17 |
|
|
/// </summary>
|
18 |
0f6604ce
|
taeseongkim
|
public class PemssApi : IDisposable
|
19 |
|
|
{
|
20 |
|
|
private string gPemssUri;
|
21 |
|
|
|
22 |
|
|
public PemssApi(string PemssApiUri)
|
23 |
|
|
{
|
24 |
|
|
gPemssUri = PemssApiUri;
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
public void Dispose()
|
28 |
|
|
{
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
/// <summary>
|
32 |
|
|
/// 정합성 목록
|
33 |
|
|
/// </summary>
|
34 |
|
|
/// <param name="pId">프로젝트 ID</param>
|
35 |
|
|
/// <param name="dId">Document ID</param>
|
36 |
|
|
/// <returns></returns>
|
37 |
|
|
public List<Requirement> GetRequirementItems(string pId,string dId)
|
38 |
|
|
{
|
39 |
|
|
List<Requirement> result = new List<Requirement>();
|
40 |
|
|
|
41 |
|
|
try
|
42 |
|
|
{
|
43 |
|
|
var jsonObj = GetWebClientString($"{gPemssUri}/rest/ext/list/requirement?pId={pId}&dId={dId}");
|
44 |
|
|
|
45 |
|
|
if (jsonObj != null)
|
46 |
|
|
{
|
47 |
|
|
JObject jObject = JObject.Parse(jsonObj, new JsonLoadSettings());
|
48 |
|
|
|
49 |
|
|
foreach (var item in JArray.Parse(jObject["rows"].ToString()))
|
50 |
|
|
{
|
51 |
84190963
|
taeseongkim
|
List<VpCommant> VpComments = new List<VpCommant>();
|
52 |
|
|
|
53 |
|
|
if (item["vpComments"].HasValues)
|
54 |
|
|
{
|
55 |
|
|
var comments = JArray.Parse(item["vpComments"].ToString());
|
56 |
|
|
|
57 |
|
|
foreach (var comment in comments)
|
58 |
|
|
{
|
59 |
|
|
VpComments.Add(new VpCommant
|
60 |
|
|
{
|
61 |
|
|
mdId = item["mdId"]?.ToObject<string>(),
|
62 |
|
|
created = comment["created"]?.ToObject<string>(),
|
63 |
|
|
comment = comment["comment"]?.ToObject<string>(),
|
64 |
|
|
commentId = comment["commentId"]?.ToObject<string>(),
|
65 |
|
|
condition = comment["condition"].HasValues ? comment["condition"].ToObject<bool>() : false,
|
66 |
|
|
createdBy = comment["createdBy"]?.ToObject<string>(),
|
67 |
|
|
createdByName = comment["createdByName"]?.ToObject<string>(),
|
68 |
|
|
});
|
69 |
|
|
}
|
70 |
|
|
}
|
71 |
|
|
|
72 |
0f6604ce
|
taeseongkim
|
result.Add(new Requirement
|
73 |
|
|
{
|
74 |
|
|
mdId = item["mdId"]?.ToObject<string>(),
|
75 |
|
|
mdText = item["mdText"]?.ToObject<string>(),
|
76 |
fad4d1c0
|
taeseongkim
|
MrComments = new List<MrCommant>(),
|
77 |
84190963
|
taeseongkim
|
VpComments = VpComments
|
78 |
0f6604ce
|
taeseongkim
|
});
|
79 |
84190963
|
taeseongkim
|
|
80 |
|
|
|
81 |
0f6604ce
|
taeseongkim
|
}
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
catch (Exception ex)
|
85 |
|
|
{
|
86 |
|
|
throw new Exception("GetRequirementItems",ex);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
return result;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
/// <summary>
|
93 |
|
|
/// 정합성 코멘트 등록
|
94 |
|
|
/// </summary>
|
95 |
|
|
/// <param name="pId">프로젝트 ID</param>
|
96 |
|
|
/// <param name="dId">Document ID</param>
|
97 |
|
|
/// <param name="mdId">MR 상세 아이템 ID</param>
|
98 |
|
|
/// <param name="commentId"></param>
|
99 |
|
|
/// <param name="comment"></param>
|
100 |
|
|
/// <param name="condition"></param>
|
101 |
|
|
/// <param name="uId"></param>
|
102 |
|
|
/// <returns></returns>
|
103 |
|
|
public bool SetRequirementComment(string pId, string dId,string mdId, string commentId,string comment,bool condition,string uId)
|
104 |
|
|
{
|
105 |
|
|
bool result = false;
|
106 |
|
|
|
107 |
|
|
try
|
108 |
|
|
{
|
109 |
|
|
//http://pemss.i-on.net/rest/ext/comment/requirement?dId=116&mdId=MD0000000352&commentId=1&comment=test&condition=true&uId=admin
|
110 |
|
|
|
111 |
84190963
|
taeseongkim
|
var values = new NameValueCollection(){
|
112 |
|
|
{ "dId",dId},
|
113 |
|
|
{ "mdId", mdId},
|
114 |
|
|
{ "commentId" , commentId},
|
115 |
|
|
{ "comment" ,comment},
|
116 |
|
|
{ "condition" ,condition.ToString()},
|
117 |
|
|
{ "uId", uId}
|
118 |
|
|
};
|
119 |
|
|
|
120 |
|
|
var jsonObj = SetWebClientString($"{gPemssUri}/rest/ext/comment/requirement", values);
|
121 |
|
|
//var jsonObj = GetWebClientString($"{gPemssUri}/rest/ext/comment/requirement?"
|
122 |
|
|
// + $"dId={dId}&mdId={mdId}&commentId={commentId}&comment={comment}&condition={condition}&uId={uId}");
|
123 |
|
|
|
124 |
0f6604ce
|
taeseongkim
|
if (jsonObj != null)
|
125 |
|
|
{
|
126 |
|
|
JObject jObject = JObject.Parse(jsonObj, new JsonLoadSettings());
|
127 |
|
|
|
128 |
|
|
if (jObject.Property("status") != null)
|
129 |
|
|
{
|
130 |
|
|
result = jObject.Property("status").ToObject<bool>();
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
catch (Exception ex)
|
135 |
|
|
{
|
136 |
|
|
throw new Exception("SetRequirementComment", ex);
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
return result;
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
/// <summary>
|
143 |
|
|
/// 정합성 코멘트 삭제
|
144 |
|
|
/// </summary>
|
145 |
|
|
/// <param name="pId">프로젝트 ID</param>
|
146 |
|
|
/// <param name="dId">Document ID</param>
|
147 |
0b75c341
|
taeseongkim
|
/// <param name="mrId">MR 상세 아이템 ID</param>
|
148 |
0f6604ce
|
taeseongkim
|
/// <param name="commentId"></param>
|
149 |
|
|
/// <param name="uId"></param>
|
150 |
|
|
/// <returns></returns>
|
151 |
|
|
public bool RemoveRequirementComment(string pId, string dId, string mdId, string commentId, string uId)
|
152 |
|
|
{
|
153 |
|
|
bool result = false;
|
154 |
|
|
|
155 |
|
|
try
|
156 |
|
|
{
|
157 |
|
|
//http://pemss.i-on.net/rest/ext/comment/requirement?dId=116&mdId=MD0000000352&commentId=1&uId=유저아이디
|
158 |
84190963
|
taeseongkim
|
|
159 |
|
|
var values = new NameValueCollection(){
|
160 |
0b75c341
|
taeseongkim
|
{ "pId",pId},
|
161 |
84190963
|
taeseongkim
|
{ "dId",dId},
|
162 |
|
|
{ "mdId", mdId},
|
163 |
|
|
{ "commentId" , commentId},
|
164 |
|
|
{ "uId", uId}
|
165 |
|
|
};
|
166 |
|
|
|
167 |
0b75c341
|
taeseongkim
|
//var jsonObj = DeleteWebClientString($"{gPemssUri}/rest/ext/comment/requirement",values);
|
168 |
|
|
var jsonObj = DeleteWebClientString($"{gPemssUri}/rest/ext/comment/requirement?dId={dId}&mdId={mdId}&commentId={commentId}&uId={uId}", values);
|
169 |
|
|
// + $"dId={dId}&mdId={mdId}&commentId={commentId}&uId={uId}", values);
|
170 |
84190963
|
taeseongkim
|
|
171 |
|
|
// var jsonObj = DeleteWebClientString($"{gPemssUri}/rest/ext/comment/requirement", values);
|
172 |
0f6604ce
|
taeseongkim
|
|
173 |
|
|
if (jsonObj != null)
|
174 |
|
|
{
|
175 |
|
|
JObject jObject = JObject.Parse(jsonObj, new JsonLoadSettings());
|
176 |
|
|
|
177 |
|
|
if (jObject.Property("status") != null)
|
178 |
|
|
{
|
179 |
|
|
result = jObject.Property("status").ToObject<bool>();
|
180 |
|
|
}
|
181 |
|
|
}
|
182 |
|
|
}
|
183 |
|
|
catch (Exception ex)
|
184 |
|
|
{
|
185 |
|
|
throw new Exception("RemoveRequirementComment", ex);
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
return result;
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
/// <summary>
|
192 |
|
|
/// 문서 정보
|
193 |
|
|
/// </summary>
|
194 |
|
|
/// <param name="pId">프로젝트 ID</param>
|
195 |
|
|
/// <param name="dId">Document ID</param>
|
196 |
|
|
/// <returns></returns>
|
197 |
|
|
public DocumentInfo GetDocumentInfo(string pId, string dId)
|
198 |
|
|
{
|
199 |
|
|
DocumentInfo result = null;
|
200 |
|
|
|
201 |
|
|
try
|
202 |
|
|
{
|
203 |
|
|
var jsonObj = GetWebClientString($"{gPemssUri}/rest/ext/docinfo?pId={pId}&dId={dId}");
|
204 |
|
|
|
205 |
|
|
if (jsonObj != null)
|
206 |
|
|
{
|
207 |
|
|
JObject jObject = JObject.Parse(jsonObj, new JsonLoadSettings());
|
208 |
|
|
|
209 |
|
|
result = new DocumentInfo
|
210 |
|
|
{
|
211 |
|
|
slipNo = jObject.Property("slipNo")?.Value?.ToString(),
|
212 |
|
|
dId = jObject.Property("dId").HasValues ? jObject.Property("dId").ToObject<int>() : -1,
|
213 |
|
|
docName = jObject.Property("docName")?.Value?.ToString(),
|
214 |
|
|
fileName = jObject.Property("fileName")?.Value?.ToString(),
|
215 |
|
|
revision = jObject.Property("revision")?.Value?.ToString()
|
216 |
|
|
};
|
217 |
|
|
}
|
218 |
|
|
}
|
219 |
|
|
catch (Exception ex)
|
220 |
|
|
{
|
221 |
|
|
throw new Exception("GetDocumentInfo",ex);
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
return result;
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
/// <summary>
|
228 |
|
|
/// 사용자 정보 목록
|
229 |
|
|
/// </summary>
|
230 |
|
|
/// <param name="pId">프로젝트 ID</param>
|
231 |
|
|
/// <param name="dId">Document ID</param>
|
232 |
|
|
/// <returns></returns>
|
233 |
|
|
public List<UserInfo> GetUserInfoItems(IEnumerable<string> userIdList)
|
234 |
|
|
{
|
235 |
|
|
List<UserInfo> result = new List<UserInfo>();
|
236 |
|
|
|
237 |
|
|
try
|
238 |
|
|
{
|
239 |
|
|
/// uIds=U00000000006&uIds=U00000000005
|
240 |
|
|
string param = string.Join("&",userIdList.Select(x => $"uIds={x}"));
|
241 |
|
|
|
242 |
|
|
var jsonObj = GetWebClientString($"{gPemssUri}/rest/ext/userinfo?{param}");
|
243 |
|
|
|
244 |
|
|
if (jsonObj != null)
|
245 |
|
|
{
|
246 |
|
|
JArray array = JArray.Parse(jsonObj, new JsonLoadSettings());
|
247 |
|
|
|
248 |
|
|
foreach (var item in array)
|
249 |
|
|
{
|
250 |
|
|
result.Add(new UserInfo
|
251 |
|
|
{
|
252 |
|
|
name = item["name"]?.ToObject<string>(),
|
253 |
|
|
email = item["email"]?.ToObject<string>(),
|
254 |
|
|
deptCode = item["deptCode"]?.ToObject<string>(),
|
255 |
|
|
deptName = item["deptName"]?.ToObject<string>()
|
256 |
|
|
});
|
257 |
|
|
}
|
258 |
|
|
}
|
259 |
|
|
}
|
260 |
|
|
catch (Exception ex)
|
261 |
|
|
{
|
262 |
|
|
throw new Exception("GetUserInfoItems", ex);
|
263 |
|
|
}
|
264 |
|
|
|
265 |
|
|
return result;
|
266 |
|
|
}
|
267 |
|
|
|
268 |
|
|
private string GetWebClientString(string uri)
|
269 |
|
|
{
|
270 |
|
|
try
|
271 |
|
|
{
|
272 |
|
|
using (System.Net.WebClient client = new System.Net.WebClient { Encoding = System.Text.Encoding.UTF8 })
|
273 |
|
|
{
|
274 |
|
|
var result = client.DownloadString(uri);
|
275 |
|
|
|
276 |
|
|
if (string.IsNullOrWhiteSpace(result.Replace("{", "").Replace("}", "")))
|
277 |
|
|
{
|
278 |
|
|
return null;
|
279 |
|
|
}
|
280 |
|
|
else
|
281 |
|
|
{
|
282 |
|
|
return result;
|
283 |
|
|
}
|
284 |
|
|
}
|
285 |
|
|
}
|
286 |
|
|
catch (Exception ex)
|
287 |
|
|
{
|
288 |
|
|
return null;
|
289 |
|
|
}
|
290 |
|
|
}
|
291 |
84190963
|
taeseongkim
|
|
292 |
|
|
private string SetWebClientString(string uri, NameValueCollection valus)
|
293 |
|
|
{
|
294 |
|
|
try
|
295 |
|
|
{
|
296 |
|
|
using (System.Net.WebClient client = new System.Net.WebClient { Encoding = System.Text.Encoding.UTF8 })
|
297 |
|
|
{
|
298 |
|
|
var response = client.UploadValues(uri,valus);
|
299 |
|
|
|
300 |
|
|
var result = System.Text.Encoding.UTF8.GetString(response);
|
301 |
|
|
|
302 |
|
|
if (string.IsNullOrWhiteSpace(result.Replace("{", "").Replace("}", "")))
|
303 |
|
|
{
|
304 |
|
|
return null;
|
305 |
|
|
}
|
306 |
|
|
else
|
307 |
|
|
{
|
308 |
|
|
return result;
|
309 |
|
|
}
|
310 |
|
|
}
|
311 |
|
|
}
|
312 |
|
|
catch (Exception ex)
|
313 |
|
|
{
|
314 |
|
|
return null;
|
315 |
|
|
}
|
316 |
|
|
}
|
317 |
|
|
|
318 |
0b75c341
|
taeseongkim
|
private string DeleteWebClientString(string RestApi, NameValueCollection valus)
|
319 |
84190963
|
taeseongkim
|
{
|
320 |
|
|
try
|
321 |
|
|
{
|
322 |
0b75c341
|
taeseongkim
|
|
323 |
|
|
using (System.Net.WebClient client = new System.Net.WebClient { Encoding = System.Text.Encoding.UTF8 })
|
324 |
84190963
|
taeseongkim
|
{
|
325 |
0b75c341
|
taeseongkim
|
var response = client.UploadValues(RestApi, "DELETE", valus);
|
326 |
|
|
var result = System.Text.Encoding.UTF8.GetString(response);
|
327 |
c47493ca
|
taeseongkim
|
|
328 |
0b75c341
|
taeseongkim
|
if (string.IsNullOrWhiteSpace(result.Replace("{", "").Replace("}", "")))
|
329 |
c47493ca
|
taeseongkim
|
{
|
330 |
0b75c341
|
taeseongkim
|
return null;
|
331 |
|
|
}
|
332 |
|
|
else
|
333 |
|
|
{
|
334 |
|
|
return result;
|
335 |
|
|
}
|
336 |
84190963
|
taeseongkim
|
}
|
337 |
|
|
}
|
338 |
|
|
catch (Exception ex)
|
339 |
|
|
{
|
340 |
|
|
return null;
|
341 |
|
|
}
|
342 |
|
|
}
|
343 |
0f6604ce
|
taeseongkim
|
}
|
344 |
|
|
} |