프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM_API / ServiceDeepView.svc.cs @ b421ac6b

이력 | 보기 | 이력해설 | 다운로드 (74.7 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.Collections.ObjectModel;
9
using System.Linq;
10
using System.Runtime.Remoting.Channels.Tcp;
11
using System.Runtime.Serialization;
12
using System.ServiceModel;
13
using System.ServiceModel.Activation;
14
using System.Text;
15
using System.Windows;
16

    
17
namespace KCOM_API
18
{
19
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ServiceDeepView" in code, svc and config file together.
20
    // 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.
21
    [ServiceContract(Namespace = "")]
22
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
23
    public partial class ServiceDeepView : System.Web.Services.WebService
24
    {
25
        //[OperationContract]
26
        //public List<HoneyheadTEXT> GetSearchText(int pageNo, string filePath,bool IsAllPage) //0아 아니면 지정 페이지
27
        //{
28

    
29
        //    return null;
30
        //}
31

    
32

    
33
        [OperationContract]
34
        public KCOM_SystemInfo GetSystemData()
35
        {
36
            try
37
            {
38
                using (KCOMEntities uc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
39
                {
40
                    var SystemInfoSet = uc.PROPERTIES.Where(data => data.TYPE == "SystemInfo").ToList();
41

    
42
                    KCOM_SystemInfo sysInfo = new KCOM_SystemInfo();
43

    
44
                    var url = SystemInfoSet.Where(data => data.PROPERTY == "Url").FirstOrDefault();
45
                    if (url != null)
46
                    {
47
                        sysInfo.HostName = url.VALUE;
48
                    }
49

    
50
                    url = SystemInfoSet.Where(data => data.PROPERTY == "Port").FirstOrDefault();
51
                    if (url != null)
52
                    {
53
                        sysInfo.HostPort = url.VALUE;
54
                    }
55

    
56
                    url = uc.PROPERTIES.Where(data => data.TYPE == "STAMP").FirstOrDefault();
57
                    if(url != null)
58
                    {
59
                        sysInfo.STAMP = url.VALUE;
60
                    }
61
                    return sysInfo;
62
                }
63
            }
64
            catch (Exception ex)
65
            {
66
            }
67
            return null;
68
            GC.Collect(2);
69
        }
70

    
71
        private static string shortGuid()
72
        {
73
            byte[] bytes = new byte[16];
74
            using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create())
75
            {
76
                provider.GetBytes(bytes);
77
            }
78

    
79
            var guid = new Guid(bytes);
80

    
81
            return Convert.ToBase64String(guid.ToByteArray())
82
                .Substring(0, 10)
83
                .Replace("/", "")
84
                .Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x");
85
        }
86

    
87

    
88
        [OperationContract]
89
        public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
90
        {
91

    
92

    
93
            using (KCOMEntities dc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
94
            {
95

    
96
                int flagString = Convert.ToInt32(FAVORITE_FLAG.Personal);
97
                List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
98
                //dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
99
                //    flagString).ToList().ForEach(data => favoriteListSet.Add(data));
100

    
101

    
102
                //dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data));
103

    
104
                favoriteListSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID && data.DOCUMENT_ID == sharepointItemID).ToList();
105

    
106
                //favoriteListSet = favoriteListSet.Distinct().ToList();
107
                return favoriteListSet;
108
            }
109
        }
110
        [OperationContract]
111
        public bool EditFavoriteVP(string prjNo, string userID, string docID, int state, string description)
112
        {
113
            using (KCOMEntities dc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
114
            {
115
                //List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
116
                //    && data.PAGE_NO == SavePageNo && data.CREATE_TIME == createTime).ToList();
117
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
118
                    && data.ID == docID).ToList();
119
                try
120
                {
121

    
122
                    if (favoriteSet.Count > 0)
123
                    {
124
                        var FavoriteVP_Instance = favoriteSet.First();
125

    
126
                        FavoriteVP_Instance.DESCRIPTION = description;
127
                        FavoriteVP_Instance.FLAG = state;
128

    
129
                        dc.SaveChanges();
130

    
131
                        return true;
132
                    }
133
                    else
134
                    {
135
                        return false;
136
                    }
137
                }
138
                catch (Exception)
139
                {
140
                    return false;
141
                }
142
            }
143
        }
144

    
145
        [OperationContract]
146
        public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string docID)
147
        {
148

    
149
            using (KCOMEntities dc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
150
            {
151

    
152
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
153
                    && data.ID == docID).ToList();
154

    
155
                try
156
                {
157
                    if (favoriteSet.Count > 0)
158
                    {
159
                        favoriteSet.ForEach(data => dc.FAVORITE_DOC.DeleteObject(data));
160
                        dc.SaveChanges();
161
                        return true;
162
                    }
163
                    else
164
                    {
165
                        return false;
166
                    }
167
                }
168
                catch (Exception)
169
                {
170
                    return false;
171
                }
172
            }
173
        }
174

    
175

    
176
        [OperationContract]
177
        public List<Rect> GetCompareRect(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress)
178
        {
179
            //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);
180
            //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);
181

    
182
            string originFile = "";
183
            string targetFile = "";
184

    
185
            if (Boolean.Parse(isInternalAddress))
186
            {
187
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, (Convert.ToInt32(originDocItem_ID) / 100).ToString(), originDocItem_ID, originPageNo);
188
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, (Convert.ToInt32(targetDocItem_ID) / 100).ToString(), targetDocItem_ID, targetPageNo);
189
            }
190
            else
191
            {
192
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  originDocItem_ID, originPageNo);
193
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  targetDocItem_ID, targetPageNo);
194
            }
195

    
196
            CompareLib compareLib = new CompareLib();
197
            //System.IO.Stream resultOrigin = compareLib.ChangeCmpUrlToPng(originFile);
198
            //System.IO.Stream resultTarget = compareLib.ChangeCmpUrlToPng(targetFile);
199

    
200
            var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
201
            var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
202

    
203
            string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
204
            var result = compareLib.GetBoundBoxInImage(outPutFile);
205

    
206
            return result;
207
        }
208

    
209

    
210

    
211
        #region Final PDF
212
        private string _ChanID = null;
213
        TcpChannel chan = null;
214
        [OperationContract]
215
        public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUserID)
