프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ ac4f1e13

이력 | 보기 | 이력해설 | 다운로드 (121 KB)

1
using IFinalPDF;
2
using IKCOM;
3
using KCOMDataModel.Common;
4
using KCOMDataModel.DataModel;
5
using System;
6
using System.Collections.Generic;
7
using System.Collections.ObjectModel;
8
using System.Configuration;
9
using System.Linq;
10
using System.Net;
11
using System.Runtime.Remoting.Channels.Tcp;
12
using System.Runtime.Serialization;
13
using System.ServiceModel;
14
using System.ServiceModel.Activation;
15
using System.Text;
16
using System.Web.Services;
17
using System.Windows;
18
using System.Xml;
19

    
20
namespace KCOM_API
21
{
22
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ServiceDeepView" in code, svc and config file together.
23
    // 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.
24
    [ServiceContract(Namespace = "")]
25
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
26
    public partial class ServiceDeepView : System.Web.Services.WebService
27
    {
28
        /// <summary>
29
        /// Client Version 과 Server Version 을 비교하여 Server Version 이 최신이면 다운로드 url 리턴.
30
        /// </summary>
31
        /// <param name="is64BitProcess">64bit = true, 32bit = false</param>
32
        /// <param name="markusVer">client version</param>
33
        /// <returns></returns>
34
        [OperationContract]
35
        public string GetVersionData(bool is64BitProcess, string markusVer)
36
        {
37
            string url = null;
38

    
39
            try
40
            {
41
                Version client_version = new Version(markusVer);
42
                
43
                //DB에서 version 정보와 다운로드 url 을 Select
44
                PROPERTIES dbvalue = null;
45
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
46
                using (KCOMEntities uc = new KCOMEntities(sConnString))
47
                {
48
                    string wherestr = string.Empty;
49
                    if (is64BitProcess)
50
                    {
51
                        wherestr = "Update_x64";                        
52
                    }
53
                    else
54
                    {
55
                        wherestr = "Update_x84";                        
56
                    }
57
                    dbvalue = uc.PROPERTIES.Where(data => data.TYPE == wherestr).FirstOrDefault();
58
                }
59

    
60
                //서버 버전이 최신이면 0보다 큰값 리턴
61
                Version server_version = new Version(dbvalue.PROPERTY);
62
                int result = server_version.CompareTo(client_version);  
63
                if (result > 0)
64
                {
65
                    url = dbvalue.VALUE;
66
                }
67
            }
68
            catch (Exception)
69
            {
70
                url = null;
71
            }
72
            return url;
73
        }
74
    
75

    
76
        [OperationContract]
77
        public KCOM_SystemInfo GetSystemData()
78
        {
79
            try
80
            {
81
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
82
                using (KCOMEntities uc = new KCOMEntities(sConnString))
83
                {
84
                    var SystemInfoSet = uc.PROPERTIES.Where(data => data.TYPE == "SystemInfo").ToList();
85

    
86
                    KCOM_SystemInfo sysInfo = new KCOM_SystemInfo();
87

    
88
                    var url = SystemInfoSet.Where(data => data.PROPERTY == "Url").FirstOrDefault();
89
                    if (url != null)
90
                    {
91
                        sysInfo.HostName = url.VALUE;
92
                    }
93

    
94
                    url = SystemInfoSet.Where(data => data.PROPERTY == "Port").FirstOrDefault();
95
                    if (url != null)
96
                    {
97
                        sysInfo.HostPort = url.VALUE;
98
                    }
99

    
100
                    url = uc.PROPERTIES.Where(data => data.TYPE == "STAMP").FirstOrDefault();
101
                    if(url != null)
102
                    {
103
                        sysInfo.STAMP = url.VALUE;
104
                    }
105
                    return sysInfo;
106
                }
107
            }
108
            catch (Exception ex)
109
            {
110
            }
111
            return null;
112
            GC.Collect(2);
113
        }
114

    
115
        private static string shortGuid()
116
        {
117
            byte[] bytes = new byte[16];
118
            using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create())
119
            {
120
                provider.GetBytes(bytes);
121
            }
122

    
123
            var guid = new Guid(bytes);
124

    
125
            return Convert.ToBase64String(guid.ToByteArray())
126
                .Substring(0, 10)
127
                .Replace("/", "")
128
                .Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x");
129
        }
130

    
131

    
132
        [OperationContract]
133
        public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
134
        {
135
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
136
            using (KCOMEntities dc = new KCOMEntities(sConnString))
137
            {
138

    
139
                int flagString = Convert.ToInt32(FAVORITE_FLAG.Personal);
140
                List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
141
                //dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
142
                //    flagString).ToList().ForEach(data => favoriteListSet.Add(data));
143

    
144

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

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

    
149
                //favoriteListSet = favoriteListSet.Distinct().ToList();
150
                return favoriteListSet;
151
            }
152
        }
153
        [OperationContract]
154
        public bool EditFavoriteVP(string prjNo, string userID, string docID, int state, string description)
155
        {
156
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
157
            using (KCOMEntities dc = new KCOMEntities(sConnString))
158
            {
159
                //List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
160
                //    && data.PAGE_NO == SavePageNo && data.CREATE_TIME == createTime).ToList();
161
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
162
                    && data.ID == docID).ToList();
163
                try
164
                {
165

    
166
                    if (favoriteSet.Count > 0)
167
                    {
168
                        var FavoriteVP_Instance = favoriteSet.First();
169

    
170
                        FavoriteVP_Instance.DESCRIPTION = description;
171
                        FavoriteVP_Instance.FLAG = state;
172

    
173
                        dc.SaveChanges();
174

    
175
                        return true;
176
                    }
177
                    else
178
                    {
179
                        return false;
180
                    }
181
                }
182
                catch (Exception)
183
                {
184
                    return false;
185
                }
186
            }
187
        }
188

    
189
        [OperationContract]
190
        public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string docID)
191
        {
192
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
193
            using (KCOMEntities dc = new KCOMEntities(sConnString))
194
            {
195

    
196
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
197
                    && data.ID == docID).ToList();
198

    
199
                try
200
                {
201
                    if (favoriteSet.Count > 0)
202
                    {
203
                        favoriteSet.ForEach(data => dc.FAVORITE_DOC.DeleteObject(data));
204
                        dc.SaveChanges();
205
                        return true;
206
                    }
207
                    else
208
                    {
209
                        return false;
210
                    }
211
                }
212
                catch (Exception)
213
                {
214
                    return false;
215
                }
216
            }
217
        }
218

    
219
        /// <summary>
220
        /// 두 페이지를 비교하여 결과를 리턴한다
221
        /// </summary>
222
        /// <param name="projectNo"></param>
223
        /// <param name="originDocItem_ID"></param>
224
        /// <param name="targetDocItem_ID"></param>
225
        /// <param name="originPageNo"></param>
226
        /// <param name="targetPageNo"></param>
227
        /// <param name="isInternalAddress"></param>
228
        /// <returns></returns>
229
        [OperationContract]
230
        public List<Rect> GetCompareRect(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress)
231
        {
232
      
233
            List<Rect> result = new List<Rect>();
234

    
235
            string originFile = "";
236
            string targetFile = "";
237

    
238
            string sOriginFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID);
239
            string sTagetFolder = targetDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(targetDocItem_ID) / 100).ToString() : (targetDocItem_ID.Length >= 5 ? targetDocItem_ID.Substring(0, 5) : targetDocItem_ID);
240

    
241
            if (Boolean.Parse(isInternalAddress))
242
            {
243
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sOriginFolder, originDocItem_ID, originPageNo);
244
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sTagetFolder, targetDocItem_ID, targetPageNo);
245
            }
246
            else
247
            {
248
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  originDocItem_ID, originPageNo);
249
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  targetDocItem_ID, targetPageNo);
250
            }
251

    
252
            using (Markus.Image.ImageComparer compareLib = new Markus.Image.ImageComparer())
253
            {
254
                result = compareLib.CompareReturnRects(originFile, targetFile, new System.Drawing.Size(20, 20));
255
            }
256

    
257
            return result;
258
        }
259

    
260
        //[OperationContract]
261
        //public List<Rect> GetCompareRect_old(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress)
262
        //{
263
        //    System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
264

    
265
        //    stopwatch.Start();
266

    
267
        //    string originFile = "";
268
        //    string targetFile = "";
269

    
270
        //    string sFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID);
271
        //    if (Boolean.Parse(isInternalAddress))
272
        //    {
273
        //        originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, originDocItem_ID, originPageNo);
274
        //        targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, targetDocItem_ID, targetPageNo);
275
        //    }
276
        //    else
277
        //    {
278
        //        originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo);
279
        //        targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo);
280
        //    }
281

    
282
        //    CompareLib compareLib = new CompareLib();
283

    
284
        //    var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
285
        //    var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
286

    
287
        //    string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
288
        //    var result = compareLib.GetBoundBoxInImage(outPutFile);
289

    
290
        //    System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks));
291

    
292
        //    return result;
293
        //}
294

    
295

    
296
        #region Final PDF
297
        private string _ChanID = null;
298
        TcpChannel chan = null;
299
        [OperationContract]
300
        public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUserID)
301
        {
302
            #region 임시보관
303
            #endregion
304
            FinalPDFResult _result = new FinalPDFResult();
305
            RemFinalPDFObject remObj = null;
306
            try
307
            {
308
                string _finalID = shortGuid();
309
                int _DocTotalPages = -1;
310
                string docItemId;
311

    
312
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
313
                using (CIEntities _ci = new CIEntities(sCIConnString))
314
                {
315
                    var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
316

    
317
                    if (_doc.Count() > 0)
318
                    {
319
                        _DocTotalPages = _doc.First().PAGE_COUNT;
320
                        docItemId = _doc.First().DOCUMENT_ID;
321
                    }
322
                    else
323
                    {
324
                        _result.Status = FinalStatus.Error;
325
                        _result.Exception = "페이지 정보를 가져올 수 없습니다.";
326
                        return _result;
327
                    }
328
                }
329
                if (_DocTotalPages > 0)
330
                {
331
                    FINAL_PDF fm = new FINAL_PDF()
332
                    {
333
                        ID = _finalID,
334
                        PROJECT_NO = ProjectNo,
335
                        DOCINFO_ID = DocInfoID,
336
                        DOCUMENT_ID = docItemId,
337
                        MARKUPINFO_ID = MarkupInfoID,
338
                        CREATE_USER_ID = CreateUserID,
339
                        TOTAL_PAGE = _DocTotalPages,
340
                        CREATE_DATETIME = DateTime.Now,
341
                        STATUS = (int)IFinalPDF.FinalStatus.Insert
342
                    };
343

    
344
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
345
                    using (KCOMEntities _entity = new KCOMEntities(sConnString))
346
                    {
347
                        _entity.AddToFINAL_PDF(fm);
348
                        _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
349
                    };
350

    
351
                    System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
352
                    if (_ch == null)
353
                    {
354
                        chan = new TcpChannel();
355
                        _ChanID = chan.ChannelName;
356
                        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
357
                        // Create an instance of the remote object
358

    
359
                        using (KCOMEntities ec = new KCOMEntities(sConnString))
360
                        {
361

    
362
                            //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
363
                            //                          "tcp://localhost:9092/remFinalPDF");
364
                            remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
365
                                                      //"tcp://192.168.0.67:9092/remFinalPDF");
366
                                                      "tcp://localhost:9092/remFinalPDF");
367
                        }
368

    
369
                        //"tcp://localhost:8080/remFinalPDF");
370

    
371
                        _result = remObj.SetFinalPDF(ProjectNo, _finalID);
372
                        _result.FinalID = _finalID;
373
                        _result.Status = FinalStatus.Success;
374

    
375
                        //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
376
                        //fa.MakeFinalPDF(fm);
377
                    }
378
                    else
379
                    {
380
                        _ChanID = _ch.ChannelName;
381
                    }
382
                }
383
            }
