markus / KCOM_API / ServiceDeepView.svc.cs @ a860bafc
이력 | 보기 | 이력해설 | 다운로드 (144 KB)
1 |
using IFinalPDF; |
---|---|
2 |
using IKCOM; |
3 |
using KCOMDataModel.Common; |
4 |
using KCOMDataModel.DataModel; |
5 |
using System; |
6 |
using System.Collections.Generic; |
7 |
using System.Collections.ObjectModel; |
8 |
using System.Configuration; |
9 |
using System.Linq; |
10 |
using System.Net; |
11 |
using System.Runtime.Remoting.Channels.Tcp; |
12 |
using System.Runtime.Serialization; |
13 |
using System.ServiceModel; |
14 |
using System.ServiceModel.Activation; |
15 |
using System.Text; |
16 |
using System.Web.Services; |
17 |
using System.Windows; |
18 |
using System.Xml; |
19 |
using ColorSelector; |
20 |
using Newtonsoft.Json.Linq; |
21 |
using log4net.Repository.Hierarchy; |
22 |
using log4net; |
23 |
using System.IO; |
24 |
|
25 |
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log.config", Watch = true)] |
26 |
namespace KCOM_API |
27 |
{ |
28 |
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ServiceDeepView" in code, svc and config file together. |
29 |
// NOTE: In order to launch WCF Test Client for testing this service, please select ServiceDeepView.svc or ServiceDeepView.svc.cs at the Solution Explorer and start debugging. |
30 |
[ServiceContract(Namespace = "")] |
31 |
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] |
32 |
public partial class ServiceDeepView : System.Web.Services.WebService |
33 |
{ |
34 |
protected ILog logger = LogManager.GetLogger(typeof(WebService)); |
35 |
|
36 |
public ServiceDeepView() |
37 |
{ |
38 |
//System.Diagnostics.Trace.WriteLine(OperationContext.Current.RequestContext.RequestMessage.Headers.Action.ToString()); |
39 |
} |
40 |
|
41 |
/// <summary> |
42 |
/// Client Version 과 Server Version 을 비교하여 Server Version 이 최신이면 다운로드 url 리턴. |
43 |
/// </summary> |
44 |
/// <param name="is64BitProcess">64bit = true, 32bit = false</param> |
45 |
/// <param name="markusVer">client version</param> |
46 |
/// <returns></returns> |
47 |
[OperationContract] |
48 |
public string GetVersionData(bool is64BitProcess, string markusVer) |
49 |
{ |
50 |
string url = null; |
51 |
|
52 |
try |
53 |
{ |
54 |
Version client_version = new Version(markusVer); |
55 |
|
56 |
//DB에서 version 정보와 다운로드 url 을 Select |
57 |
PROPERTIES dbvalue = null; |
58 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
59 |
using (KCOMEntities uc = new KCOMEntities(sConnString)) |
60 |
{ |
61 |
string wherestr = string.Empty; |
62 |
if (is64BitProcess) |
63 |
{ |
64 |
wherestr = "Update_x64"; |
65 |
} |
66 |
else |
67 |
{ |
68 |
wherestr = "Update_x86"; |
69 |
} |
70 |
dbvalue = uc.PROPERTIES.Where(data => data.TYPE == wherestr).FirstOrDefault(); |
71 |
} |
72 |
|
73 |
//서버 버전이 최신이면 0보다 큰값 리턴 |
74 |
Version server_version = new Version(dbvalue.PROPERTY); |
75 |
int result = server_version.CompareTo(client_version); |
76 |
if (result > 0) |
77 |
{ |
78 |
url = dbvalue.VALUE; |
79 |
} |
80 |
} |
81 |
catch (Exception ex) |
82 |
{ |
83 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetVersionData : " + ex.ToString()); |
84 |
|
85 |
url = null; |
86 |
} |
87 |
return url; |
88 |
} |
89 |
|
90 |
|
91 |
[OperationContract] |
92 |
public KCOM_SystemInfo GetSystemData() |
93 |
{ |
94 |
try |
95 |
{ |
96 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
97 |
using (KCOMEntities uc = new KCOMEntities(sConnString)) |
98 |
{ |
99 |
var SystemInfoSet = uc.PROPERTIES.Where(data => data.TYPE == "SystemInfo").ToList(); |
100 |
|
101 |
KCOM_SystemInfo sysInfo = new KCOM_SystemInfo(); |
102 |
|
103 |
var url = SystemInfoSet.Where(data => data.PROPERTY == "Url").FirstOrDefault(); |
104 |
if (url != null) |
105 |
{ |
106 |
sysInfo.HostName = url.VALUE; |
107 |
} |
108 |
|
109 |
var port = SystemInfoSet.Where(data => data.PROPERTY == "Port").FirstOrDefault(); |
110 |
if (port != null) |
111 |
{ |
112 |
sysInfo.HostPort = port.VALUE; |
113 |
} |
114 |
|
115 |
var stamp = uc.PROPERTIES.Where(data => data.TYPE == "STAMP").FirstOrDefault(); |
116 |
if(stamp != null) |
117 |
{ |
118 |
sysInfo.STAMP = stamp.VALUE; |
119 |
|
120 |
} |
121 |
|
122 |
var stampContents = uc.PROPERTIES.Where(data => data.TYPE == "STAMP_CONTENTS"); |
123 |
|
124 |
if (stampContents?.Count() > 0) |
125 |
{ |
126 |
sysInfo.STAMP_CONTENTS = stampContents.ToDictionary(x => x.PROPERTY, x => x.VALUE); |
127 |
} |
128 |
|
129 |
return sysInfo; |
130 |
} |
131 |
} |
132 |
catch (Exception ex) |
133 |
{ |
134 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetSystemData : " + ex.ToString()); |
135 |
|
136 |
} |
137 |
return null; |
138 |
//GC.Collect(2); |
139 |
} |
140 |
|
141 |
private static string ShortGuid() |
142 |
{ |
143 |
byte[] bytes = new byte[16]; |
144 |
using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create()) |
145 |
{ |
146 |
provider.GetBytes(bytes); |
147 |
} |
148 |
|
149 |
var guid = new Guid(bytes); |
150 |
|
151 |
return Convert.ToBase64String(guid.ToByteArray()) |
152 |
.Substring(0, 10) |
153 |
.Replace("/", "") |
154 |
.Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x"); |
155 |
} |
156 |
|
157 |
|
158 |
[OperationContract] |
159 |
public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID) |
160 |
{ |
161 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
162 |
using (KCOMEntities dc = new KCOMEntities(sConnString)) |
163 |
{ |
164 |
|
165 |
int flagString = Convert.ToInt32(FAVORITE_FLAG.Personal); |
166 |
List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>(); |
167 |
//dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG != |
168 |
// flagString).ToList().ForEach(data => favoriteListSet.Add(data)); |
169 |
|
170 |
|
171 |
//dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data)); |
172 |
|
173 |
favoriteListSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID && data.DOCUMENT_ID == sharepointItemID).ToList(); |
174 |
|
175 |
//favoriteListSet = favoriteListSet.Distinct().ToList(); |
176 |
return favoriteListSet; |
177 |
} |
178 |
} |
179 |
|
180 |
[OperationContract] |
181 |
public bool EditFavoriteVP(string prjNo, string userID, string docID, int state, string description) |
182 |
{ |
183 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
184 |
using (KCOMEntities dc = new KCOMEntities(sConnString)) |
185 |
{ |
186 |
//List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID |
187 |
// && data.PAGE_NO == SavePageNo && data.CREATE_TIME == createTime).ToList(); |
188 |
List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID |
189 |
&& data.ID == docID).ToList(); |
190 |
try |
191 |
{ |
192 |
|
193 |
if (favoriteSet.Count > 0) |
194 |
{ |
195 |
var FavoriteVP_Instance = favoriteSet.First(); |
196 |
|
197 |
FavoriteVP_Instance.DESCRIPTION = description; |
198 |
FavoriteVP_Instance.FLAG = state; |
199 |
|
200 |
dc.SaveChanges(); |
201 |
|
202 |
return true; |
203 |
} |
204 |
else |
205 |
{ |
206 |
return false; |
207 |
} |
208 |
} |
209 |
catch (Exception ex) |
210 |
{ |
211 |
System.Diagnostics.Trace.WriteLine("KCOM_API - EditFavoriteVP : " + ex.ToString()); |
212 |
|
213 |
return false; |
214 |
} |
215 |
} |
216 |
} |
217 |
|
218 |
[OperationContract] |
219 |
public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string docID) |
220 |
{ |
221 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
222 |
using (KCOMEntities dc = new KCOMEntities(sConnString)) |
223 |
{ |
224 |
|
225 |
List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID |
226 |
&& data.ID == docID).ToList(); |
227 |
|
228 |
try |
229 |
{ |
230 |
if (favoriteSet.Count > 0) |
231 |
{ |
232 |
favoriteSet.ForEach(data => dc.FAVORITE_DOC.DeleteObject(data)); |
233 |
dc.SaveChanges(); |
234 |
return true; |
235 |
} |
236 |
else |
237 |
{ |
238 |
return false; |
239 |
} |
240 |
} |
241 |
catch (Exception ex) |
242 |
{ |
243 |
System.Diagnostics.Trace.WriteLine("KCOM_API - DelFavoriteVP : " + ex.ToString()); |
244 |
|
245 |
return false; |
246 |
} |
247 |
} |
248 |
} |
249 |
|
250 |
/// <summary> |
251 |
/// 두 페이지를 비교하여 결과를 리턴한다 |
252 |
/// </summary> |
253 |
/// <param name="projectNo"></param> |
254 |
/// <param name="originDocItem_ID"></param> |
255 |
/// <param name="targetDocItem_ID"></param> |
256 |
/// <param name="originPageNo"></param> |
257 |
/// <param name="targetPageNo"></param> |
258 |
/// <param name="isInternalAddress"></param> |
259 |
/// <returns></returns> |
260 |
[OperationContract] |
261 |
public List<Rect> GetCompareRectsTargetSize(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, bool IsResultTargatSize, string isInternalAddress) |
262 |
{ |
263 |
List<Rect> result = new List<Rect>(); |
264 |
|
265 |
string originFile = ""; |
266 |
string targetFile = ""; |
267 |
|
268 |
try |
269 |
{ |
270 |
//string sOriginFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToInt64(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID); |
271 |
//string sTagetFolder = targetDocItem_ID.All(char.IsDigit) ? (Convert.ToInt64(targetDocItem_ID) / 100).ToString() : (targetDocItem_ID.Length >= 5 ? targetDocItem_ID.Substring(0, 5) : targetDocItem_ID); |
272 |
|
273 |
string sOriginFolder = GetSubPath(originDocItem_ID); |
274 |
string sTagetFolder = GetSubPath(targetDocItem_ID); |
275 |
|
276 |
//if (Boolean.Parse(isInternalAddress)) |
277 |
//{ |
278 |
originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sOriginFolder, originDocItem_ID, originPageNo); |
279 |
targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sTagetFolder, targetDocItem_ID, targetPageNo); |
280 |
//} |
281 |
//else |
282 |
//{ |
283 |
// originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo); |
284 |
// targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo); |
285 |
//} |
286 |
|
287 |
|
288 |
System.Drawing.Size? resultSize = null; |
289 |
|
290 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
291 |
using (CIEntities _ci = new CIEntities(sCIConnString)) |
292 |
{ |
293 |
string docItemID = originDocItem_ID; |
294 |
int pageNo = Convert.ToInt32(originPageNo); |
295 |
|
296 |
if (IsResultTargatSize) |
297 |
{ |
298 |
docItemID = targetDocItem_ID; |
299 |
pageNo = Convert.ToInt32(targetPageNo); |
300 |
} |
301 |
|
302 |
var doc = _ci.DOCINFO.Where(data => data.DOCUMENT_ID == docItemID).FirstOrDefault(); |
303 |
if (doc != null) |
304 |
{ |
305 |
var pages = doc.DOCPAGE.Where(page=>page.PAGE_NUMBER == pageNo); |
306 |
|
307 |
if(pages.Count() > 0) |
308 |
{ |
309 |
resultSize = new System.Drawing.Size(Convert.ToInt32(pages.First().PAGE_WIDTH), Convert.ToInt32(pages.First().PAGE_HEIGHT)); |
310 |
} |
311 |
} |
312 |
} |
313 |
|
314 |
//using (Markus.Image.ImageCompare compareLib = new Markus.Image.ImageCompare()) |
315 |
//{ |
316 |
// //if (resultSize != null) |
317 |
// //{ |
318 |
// // result = compareLib.CompareReturnRects(originFile, targetFile, new System.Drawing.Size(10, 10),resultSize); |
319 |
// //} |
320 |
// //else |
321 |
// //{ |
322 |
// // result = compareLib.CompareReturnRects(originFile, targetFile, new System.Drawing.Size(10, 10), IsResultTargatSize); |
323 |
// //} |
324 |
//} |
325 |
} |
326 |
catch (Exception ex) |
327 |
{ |
328 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetCompareRect : " + ex.ToString()); |
329 |
throw new FaultException("system Error."); |
330 |
//throw new FaultException($"{originFile} {targetFile} " + ex.ToString() + " Inner Exception : " + ex.InnerException?.ToString()); |
331 |
} |
332 |
|
333 |
|
334 |
return result; |
335 |
} |
336 |
|
337 |
/// <summary> |
338 |
/// 두 페이지를 비교하여 결과를 리턴한다 |
339 |
/// </summary> |
340 |
/// <param name="projectNo"></param> |
341 |
/// <param name="originDocItem_ID"></param> |
342 |
/// <param name="targetDocItem_ID"></param> |
343 |
/// <param name="originPageNo"></param> |
344 |
/// <param name="targetPageNo"></param> |
345 |
/// <param name="isInternalAddress"></param> |
346 |
/// <returns></returns> |
347 |
[OperationContract] |
348 |
public List<Rect> GetCompareRect(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress) |
349 |
{ |
350 |
List<Rect> result = new List<Rect>(); |
351 |
|
352 |
string originFile = ""; |
353 |
string targetFile = ""; |
354 |
|
355 |
try |
356 |
{ |
357 |
//string sOriginFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToInt64(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID); |
358 |
//string sTagetFolder = targetDocItem_ID.All(char.IsDigit) ? (Convert.ToInt64(targetDocItem_ID) / 100).ToString() : (targetDocItem_ID.Length >= 5 ? targetDocItem_ID.Substring(0, 5) : targetDocItem_ID); |
359 |
|
360 |
string sOriginFolder = GetSubPath(originDocItem_ID); |
361 |
string sTagetFolder = GetSubPath(targetDocItem_ID); |
362 |
|
363 |
//if (Boolean.Parse(isInternalAddress)) |
364 |
//{ |
365 |
originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sOriginFolder, originDocItem_ID, originPageNo); |
366 |
targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sTagetFolder, targetDocItem_ID, targetPageNo); |
367 |
//} |
368 |
//else |
369 |
//{ |
370 |
// originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo); |
371 |
// targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo); |
372 |
//} |
373 |
|
374 |
//using (Markus.Image.ImageCompare compareLib = new Markus.Image.ImageCompare()) |
375 |
//{ |
376 |
// result = compareLib.CompareReturnRects(originFile, targetFile,new System.Drawing.Size(20, 20),false); |
377 |
//} |
378 |
} |
379 |
catch (Exception ex) |
380 |
{ |
381 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetCompareRect : " + ex.ToString()); |
382 |
throw new FaultException($"{originFile} {targetFile} " + ex.ToString() + " Inner Exception : " + ex.InnerException?.ToString()); |
383 |
} |
384 |
|
385 |
|
386 |
return result; |
387 |
} |
388 |
|
389 |
public string GetSubPath(string DocumentID) |
390 |
{ |
391 |
Int64 outValue = 0; |
392 |
if (Int64.TryParse(DocumentID, out outValue)) |
393 |
{ |
394 |
return (System.Convert.ToInt64(DocumentID) / 100).ToString(); |
395 |
} |
396 |
else |
397 |
{ |
398 |
return DocumentID.Substring(0, 5).ToString(); |
399 |
} |
400 |
} |
401 |
|
402 |
/// <summary> |
403 |
/// 두 페이지를 비교하여 결과를 리턴한다 |
404 |
/// </summary> |
405 |
/// <param name="projectNo"></param> |
406 |
/// <param name="originDocItem_ID"></param> |
407 |
/// <param name="targetDocItem_ID"></param> |
408 |
/// <param name="originPageNo"></param> |
409 |
/// <param name="targetPageNo"></param> |
410 |
/// <param name="isInternalAddress"></param> |
411 |
/// <returns></returns> |
412 |
[OperationContract] |
413 |
public List<Rect> GetComparefixSize(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo,Size FixSize, string isInternalAddress) |
414 |
{ |
415 |
List<Rect> result = new List<Rect>(); |
416 |
|
417 |
try |
418 |
{ |
419 |
string originFile = ""; |
420 |
string targetFile = ""; |
421 |
|
422 |
string sOriginFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToInt64(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID); |
423 |
string sTagetFolder = targetDocItem_ID.All(char.IsDigit) ? (Convert.ToInt64(targetDocItem_ID) / 100).ToString() : (targetDocItem_ID.Length >= 5 ? targetDocItem_ID.Substring(0, 5) : targetDocItem_ID); |
424 |
|
425 |
if (Boolean.Parse(isInternalAddress)) |
426 |
{ |
427 |
originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sOriginFolder, originDocItem_ID, originPageNo); |
428 |
targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sTagetFolder, targetDocItem_ID, targetPageNo); |
429 |
} |
430 |
else |
431 |
{ |
432 |
originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo); |
433 |
targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo); |
434 |
} |
435 |
|
436 |
//using (Markus.Image.ImageCompare compareLib = new Markus.Image.ImageCompare()) |
437 |
//{ |
438 |
|
439 |
// result = compareLib.CompareReturnRects(originFile, targetFile, new System.Drawing.Size(20, 20),false); |
440 |
//} |
441 |
} |
442 |
catch (Exception ex) |
443 |
{ |
444 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetCompareRect : " + ex.ToString()); |
445 |
//throw new FaultException(ex.ToString() + " Inner Exception : " + ex.InnerException?.ToString()); |
446 |
} |
447 |
|
448 |
|
449 |
return result; |
450 |
} |
451 |
|
452 |
//[OperationContract] |
453 |
//public List<Rect> GetCompareRect_old(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress) |
454 |
//{ |
455 |
// System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); |
456 |
|
457 |
// stopwatch.Start(); |
458 |
|
459 |
// string originFile = ""; |
460 |
// string targetFile = ""; |
461 |
|
462 |
// string sFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID); |
463 |
// if (Boolean.Parse(isInternalAddress)) |
464 |
// { |
465 |
// originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, originDocItem_ID, originPageNo); |
466 |
// targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, targetDocItem_ID, targetPageNo); |
467 |
// } |
468 |
// else |
469 |
// { |
470 |
// originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo); |
471 |
// targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo); |
472 |
// } |
473 |
|
474 |
// CompareLib compareLib = new CompareLib(); |
475 |
|
476 |
// var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile); |
477 |
// var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile); |
478 |
|
479 |
// string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget); |
480 |
// var result = compareLib.GetBoundBoxInImage(outPutFile); |
481 |
|
482 |
// System.Diagnostics.Trace.WriteLine(new TimeSpan(stopwatch.ElapsedTicks)); |
483 |
|
484 |
// return result; |
485 |
//} |
486 |
|
487 |
|
488 |
#region Final PDF |
489 |
private string _ChanID = null; |
490 |
TcpChannel chan = null; |
491 |
[OperationContract] |
492 |
public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUserID) |
493 |
{ |
494 |
#region 임시보관 |
495 |
#endregion |
496 |
FinalPDFResult _result = new FinalPDFResult(); |
497 |
RemFinalPDFObject remObj = null; |
498 |
try |
499 |
{ |
500 |
string _finalID = ShortGuid(); |
501 |
int _DocTotalPages = -1; |
502 |
string docItemId; |
503 |
|
504 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
505 |
using (CIEntities _ci = new CIEntities(sCIConnString)) |
506 |
{ |
507 |
var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID); |
508 |
|
509 |
if (_doc.Count() > 0) |
510 |
{ |
511 |
_DocTotalPages = _doc.First().PAGE_COUNT; |
512 |
docItemId = _doc.First().DOCUMENT_ID; |
513 |
} |
514 |
else |
515 |
{ |
516 |
_result.Status = FinalStatus.Error; |
517 |
_result.Exception = "페이지 정보를 가져올 수 없습니다."; |
518 |
return _result; |
519 |
} |
520 |
} |
521 |
if (_DocTotalPages > 0) |
522 |
{ |
523 |
FINAL_PDF fm = new FINAL_PDF() |
524 |
{ |
525 |
ID = _finalID, |
526 |
PROJECT_NO = ProjectNo, |
527 |
DOCINFO_ID = DocInfoID, |
528 |
DOCUMENT_ID = docItemId, |
529 |
MARKUPINFO_ID = MarkupInfoID, |
530 |
CREATE_USER_ID = CreateUserID, |
531 |
TOTAL_PAGE = _DocTotalPages, |
532 |
CREATE_DATETIME = DateTime.Now, |
533 |
STATUS = (int)IFinalPDF.FinalStatus.Insert |
534 |
}; |
535 |
|
536 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
537 |
using (KCOMEntities _entity = new KCOMEntities(sConnString)) |
538 |
{ |
539 |
_entity.AddToFINAL_PDF(fm); |
540 |
_entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave); |
541 |
}; |
542 |
|
543 |
if(KCOM_API.Properties.Settings.Default.FinalService.StartsWith("tcp")) |
544 |
{ |
545 |
System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp"); |
546 |
if (_ch == null) |
547 |
{ |
548 |
chan = new TcpChannel(); |
549 |
_ChanID = chan.ChannelName; |
550 |
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false); |
551 |
// Create an instance of the remote object |
552 |
|
553 |
using (KCOMEntities ec = new KCOMEntities(sConnString)) |
554 |
{ |
555 |
|
556 |
//remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject), |
557 |
// "tcp://localhost:9092/remFinalPDF"); |
558 |
remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject), |
559 |
//"tcp://192.168.0.67:9092/remFinalPDF"); |
560 |
KCOM_API.Properties.Settings.Default.FinalService); |
561 |
} |
562 |
|
563 |
//"tcp://localhost:8080/remFinalPDF"); |
564 |
|
565 |
_result = remObj.SetFinalPDF(ProjectNo, _finalID); |
566 |
_result.FinalID = _finalID; |
567 |
_result.Status = FinalStatus.Success; |
568 |
|
569 |
//MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF(); |
570 |
//fa.MakeFinalPDF(fm); |
571 |
} |
572 |
else |
573 |
{ |
574 |
_ChanID = _ch.ChannelName; |
575 |
} |
576 |
} |
577 |
else |
578 |
{ |
579 |
System.Net.WebClient client = new System.Net.WebClient(); |
580 |
var convertResult = client.DownloadString($"{KCOM_API.Properties.Settings.Default.FinalService}/Rest/FinalAdd?ProjectNo={ProjectNo}&FinalID={_finalID}"); |
581 |
|
582 |
JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings()); |
583 |
|
584 |
if(jObject["FinalAddResult"].ToString() == true.ToString()) |
585 |
{ |
586 |
_result.FinalID = _finalID; |
587 |
_result.Status = FinalStatus.Success; |
588 |
} |
589 |
} |
590 |
|
591 |
} |
592 |
} |
593 |
catch (Exception ex) |
594 |
{ |
595 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SetFinalPDF : " + ex.ToString()); |
596 |
|
597 |
_result.Status = FinalStatus.Error; |
598 |
|
599 |
if (ex.GetType() == typeof(System.Net.Sockets.SocketException)) |
600 |
_result.Exception = "Final Server Not Connection"; |
601 |
else _result.Exception = ex.ToString(); |
602 |
} |
603 |
finally |
604 |
{ |
605 |
remObj = null; |
606 |
if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null) |
607 |
System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan); |
608 |
|
609 |
GC.Collect(2); |
610 |
} |
611 |
return _result; |
612 |
} |
613 |
#endregion |
614 |
|
615 |
|
616 |
[OperationContract] |
617 |
public bool GetConversionState(KCOM_BasicParam param) |
618 |
{ |
619 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
620 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
621 |
{ |
622 |
var doc = entity.DOCINFO.Where(data => data.DOCUMENT_ID == param.documentID).FirstOrDefault(); |
623 |
if (doc != null) |
624 |
{ |
625 |
var count = doc.DOCPAGE.Count(data => data.DOCINFO_ID == doc.ID); |
626 |
logger.Info($"GetConversionState {doc.PAGE_COUNT} / {count}"); |
627 |
if (doc.PAGE_COUNT == count) //페이지 수가 일치하는지 |
628 |
{ |
629 |
return true; |
630 |
} |
631 |
else //페이지 수가 일치하지 않는 경우 |
632 |
{ |
633 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
634 |
KCOMEntities entity_kcom = new KCOMEntities(sConnString); |
635 |
var lst = entity_kcom.CONVERTER_DOC.Where(data => data.PROJECT_NO == param.projectNo && data.DOCUMENT_ID == param.documentID && data.TOTAL_PAGE != doc.PAGE_COUNT).ToList(); |
636 |
|
637 |
if (lst != null || lst.Count >= 1) |
638 |
{ |
639 |
//Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_PAGECOUNT"), param.documentID, param.projectNo); |
640 |
//이메일 클라이언트를 구현해야함 |
641 |
} |
642 |
return false; |
643 |
} |
644 |
} |
645 |
else |
646 |
{ |
647 |
//Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_CONVERTFAILED"), param.documentID, param.projectNo); |
648 |
//이메일 클라이언트를 구현해야함 |
649 |
return false; |
650 |
} |
651 |
} |
652 |
} |
653 |
|
654 |
[OperationContract] |
655 |
public List<VPRevision> GetVPRevisionHistory(string ProjectNo, string vpNo, string DocumentId) |
656 |
{ |
657 |
List<VPRevision> _result = new List<VPRevision>(); |
658 |
try |
659 |
{ |
660 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
661 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
662 |
{ |
663 |
var _vpList = (from docitem in entity.DOCUMENT_ITEM |
664 |
where docitem.PROJECT_NO == ProjectNo && docitem.DOCUMENT_NO == vpNo |
665 |
select new VPRevision |
666 |
{ |
667 |
RevNo = docitem.REVISION, |
668 |
GroupNo = docitem.GROUP_NO, |
669 |
FROM_VENDOR = docitem.ORIGINAL_FILE, |
670 |
DOCUMENT_ID = docitem.DOCUMENT_ID, |
671 |
TO_VENDOR = docitem.RESULT_FILE, |
672 |
RESULT = docitem.RESULT, |
673 |
DocNo = docitem.DOCUMENT_NO, |
674 |
EnsembleLink = docitem.Link |
675 |
//EnsembleLink = docitem.ENSEMBLEINFO_URL, |
676 |
//IsSyncPossible = docitem.DOCUMENT_ID == DocumentId ? false : entity.DOCINFO.Where(d => d.DOCUMENT_ID == docitem.DOCUMENT_ID).ToList().Count > 0 ? true : false |
677 |
}); |
678 |
_result = _vpList.ToList(); |
679 |
foreach (var vp in _result) |
680 |
{ |
681 |
if (entity.DOCINFO.Where(d => d.DOCUMENT_ID == vp.DOCUMENT_ID).ToList().Count > 0) |
682 |
vp.IsSyncPossible = true; |
683 |
else |
684 |
vp.IsSyncPossible = false; |
685 |
} |
686 |
|
687 |
//_result = _result.OrderByDescending(r => UInt64.Parse(System.Text.RegularExpressions.Regex.Replace(r.GroupNo, @"\D", ""))).ToList(); |
688 |
_result = _result.OrderByDescending(r => r.GroupNo).ToList(); |
689 |
} |
690 |
} |
691 |
catch (Exception ex) |
692 |
{ |
693 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetVPRevisionHistory : " + ex.ToString()); |
694 |
} |
695 |
finally |
696 |
{ |
697 |
//GC.Collect(2); |
698 |
} |
699 |
|
700 |
return _result; |
701 |
} |
702 |
|
703 |
[OperationContract] |
704 |
public VPRevision GetVPRevisionFirstOrDefault(string ProjectNo, string DocumentId) |
705 |
{ |
706 |
VPRevision _result = null; |
707 |
try |
708 |
{ |
709 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
710 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
711 |
{ |
712 |
_result = (from docitem in entity.DOCUMENT_ITEM |
713 |
where docitem.PROJECT_NO == ProjectNo && docitem.DOCUMENT_ID == DocumentId |
714 |
select new VPRevision |
715 |
{ |
716 |
RevNo = docitem.REVISION, |
717 |
GroupNo = docitem.GROUP_NO, |
718 |
FROM_VENDOR = docitem.ORIGINAL_FILE, |
719 |
DOCUMENT_ID = docitem.DOCUMENT_ID, |
720 |
TO_VENDOR = docitem.RESULT_FILE, |
721 |
RESULT = docitem.RESULT |
722 |
}).FirstOrDefault(); |
723 |
} |
724 |
} |
725 |
catch (Exception ex) |
726 |
{ |
727 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetVPRevisionFirstOrDefault : " + ex.ToString()); |
728 |
} |
729 |
finally |
730 |
{ |
731 |
//GC.Collect(2); |
732 |
} |
733 |
return _result; |
734 |
} |
735 |
|
736 |
[OperationContract] |
737 |
public DOCINFO GetDocInfo(KCOM_BasicParam param) |
738 |
{ |
739 |
DOCINFO _result = null; |
740 |
try |
741 |
{ |
742 |
// 차후 아래의 코드로 변경 |
743 |
//using (CI_Entities ModelDeeview = new CI_Entities(DaelimCiConnectionString.ToString())) |
744 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
745 |
CIEntities ModelDeeview = new CIEntities(sCIConnString); |
746 |
|
747 |
var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID && doc.PROJECT_NO == param.projectNo); |
748 |
if (docinfo.Count() > 0) |
749 |
{ |
750 |
_result = docinfo.First(); |
751 |
_result.MARKUP_INFO.Clear(); |
752 |
|
753 |
} |
754 |
return _result; |
755 |
|
756 |
} |
757 |
catch (Exception ex) |
758 |
{ |
759 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetDocInfo : " + ex.ToString()); |
760 |
} |
761 |
finally |
762 |
{ |
763 |
//GC.Collect(2); |
764 |
} |
765 |
return null; |
766 |
} |
767 |
|
768 |
[OperationContract] |
769 |
public bool GetCheckSystemAdmin(string UserID) |
770 |
{ |
771 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
772 |
using (KCOMEntities uc = new KCOMEntities(sConnString)) |
773 |
{ |
774 |
var user = uc.PROPERTIES.Where(data => data.TYPE == "Administrator" && data.PROPERTY.Contains(UserID)).FirstOrDefault(); |
775 |
if (user != null) |
776 |
{ |
777 |
return true; |
778 |
} |
779 |
else |
780 |
{ |
781 |
return false; |
782 |
} |
783 |
} |
784 |
//GC.Collect(2); |
785 |
} |
786 |
|
787 |
[OperationContract] |
788 |
public DOCUMENT_ITEM GetDocumentItemInfo(KCOM_BasicParam param) |
789 |
{ |
790 |
///param : prjNo, documentId, userId |
791 |
DOCUMENT_ITEM _result = null; |
792 |
|
793 |
try |
794 |
{ |
795 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
796 |
CIEntities entity = new CIEntities(sCIConnString); |
797 |
|
798 |
var _items = entity.DOCUMENT_ITEM.Where(data => data.PROJECT_NO == param.projectNo && data.DOCUMENT_ID == param.documentID); |
799 |
|
800 |
if (_items.Count() > 0) |
801 |
{ |
802 |
_result = _items.First(); |
803 |
|
804 |
return _result; |
805 |
} |
806 |
//else |
807 |
//{ |
808 |
// Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_DOCUMENTNOTFOUND"), param.documentID, param.projectNo); |
809 |
//} |
810 |
} |
811 |
catch (Exception ex) |
812 |
{ |
813 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetDocumentItemInfo : " + ex.ToString()); |
814 |
|
815 |
new FaultException("GetDocumentItemInfo Error - " + ex.ToString()); |
816 |
//throw new FaultException(ex.ToString()); |
817 |
//Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo); |
818 |
} |
819 |
|
820 |
return _result; |
821 |
} |
822 |
/// <summary> |
823 |
/// DOCUMENT_ITEM Table 의 ID 로 Item 을 Select |
824 |
/// </summary> |
825 |
/// 대림의 경우 Interface ID(Document 의 ID) 를 parameter 로 전달 |
826 |
/// 넘어온 ID를 통해 document id 를 확인하는 과정이 필요 |
827 |
/// <param name="ensemble_id"></param> |
828 |
/// <returns></returns> |
829 |
[OperationContract] |
830 |
public string GetDocItemID(string ensemble_id) |
831 |
{ |
832 |
///param : prjNo, documentId, userId |
833 |
string _result = string.Empty; |
834 |
|
835 |
try |
836 |
{ |
837 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
838 |
CIEntities entity = new CIEntities(sCIConnString); |
839 |
|
840 |
var _items = entity.DOCUMENT_ITEM.Where(data => data.ID == ensemble_id).FirstOrDefault(); |
841 |
if(_items != null) |
842 |
_result = _items.DOCUMENT_ID; |
843 |
} |
844 |
catch (Exception ex) |
845 |
{ |
846 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetDocItemID : " + ex.ToString()); |
847 |
//System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex); |
848 |
//Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo); |
849 |
} |
850 |
|
851 |
return _result; |
852 |
} |
853 |
public string UserGO(MARKUP_INFO item) |
854 |
{ |
855 |
if (item != null) |
856 |
{ |
857 |
return item.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID; |
858 |
} |
859 |
return null; |
860 |
} |
861 |
|
862 |
[OperationContract] |
863 |
public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId) |
864 |
{ |
865 |
List<MarkupInfoItem> _result = new List<MarkupInfoItem>(); |
866 |
try |
867 |
{ |
868 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
869 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
870 |
{ |
871 |
var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList(); |
872 |
|
873 |
var markupList = from markup in markupListData |
874 |
orderby markup.CREATE_TIME descending |
875 |
select new MarkupInfoItem |
876 |
{ |
877 |
MarkupInfoID = markup.ID, |
878 |
UserID = markup.USER_ID, |
879 |
MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID, |
880 |
CreateTime = markup.CREATE_TIME, |
881 |
Consolidate = markup.CONSOLIDATE, |
882 |
Description = markup.DESCRIPTION, |
883 |
AvoidConsolidate = markup.AVOID_CONSOLIDATE, |
884 |
PartConsolidate = markup.PART_CONSOLIDATE, |
885 |
UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()), |
886 |
}; |
887 |
|
888 |
if (markupList.Count() > 0) |
889 |
{ |
890 |
_result = markupList.ToList(); |
891 |
} |
892 |
|
893 |
_result.ForEach(r => |
894 |
{ |
895 |
|
896 |
r.MarkupList = (from markupData in entity.MARKUP_DATA |
897 |
where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID |
898 |
orderby markupData.PAGENUMBER |
899 |
select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList(); |
900 |
}); |
901 |
|
902 |
List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>(); |
903 |
Random random = new Random(); |
904 |
|
905 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
906 |
using (KCOMEntities kcomEntity = new KCOMEntities(sConnString)) |
907 |
{ |
908 |
_ColorsProperties = (from property in kcomEntity.PROPERTIES |
909 |
where property.TYPE == "DisplayColor" |
910 |
select property).ToList(); |
911 |
|
912 |
} |
913 |
|
914 |
if (_ColorsProperties.Count() != _result.GroupBy(x=>x.UserID).Count()) |
915 |
{ |
916 |
ColorGenerator uniqueColorGenerator = new ColorGenerator(System.Drawing.Color.Red); // 2303 = (int)Color.Red |
917 |
|
918 |
uniqueColorGenerator.GetEnumerator(_result.Count()); |
919 |
|
920 |
for (int i = 0; i < _result.Count(); i++) |
921 |
{ |
922 |
var c = uniqueColorGenerator.GetNext(); |
923 |
_ColorsProperties.Add(new PROPERTIES { VALUE = String.Format("{0:X2}{1:X2}{2:X2}",c.R, c.G,c.B) }); |
924 |
} |
925 |
} |
926 |
|
927 |
bool IsProjectNoPass = Properties.Settings.Default.IsProjectNoPass; |
928 |
|
929 |
foreach (var item in _result.GroupBy(x=>x.UserID)) |
930 |
{ |
931 |
string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId"; |
932 |
|
933 |
System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery |
934 |
= entity.CreateQuery<System.Data.Common.DbDataRecord>(query,new System.Data.Objects.ObjectParameter("userId",item.Key)); |
935 |
|
936 |
if (memberQuery.Count() > 0) |
937 |
{ |
938 |
string userName = memberQuery.First()["NAME"]?.ToString().Trim(); |
939 |
string depatment = memberQuery.First()["DEPARTMENT"]?.ToString().Trim(); |
940 |
|
941 |
PROPERTIES deptColor = _ColorsProperties[0]; |
942 |
|
943 |
_ColorsProperties.RemoveAt(0); |
944 |
//PROPERTIES deptColor = _ColorsProperties.Find(c => c.PROPERTY == depatment); |
945 |
|
946 |
//if (_ColorsProperties.Count > 0) |
947 |
//{ |
948 |
// if (deptColor == null) |
949 |
// { |
950 |
// item.DisplayColor = "#FF" + _ColorsProperties[0].VALUE; |
951 |
// _ColorsProperties.RemoveAt(0); |
952 |
// } |
953 |
// else |
954 |
// { |
955 |
// item.DisplayColor = "#FF" + deptColor.VALUE; |
956 |
// _ColorsProperties.Remove(deptColor); |
957 |
// } |
958 |
//} |
959 |
|
960 |
foreach (var markupInfo in item) |
961 |
{ |
962 |
markupInfo.DisplayColor = "#FF" + deptColor.VALUE; |
963 |
markupInfo.UserName = userName; |
964 |
markupInfo.Depatment = depatment; |
965 |
} |
966 |
} |
967 |
} |
968 |
|
969 |
|
970 |
//else |
971 |
//{ |
972 |
// item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000)); |
973 |
//} |
974 |
} |
975 |
} |
976 |
catch (Exception ex) |
977 |
{ |
978 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetMarkupInfoItems : " + ex.ToString()); |
979 |
|
980 |
return _result; |
981 |
} |
982 |
finally |
983 |
{ |
984 |
//GC.Collect(2); |
985 |
} |
986 |
|
987 |
return _result; |
988 |
} |
989 |
|
990 |
[OperationContract] |
991 |
public List<MarkupInfoItem> GetSyncMarkupInfoItems(string ProjectNo, string DocInfoId, string currentUser) |
992 |
{ |
993 |
List<MarkupInfoItem> _result = new List<MarkupInfoItem>(); |
994 |
try |
995 |
{ |
996 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
997 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
998 |
{ |
999 |
var docItem = entity.DOCINFO.Where(data => data.DOCUMENT_ID == DocInfoId).FirstOrDefault(); |
1000 |
if (docItem == null) |
1001 |
{ |
1002 |
return null; |
1003 |
} |
1004 |
var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == docItem.ID).ToList(); |
1005 |
|
1006 |
var markupList = from markup in markupListData |
1007 |
where markup.USER_ID == currentUser || markup.CONSOLIDATE == 1 |
1008 |
orderby markup.CREATE_TIME descending |
1009 |
select new MarkupInfoItem |
1010 |
{ |
1011 |
MarkupInfoID = markup.ID, |
1012 |
UserID = markup.USER_ID, |
1013 |
MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID, |
1014 |
CreateTime = markup.CREATE_TIME, |
1015 |
Consolidate = markup.CONSOLIDATE, |
1016 |
Description = markup.DESCRIPTION, |
1017 |
AvoidConsolidate = markup.AVOID_CONSOLIDATE, |
1018 |
PartConsolidate = markup.PART_CONSOLIDATE, |
1019 |
}; |
1020 |
|
1021 |
|
1022 |
|
1023 |
if (markupList.Count() > 0) |
1024 |
{ |
1025 |
_result = markupList.ToList(); |
1026 |
} |
1027 |
|
1028 |
|
1029 |
|
1030 |
_result.ForEach(r => |
1031 |
{ |
1032 |
|
1033 |
r.MarkupList = (from markupData in entity.MARKUP_DATA |
1034 |
where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID |
1035 |
orderby markupData.PAGENUMBER |
1036 |
select new MarkupItem |
1037 |
{ |
1038 |
ID = markupData.ID, |
1039 |
PageNumber = markupData.PAGENUMBER, |
1040 |
Data = markupData.DATA, |
1041 |
Data_Type = markupData.DATA_TYPE, |
1042 |
Symbol_ID = markupData.SYMBOL_ID |
1043 |
}).ToList(); |
1044 |
}); |
1045 |
|
1046 |
List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>(); |
1047 |
Random random = new Random(); |
1048 |
|
1049 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
1050 |
using (KCOMEntities kcomEntity = new KCOMEntities(sConnString)) |
1051 |
{ |
1052 |
_ColorsProperties = (from property in kcomEntity.PROPERTIES |
1053 |
where property.TYPE == "DisplayColor" |
1054 |
select property).ToList(); |
1055 |
} |
1056 |
|
1057 |
foreach (var item in _result) |
1058 |
{ |
1059 |
string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId"; |
1060 |
|
1061 |
System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery |
1062 |
= entity.CreateQuery<System.Data.Common.DbDataRecord>(query, new System.Data.Objects.ObjectParameter("userId", item.UserID)); |
1063 |
|
1064 |
if (memberQuery.Count() > 0) |
1065 |
{ |
1066 |
|
1067 |
string userName = memberQuery.First()["NAME"]?.ToString().Trim(); |
1068 |
string depatment = memberQuery.First()["DEPARTMENT"]?.ToString().Trim(); |
1069 |
|
1070 |
item.UserName = userName; |
1071 |
item.Depatment = depatment; |
1072 |
} |
1073 |
|
1074 |
if (_ColorsProperties.Count > 0) |
1075 |
{ |
1076 |
int colorIdx = random.Next(1, _ColorsProperties.Count()); |
1077 |
#region 부서별로 색상을 지정하고자 할때 |
1078 |
/// 일단 의견을 들어보자구! |
1079 |
#endregion |
1080 |
item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE; |
1081 |
_ColorsProperties.Remove(_ColorsProperties[colorIdx]); |
1082 |
//item.DisplayColor = "#FF" + _Colors.First(); |
1083 |
//_Colors.Remove(_Colors.First()); |
1084 |
} |
1085 |
else |
1086 |
{ |
1087 |
item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000)); |
1088 |
} |
1089 |
} |
1090 |
} |
1091 |
} |
1092 |
catch (Exception ex) |
1093 |
{ |
1094 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetSyncMarkupInfoItems : " + ex.ToString()); |
1095 |
return _result; |
1096 |
} |
1097 |
finally |
1098 |
{ |
1099 |
//GC.Collect(2); |
1100 |
} |
1101 |
|
1102 |
return _result; |
1103 |
} |
1104 |
|
1105 |
|
1106 |
//[OperationContract] |
1107 |
//[ServiceKnownType(typeof(MEMBER))] |
1108 |
//public List<MEMBER> GetUserData(string ProjectNo, string UserID) |
1109 |
//{ |
1110 |
// List<MEMBER> _result = new List<MEMBER>(); |
1111 |
|
1112 |
// using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
1113 |
// { |
1114 |
// var _UserList = from member in entity.MEMBER |
1115 |
// where member.ID == UserID |
1116 |
// select member; |
1117 |
// _result = _UserList.ToList(); |
1118 |
// } |
1119 |
// //GC.Collect(2); |
1120 |
// return _result; |
1121 |
//} |
1122 |
|
1123 |
[OperationContract] |
1124 |
[ServiceKnownType(typeof(MEMBER))] |
1125 |
public List<MEMBER> GetUserData(string ProjectNo, string UserID) |
1126 |
{ |
1127 |
List<MEMBER> _result = new List<MEMBER>(); |
1128 |
|
1129 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1130 |
|
1131 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
1132 |
{ |
1133 |
_result = GetMemberQuery(entity, UserID); |
1134 |
} |
1135 |
//GC.Collect(2); |
1136 |
return _result; |
1137 |
} |
1138 |
|
1139 |
|
1140 |
[OperationContract] |
1141 |
public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정 |
1142 |
{ |
1143 |
List<string> _result = new List<string>(); |
1144 |
|
1145 |
try |
1146 |
{ |
1147 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
1148 |
KCOMEntities entity = new KCOMEntities(sConnString); |
1149 |
var YourEnginner = (from dept in entity.PROPERTIES |
1150 |
where dept.TYPE == "DeptName" && UserDept.Contains(dept.VALUE) |
1151 |
select dept).FirstOrDefault(); |
1152 |
|
1153 |
if (YourEnginner != null) |
1154 |
{ |
1155 |
_result = (from dept in entity.PROPERTIES |
1156 |
where dept.PROPERTY == YourEnginner.PROPERTY |
1157 |
select dept.VALUE).ToList(); |
1158 |
return _result; |
1159 |
} |
1160 |
else |
1161 |
{ |
1162 |
return null; |
1163 |
} |
1164 |
} |
1165 |
catch (Exception ex) |
1166 |
{ |
1167 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetDeptData : " + ex.ToString()); |
1168 |
} |
1169 |
finally |
1170 |
{ |
1171 |
//GC.Collect(2); |
1172 |
} |
1173 |
return _result; |
1174 |
} |
1175 |
|
1176 |
[OperationContract] |
1177 |
public bool DeleteMarkup(string ProjectNo, string MarkupInfoID) |
1178 |
{ |
1179 |
bool _result = false; |
1180 |
try |
1181 |
{ |
1182 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1183 |
using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(sCIConnString)) |
1184 |
{ |
1185 |
|
1186 |
MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault(); |
1187 |
|
1188 |
if (instance == null) |
1189 |
{ |
1190 |
return false; |
1191 |
} |
1192 |
MARKUP_INFO_VERSION version = instance.MARKUP_INFO_VERSION.FirstOrDefault(); |
1193 |
|
1194 |
|
1195 |
version.MARKUP_DATA.ToList().ForEach(data => |
1196 |
{ |
1197 |
Entity.MARKUP_DATA.DeleteObject(data); |
1198 |
Entity.SaveChanges(); |
1199 |
}); |
1200 |
|
1201 |
Entity.MARKUP_INFO_VERSION.DeleteObject(version); |
1202 |
Entity.SaveChanges(); |
1203 |
|
1204 |
Entity.MARKUP_INFO.DeleteObject(instance); |
1205 |
Entity.SaveChanges(); |
1206 |
|
1207 |
} |
1208 |
_result = true; |
1209 |
} |
1210 |
catch (Exception ex) |
1211 |
{ |
1212 |
System.Diagnostics.Trace.WriteLine("KCOM_API - DeleteMarkup : " + ex.ToString()); |
1213 |
} |
1214 |
finally |
1215 |
{ |
1216 |
//GC.Collect(2); |
1217 |
} |
1218 |
return _result; |
1219 |
} |
1220 |
|
1221 |
#region Favorite |
1222 |
[OperationContract] |
1223 |
public bool SetFavoriteVP(string prjNo, string userID, string groupNo, string docNo, string rev, int SavePageNo, string documentItemID, string VPDescription, IKCOM.FAVORITE_FLAG flag) |
1224 |
{ |
1225 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
1226 |
using (KCOMEntities entity = new KCOMEntities(sConnString)) |
1227 |
{ |
1228 |
try |
1229 |
{ |
1230 |
entity.FAVORITE_DOC.AddObject(new FAVORITE_DOC |
1231 |
{ |
1232 |
ID = ShortGuid(), |
1233 |
PROJECT_NO = prjNo, |
1234 |
DOCUMENT_ID = documentItemID, |
1235 |
GROUP_NO = groupNo, |
1236 |
DOCUMENT_NO = docNo, |
1237 |
MEMBER_USER_ID = userID, |
1238 |
DESCRIPTION = VPDescription, |
1239 |
CREATE_TIME = DateTime.Now, |
1240 |
REVISION = rev, |
1241 |
FLAG = (int)flag, |
1242 |
PAGE_NO = SavePageNo, |
1243 |
}); |
1244 |
entity.SaveChanges(); |
1245 |
} |
1246 |
catch (Exception ex) |
1247 |
{ |
1248 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SetFavoriteVP : " + ex.ToString()); |
1249 |
return false; |
1250 |
} |
1251 |
|
1252 |
return true; |
1253 |
} |
1254 |
} |
1255 |
|
1256 |
//[OperationContract] |
1257 |
//public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID) |
1258 |
//{ |
1259 |
// using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
1260 |
// { |
1261 |
|
1262 |
// int flagString = Convert.ToInt32(IKCOM.FAVORITE_FLAG.Personal); |
1263 |
// List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>(); |
1264 |
// entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG != |
1265 |
// flagString).ToList().ForEach(data => favoriteListSet.Add(data)); |
1266 |
// entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data)); |
1267 |
// favoriteListSet = favoriteListSet.Distinct().ToList(); |
1268 |
// return favoriteListSet; |
1269 |
// } |
1270 |
//} |
1271 |
//[OperationContract] |
1272 |
//public bool EditFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime, int state, string description) |
1273 |
//{ |
1274 |
// using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
1275 |
// { |
1276 |
// List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID |
1277 |
// && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList(); |
1278 |
|
1279 |
// try |
1280 |
// { |
1281 |
|
1282 |
|
1283 |
// if (favoriteSet.Count > 0) |
1284 |
// { |
1285 |
// var FavoriteVP_Instance = favoriteSet.First(); |
1286 |
|
1287 |
// FavoriteVP_Instance.Description = description; |
1288 |
// FavoriteVP_Instance.Flag = state; |
1289 |
|
1290 |
// dc.SaveChanges(); |
1291 |
|
1292 |
// return true; |
1293 |
// } |
1294 |
// else |
1295 |
// { |
1296 |
// return false; |
1297 |
// } |
1298 |
// } |
1299 |
// catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1300 |
// { |
1301 |
// return false; |
1302 |
// } |
1303 |
// } |
1304 |
//} |
1305 |
//[OperationContract] |
1306 |
//public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime) |
1307 |
//{ |
1308 |
|
1309 |
// using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
1310 |
// { |
1311 |
// List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID |
1312 |
// && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList(); |
1313 |
|
1314 |
// try |
1315 |
// { |
1316 |
|
1317 |
|
1318 |
// if (favoriteSet.Count > 0) |
1319 |
// { |
1320 |
// favoriteSet.ForEach(data => dc.FavoriteVP.DeleteObject(data)); |
1321 |
// dc.SaveChanges(); |
1322 |
// return true; |
1323 |
// } |
1324 |
// else |
1325 |
// { |
1326 |
// return false; |
1327 |
// } |
1328 |
// } |
1329 |
// catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1330 |
// { |
1331 |
// return false; |
1332 |
// } |
1333 |
// } |
1334 |
//} |
1335 |
#endregion |
1336 |
|
1337 |
[OperationContract] |
1338 |
public bool SaveMarkupData(MarkupInfoItem UserState,string project_no,string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data) |
1339 |
{ |
1340 |
|
1341 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1342 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1343 |
{ |
1344 |
#region Docinfo 정보 가져오기 |
1345 |
|
1346 |
string docinfoid_ = (from info in Entity.DOCINFO |
1347 |
where info.DOCUMENT_ID == doc_id |
1348 |
&& info.PROJECT_NO == project_no |
1349 |
select info.ID |
1350 |
).First().ToString(); |
1351 |
#endregion |
1352 |
|
1353 |
#region Markup_Info 저장 |
1354 |
|
1355 |
MARKUP_INFO markup_info = new MARKUP_INFO(); |
1356 |
try |
1357 |
{ |
1358 |
markup_info = (from info in Entity.MARKUP_INFO |
1359 |
where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id |
1360 |
select info).FirstOrDefault(); |
1361 |
} |
1362 |
catch (Exception ex) |
1363 |
{ |
1364 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SaveMarkupData Get markup_info: " + ex.ToString()); |
1365 |
markup_info = null; |
1366 |
} |
1367 |
|
1368 |
//markup_info가 없을 경우 생성 |
1369 |
if (markup_info == null) |
1370 |
{ |
1371 |
//MarkupInfo 저장 |
1372 |
markup_info = new MARKUP_INFO |
1373 |
{ |
1374 |
ID = UserState.MarkupInfoID, |
1375 |
DOCINFO_ID = docinfoid_, |
1376 |
USER_ID = user_id, |
1377 |
CREATE_TIME = DateTime.Now, |
1378 |
CONSOLIDATE = UserState.Consolidate, |
1379 |
AVOID_CONSOLIDATE = UserState.AvoidConsolidate, |
1380 |
PART_CONSOLIDATE = UserState.PartConsolidate, |
1381 |
DESCRIPTION = UserState.Description, |
1382 |
UPDATE_TIME = DateTime.Now |
1383 |
}; |
1384 |
Entity.MARKUP_INFO.AddObject(markup_info); |
1385 |
} |
1386 |
//markup_info가 있을 경우 업데이트 |
1387 |
else |
1388 |
{ |
1389 |
markup_info.UPDATE_TIME = DateTime.Now; |
1390 |
} |
1391 |
Entity.SaveChanges(); |
1392 |
#endregion |
1393 |
|
1394 |
#region Markup_Info_Version 저장 |
1395 |
|
1396 |
MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION(); |
1397 |
|
1398 |
try |
1399 |
{ |
1400 |
markup_info_version = (from info in Entity.MARKUP_INFO_VERSION |
1401 |
where info.MARKUPINFO_ID == markup_info.ID |
1402 |
select info).FirstOrDefault(); |
1403 |
} |
1404 |
catch (Exception ex) |
1405 |
{ |
1406 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SaveMarkupData Get markup_info_version : " + ex.ToString()); |
1407 |
markup_info_version = null; |
1408 |
} |
1409 |
|
1410 |
//markup_info_version 없을 경우 생성 |
1411 |
if (markup_info_version == null) |
1412 |
{ |
1413 |
//MarkupInfo_version 저장 |
1414 |
markup_info_version = new MARKUP_INFO_VERSION() |
1415 |
{ |
1416 |
ID = UserState.MarkupVersionID, |
1417 |
MARKUPINFO_ID = markup_info.ID, |
1418 |
CREATE_DATE = DateTime.Now |
1419 |
}; |
1420 |
Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version); |
1421 |
Entity.SaveChanges(); |
1422 |
} |
1423 |
#endregion |
1424 |
|
1425 |
|
1426 |
Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item => |
1427 |
{ |
1428 |
Entity.MARKUP_DATA.DeleteObject(item); |
1429 |
}); |
1430 |
|
1431 |
Entity.SaveChanges(); |
1432 |
|
1433 |
try |
1434 |
{ |
1435 |
mlmarkup_data.ForEach(value => |
1436 |
{ |
1437 |
Entity.MARKUP_DATA.AddObject(new MARKUP_DATA |
1438 |
{ |
1439 |
ID = value.ID, |
1440 |
DATA = value.DATA, |
1441 |
DATA_TYPE = value.DATA_TYPE, |
1442 |
PAGENUMBER = value.PAGENUMBER, |
1443 |
MARKUPINFO_VERSION_ID = markup_info_version.ID, |
1444 |
SYMBOL_ID = value.SYMBOL_ID, |
1445 |
//GROUP_ID = value.GROUP_ID |
1446 |
}); |
1447 |
|
1448 |
|
1449 |
}); |
1450 |
Entity.SaveChanges(); |
1451 |
|
1452 |
if (Properties.Settings.Default.Properties["CLIENT_VERSION"] != null) |
1453 |
{ |
1454 |
string sql = $"UPDATE MARKUP_DATA SET REMARK = '{Properties.Settings.Default.CLIENT_VERSION} {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }' WHERE ID = @ID"; |
1455 |
|
1456 |
mlmarkup_data.ForEach(value => |
1457 |
{ |
1458 |
var param = new System.Data.Common.DbParameter[] { new System.Data.SqlClient.SqlParameter { ParameterName = "ID", Value = value.ID } }; |
1459 |
var result = Entity.ExecuteStoreCommand(sql, param); |
1460 |
}); |
1461 |
|
1462 |
Entity.SaveChanges(); |
1463 |
} |
1464 |
} |
1465 |
catch (Exception ex) |
1466 |
{ |
1467 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SaveMarkupData set mlmarkup_data : " + ex.ToString()); |
1468 |
return false; |
1469 |
} |
1470 |
} |
1471 |
return true; |
1472 |
} |
1473 |
|
1474 |
[OperationContract] |
1475 |
public bool SavePageMarkupData(MarkupInfoItem UserState,int PageNo, string project_no, string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data) |
1476 |
{ |
1477 |
|
1478 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1479 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1480 |
{ |
1481 |
#region Docinfo 정보 가져오기 |
1482 |
|
1483 |
string docinfoid_ = (from info in Entity.DOCINFO |
1484 |
where info.DOCUMENT_ID == doc_id |
1485 |
&& info.PROJECT_NO == project_no |
1486 |
select info.ID |
1487 |
).First().ToString(); |
1488 |
#endregion |
1489 |
|
1490 |
#region Markup_Info 저장 |
1491 |
|
1492 |
MARKUP_INFO markup_info = new MARKUP_INFO(); |
1493 |
try |
1494 |
{ |
1495 |
markup_info = (from info in Entity.MARKUP_INFO |
1496 |
where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id |
1497 |
select info).FirstOrDefault(); |
1498 |
} |
1499 |
catch (Exception ex) |
1500 |
{ |
1501 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SavePageMarkupData : " + ex.ToString()); |
1502 |
|
1503 |
markup_info = null; |
1504 |
} |
1505 |
|
1506 |
//markup_info가 없을 경우 생성 |
1507 |
if (markup_info == null) |
1508 |
{ |
1509 |
//MarkupInfo 저장 |
1510 |
markup_info = new MARKUP_INFO |
1511 |
{ |
1512 |
ID = UserState.MarkupInfoID, |
1513 |
DOCINFO_ID = docinfoid_, |
1514 |
USER_ID = user_id, |
1515 |
CREATE_TIME = DateTime.Now, |
1516 |
CONSOLIDATE = UserState.Consolidate, |
1517 |
AVOID_CONSOLIDATE = UserState.AvoidConsolidate, |
1518 |
PART_CONSOLIDATE = UserState.PartConsolidate, |
1519 |
DESCRIPTION = UserState.Description, |
1520 |
UPDATE_TIME = DateTime.Now |
1521 |
}; |
1522 |
Entity.MARKUP_INFO.AddObject(markup_info); |
1523 |
} |
1524 |
//markup_info가 있을 경우 업데이트 |
1525 |
else |
1526 |
{ |
1527 |
markup_info.UPDATE_TIME = DateTime.Now; |
1528 |
} |
1529 |
Entity.SaveChanges(); |
1530 |
#endregion |
1531 |
|
1532 |
#region Markup_Info_Version 저장 |
1533 |
|
1534 |
MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION(); |
1535 |
|
1536 |
try |
1537 |
{ |
1538 |
markup_info_version = (from info in Entity.MARKUP_INFO_VERSION |
1539 |
where info.MARKUPINFO_ID == markup_info.ID |
1540 |
select info).FirstOrDefault(); |
1541 |
} |
1542 |
catch (Exception ex) |
1543 |
{ |
1544 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SavePageMarkupData get markup_info_version : " + ex.ToString()); |
1545 |
markup_info_version = null; |
1546 |
} |
1547 |
|
1548 |
//markup_info_version 없을 경우 생성 |
1549 |
if (markup_info_version == null) |
1550 |
{ |
1551 |
//MarkupInfo_version 저장 |
1552 |
markup_info_version = new MARKUP_INFO_VERSION() |
1553 |
{ |
1554 |
ID = UserState.MarkupVersionID, |
1555 |
MARKUPINFO_ID = markup_info.ID, |
1556 |
CREATE_DATE = DateTime.Now |
1557 |
}; |
1558 |
Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version); |
1559 |
Entity.SaveChanges(); |
1560 |
} |
1561 |
#endregion |
1562 |
|
1563 |
|
1564 |
Entity.MARKUP_DATA.Where(data => data.PAGENUMBER == PageNo && data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item => |
1565 |
{ |
1566 |
Entity.MARKUP_DATA.DeleteObject(item); |
1567 |
}); |
1568 |
Entity.SaveChanges(); |
1569 |
|
1570 |
try |
1571 |
{ |
1572 |
mlmarkup_data.ForEach(value => |
1573 |
{ |
1574 |
Entity.MARKUP_DATA.AddObject(new MARKUP_DATA |
1575 |
{ |
1576 |
ID = value.ID, |
1577 |
DATA = value.DATA, |
1578 |
DATA_TYPE = value.DATA_TYPE, |
1579 |
PAGENUMBER = value.PAGENUMBER, |
1580 |
MARKUPINFO_VERSION_ID = markup_info_version.ID, |
1581 |
SYMBOL_ID = value.SYMBOL_ID, |
1582 |
//GROUP_ID = value.GROUP_ID |
1583 |
}); |
1584 |
}); |
1585 |
Entity.SaveChanges(); |
1586 |
} |
1587 |
catch (Exception ex) |
1588 |
{ |
1589 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SavePageMarkupData set mlmarkup_data : " + ex.ToString()); |
1590 |
return false; |
1591 |
} |
1592 |
} |
1593 |
return true; |
1594 |
} |
1595 |
|
1596 |
//[OperationContract] |
1597 |
//public long AddMarkupDataGroup(MARKUP_DATA_GROUP mARKUP_DATA_GROUP, string ProjectNo) |
1598 |
//{ |
1599 |
// try |
1600 |
// { |
1601 |
// using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
1602 |
// { |
1603 |
// Entity.AddToMARKUP_DATA_GROUP(mARKUP_DATA_GROUP); |
1604 |
// //MARKUP_DATA_GROUP tt = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == id).FirstOrDefault(); |
1605 |
// Entity.SaveChanges(); |
1606 |
|
1607 |
// return Entity.MARKUP_DATA_GROUP.ToList().LastOrDefault().ID; |
1608 |
// } |
1609 |
// } |
1610 |
// catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1611 |
// { |
1612 |
// return 0; |
1613 |
// } |
1614 |
//} |
1615 |
//[OperationContract] |
1616 |
//public bool UpdateMarkupDataGroup(long Group_ID, string ProjectNo) |
1617 |
//{ |
1618 |
// try |
1619 |
// { |
1620 |
// using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
1621 |
// { |
1622 |
// var UpdateItem = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == Group_ID).FirstOrDefault(); |
1623 |
// UpdateItem.STATE = 1; |
1624 |
// Entity.SaveChanges(); |
1625 |
// } |
1626 |
// } |
1627 |
// catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1628 |
// { |
1629 |
// return false; |
1630 |
// } |
1631 |
// return true; |
1632 |
//} |
1633 |
[OperationContract] |
1634 |
public bool UpdateMarkupData(string CommentID, long Group_ID, string ProjectNo) |
1635 |
{ |
1636 |
try |
1637 |
{ |
1638 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1639 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1640 |
{ |
1641 |
var UpdateItem = Entity.MARKUP_DATA.Where(info => info.ID == CommentID).FirstOrDefault(); |
1642 |
//UpdateItem.GROUP_ID = Group_ID; |
1643 |
Entity.SaveChanges(); |
1644 |
} |
1645 |
} |
1646 |
catch (Exception ex) |
1647 |
{ |
1648 |
System.Diagnostics.Trace.WriteLine("KCOM_API - UpdateMarkupData: " + ex.ToString()); |
1649 |
return false; |
1650 |
} |
1651 |
return true; |
1652 |
} |
1653 |
|
1654 |
[OperationContract] |
1655 |
public bool SaveSymbol(SYMBOL_PRIVATE symbol_private) |
1656 |
{ |
1657 |
try |
1658 |
{ |
1659 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
1660 |
using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString)) |
1661 |
{ |
1662 |
uc.AddToSYMBOL_PRIVATE(symbol_private); |
1663 |
uc.SaveChanges(); |
1664 |
} |
1665 |
} |
1666 |
catch (Exception ex) |
1667 |
{ |
1668 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SaveSymbol: " + ex.ToString()); |
1669 |
return false; |
1670 |
} |
1671 |
return true; |
1672 |
} |
1673 |
[OperationContract] |
1674 |
public bool AddPublicSymbol(SYMBOL_PUBLIC symbol) |
1675 |
{ |
1676 |
try |
1677 |
{ |
1678 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
1679 |
using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString)) |
1680 |
{ |
1681 |
uc.AddToSYMBOL_PUBLIC(symbol); |
1682 |
uc.SaveChanges(); |
1683 |
} |
1684 |
} |
1685 |
catch (Exception ex) |
1686 |
{ |
1687 |
System.Diagnostics.Trace.WriteLine("KCOM_API - AddPublicSymbol: " + ex.ToString()); |
1688 |
return false; |
1689 |
} |
1690 |
return true; |
1691 |
} |
1692 |
[OperationContract] |
1693 |
public bool DeleteSymbol(string symbol_id, int type) |
1694 |
{ |
1695 |
try |
1696 |
{ |
1697 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
1698 |
using (KCOMEntities Entity = new KCOMEntities(sConnString)) |
1699 |
{ |
1700 |
if (type == 0) |
1701 |
{ |
1702 |
string delItem_ID = symbol_id; |
1703 |
var delitem = Entity.SYMBOL_PRIVATE.Where(data => data.ID == delItem_ID).FirstOrDefault(); |
1704 |
Entity.SYMBOL_PRIVATE.DeleteObject(delitem); |
1705 |
Entity.SaveChanges(); |
1706 |
} |
1707 |
else |
1708 |
{ |
1709 |
string delItem_ID = symbol_id; |
1710 |
var delitem = Entity.SYMBOL_PUBLIC.Where(data => data.ID == delItem_ID).FirstOrDefault(); |
1711 |
Entity.SYMBOL_PUBLIC.DeleteObject(delitem); |
1712 |
Entity.SaveChanges(); |
1713 |
} |
1714 |
} |
1715 |
} |
1716 |
catch (Exception ex) |
1717 |
{ |
1718 |
System.Diagnostics.Trace.WriteLine("KCOM_API - DeleteSymbol : " + ex.ToString()); |
1719 |
|
1720 |
return false; |
1721 |
} |
1722 |
return true; |
1723 |
} |
1724 |
|
1725 |
[OperationContract] |
1726 |
public bool RenameSymbol(string symbol_id, string name, int type) |
1727 |
{ |
1728 |
try |
1729 |
{ |
1730 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
1731 |
using (KCOMEntities Entity = new KCOMEntities(sConnString)) |
1732 |
{ |
1733 |
if (type == 0) |
1734 |
{ |
1735 |
var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == symbol_id).FirstOrDefault(); |
1736 |
UpdateItem.NAME = name; |
1737 |
Entity.SaveChanges(); |
1738 |
} |
1739 |
else |
1740 |
{ |
1741 |
var UpdateItem = Entity.SYMBOL_PUBLIC.Where(info => info.ID == symbol_id).FirstOrDefault(); |
1742 |
UpdateItem.NAME = name; |
1743 |
Entity.SaveChanges(); |
1744 |
} |
1745 |
} |
1746 |
} |
1747 |
catch (Exception ex) |
1748 |
{ |
1749 |
System.Diagnostics.Trace.WriteLine("KCOM_API - RenameSymbol: " + ex.ToString()); |
1750 |
return false; |
1751 |
} |
1752 |
return true; |
1753 |
} |
1754 |
|
1755 |
[OperationContract] |
1756 |
public bool AddCheckListHistory(string project_no, CHECK_LIST_HISTORY Check_History) |
1757 |
{ |
1758 |
try |
1759 |
{ |
1760 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1761 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1762 |
{ |
1763 |
Entity.CHECK_LIST_HISTORY.AddObject(Check_History); |
1764 |
Entity.SaveChanges(); |
1765 |
} |
1766 |
} |
1767 |
catch (Exception ex) |
1768 |
{ |
1769 |
System.Diagnostics.Trace.WriteLine("KCOM_API - AddCheckListHistory: " + ex.ToString()); |
1770 |
return false; |
1771 |
} |
1772 |
return true; |
1773 |
} |
1774 |
[OperationContract] |
1775 |
public bool SaveCheckListHistory(string project_no, string rev, CHECK_LIST_HISTORY Check_History) |
1776 |
{ |
1777 |
try |
1778 |
{ |
1779 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1780 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1781 |
{ |
1782 |
var item = Entity.CHECK_LIST_HISTORY.Where(info => info.REVISION == rev).FirstOrDefault(); |
1783 |
item = Check_History; |
1784 |
Entity.SaveChanges(); |
1785 |
} |
1786 |
} |
1787 |
catch (Exception ex) |
1788 |
{ |
1789 |
System.Diagnostics.Trace.WriteLine("KCOM_API - SaveCheckListHistory: " + ex.ToString()); |
1790 |
return false; |
1791 |
} |
1792 |
return true; |
1793 |
} |
1794 |
[OperationContract] |
1795 |
public bool SaveCheckList(string project_no, string _id, CHECK_LIST Check_value) |
1796 |
{ |
1797 |
try |
1798 |
{ |
1799 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1800 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1801 |
{ |
1802 |
var item = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault(); |
1803 |
item.TODOLIST = Check_value.TODOLIST; |
1804 |
item.REMARK = Check_value.REMARK; |
1805 |
item.STATUS = Check_value.STATUS; |
1806 |
item.VENDOR = Check_value.VENDOR; |
1807 |
item.REPLY = Check_value.REPLY; |
1808 |
item.IMAGE_URL = Check_value.IMAGE_URL; |
1809 |
item.IMAGE_ANCHOR = Check_value.IMAGE_ANCHOR; |
1810 |
item.UPDATE_TIME = Check_value.UPDATE_TIME; |
1811 |
if(Check_value.STATUS == "False") |
1812 |
{ |
1813 |
item.STATUS_DESC_OPEN = Check_value.STATUS_DESC_OPEN; |
1814 |
} |
1815 |
else |
1816 |
{ |
1817 |
item.STATUS_DESC_CLOSE = Check_value.STATUS_DESC_CLOSE; |
1818 |
} |
1819 |
Entity.SaveChanges(); |
1820 |
} |
1821 |
} |
1822 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1823 |
return false; |
1824 |
} |
1825 |
return true; |
1826 |
} |
1827 |
[OperationContract] |
1828 |
public bool AddCheckList(string project_no, CHECK_LIST Check_value) |
1829 |
{ |
1830 |
try |
1831 |
{ |
1832 |
|
1833 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1834 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1835 |
{ |
1836 |
Entity.CHECK_LIST.AddObject(Check_value); |
1837 |
Entity.SaveChanges(); |
1838 |
} |
1839 |
} |
1840 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1841 |
return false; |
1842 |
} |
1843 |
return true; |
1844 |
} |
1845 |
|
1846 |
[OperationContract] |
1847 |
public CHECK_LIST GetCheckList(string project_no, string _id) |
1848 |
{ |
1849 |
CHECK_LIST Check_value = new CHECK_LIST(); |
1850 |
try |
1851 |
{ |
1852 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1853 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1854 |
{ |
1855 |
Check_value = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault(); |
1856 |
} |
1857 |
} |
1858 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1859 |
return null; |
1860 |
} |
1861 |
return Check_value; |
1862 |
} |
1863 |
[OperationContract] |
1864 |
public List<CHECK_LIST> GetUserCheckList(string project_no, string user_id, string doc_no) |
1865 |
{ |
1866 |
List<CHECK_LIST> list = new List<CHECK_LIST>(); |
1867 |
try |
1868 |
{ |
1869 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1870 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1871 |
{ |
1872 |
list = Entity.CHECK_LIST.Where(i => i.PROJECT_NO == project_no && i.DOCUMENT_NO == doc_no && i.USER_ID == user_id).OrderBy(p => p.CREATE_TIME).ToList(); |
1873 |
} |
1874 |
} |
1875 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1876 |
return null; |
1877 |
} |
1878 |
return list; |
1879 |
} |
1880 |
[OperationContract] |
1881 |
public List<CHECK_LIST_HISTORY> GetCheckListHistory(string project_no, string _id) |
1882 |
{ |
1883 |
List<CHECK_LIST_HISTORY> history = new List<CHECK_LIST_HISTORY>(); |
1884 |
try |
1885 |
{ |
1886 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1887 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1888 |
{ |
1889 |
history = Entity.CHECK_LIST_HISTORY.Where(data => data.CHECKLIST_ID == _id).ToList(); |
1890 |
} |
1891 |
} |
1892 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1893 |
return null; |
1894 |
} |
1895 |
return history; |
1896 |
} |
1897 |
[OperationContract] |
1898 |
public CHECK_LIST_HISTORY GetCheckListHistoryFirstOrDefault(string project_no, string checklist_id, string rev) |
1899 |
{ |
1900 |
CHECK_LIST_HISTORY Check_Item = new CHECK_LIST_HISTORY(); |
1901 |
try |
1902 |
{ |
1903 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1904 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1905 |
{ |
1906 |
Check_Item = Entity.CHECK_LIST_HISTORY.Where(info => info.CHECKLIST_ID == checklist_id && info.REVISION == rev).FirstOrDefault(); |
1907 |
} |
1908 |
} |
1909 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1910 |
return null; |
1911 |
} |
1912 |
return Check_Item; |
1913 |
} |
1914 |
[OperationContract] |
1915 |
public bool SavePageAngle(string project_no, List<DOCPAGE> _mldocpage) |
1916 |
{ |
1917 |
try |
1918 |
{ |
1919 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1920 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1921 |
{ |
1922 |
KCOMDataModel.DataModel.DOCPAGE _docpage = new KCOMDataModel.DataModel.DOCPAGE(); |
1923 |
_mldocpage.ForEach(data => |
1924 |
{ |
1925 |
_docpage = (from info in Entity.DOCPAGE |
1926 |
where info.ID == data.ID |
1927 |
select info).FirstOrDefault(); |
1928 |
|
1929 |
if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE) |
1930 |
{ |
1931 |
_docpage.PAGE_ANGLE = data.PAGE_ANGLE; |
1932 |
} |
1933 |
}); |
1934 |
|
1935 |
Entity.SaveChanges(); |
1936 |
} |
1937 |
} |
1938 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1939 |
return false; |
1940 |
} |
1941 |
return true; |
1942 |
} |
1943 |
|
1944 |
[OperationContract] |
1945 |
public MARKUP_INFO GetMarkupInfo(string project_no, string _id) |
1946 |
{ |
1947 |
MARKUP_INFO markupInfo = new MARKUP_INFO(); |
1948 |
|
1949 |
try |
1950 |
{ |
1951 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1952 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1953 |
{ |
1954 |
markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault(); |
1955 |
} |
1956 |
} |
1957 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1958 |
return null; |
1959 |
} |
1960 |
return markupInfo; |
1961 |
} |
1962 |
|
1963 |
[OperationContract] |
1964 |
public List<string> GetMarkupDataListperPage(string project_no, string _markupinfoid, int _pageNo) |
1965 |
{ |
1966 |
List<string> markupdata = new List<string>(); |
1967 |
MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION(); |
1968 |
try |
1969 |
{ |
1970 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1971 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1972 |
{ |
1973 |
markup_info_version = (from version in Entity.MARKUP_INFO_VERSION |
1974 |
where version.MARKUPINFO_ID == _markupinfoid |
1975 |
orderby version.CREATE_DATE descending |
1976 |
select version).First(); |
1977 |
markupdata = (from data in Entity.MARKUP_DATA |
1978 |
where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo |
1979 |
select data.DATA).ToList(); |
1980 |
} |
1981 |
} |
1982 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
1983 |
return null; |
1984 |
} |
1985 |
return markupdata; |
1986 |
} |
1987 |
|
1988 |
[OperationContract] |
1989 |
public bool AddMarkupInfo(string project_no, MARKUP_INFO value) |
1990 |
{ |
1991 |
try |
1992 |
{ |
1993 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
1994 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
1995 |
{ |
1996 |
Entity.MARKUP_INFO.AddObject(value); |
1997 |
Entity.SaveChanges(); |
1998 |
} |
1999 |
} |
2000 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2001 |
return false; |
2002 |
} |
2003 |
return true; |
2004 |
} |
2005 |
|
2006 |
[OperationContract] |
2007 |
public bool AddMarkupInfoVersion(string project_no, MARKUP_INFO_VERSION value) |
2008 |
{ |
2009 |
try |
2010 |
{ |
2011 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2012 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2013 |
{ |
2014 |
Entity.MARKUP_INFO_VERSION.AddObject(value); |
2015 |
Entity.SaveChanges(); |
2016 |
} |
2017 |
} |
2018 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2019 |
return false; |
2020 |
} |
2021 |
return true; |
2022 |
} |
2023 |
|
2024 |
[OperationContract] |
2025 |
public bool AddMarkupData(string project_no, MARKUP_DATA value) |
2026 |
{ |
2027 |
try |
2028 |
{ |
2029 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2030 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2031 |
{ |
2032 |
Entity.MARKUP_DATA.AddObject(value); |
2033 |
Entity.SaveChanges(); |
2034 |
} |
2035 |
} |
2036 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2037 |
return false; |
2038 |
} |
2039 |
return true; |
2040 |
} |
2041 |
|
2042 |
[OperationContract] |
2043 |
public bool AvoidMarkupInfo(string project_no, string _doc_id) |
2044 |
{ |
2045 |
try |
2046 |
{ |
2047 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2048 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2049 |
{ |
2050 |
var item = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault(); |
2051 |
item.AVOID_CONSOLIDATE = 1; |
2052 |
Entity.SaveChanges(); |
2053 |
} |
2054 |
} |
2055 |
catch (Exception ex) { |
2056 |
System.Diagnostics.Trace.WriteLine(ex); |
2057 |
return false; |
2058 |
} |
2059 |
return true; |
2060 |
} |
2061 |
|
2062 |
[OperationContract] |
2063 |
public bool SaveMarkupInfo(string project_no, string _id, MARKUP_INFO value) |
2064 |
{ |
2065 |
try |
2066 |
{ |
2067 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2068 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2069 |
{ |
2070 |
var item = Entity.MARKUP_INFO.Where(info => info.ID == _id).FirstOrDefault(); |
2071 |
item = value; |
2072 |
Entity.SaveChanges(); |
2073 |
} |
2074 |
} |
2075 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2076 |
return false; |
2077 |
} |
2078 |
return true; |
2079 |
} |
2080 |
[OperationContract] |
2081 |
public List<MARKUP_DATA> GetMarkupDataList(string project_no, string _versionid) |
2082 |
{ |
2083 |
List<MARKUP_DATA> mlresult = new List<MARKUP_DATA>(); |
2084 |
|
2085 |
try |
2086 |
{ |
2087 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2088 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2089 |
{ |
2090 |
mlresult = Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == _versionid).ToList(); |
2091 |
} |
2092 |
} |
2093 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2094 |
return null; |
2095 |
} |
2096 |
return mlresult; |
2097 |
} |
2098 |
|
2099 |
[OperationContract] |
2100 |
public bool Consolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems) |
2101 |
{ |
2102 |
try |
2103 |
{ |
2104 |
List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>(); |
2105 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2106 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2107 |
{ |
2108 |
var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.CONSOLIDATE == 1).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault(); |
2109 |
if (markupInfo != null) |
2110 |
{ |
2111 |
markupInfo.AVOID_CONSOLIDATE = 1; |
2112 |
} |
2113 |
|
2114 |
foreach (MarkupInfoItem item in markupInfoItems) |
2115 |
{ |
2116 |
Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d => |
2117 |
{ |
2118 |
instanceDataSet.Add(d); |
2119 |
}); |
2120 |
} |
2121 |
|
2122 |
KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO(); |
2123 |
info.ID = ShortGuid(); |
2124 |
info.CONSOLIDATE = 1; |
2125 |
info.CREATE_TIME = DateTime.Now; |
2126 |
info.DOCINFO_ID = _doc_id; |
2127 |
info.UPDATE_TIME = DateTime.Now; |
2128 |
info.USER_ID = _user_id; |
2129 |
info.AVOID_CONSOLIDATE = 0; |
2130 |
|
2131 |
Entity.MARKUP_INFO.AddObject(info); |
2132 |
|
2133 |
|
2134 |
KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION |
2135 |
{ |
2136 |
ID = ShortGuid(), |
2137 |
CREATE_DATE = DateTime.Now, |
2138 |
MARKUP_INFO = info, |
2139 |
}; |
2140 |
|
2141 |
foreach (var item in instanceDataSet) |
2142 |
{ |
2143 |
Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA |
2144 |
{ |
2145 |
ID = ShortGuid(), |
2146 |
DATA = item.DATA, |
2147 |
DATA_TYPE = item.DATA_TYPE, |
2148 |
PAGENUMBER = item.PAGENUMBER, |
2149 |
MARKUP_INFO_VERSION = info2, |
2150 |
SYMBOL_ID = item.SYMBOL_ID, |
2151 |
//GROUP_ID = item.GROUP_ID |
2152 |
}); |
2153 |
} |
2154 |
|
2155 |
Entity.SaveChanges(); |
2156 |
} |
2157 |
} |
2158 |
catch (Exception ex) { |
2159 |
System.Diagnostics.Trace.WriteLine(ex); |
2160 |
return false; |
2161 |
} |
2162 |
return true; |
2163 |
} |
2164 |
|
2165 |
|
2166 |
[OperationContract] |
2167 |
public FinalPDFResult ConsolidateMergedPDF(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems, string ProjectNo, string DocInfoID, string CreateUserID) |
2168 |
{ |
2169 |
bool consolidate = false; |
2170 |
try |
2171 |
{ |
2172 |
List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>(); |
2173 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2174 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2175 |
{ |
2176 |
var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault(); |
2177 |
if (markupInfo.CONSOLIDATE == 1) |
2178 |
{ |
2179 |
markupInfo.AVOID_CONSOLIDATE = 1; |
2180 |
} |
2181 |
|
2182 |
foreach (MarkupInfoItem item in markupInfoItems) |
2183 |
{ |
2184 |
Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d => |
2185 |
{ |
2186 |
instanceDataSet.Add(d); |
2187 |
}); |
2188 |
} |
2189 |
|
2190 |
KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO(); |
2191 |
info.ID = ShortGuid(); |
2192 |
info.CONSOLIDATE = 1; |
2193 |
info.CREATE_TIME = DateTime.Now; |
2194 |
info.DOCINFO_ID = _doc_id; |
2195 |
info.UPDATE_TIME = DateTime.Now; |
2196 |
info.USER_ID = _user_id; |
2197 |
info.AVOID_CONSOLIDATE = 0; |
2198 |
|
2199 |
Entity.MARKUP_INFO.AddObject(info); |
2200 |
Entity.SaveChanges(); |
2201 |
|
2202 |
|
2203 |
KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION |
2204 |
{ |
2205 |
ID = ShortGuid(), |
2206 |
CREATE_DATE = DateTime.Now, |
2207 |
MARKUP_INFO = info, |
2208 |
}; |
2209 |
Entity.SaveChanges(); |
2210 |
|
2211 |
foreach (var item in instanceDataSet) |
2212 |
{ |
2213 |
Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA |
2214 |
{ |
2215 |
ID = ShortGuid(), |
2216 |
DATA = item.DATA, |
2217 |
DATA_TYPE = item.DATA_TYPE, |
2218 |
PAGENUMBER = item.PAGENUMBER, |
2219 |
MARKUP_INFO_VERSION = info2, |
2220 |
SYMBOL_ID = item.SYMBOL_ID, |
2221 |
//GROUP_ID = item.GROUP_ID |
2222 |
}); |
2223 |
} |
2224 |
Entity.SaveChanges(); |
2225 |
|
2226 |
|
2227 |
} |
2228 |
consolidate = true; |
2229 |
} |
2230 |
catch (Exception ex) |
2231 |
{ |
2232 |
System.Diagnostics.Trace.WriteLine(ex); |
2233 |
consolidate = false; |
2234 |
} |
2235 |
|
2236 |
FinalPDFResult _result = new FinalPDFResult(); |
2237 |
if (consolidate == true) |
2238 |
{ |
2239 |
RemFinalPDFObject remObj = null; |
2240 |
try |
2241 |
{ |
2242 |
string _finalID = ShortGuid(); |
2243 |
int _DocTotalPages = -1; |
2244 |
string docItemId; |
2245 |
|
2246 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2247 |
using (CIEntities _ci = new CIEntities(sCIConnString)) |
2248 |
{ |
2249 |
var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID); |
2250 |
|
2251 |
if (_doc.Count() > 0) |
2252 |
{ |
2253 |
_DocTotalPages = _doc.First().PAGE_COUNT; |
2254 |
docItemId = _doc.First().DOCUMENT_ID; |
2255 |
} |
2256 |
else |
2257 |
{ |
2258 |
_result.Status = FinalStatus.Error; |
2259 |
_result.Exception = "페이지 정보를 가져올 수 없습니다."; |
2260 |
return _result; |
2261 |
} |
2262 |
} |
2263 |
|
2264 |
var Items = GetMarkupInfoItems(ProjectNo, DocInfoID); |
2265 |
if (_DocTotalPages > 0) |
2266 |
{ |
2267 |
var item2 = Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault(); |
2268 |
FINAL_PDF fm = new FINAL_PDF() |
2269 |
{ |
2270 |
ID = _finalID, |
2271 |
PROJECT_NO = ProjectNo, |
2272 |
DOCINFO_ID = DocInfoID, |
2273 |
DOCUMENT_ID = docItemId, |
2274 |
MARKUPINFO_ID = item2.MarkupInfoID, |
2275 |
CREATE_USER_ID = CreateUserID, |
2276 |
TOTAL_PAGE = _DocTotalPages, |
2277 |
CREATE_DATETIME = DateTime.Now, |
2278 |
STATUS = (int)IFinalPDF.FinalStatus.Insert |
2279 |
}; |
2280 |
|
2281 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
2282 |
using (KCOMEntities _entity = new KCOMEntities(sConnString)) |
2283 |
{ |
2284 |
_entity.AddToFINAL_PDF(fm); |
2285 |
_entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave); |
2286 |
}; |
2287 |
|
2288 |
System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp"); |
2289 |
if (_ch == null) |
2290 |
{ |
2291 |
chan = new TcpChannel(); |
2292 |
_ChanID = chan.ChannelName; |
2293 |
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false); |
2294 |
// Create an instance of the remote object |
2295 |
|
2296 |
using (KCOMEntities ec = new KCOMEntities(sConnString)) |
2297 |
{ |
2298 |
|
2299 |
//remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject), |
2300 |
// "tcp://localhost:9092/remFinalPDF"); |
2301 |
remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject), |
2302 |
//"tcp://192.168.0.67:9092/remFinalPDF"); |
2303 |
"tcp://192.168.0.67:9092/remFinalPDF"); |
2304 |
} |
2305 |
|
2306 |
//"tcp://localhost:8080/remFinalPDF"); |
2307 |
|
2308 |
_result = remObj.SetFinalPDF(ProjectNo, _finalID); |
2309 |
_result.FinalID = _finalID; |
2310 |
_result.Status = FinalStatus.Success; |
2311 |
|
2312 |
//MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF(); |
2313 |
//fa.MakeFinalPDF(fm); |
2314 |
} |
2315 |
else |
2316 |
{ |
2317 |
_ChanID = _ch.ChannelName; |
2318 |
} |
2319 |
} |
2320 |
} |
2321 |
catch (Exception ex) |
2322 |
{ |
2323 |
_result.Status = FinalStatus.Error; |
2324 |
|
2325 |
if (ex.GetType() == typeof(System.Net.Sockets.SocketException)) |
2326 |
_result.Exception = "Final Server Not Connection"; |
2327 |
} |
2328 |
finally |
2329 |
{ |
2330 |
remObj = null; |
2331 |
if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null) |
2332 |
System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan); |
2333 |
|
2334 |
GC.Collect(2); |
2335 |
} |
2336 |
} |
2337 |
return _result; |
2338 |
} |
2339 |
[OperationContract] |
2340 |
public bool TeamConsolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems) |
2341 |
{ |
2342 |
try |
2343 |
{ |
2344 |
List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>(); |
2345 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2346 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2347 |
{ |
2348 |
var members = GetMemberQuery(Entity, _user_id); |
2349 |
|
2350 |
string user_dept = ""; |
2351 |
|
2352 |
if(members.Count() > 0) |
2353 |
{ |
2354 |
user_dept = members.First().DEPARTMENT; |
2355 |
} |
2356 |
|
2357 |
var markupInfos = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.PART_CONSOLIDATE == 1) |
2358 |
.OrderByDescending(j => j.CREATE_TIME).ToList(); |
2359 |
|
2360 |
foreach (var markupinfo in markupInfos) |
2361 |
{ |
2362 |
string markupdept = ""; |
2363 |
|
2364 |
var markupMembers = GetMemberQuery(Entity, markupinfo.USER_ID); |
2365 |
|
2366 |
if (markupMembers.Count() > 0) |
2367 |
{ |
2368 |
markupdept = markupMembers.First().DEPARTMENT; |
2369 |
} |
2370 |
|
2371 |
if (user_dept == markupdept) |
2372 |
{ |
2373 |
markupinfo.AVOID_CONSOLIDATE = 1; |
2374 |
} |
2375 |
} |
2376 |
|
2377 |
foreach (MarkupInfoItem item in markupInfoItems) |
2378 |
{ |
2379 |
Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d => |
2380 |
{ |
2381 |
instanceDataSet.Add(d); |
2382 |
}); |
2383 |
} |
2384 |
|
2385 |
KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO(); |
2386 |
info.ID = ShortGuid(); |
2387 |
info.PART_CONSOLIDATE = 1; |
2388 |
info.CREATE_TIME = DateTime.Now; |
2389 |
info.DOCINFO_ID = _doc_id; |
2390 |
info.UPDATE_TIME = DateTime.Now; |
2391 |
info.USER_ID = _user_id; |
2392 |
info.AVOID_CONSOLIDATE = 0; |
2393 |
|
2394 |
Entity.MARKUP_INFO.AddObject(info); |
2395 |
Entity.SaveChanges(); |
2396 |
|
2397 |
|
2398 |
KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION |
2399 |
{ |
2400 |
ID = ShortGuid(), |
2401 |
CREATE_DATE = DateTime.Now, |
2402 |
MARKUP_INFO = info, |
2403 |
}; |
2404 |
Entity.SaveChanges(); |
2405 |
|
2406 |
foreach (var item in instanceDataSet) |
2407 |
{ |
2408 |
Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA |
2409 |
{ |
2410 |
ID = ShortGuid(), |
2411 |
DATA = item.DATA, |
2412 |
DATA_TYPE = item.DATA_TYPE, |
2413 |
PAGENUMBER = item.PAGENUMBER, |
2414 |
MARKUP_INFO_VERSION = info2, |
2415 |
SYMBOL_ID = item.SYMBOL_ID, |
2416 |
//GROUP_ID = item.GROUP_ID |
2417 |
}); |
2418 |
} |
2419 |
Entity.SaveChanges(); |
2420 |
|
2421 |
|
2422 |
} |
2423 |
} |
2424 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2425 |
return false; |
2426 |
} |
2427 |
return true; |
2428 |
} |
2429 |
|
2430 |
[OperationContract] |
2431 |
[ServiceKnownType(typeof(MEMBER))] |
2432 |
public MEMBER GetMember(string project_no, string user_id) |
2433 |
{ |
2434 |
MEMBER rstmember = null; |
2435 |
try |
2436 |
{ |
2437 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2438 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2439 |
{ |
2440 |
var members = GetMemberQuery(Entity, user_id); |
2441 |
|
2442 |
if(members.Count() > 0) |
2443 |
{ |
2444 |
rstmember = members.First(); |
2445 |
} |
2446 |
} |
2447 |
} |
2448 |
catch (Exception ex) |
2449 |
{ |
2450 |
return null; |
2451 |
} |
2452 |
return rstmember; |
2453 |
} |
2454 |
|
2455 |
private List<MEMBER> GetMemberQuery(System.Data.Objects.ObjectContext context, string UserID) |
2456 |
{ |
2457 |
List<MEMBER> result = new List<MEMBER>(); |
2458 |
|
2459 |
try |
2460 |
{ |
2461 |
string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId"; |
2462 |
|
2463 |
var param = new[] { new System.Data.Objects.ObjectParameter("userId", UserID) }; |
2464 |
|
2465 |
System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery |
2466 |
= context.CreateQuery<System.Data.Common.DbDataRecord>(query, param); |
2467 |
|
2468 |
if (memberQuery.Count() > 0) |
2469 |
{ |
2470 |
foreach (var dataRecord in memberQuery) |
2471 |
{ |
2472 |
MEMBER member = new MEMBER(); |
2473 |
|
2474 |
string userName = dataRecord["NAME"]?.ToString().Trim(); |
2475 |
string ID = dataRecord["ID"]?.ToString().Trim(); |
2476 |
string depatment = dataRecord["DEPARTMENT"]?.ToString().Trim(); |
2477 |
|
2478 |
member.NAME = userName; |
2479 |
member.ID = ID; |
2480 |
member.DEPARTMENT = depatment; |
2481 |
|
2482 |
result.Add(member); |
2483 |
} |
2484 |
} |
2485 |
} |
2486 |
catch (Exception ex) |
2487 |
{ |
2488 |
throw new Exception("GetMember(System.Data.Objects.ObjectContext context, string UserID) " , ex); |
2489 |
} |
2490 |
|
2491 |
return result; |
2492 |
} |
2493 |
|
2494 |
[WebMethod] |
2495 |
[OperationContract] |
2496 |
public List<SYMBOL_PRIVATE> GetSymbolList(string user_id) |
2497 |
{ |
2498 |
List<SYMBOL_PRIVATE> Custom_List = new List<SYMBOL_PRIVATE>(); |
2499 |
try |
2500 |
{ |
2501 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
2502 |
using (KCOMEntities Entity = new KCOMEntities(sConnString)) |
2503 |
{ |
2504 |
Custom_List = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == user_id).ToList(); |
2505 |
} |
2506 |
} |
2507 |
catch (Exception ex) |
2508 |
{ |
2509 |
return null; |
2510 |
} |
2511 |
return Custom_List; |
2512 |
} |
2513 |
[OperationContract] |
2514 |
public List<string> GetPublicSymbolDeptList() |
2515 |
{ |
2516 |
List<string> Custom_List = new List<string>(); |
2517 |
try |
2518 |
{ |
2519 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
2520 |
using (KCOMEntities Entity = new KCOMEntities(sConnString)) |
2521 |
{ |
2522 |
Custom_List = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).Distinct().ToList(); |
2523 |
} |
2524 |
} |
2525 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2526 |
return null; |
2527 |
} |
2528 |
return Custom_List; |
2529 |
} |
2530 |
[OperationContract] |
2531 |
public List<SYMBOL_PUBLIC> GetPublicSymbolList(string dept) |
2532 |
{ |
2533 |
List<SYMBOL_PUBLIC> Custom_List = new List<SYMBOL_PUBLIC>(); |
2534 |
try |
2535 |
{ |
2536 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
2537 |
using (KCOMEntities Entity = new KCOMEntities(sConnString)) |
2538 |
{ |
2539 |
if(!string.IsNullOrEmpty(dept)) |
2540 |
{ |
2541 |
Custom_List = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == dept).ToList(); |
2542 |
} |
2543 |
else |
2544 |
{ |
2545 |
Custom_List = Entity.SYMBOL_PUBLIC.ToList(); |
2546 |
} |
2547 |
|
2548 |
} |
2549 |
} |
2550 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2551 |
return null; |
2552 |
} |
2553 |
return Custom_List; |
2554 |
} |
2555 |
|
2556 |
/// <summary> |
2557 |
/// |
2558 |
/// </summary> |
2559 |
/// <param name="id">symbol id</param> |
2560 |
/// <param name="type"> 0 : PRIVATE, 1 : PUBLIC</param> |
2561 |
/// <returns></returns> |
2562 |
[OperationContract] |
2563 |
public string GetSymbolData(string id, int type) |
2564 |
{ |
2565 |
string result; |
2566 |
try |
2567 |
{ |
2568 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
2569 |
using (KCOMEntities Entity = new KCOMEntities(sConnString)) |
2570 |
{ |
2571 |
if(type == 0) |
2572 |
{ |
2573 |
result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA; |
2574 |
} |
2575 |
else |
2576 |
{ |
2577 |
result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA; |
2578 |
} |
2579 |
} |
2580 |
} |
2581 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2582 |
return null; |
2583 |
} |
2584 |
return result; |
2585 |
} |
2586 |
[OperationContract] |
2587 |
public string GetSymbolImageURL(string id, int type) |
2588 |
{ |
2589 |
string result; |
2590 |
try |
2591 |
{ |
2592 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
2593 |
using (KCOMEntities Entity = new KCOMEntities(sConnString)) |
2594 |
{ |
2595 |
if (type == 0) |
2596 |
{ |
2597 |
result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL; |
2598 |
} |
2599 |
else |
2600 |
{ |
2601 |
result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL; |
2602 |
} |
2603 |
} |
2604 |
} |
2605 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2606 |
return null; |
2607 |
} |
2608 |
return result; |
2609 |
} |
2610 |
|
2611 |
[OperationContract] |
2612 |
public string GetSignData(string project_no, string user_id) |
2613 |
{ |
2614 |
string result = null; |
2615 |
try |
2616 |
{ |
2617 |
string ifsign = getEnsembleSign(user_id); |
2618 |
if (string.IsNullOrEmpty(ifsign)) |
2619 |
{ |
2620 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2621 |
var ModelWFConnectionString = sCIConnString; |
2622 |
if (null != ModelWFConnectionString) |
2623 |
{ |
2624 |
using (CIEntities entity = new CIEntities(ModelWFConnectionString)) |
2625 |
{ |
2626 |
var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id); |
2627 |
if (_sign.Count() > 0) |
2628 |
{ |
2629 |
result = _sign.First().SIGN_STR; |
2630 |
} |
2631 |
else |
2632 |
{ |
2633 |
return null; |
2634 |
} |
2635 |
} |
2636 |
} |
2637 |
} |
2638 |
else |
2639 |
{ |
2640 |
result = ifsign; |
2641 |
} |
2642 |
|
2643 |
} |
2644 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2645 |
return null; |
2646 |
} |
2647 |
return result; |
2648 |
} |
2649 |
|
2650 |
[OperationContract] |
2651 |
public string GetSignStrokes(string project_no, string user_id) |
2652 |
{ |
2653 |
string result = null; |
2654 |
try |
2655 |
{ |
2656 |
string ifsign = getEnsembleSign(user_id); |
2657 |
if (string.IsNullOrEmpty(ifsign)) |
2658 |
{ |
2659 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2660 |
var ModelWFConnectionString = sCIConnString; |
2661 |
if (null != ModelWFConnectionString) |
2662 |
{ |
2663 |
using (CIEntities entity = new CIEntities(ModelWFConnectionString)) |
2664 |
{ |
2665 |
var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id); |
2666 |
if (_sign.Count() > 0) |
2667 |
{ |
2668 |
result = _sign.First().SIGN_STROKES; |
2669 |
} |
2670 |
else |
2671 |
{ |
2672 |
return null; |
2673 |
} |
2674 |
} |
2675 |
} |
2676 |
} |
2677 |
else |
2678 |
{ |
2679 |
result = ifsign; |
2680 |
} |
2681 |
|
2682 |
} |
2683 |
catch (Exception ex) |
2684 |
{ |
2685 |
System.Diagnostics.Trace.WriteLine(ex); |
2686 |
return null; |
2687 |
} |
2688 |
return result; |
2689 |
} |
2690 |
|
2691 |
[OperationContract] |
2692 |
public int SetSignData(string user_id,string SignStr,int CropX,int CropY,int CropWidth,int CropHeight) |
2693 |
{ |
2694 |
int result = -1; |
2695 |
|
2696 |
try |
2697 |
{ |
2698 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2699 |
|
2700 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
2701 |
{ |
2702 |
var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id); |
2703 |
|
2704 |
var cropImg = Convert.ToBase64String(SignatureCrop(SignStr, CropX, CropY, CropWidth, CropHeight)); |
2705 |
|
2706 |
if (_sign.Count() > 0) |
2707 |
{ |
2708 |
_sign.First().SIGN_STR = cropImg; |
2709 |
_sign.First().MODIFY_DATE = DateTime.Now; |
2710 |
} |
2711 |
else |
2712 |
{ |
2713 |
entity.SIGN_INFO.AddObject(new SIGN_INFO |
2714 |
{ |
2715 |
ID = ShortGuid(), |
2716 |
MEMBER_USER_ID = user_id, |
2717 |
CREATE_DATE = DateTime.Now, |
2718 |
SIGN_STR = cropImg |
2719 |
}); |
2720 |
} |
2721 |
|
2722 |
result = entity.SaveChanges(); |
2723 |
} |
2724 |
} |
2725 |
catch (Exception ex) |
2726 |
{ |
2727 |
System.Diagnostics.Trace.WriteLine(ex); |
2728 |
} |
2729 |
return result; |
2730 |
} |
2731 |
|
2732 |
|
2733 |
[OperationContract] |
2734 |
public int SetSignStrokes(string user_id, string strokesData) |
2735 |
{ |
2736 |
int result = -1; |
2737 |
|
2738 |
try |
2739 |
{ |
2740 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2741 |
|
2742 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
2743 |
{ |
2744 |
var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id); |
2745 |
|
2746 |
if (_sign.Count() > 0) |
2747 |
{ |
2748 |
_sign.First().SIGN_STROKES = strokesData; |
2749 |
_sign.First().MODIFY_DATE = DateTime.Now; |
2750 |
} |
2751 |
else |
2752 |
{ |
2753 |
entity.SIGN_INFO.AddObject(new SIGN_INFO |
2754 |
{ |
2755 |
ID = ShortGuid(), |
2756 |
MEMBER_USER_ID = user_id, |
2757 |
CREATE_DATE = DateTime.Now, |
2758 |
SIGN_STROKES = strokesData |
2759 |
}); |
2760 |
} |
2761 |
|
2762 |
result = entity.SaveChanges(); |
2763 |
} |
2764 |
} |
2765 |
catch (Exception ex) |
2766 |
{ |
2767 |
System.Diagnostics.Trace.WriteLine(ex); |
2768 |
} |
2769 |
return result; |
2770 |
} |
2771 |
|
2772 |
private byte[] SignatureCrop(string imgStr,int X,int Y,int Width,int Height) |
2773 |
{ |
2774 |
using (System.IO.MemoryStream readStream = new System.IO.MemoryStream(Convert.FromBase64String(imgStr))) |
2775 |
{ |
2776 |
using (System.Drawing.Image OriginalImage = System.Drawing.Image.FromStream(readStream)) |
2777 |
{ |
2778 |
using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Width, Height)) |
2779 |
{ |
2780 |
bmp.SetResolution(OriginalImage.HorizontalResolution, OriginalImage.VerticalResolution); |
2781 |
using (System.Drawing.Graphics Graphic = System.Drawing.Graphics.FromImage(bmp)) |
2782 |
{ |
2783 |
Graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; |
2784 |
Graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; |
2785 |
Graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; |
2786 |
Graphic.DrawImage(OriginalImage, new System.Drawing.Rectangle(0, 0, Width, Height), X, Y, Width, Height, System.Drawing.GraphicsUnit.Pixel); |
2787 |
System.IO.MemoryStream ms = new System.IO.MemoryStream(); |
2788 |
bmp.Save(ms, OriginalImage.RawFormat); |
2789 |
return ms.GetBuffer(); |
2790 |
} |
2791 |
} |
2792 |
} |
2793 |
} |
2794 |
} |
2795 |
|
2796 |
[OperationContract] |
2797 |
public string GetProjectName(string project_no) |
2798 |
{ |
2799 |
string result = null; |
2800 |
|
2801 |
try |
2802 |
{ |
2803 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
2804 |
using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(sConnString)) |
2805 |
{ |
2806 |
result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString(); |
2807 |
} |
2808 |
} |
2809 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2810 |
return null; |
2811 |
} |
2812 |
return result; |
2813 |
} |
2814 |
|
2815 |
[OperationContract] |
2816 |
public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev) |
2817 |
{ |
2818 |
List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>(); |
2819 |
|
2820 |
try |
2821 |
{ |
2822 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2823 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2824 |
{ |
2825 |
result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no |
2826 |
&& i.DOCUMENT_NO == doc_no |
2827 |
&& i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList(); |
2828 |
} |
2829 |
} |
2830 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2831 |
return null; |
2832 |
} |
2833 |
return result; |
2834 |
} |
2835 |
|
2836 |
[OperationContract] |
2837 |
public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id) |
2838 |
{ |
2839 |
DOCINFO docinfo = null; |
2840 |
|
2841 |
try |
2842 |
{ |
2843 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2844 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2845 |
{ |
2846 |
docinfo = (from info in Entity.DOCINFO |
2847 |
where info.DOCUMENT_ID == doc_id |
2848 |
&& info.PROJECT_NO == project_no |
2849 |
select info).First(); |
2850 |
} |
2851 |
} |
2852 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2853 |
return null; |
2854 |
} |
2855 |
return docinfo; |
2856 |
} |
2857 |
|
2858 |
[OperationContract] |
2859 |
public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList) |
2860 |
{ |
2861 |
MarkupInfoItem _result = null; |
2862 |
List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>(); |
2863 |
try |
2864 |
{ |
2865 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2866 |
using (CIEntities Entity = new CIEntities(sCIConnString)) |
2867 |
{ |
2868 |
var docitem = (from info in Entity.DOCINFO |
2869 |
where info.DOCUMENT_ID == doc_id |
2870 |
&& info.PROJECT_NO == project_no |
2871 |
select info).First(); |
2872 |
|
2873 |
foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO) |
2874 |
{ |
2875 |
var members = GetMemberQuery(Entity, markinfo.USER_ID); |
2876 |
|
2877 |
MEMBER member = new MEMBER(); |
2878 |
|
2879 |
if (members.Count() > 0) |
2880 |
{ |
2881 |
member = members.First(); |
2882 |
} |
2883 |
|
2884 |
string displaycolor = null; |
2885 |
|
2886 |
try |
2887 |
{ |
2888 |
displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor; |
2889 |
} |
2890 |
catch (Exception ex) |
2891 |
{ |
2892 |
System.Diagnostics.Trace.WriteLine("KCOM_API - GetPrintDocItemList displaycolor : " + ex.ToString()); |
2893 |
|
2894 |
displaycolor = "#FFFFFF"; |
2895 |
} |
2896 |
|
2897 |
_result = new MarkupInfoItem |
2898 |
{ |
2899 |
MarkupInfoID = markinfo.ID, |
2900 |
Consolidate = markinfo.CONSOLIDATE, |
2901 |
CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME, |
2902 |
DisplayColor = displaycolor, |
2903 |
UserID = markinfo.USER_ID, |
2904 |
UserName = member.NAME, |
2905 |
Depatment = member.DEPARTMENT, |
2906 |
}; |
2907 |
|
2908 |
_result.MarkupList = new List<IKCOM.MarkupItem>(); |
2909 |
var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First(); |
2910 |
|
2911 |
foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA) |
2912 |
{ |
2913 |
MarkupItem markitem = new MarkupItem() |
2914 |
{ |
2915 |
ID = markdata.ID, |
2916 |
PageNumber = markdata.PAGENUMBER, |
2917 |
}; |
2918 |
_result.MarkupList.Add(markitem); |
2919 |
} |
2920 |
|
2921 |
_result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count(); |
2922 |
|
2923 |
markupinfo.Add(_result); |
2924 |
} |
2925 |
} |
2926 |
} |
2927 |
catch (Exception ex) |
2928 |
{ |
2929 |
return null; |
2930 |
} |
2931 |
return markupinfo; |
2932 |
} |
2933 |
|
2934 |
[OperationContract] |
2935 |
public bool AddMessage(string project_no, TALK value) |
2936 |
{ |
2937 |
try |
2938 |
{ |
2939 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2940 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
2941 |
{ |
2942 |
entity.TALK.AddObject(value); |
2943 |
entity.SaveChanges(); |
2944 |
} |
2945 |
} |
2946 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
2947 |
return false; |
2948 |
} |
2949 |
return true; |
2950 |
} |
2951 |
|
2952 |
[OperationContract] |
2953 |
public List<TALK> GetMessage(string project_no, string doc_id) |
2954 |
{ |
2955 |
List<TALK> result = new List<TALK>(); |
2956 |
try |
2957 |
{ |
2958 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
2959 |
using (CIEntities entity = new CIEntities(sCIConnString)) |
2960 |
{ |
2961 |
result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList(); |
2962 |
} |
2963 |
} |
2964 |
catch (Exception ex) |
2965 |
{ |
2966 |
return result; |
2967 |
} |
2968 |
return result; |
2969 |
} |
2970 |
|
2971 |
|
2972 |
#region Legacy System I/F |
2973 |
/// <summary> |
2974 |
/// Ensemble+ Sign Data Return |
2975 |
/// </summary> |
2976 |
/// <param name="user_id"></param> |
2977 |
/// <returns></returns> |
2978 |
private string getEnsembleSign(string user_id) |
2979 |
{ |
2980 |
string result = null; |
2981 |
string soapurl = string.Empty; |
2982 |
|
2983 |
try |
2984 |
{ |
2985 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
2986 |
using (KCOMEntities Entity = new KCOMEntities(sConnString)) |
2987 |
{ |
2988 |
var item = Entity.PROPERTIES.Where(d => d.TYPE == "UpLoadServiceUrl").FirstOrDefault(); |
2989 |
|
2990 |
if (item != null) |
2991 |
{ |
2992 |
soapurl = item.VALUE; |
2993 |
|
2994 |
WebClient webClient = new WebClient(); |
2995 |
string data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ens=\"http://EnsemblePlus.Webservice\"> <soapenv:Header/> <soapenv:Body> <ens:checkoutSignImage>" |
2996 |
+ "<ens:sUserNo>" + user_id + "</ens:sUserNo>" |
2997 |
+ "</ens:checkoutSignImage> </soapenv:Body></soapenv:Envelope>"; |
2998 |
webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml"); |
2999 |
webClient.Headers.Add("SOAPAction", "http://EnsemblePlus.Webservice"); |
3000 |
var _result = webClient.UploadString(new Uri(soapurl), data); |
3001 |
XmlDocument xmlDoc = new XmlDocument(); |
3002 |
xmlDoc.LoadXml(_result); |
3003 |
XmlNodeList list = xmlDoc.GetElementsByTagName("checkoutSignImageResponse"); |
3004 |
|
3005 |
foreach (XmlNode xn in list) |
3006 |
{ |
3007 |
result = xn["checkoutSignImageReturn"].InnerText; |
3008 |
} |
3009 |
|
3010 |
if (result.Contains("No business object")) |
3011 |
{ |
3012 |
result = null; |
3013 |
} |
3014 |
} |
3015 |
else |
3016 |
{ |
3017 |
result = null; |
3018 |
} |
3019 |
} |
3020 |
|
3021 |
} |
3022 |
catch (Exception ex) |
3023 |
{ |
3024 |
result = null; |
3025 |
} |
3026 |
|
3027 |
return result; |
3028 |
} |
3029 |
#endregion |
3030 |
|
3031 |
#region Final Service |
3032 |
[OperationContract] |
3033 |
[ServiceKnownType(typeof(DOCINFO))] |
3034 |
public DOCINFO FinalPDF_GetDocinfo(string project_no, string docinfo_id) |
3035 |
{ |
3036 |
DOCINFO docinfo = null; |
3037 |
|
3038 |
try |
3039 |
{ |
3040 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
3041 |
using (CIEntities _entity = new CIEntities(sCIConnString)) |
3042 |
{ |
3043 |
var doc = _entity.DOCINFO.Where(x => x.ID == docinfo_id).FirstOrDefault(); |
3044 |
if(doc != null) |
3045 |
{ |
3046 |
docinfo = new DOCINFO() |
3047 |
{ |
3048 |
ID = doc.ID, |
3049 |
DOCUMENT_ID = doc.DOCUMENT_ID, |
3050 |
PAGE_COUNT = doc.PAGE_COUNT, |
3051 |
ORIGINAL_FILE = doc.ORIGINAL_FILE, |
3052 |
PROJECT_NO = doc.PROJECT_NO |
3053 |
}; |
3054 |
} |
3055 |
} |
3056 |
} |
3057 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3058 |
throw; |
3059 |
} |
3060 |
return docinfo; |
3061 |
} |
3062 |
[OperationContract] |
3063 |
[ServiceKnownType(typeof(DOCUMENT_ITEM))] |
3064 |
public DOCUMENT_ITEM FinalPDF_GetDocumentItem(string project_no, string document_id) |
3065 |
{ |
3066 |
DOCUMENT_ITEM item = null; |
3067 |
|
3068 |
try |
3069 |
{ |
3070 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
3071 |
using (CIEntities _entity = new CIEntities(sCIConnString)) |
3072 |
{ |
3073 |
var doc = _entity.DOCUMENT_ITEM.Where(x => x.PROJECT_NO == project_no && x.DOCUMENT_ID == document_id).FirstOrDefault(); |
3074 |
if(doc != null) |
3075 |
{ |
3076 |
item = new DOCUMENT_ITEM() |
3077 |
{ |
3078 |
ID = doc.ID, |
3079 |
ORIGINAL_FILE = doc.ORIGINAL_FILE, |
3080 |
PROJECT_NO = doc.PROJECT_NO, |
3081 |
DOCUMENT_ID = doc.DOCUMENT_ID, |
3082 |
DOCUMENT_NO = doc.DOCUMENT_NO, |
3083 |
DOCUMENT_NAME = doc.DOCUMENT_NAME, |
3084 |
//ENSEMBLEINFO_URL = doc.ENSEMBLEINFO_URL, |
3085 |
GROUP_NO = doc.GROUP_NO, |
3086 |
RESULT = doc.RESULT, |
3087 |
REVISION = doc.REVISION, |
3088 |
RESULT_FILE = doc.RESULT_FILE |
3089 |
}; |
3090 |
} |
3091 |
|
3092 |
} |
3093 |
} |
3094 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3095 |
throw; |
3096 |
} |
3097 |
return item; |
3098 |
} |
3099 |
[OperationContract] |
3100 |
[ServiceKnownType(typeof(MARKUP_DATA))] |
3101 |
public List<MARKUP_DATA> FinalPDF_GetMarkupdata(string project_no, string docinfo_id) |
3102 |
{ |
3103 |
List<MARKUP_DATA> results = new List<MARKUP_DATA>(); |
3104 |
|
3105 |
try |
3106 |
{ |
3107 |
//using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString())) |
3108 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
3109 |
using (CIEntities _entity = new CIEntities(sCIConnString)) |
3110 |
{ |
3111 |
var datas = _entity.MARKUP_DATA.Where(x => x.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO_ID == docinfo_id |
3112 |
&& x.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1 |
3113 |
&& x.MARKUP_INFO_VERSION.MARKUP_INFO.AVOID_CONSOLIDATE == 0 |
3114 |
&& x.MARKUP_INFO_VERSION.MARKUP_INFO.PART_CONSOLIDATE == 0).ToList(); |
3115 |
foreach (var data in datas) |
3116 |
{ |
3117 |
MARKUP_DATA d = new MARKUP_DATA() |
3118 |
{ |
3119 |
ID = data.ID, |
3120 |
//GROUP_ID = data.GROUP_ID, |
3121 |
SYMBOL_ID = data.SYMBOL_ID, |
3122 |
DATA = data.DATA, |
3123 |
DATA_TYPE = data.DATA_TYPE, |
3124 |
MARKUPINFO_VERSION_ID = data.MARKUPINFO_VERSION_ID, |
3125 |
PAGENUMBER = data.PAGENUMBER |
3126 |
}; |
3127 |
results.Add(d); |
3128 |
} |
3129 |
} |
3130 |
} |
3131 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3132 |
throw; |
3133 |
} |
3134 |
return results; |
3135 |
} |
3136 |
[OperationContract] |
3137 |
[ServiceKnownType(typeof(MARKUP_INFO))] |
3138 |
public MARKUP_INFO FinalPDF_GetMarkupinfo(string project_no, string docinfo_id) |
3139 |
{ |
3140 |
MARKUP_INFO markupInfo = null; |
3141 |
|
3142 |
try |
3143 |
{ |
3144 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
3145 |
using (CIEntities _entity = new CIEntities(sCIConnString)) |
3146 |
{ |
3147 |
var tmp = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo_id && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0).FirstOrDefault(); |
3148 |
if (tmp != null) |
3149 |
{ |
3150 |
markupInfo = new MARKUP_INFO() |
3151 |
{ |
3152 |
ID = tmp.ID, |
3153 |
DOCINFO_ID = tmp.DOCINFO_ID, |
3154 |
USER_ID = tmp.USER_ID |
3155 |
}; |
3156 |
} |
3157 |
} |
3158 |
} |
3159 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3160 |
throw; |
3161 |
} |
3162 |
return markupInfo; |
3163 |
} |
3164 |
[OperationContract] |
3165 |
[ServiceKnownType(typeof(FINAL_PDF))] |
3166 |
public List<FINAL_PDF> FinalPDF_GetFinalPDFs(string final_id) |
3167 |
{ |
3168 |
List<FINAL_PDF> results = new List<FINAL_PDF>(); |
3169 |
|
3170 |
try |
3171 |
{ |
3172 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
3173 |
using (KCOMEntities _entity = new KCOMEntities(sConnString)) |
3174 |
{ |
3175 |
var finalList = _entity.FINAL_PDF.Where(final => final.ID == final_id).ToList(); |
3176 |
foreach(var final in finalList) |
3177 |
{ |
3178 |
FINAL_PDF pdf = new FINAL_PDF() |
3179 |
{ |
3180 |
ID = final.ID, |
3181 |
DOCINFO_ID = final.DOCINFO_ID, |
3182 |
DOCUMENT_ID = final.DOCUMENT_ID, |
3183 |
STATUS = final.STATUS, |
3184 |
CURRENT_PAGE = final.CURRENT_PAGE, |
3185 |
CREATE_DATETIME = final.CREATE_DATETIME, |
3186 |
START_DATETIME = final.START_DATETIME, |
3187 |
END_DATETIME = final.END_DATETIME, |
3188 |
EXCEPTION = final.EXCEPTION, |
3189 |
PROJECT_NO = final.PROJECT_NO, |
3190 |
TOTAL_PAGE = final.TOTAL_PAGE, |
3191 |
MARKUPINFO_ID = final.MARKUPINFO_ID, |
3192 |
CREATE_USER_ID = final.CREATE_USER_ID |
3193 |
}; |
3194 |
results.Add(pdf); |
3195 |
} |
3196 |
} |
3197 |
} |
3198 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3199 |
throw; |
3200 |
} |
3201 |
return results; |
3202 |
} |
3203 |
[OperationContract] |
3204 |
[ServiceKnownType(typeof(DOCPAGE))] |
3205 |
public List<DOCPAGE> FinalPDF_GetDocpage(string project_no, string docinfo_id) |
3206 |
{ |
3207 |
List<DOCPAGE> results = new List<DOCPAGE>(); |
3208 |
|
3209 |
try |
3210 |
{ |
3211 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
3212 |
using (CIEntities _entity = new CIEntities(sCIConnString)) |
3213 |
{ |
3214 |
var pages = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == docinfo_id).OrderBy(x => x.PAGE_NUMBER).ToList(); |
3215 |
foreach(var page in pages) |
3216 |
{ |
3217 |
DOCPAGE p = new DOCPAGE() |
3218 |
{ |
3219 |
PAGE_ANGLE = page.PAGE_ANGLE, |
3220 |
PAGE_NUMBER = page.PAGE_NUMBER, |
3221 |
PAGE_HEIGHT = page.PAGE_HEIGHT, |
3222 |
PAGE_WIDTH = page.PAGE_WIDTH, |
3223 |
DOCINFO_ID = page.DOCINFO_ID |
3224 |
}; |
3225 |
results.Add(p); |
3226 |
} |
3227 |
} |
3228 |
} |
3229 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3230 |
throw; |
3231 |
} |
3232 |
return results; |
3233 |
} |
3234 |
[OperationContract] |
3235 |
public bool FinalPDF_SetFinalPDFStatus(string final_id, FinalStatus status) |
3236 |
{ |
3237 |
bool result = false; |
3238 |
|
3239 |
try |
3240 |
{ |
3241 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
3242 |
using (KCOMEntities _entity = new KCOMEntities(sConnString)) |
3243 |
{ |
3244 |
var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault(); |
3245 |
if(tmp != null) |
3246 |
{ |
3247 |
switch(status) |
3248 |
{ |
3249 |
case FinalStatus.Create: |
3250 |
tmp.START_DATETIME = DateTime.Now; |
3251 |
break; |
3252 |
case FinalStatus.Success: |
3253 |
tmp.END_DATETIME = DateTime.Now; |
3254 |
tmp.EXCEPTION = string.Empty; |
3255 |
break; |
3256 |
} |
3257 |
tmp.STATUS = (int)status; |
3258 |
_entity.SaveChanges(); |
3259 |
result = true; |
3260 |
} |
3261 |
} |
3262 |
} |
3263 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3264 |
throw; |
3265 |
} |
3266 |
return result; |
3267 |
} |
3268 |
|
3269 |
/// <summary> |
3270 |
/// 현재 진행중인 Final PDF 가 없거나 Success 일 경우에만 true return |
3271 |
/// </summary> |
3272 |
/// <param name="DocInfoID"></param> |
3273 |
/// <param name="MarkupInfoID"></param> |
3274 |
/// <param name="CreateUserID"></param> |
3275 |
/// <returns></returns> |
3276 |
[OperationContract] |
3277 |
public bool FinalPDF_GetFinalPDFStatus(string DocInfoID, string MarkupInfoID, string CreateUserID) |
3278 |
{ |
3279 |
bool result = false; |
3280 |
|
3281 |
try |
3282 |
{ |
3283 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
3284 |
using (KCOMEntities _entity = new KCOMEntities(sConnString)) |
3285 |
{ |
3286 |
var finalpdf = _entity.FINAL_PDF.Where(x => x.DOCINFO_ID == DocInfoID && x.MARKUPINFO_ID == MarkupInfoID && x.CREATE_USER_ID == CreateUserID && x.STATUS != (int)FinalStatus.Error).FirstOrDefault(); |
3287 |
if (finalpdf != null) |
3288 |
{ |
3289 |
if (finalpdf.STATUS == (int)FinalStatus.Success) |
3290 |
{ |
3291 |
result = true; |
3292 |
} |
3293 |
} |
3294 |
else |
3295 |
result = true; |
3296 |
} |
3297 |
} |
3298 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3299 |
throw; |
3300 |
} |
3301 |
return result; |
3302 |
} |
3303 |
|
3304 |
[OperationContract] |
3305 |
public bool FinalPDF_SetCurrentPage(string final_id, int currentpage) |
3306 |
{ |
3307 |
bool result = false; |
3308 |
|
3309 |
try |
3310 |
{ |
3311 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
3312 |
using (KCOMEntities _entity = new KCOMEntities(sConnString)) |
3313 |
{ |
3314 |
var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault(); |
3315 |
if (tmp != null) |
3316 |
{ |
3317 |
tmp.CURRENT_PAGE = currentpage; |
3318 |
_entity.SaveChanges(); |
3319 |
result = true; |
3320 |
} |
3321 |
} |
3322 |
} |
3323 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3324 |
throw; |
3325 |
} |
3326 |
return result; |
3327 |
} |
3328 |
[OperationContract] |
3329 |
public bool FinalPDF_SetError(string final_id, string msg) |
3330 |
{ |
3331 |
bool result = false; |
3332 |
|
3333 |
try |
3334 |
{ |
3335 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
3336 |
using (KCOMEntities _entity = new KCOMEntities(sConnString)) |
3337 |
{ |
3338 |
var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault(); |
3339 |
if (tmp != null) |
3340 |
{ |
3341 |
tmp.STATUS = (int)FinalStatus.Error; |
3342 |
tmp.EXCEPTION = DateTime.Now.ToShortDateString() + " " + msg; |
3343 |
_entity.SaveChanges(); |
3344 |
result = true; |
3345 |
} |
3346 |
} |
3347 |
} |
3348 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3349 |
throw; |
3350 |
} |
3351 |
return result; |
3352 |
} |
3353 |
|
3354 |
[OperationContract] |
3355 |
public bool FinalPDF_SetFinalResultPath(string project_no, string document_id, string url) |
3356 |
{ |
3357 |
bool result = false; |
3358 |
|
3359 |
try |
3360 |
{ |
3361 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
3362 |
using (CIEntities _entity = new CIEntities(sCIConnString)) |
3363 |
{ |
3364 |
var item = _entity.DOCUMENT_ITEM.Where(d =>d.PROJECT_NO == project_no && d.DOCUMENT_ID == document_id).FirstOrDefault(); |
3365 |
if (item != null) |
3366 |
{ |
3367 |
item.RESULT_FILE = url; |
3368 |
_entity.SaveChanges(); |
3369 |
result = true; |
3370 |
} |
3371 |
} |
3372 |
} |
3373 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3374 |
throw; |
3375 |
} |
3376 |
return result; |
3377 |
} |
3378 |
|
3379 |
[OperationContract] |
3380 |
public bool SaveLog(string project_no, string document_id, string Log) |
3381 |
{ |
3382 |
bool result = false; |
3383 |
|
3384 |
try |
3385 |
{ |
3386 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
3387 |
using (KCOMEntities _entity = new KCOMEntities(sConnString)) |
3388 |
{ |
3389 |
_entity.AddToERROR_LOG(new ERROR_LOG |
3390 |
{ |
3391 |
PROJECT_NO = project_no, |
3392 |
DOCUMENT_ID = document_id, |
3393 |
CONTENTS = Log, |
3394 |
CREATE_DATETIME = DateTime.Now.ToString("yyMMddssmm"), |
3395 |
CODE = "", |
3396 |
TYPE = "Markus Log", |
3397 |
LEVEL = "", |
3398 |
SERVICE_NAME = "Markus", |
3399 |
}); |
3400 |
|
3401 |
_entity.SaveChanges(); |
3402 |
} |
3403 |
} |
3404 |
catch (Exception ex) |
3405 |
{ |
3406 |
} |
3407 |
|
3408 |
return result; |
3409 |
} |
3410 |
|
3411 |
[OperationContract] |
3412 |
[ServiceKnownType(typeof(MEMBER))] |
3413 |
public MEMBER FinalPDF_GetCommentMember(string project_no, string markupdata_id) |
3414 |
{ |
3415 |
MEMBER member = null; |
3416 |
try |
3417 |
{ |
3418 |
string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
3419 |
using (CIEntities _entity = new CIEntities(sCIConnString)) |
3420 |
{ |
3421 |
var data = _entity.MARKUP_DATA.Where(x => x.ID == markupdata_id).FirstOrDefault(); |
3422 |
string user_id = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID; |
3423 |
|
3424 |
var person = GetMemberQuery(_entity,user_id); |
3425 |
|
3426 |
if(person.Count() > 0) |
3427 |
{ |
3428 |
member = person.First(); |
3429 |
} |
3430 |
} |
3431 |
} |
3432 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3433 |
throw; |
3434 |
} |
3435 |
|
3436 |
return member; |
3437 |
} |
3438 |
|
3439 |
[OperationContract] |
3440 |
[ServiceKnownType(typeof(PROPERTIES))] |
3441 |
public List<PROPERTIES> FinalPDF_GetProperties(string project_no) |
3442 |
{ |
3443 |
List<PROPERTIES> results = new List<PROPERTIES>(); |
3444 |
try |
3445 |
{ |
3446 |
string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
3447 |
using (KCOMEntities _entity = new KCOMEntities(sConnString)) |
3448 |
{ |
3449 |
var _items = _entity.PROPERTIES.Where(x => x.PROPERTY == project_no).ToList(); |
3450 |
foreach(var item in _items) |
3451 |
{ |
3452 |
PROPERTIES pROPERTIES = new PROPERTIES() |
3453 |
{ |
3454 |
ID = item.ID, |
3455 |
PROPERTY = item.PROPERTY, |
3456 |
TYPE = item.TYPE, |
3457 |
VALUE = item.VALUE |
3458 |
}; |
3459 |
results.Add(pROPERTIES); |
3460 |
} |
3461 |
} |
3462 |
|
3463 |
} |
3464 |
catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); |
3465 |
throw; |
3466 |
} |
3467 |
return results; |
3468 |
} |
3469 |
#endregion |
3470 |
} |
3471 |
} |