216
        {
217
            #region 임시보관
218
            #endregion
219
            FinalPDFResult _result = new FinalPDFResult();
220
            RemFinalPDFObject remObj = null;
221
            try
222
            {
223
                string _finalID = shortGuid();
224
                int _DocTotalPages = -1;
225
                string docItemId;
226

    
227

    
228
                using (CIEntities _ci = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
229
                {
230
                    var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
231

    
232
                    if (_doc.Count() > 0)
233
                    {
234
                        _DocTotalPages = _doc.First().PAGE_COUNT;
235
                        docItemId = _doc.First().DOCUMENT_ID;
236
                    }
237
                    else
238
                    {
239
                        _result.Status = FinalStatus.Error;
240
                        _result.Exception = "페이지 정보를 가져올 수 없습니다.";
241
                        return _result;
242
                    }
243
                }
244
                if (_DocTotalPages > 0)
245
                {
246
                    FINAL_PDF fm = new FINAL_PDF()
247
                    {
248
                        ID = _finalID,
249
                        PROJECT_NO = ProjectNo,
250
                        DOCINFO_ID = DocInfoID,
251
                        DOCUMENT_ID = docItemId,
252
                        MARKUPINFO_ID = MarkupInfoID,
253
                        CREATE_USER_ID = CreateUserID,
254
                        TOTAL_PAGE = _DocTotalPages,
255
                        CREATE_DATETIME = DateTime.Now,
256
                        STATUS = (int)IFinalPDF.FinalStatus.Insert
257
                    };
258
                    using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
259
                    {
260
                        _entity.AddToFINAL_PDF(fm);
261
                        _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
262
                    };
263

    
264
                    System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
265
                    if (_ch == null)
266
                    {
267
                        chan = new TcpChannel();
268
                        _ChanID = chan.ChannelName;
269
                        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
270
                        // Create an instance of the remote object
271

    
272

    
273
                        using (KCOMEntities ec = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
274
                        {
275

    
276
                            //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
277
                            //                          "tcp://localhost:9092/remFinalPDF");
278
                            remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
279
                                                      //"tcp://192.168.0.67:9092/remFinalPDF");
280
                                                      "tcp://192.168.0.67:9092/remFinalPDF");
281
                        }
282

    
283
                        //"tcp://localhost:8080/remFinalPDF");
284

    
285
                        _result = remObj.SetFinalPDF(ProjectNo, _finalID);
286
                        _result.FinalID = _finalID;
287
                        _result.Status = FinalStatus.Success;
288

    
289
                        //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
290
                        //fa.MakeFinalPDF(fm);
291
                    }
292
                    else
293
                    {
294
                        _ChanID = _ch.ChannelName;
295
                    }
296
                }
297
            }
298
            catch (Exception ex)
299
            {
300
                _result.Status = FinalStatus.Error;
301

    
302
                if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
303
                    _result.Exception = "Final Server Not Connection";
304
            }
305
            finally
306
            {
307
                remObj = null;
308
                if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
309
                    System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
310

    
311
                GC.Collect(2);
312
            }
313
            return _result;
314
        }
315
        #endregion
316

    
317

    
318
        [OperationContract]
319
        public bool GetConversionState(KCOM_BasicParam param)
320
        {
321
            using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(param.projectNo).ToString()))
322
            {
323
                var doc = entity.DOCINFO.Where(data => data.DOCUMENT_ID == param.documentID).FirstOrDefault();
324
                if (doc != null)
325
                {
326
                    var count = doc.DOCPAGE.Where(data => data.DOCINFO_ID == doc.ID).Count();
327
                    if (doc.PAGE_COUNT == count)  //페이지 수가 일치하는지
328
                    {
329
                        return true;
330
                    }
331
                    else //페이지 수가 일치하지 않는 경우
332
                    {
333
                        KCOMEntities entity_kcom = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString());
334
                        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();
335

    
336
                        if (lst != null || lst.Count >= 1)
337
                        {
338
                            //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_PAGECOUNT"), param.documentID, param.projectNo);
339
                            //이메일 클라이언트를 구현해야함
340
                        }
341
                        return false;
342
                    }
343
                }
344
                else
345
                {
346
                    //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_CONVERTFAILED"), param.documentID, param.projectNo);
347
                    //이메일 클라이언트를 구현해야함
348
                    return false;
349
                }
350
            }
351
        }
352

    
353
        [OperationContract]
354
        public List<VPRevision> GetVPRevisionHistory(string ProjectNo, string vpNo, string DocumentId)
355
        {
356
            List<VPRevision> _result = new List<VPRevision>();
357
            try
358
            {
359
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
360
                {
361
                    var _vpList = (from docitem in entity.DOCUMENT_ITEM
362
                                   where docitem.DOCUMENT_NO == vpNo
363
                                   select new VPRevision
364
                                   {
365
                                       RevNo = docitem.REVISION,
366
                                       GroupNo = docitem.GROUP_NO,
367
                                       FROM_VENDOR = docitem.ORIGINAL_FILE,
368
                                       DOCUMENT_ID = docitem.DOCUMENT_ID,
369
                                       TO_VENDOR = docitem.RESULT_FILE,
370
                                       RESULT = docitem.RESULT,
371
                                       DocNo = docitem.DOCUMENT_NO,
372
                                       IsSyncPossible = docitem.DOCUMENT_ID == DocumentId ? false : true
373
                                   });
374
                    _result = _vpList.ToList();
375
                    _result = _result.OrderByDescending(r => r.GroupNo).ToList();
376
                }
377
            }
378
            catch (Exception)
379
            {
380

    
381
                throw;
382
            }
383
            finally
384
            {
385
                GC.Collect(2);
386
            }
387
            return _result;
388
        }
389

    
390
        [OperationContract]
391
        public VPRevision GetVPRevisionFirstOrDefault(string ProjectNo, string DocumentId)
392
        {
393
            VPRevision _result = null;
394
            try
395
            {
396
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
397
                {
398
                    _result = (from docitem in entity.DOCUMENT_ITEM
399
                     where docitem.DOCUMENT_ID == DocumentId
400
                     select new VPRevision
401
                     {
402
                         RevNo = docitem.REVISION,
403
                         GroupNo = docitem.GROUP_NO,
404
                         FROM_VENDOR = docitem.ORIGINAL_FILE,
405
                         DOCUMENT_ID = docitem.DOCUMENT_ID,
406
                         TO_VENDOR = docitem.RESULT_FILE,
407
                         RESULT = docitem.RESULT
408
                     }).FirstOrDefault();
409
                }
410
            }
411
            catch (Exception)
412
            {
413
                throw;
414
            }
415
            finally
416
            {
417
                GC.Collect(2);
418
            }
419
            return _result;
420
        }
421

    
422
        [OperationContract]
423
        public DOCINFO GetDocInfo(KCOM_BasicParam param)
424
        {
425
            DOCINFO _result = null;
426
            try
427
            {
428
                // 차후 아래의 코드로 변경
429
                //using (CI_Entities ModelDeeview = new CI_Entities(DaelimCiConnectionString.ToString()))
430
                CIEntities ModelDeeview = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(param.projectNo).ToString());
431

    
432
                var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID);
433
                if (docinfo.Count() > 0)
434
                {
435
                    _result = docinfo.First();
436
                    _result.MARKUP_INFO.Clear();
437

    
438
                }
439
                return _result;
440

    
441
            }
442
            catch (Exception ex)
443
            {
444
                System.Diagnostics.Trace.WriteLine("GetDocInfo Error : " + ex);
445
            }
446
            finally
447
            {
448
                GC.Collect(2);
449
            }
450
            return null;
451
        }
452

    
453
        [OperationContract]
454
        public bool GetCheckSystemAdmin(string UserID)