384
            catch (Exception ex)
385
            {
386
                _result.Status = FinalStatus.Error;
387

    
388
                if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
389
                    _result.Exception = "Final Server Not Connection";
390
                else _result.Exception = ex.ToString();
391
            }
392
            finally
393
            {
394
                remObj = null;
395
                if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
396
                    System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
397

    
398
                GC.Collect(2);
399
            }
400
            return _result;
401
        }
402
        #endregion
403

    
404

    
405
        [OperationContract]
406
        public bool GetConversionState(KCOM_BasicParam param)
407
        {
408
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
409
            using (CIEntities entity = new CIEntities(sCIConnString))
410
            {
411
                var doc = entity.DOCINFO.Where(data => data.DOCUMENT_ID == param.documentID).FirstOrDefault();
412
                if (doc != null)
413
                {
414
                    var count = doc.DOCPAGE.Where(data => data.DOCINFO_ID == doc.ID).Count();
415
                    if (doc.PAGE_COUNT == count)  //페이지 수가 일치하는지
416
                    {
417
                        return true;
418
                    }
419
                    else //페이지 수가 일치하지 않는 경우
420
                    {
421
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
422
                        KCOMEntities entity_kcom = new KCOMEntities(sConnString);
423
                        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();
424

    
425
                        if (lst != null || lst.Count >= 1)
426
                        {
427
                            //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_PAGECOUNT"), param.documentID, param.projectNo);
428
                            //이메일 클라이언트를 구현해야함
429
                        }
430
                        return false;
431
                    }
432
                }
433
                else
434
                {
435
                    //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_CONVERTFAILED"), param.documentID, param.projectNo);
436
                    //이메일 클라이언트를 구현해야함
437
                    return false;
438
                }
439
            }
440
        }
441

    
442
        [OperationContract]
443
        public List<VPRevision> GetVPRevisionHistory(string ProjectNo, string vpNo, string DocumentId)
444
        {
445
            List<VPRevision> _result = new List<VPRevision>();
446
            try
447
            {
448
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
449
                using (CIEntities entity = new CIEntities(sCIConnString))
450
                {
451
                    var _vpList = (from docitem in entity.DOCUMENT_ITEM
452
                                   where docitem.DOCUMENT_NO == vpNo
453
                                   select new VPRevision
454
                                   {
455
                                       RevNo = docitem.REVISION,
456
                                       GroupNo = docitem.GROUP_NO,
457
                                       FROM_VENDOR = docitem.ORIGINAL_FILE,
458
                                       DOCUMENT_ID = docitem.DOCUMENT_ID,
459
                                       TO_VENDOR = docitem.RESULT_FILE,
460
                                       RESULT = docitem.RESULT,
461
                                       DocNo = docitem.DOCUMENT_NO,
462
                                       //EnsembleLink = docitem.ENSEMBLEINFO_URL,
463
                                       //IsSyncPossible = docitem.DOCUMENT_ID == DocumentId ? false : entity.DOCINFO.Where(d => d.DOCUMENT_ID == docitem.DOCUMENT_ID).ToList().Count > 0 ? true : false
464
                                   });
465
                    _result = _vpList.ToList();
466
                    foreach (var vp in _result)
467
                    {
468
                        if (entity.DOCINFO.Where(d => d.DOCUMENT_ID == vp.DOCUMENT_ID).ToList().Count > 0)
469
                            vp.IsSyncPossible = true;
470
                        else
471
                            vp.IsSyncPossible = false;
472
                    }
473

    
474
                    //_result = _result.OrderByDescending(r => UInt64.Parse(System.Text.RegularExpressions.Regex.Replace(r.GroupNo, @"\D", ""))).ToList();
475
                    _result =  _result.OrderByDescending(r => r.GroupNo).ToList();
476
                }
477
            }
478
            catch (Exception ex)
479
            {
480

    
481
                throw ex;
482
            }
483
            finally
484
            {
485
                GC.Collect(2);
486
            }
487
            return _result;
488
        }
489

    
490
        [OperationContract]
491
        public VPRevision GetVPRevisionFirstOrDefault(string ProjectNo, string DocumentId)
492
        {
493
            VPRevision _result = null;
494
            try
495
            {
496
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
497
                using (CIEntities entity = new CIEntities(sCIConnString))
498
                {
499
                    _result = (from docitem in entity.DOCUMENT_ITEM
500
                     where docitem.DOCUMENT_ID == DocumentId
501
                     select new VPRevision
502
                     {
503
                         RevNo = docitem.REVISION,
504
                         GroupNo = docitem.GROUP_NO,
505
                         FROM_VENDOR = docitem.ORIGINAL_FILE,
506
                         DOCUMENT_ID = docitem.DOCUMENT_ID,
507
                         TO_VENDOR = docitem.RESULT_FILE,
508
                         RESULT = docitem.RESULT
509
                     }).FirstOrDefault();
510
                }
511
            }
512
            catch (Exception)
513
            {
514
                throw;
515
            }
516
            finally
517
            {
518
                GC.Collect(2);
519
            }
520
            return _result;
521
        }
522

    
523
        [OperationContract]
524
        public DOCINFO GetDocInfo(KCOM_BasicParam param)
525
        {
526
            DOCINFO _result = null;
527
            try
528
            {
529
                // 차후 아래의 코드로 변경
530
                //using (CI_Entities ModelDeeview = new CI_Entities(DaelimCiConnectionString.ToString()))
531
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
532
                CIEntities ModelDeeview = new CIEntities(sCIConnString);
533

    
534
                var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID && doc.PROJECT_NO == param.projectNo);
535
                if (docinfo.Count() > 0)
536
                {
537
                    _result = docinfo.First();
538
                    _result.MARKUP_INFO.Clear();
539

    
540
                }
541
                return _result;
542

    
543
            }
544
            catch (Exception ex)
545
            {
546
                System.Diagnostics.Trace.WriteLine("GetDocInfo Error : " + ex);
547
            }
548
            finally
549
            {
550
                GC.Collect(2);
551
            }
552
            return null;
553
        }
554

    
555
        [OperationContract]
556
        public bool GetCheckSystemAdmin(string UserID)
557
        {
558
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
559
            using (KCOMEntities uc = new KCOMEntities(sConnString))
560
            {
561
                var user = uc.PROPERTIES.Where(data => data.TYPE == "Administrator" && data.PROPERTY.Contains(UserID)).FirstOrDefault();
562
                if (user != null)
563
                {
564
                    return true;
565
                }
566
                else
567
                {
568
                    return false;
569
                }
570
            }
571
            GC.Collect(2);
572
        }
573

    
574
        [OperationContract]
575
        public DOCUMENT_ITEM GetDocumentItemInfo(KCOM_BasicParam param)
576
        {
577
            ///param : prjNo, documentId, userId
578
            DOCUMENT_ITEM _result = null;
579

    
580
            try
581
            {
582
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
583
                CIEntities entity = new CIEntities(sCIConnString);
584
               
585
                var _items = entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == param.documentID);
586

    
587
                if (_items.Count() > 0)
588
                {
589
                    _result = _items.First();
590

    
591
                    return _result;
592
                }
593
                //else
594
                //{
595
                //    Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_DOCUMENTNOTFOUND"), param.documentID, param.projectNo);
596
                //}
597
            }
598
            catch (Exception ex)
599
            {
600
                System.Diagnostics.Trace.WriteLine("GetDocumentItemInfo Error : " + ex);
601

    
602
                new FaultException("GetDocumentItemInfo Error - "  + ex.ToString());
603
                //throw new FaultException(ex.ToString());
604
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
605
            }
606

    
607
            return _result;
608
        }
609
        /// <summary>
610
        /// DOCUMENT_ITEM Table 의 ID 로 Item 을 Select
611
        /// </summary>
612
        /// 대림의 경우 Interface ID(Document 의 ID) 를 parameter 로 전달
613
        /// 넘어온 ID를 통해 document id 를 확인하는 과정이 필요
614
        /// <param name="ensemble_id"></param>
615
        /// <returns></returns>
616
        [OperationContract]
617
        public string GetDocItemID(string ensemble_id)
618
        {
619
            ///param : prjNo, documentId, userId
620
            string _result = string.Empty;
621

    
622
            try
623
            {
624
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
625
                CIEntities entity = new CIEntities(sCIConnString);
626

    
627
                var _items = entity.DOCUMENT_ITEM.Where(data => data.ID == ensemble_id).FirstOrDefault();
628
                if(_items != null)
629
                    _result = _items.DOCUMENT_ID;
630
            }
631
            catch (Exception ex)
632
            {
633
                //System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex);
634
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
635
            }
636

    
637
            return _result;
638
        }
639
        public string UserGO(MARKUP_INFO item)
640
        {
641
            if (item != null)
642
            {
643
                return item.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID;
644
            }
645
            return null;
646
        }
647
        
648
        [OperationContract]
649
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
650
        {
651
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
652
            try
653
            {
654
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
655
                using (CIEntities entity = new CIEntities(sCIConnString))
656
                {
657
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
658

    
659
                    var markupList = from markup in markupListData
660
                                     orderby markup.CREATE_TIME descending
661
                                     select new MarkupInfoItem
662
                                     {
663
                                         MarkupInfoID = markup.ID,
664
                                         UserID = markup.USER_ID,
665
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
666
                                         CreateTime = markup.CREATE_TIME,
667
                                         Consolidate = markup.CONSOLIDATE,
668
                                         Description = markup.DESCRIPTION,
669
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
670
                                         PartConsolidate = markup.PART_CONSOLIDATE,
671
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
672
                                     };
673

    
674
                    if (markupList.Count() > 0)
675
                    {
676
                        _result = markupList.ToList();
677
                    }
678

    
679
                    _result.ForEach(r =>
680
                    {
681

    
682
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
683
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
684
                                        orderby markupData.PAGENUMBER
685
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList();
686
                    });
687

    
688
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
689
                    Random random = new Random();
690

    
691
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
692
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
693
                    {
694
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
695
                                             where property.TYPE == "DisplayColor"
696
                                             select property).ToList();
697
                    }
698

    
699
                    bool IsProjectNoPass = Properties.Settings.Default.IsProjectNoPass;
700

    
701
                    foreach (var item in _result)
702
                    {
703
                        string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
704

    
705
                        System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery 
706
                                      = entity.CreateQuery<System.Data.Common.DbDataRecord>(query,new System.Data.Objects.ObjectParameter("userId",item.UserID));
707
                        
708
                        if (memberQuery.Count() > 0)
709
                        {
710
                            string userName = memberQuery.First()["NAME"]?.ToString().Trim();
711
                            string depatment = memberQuery.First()["DEPARTMENT"]?.ToString().Trim();
712

    
713
                            item.UserName = userName;
714
                            item.Depatment = depatment;
715
                        }
716

    
717
                        if (_ColorsProperties.Count > 0)
718
                        {
719
                            int colorIdx = random.Next(0, _ColorsProperties.Count() - 1);
720
                            #region 부서별로 색상을 지정하고자 할때
721
                            /// 일단 의견을 들어보자구!
722
                            #endregion
723
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
724
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
725
                        }
726
                        else
727
                        {
728
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
729
                        }
730
                    }
731
                }
732
            }
733
            catch (Exception EX)
734
            {
735
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
736
                return _result;
737
            }
738
            finally
739
            {
740
                GC.Collect(2);
741
            }
742

    
743
            return _result;
744
        }
745

    
746
        [OperationContract]
747
        public List<MarkupInfoItem> GetSyncMarkupInfoItems(string ProjectNo, string DocInfoId, string currentUser)
