프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ 5de0c110

이력 | 보기 | 이력해설 | 다운로드 (73.4 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 => Convert.ToInt32(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

    
1076
        [OperationContract]
1077
        public bool DeleteSymbol(string symbol_id)
1078
        {
1079
            try
1080
            {
1081
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1082
                {
1083
                    string delItem_ID = symbol_id;
1084
                    var delitem = Entity.SYMBOL_PRIVATE.Where(data => data.ID == delItem_ID).FirstOrDefault();
1085
                    Entity.SYMBOL_PRIVATE.DeleteObject(delitem);
1086
                    Entity.SaveChanges();
1087
                }
1088
            }
1089
            catch(Exception)
1090
            {
1091
                return false;
1092
            }
1093
            return true;
1094
        }
1095

    
1096
        [OperationContract]
1097
        public bool RenameSymbol(string symbol_id, string name)
1098
        {
1099
            try
1100
            {
1101
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1102
                {
1103
                    var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == symbol_id).FirstOrDefault();
1104
                    UpdateItem.NAME = name;
1105
                    Entity.SaveChanges();
1106
                }
1107
            }
1108
            catch (Exception)
1109
            {
1110
                return false;
1111
            }
1112
            return true;
1113
        }
1114

    
1115
        [OperationContract]
1116
        public bool AddCheckListHistory(string project_no, CHECK_LIST_HISTORY Check_History)
1117
        {
1118
            try
1119
            {                
1120
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1121
                {
1122
                    Entity.CHECK_LIST_HISTORY.AddObject(Check_History);
1123
                    Entity.SaveChanges();  
1124
                }
1125
            }
1126
            catch (Exception)
1127
            {
1128
                return false;
1129
            }
1130
            return true;
1131
        }
1132
        [OperationContract]
1133
        public bool SaveCheckListHistory(string project_no, string rev, CHECK_LIST_HISTORY Check_History)
1134
        {
1135
            try
1136
            {
1137
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1138
                {
1139
                    var item = Entity.CHECK_LIST_HISTORY.Where(info => info.REVISION == rev).FirstOrDefault();
1140
                    item = Check_History;
1141
                    Entity.SaveChanges();
1142
                }
1143
            }
1144
            catch (Exception)
1145
            {
1146
                return false;
1147
            }
1148
            return true;
1149
        }
1150
        [OperationContract]
1151
        public bool SaveCheckList(string project_no, string _id, CHECK_LIST Check_value)
1152
        {
1153
            try
1154
            {
1155
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1156
                {
1157
                    var item = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1158
                    item.TODOLIST = Check_value.TODOLIST;
1159
                    item.REMARK = Check_value.REMARK;
1160
                    item.STATUS = Check_value.STATUS;
1161
                    item.VENDOR = Check_value.VENDOR;
1162
                    item.REPLY = Check_value.REPLY;
1163
                    item.IMAGE_URL = Check_value.IMAGE_URL;
1164
                    item.IMAGE_ANCHOR = Check_value.IMAGE_ANCHOR;
1165
                    item.UPDATE_TIME = Check_value.UPDATE_TIME;
1166
                    if(Check_value.STATUS == "False")
1167
                    {
1168
                        item.STATUS_DESC_OPEN = Check_value.STATUS_DESC_OPEN;
1169
                    }
1170
                    else
1171
                    {
1172
                        item.STATUS_DESC_CLOSE = Check_value.STATUS_DESC_CLOSE;
1173
                    }                     
1174
                    Entity.SaveChanges();
1175
                }
1176
            }
1177
            catch (Exception)
1178
            {
1179
                return false;
1180
            }
1181
            return true;
1182
        }
1183
        [OperationContract]
1184
        public bool AddCheckList(string project_no, CHECK_LIST Check_value)
1185
        {
1186
            try
1187
            {
1188
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1189
                {
1190
                    Entity.CHECK_LIST.AddObject(Check_value);
1191
                    Entity.SaveChanges();
1192
                }
1193
            }
1194
            catch (Exception)
1195
            {
1196
                return false;
1197
            }
1198
            return true;
1199
        }
1200

    
1201
        [OperationContract]
1202
        public CHECK_LIST GetCheckList(string project_no, string _id)
1203
        {
1204
            CHECK_LIST Check_value = new CHECK_LIST();
1205
            try
1206
            {
1207
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1208
                {
1209
                    Check_value = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1210
                }
1211
            }
1212
            catch (Exception)
1213
            {
1214
                return null;
1215
            }
1216
            return Check_value;
1217
        }
1218
        [OperationContract]
1219
        public List<CHECK_LIST> GetUserCheckList(string project_no, string user_id, string doc_no)
1220
        {
1221
            List<CHECK_LIST> list = new List<CHECK_LIST>();
1222
            try
1223
            {
1224
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1225
                {
1226
                    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();
1227
                }
1228
            }
1229
            catch (Exception)
1230
            {
1231
                return null;
1232
            }
1233
            return list;
1234
        }
1235
        [OperationContract]
1236
        public List<CHECK_LIST_HISTORY> GetCheckListHistory(string project_no, string _id)
1237
        {
1238
            List<CHECK_LIST_HISTORY> history = new List<CHECK_LIST_HISTORY>();
1239
            try
1240
            {
1241
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1242
                {
1243
                    history = Entity.CHECK_LIST_HISTORY.Where(data => data.CHECKLIST_ID == _id).ToList();
1244
                }
1245
            }
1246
            catch (Exception)
1247
            {
1248
                return null;
1249
            }
1250
            return history;
1251
        }
1252
        [OperationContract]
1253
        public CHECK_LIST_HISTORY GetCheckListHistoryFirstOrDefault(string project_no, string checklist_id, string rev)
1254
        {
1255
            CHECK_LIST_HISTORY Check_Item = new CHECK_LIST_HISTORY();
1256
            try
1257
            {
1258
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1259
                {   
1260
                    Check_Item = Entity.CHECK_LIST_HISTORY.Where(info => info.CHECKLIST_ID == checklist_id && info.REVISION == rev).FirstOrDefault();
1261
                }
1262
            }
1263
            catch (Exception)
1264
            {
1265
                return null;
1266
            }
1267
            return Check_Item;
1268
        }
1269
        [OperationContract]
1270
        public bool SavePageAngle(string project_no, List<DOCPAGE> _mldocpage)
1271
        {
1272
            try
1273
            {
1274
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1275
                {
1276
                    KCOMDataModel.DataModel.DOCPAGE _docpage = new KCOMDataModel.DataModel.DOCPAGE();
1277
                    _mldocpage.ForEach(data =>
1278
                    {
1279
                        _docpage = (from info in Entity.DOCPAGE
1280
                                    where info.ID == data.ID
1281
                                    select info).FirstOrDefault();
1282

    
1283
                        if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE)
1284
                        {
1285
                            _docpage.PAGE_ANGLE = data.PAGE_ANGLE;
1286
                        }
1287
                    });
1288

    
1289
                    Entity.SaveChanges();
1290
                }
1291
            }
1292
            catch (Exception)
1293
            {
1294
                return false;
1295
            }
1296
            return true;
1297
        }