455
        {
456
            using (KCOMEntities uc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
457
            {
458
                var user = uc.PROPERTIES.Where(data => data.TYPE == "Administrator" && data.PROPERTY.Contains(UserID)).FirstOrDefault();
459
                if (user != null)
460
                {
461
                    return true;
462
                }
463
                else
464
                {
465
                    return false;
466
                }
467
            }
468
            GC.Collect(2);
469
        }
470

    
471
        [OperationContract]
472
        public DOCUMENT_ITEM GetDocumentItemInfo(KCOM_BasicParam param)
473
        {
474
            ///param : prjNo, documentId, userId
475
            DOCUMENT_ITEM _result = null;
476

    
477
            try
478
            {
479
                CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(param.projectNo).ToString());
480

    
481
                var _items = entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == param.documentID);
482

    
483
                if (_items.Count() > 0)
484
                {
485
                    _result = _items.First();
486

    
487
                    return _result;
488
                }
489
                //else
490
                //{
491
                //    Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_DOCUMENTNOTFOUND"), param.documentID, param.projectNo);
492
                //}
493
            }
494
            catch (Exception ex)
495
            {
496
                System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex);
497
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
498
            }
499

    
500
            return _result;
501
        }
502

    
503
        public string UserGO(MARKUP_INFO item)
504
        {
505
            if (item != null)
506
            {
507
                return item.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID;
508
            }
509
            return null;
510
        }
511

    
512
        [OperationContract]
513
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
514
        {
515
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
516
            try
517
            {
518
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
519
                {
520
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
521
                    //foreach (var item in markupListData)
522
                    //{
523
                    //    if (!item.AVOID_CONSOLIDATE.HasValue)
524
                    //    {
525
                    //        item.AVOID_CONSOLIDATE = 0;
526
                    //    }
527
                    //}
528

    
529
                    var markupList = from markup in markupListData
530
                                     orderby markup.CREATE_TIME descending
531
                                     select new MarkupInfoItem
532
                                     {
533
                                         MarkupInfoID = markup.ID,
534
                                         UserID = markup.USER_ID,
535
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
536
                                         CreateTime = markup.CREATE_TIME,
537
                                         Consolidate = markup.CONSOLIDATE,
538
                                         Description = markup.DESCRIPTION,
539
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
540
                                         PartConsolidate = markup.PART_CONSOLIDATE,
541
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
542
                                     };
543

    
544

    
545

    
546
                    if (markupList.Count() > 0)
547
                    {
548
                        _result = markupList.ToList();
549
                    }
550

    
551

    
552

    
553
                    _result.ForEach(r =>
554
                    {
555

    
556
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
557
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
558
                                        orderby markupData.PAGENUMBER
559
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID }).ToList();
560
                    });
561

    
562
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
563
                    Random random = new Random();
564

    
565
                    using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
566
                    {
567
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
568
                                             where property.TYPE == "DisplayColor"
569
                                             select property).ToList();
570
                    }
571

    
572
                    foreach (var item in _result)
573
                    {
574
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
575

    
576
                        if (_member.Count() > 0)
577
                        {
578
                            item.UserName = _member.First().NAME;
579
                            item.Depatment = _member.First().DEPARTMENT;
580
                        }
581

    
582
                        if (_ColorsProperties.Count > 0)
583
                        {
584
                            int colorIdx = random.Next(1, _ColorsProperties.Count());
585
                            #region 부서별로 색상을 지정하고자 할때
586
                            /// 일단 의견을 들어보자구!
587
                            #endregion
588
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
589
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
590
                            //item.DisplayColor = "#FF" + _Colors.First();
591
                            //_Colors.Remove(_Colors.First());
592
                        }
593
                        else
594
                        {
595
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
596
                        }
597
                    }
598
                }
599
            }
600
            catch (Exception EX)
601
            {
602
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
603
                return _result;
604
            }
605
            finally
606
            {
607
                GC.Collect(2);
608
            }
609

    
610
            return _result;
611
        }
612

    
613
        [OperationContract]
614
        public List<MarkupInfoItem> GetSyncMarkupInfoItems(string ProjectNo, string DocInfoId, string currentUser)
615
        {
616
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
617
            try
618
            {
619
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
620
                {
621
                    var docItem = entity.DOCINFO.Where(data => data.DOCUMENT_ID == DocInfoId).FirstOrDefault();
622
                    if (docItem == null)
623
                    {
624
                        return null;
625
                    }
626
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == docItem.ID).ToList();
627

    
628
                    var markupList = from markup in markupListData
629
                                     where markup.USER_ID == currentUser || markup.CONSOLIDATE == 1
630
                                     orderby markup.CREATE_TIME descending
631
                                     select new MarkupInfoItem
632
                                     {
633
                                         MarkupInfoID = markup.ID,
634
                                         UserID = markup.USER_ID,
635
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
636
                                         CreateTime = markup.CREATE_TIME,
637
                                         Consolidate = markup.CONSOLIDATE,
638
                                         Description = markup.DESCRIPTION,
639
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
640
                                         PartConsolidate = markup.PART_CONSOLIDATE,
641
                                     };
642

    
643

    
644

    
645
                    if (markupList.Count() > 0)
646
                    {
647
                        _result = markupList.ToList();
648
                    }
649

    
650

    
651

    
652
                    _result.ForEach(r =>
653
                    {
654

    
655
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
656
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
657
                                        orderby markupData.PAGENUMBER
658
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID }).ToList();
659
                    });
660

    
661
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
662
                    Random random = new Random();
663

    
664
                    using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
665
                    {
666
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
667
                                             where property.TYPE == "DisplayColor"
668
                                             select property).ToList();
669
                    }
670

    
671
                    foreach (var item in _result)
672
                    {
673
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
674

    
675
                        if (_member.Count() > 0)
676
                        {
677
                            item.UserName = _member.First().NAME;
678
                            item.Depatment = _member.First().DEPARTMENT;
679
                        }
680

    
681
                        if (_ColorsProperties.Count > 0)
682
                        {
683
                            int colorIdx = random.Next(1, _ColorsProperties.Count());
684
                            #region 부서별로 색상을 지정하고자 할때
685
                            /// 일단 의견을 들어보자구!
686
                            #endregion
687
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
688
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
689
                            //item.DisplayColor = "#FF" + _Colors.First();
690
                            //_Colors.Remove(_Colors.First());
691
                        }
692
                        else
693
                        {
694
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
695
                        }
696
                    }
697
                }
698
            }
699
            catch (Exception EX)
700
            {
701
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
702
                return _result;
703
            }
704
            finally
705
            {
706
                GC.Collect(2);
707
            }
708

    
709
            return _result;
710
        }
711

    
712

    
713
        //[OperationContract]
714
        //[ServiceKnownType(typeof(MEMBER))]
715
        //public List<MEMBER> GetUserData(string ProjectNo, string UserID)
716
        //{
717
        //    List<MEMBER> _result = new List<MEMBER>();
718

    
719
        //    using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
720
        //    {