748
        {
749
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
750
            try
751
            {
752
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
753
                using (CIEntities entity = new CIEntities(sCIConnString))
754
                {
755
                    var docItem = entity.DOCINFO.Where(data => data.DOCUMENT_ID == DocInfoId).FirstOrDefault();
756
                    if (docItem == null)
757
                    {
758
                        return null;
759
                    }
760
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == docItem.ID).ToList();
761

    
762
                    var markupList = from markup in markupListData
763
                                     where markup.USER_ID == currentUser || markup.CONSOLIDATE == 1
764
                                     orderby markup.CREATE_TIME descending
765
                                     select new MarkupInfoItem
766
                                     {
767
                                         MarkupInfoID = markup.ID,
768
                                         UserID = markup.USER_ID,
769
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
770
                                         CreateTime = markup.CREATE_TIME,
771
                                         Consolidate = markup.CONSOLIDATE,
772
                                         Description = markup.DESCRIPTION,
773
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
774
                                         PartConsolidate = markup.PART_CONSOLIDATE,
775
                                     };
776

    
777

    
778

    
779
                    if (markupList.Count() > 0)
780
                    {
781
                        _result = markupList.ToList();
782
                    }
783

    
784

    
785

    
786
                    _result.ForEach(r =>
787
                    {
788

    
789
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
790
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
791
                                        orderby markupData.PAGENUMBER
792
                                        select new MarkupItem
793
                                        {
794
                                            ID = markupData.ID,
795
                                            PageNumber = markupData.PAGENUMBER,
796
                                            Data = markupData.DATA,
797
                                            Data_Type = markupData.DATA_TYPE,
798
                                            Symbol_ID = markupData.SYMBOL_ID
799
                                        }).ToList();
800
                    });
801

    
802
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
803
                    Random random = new Random();
804

    
805
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
806
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
807
                    {
808
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
809
                                             where property.TYPE == "DisplayColor"
810
                                             select property).ToList();
811
                    }
812

    
813
                    foreach (var item in _result)
814
                    {
815
                        string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
816

    
817
                        System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery
818
                                      = entity.CreateQuery<System.Data.Common.DbDataRecord>(query, new System.Data.Objects.ObjectParameter("userId", item.UserID));
819

    
820
                        if (memberQuery.Count() > 0)
821
                        {
822

    
823
                            string userName = memberQuery.First()["NAME"]?.ToString().Trim();
824
                            string depatment = memberQuery.First()["DEPARTMENT"]?.ToString().Trim();
825

    
826
                            item.UserName = userName;
827
                            item.Depatment = depatment;
828
                        }
829

    
830
                        if (_ColorsProperties.Count > 0)
831
                        {
832
                            int colorIdx = random.Next(1, _ColorsProperties.Count());
833
                            #region 부서별로 색상을 지정하고자 할때
834
                            /// 일단 의견을 들어보자구!
835
                            #endregion
836
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
837
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
838
                            //item.DisplayColor = "#FF" + _Colors.First();
839
                            //_Colors.Remove(_Colors.First());
840
                        }
841
                        else
842
                        {
843
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
844
                        }
845
                    }
846
                }
847
            }
848
            catch (Exception EX)
849
            {
850
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
851
                return _result;
852
            }
853
            finally
854
            {
855
                GC.Collect(2);
856
            }
857

    
858
            return _result;
859
        }
860

    
861

    
862
        //[OperationContract]
863
        //[ServiceKnownType(typeof(MEMBER))]
864
        //public List<MEMBER> GetUserData(string ProjectNo, string UserID)
865
        //{
866
        //    List<MEMBER> _result = new List<MEMBER>();
867

    
868
        //    using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
869
        //    {
870
        //        var _UserList = from member in entity.MEMBER
871
        //                        where member.ID == UserID
872
        //                        select member;
873
        //        _result = _UserList.ToList();
874
        //    }
875
        //    //GC.Collect(2);
876
        //    return _result;
877
        //}
878

    
879
        [OperationContract]
880
        [ServiceKnownType(typeof(MEMBER))]
881
        public List<MEMBER> GetUserData(string ProjectNo, string UserID)
882
        {
883
            List<MEMBER> _result = new List<MEMBER>();
884

    
885
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
886
            using (CIEntities entity = new CIEntities(sCIConnString))
887
            {
888
                var _UserList = from member in entity.MEMBER
889
                                where member.ID == UserID
890
                                select member;
891
                _result = _UserList.ToList();
892
            }
893
            //GC.Collect(2);
894
            return _result;
895
        }
896

    
897

    
898
        [OperationContract]
899
        public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정
900
        {
901
            List<string> _result = new List<string>();
902

    
903
            try
904
            {
905
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
906
                KCOMEntities entity = new KCOMEntities(sConnString);
907
                var YourEnginner = (from dept in entity.PROPERTIES
908
                                    where dept.TYPE == "DeptName" && UserDept.Contains(dept.VALUE)
909
                                    select dept).FirstOrDefault();
910

    
911
                if (YourEnginner != null)
912
                {
913
                    _result = (from dept in entity.PROPERTIES
914
                               where dept.PROPERTY == YourEnginner.PROPERTY
915
                               select dept.VALUE).ToList();
916
                    return _result;
917
                }
918
                else
919
                {
920
                    return null;
921
                }
922
            }
923
            catch (Exception ex)
924
            {
925
                System.Diagnostics.Debug.WriteLine(ex.Message);
926
            }
927
            finally
928
            {
929
                GC.Collect(2);
930
            }
931
            return _result;
932
        }
933

    
934
        [OperationContract]
935
        public bool DeleteMarkup(string ProjectNo, string MarkupInfoID)
936
        {
937
            bool _result = false;
938
            try
939
            {
940
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
941
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(sCIConnString))
942
                {
943

    
944
                    MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault();
945

    
946
                    if (instance == null)
947
                    {
948
                        return false;
949
                    }
950
                    MARKUP_INFO_VERSION version = instance.MARKUP_INFO_VERSION.FirstOrDefault();
951

    
952

    
953
                    version.MARKUP_DATA.ToList().ForEach(data =>
954
                    {
955
                        Entity.MARKUP_DATA.DeleteObject(data);
956
                        Entity.SaveChanges();
957
                    });
958

    
959
                    Entity.MARKUP_INFO_VERSION.DeleteObject(version);
960
                    Entity.SaveChanges();
961

    
962
                    Entity.MARKUP_INFO.DeleteObject(instance);
963
                    Entity.SaveChanges();
964

    
965
                }
966
                _result = true;
967
            }
968
            catch (Exception ex)
969
            {
970
                System.Diagnostics.Trace.WriteLine(ex, "SaveMarkup");
971
            }
972
            finally
973
            {
974
                GC.Collect(2);
975
            }
976
            return _result;
977
        }
978

    
979
        #region Favorite
980
        [OperationContract]
981
        public bool SetFavoriteVP(string prjNo, string userID, string groupNo, string docNo, string rev, int SavePageNo, string documentItemID, string VPDescription, IKCOM.FAVORITE_FLAG flag)
982
        {
983
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
984
            using (KCOMEntities entity = new KCOMEntities(sConnString))
985
            {
986
                try
987
                {
988
                    entity.FAVORITE_DOC.AddObject(new FAVORITE_DOC
989
                    {
990
                        ID = shortGuid(),
991
                        PROJECT_NO = prjNo,
992
                        DOCUMENT_ID = documentItemID,
993
                        GROUP_NO = groupNo,
994
                        DOCUMENT_NO = docNo,
995
                        MEMBER_USER_ID = userID,
996
                        DESCRIPTION = VPDescription,
997
                        CREATE_TIME = DateTime.Now,
998
                        REVISION = rev,
999
                        FLAG = (int)flag,
1000
                        PAGE_NO = SavePageNo,
1001
                    });
1002
                    entity.SaveChanges();
1003
                }
1004
                catch (Exception)
1005
                {
1006
                    return false;
1007
                }
1008

    
1009
                return true;
1010
            }
1011
        }
1012

    
1013
        //[OperationContract]
1014
        //public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
1015
        //{
1016
        //    using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1017
        //    {
1018

    
1019
        //        int flagString = Convert.ToInt32(IKCOM.FAVORITE_FLAG.Personal);                
1020
        //        List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
1021
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
1022
        //            flagString).ToList().ForEach(data => favoriteListSet.Add(data));
1023
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data));
1024
        //        favoriteListSet = favoriteListSet.Distinct().ToList();
1025
        //        return favoriteListSet;
1026
        //    }
1027
        //}
1028
        //[OperationContract]
1029
        //public bool EditFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime, int state, string description)
1030
        //{
1031
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1032
        //    {
1033
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1034
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1035

    
1036
        //        try
1037
        //        {
1038

    
1039

    
1040
        //            if (favoriteSet.Count > 0)
1041
        //            {
1042
        //                var FavoriteVP_Instance = favoriteSet.First();
1043

    
1044
        //                FavoriteVP_Instance.Description = description;
1045
        //                FavoriteVP_Instance.Flag = state;
1046

    
1047
        //                dc.SaveChanges();
1048

    
1049
        //                return true;
1050
        //            }
1051
        //            else
1052
        //            {
1053
        //                return false;
1054
        //            }
1055
        //        }
1056
        //        catch (Exception)
1057
        //        {
1058
        //            return false;
1059
        //        }
1060
        //    }
1061
        //}
1062
        //[OperationContract]
1063
        //public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime)
1064
        //{
1065

    
1066
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1067
        //    {
1068
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1069
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1070

    
1071
        //        try
1072
        //        {
1073

    
1074

    
1075
        //            if (favoriteSet.Count > 0)
1076
        //            {
1077
        //                favoriteSet.ForEach(data => dc.FavoriteVP.DeleteObject(data));
1078
        //                dc.SaveChanges();
1079
        //                return true;
1080
        //            }
1081
        //            else
1082
        //            {
1083
        //                return false;
1084
        //            }
1085
        //        }
1086
        //        catch (Exception)
1087
        //        {
1088
        //            return false;
1089
        //        }
1090
        //    }
1091
        //}
1092
        #endregion
1093

    
1094
        [OperationContract]
