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