721
        //        var _UserList = from member in entity.MEMBER
722
        //                        where member.ID == UserID
723
        //                        select member;
724
        //        _result = _UserList.ToList();
725
        //    }
726
        //    //GC.Collect(2);
727
        //    return _result;
728
        //}
729

    
730
        [OperationContract]
731
        [ServiceKnownType(typeof(MEMBER))]
732
        public List<MEMBER> GetUserData(string ProjectNo, string UserID)
733
        {
734
            List<MEMBER> _result = new List<MEMBER>();
735

    
736
            using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
737
            {
738
                var _UserList = from member in entity.MEMBER
739
                                where member.ID == UserID
740
                                select member;
741
                _result = _UserList.ToList();
742
            }
743
            //GC.Collect(2);
744
            return _result;
745
        }
746

    
747

    
748
        [OperationContract]
749
        public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정
750
        {
751
            List<string> _result = new List<string>();
752

    
753
            try
754
            {
755
                KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString());
756
                var YourEnginner = (from dept in entity.PROPERTIES
757
                                    where dept.TYPE == "DeptName" && UserDept.Contains(dept.VALUE)
758
                                    select dept).FirstOrDefault();
759

    
760
                if (YourEnginner != null)
761
                {
762
                    _result = (from dept in entity.PROPERTIES
763
                               where dept.PROPERTY == YourEnginner.PROPERTY
764
                               select dept.VALUE).ToList();
765
                    return _result;
766
                }
767
                else
768
                {
769
                    return null;
770
                }
771
            }
772
            catch (Exception ex)
773
            {
774
                System.Diagnostics.Debug.WriteLine(ex.Message);
775
            }
776
            finally
777
            {
778
                GC.Collect(2);
779
            }
780
            return _result;
781
        }
782

    
783
        [OperationContract]
784
        public bool DeleteMarkup(string ProjectNo, string MarkupInfoID)
785
        {
786
            bool _result = false;
787
            try
788
            {
789
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
790
                {
791

    
792
                    MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault();
793

    
794
                    if (instance == null)
795
                    {
796
                        return false;
797
                    }
798
                    MARKUP_INFO_VERSION version = instance.MARKUP_INFO_VERSION.FirstOrDefault();
799

    
800

    
801
                    version.MARKUP_DATA.ToList().ForEach(data =>
802
                    {
803
                        Entity.MARKUP_DATA.DeleteObject(data);
804
                        Entity.SaveChanges();
805
                    });
806

    
807
                    Entity.MARKUP_INFO_VERSION.DeleteObject(version);
808
                    Entity.SaveChanges();
809

    
810
                    Entity.MARKUP_INFO.DeleteObject(instance);
811
                    Entity.SaveChanges();
812

    
813
                }
814
                _result = true;
815
            }
816
            catch (Exception ex)
817
            {
818
                System.Diagnostics.Trace.WriteLine(ex, "SaveMarkup");
819
            }
820
            finally
821
            {
822
                GC.Collect(2);
823
            }
824
            return _result;
825
        }
826

    
827
        #region Favorite
828
        [OperationContract]
829
        public bool SetFavoriteVP(string prjNo, string userID, string groupNo, string docNo, string rev, int SavePageNo, string documentItemID, string VPDescription, IKCOM.FAVORITE_FLAG flag)
830
        {
831

    
832
            using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
833
            {
834
                try
835
                {
836
                    entity.FAVORITE_DOC.AddObject(new FAVORITE_DOC
837
                    {
838
                        ID = shortGuid(),
839
                        PROJECT_NO = prjNo,
840
                        DOCUMENT_ID = documentItemID,
841
                        GROUP_NO = groupNo,
842
                        DOCUMENT_NO = docNo,
843
                        MEMBER_USER_ID = userID,
844
                        DESCRIPTION = VPDescription,
845
                        CREATE_TIME = DateTime.Now,
846
                        REVISION = rev,
847
                        FLAG = (int)flag,
848
                        PAGE_NO = SavePageNo,
849
                    });
850
                    entity.SaveChanges();
851
                }
852
                catch (Exception)
853
                {
854
                    return false;
855
                }
856

    
857
                return true;
858
            }
859
        }
860

    
861
        //[OperationContract]
862
        //public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
863
        //{
864
        //    using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
865
        //    {
866

    
867
        //        int flagString = Convert.ToInt32(IKCOM.FAVORITE_FLAG.Personal);                
868
        //        List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
869
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
870
        //            flagString).ToList().ForEach(data => favoriteListSet.Add(data));
871
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data));
872
        //        favoriteListSet = favoriteListSet.Distinct().ToList();
873
        //        return favoriteListSet;
874
        //    }
875
        //}
876
        //[OperationContract]
877
        //public bool EditFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime, int state, string description)
878
        //{
879
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
880
        //    {
881
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
882
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
883

    
884
        //        try
885
        //        {
886

    
887

    
888
        //            if (favoriteSet.Count > 0)
889
        //            {
890
        //                var FavoriteVP_Instance = favoriteSet.First();
891

    
892
        //                FavoriteVP_Instance.Description = description;
893
        //                FavoriteVP_Instance.Flag = state;
894

    
895
        //                dc.SaveChanges();
896

    
897
        //                return true;
898
        //            }
899
        //            else
900
        //            {
901
        //                return false;
902
        //            }
903
        //        }
904
        //        catch (Exception)
905
        //        {
906
        //            return false;
907
        //        }
908
        //    }
909
        //}
910
        //[OperationContract]
911
        //public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime)
912
        //{
913

    
914
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
915
        //    {
916
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
917
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
918

    
919
        //        try
920
        //        {
921

    
922

    
923
        //            if (favoriteSet.Count > 0)
924
        //            {
925
        //                favoriteSet.ForEach(data => dc.FavoriteVP.DeleteObject(data));
926
        //                dc.SaveChanges();
927
        //                return true;
928
        //            }
929
        //            else
930
        //            {
931
        //                return false;
932
        //            }
933
        //        }
934
        //        catch (Exception)
935
        //        {
936
        //            return false;
937
        //        }
938
        //    }
939
        //}
940
        #endregion
941

    
942
        [OperationContract]