1095
        public bool SaveMarkupData(MarkupInfoItem UserState,string project_no,string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1096
        {
1097
            
1098
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1099
            using (CIEntities Entity = new CIEntities(sCIConnString))
1100
            {     
1101
                #region Docinfo 정보 가져오기
1102

    
1103
                string docinfoid_ = (from info in Entity.DOCINFO
1104
                                     where info.DOCUMENT_ID == doc_id
1105
                                     && info.PROJECT_NO == project_no
1106
                                     select info.ID
1107
                                     ).First().ToString();
1108
                #endregion
1109

    
1110
                #region Markup_Info 저장
1111

    
1112
                MARKUP_INFO markup_info = new MARKUP_INFO();
1113
                try
1114
                {
1115
                    markup_info = (from info in Entity.MARKUP_INFO
1116
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
1117
                                   select info).FirstOrDefault();
1118
                }
1119
                catch (Exception)
1120
                {
1121
                    markup_info = null;
1122
                }
1123

    
1124
                //markup_info가 없을 경우 생성
1125
                if (markup_info == null)
1126
                {
1127
                    //MarkupInfo 저장
1128
                    markup_info = new MARKUP_INFO
1129
                    {
1130
                        ID = UserState.MarkupInfoID,
1131
                        DOCINFO_ID = docinfoid_,
1132
                        USER_ID = user_id,
1133
                        CREATE_TIME = DateTime.Now,
1134
                        CONSOLIDATE = UserState.Consolidate,
1135
                        AVOID_CONSOLIDATE = UserState.AvoidConsolidate,
1136
                        PART_CONSOLIDATE = UserState.PartConsolidate,
1137
                        DESCRIPTION = UserState.Description,
1138
                        UPDATE_TIME = DateTime.Now
1139
                    };
1140
                    Entity.MARKUP_INFO.AddObject(markup_info);
1141
                }
1142
                //markup_info가 있을 경우 업데이트
1143
                else
1144
                {
1145
                    markup_info.UPDATE_TIME = DateTime.Now;
1146
                }
1147
                Entity.SaveChanges();
1148
                #endregion
1149

    
1150
                #region Markup_Info_Version 저장
1151

    
1152
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1153

    
1154
                try
1155
                {
1156
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1157
                                           where info.MARKUPINFO_ID == markup_info.ID
1158
                                           select info).FirstOrDefault();
1159
                }
1160
                catch (Exception)
1161
                {
1162
                    markup_info_version = null;
1163
                }
1164

    
1165
                //markup_info_version 없을 경우 생성
1166
                if (markup_info_version == null)
1167
                {
1168
                    //MarkupInfo_version 저장
1169
                    markup_info_version = new MARKUP_INFO_VERSION()
1170
                    {
1171
                        ID = UserState.MarkupVersionID,
1172
                        MARKUPINFO_ID = markup_info.ID,
1173
                        CREATE_DATE = DateTime.Now
1174
                    };
1175
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1176
                    Entity.SaveChanges();
1177
                }
1178
                #endregion
1179

    
1180
                
1181
                Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1182
                {
1183
                    Entity.MARKUP_DATA.DeleteObject(item);
1184
                });
1185
                Entity.SaveChanges();
1186

    
1187
                try
1188
                {
1189
                    mlmarkup_data.ForEach(value =>
1190
                    {
1191
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1192
                        {
1193
                            ID = value.ID,
1194
                            DATA = value.DATA,
1195
                            DATA_TYPE = value.DATA_TYPE,
1196
                            PAGENUMBER = value.PAGENUMBER,
1197
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1198
                            SYMBOL_ID = value.SYMBOL_ID,
1199
                            //GROUP_ID = value.GROUP_ID
1200
                        });
1201
                    });
1202
                    Entity.SaveChanges();
1203
                }
1204
                catch (Exception)
1205
                {
1206
                    return false;
1207
                }
1208
            }
1209
            return true;
1210
        }
1211

    
1212
        [OperationContract]
1213
        public bool SavePageMarkupData(MarkupInfoItem UserState,int PageNo, string project_no, string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1214
        {
1215

    
1216
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1217
            using (CIEntities Entity = new CIEntities(sCIConnString))
1218
            {
1219
                #region Docinfo 정보 가져오기
1220

    
1221
                string docinfoid_ = (from info in Entity.DOCINFO
1222
                                     where info.DOCUMENT_ID == doc_id
1223
                                     && info.PROJECT_NO == project_no
1224
                                     select info.ID
1225
                                     ).First().ToString();
1226
                #endregion
1227

    
1228
                #region Markup_Info 저장
1229

    
1230
                MARKUP_INFO markup_info = new MARKUP_INFO();
1231
                try
1232
                {
1233
                    markup_info = (from info in Entity.MARKUP_INFO
1234
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
1235
                                   select info).FirstOrDefault();
1236
                }
1237
                catch (Exception)
1238
                {
1239
                    markup_info = null;
1240
                }
1241

    
1242
                //markup_info가 없을 경우 생성
1243
                if (markup_info == null)
1244
                {
1245
                    //MarkupInfo 저장
1246
                    markup_info = new MARKUP_INFO
1247
                    {
1248
                        ID = UserState.MarkupInfoID,
1249
                        DOCINFO_ID = docinfoid_,
1250
                        USER_ID = user_id,
1251
                        CREATE_TIME = DateTime.Now,
1252
                        CONSOLIDATE = UserState.Consolidate,
1253
                        AVOID_CONSOLIDATE = UserState.AvoidConsolidate,
1254
                        PART_CONSOLIDATE = UserState.PartConsolidate,
1255
                        DESCRIPTION = UserState.Description,
1256
                        UPDATE_TIME = DateTime.Now
1257
                    };
1258
                    Entity.MARKUP_INFO.AddObject(markup_info);
1259
                }
1260
                //markup_info가 있을 경우 업데이트
1261
                else
1262
                {
1263
                    markup_info.UPDATE_TIME = DateTime.Now;
1264
                }
1265
                Entity.SaveChanges();
1266
                #endregion
1267

    
1268
                #region Markup_Info_Version 저장
1269

    
1270
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1271

    
1272
                try
1273
                {
1274
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1275
                                           where info.MARKUPINFO_ID == markup_info.ID
1276
                                           select info).FirstOrDefault();
1277
                }
1278
                catch (Exception)
1279
                {
1280
                    markup_info_version = null;
1281
                }
1282

    
1283
                //markup_info_version 없을 경우 생성
1284
                if (markup_info_version == null)
1285
                {
1286
                    //MarkupInfo_version 저장
1287
                    markup_info_version = new MARKUP_INFO_VERSION()
1288
                    {
1289
                        ID = UserState.MarkupVersionID,
1290
                        MARKUPINFO_ID = markup_info.ID,
1291
                        CREATE_DATE = DateTime.Now
1292
                    };
1293
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1294
                    Entity.SaveChanges();
1295
                }
1296
                #endregion
1297

    
1298

    
1299
                Entity.MARKUP_DATA.Where(data =>  data.PAGENUMBER == PageNo && data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1300
                {
1301
                    Entity.MARKUP_DATA.DeleteObject(item);
1302
                });
1303
                Entity.SaveChanges();
1304

    
1305
                try
1306
                {
1307
                    mlmarkup_data.ForEach(value =>
1308
                    {
1309
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1310
                        {
1311
                            ID = value.ID,
1312
                            DATA = value.DATA,
1313
                            DATA_TYPE = value.DATA_TYPE,
1314
                            PAGENUMBER = value.PAGENUMBER,
1315
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1316
                            SYMBOL_ID = value.SYMBOL_ID,
1317
                            //GROUP_ID = value.GROUP_ID
1318
                        });
1319
                    });
1320
                    Entity.SaveChanges();
1321
                }
1322
                catch (Exception)
1323
                {
1324
                    return false;
1325
                }
1326
            }
1327
            return true;
1328
        }
1329

    
1330
        //[OperationContract]
1331
        //public long AddMarkupDataGroup(MARKUP_DATA_GROUP mARKUP_DATA_GROUP, string ProjectNo)
1332
        //{
1333
        //    try
1334
        //    {
1335
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1336
        //        {
1337
        //            Entity.AddToMARKUP_DATA_GROUP(mARKUP_DATA_GROUP);
1338
        //            //MARKUP_DATA_GROUP tt = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == id).FirstOrDefault();
1339
        //            Entity.SaveChanges();
1340

    
1341
        //            return Entity.MARKUP_DATA_GROUP.ToList().LastOrDefault().ID;
1342
        //        }
1343
        //    }
1344
        //    catch (Exception)
1345
        //    {
1346
        //        return 0;
1347
        //    }
1348
        //}
1349
        //[OperationContract]
1350
        //public bool UpdateMarkupDataGroup(long Group_ID, string ProjectNo)
1351
        //{
1352
        //    try
1353
        //    {
1354
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1355
        //        {
1356
        //            var UpdateItem = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == Group_ID).FirstOrDefault();
1357
        //            UpdateItem.STATE = 1;
1358
        //            Entity.SaveChanges();
1359
        //        }
1360
        //    }
1361
        //    catch (Exception)
1362
        //    {
1363
        //        return false;
1364
        //    }
1365
        //    return true;
1366
        //}
1367
        [OperationContract]
1368
        public bool UpdateMarkupData(string CommentID, long Group_ID, string ProjectNo)
1369
        {
1370
            try
1371
            {
1372
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1373
                using (CIEntities Entity = new CIEntities(sCIConnString))
1374
                {
1375
                    var UpdateItem = Entity.MARKUP_DATA.Where(info => info.ID == CommentID).FirstOrDefault();
1376
                    //UpdateItem.GROUP_ID = Group_ID;
1377
                    Entity.SaveChanges();
1378
                }
1379
            }
1380
            catch (Exception)
1381
            {
1382
                return false;
1383
            }
1384
            return true;
1385
        }
1386

    
1387
        [OperationContract]
1388
        public bool SaveSymbol(SYMBOL_PRIVATE symbol_private)
1389
        {
1390
            try
1391
            {
1392
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1393
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
1394
                {
1395
                    uc.AddToSYMBOL_PRIVATE(symbol_private);
1396
                    uc.SaveChanges();
1397
                }
1398
            }
1399
            catch(Exception)
1400
            {
1401
                return false;
1402
            }
1403
            return true;
1404
        }
1405
        [OperationContract]
1406
        public bool AddPublicSymbol(SYMBOL_PUBLIC symbol)
1407
        {
1408
            try
1409
            {
1410
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1411
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
1412
                {
1413
                    uc.AddToSYMBOL_PUBLIC(symbol);
1414
                    uc.SaveChanges();
1415
                }
1416
            }
1417
            catch (Exception)
1418
            {
1419
                return false;
1420
            }
1421
            return true;
1422
        }
1423
        [OperationContract]
1424
        public bool DeleteSymbol(string symbol_id, int type)
1425
        {
1426
            try
1427
            {
1428
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1429
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
1430
                {
1431
                    if (type == 0)
1432
                    {
1433
                        string delItem_ID = symbol_id;
1434
                        var delitem = Entity.SYMBOL_PRIVATE.Where(data => data.ID == delItem_ID).FirstOrDefault();
1435
                        Entity.SYMBOL_PRIVATE.DeleteObject(delitem);
1436
                        Entity.SaveChanges();
1437
                    }
1438
                    else
1439
                    {
1440
                        string delItem_ID = symbol_id;
1441
                        var delitem = Entity.SYMBOL_PUBLIC.Where(data => data.ID == delItem_ID).FirstOrDefault();
1442
                        Entity.SYMBOL_PUBLIC.DeleteObject(delitem);
1443
                        Entity.SaveChanges();
1444
                    }
1445
                }
1446
            }
1447
            catch(Exception)
1448
            {
1449
                return false;
1450
            }
1451
            return true;
1452
        }
1453

    
1454
        [OperationContract]
1455
        public bool RenameSymbol(string symbol_id, string name, int type)
1456
        {
1457
            try
1458
            {
1459
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1460
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
1461
                {
1462
                    if (type == 0)
1463
                    {
1464
                        var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == symbol_id).FirstOrDefault();
1465
                        UpdateItem.NAME = name;
1466
                        Entity.SaveChanges();
1467
                    }
1468
                    else
1469
                    {
1470
                        var UpdateItem = Entity.SYMBOL_PUBLIC.Where(info => info.ID == symbol_id).FirstOrDefault();
1471
                        UpdateItem.NAME = name;
1472
                        Entity.SaveChanges();
1473
                    }
1474
                }
1475
            }
1476
            catch (Exception)
1477
            {
1478
                return false;
1479
            }
1480
            return true;
1481
        }
1482

    
1483
        [OperationContract]
1484
        public bool AddCheckListHistory(string project_no, CHECK_LIST_HISTORY Check_History)
1485
        {
1486
            try
1487
            {
1488
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1489
                using (CIEntities Entity = new CIEntities(sCIConnString))
1490
                {
1491
                    Entity.CHECK_LIST_HISTORY.AddObject(Check_History);
1492
                    Entity.SaveChanges();  
1493
                }
1494
            }
1495
            catch (Exception)
1496
            {
1497
                return false;
1498
            }
1499
            return true;
1500
        }
1501
        [OperationContract]
1502
        public bool SaveCheckListHistory(string project_no, string rev, CHECK_LIST_HISTORY Check_History)
