markus / KCOM_API / ServiceDeepView.svc.cs @ 5bffa106
이력 | 보기 | 이력해설 | 다운로드 (37.1 KB)
1 |
using IFinalPDF; |
---|---|
2 |
using IKCOM; |
3 |
using KCOMDataModel.Common; |
4 |
using KCOMDataModel.DataModel; |
5 |
using MARKUS; |
6 |
using System; |
7 |
using System.Collections.Generic; |
8 |
using System.Linq; |
9 |
using System.Runtime.Remoting.Channels.Tcp; |
10 |
using System.Runtime.Serialization; |
11 |
using System.ServiceModel; |
12 |
using System.ServiceModel.Activation; |
13 |
using System.Text; |
14 |
using System.Windows; |
15 |
|
16 |
namespace KCOM_API |
17 |
{ |
18 |
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ServiceDeepView" in code, svc and config file together. |
19 |
// 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. |
20 |
[ServiceContract(Namespace = "")] |
21 |
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] |
22 |
public partial class ServiceDeepView : System.Web.Services.WebService |
23 |
{ |
24 |
//[OperationContract] |
25 |
//public List<HoneyheadTEXT> GetSearchText(int pageNo, string filePath,bool IsAllPage) //0아 아니면 지정 페이지 |
26 |
//{ |
27 |
|
28 |
// return null; |
29 |
//} |
30 |
|
31 |
|
32 |
[OperationContract] |
33 |
public KCOM_SystemInfo GetSystemData() |
34 |
{ |
35 |
try |
36 |
{ |
37 |
using (KCOMEntities uc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
38 |
{ |
39 |
var SystemInfoSet = uc.PROPERTIES.Where(data => data.TYPE == "SystemInfo").ToList(); |
40 |
|
41 |
KCOM_SystemInfo sysInfo = new KCOM_SystemInfo(); |
42 |
|
43 |
var url = SystemInfoSet.Where(data => data.PROPERTY == "Url").FirstOrDefault(); |
44 |
if (url != null) |
45 |
{ |
46 |
sysInfo.HostName = url.VALUE; |
47 |
} |
48 |
|
49 |
url = SystemInfoSet.Where(data => data.PROPERTY == "Port").FirstOrDefault(); |
50 |
if (url != null) |
51 |
{ |
52 |
sysInfo.HostPort = url.VALUE; |
53 |
} |
54 |
|
55 |
url = uc.PROPERTIES.Where(data => data.TYPE == "STAMP").FirstOrDefault(); |
56 |
if(url != null) |
57 |
{ |
58 |
sysInfo.STAMP = url.VALUE; |
59 |
} |
60 |
return sysInfo; |
61 |
} |
62 |
} |
63 |
catch (Exception ex) |
64 |
{ |
65 |
} |
66 |
return null; |
67 |
GC.Collect(2); |
68 |
} |
69 |
|
70 |
private static string shortGuid() |
71 |
{ |
72 |
byte[] bytes = new byte[16]; |
73 |
using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create()) |
74 |
{ |
75 |
provider.GetBytes(bytes); |
76 |
} |
77 |
|
78 |
var guid = new Guid(bytes); |
79 |
|
80 |
return Convert.ToBase64String(guid.ToByteArray()) |
81 |
.Substring(0, 10) |
82 |
.Replace("/", "") |
83 |
.Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x"); |
84 |
} |
85 |
|
86 |
|
87 |
[OperationContract] |
88 |
public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID) |
89 |
{ |
90 |
|
91 |
|
92 |
using (KCOMEntities dc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
93 |
{ |
94 |
|
95 |
int flagString = Convert.ToInt32(FAVORITE_FLAG.Personal); |
96 |
List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>(); |
97 |
//dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG != |
98 |
// flagString).ToList().ForEach(data => favoriteListSet.Add(data)); |
99 |
|
100 |
|
101 |
//dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data)); |
102 |
|
103 |
favoriteListSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID && data.DOCUMENT_ID == sharepointItemID).ToList(); |
104 |
|
105 |
//favoriteListSet = favoriteListSet.Distinct().ToList(); |
106 |
return favoriteListSet; |
107 |
} |
108 |
} |
109 |
[OperationContract] |
110 |
public bool EditFavoriteVP(string prjNo, string userID, string docID, int state, string description) |
111 |
{ |
112 |
using (KCOMEntities dc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
113 |
{ |
114 |
//List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID |
115 |
// && data.PAGE_NO == SavePageNo && data.CREATE_TIME == createTime).ToList(); |
116 |
List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID |
117 |
&& data.ID == docID).ToList(); |
118 |
try |
119 |
{ |
120 |
|
121 |
if (favoriteSet.Count > 0) |
122 |
{ |
123 |
var FavoriteVP_Instance = favoriteSet.First(); |
124 |
|
125 |
FavoriteVP_Instance.DESCRIPTION = description; |
126 |
FavoriteVP_Instance.FLAG = state; |
127 |
|
128 |
dc.SaveChanges(); |
129 |
|
130 |
return true; |
131 |
} |
132 |
else |
133 |
{ |
134 |
return false; |
135 |
} |
136 |
} |
137 |
catch (Exception) |
138 |
{ |
139 |
return false; |
140 |
} |
141 |
} |
142 |
} |
143 |
|
144 |
[OperationContract] |
145 |
public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string docID) |
146 |
{ |
147 |
|
148 |
using (KCOMEntities dc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
149 |
{ |
150 |
|
151 |
List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID |
152 |
&& data.ID == docID).ToList(); |
153 |
|
154 |
try |
155 |
{ |
156 |
if (favoriteSet.Count > 0) |
157 |
{ |
158 |
favoriteSet.ForEach(data => dc.FAVORITE_DOC.DeleteObject(data)); |
159 |
dc.SaveChanges(); |
160 |
return true; |
161 |
} |
162 |
else |
163 |
{ |
164 |
return false; |
165 |
} |
166 |
} |
167 |
catch (Exception) |
168 |
{ |
169 |
return false; |
170 |
} |
171 |
} |
172 |
} |
173 |
|
174 |
|
175 |
[OperationContract] |
176 |
public List<Rect> GetCompareRect(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, bool isInternalAddress) |
177 |
{ |
178 |
//string originFile = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", projectNo, (Convert.ToInt32(originDocItem_ID) / 100).ToString(), originDocItem_ID, originPageNo); |
179 |
//string targetFile = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", projectNo, (Convert.ToInt32(targetDocItem_ID) / 100).ToString(), targetDocItem_ID, targetPageNo); |
180 |
|
181 |
string originFile = ""; |
182 |
string targetFile = ""; |
183 |
|
184 |
if (isInternalAddress) |
185 |
{ |
186 |
originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, (Convert.ToInt32(originDocItem_ID) / 100).ToString(), originDocItem_ID, originPageNo); |
187 |
targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, (Convert.ToInt32(targetDocItem_ID) / 100).ToString(), targetDocItem_ID, targetPageNo); |
188 |
} |
189 |
else |
190 |
{ |
191 |
originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo); |
192 |
targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo); |
193 |
} |
194 |
|
195 |
CompareLib compareLib = new CompareLib(); |
196 |
//System.IO.Stream resultOrigin = compareLib.ChangeCmpUrlToPng(originFile); |
197 |
//System.IO.Stream resultTarget = compareLib.ChangeCmpUrlToPng(targetFile); |
198 |
|
199 |
var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile); |
200 |
var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile); |
201 |
|
202 |
string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget); |
203 |
var result = compareLib.GetBoundBoxInImage(outPutFile); |
204 |
|
205 |
return result; |
206 |
} |
207 |
|
208 |
|
209 |
|
210 |
#region Final PDF |
211 |
private string _ChanID = null; |
212 |
TcpChannel chan = null; |
213 |
[OperationContract] |
214 |
public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUserID) |
215 |
{ |
216 |
#region 임시보관 |
217 |
#endregion |
218 |
FinalPDFResult _result = new FinalPDFResult(); |
219 |
RemFinalPDFObject remObj = null; |
220 |
try |
221 |
{ |
222 |
string _finalID = shortGuid(); |
223 |
int _DocTotalPages = -1; |
224 |
string docItemId; |
225 |
|
226 |
|
227 |
using (CIEntities _ci = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
228 |
{ |
229 |
var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID); |
230 |
|
231 |
if (_doc.Count() > 0) |
232 |
{ |
233 |
_DocTotalPages = _doc.First().PAGE_COUNT; |
234 |
docItemId = _doc.First().DOCUMENT_ID; |
235 |
} |
236 |
else |
237 |
{ |
238 |
_result.Status = FinalStatus.Error; |
239 |
_result.Exception = "페이지 정보를 가져올 수 없습니다."; |
240 |
return _result; |
241 |
} |
242 |
} |
243 |
if (_DocTotalPages > 0) |
244 |
{ |
245 |
FINAL_PDF fm = new FINAL_PDF() |
246 |
{ |
247 |
ID = _finalID, |
248 |
PROJECT_NO = ProjectNo, |
249 |
DOCINFO_ID = DocInfoID, |
250 |
DOCUMENT_ID = docItemId, |
251 |
MARKUPINFO_ID = MarkupInfoID, |
252 |
CREATE_USER_ID = CreateUserID, |
253 |
TOTAL_PAGE = _DocTotalPages, |
254 |
CREATE_DATETIME = DateTime.Now, |
255 |
STATUS = (int)IFinalPDF.FinalStatus.Insert |
256 |
}; |
257 |
using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
258 |
{ |
259 |
_entity.AddToFINAL_PDF(fm); |
260 |
_entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave); |
261 |
}; |
262 |
|
263 |
System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp"); |
264 |
if (_ch == null) |
265 |
{ |
266 |
chan = new TcpChannel(); |
267 |
_ChanID = chan.ChannelName; |
268 |
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false); |
269 |
// Create an instance of the remote object |
270 |
|
271 |
|
272 |
using (KCOMEntities ec = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
273 |
{ |
274 |
|
275 |
//remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject), |
276 |
// "tcp://localhost:9092/remFinalPDF"); |
277 |
remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject), |
278 |
//"tcp://192.168.0.67:9092/remFinalPDF"); |
279 |
"tcp://192.168.0.67:9092/remFinalPDF"); |
280 |
} |
281 |
|
282 |
//"tcp://localhost:8080/remFinalPDF"); |
283 |
|
284 |
_result = remObj.SetFinalPDF(ProjectNo, _finalID); |
285 |
_result.FinalID = _finalID; |
286 |
_result.Status = FinalStatus.Success; |
287 |
|
288 |
//MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF(); |
289 |
//fa.MakeFinalPDF(fm); |
290 |
} |
291 |
else |
292 |
{ |
293 |
_ChanID = _ch.ChannelName; |
294 |
} |
295 |
} |
296 |
} |
297 |
catch (Exception ex) |
298 |
{ |
299 |
_result.Status = FinalStatus.Error; |
300 |
|
301 |
if (ex.GetType() == typeof(System.Net.Sockets.SocketException)) |
302 |
_result.Exception = "Final Server Not Connection"; |
303 |
} |
304 |
finally |
305 |
{ |
306 |
remObj = null; |
307 |
if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null) |
308 |
System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan); |
309 |
|
310 |
GC.Collect(2); |
311 |
} |
312 |
return _result; |
313 |
} |
314 |
#endregion |
315 |
|
316 |
|
317 |
[OperationContract] |
318 |
public bool GetConversionState(KCOM_BasicParam param) |
319 |
{ |
320 |
using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(param.projectNo).ToString())) |
321 |
{ |
322 |
var doc = entity.DOCINFO.Where(data => data.DOCUMENT_ID == param.documentID).FirstOrDefault(); |
323 |
if (doc != null) |
324 |
{ |
325 |
var count = doc.DOCPAGE.Where(data => data.DOCINFO_ID == doc.ID).Count(); |
326 |
if (doc.PAGE_COUNT == count) //페이지 수가 일치하는지 |
327 |
{ |
328 |
return true; |
329 |
} |
330 |
else //페이지 수가 일치하지 않는 경우 |
331 |
{ |
332 |
KCOMEntities entity_kcom = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()); |
333 |
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(); |
334 |
|
335 |
if (lst != null || lst.Count >= 1) |
336 |
{ |
337 |
//Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_PAGECOUNT"), param.documentID, param.projectNo); |
338 |
//이메일 클라이언트를 구현해야함 |
339 |
} |
340 |
return false; |
341 |
} |
342 |
} |
343 |
else |
344 |
{ |
345 |
//Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_CONVERTFAILED"), param.documentID, param.projectNo); |
346 |
//이메일 클라이언트를 구현해야함 |
347 |
return false; |
348 |
} |
349 |
} |
350 |
} |
351 |
|
352 |
[OperationContract] |
353 |
public List<VPRevision> GetVPRevisionHistory(string ProjectNo, string vpNo, string DocumentId) |
354 |
{ |
355 |
List<VPRevision> _result = new List<VPRevision>(); |
356 |
try |
357 |
{ |
358 |
using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
359 |
{ |
360 |
var _vpList = (from docitem in entity.DOCUMENT_ITEM |
361 |
where docitem.DOCUMENT_NO == vpNo |
362 |
select new VPRevision |
363 |
{ |
364 |
RevNo = docitem.REVISION, |
365 |
GroupNo = docitem.GROUP_NO, |
366 |
FROM_VENDOR = docitem.ORIGINAL_FILE, |
367 |
DOCUMENT_ID = docitem.DOCUMENT_ID, |
368 |
TO_VENDOR = docitem.RESULT_FILE, |
369 |
RESULT = docitem.RESULT, |
370 |
|
371 |
IsSyncPossible = docitem.DOCUMENT_ID == DocumentId ? false : true |
372 |
}); |
373 |
_result = _vpList.ToList(); |
374 |
_result = _result.OrderByDescending(r => Convert.ToInt32(r.GroupNo)).ToList(); |
375 |
} |
376 |
} |
377 |
catch (Exception) |
378 |
{ |
379 |
|
380 |
throw; |
381 |
} |
382 |
finally |
383 |
{ |
384 |
GC.Collect(2); |
385 |
} |
386 |
return _result; |
387 |
} |
388 |
|
389 |
[OperationContract] |
390 |
public DOCINFO GetDocInfo(KCOM_BasicParam param) |
391 |
{ |
392 |
DOCINFO _result = null; |
393 |
try |
394 |
{ |
395 |
// 차후 아래의 코드로 변경 |
396 |
//using (CI_Entities ModelDeeview = new CI_Entities(DaelimCiConnectionString.ToString())) |
397 |
CIEntities ModelDeeview = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(param.projectNo).ToString()); |
398 |
|
399 |
var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID); |
400 |
if (docinfo.Count() > 0) |
401 |
{ |
402 |
_result = docinfo.First(); |
403 |
_result.MARKUP_INFO.Clear(); |
404 |
|
405 |
} |
406 |
return _result; |
407 |
|
408 |
} |
409 |
catch (Exception ex) |
410 |
{ |
411 |
System.Diagnostics.Trace.WriteLine("GetDocInfo Error : " + ex); |
412 |
} |
413 |
finally |
414 |
{ |
415 |
GC.Collect(2); |
416 |
} |
417 |
return null; |
418 |
} |
419 |
|
420 |
[OperationContract] |
421 |
public bool GetCheckSystemAdmin(string UserID) |
422 |
{ |
423 |
using (KCOMEntities uc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
424 |
{ |
425 |
var user = uc.PROPERTIES.Where(data => data.TYPE == "Administrator" && data.PROPERTY.Contains(UserID)).FirstOrDefault(); |
426 |
if (user != null) |
427 |
{ |
428 |
return true; |
429 |
} |
430 |
else |
431 |
{ |
432 |
return false; |
433 |
} |
434 |
} |
435 |
GC.Collect(2); |
436 |
} |
437 |
|
438 |
[OperationContract] |
439 |
public DOCUMENT_ITEM GetDocumentItemInfo(KCOM_BasicParam param) |
440 |
{ |
441 |
///param : prjNo, documentId, userId |
442 |
DOCUMENT_ITEM _result = null; |
443 |
|
444 |
try |
445 |
{ |
446 |
CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(param.projectNo).ToString()); |
447 |
|
448 |
var _items = entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == param.documentID); |
449 |
|
450 |
if (_items.Count() > 0) |
451 |
{ |
452 |
_result = _items.First(); |
453 |
|
454 |
return _result; |
455 |
} |
456 |
//else |
457 |
//{ |
458 |
// Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_DOCUMENTNOTFOUND"), param.documentID, param.projectNo); |
459 |
//} |
460 |
} |
461 |
catch (Exception ex) |
462 |
{ |
463 |
System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex); |
464 |
//Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo); |
465 |
} |
466 |
|
467 |
return _result; |
468 |
} |
469 |
|
470 |
public string UserGO(MARKUP_INFO item) |
471 |
{ |
472 |
if (item != null) |
473 |
{ |
474 |
return item.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID; |
475 |
} |
476 |
return null; |
477 |
} |
478 |
|
479 |
[OperationContract] |
480 |
public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId) |
481 |
{ |
482 |
List<MarkupInfoItem> _result = new List<MarkupInfoItem>(); |
483 |
try |
484 |
{ |
485 |
using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
486 |
{ |
487 |
var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList(); |
488 |
//foreach (var item in markupListData) |
489 |
//{ |
490 |
// if (!item.AVOID_CONSOLIDATE.HasValue) |
491 |
// { |
492 |
// item.AVOID_CONSOLIDATE = 0; |
493 |
// } |
494 |
//} |
495 |
|
496 |
var markupList = from markup in markupListData |
497 |
orderby markup.CREATE_TIME descending |
498 |
select new MarkupInfoItem |
499 |
{ |
500 |
MarkupInfoID = markup.ID, |
501 |
UserID = markup.USER_ID, |
502 |
MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID, |
503 |
CreateTime = markup.CREATE_TIME, |
504 |
Consolidate = markup.CONSOLIDATE, |
505 |
Description = markup.DESCRIPTION, |
506 |
AvoidConsolidate = markup.AVOID_CONSOLIDATE, |
507 |
PartConsolidate = markup.PART_CONSOLIDATE, |
508 |
UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()), |
509 |
}; |
510 |
|
511 |
|
512 |
|
513 |
if (markupList.Count() > 0) |
514 |
{ |
515 |
_result = markupList.ToList(); |
516 |
} |
517 |
|
518 |
|
519 |
|
520 |
_result.ForEach(r => |
521 |
{ |
522 |
|
523 |
r.MarkupList = (from markupData in entity.MARKUP_DATA |
524 |
where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID |
525 |
orderby markupData.PAGENUMBER |
526 |
select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE }).ToList(); |
527 |
}); |
528 |
|
529 |
List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>(); |
530 |
Random random = new Random(); |
531 |
|
532 |
using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
533 |
{ |
534 |
_ColorsProperties = (from property in kcomEntity.PROPERTIES |
535 |
where property.TYPE == "DisplayColor" |
536 |
select property).ToList(); |
537 |
} |
538 |
|
539 |
foreach (var item in _result) |
540 |
{ |
541 |
var _member = entity.MEMBER.Where(member => member.ID == item.UserID); |
542 |
|
543 |
if (_member.Count() > 0) |
544 |
{ |
545 |
item.UserName = _member.First().NAME; |
546 |
item.Depatment = _member.First().DEPARTMENT; |
547 |
} |
548 |
|
549 |
if (_ColorsProperties.Count > 0) |
550 |
{ |
551 |
int colorIdx = random.Next(1, _ColorsProperties.Count()); |
552 |
#region 부서별로 색상을 지정하고자 할때 |
553 |
/// 일단 의견을 들어보자구! |
554 |
#endregion |
555 |
item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE; |
556 |
_ColorsProperties.Remove(_ColorsProperties[colorIdx]); |
557 |
//item.DisplayColor = "#FF" + _Colors.First(); |
558 |
//_Colors.Remove(_Colors.First()); |
559 |
} |
560 |
else |
561 |
{ |
562 |
item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000)); |
563 |
} |
564 |
} |
565 |
} |
566 |
} |
567 |
catch (Exception EX) |
568 |
{ |
569 |
System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX); |
570 |
return _result; |
571 |
} |
572 |
finally |
573 |
{ |
574 |
GC.Collect(2); |
575 |
} |
576 |
|
577 |
return _result; |
578 |
} |
579 |
|
580 |
[OperationContract] |
581 |
public List<MarkupInfoItem> GetSyncMarkupInfoItems(string ProjectNo, string DocInfoId, string currentUser) |
582 |
{ |
583 |
List<MarkupInfoItem> _result = new List<MarkupInfoItem>(); |
584 |
try |
585 |
{ |
586 |
using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
587 |
{ |
588 |
var docItem = entity.DOCINFO.Where(data => data.DOCUMENT_ID == DocInfoId).FirstOrDefault(); |
589 |
if (docItem == null) |
590 |
{ |
591 |
return null; |
592 |
} |
593 |
var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == docItem.ID).ToList(); |
594 |
|
595 |
var markupList = from markup in markupListData |
596 |
where markup.USER_ID == currentUser || markup.CONSOLIDATE == 1 |
597 |
orderby markup.CREATE_TIME descending |
598 |
select new MarkupInfoItem |
599 |
{ |
600 |
MarkupInfoID = markup.ID, |
601 |
UserID = markup.USER_ID, |
602 |
MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID, |
603 |
CreateTime = markup.CREATE_TIME, |
604 |
Consolidate = markup.CONSOLIDATE, |
605 |
Description = markup.DESCRIPTION, |
606 |
AvoidConsolidate = markup.AVOID_CONSOLIDATE, |
607 |
PartConsolidate = markup.PART_CONSOLIDATE, |
608 |
}; |
609 |
|
610 |
|
611 |
|
612 |
if (markupList.Count() > 0) |
613 |
{ |
614 |
_result = markupList.ToList(); |
615 |
} |
616 |
|
617 |
|
618 |
|
619 |
_result.ForEach(r => |
620 |
{ |
621 |
|
622 |
r.MarkupList = (from markupData in entity.MARKUP_DATA |
623 |
where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID |
624 |
orderby markupData.PAGENUMBER |
625 |
select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE }).ToList(); |
626 |
}); |
627 |
|
628 |
List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>(); |
629 |
Random random = new Random(); |
630 |
|
631 |
using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
632 |
{ |
633 |
_ColorsProperties = (from property in kcomEntity.PROPERTIES |
634 |
where property.TYPE == "DisplayColor" |
635 |
select property).ToList(); |
636 |
} |
637 |
|
638 |
foreach (var item in _result) |
639 |
{ |
640 |
var _member = entity.MEMBER.Where(member => member.ID == item.UserID); |
641 |
|
642 |
if (_member.Count() > 0) |
643 |
{ |
644 |
item.UserName = _member.First().NAME; |
645 |
item.Depatment = _member.First().DEPARTMENT; |
646 |
} |
647 |
|
648 |
if (_ColorsProperties.Count > 0) |
649 |
{ |
650 |
int colorIdx = random.Next(1, _ColorsProperties.Count()); |
651 |
#region 부서별로 색상을 지정하고자 할때 |
652 |
/// 일단 의견을 들어보자구! |
653 |
#endregion |
654 |
item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE; |
655 |
_ColorsProperties.Remove(_ColorsProperties[colorIdx]); |
656 |
//item.DisplayColor = "#FF" + _Colors.First(); |
657 |
//_Colors.Remove(_Colors.First()); |
658 |
} |
659 |
else |
660 |
{ |
661 |
item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000)); |
662 |
} |
663 |
} |
664 |
} |
665 |
} |
666 |
catch (Exception EX) |
667 |
{ |
668 |
System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX); |
669 |
return _result; |
670 |
} |
671 |
finally |
672 |
{ |
673 |
GC.Collect(2); |
674 |
} |
675 |
|
676 |
return _result; |
677 |
} |
678 |
|
679 |
|
680 |
//[OperationContract] |
681 |
//[ServiceKnownType(typeof(MEMBER))] |
682 |
//public List<MEMBER> GetUserData(string ProjectNo, string UserID) |
683 |
//{ |
684 |
// List<MEMBER> _result = new List<MEMBER>(); |
685 |
|
686 |
// using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
687 |
// { |
688 |
// var _UserList = from member in entity.MEMBER |
689 |
// where member.ID == UserID |
690 |
// select member; |
691 |
// _result = _UserList.ToList(); |
692 |
// } |
693 |
// //GC.Collect(2); |
694 |
// return _result; |
695 |
//} |
696 |
|
697 |
//[OperationContract] |
698 |
//[ServiceKnownType(typeof(MEMBER))] |
699 |
//public List<MEMBER> GetUserData(string ProjectNo, string UserID) |
700 |
//{ |
701 |
// List<MEMBER> _result = new List<MEMBER>(); |
702 |
|
703 |
// using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
704 |
// { |
705 |
// var _UserList = from member in entity.MEMBER |
706 |
// where member.ID == UserID |
707 |
// select member; |
708 |
// _result = _UserList.ToList(); |
709 |
// } |
710 |
// //GC.Collect(2); |
711 |
// return _result; |
712 |
//} |
713 |
|
714 |
|
715 |
[OperationContract] |
716 |
public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정 |
717 |
{ |
718 |
List<string> _result = new List<string>(); |
719 |
|
720 |
try |
721 |
{ |
722 |
KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()); |
723 |
var YourEnginner = (from dept in entity.PROPERTIES |
724 |
where dept.TYPE == "DeptName" && UserDept.Contains(dept.VALUE) |
725 |
select dept).FirstOrDefault(); |
726 |
|
727 |
if (YourEnginner != null) |
728 |
{ |
729 |
_result = (from dept in entity.PROPERTIES |
730 |
where dept.PROPERTY == YourEnginner.PROPERTY |
731 |
select dept.VALUE).ToList(); |
732 |
return _result; |
733 |
} |
734 |
else |
735 |
{ |
736 |
return null; |
737 |
} |
738 |
} |
739 |
catch (Exception ex) |
740 |
{ |
741 |
System.Diagnostics.Debug.WriteLine(ex.Message); |
742 |
} |
743 |
finally |
744 |
{ |
745 |
GC.Collect(2); |
746 |
} |
747 |
return _result; |
748 |
} |
749 |
|
750 |
[OperationContract] |
751 |
public bool DeleteMarkup(string ProjectNo, string MarkupInfoID) |
752 |
{ |
753 |
bool _result = false; |
754 |
try |
755 |
{ |
756 |
using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
757 |
{ |
758 |
|
759 |
MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault(); |
760 |
|
761 |
if (instance == null) |
762 |
{ |
763 |
return false; |
764 |
} |
765 |
MARKUP_INFO_VERSION version = instance.MARKUP_INFO_VERSION.FirstOrDefault(); |
766 |
|
767 |
|
768 |
version.MARKUP_DATA.ToList().ForEach(data => |
769 |
{ |
770 |
Entity.MARKUP_DATA.DeleteObject(data); |
771 |
Entity.SaveChanges(); |
772 |
}); |
773 |
|
774 |
Entity.MARKUP_INFO_VERSION.DeleteObject(version); |
775 |
Entity.SaveChanges(); |
776 |
|
777 |
Entity.MARKUP_INFO.DeleteObject(instance); |
778 |
Entity.SaveChanges(); |
779 |
|
780 |
} |
781 |
_result = true; |
782 |
} |
783 |
catch (Exception ex) |
784 |
{ |
785 |
System.Diagnostics.Trace.WriteLine(ex, "SaveMarkup"); |
786 |
} |
787 |
finally |
788 |
{ |
789 |
GC.Collect(2); |
790 |
} |
791 |
return _result; |
792 |
} |
793 |
|
794 |
#region Favorite |
795 |
[OperationContract] |
796 |
public bool SetFavoriteVP(string prjNo, string userID, string groupNo, string docNo, string rev, int SavePageNo, string documentItemID, string VPDescription, IKCOM.FAVORITE_FLAG flag) |
797 |
{ |
798 |
|
799 |
using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
800 |
{ |
801 |
try |
802 |
{ |
803 |
entity.FAVORITE_DOC.AddObject(new FAVORITE_DOC |
804 |
{ |
805 |
ID = shortGuid(), |
806 |
PROJECT_NO = prjNo, |
807 |
DOCUMENT_ID = documentItemID, |
808 |
GROUP_NO = groupNo, |
809 |
DOCUMENT_NO = docNo, |
810 |
MEMBER_USER_ID = userID, |
811 |
DESCRIPTION = VPDescription, |
812 |
CREATE_TIME = DateTime.Now, |
813 |
REVISION = rev, |
814 |
FLAG = (int)flag, |
815 |
PAGE_NO = SavePageNo, |
816 |
}); |
817 |
entity.SaveChanges(); |
818 |
} |
819 |
catch (Exception) |
820 |
{ |
821 |
return false; |
822 |
} |
823 |
|
824 |
return true; |
825 |
} |
826 |
} |
827 |
|
828 |
//[OperationContract] |
829 |
//public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID) |
830 |
//{ |
831 |
// using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
832 |
// { |
833 |
|
834 |
// int flagString = Convert.ToInt32(IKCOM.FAVORITE_FLAG.Personal); |
835 |
// List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>(); |
836 |
// entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG != |
837 |
// flagString).ToList().ForEach(data => favoriteListSet.Add(data)); |
838 |
// entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data)); |
839 |
// favoriteListSet = favoriteListSet.Distinct().ToList(); |
840 |
// return favoriteListSet; |
841 |
// } |
842 |
//} |
843 |
//[OperationContract] |
844 |
//public bool EditFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime, int state, string description) |
845 |
//{ |
846 |
// using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
847 |
// { |
848 |
// List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID |
849 |
// && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList(); |
850 |
|
851 |
// try |
852 |
// { |
853 |
|
854 |
|
855 |
// if (favoriteSet.Count > 0) |
856 |
// { |
857 |
// var FavoriteVP_Instance = favoriteSet.First(); |
858 |
|
859 |
// FavoriteVP_Instance.Description = description; |
860 |
// FavoriteVP_Instance.Flag = state; |
861 |
|
862 |
// dc.SaveChanges(); |
863 |
|
864 |
// return true; |
865 |
// } |
866 |
// else |
867 |
// { |
868 |
// return false; |
869 |
// } |
870 |
// } |
871 |
// catch (Exception) |
872 |
// { |
873 |
// return false; |
874 |
// } |
875 |
// } |
876 |
//} |
877 |
//[OperationContract] |
878 |
//public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime) |
879 |
//{ |
880 |
|
881 |
// using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString())) |
882 |
// { |
883 |
// List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID |
884 |
// && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList(); |
885 |
|
886 |
// try |
887 |
// { |
888 |
|
889 |
|
890 |
// if (favoriteSet.Count > 0) |
891 |
// { |
892 |
// favoriteSet.ForEach(data => dc.FavoriteVP.DeleteObject(data)); |
893 |
// dc.SaveChanges(); |
894 |
// return true; |
895 |
// } |
896 |
// else |
897 |
// { |
898 |
// return false; |
899 |
// } |
900 |
// } |
901 |
// catch (Exception) |
902 |
// { |
903 |
// return false; |
904 |
// } |
905 |
// } |
906 |
//} |
907 |
#endregion |
908 |
} |
909 |
} |