943
        public bool SaveMarkupData(MarkupInfoItem UserState,string project_no,string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
944
        {
945
            using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
946
            {     
947
                #region Docinfo 정보 가져오기
948

    
949
                string docinfoid_ = (from info in Entity.DOCINFO
950
                                     where info.DOCUMENT_ID == doc_id
951
                                     && info.PROJECT_NO == project_no
952
                                     select info.ID
953
                                     ).First().ToString();
954
                #endregion
955

    
956
                #region Markup_Info 저장
957

    
958
                MARKUP_INFO markup_info = new MARKUP_INFO();
959
                try
960
                {
961
                    markup_info = (from info in Entity.MARKUP_INFO
962
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
963
                                   select info).FirstOrDefault();
964
                }
965
                catch (Exception)
966
                {
967
                    markup_info = null;
968
                }
969

    
970
                //markup_info가 없을 경우 생성
971
                if (markup_info == null)
972
                {
973
                    //MarkupInfo 저장
974
                    markup_info = new MARKUP_INFO
975
                    {
976
                        ID = UserState.MarkupInfoID,
977
                        DOCINFO_ID = docinfoid_,
978
                        USER_ID = user_id,
979
                        CREATE_TIME = DateTime.Now,
980
                        CONSOLIDATE = UserState.Consolidate,
981
                        AVOID_CONSOLIDATE = UserState.AvoidConsolidate,
982
                        PART_CONSOLIDATE = UserState.PartConsolidate,
983
                        DESCRIPTION = UserState.Description,
984
                        UPDATE_TIME = DateTime.Now
985
                    };
986
                    Entity.MARKUP_INFO.AddObject(markup_info);
987
                }
988
                //markup_info가 있을 경우 업데이트
989
                else
990
                {
991
                    markup_info.UPDATE_TIME = DateTime.Now;
992
                }
993
                Entity.SaveChanges();
994
                #endregion
995

    
996
                #region Markup_Info_Version 저장
997

    
998
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
999

    
1000
                try
1001
                {
1002
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1003
                                           where info.MARKUPINFO_ID == markup_info.ID
1004
                                           select info).FirstOrDefault();
1005
                }
1006
                catch (Exception)
1007
                {
1008
                    markup_info_version = null;
1009
                }
1010

    
1011
                //markup_info_version 없을 경우 생성
1012
                if (markup_info_version == null)
1013
                {
1014
                    //MarkupInfo_version 저장
1015
                    markup_info_version = new MARKUP_INFO_VERSION()
1016
                    {
1017
                        ID = UserState.MarkupVersionID,
1018
                        MARKUPINFO_ID = markup_info.ID,
1019
                        CREATE_DATE = DateTime.Now
1020
                    };
1021
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1022
                    Entity.SaveChanges();
1023
                }
1024
                #endregion
1025

    
1026
                
1027
                Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1028
                {
1029
                    Entity.MARKUP_DATA.DeleteObject(item);
1030
                });
1031
                Entity.SaveChanges();
1032

    
1033
                try
1034
                {
1035
                    mlmarkup_data.ForEach(value =>
1036
                    {
1037
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1038
                        {
1039
                            ID = value.ID,
1040
                            DATA = value.DATA,
1041
                            DATA_TYPE = value.DATA_TYPE,
1042
                            PAGENUMBER = value.PAGENUMBER,
1043
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1044
                            SYMBOL_ID = value.SYMBOL_ID
1045
                        });
1046
                    });
1047
                    Entity.SaveChanges();
1048
                }
1049
                catch (Exception)
1050
                {
1051
                    return false;
1052
                }
1053
            }
1054
            return true;
1055
        }
1056

    
1057

    
1058
        [OperationContract]
1059
        public bool SaveSymbol(SYMBOL_PRIVATE symbol_private)
1060
        {
1061
            try
1062
            {
1063
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
1064
                {
1065
                    uc.AddToSYMBOL_PRIVATE(symbol_private);
1066
                    uc.SaveChanges();
1067
                }
1068
            }
1069
            catch(Exception)
1070
            {
1071
                return false;
1072
            }
1073
            return true;
1074
        }
1075
        [OperationContract]
1076
        public bool AddPublicSymbol(SYMBOL_PUBLIC symbol)
1077
        {
1078
            try
1079
            {
1080
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
1081
                {
1082
                    uc.AddToSYMBOL_PUBLIC(symbol);
1083
                    uc.SaveChanges();
1084
                }
1085
            }
1086
            catch (Exception)
1087
            {
1088
                return false;
1089
            }
1090
            return true;
1091
        }
1092
        [OperationContract]
1093
        public bool DeleteSymbol(string symbol_id, int type)
1094
        {
1095
            try
1096
            {
1097
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1098
                {
1099
                    if (type == 0)
1100
                    {
1101
                        string delItem_ID = symbol_id;
1102
                        var delitem = Entity.SYMBOL_PRIVATE.Where(data => data.ID == delItem_ID).FirstOrDefault();
1103
                        Entity.SYMBOL_PRIVATE.DeleteObject(delitem);
1104
                        Entity.SaveChanges();
1105
                    }
1106
                    else
1107
                    {
1108
                        string delItem_ID = symbol_id;
1109
                        var delitem = Entity.SYMBOL_PUBLIC.Where(data => data.ID == delItem_ID).FirstOrDefault();
1110
                        Entity.SYMBOL_PUBLIC.DeleteObject(delitem);
1111
                        Entity.SaveChanges();
1112
                    }
1113
                }
1114
            }
1115
            catch(Exception)
1116
            {
1117
                return false;
1118
            }
1119
            return true;
1120
        }
1121

    
1122
        [OperationContract]
1123
        public bool RenameSymbol(string symbol_id, string name, int type)
1124
        {
1125
            try
1126
            {
1127
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1128
                {
1129
                    if (type == 0)
1130
                    {
1131
                        var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == symbol_id).FirstOrDefault();
1132
                        UpdateItem.NAME = name;
1133
                        Entity.SaveChanges();
1134
                    }
1135
                    else
1136
                    {
1137
                        var UpdateItem = Entity.SYMBOL_PUBLIC.Where(info => info.ID == symbol_id).FirstOrDefault();
1138
                        UpdateItem.NAME = name;
1139
                        Entity.SaveChanges();
1140
                    }
1141
                }
1142
            }
1143
            catch (Exception)
1144
            {
1145
                return false;
1146
            }
1147
            return true;
1148
        }
1149

    
1150
        [OperationContract]
1151
        public bool AddCheckListHistory(string project_no, CHECK_LIST_HISTORY Check_History)
1152
        {
1153
            try
1154
            {                
1155
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1156
                {
1157
                    Entity.CHECK_LIST_HISTORY.AddObject(Check_History);
1158
                    Entity.SaveChanges();  
1159
                }
1160
            }
1161
            catch (Exception)
1162
            {
1163
                return false;
1164
            }
1165
            return true;
1166
        }
1167
        [OperationContract]
1168
        public bool SaveCheckListHistory(string project_no, string rev, CHECK_LIST_HISTORY Check_History)
1169
        {
1170
            try
1171
            {
1172
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1173
                {
1174
                    var item = Entity.CHECK_LIST_HISTORY.Where(info => info.REVISION == rev).FirstOrDefault();
1175
                    item = Check_History;
1176
                    Entity.SaveChanges();
1177
                }
1178
            }
1179
            catch (Exception)
1180
            {
1181
                return false;
1182
            }
1183
            return true;
1184
        }
1185
        [OperationContract]
1186
        public bool SaveCheckList(string project_no, string _id, CHECK_LIST Check_value)