1503
        {
1504
            try
1505
            {
1506
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1507
                using (CIEntities Entity = new CIEntities(sCIConnString))
1508
                {
1509
                    var item = Entity.CHECK_LIST_HISTORY.Where(info => info.REVISION == rev).FirstOrDefault();
1510
                    item = Check_History;
1511
                    Entity.SaveChanges();
1512
                }
1513
            }
1514
            catch (Exception)
1515
            {
1516
                return false;
1517
            }
1518
            return true;
1519
        }
1520
        [OperationContract]
1521
        public bool SaveCheckList(string project_no, string _id, CHECK_LIST Check_value)
1522
        {
1523
            try
1524
            {
1525
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1526
                using (CIEntities Entity = new CIEntities(sCIConnString))
1527
                {
1528
                    var item = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1529
                    item.TODOLIST = Check_value.TODOLIST;
1530
                    item.REMARK = Check_value.REMARK;
1531
                    item.STATUS = Check_value.STATUS;
1532
                    item.VENDOR = Check_value.VENDOR;
1533
                    item.REPLY = Check_value.REPLY;
1534
                    item.IMAGE_URL = Check_value.IMAGE_URL;
1535
                    item.IMAGE_ANCHOR = Check_value.IMAGE_ANCHOR;
1536
                    item.UPDATE_TIME = Check_value.UPDATE_TIME;
1537
                    if(Check_value.STATUS == "False")
1538
                    {
1539
                        item.STATUS_DESC_OPEN = Check_value.STATUS_DESC_OPEN;
1540
                    }
1541
                    else
1542
                    {
1543
                        item.STATUS_DESC_CLOSE = Check_value.STATUS_DESC_CLOSE;
1544
                    }                     
1545
                    Entity.SaveChanges();
1546
                }
1547
            }
1548
            catch (Exception)
1549
            {
1550
                return false;
1551
            }
1552
            return true;
1553
        }
1554
        [OperationContract]
1555
        public bool AddCheckList(string project_no, CHECK_LIST Check_value)
1556
        {
1557
            try
1558
            {
1559
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1560
                using (CIEntities Entity = new CIEntities(sCIConnString))
1561
                {
1562
                    Entity.CHECK_LIST.AddObject(Check_value);
1563
                    Entity.SaveChanges();
1564
                }
1565
            }
1566
            catch (Exception)
1567
            {
1568
                return false;
1569
            }
1570
            return true;
1571
        }
1572

    
1573
        [OperationContract]
1574
        public CHECK_LIST GetCheckList(string project_no, string _id)
1575
        {
1576
            CHECK_LIST Check_value = new CHECK_LIST();
1577
            try
1578
            {
1579
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1580
                using (CIEntities Entity = new CIEntities(sCIConnString))
1581
                {
1582
                    Check_value = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1583
                }
1584
            }
1585
            catch (Exception)
1586
            {
1587
                return null;
1588
            }
1589
            return Check_value;
1590
        }
1591
        [OperationContract]
1592
        public List<CHECK_LIST> GetUserCheckList(string project_no, string user_id, string doc_no)
1593
        {
1594
            List<CHECK_LIST> list = new List<CHECK_LIST>();
1595
            try
1596
            {
1597
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1598
                using (CIEntities Entity = new CIEntities(sCIConnString))
1599
                {
1600
                    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();
1601
                }
1602
            }
1603
            catch (Exception)
1604
            {
1605
                return null;
1606
            }
1607
            return list;
1608
        }
1609
        [OperationContract]
1610
        public List<CHECK_LIST_HISTORY> GetCheckListHistory(string project_no, string _id)
1611
        {
1612
            List<CHECK_LIST_HISTORY> history = new List<CHECK_LIST_HISTORY>();
1613
            try
1614
            {
1615
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1616
                using (CIEntities Entity = new CIEntities(sCIConnString))
1617
                {
1618
                    history = Entity.CHECK_LIST_HISTORY.Where(data => data.CHECKLIST_ID == _id).ToList();
1619
                }
1620
            }
1621
            catch (Exception)
1622
            {
1623
                return null;
1624
            }
1625
            return history;
1626
        }
1627
        [OperationContract]
1628
        public CHECK_LIST_HISTORY GetCheckListHistoryFirstOrDefault(string project_no, string checklist_id, string rev)
1629
        {
1630
            CHECK_LIST_HISTORY Check_Item = new CHECK_LIST_HISTORY();
1631
            try
1632
            {
1633
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1634
                using (CIEntities Entity = new CIEntities(sCIConnString))
1635
                {   
1636
                    Check_Item = Entity.CHECK_LIST_HISTORY.Where(info => info.CHECKLIST_ID == checklist_id && info.REVISION == rev).FirstOrDefault();
1637
                }
1638
            }
1639
            catch (Exception)
1640
            {
1641
                return null;
1642
            }
1643
            return Check_Item;
1644
        }
1645
        [OperationContract]
1646
        public bool SavePageAngle(string project_no, List<DOCPAGE> _mldocpage)
1647
        {
1648
            try
1649
            {
1650
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1651
                using (CIEntities Entity = new CIEntities(sCIConnString))
1652
                {
1653
                    KCOMDataModel.DataModel.DOCPAGE _docpage = new KCOMDataModel.DataModel.DOCPAGE();
1654
                    _mldocpage.ForEach(data =>
1655
                    {
1656
                        _docpage = (from info in Entity.DOCPAGE
1657
                                    where info.ID == data.ID
1658
                                    select info).FirstOrDefault();
1659

    
1660
                        if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE)
1661
                        {
1662
                            _docpage.PAGE_ANGLE = data.PAGE_ANGLE;
1663
                        }
1664
                    });
1665

    
1666
                    Entity.SaveChanges();
1667
                }
1668
            }
1669
            catch (Exception)
1670
            {
1671
                return false;
1672
            }
1673
            return true;
1674
        }
1675

    
1676
        [OperationContract]
1677
        public MARKUP_INFO GetMarkupInfo(string project_no, string _id)
1678
        {
1679
            MARKUP_INFO markupInfo = new MARKUP_INFO();
1680

    
1681
            try
1682
            {
1683
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1684
                using (CIEntities Entity = new CIEntities(sCIConnString))
1685
                {
1686
                    markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1687
                }
1688
            }
1689
            catch (Exception)
1690
            {
1691
                return null;
1692
            }
1693
            return markupInfo;
1694
        }
1695

    
1696
        [OperationContract]
1697
        public List<string> GetMarkupDataListperPage(string project_no, string _markupinfoid, int _pageNo)
1698
        {
1699
            List<string> markupdata = new List<string>();
1700
            MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1701
            try
1702
            {
1703
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1704
                using (CIEntities Entity = new CIEntities(sCIConnString))
1705
                {
1706
                    markup_info_version = (from version in Entity.MARKUP_INFO_VERSION
1707
                                           where version.MARKUPINFO_ID == _markupinfoid
1708
                                           orderby version.CREATE_DATE descending
1709
                                           select version).First();
1710
                    markupdata = (from data in Entity.MARKUP_DATA
1711
                                  where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo
1712
                                  select data.DATA).ToList();
1713
                }
1714
            }
1715
            catch (Exception)
1716
            {
1717
                return null;
1718
            }
1719
            return markupdata;
1720
        }
1721

    
1722
        [OperationContract]
1723
        public bool AddMarkupInfo(string project_no, MARKUP_INFO value)
1724
        {
1725
            try
1726
            {
1727
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1728
                using (CIEntities Entity = new CIEntities(sCIConnString))
1729
                {
1730
                    Entity.MARKUP_INFO.AddObject(value);
1731
                    Entity.SaveChanges();
1732
                }
1733
            }
1734
            catch (Exception)
1735
            {
1736
                return false;
1737
            }
1738
            return true;
1739
        }
1740

    
1741
        [OperationContract]
1742
        public bool AddMarkupInfoVersion(string project_no, MARKUP_INFO_VERSION value)
1743
        {
1744
            try
1745
            {
1746
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1747
                using (CIEntities Entity = new CIEntities(sCIConnString))
1748
                {
1749
                    Entity.MARKUP_INFO_VERSION.AddObject(value);
1750
                    Entity.SaveChanges();
1751
                }
1752
            }
1753
            catch (Exception)
1754
            {
1755
                return false;
1756
            }
1757
            return true;
1758
        }
1759

    
1760
        [OperationContract]
1761
        public bool AddMarkupData(string project_no, MARKUP_DATA value)
1762
        {
1763
            try
1764
            {
1765
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1766
                using (CIEntities Entity = new CIEntities(sCIConnString))
1767
                {
1768
                    Entity.MARKUP_DATA.AddObject(value);
1769
                    Entity.SaveChanges();
1770
                }
1771
            }
1772
            catch (Exception)
1773
            {
1774
                return false;
1775
            }
1776
            return true;
1777
        }
1778

    
1779
        [OperationContract]
1780
        public bool AvoidMarkupInfo(string project_no, string _doc_id)
1781
        {
1782
            try
1783
            {
1784
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1785
                using (CIEntities Entity = new CIEntities(sCIConnString))
1786
                {
1787
                    var item = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1788
                    item.AVOID_CONSOLIDATE = 1;
1789
                    Entity.SaveChanges();
1790
                }
1791
            }
1792
            catch (Exception)
1793
            {
1794
                return false;
1795
            }
1796
            return true;
1797
        }
1798

    
1799
        [OperationContract]
1800
        public bool SaveMarkupInfo(string project_no, string _id, MARKUP_INFO value)
1801
        {
1802
            try
1803
            {
1804
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1805
                using (CIEntities Entity = new CIEntities(sCIConnString))
1806
                {
1807
                    var item = Entity.MARKUP_INFO.Where(info => info.ID == _id).FirstOrDefault();
1808
                    item = value;                    
1809
                    Entity.SaveChanges();
1810
                }
1811
            }
1812
            catch (Exception)
1813
            {
1814
                return false;
1815
            }
1816
            return true;
1817
        }
1818
        [OperationContract]
1819
        public List<MARKUP_DATA> GetMarkupDataList(string project_no, string _versionid)
1820
        {
1821
            List<MARKUP_DATA> mlresult = new List<MARKUP_DATA>();
1822

    
1823
            try
1824
            {
1825
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1826
                using (CIEntities Entity = new CIEntities(sCIConnString))
1827
                {
1828
                    mlresult = Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == _versionid).ToList();
1829
                }
1830
            }
1831
            catch (Exception)
1832
            {
1833
                return null;
1834
            }
1835
            return mlresult;
1836
        }
1837

    
1838
        [OperationContract]
1839
        public bool Consolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
1840
        {
1841
            try
1842
            {
1843
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1844
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1845
                using (CIEntities Entity = new CIEntities(sCIConnString))
1846
                {
1847
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.CONSOLIDATE == 1).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1848
                    if (markupInfo != null)
1849
                    {
1850
                        markupInfo.AVOID_CONSOLIDATE = 1;
1851
                    }
1852

    
1853
                    foreach (MarkupInfoItem item in markupInfoItems)
1854
                    {
1855
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1856
                        {
1857
                            instanceDataSet.Add(d);
1858
                        });
1859
                    }
1860

    
1861
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1862
                    info.ID = shortGuid();
1863
                    info.CONSOLIDATE = 1;
1864
                    info.CREATE_TIME = DateTime.Now;
1865
                    info.DOCINFO_ID = _doc_id;
1866
                    info.UPDATE_TIME = DateTime.Now;
1867
                    info.USER_ID = _user_id;
1868
                    info.AVOID_CONSOLIDATE = 0;
1869

    
1870
                    Entity.MARKUP_INFO.AddObject(info);
1871
                    Entity.SaveChanges();
1872

    
1873

    
1874
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1875
                    {
1876
                        ID = shortGuid(),
1877
                        CREATE_DATE = DateTime.Now,
1878
                        MARKUP_INFO = info,
1879
                    };
1880
                    Entity.SaveChanges();
1881

    
1882
                    foreach (var item in instanceDataSet)
1883
                    {
1884
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1885
                        {
1886
                            ID = shortGuid(),
1887
                            DATA = item.DATA,
1888
                            DATA_TYPE = item.DATA_TYPE,
1889
                            PAGENUMBER = item.PAGENUMBER,
1890
                            MARKUP_INFO_VERSION = info2,
1891
                            SYMBOL_ID = item.SYMBOL_ID,
1892
                            //GROUP_ID = item.GROUP_ID
1893
                        });
1894
                    }