1298

    
1299
        [OperationContract]
1300
        public MARKUP_INFO GetMarkupInfo(string project_no, string _id)
1301
        {
1302
            MARKUP_INFO markupInfo = new MARKUP_INFO();
1303

    
1304
            try
1305
            {
1306
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1307
                {
1308
                    markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1309
                }
1310
            }
1311
            catch (Exception)
1312
            {
1313
                return null;
1314
            }
1315
            return markupInfo;
1316
        }
1317

    
1318
        [OperationContract]
1319
        public List<string> GetMarkupDataListperPage(string project_no, string _markupinfoid, int _pageNo)
1320
        {
1321
            List<string> markupdata = new List<string>();
1322
            MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1323
            try
1324
            {
1325
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1326
                {
1327
                    markup_info_version = (from version in Entity.MARKUP_INFO_VERSION
1328
                                           where version.MARKUPINFO_ID == _markupinfoid
1329
                                           orderby version.CREATE_DATE descending
1330
                                           select version).First();
1331
                    markupdata = (from data in Entity.MARKUP_DATA
1332
                                  where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo
1333
                                  select data.DATA).ToList();
1334
                }
1335
            }
1336
            catch (Exception)
1337
            {
1338
                return null;
1339
            }
1340
            return markupdata;
1341
        }