1187
        {
1188
            try
1189
            {
1190
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1191
                {
1192
                    var item = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1193
                    item.TODOLIST = Check_value.TODOLIST;
1194
                    item.REMARK = Check_value.REMARK;
1195
                    item.STATUS = Check_value.STATUS;
1196
                    item.VENDOR = Check_value.VENDOR;
1197
                    item.REPLY = Check_value.REPLY;
1198
                    item.IMAGE_URL = Check_value.IMAGE_URL;
1199
                    item.IMAGE_ANCHOR = Check_value.IMAGE_ANCHOR;
1200
                    item.UPDATE_TIME = Check_value.UPDATE_TIME;
1201
                    if(Check_value.STATUS == "False")
1202
                    {
1203
                        item.STATUS_DESC_OPEN = Check_value.STATUS_DESC_OPEN;
1204
                    }
1205
                    else
1206
                    {
1207
                        item.STATUS_DESC_CLOSE = Check_value.STATUS_DESC_CLOSE;
1208
                    }                     
1209
                    Entity.SaveChanges();
1210
                }
1211
            }
1212
            catch (Exception)
1213
            {
1214
                return false;
1215
            }
1216
            return true;
1217
        }
1218
        [OperationContract]
1219
        public bool AddCheckList(string project_no, CHECK_LIST Check_value)
1220
        {
1221
            try
1222
            {
1223
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1224
                {
1225
                    Entity.CHECK_LIST.AddObject(Check_value);
1226
                    Entity.SaveChanges();
1227
                }
1228
            }
1229
            catch (Exception)
1230
            {
1231
                return false;
1232
            }
1233
            return true;
1234
        }
1235

    
1236
        [OperationContract]
1237
        public CHECK_LIST GetCheckList(string project_no, string _id)
1238
        {
1239
            CHECK_LIST Check_value = new CHECK_LIST();
1240
            try
1241
            {
1242
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1243
                {
1244
                    Check_value = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1245
                }
1246
            }
1247
            catch (Exception)
1248
            {
1249
                return null;
1250
            }
1251
            return Check_value;
1252
        }
1253
        [OperationContract]
1254
        public List<CHECK_LIST> GetUserCheckList(string project_no, string user_id, string doc_no)
1255
        {
1256
            List<CHECK_LIST> list = new List<CHECK_LIST>();
1257
            try
1258
            {
1259
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1260
                {
1261
                    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();
1262
                }
1263
            }
1264
            catch (Exception)
1265
            {
1266
                return null;
1267
            }
1268
            return list;
1269
        }
1270
        [OperationContract]
1271
        public List<CHECK_LIST_HISTORY> GetCheckListHistory(string project_no, string _id)
1272
        {
1273
            List<CHECK_LIST_HISTORY> history = new List<CHECK_LIST_HISTORY>();
1274
            try
1275
            {
1276
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1277
                {
1278
                    history = Entity.CHECK_LIST_HISTORY.Where(data => data.CHECKLIST_ID == _id).ToList();
1279
                }
1280
            }
1281
            catch (Exception)
1282
            {
1283
                return null;
1284
            }
1285
            return history;
1286
        }
1287
        [OperationContract]
1288
        public CHECK_LIST_HISTORY GetCheckListHistoryFirstOrDefault(string project_no, string checklist_id, string rev)
1289
        {
1290
            CHECK_LIST_HISTORY Check_Item = new CHECK_LIST_HISTORY();
1291
            try
1292
            {
1293
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1294
                {   
1295
                    Check_Item = Entity.CHECK_LIST_HISTORY.Where(info => info.CHECKLIST_ID == checklist_id && info.REVISION == rev).FirstOrDefault();
1296
                }
1297
            }
1298
            catch (Exception)
1299
            {
1300
                return null;
1301
            }
1302
            return Check_Item;
1303
        }
1304
        [OperationContract]
1305
        public bool SavePageAngle(string project_no, List<DOCPAGE> _mldocpage)
1306
        {
1307
            try
1308
            {
1309
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1310
                {
1311
                    KCOMDataModel.DataModel.DOCPAGE _docpage = new KCOMDataModel.DataModel.DOCPAGE();
1312
                    _mldocpage.ForEach(data =>
1313
                    {
1314
                        _docpage = (from info in Entity.DOCPAGE
1315
                                    where info.ID == data.ID
1316
                                    select info).FirstOrDefault();
1317

    
1318
                        if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE)
1319
                        {
1320
                            _docpage.PAGE_ANGLE = data.PAGE_ANGLE;
1321
                        }
1322
                    });
1323

    
1324
                    Entity.SaveChanges();
1325
                }
1326
            }
1327
            catch (Exception)
1328
            {
1329
                return false;
1330
            }
1331
            return true;
1332
        }
1333

    
1334
        [OperationContract]
1335
        public MARKUP_INFO GetMarkupInfo(string project_no, string _id)
1336
        {
1337
            MARKUP_INFO markupInfo = new MARKUP_INFO();
1338

    
1339
            try
1340
            {
1341
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1342
                {
1343
                    markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1344
                }
1345
            }
1346
            catch (Exception)
1347
            {
1348
                return null;
1349
            }
1350
            return markupInfo;
1351
        }
1352

    
1353
        [OperationContract]
1354
        public List<string> GetMarkupDataListperPage(string project_no, string _markupinfoid, int _pageNo)
1355
        {
1356
            List<string> markupdata = new List<string>();
1357
            MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1358
            try
1359
            {
1360
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1361
                {
1362
                    markup_info_version = (from version in Entity.MARKUP_INFO_VERSION
1363
                                           where version.MARKUPINFO_ID == _markupinfoid
1364
                                           orderby version.CREATE_DATE descending
1365
                                           select version).First();
1366
                    markupdata = (from data in Entity.MARKUP_DATA
1367
                                  where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo
1368
                                  select data.DATA).ToList();
1369
                }
1370
            }
1371
            catch (Exception)
1372
            {
1373
                return null;
1374
            }
1375
            return markupdata;
1376
        }
1377

    
1378
        [OperationContract]
1379
        public bool AddMarkupInfo(string project_no, MARKUP_INFO value)
1380
        {
1381
            try
1382
            {
1383
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1384
                {
1385
                    Entity.MARKUP_INFO.AddObject(value);
1386
                    Entity.SaveChanges();
1387
                }
1388
            }
1389
            catch (Exception)
1390
            {
1391
                return false;
1392
            }
1393
            return true;
1394
        }
1395

    
1396
        [OperationContract]
1397
        public bool AddMarkupInfoVersion(string project_no, MARKUP_INFO_VERSION value)
1398
        {
1399
            try
1400
            {
1401
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1402
                {
1403
                    Entity.MARKUP_INFO_VERSION.AddObject(value);
1404
                    Entity.SaveChanges();
1405
                }
1406
            }
1407
            catch (Exception)
1408
            {
1409
                return false;
1410
            }
1411
            return true;
1412
        }
1413

    
1414
        [OperationContract]
1415
        public bool AddMarkupData(string project_no, MARKUP_DATA value)