1895
                    Entity.SaveChanges();
1896

    
1897

    
1898
                }
1899
            }
1900
            catch (Exception)
1901
            {
1902
                return false;
1903
            }
1904
            return true;
1905
        }
1906

    
1907

    
1908
        [OperationContract]
1909
        public FinalPDFResult ConsolidateMergedPDF(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems, string ProjectNo, string DocInfoID, string CreateUserID)
1910
        {
1911
            bool consolidate = false;
1912
            try
1913
            {
1914
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1915
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1916
                using (CIEntities Entity = new CIEntities(sCIConnString))
1917
                {
1918
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1919
                    if (markupInfo.CONSOLIDATE == 1)
1920
                    {
1921
                        markupInfo.AVOID_CONSOLIDATE = 1;
1922
                    }
1923

    
1924
                    foreach (MarkupInfoItem item in markupInfoItems)
1925
                    {
1926
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1927
                        {
1928
                            instanceDataSet.Add(d);
1929
                        });
1930
                    }
1931

    
1932
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1933
                    info.ID = shortGuid();
1934
                    info.CONSOLIDATE = 1;
1935
                    info.CREATE_TIME = DateTime.Now;
1936
                    info.DOCINFO_ID = _doc_id;
1937
                    info.UPDATE_TIME = DateTime.Now;
1938
                    info.USER_ID = _user_id;
1939
                    info.AVOID_CONSOLIDATE = 0;
1940

    
1941
                    Entity.MARKUP_INFO.AddObject(info);
1942
                    Entity.SaveChanges();
1943

    
1944

    
1945
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1946
                    {
1947
                        ID = shortGuid(),
1948
                        CREATE_DATE = DateTime.Now,
1949
                        MARKUP_INFO = info,
1950
                    };
1951
                    Entity.SaveChanges();
1952

    
1953
                    foreach (var item in instanceDataSet)
1954
                    {
1955
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1956
                        {
1957
                            ID = shortGuid(),
1958
                            DATA = item.DATA,
1959
                            DATA_TYPE = item.DATA_TYPE,
1960
                            PAGENUMBER = item.PAGENUMBER,
1961
                            MARKUP_INFO_VERSION = info2,
1962
                            SYMBOL_ID = item.SYMBOL_ID,
1963
                            //GROUP_ID = item.GROUP_ID
1964
                        });
1965
                    }
1966
                    Entity.SaveChanges();
1967

    
1968

    
1969
                }
1970
                consolidate = true;
1971
            }
1972
            catch (Exception)
1973
            {
1974
                consolidate = false;
1975
            }
1976
            FinalPDFResult _result = new FinalPDFResult();
1977
            if (consolidate == true)
1978
            {
1979
                RemFinalPDFObject remObj = null;
1980
                try
1981
                {
1982
                    string _finalID = shortGuid();
1983
                    int _DocTotalPages = -1;
1984
                    string docItemId;
1985

    
1986
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1987
                    using (CIEntities _ci = new CIEntities(sCIConnString))
1988
                    {
1989
                        var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
1990

    
1991
                        if (_doc.Count() > 0)
1992
                        {
1993
                            _DocTotalPages = _doc.First().PAGE_COUNT;
1994
                            docItemId = _doc.First().DOCUMENT_ID;
1995
                        }
1996
                        else
1997
                        {
1998
                            _result.Status = FinalStatus.Error;
1999
                            _result.Exception = "페이지 정보를 가져올 수 없습니다.";
2000
                            return _result;
2001
                        }
2002
                    }
2003

    
2004
                    var Items = GetMarkupInfoItems(ProjectNo, DocInfoID);
2005
                    if (_DocTotalPages > 0)
2006
                    {
2007
                        var item2 = Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
2008
                        FINAL_PDF fm = new FINAL_PDF()
2009
                        {
2010
                            ID = _finalID,
2011
                            PROJECT_NO = ProjectNo,
2012
                            DOCINFO_ID = DocInfoID,
2013
                            DOCUMENT_ID = docItemId,
2014
                            MARKUPINFO_ID = item2.MarkupInfoID,
2015
                            CREATE_USER_ID = CreateUserID,
2016
                            TOTAL_PAGE = _DocTotalPages,
2017
                            CREATE_DATETIME = DateTime.Now,
2018
                            STATUS = (int)IFinalPDF.FinalStatus.Insert
2019
                        };
2020

    
2021
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2022
                        using (KCOMEntities _entity = new KCOMEntities(sConnString))
2023
                        {
2024
                            _entity.AddToFINAL_PDF(fm);
2025
                            _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
2026
                        };
2027

    
2028
                        System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
2029
                        if (_ch == null)
2030
                        {
2031
                            chan = new TcpChannel();
2032
                            _ChanID = chan.ChannelName;
2033
                            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
2034
                            // Create an instance of the remote object
2035

    
2036
                            using (KCOMEntities ec = new KCOMEntities(sConnString))
2037
                            {
2038

    
2039
                                //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2040
                                //                          "tcp://localhost:9092/remFinalPDF");
2041
                                remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2042
                                                          //"tcp://192.168.0.67:9092/remFinalPDF");
2043
                                                          "tcp://192.168.0.67:9092/remFinalPDF");
2044
                            }
2045

    
2046
                            //"tcp://localhost:8080/remFinalPDF");
2047

    
2048
                            _result = remObj.SetFinalPDF(ProjectNo, _finalID);
2049
                            _result.FinalID = _finalID;
2050
                            _result.Status = FinalStatus.Success;
2051

    
2052
                            //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
2053
                            //fa.MakeFinalPDF(fm);
2054
                        }
2055
                        else
2056
                        {
2057
                            _ChanID = _ch.ChannelName;
2058
                        }
2059
                    }
2060
                }
2061
                catch (Exception ex)
2062
                {
2063
                    _result.Status = FinalStatus.Error;
2064

    
2065
                    if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
2066
                        _result.Exception = "Final Server Not Connection";
2067
                }
2068
                finally
2069
                {
2070
                    remObj = null;
2071
                    if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
2072
                        System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
2073

    
2074
                    GC.Collect(2);
2075
                }
2076
            }
2077
            return _result;
2078
        }
2079
        [OperationContract]
2080
        public bool TeamConsolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
2081
        {
2082
            try
2083
            {
2084
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
2085
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2086
                using (CIEntities Entity = new CIEntities(sCIConnString))
2087
                {
2088
                    string user_dept = Entity.MEMBER.Where(m => m.ID == _user_id).FirstOrDefault().DEPARTMENT;
2089
                    var markupInfos = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id
2090
                    && entity.PART_CONSOLIDATE == 1
2091
                    ).OrderByDescending(j => j.CREATE_TIME).ToList();
2092
                    foreach (var markupinfo in markupInfos)
2093
                    {
2094
                        string markupdept = Entity.MEMBER.Where(m => m.ID == markupinfo.USER_ID).FirstOrDefault().DEPARTMENT;
2095
                        if (user_dept == markupdept)
2096
                        {
2097
                            markupinfo.AVOID_CONSOLIDATE = 1;
2098
                        }
2099
                    }
2100

    
2101
                    foreach (MarkupInfoItem item in markupInfoItems)
2102
                    {
2103
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2104
                        {
2105
                            instanceDataSet.Add(d);
2106
                        });
2107
                    }
2108

    
2109
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2110
                    info.ID = shortGuid();
2111
                    info.PART_CONSOLIDATE = 1;
2112
                    info.CREATE_TIME = DateTime.Now;
2113
                    info.DOCINFO_ID = _doc_id;
2114
                    info.UPDATE_TIME = DateTime.Now;
2115
                    info.USER_ID = _user_id;
2116
                    info.AVOID_CONSOLIDATE = 0;
2117

    
2118
                    Entity.MARKUP_INFO.AddObject(info);
2119
                    Entity.SaveChanges();
2120

    
2121

    
2122
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2123
                    {
2124
                        ID = shortGuid(),
2125
                        CREATE_DATE = DateTime.Now,
2126
                        MARKUP_INFO = info,
2127
                    };
2128
                    Entity.SaveChanges();
2129

    
2130
                    foreach (var item in instanceDataSet)
2131
                    {
2132
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2133
                        {
2134
                            ID = shortGuid(),
2135
                            DATA = item.DATA,
2136
                            DATA_TYPE = item.DATA_TYPE,
2137
                            PAGENUMBER = item.PAGENUMBER,
2138
                            MARKUP_INFO_VERSION = info2,
2139
                            SYMBOL_ID = item.SYMBOL_ID,
2140
                            //GROUP_ID = item.GROUP_ID
2141
                        });
2142
                    }
2143
                    Entity.SaveChanges();
2144

    
2145

    
2146
                }
2147
            }
2148
            catch (Exception)
2149
            {
2150
                return false;
2151
            }
2152
            return true;
2153
        }
2154

    
2155
        [OperationContract]
2156
        [ServiceKnownType(typeof(MEMBER))]
2157
        public MEMBER GetMember(string project_no, string user_id)
2158
        {
2159
            MEMBER rstmember = null;
2160
            try
2161
            {
2162
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2163
                using (CIEntities Entity = new CIEntities(sCIConnString))
2164
                {
2165
                    string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
2166

    
2167
                    var param = new[] { new System.Data.Objects.ObjectParameter("userId", user_id) };
2168

    
2169
                    System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery
2170
                                  = Entity.CreateQuery<System.Data.Common.DbDataRecord>(query, param);
2171

    
2172
                    if (memberQuery.Count() > 0)
2173
                    {
2174
                        string userName = memberQuery.First()["NAME"]?.ToString().Trim();
2175
                        string ID = memberQuery.First()["ID"]?.ToString().Trim();
2176
                        string depatment = memberQuery.First()["DEPARTMENT"]?.ToString().Trim();
2177

    
2178
                        rstmember.NAME = userName;
2179
                        rstmember.ID = ID;
2180
                        rstmember.DEPARTMENT = depatment;
2181
                    }
2182
                }
2183
            }
2184
            catch (Exception ex)
2185
            {
2186
                return null;
2187
            }
2188
            return rstmember;
2189
        }
2190

    
2191
        [WebMethod]
2192
        [OperationContract]
2193
        public List<SYMBOL_PRIVATE> GetSymbolList(string user_id)
2194
        {
2195
            List<SYMBOL_PRIVATE> Custom_List = new List<SYMBOL_PRIVATE>();
2196
            try
2197
            {
2198
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2199
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2200
                {
2201
                    Custom_List = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == user_id).ToList();
2202
                }
2203
            }
2204
            catch (Exception ex)
2205
            {
2206
                return null;
2207
            }
2208
            return Custom_List;
2209
        }
2210
        [OperationContract]
2211
        public List<string> GetPublicSymbolDeptList()
2212
        {
2213
            List<string> Custom_List = new List<string>();
2214
            try
2215
            {
2216
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2217
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2218
                {
2219
                    Custom_List = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).Distinct().ToList();
2220
                }
2221
            }
2222
            catch (Exception)
2223
            {
2224
                return null;
2225
            }
2226
            return Custom_List;
2227
        }
2228
        [OperationContract]
2229
        public List<SYMBOL_PUBLIC> GetPublicSymbolList(string dept)