1342

    
1343
        [OperationContract]
1344
        public bool AddMarkupInfo(string project_no, MARKUP_INFO value)
1345
        {
1346
            try
1347
            {
1348
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1349
                {
1350
                    Entity.MARKUP_INFO.AddObject(value);
1351
                    Entity.SaveChanges();
1352
                }
1353
            }
1354
            catch (Exception)
1355
            {
1356
                return false;
1357
            }
1358
            return true;
1359
        }
1360

    
1361
        [OperationContract]
1362
        public bool AddMarkupInfoVersion(string project_no, MARKUP_INFO_VERSION value)
1363
        {
1364
            try
1365
            {
1366
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1367
                {
1368
                    Entity.MARKUP_INFO_VERSION.AddObject(value);
1369
                    Entity.SaveChanges();
1370
                }
1371
            }
1372
            catch (Exception)
1373
            {
1374
                return false;
1375
            }
1376
            return true;
1377
        }
1378

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

    
1397
        [OperationContract]
1398
        public bool AvoidMarkupInfo(string project_no, string _doc_id)
1399
        {
1400
            try
1401
            {
1402
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1403
                {
1404
                    var item = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1405
                    item.AVOID_CONSOLIDATE = 1;
1406
                    Entity.SaveChanges();
1407
                }
1408
            }
1409
            catch (Exception)
1410
            {
1411
                return false;
1412
            }
1413
            return true;
1414
        }
1415

    
1416
        [OperationContract]
1417
        public bool SaveMarkupInfo(string project_no, string _id, MARKUP_INFO value)
1418
        {
1419
            try
1420
            {
1421
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1422
                {
1423
                    var item = Entity.MARKUP_INFO.Where(info => info.ID == _id).FirstOrDefault();
1424
                    item = value;                    
1425
                    Entity.SaveChanges();
1426
                }
1427
            }
1428
            catch (Exception)
1429
            {
1430
                return false;
1431
            }
1432
            return true;
1433
        }
1434
        [OperationContract]
1435
        public List<MARKUP_DATA> GetMarkupDataList(string project_no, string _versionid)
1436
        {
1437
            List<MARKUP_DATA> mlresult = new List<MARKUP_DATA>();
1438

    
1439
            try
1440
            {
1441
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1442
                {
1443
                    mlresult = Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == _versionid).ToList();
1444
                }
1445
            }
1446
            catch (Exception)
1447
            {
1448
                return null;
1449
            }
1450
            return mlresult;
1451
        }
1452

    
1453
        [OperationContract]
1454
        public bool Consolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