1416
        {
1417
            try
1418
            {
1419
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1420
                {
1421
                    Entity.MARKUP_DATA.AddObject(value);
1422
                    Entity.SaveChanges();
1423
                }
1424
            }
1425
            catch (Exception)
1426
            {
1427
                return false;
1428
            }
1429
            return true;
1430
        }
1431

    
1432
        [OperationContract]
1433
        public bool AvoidMarkupInfo(string project_no, string _doc_id)
1434
        {
1435
            try
1436
            {
1437
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1438
                {
1439
                    var item = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1440
                    item.AVOID_CONSOLIDATE = 1;
1441
                    Entity.SaveChanges();
1442
                }
1443
            }
1444
            catch (Exception)
1445
            {
1446
                return false;
1447
            }
1448
            return true;
1449
        }
1450

    
1451
        [OperationContract]
1452
        public bool SaveMarkupInfo(string project_no, string _id, MARKUP_INFO value)
1453
        {
1454
            try
1455
            {
1456
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1457
                {
1458
                    var item = Entity.MARKUP_INFO.Where(info => info.ID == _id).FirstOrDefault();
1459
                    item = value;                    
1460
                    Entity.SaveChanges();
1461
                }
1462
            }
1463
            catch (Exception)
1464
            {
1465
                return false;
1466
            }
1467
            return true;
1468
        }
1469
        [OperationContract]
1470
        public List<MARKUP_DATA> GetMarkupDataList(string project_no, string _versionid)
1471
        {
1472
            List<MARKUP_DATA> mlresult = new List<MARKUP_DATA>();
1473

    
1474
            try
1475
            {
1476
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1477
                {
1478
                    mlresult = Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == _versionid).ToList();
1479
                }
1480
            }
1481
            catch (Exception)
1482
            {
1483
                return null;
1484
            }
1485
            return mlresult;
1486
        }
1487

    
1488
        [OperationContract]
1489
        public bool Consolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
1490
        {
1491
            try
1492
            {
1493
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1494
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1495
                {
1496
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1497
                    if (markupInfo.CONSOLIDATE == 1)
1498
                    {
1499
                        markupInfo.AVOID_CONSOLIDATE = 1;
1500
                    }
1501

    
1502
                    foreach (MarkupInfoItem item in markupInfoItems)
1503
                    {
1504
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1505
                        {
1506
                            instanceDataSet.Add(d);
1507
                        });
1508
                    }
1509

    
1510
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1511
                    info.ID = shortGuid();
1512
                    info.CONSOLIDATE = 1;
1513
                    info.CREATE_TIME = DateTime.Now;
1514
                    info.DOCINFO_ID = _doc_id;
1515
                    info.UPDATE_TIME = DateTime.Now;
1516
                    info.USER_ID = _user_id;
1517
                    info.AVOID_CONSOLIDATE = 0;
1518

    
1519
                    Entity.MARKUP_INFO.AddObject(info);
1520
                    Entity.SaveChanges();
1521

    
1522

    
1523
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1524
                    {
1525
                        ID = shortGuid(),
1526
                        CREATE_DATE = DateTime.Now,
1527
                        MARKUP_INFO = info,
1528
                    };
1529
                    Entity.SaveChanges();
1530

    
1531
                    foreach (var item in instanceDataSet)
1532
                    {
1533
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1534
                        {
1535
                            ID = shortGuid(),
1536
                            DATA = item.DATA,
1537
                            DATA_TYPE = item.DATA_TYPE,
1538
                            PAGENUMBER = item.PAGENUMBER,
1539
                            MARKUP_INFO_VERSION = info2,
1540
                            SYMBOL_ID = item.SYMBOL_ID
1541
                        });
1542
                    }
1543
                    Entity.SaveChanges();
1544

    
1545

    
1546
                }
1547
            }
1548
            catch (Exception)
1549
            {
1550
                return false;
1551
            }
1552
            return true;
1553
        }
1554

    
1555
        [OperationContract]
1556
        public bool TeamConsolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
1557
        {
1558
            try
1559
            {
1560
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1561
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1562
                {
1563
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1564
                    if (markupInfo.PART_CONSOLIDATE == 1)
1565
                    {
1566
                        markupInfo.AVOID_CONSOLIDATE = 1;
1567
                    }
1568

    
1569
                    foreach (MarkupInfoItem item in markupInfoItems)
1570
                    {
1571
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1572
                        {
1573
                            instanceDataSet.Add(d);
1574
                        });
1575
                    }
1576

    
1577
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1578
                    info.ID = shortGuid();
1579
                    info.PART_CONSOLIDATE = 1;
1580
                    info.CREATE_TIME = DateTime.Now;
1581
                    info.DOCINFO_ID = _doc_id;
1582
                    info.UPDATE_TIME = DateTime.Now;
1583
                    info.USER_ID = _user_id;
1584
                    info.AVOID_CONSOLIDATE = 0;
1585

    
1586
                    Entity.MARKUP_INFO.AddObject(info);
1587
                    Entity.SaveChanges();
1588

    
1589

    
1590
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1591
                    {
1592
                        ID = shortGuid(),
1593
                        CREATE_DATE = DateTime.Now,
1594
                        MARKUP_INFO = info,
1595
                    };
1596
                    Entity.SaveChanges();
1597

    
1598
                    foreach (var item in instanceDataSet)
1599
                    {
1600
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1601
                        {
1602
                            ID = shortGuid(),
1603
                            DATA = item.DATA,
1604
                            DATA_TYPE = item.DATA_TYPE,
1605
                            PAGENUMBER = item.PAGENUMBER,
1606
                            MARKUP_INFO_VERSION = info2,
1607
                            SYMBOL_ID = item.SYMBOL_ID
1608
                        });
1609
                    }
1610
                    Entity.SaveChanges();
1611

    
1612

    
1613
                }
1614
            }
1615
            catch (Exception)
1616
            {
1617
                return false;
1618
            }
1619
            return true;
1620
        }
1621

    
1622
        [OperationContract]
1623
        [ServiceKnownType(typeof(MEMBER))]
1624
        public MEMBER GetMember(string project_no, string user_id)
1625
        {
1626
            MEMBER rstmember = new MEMBER();
1627
            try
1628
            {
1629
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1630
                {
1631
                    var tmp = (from member in Entity.MEMBER
1632
                                    where member.ID == user_id
1633
                                    select member).FirstOrDefault();
1634
                    rstmember.DEPARTMENT = tmp.DEPARTMENT;
1635
                    rstmember.ID = tmp.ID;
1636
                    rstmember.NAME = tmp.NAME;
1637
                }
1638
            }
1639
            catch (Exception)
1640
            {
1641
                return null;
1642
            }
1643
            return rstmember;
1644
        }
1645

    
1646
        [OperationContract]
1647
        public List<SYMBOL_PRIVATE> GetSymbolList(string user_id)
1648
        {
1649
            List<SYMBOL_PRIVATE> Custom_List = new List<SYMBOL_PRIVATE>();
1650
            try
1651
            {
1652
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1653
                {
1654
                    Custom_List = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == user_id).ToList();
1655
                }
1656
            }
1657
            catch (Exception)