2230
        {
2231
            List<SYMBOL_PUBLIC> Custom_List = new List<SYMBOL_PUBLIC>();
2232
            try
2233
            {
2234
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2235
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2236
                {
2237
                    if(!string.IsNullOrEmpty(dept))
2238
                    {
2239
                        Custom_List = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == dept).ToList();
2240
                    }
2241
                    else
2242
                    {
2243
                        Custom_List = Entity.SYMBOL_PUBLIC.ToList();
2244
                    }
2245
                    
2246
                }
2247
            }
2248
            catch (Exception)
2249
            {
2250
                return null;
2251
            }
2252
            return Custom_List;
2253
        }
2254

    
2255
        /// <summary>
2256
        /// 
2257
        /// </summary>
2258
        /// <param name="id">symbol id</param>
2259
        /// <param name="type"> 0 : PRIVATE, 1 : PUBLIC</param>
2260
        /// <returns></returns>
2261
        [OperationContract]
2262
        public string GetSymbolData(string id, int type)
2263
        {
2264
            string result;
2265
            try
2266
            {
2267
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2268
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2269
                {
2270
                    if(type == 0)
2271
                    {
2272
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA;
2273
                    }
2274
                    else
2275
                    {
2276
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA;
2277
                    }
2278
                }
2279
            }
2280
            catch (Exception)
2281
            {
2282
                return null;
2283
            }
2284
            return result;
2285
        }
2286
        [OperationContract]
2287
        public string GetSymbolImageURL(string id, int type)
2288
        {
2289
            string result;
2290
            try
2291
            {
2292
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2293
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2294
                {
2295
                    if (type == 0)
2296
                    {
2297
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2298
                    }
2299
                    else
2300
                    {
2301
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2302
                    }
2303
                }
2304
            }
2305
            catch (Exception)
2306
            {
2307
                return null;
2308
            }
2309
            return result;
2310
        }
2311
        [OperationContract]
2312
        public string GetSignData(string project_no, string user_id)
2313
        {
2314
            string result = null;
2315
            try
2316
            {
2317
                string ifsign = getEnsembleSign(user_id);
2318
                if (string.IsNullOrEmpty(ifsign))
2319
                {
2320
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2321
                    var ModelWFConnectionString = sCIConnString;
2322
                    if (null != ModelWFConnectionString)
2323
                    {
2324
                        using (CIEntities entity = new CIEntities(ModelWFConnectionString))
2325
                        {
2326
                            var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2327
                            if (_sign.Count() > 0)
2328
                            {
2329
                                result = _sign.First().SIGN_STR;
2330
                            }
2331
                            else
2332
                            {
2333
                                return null;
2334
                            }
2335
                        }
2336
                    }
2337
                }
2338
                else
2339
                {
2340
                    result = ifsign;
2341
                }
2342

    
2343
            }
2344
            catch (Exception)
2345
            {
2346
                return null;
2347
            }
2348
            return result;
2349
        }
2350

    
2351
        [OperationContract]        
2352
        public string GetProjectName(string project_no)
2353
        {
2354
            string result = null;
2355

    
2356
            try
2357
            {
2358
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2359
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
2360
                {
2361
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
2362
                }
2363
            }
2364
            catch (Exception)
2365
            {
2366
                return null;
2367
            }
2368
            return result;
2369
        }
2370

    
2371
        [OperationContract]
2372
        public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev)
2373
        {
2374
            List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>();
2375
            
2376
            try
2377
            {
2378
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2379
                using (CIEntities Entity = new CIEntities(sCIConnString))
2380
                {
2381
                    result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no
2382
                    && i.DOCUMENT_NO == doc_no
2383
                    && i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList();
2384
                }
2385
            }
2386
            catch (Exception)
2387
            {
2388
                return null;
2389
            }
2390
            return result;
2391
        }
2392

    
2393
        [OperationContract]
2394
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
2395
        {
2396
            DOCINFO docinfo = null;
2397

    
2398
            try
2399
            {
2400
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2401
                using (CIEntities Entity = new CIEntities(sCIConnString))
2402
                {
2403
                    docinfo = (from info in Entity.DOCINFO
2404
                              where info.DOCUMENT_ID == doc_id
2405
                              && info.PROJECT_NO == project_no
2406
                              select info).First();
2407
                }
2408
            }
2409
            catch (Exception)
2410
            {
2411
                return null;
2412
            }
2413
            return docinfo;
2414
        }
2415

    
2416
        [OperationContract]
2417
        public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList)
2418
        {
2419
            MarkupInfoItem _result = null;
2420
            List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>();
2421
            try
2422
            {
2423
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2424
                using (CIEntities Entity = new CIEntities(sCIConnString))
2425
                {
2426
                    var docitem = (from info in Entity.DOCINFO
2427
                               where info.DOCUMENT_ID == doc_id
2428
                               && info.PROJECT_NO == project_no
2429
                               select info).First();
2430

    
2431
                    foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO)
2432
                    {
2433
                        var member = (from mem in Entity.MEMBER
2434
                                     where mem.ID == markinfo.USER_ID
2435
                                     select mem).First();
2436
                        string displaycolor = null;
2437
                        try
2438
                        {
2439
                            displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor;
2440
                        }
2441
                        catch(Exception)
2442
                        {
2443
                            displaycolor = "#FFFFFF";
2444
                        }
2445
                        
2446
                        _result = new MarkupInfoItem
2447
                        {
2448
                            MarkupInfoID = markinfo.ID,
2449
                            Consolidate = markinfo.CONSOLIDATE,
2450
                            CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME,
2451
                            DisplayColor = displaycolor,
2452
                            UserID = markinfo.USER_ID,
2453
                            UserName = member.NAME,
2454
                            Depatment = member.DEPARTMENT,
2455
                        };
2456

    
2457
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
2458
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
2459

    
2460
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
2461
                        {
2462
                            MarkupItem markitem = new MarkupItem()
2463
                            {
2464
                                ID = markdata.ID,
2465
                                PageNumber = markdata.PAGENUMBER,
2466
                            };
2467
                            _result.MarkupList.Add(markitem);
2468
                        }
2469

    
2470
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
2471

    
2472
                        markupinfo.Add(_result);
2473
                    }
2474
                }
2475
            }
2476
            catch (Exception)
2477
            {
2478
                return null;
2479
            }
2480
            return markupinfo;
2481
        }
2482

    
2483
        [OperationContract]
2484
        public bool AddMessage(string project_no, TALK value)
2485
        {
2486
            try
2487
            {
2488
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2489
                using (CIEntities entity = new CIEntities(sCIConnString))
2490
                {                    
2491
                    entity.TALK.AddObject(value);
2492
                    entity.SaveChanges();
2493
                }
2494
            }
2495
            catch (Exception)
2496
            {
2497
                return false;
2498
            }
2499
            return true;
2500
        }
2501

    
2502
        [OperationContract]
2503
        public List<TALK> GetMessage(string project_no, string doc_id)
2504
        {
2505
            List<TALK> result = new List<TALK>();
2506
            try
2507
            {
2508
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2509
                using (CIEntities entity = new CIEntities(sCIConnString))
2510
                {
2511
                    result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList();                        
2512
                }
2513
            }
2514
            catch (Exception ex)
2515
            {
2516
                return result;
2517
            }
2518
            return result;
2519
        }
2520

    
2521

    
2522
        #region Legacy System I/F
2523
        /// <summary>
2524
        /// Ensemble+ Sign Data Return
2525
        /// </summary>
2526
        /// <param name="user_id"></param>
2527
        /// <returns></returns>
2528
        private string getEnsembleSign(string user_id)
2529
        {
2530
            string result = null;
2531
            string soapurl = string.Empty;
2532

    
2533
            try
2534
            {
2535
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2536
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2537
                {
2538
                    var item = Entity.PROPERTIES.Where(d => d.TYPE == "UpLoadServiceUrl").FirstOrDefault();
2539

    
2540
                    if (item != null)
2541
                    {
2542
                        soapurl = item.VALUE;
2543

    
2544
                        WebClient webClient = new WebClient();
2545
                        string data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ens=\"http://EnsemblePlus.Webservice\"> <soapenv:Header/> <soapenv:Body> <ens:checkoutSignImage>"
2546
                            + "<ens:sUserNo>" + user_id + "</ens:sUserNo>"
2547
                            + "</ens:checkoutSignImage> </soapenv:Body></soapenv:Envelope>";
2548
                        webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
2549
                        webClient.Headers.Add("SOAPAction", "http://EnsemblePlus.Webservice");
2550
                        var _result = webClient.UploadString(new Uri(soapurl), data);
2551
                        XmlDocument xmlDoc = new XmlDocument();
2552
                        xmlDoc.LoadXml(_result);
2553
                        XmlNodeList list = xmlDoc.GetElementsByTagName("checkoutSignImageResponse");
2554

    
2555
                        foreach (XmlNode xn in list)
2556
                        {
2557
                            result = xn["checkoutSignImageReturn"].InnerText;
2558
                        }
2559

    
2560
                        if (result.Contains("No business object"))
2561
                        {
2562
                            result = null;
2563
                        }
2564
                    }
2565
                    else
2566
                    {
2567
                        result = null;
2568
                    }
2569
                }
2570
             
2571
            }
2572
            catch (Exception ex)
2573
            {   
2574
                result = null;
2575
            }
2576

    
2577
            return result;
2578
        }
2579
        #endregion
2580

    
2581
        #region Final Service
2582
        [OperationContract]
2583
        [ServiceKnownType(typeof(DOCINFO))]                
2584
        public DOCINFO FinalPDF_GetDocinfo(string project_no, string docinfo_id)
2585
        {
2586
            DOCINFO docinfo = null;
2587

    
2588
            try
2589
            {
2590
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2591
                using (CIEntities _entity = new CIEntities(sCIConnString))
2592
                {
2593
                    var doc = _entity.DOCINFO.Where(x => x.ID == docinfo_id).FirstOrDefault();
2594
                    if(doc != null)
2595
                    {
2596
                        docinfo = new DOCINFO()
2597
                        {
2598
                            ID = doc.ID,
2599
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2600
                            PAGE_COUNT = doc.PAGE_COUNT,
2601
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2602
                            PROJECT_NO = doc.PROJECT_NO
2603
                        };
2604
                    }                    
2605
                }
2606
            }
2607
            catch (Exception)
2608
            {
2609
                throw;
2610
            }
2611
            return docinfo;
2612
        }
2613
        [OperationContract]
2614
        [ServiceKnownType(typeof(DOCUMENT_ITEM))]
2615
        public DOCUMENT_ITEM FinalPDF_GetDocumentItem(string project_no, string document_id)
2616
        {
2617
            DOCUMENT_ITEM item = null;
2618

    
2619
            try
2620
            {
2621
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2622
                using (CIEntities _entity = new CIEntities(sCIConnString))
2623
                {
2624
                    var doc = _entity.DOCUMENT_ITEM.Where(x => x.DOCUMENT_ID == document_id).FirstOrDefault();
2625
                    if(doc != null)
2626
                    {
2627
                        item = new DOCUMENT_ITEM()
2628
                        {
2629
                            ID = doc.ID,
2630
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2631
                            PROJECT_NO = doc.PROJECT_NO,
2632
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2633
                            DOCUMENT_NO = doc.DOCUMENT_NO,
2634
                            DOCUMENT_NAME = doc.DOCUMENT_NAME,
2635
                            //ENSEMBLEINFO_URL = doc.ENSEMBLEINFO_URL,
2636
                            GROUP_NO = doc.GROUP_NO,
2637
                            RESULT = doc.RESULT,
2638
                            REVISION = doc.REVISION,
2639
                            RESULT_FILE = doc.RESULT_FILE
2640
                        };
2641
                    }
2642
                    
2643
                }
2644
            }
2645
            catch (Exception)
2646
            {
2647
                throw;
2648
            }
2649
            return item;
2650
        }
2651
        [OperationContract]
2652
        [ServiceKnownType(typeof(MARKUP_DATA))]