1455
        {
1456
            try
1457
            {
1458
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1459
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1460
                {
1461
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1462
                    if (markupInfo.CONSOLIDATE == 1)
1463
                    {
1464
                        markupInfo.AVOID_CONSOLIDATE = 1;
1465
                    }
1466

    
1467
                    foreach (MarkupInfoItem item in markupInfoItems)
1468
                    {
1469
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1470
                        {
1471
                            instanceDataSet.Add(d);
1472
                        });
1473
                    }
1474

    
1475
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1476
                    info.ID = shortGuid();
1477
                    info.CONSOLIDATE = 1;
1478
                    info.CREATE_TIME = DateTime.Now;
1479
                    info.DOCINFO_ID = _doc_id;
1480
                    info.UPDATE_TIME = DateTime.Now;
1481
                    info.USER_ID = _user_id;
1482
                    info.AVOID_CONSOLIDATE = 0;
1483

    
1484
                    Entity.MARKUP_INFO.AddObject(info);
1485
                    Entity.SaveChanges();
1486

    
1487

    
1488
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1489
                    {
1490
                        ID = shortGuid(),
1491
                        CREATE_DATE = DateTime.Now,
1492
                        MARKUP_INFO = info,
1493
                    };
1494
                    Entity.SaveChanges();
1495

    
1496
                    foreach (var item in instanceDataSet)
1497
                    {
1498
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1499
                        {
1500
                            ID = shortGuid(),
1501
                            DATA = item.DATA,
1502
                            DATA_TYPE = item.DATA_TYPE,
1503
                            PAGENUMBER = item.PAGENUMBER,
1504
                            MARKUP_INFO_VERSION = info2,
1505
                            SYMBOL_ID = item.SYMBOL_ID
1506
                        });
1507
                    }
1508
                    Entity.SaveChanges();
1509

    
1510

    
1511
                }
1512
            }
1513
            catch (Exception)
1514
            {
1515
                return false;
1516
            }
1517
            return true;
1518
        }
1519

    
1520
        [OperationContract]
1521
        public bool TeamConsolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
1522
        {
1523
            try
1524
            {
1525
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1526
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1527
                {
1528
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1529
                    if (markupInfo.PART_CONSOLIDATE == 1)
1530
                    {
1531
                        markupInfo.AVOID_CONSOLIDATE = 1;
1532
                    }
1533

    
1534
                    foreach (MarkupInfoItem item in markupInfoItems)
1535
                    {
1536
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1537
                        {
1538
                            instanceDataSet.Add(d);
1539
                        });
1540
                    }
1541

    
1542
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1543
                    info.ID = shortGuid();
1544
                    info.PART_CONSOLIDATE = 1;
1545
                    info.CREATE_TIME = DateTime.Now;
1546
                    info.DOCINFO_ID = _doc_id;
1547
                    info.UPDATE_TIME = DateTime.Now;
1548
                    info.USER_ID = _user_id;
1549
                    info.AVOID_CONSOLIDATE = 0;
1550

    
1551
                    Entity.MARKUP_INFO.AddObject(info);
1552
                    Entity.SaveChanges();
1553

    
1554

    
1555
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1556
                    {
1557
                        ID = shortGuid(),
1558
                        CREATE_DATE = DateTime.Now,
1559
                        MARKUP_INFO = info,
1560
                    };
1561
                    Entity.SaveChanges();
1562

    
1563
                    foreach (var item in instanceDataSet)
1564
                    {
1565
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1566
                        {
1567
                            ID = shortGuid(),
1568
                            DATA = item.DATA,
1569
                            DATA_TYPE = item.DATA_TYPE,
1570
                            PAGENUMBER = item.PAGENUMBER,
1571
                            MARKUP_INFO_VERSION = info2,
1572
                            SYMBOL_ID = item.SYMBOL_ID
1573
                        });
1574
                    }
1575
                    Entity.SaveChanges();
1576

    
1577

    
1578
                }
1579
            }
1580
            catch (Exception)
1581
            {
1582
                return false;
1583
            }
1584
            return true;
1585
        }
1586

    
1587
        [OperationContract]
1588
        [ServiceKnownType(typeof(MEMBER))]
1589
        public MEMBER GetMember(string project_no, string user_id)
1590
        {
1591
            MEMBER rstmember = new MEMBER();
1592
            try
1593
            {
1594
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1595
                {
1596
                    var tmp = (from member in Entity.MEMBER
1597
                                    where member.ID == user_id
1598
                                    select member).FirstOrDefault();
1599
                    rstmember.DEPARTMENT = tmp.DEPARTMENT;
1600
                    rstmember.ID = tmp.ID;
1601
                    rstmember.NAME = tmp.NAME;
1602
                }
1603
            }
1604
            catch (Exception)
1605
            {
1606
                return null;
1607
            }
1608
            return rstmember;
1609
        }