1658
            {
1659
                return null;
1660
            }
1661
            return Custom_List;
1662
        }
1663
        [OperationContract]
1664
        public List<string> GetPublicSymbolDeptList()
1665
        {
1666
            List<string> Custom_List = new List<string>();
1667
            try
1668
            {
1669
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1670
                {
1671
                    Custom_List = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).ToList();
1672
                }
1673
            }
1674
            catch (Exception)
1675
            {
1676
                return null;
1677
            }
1678
            return Custom_List;
1679
        }
1680
        [OperationContract]
1681
        public List<SYMBOL_PUBLIC> GetPublicSymbolList(string dept)
1682
        {
1683
            List<SYMBOL_PUBLIC> Custom_List = new List<SYMBOL_PUBLIC>();
1684
            try
1685
            {
1686
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1687
                {
1688
                    if(!string.IsNullOrEmpty(dept))
1689
                    {
1690
                        Custom_List = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == dept).ToList();
1691
                    }
1692
                    else
1693
                    {
1694
                        Custom_List = Entity.SYMBOL_PUBLIC.ToList();
1695
                    }
1696
                    
1697
                }
1698
            }
1699
            catch (Exception)
1700
            {
1701
                return null;
1702
            }
1703
            return Custom_List;
1704
        }
1705

    
1706
        /// <summary>
1707
        /// 
1708
        /// </summary>
1709
        /// <param name="id">symbol id</param>
1710
        /// <param name="type"> 0 : PRIVATE, 1 : PUBLIC</param>
1711
        /// <returns></returns>
1712
        [OperationContract]
1713
        public string GetSymbolData(string id, int type)
1714
        {
1715
            string result;
1716
            try
1717
            {
1718
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1719
                {
1720
                    if(type == 0)
1721
                    {
1722
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA;
1723
                    }
1724
                    else
1725
                    {
1726
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA;
1727
                    }
1728
                }
1729
            }
1730
            catch (Exception)
1731
            {
1732
                return null;
1733
            }
1734
            return result;
1735
        }
1736

    
1737
        [OperationContract]
1738
        public string GetSignData(string project_no, string user_id)
1739
        {
1740
            string result = null;
1741
            try
1742
            {
1743
                var ModelWFConnectionString = ConnectStringBuilder.ProjectCIConnectString(project_no).ToString();
1744
                if (null != ModelWFConnectionString)
1745
                {
1746
                    using (CIEntities entity = new CIEntities(ModelWFConnectionString))
1747
                    {
1748
                        var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
1749
                        if (_sign.Count() > 0)
1750
                        {
1751
                            result = _sign.First().SIGN_STR;                            
1752
                        }
1753
                        else
1754
                        {
1755
                            return null;
1756
                        }
1757
                    }
1758
                }
1759
            }
1760
            catch (Exception)
1761
            {
1762
                return null;
1763
            }
1764
            return result;
1765
        }
1766

    
1767
        [OperationContract]        
1768
        public string GetProjectName(string project_no)
1769
        {
1770
            string result = null;
1771

    
1772
            try
1773
            {
1774
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
1775
                {
1776
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
1777
                }
1778
            }
1779
            catch (Exception)
1780
            {
1781
                return null;
1782
            }
1783
            return result;
1784
        }
1785

    
1786
        [OperationContract]
1787
        public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev)
1788
        {
1789
            List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>();
1790
            
1791
            try
1792
            {
1793
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1794
                {
1795
                    result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no
1796
                    && i.DOCUMENT_NO == doc_no
1797
                    && i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList();
1798
                }
1799
            }
1800
            catch (Exception)
1801
            {
1802
                return null;
1803
            }
1804
            return result;
1805
        }
1806

    
1807
        [OperationContract]
1808
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
1809
        {
1810
            DOCINFO docinfo = null;
1811

    
1812
            try
1813
            {
1814
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1815
                {
1816
                    docinfo = (from info in Entity.DOCINFO
1817
                              where info.DOCUMENT_ID == doc_id
1818
                              && info.PROJECT_NO == project_no
1819
                              select info).First();
1820
                }
1821
            }
1822
            catch (Exception)
1823
            {
1824
                return null;
1825
            }
1826
            return docinfo;
1827
        }
1828

    
1829
        [OperationContract]
1830
        public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList)
1831
        {
1832
            MarkupInfoItem _result = null;
1833
            List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>();
1834
            try
1835
            {
1836
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1837
                {
1838
                    var docitem = (from info in Entity.DOCINFO
1839
                               where info.DOCUMENT_ID == doc_id
1840
                               && info.PROJECT_NO == project_no
1841
                               select info).First();
1842

    
1843
                    foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO)
1844
                    {
1845
                        var member = (from mem in Entity.MEMBER
1846
                                     where mem.ID == markinfo.USER_ID
1847
                                     select mem).First();
1848
                        string displaycolor = null;
1849
                        try
1850
                        {
1851
                            displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor;
1852
                        }
1853
                        catch(Exception)
1854
                        {
1855
                            displaycolor = "#FFFFFF";
1856
                        }
1857
                        
1858
                        _result = new MarkupInfoItem
1859
                        {
1860
                            MarkupInfoID = markinfo.ID,
1861
                            Consolidate = markinfo.CONSOLIDATE,
1862
                            CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME,
1863
                            DisplayColor = displaycolor,
1864
                            UserID = markinfo.USER_ID,
1865
                            UserName = member.NAME,
1866
                            Depatment = member.DEPARTMENT,
1867
                        };
1868

    
1869
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
1870
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
1871

    
1872
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
1873
                        {
1874
                            MarkupItem markitem = new MarkupItem()
1875
                            {
1876
                                ID = markdata.ID,
1877
                                PageNumber = markdata.PAGENUMBER,
1878
                            };
1879
                            _result.MarkupList.Add(markitem);
1880
                        }
1881

    
1882
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
1883

    
1884
                        markupinfo.Add(_result);
1885
                    }
1886
                }
1887
            }
1888
            catch (Exception)
1889
            {
1890
                return null;
1891
            }
1892
            return markupinfo;
1893
        }
1894

    
1895
        [OperationContract]
1896
        public bool AddMessage(string project_no, TALK value)
1897
        {
1898
            try
1899
            {
1900
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1901
                {                    
1902
                    entity.TALK.AddObject(value);
1903
                    entity.SaveChanges();
1904
                }
1905
            }
1906
            catch (Exception)
1907
            {
1908
                return false;
1909
            }
1910
            return true;
1911
        }
1912

    
1913
        [OperationContract]
1914
        public List<TALK> GetMessage(string project_no, string doc_id)
1915
        {
1916
            List<TALK> result = new List<TALK>();
1917
            try
1918
            {
1919
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1920
                {
1921
                    result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList();                        
1922
                }
1923
            }
1924
            catch (Exception)
1925
            {
1926
                return result;
1927
            }
1928
            return result;
1929
        }
1930
    }
1931
}
클립보드 이미지 추가 (최대 크기: 500 MB)