2653
        public List<MARKUP_DATA> FinalPDF_GetMarkupdata(string project_no, string docinfo_id)
2654
        {
2655
            List<MARKUP_DATA> results = new List<MARKUP_DATA>();
2656

    
2657
            try
2658
            {
2659
                //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2660
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2661
                using (CIEntities _entity = new CIEntities(sCIConnString))
2662
                {
2663
                    var datas = _entity.MARKUP_DATA.Where(x => x.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO_ID == docinfo_id
2664
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1
2665
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.AVOID_CONSOLIDATE == 0
2666
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.PART_CONSOLIDATE == 0).ToList();
2667
                    foreach (var data in datas)
2668
                    {
2669
                        MARKUP_DATA d = new MARKUP_DATA()
2670
                        {
2671
                            ID = data.ID,
2672
                            //GROUP_ID = data.GROUP_ID,
2673
                            SYMBOL_ID = data.SYMBOL_ID,
2674
                            DATA = data.DATA,
2675
                            DATA_TYPE = data.DATA_TYPE,
2676
                            MARKUPINFO_VERSION_ID = data.MARKUPINFO_VERSION_ID,
2677
                            PAGENUMBER = data.PAGENUMBER
2678
                        };
2679
                        results.Add(d);
2680
                    }
2681
                }
2682
            }
2683
            catch (Exception)
2684
            {
2685
                throw;
2686
            }
2687
            return results;
2688
        }
2689
        [OperationContract]
2690
        [ServiceKnownType(typeof(MARKUP_INFO))]
2691
        public MARKUP_INFO FinalPDF_GetMarkupinfo(string project_no, string docinfo_id)
2692
        {
2693
            MARKUP_INFO markupInfo = null;
2694

    
2695
            try
2696
            {
2697
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2698
                using (CIEntities _entity = new CIEntities(sCIConnString))
2699
                {
2700
                    var tmp = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo_id && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0).FirstOrDefault();
2701
                    if (tmp != null)
2702
                    {
2703
                        markupInfo = new MARKUP_INFO()
2704
                        {
2705
                            ID = tmp.ID,
2706
                            DOCINFO_ID = tmp.DOCINFO_ID,
2707
                            USER_ID = tmp.USER_ID
2708
                        };
2709
                    }                    
2710
                }
2711
            }
2712
            catch (Exception)
2713
            {
2714
                throw;
2715
            }
2716
            return markupInfo;
2717
        }
2718
        [OperationContract]
2719
        [ServiceKnownType(typeof(FINAL_PDF))]
2720
        public List<FINAL_PDF> FinalPDF_GetFinalPDFs(string final_id)
2721
        {
2722
            List<FINAL_PDF> results = new List<FINAL_PDF>();
2723

    
2724
            try
2725
            {
2726
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2727
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2728
                {
2729
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == final_id).ToList();
2730
                    foreach(var final in finalList)
2731
                    {
2732
                        FINAL_PDF pdf = new FINAL_PDF()
2733
                        {
2734
                            ID = final.ID,
2735
                            DOCINFO_ID = final.DOCINFO_ID,
2736
                            DOCUMENT_ID = final.DOCUMENT_ID,
2737
                            STATUS = final.STATUS,
2738
                            CURRENT_PAGE = final.CURRENT_PAGE,
2739
                            CREATE_DATETIME = final.CREATE_DATETIME,
2740
                            START_DATETIME = final.START_DATETIME,
2741
                            END_DATETIME = final.END_DATETIME,
2742
                            EXCEPTION = final.EXCEPTION,
2743
                            PROJECT_NO = final.PROJECT_NO,
2744
                            TOTAL_PAGE = final.TOTAL_PAGE,
2745
                            MARKUPINFO_ID = final.MARKUPINFO_ID,
2746
                            CREATE_USER_ID = final.CREATE_USER_ID
2747
                        };
2748
                        results.Add(pdf);
2749
                    }
2750
                }
2751
            }
2752
            catch (Exception)
2753
            {
2754
                throw;
2755
            }
2756
            return results;
2757
        }
2758
        [OperationContract]
2759
        [ServiceKnownType(typeof(DOCPAGE))]
2760
        public List<DOCPAGE> FinalPDF_GetDocpage(string project_no, string docinfo_id)
2761
        {
2762
            List<DOCPAGE> results = new List<DOCPAGE>();
2763

    
2764
            try
2765
            {
2766
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2767
                using (CIEntities _entity = new CIEntities(sCIConnString))
2768
                {
2769
                    var pages = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == docinfo_id).OrderBy(x => x.PAGE_NUMBER).ToList();
2770
                    foreach(var page in pages)
2771
                    {
2772
                        DOCPAGE p = new DOCPAGE()
2773
                        {
2774
                            PAGE_ANGLE = page.PAGE_ANGLE,
2775
                            PAGE_NUMBER = page.PAGE_NUMBER,
2776
                            PAGE_HEIGHT = page.PAGE_HEIGHT,
2777
                            PAGE_WIDTH = page.PAGE_WIDTH,
2778
                            DOCINFO_ID = page.DOCINFO_ID                            
2779
                        };
2780
                        results.Add(p);
2781
                    }                    
2782
                }
2783
            }
2784
            catch (Exception)
2785
            {
2786
                throw;
2787
            }
2788
            return results;
2789
        }
2790
        [OperationContract]        
2791
        public bool FinalPDF_SetFinalPDFStatus(string final_id, FinalStatus status)
2792
        {
2793
            bool result = false;
2794

    
2795
            try
2796
            {
2797
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2798
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2799
                {
2800
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2801
                    if(tmp != null)
2802
                    {
2803
                        switch(status)
2804
                        {
2805
                            case FinalStatus.Create:
2806
                                tmp.START_DATETIME = DateTime.Now;
2807
                                break;
2808
                            case FinalStatus.Success:
2809
                                tmp.END_DATETIME = DateTime.Now;
2810
                                tmp.EXCEPTION = string.Empty;
2811
                                break;                                
2812
                        }
2813
                        tmp.STATUS = (int)status;
2814
                        _entity.SaveChanges();
2815
                        result = true;                        
2816
                    }
2817
                }                    
2818
            }
2819
            catch (Exception)
2820
            {
2821
                throw;
2822
            }
2823
            return result;
2824
        }
2825

    
2826
        /// <summary>
2827
        /// 현재 진행중인 Final PDF 가 없거나 Success 일 경우에만 true return
2828
        /// </summary>
2829
        /// <param name="DocInfoID"></param>
2830
        /// <param name="MarkupInfoID"></param>
2831
        /// <param name="CreateUserID"></param>
2832
        /// <returns></returns>
2833
        [OperationContract]
2834
        public bool FinalPDF_GetFinalPDFStatus(string DocInfoID, string MarkupInfoID, string CreateUserID)
2835
        {
2836
            bool result = false;
2837

    
2838
            try
2839
            {
2840
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2841
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2842
                {
2843
                    var finalpdf = _entity.FINAL_PDF.Where(x => x.DOCINFO_ID == DocInfoID && x.MARKUPINFO_ID == MarkupInfoID && x.CREATE_USER_ID == CreateUserID && x.STATUS != (int)FinalStatus.Error).FirstOrDefault();
2844
                    if (finalpdf != null)
2845
                    {
2846
                        if (finalpdf.STATUS == (int)FinalStatus.Success)
2847
                        {
2848
                            result = true;
2849
                        }
2850
                    }
2851
                    else
2852
                        result = true;
2853
                }
2854
            }
2855
            catch (Exception)
2856
            {
2857
                throw;
2858
            }
2859
            return result;
2860
        }
2861

    
2862
        [OperationContract]
2863
        public bool FinalPDF_SetCurrentPage(string final_id, int currentpage)
2864
        {
2865
            bool result = false;
2866

    
2867
            try
2868
            {
2869
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2870
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2871
                {
2872
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2873
                    if (tmp != null)
2874
                    {
2875
                        tmp.CURRENT_PAGE = currentpage;
2876
                        _entity.SaveChanges();
2877
                        result = true;
2878
                    }
2879
                }
2880
            }
2881
            catch (Exception)
2882
            {
2883
                throw;
2884
            }
2885
            return result;
2886
        }
2887
        [OperationContract]
2888
        public bool FinalPDF_SetError(string final_id, string msg)
2889
        {
2890
            bool result = false;
2891

    
2892
            try
2893
            {
2894
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2895
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2896
                {
2897
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2898
                    if (tmp != null)
2899
                    {                        
2900
                        tmp.STATUS = (int)FinalStatus.Error;
2901
                        tmp.EXCEPTION = DateTime.Now.ToShortDateString() + " " + msg;                        
2902
                        _entity.SaveChanges();
2903
                        result = true;
2904
                    }
2905
                }
2906
            }
2907
            catch (Exception)
2908
            {
2909
                throw;
2910
            }
2911
            return result;
2912
        }
2913

    
2914
        [OperationContract]
2915
        public bool FinalPDF_SetFinalResultPath(string project_no, string document_id, string url)
2916
        {
2917
            bool result = false;
2918

    
2919
            try
2920
            {
2921
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2922
                using (CIEntities _entity = new CIEntities(sCIConnString))
2923
                {
2924
                    var item = _entity.DOCUMENT_ITEM.Where(d => d.DOCUMENT_ID == document_id).FirstOrDefault();
2925
                    if (item != null)
2926
                    {
2927
                        item.RESULT_FILE = url;
2928
                        _entity.SaveChanges();
2929
                        result = true;
2930
                    }
2931
                }
2932
            }
2933
            catch (Exception)
2934
            {
2935
                throw;
2936
            }
2937
            return result;
2938
        }
2939
        [OperationContract]
2940
        [ServiceKnownType(typeof(MEMBER))]
2941
        public MEMBER FinalPDF_GetCommentMember(string project_no, string markupdata_id)
2942
        {
2943
            MEMBER member = null;
2944
            try
2945
            {
2946
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2947
                using (CIEntities _entity = new CIEntities(sCIConnString))
2948
                {
2949
                    var data = _entity.MARKUP_DATA.Where(x => x.ID == markupdata_id).FirstOrDefault();
2950
                    string user_id = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
2951
                    var person = _entity.MEMBER.Where(p => p.ID == user_id).FirstOrDefault();
2952
                    if(person != null)
2953
                    {
2954
                        member = new MEMBER()
2955
                        {
2956
                            ID = user_id,
2957
                            NAME = person.NAME,
2958
                            DEPARTMENT = person.DEPARTMENT
2959
                        };
2960
                    }
2961
                }
2962
            }
2963
            catch (Exception)
2964
            {
2965
                throw;
2966
            }
2967
            return member;
2968
        }
2969

    
2970
        [OperationContract]
2971
        [ServiceKnownType(typeof(PROPERTIES))]
2972
        public List<PROPERTIES> FinalPDF_GetProperties(string project_no)
2973
        {
2974
            List<PROPERTIES> results = new List<PROPERTIES>();
2975
            try
2976
            {
2977
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2978
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2979
                {
2980
                    var _items = _entity.PROPERTIES.Where(x => x.PROPERTY == project_no).ToList();
2981
                    foreach(var item in _items)
2982
                    {
2983
                        PROPERTIES pROPERTIES = new PROPERTIES()
2984
                        {
2985
                            ID = item.ID,
2986
                            PROPERTY = item.PROPERTY,
2987
                            TYPE = item.TYPE,
2988
                            VALUE = item.VALUE
2989
                        };
2990
                        results.Add(pROPERTIES);
2991
                    }
2992
                }
2993

    
2994
            }
2995
            catch (Exception)
2996
            {
2997
                throw;
2998
            }
2999
            return results;
3000
        }
3001
        #endregion
3002
    }    
3003
}
클립보드 이미지 추가 (최대 크기: 500 MB)