1610

    
1611
        [OperationContract]
1612
        public List<SYMBOL_PRIVATE> GetSymbolList(string user_id)
1613
        {
1614
            List<SYMBOL_PRIVATE> Custom_List = new List<SYMBOL_PRIVATE>();
1615
            try
1616
            {
1617
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1618
                {
1619
                    Custom_List = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == user_id).ToList();
1620
                }
1621
            }
1622
            catch (Exception)
1623
            {
1624
                return null;
1625
            }
1626
            return Custom_List;
1627
        }
1628
        [OperationContract]
1629
        public List<string> GetPublicSymbolDeptList()
1630
        {
1631
            List<string> Custom_List = new List<string>();
1632
            try
1633
            {
1634
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1635
                {
1636
                    Custom_List = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).ToList();
1637
                }
1638
            }
1639
            catch (Exception)
1640
            {
1641
                return null;
1642
            }
1643
            return Custom_List;
1644
        }
1645
        [OperationContract]
1646
        public List<SYMBOL_PUBLIC> GetPublicSymbolList(string dept)
1647
        {
1648
            List<SYMBOL_PUBLIC> Custom_List = new List<SYMBOL_PUBLIC>();
1649
            try
1650
            {
1651
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1652
                {
1653
                    if(!string.IsNullOrEmpty(dept))
1654
                    {
1655
                        Custom_List = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == dept).ToList();
1656
                    }
1657
                    else
1658
                    {
1659
                        Custom_List = Entity.SYMBOL_PUBLIC.ToList();
1660
                    }
1661
                    
1662
                }
1663
            }
1664
            catch (Exception)
1665
            {
1666
                return null;
1667
            }
1668
            return Custom_List;
1669
        }
1670

    
1671
        /// <summary>
1672
        /// 
1673
        /// </summary>
1674
        /// <param name="id">symbol id</param>
1675
        /// <param name="type"> 0 : PRIVATE, 1 : PUBLIC</param>
1676
        /// <returns></returns>
1677
        [OperationContract]
1678
        public string GetSymbolData(string id, int type)
1679
        {
1680
            string result;
1681
            try
1682
            {
1683
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1684
                {
1685
                    if(type == 0)
1686
                    {
1687
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA;
1688
                    }
1689
                    else
1690
                    {
1691
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA;
1692
                    }
1693
                }
1694
            }
1695
            catch (Exception)
1696
            {
1697
                return null;
1698
            }
1699
            return result;
1700
        }
1701

    
1702
        [OperationContract]
1703
        public string GetSignData(string project_no, string user_id)
1704
        {
1705
            string result = null;
1706
            try
1707
            {
1708
                var ModelWFConnectionString = ConnectStringBuilder.ProjectCIConnectString(project_no).ToString();
1709
                if (null != ModelWFConnectionString)
1710
                {
1711
                    using (CIEntities entity = new CIEntities(ModelWFConnectionString))
1712
                    {
1713
                        var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
1714
                        if (_sign.Count() > 0)
1715
                        {
1716
                            result = _sign.First().SIGN_STR;                            
1717
                        }
1718
                        else
1719
                        {
1720
                            return null;
1721
                        }
1722
                    }
1723
                }
1724
            }
1725
            catch (Exception)
1726
            {
1727
                return null;
1728
            }
1729
            return result;
1730
        }
1731

    
1732
        [OperationContract]        
1733
        public string GetProjectName(string project_no)
1734
        {
1735
            string result = null;
1736

    
1737
            try
1738
            {
1739
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
1740
                {
1741
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
1742
                }
1743
            }
1744
            catch (Exception)
1745
            {
1746
                return null;
1747
            }
1748
            return result;
1749
        }
1750

    
1751
        [OperationContract]
1752
        public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev)
1753
        {
1754
            List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>();
1755
            
1756
            try
1757
            {
1758
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1759
                {
1760
                    result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no
1761
                    && i.DOCUMENT_NO == doc_no
1762
                    && i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList();
1763
                }
1764
            }
1765
            catch (Exception)
1766
            {
1767
                return null;
1768
            }
1769
            return result;
1770
        }
1771

    
1772
        [OperationContract]
1773
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
1774
        {
1775
            DOCINFO docinfo = null;
1776

    
1777
            try
1778
            {
1779
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1780
                {
1781
                    docinfo = (from info in Entity.DOCINFO
1782
                              where info.DOCUMENT_ID == doc_id
1783
                              && info.PROJECT_NO == project_no
1784
                              select info).First();
1785
                }
1786
            }
1787
            catch (Exception)
1788
            {
1789
                return null;
1790
            }
1791
            return docinfo;
1792
        }
1793

    
1794
        [OperationContract]
1795
        public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList)
1796
        {
1797
            MarkupInfoItem _result = null;
1798
            List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>();
1799
            try
1800
            {
1801
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1802
                {
1803
                    var docitem = (from info in Entity.DOCINFO
1804
                               where info.DOCUMENT_ID == doc_id
1805
                               && info.PROJECT_NO == project_no
1806
                               select info).First();
1807

    
1808
                    foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO)
1809
                    {
1810
                        var member = (from mem in Entity.MEMBER
1811
                                     where mem.ID == markinfo.USER_ID
1812
                                     select mem).First();
1813
                        string displaycolor = null;
1814
                        try
1815
                        {
1816
                            displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor;
1817
                        }
1818
                        catch(Exception)
1819
                        {
1820
                            displaycolor = "#FFFFFF";
1821
                        }
1822
                        
1823
                        _result = new MarkupInfoItem
1824
                        {
1825
                            MarkupInfoID = markinfo.ID,
1826
                            Consolidate = markinfo.CONSOLIDATE,
1827
                            CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME,
1828
                            DisplayColor = displaycolor,
1829
                            UserID = markinfo.USER_ID,
1830
                            UserName = member.NAME,
1831
                            Depatment = member.DEPARTMENT,
1832
                        };
1833

    
1834
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
1835
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
1836

    
1837
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
1838
                        {
1839
                            MarkupItem markitem = new MarkupItem()
1840
                            {
1841
                                ID = markdata.ID,
1842
                                PageNumber = markdata.PAGENUMBER,
1843
                            };
1844
                            _result.MarkupList.Add(markitem);
1845
                        }
1846

    
1847
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
1848

    
1849
                        markupinfo.Add(_result);
1850
                    }
1851
                }
1852
            }
1853
            catch (Exception)
1854
            {
1855
                return null;
1856
            }
1857
            return markupinfo;
1858
        }
1859

    
1860
        [OperationContract]
1861
        public bool AddMessage(string project_no, TALK value)
1862
        {
1863
            try
1864
            {
1865
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1866
                {                    
1867
                    entity.TALK.AddObject(value);
1868
                    entity.SaveChanges();
1869
                }
1870
            }
1871
            catch (Exception)
1872
            {
1873
                return false;
1874
            }
1875
            return true;
1876
        }
1877

    
1878
        [OperationContract]
1879
        public List<TALK> GetMessage(string project_no, string doc_id)
1880
        {
1881
            List<TALK> result = new List<TALK>();
1882
            try
1883
            {
1884
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1885
                {
1886
                    result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList();                        
1887
                }
1888
            }
1889
            catch (Exception)
1890
            {
1891
                return result;
1892
            }
1893
            return result;
1894
        }
1895
    }
1896
}
클립보드 이미지 추가 (최대 크기: 500 MB)