프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ 0b75c341

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

1
using IFinalPDF;
2
using IKCOM;
3
using KCOMDataModel.Common;
4
using KCOMDataModel.DataModel;
5
using MARKUS;
6
using System;
7
using System.Collections.Generic;
8
using System.Collections.ObjectModel;
9
using System.Linq;
10
using System.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.Windows;
17
using System.Xml;
18

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

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

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

    
73

    
74
        [OperationContract]
75
        public KCOM_SystemInfo GetSystemData()
76
        {
77
            try
78
            {
79
                using (KCOMEntities uc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
80
                {
81
                    var SystemInfoSet = uc.PROPERTIES.Where(data => data.TYPE == "SystemInfo").ToList();
82

    
83
                    KCOM_SystemInfo sysInfo = new KCOM_SystemInfo();
84

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

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

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

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

    
120
            var guid = new Guid(bytes);
121

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

    
128

    
129
        [OperationContract]
130
        public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
131
        {
132
            using (KCOMEntities dc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
133
            {
134

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

    
140

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

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

    
145
                //favoriteListSet = favoriteListSet.Distinct().ToList();
146
                return favoriteListSet;
147
            }
148
        }
149
        [OperationContract]
150
        public bool EditFavoriteVP(string prjNo, string userID, string docID, int state, string description)
151
        {
152
            using (KCOMEntities dc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
153
            {
154
                //List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
155
                //    && data.PAGE_NO == SavePageNo && data.CREATE_TIME == createTime).ToList();
156
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
157
                    && data.ID == docID).ToList();
158
                try
159
                {
160

    
161
                    if (favoriteSet.Count > 0)
162
                    {
163
                        var FavoriteVP_Instance = favoriteSet.First();
164

    
165
                        FavoriteVP_Instance.DESCRIPTION = description;
166
                        FavoriteVP_Instance.FLAG = state;
167

    
168
                        dc.SaveChanges();
169

    
170
                        return true;
171
                    }
172
                    else
173
                    {
174
                        return false;
175
                    }
176
                }
177
                catch (Exception)
178
                {
179
                    return false;
180
                }
181
            }
182
        }
183

    
184
        [OperationContract]
185
        public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string docID)
186
        {
187

    
188
            using (KCOMEntities dc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
189
            {
190

    
191
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
192
                    && data.ID == docID).ToList();
193

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

    
214

    
215
        [OperationContract]
216
        public List<Rect> GetCompareRect(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress)
217
        {
218
            //string originFile = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", projectNo, (Convert.ToInt32(originDocItem_ID) / 100).ToString(), originDocItem_ID, originPageNo);
219
            //string targetFile = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", projectNo, (Convert.ToInt32(targetDocItem_ID) / 100).ToString(), targetDocItem_ID, targetPageNo);
220

    
221
            string originFile = "";
222
            string targetFile = "";
223

    
224
            if (Boolean.Parse(isInternalAddress))
225
            {
226
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, (Convert.ToUInt32(originDocItem_ID) / 100).ToString(), originDocItem_ID, originPageNo);
227
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, (Convert.ToUInt32(targetDocItem_ID) / 100).ToString(), targetDocItem_ID, targetPageNo);
228
            }
229
            else
230
            {
231
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  originDocItem_ID, originPageNo);
232
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  targetDocItem_ID, targetPageNo);
233
            }
234

    
235
            CompareLib compareLib = new CompareLib();
236
            //System.IO.Stream resultOrigin = compareLib.ChangeCmpUrlToPng(originFile);
237
            //System.IO.Stream resultTarget = compareLib.ChangeCmpUrlToPng(targetFile);
238

    
239
            var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
240
            var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
241

    
242
            string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
243
            var result = compareLib.GetBoundBoxInImage(outPutFile);
244

    
245
            return result;
246
        }
247

    
248

    
249

    
250
        #region Final PDF
251
        private string _ChanID = null;
252
        TcpChannel chan = null;
253
        [OperationContract]
254
        public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUserID)
255
        {
256
            #region 임시보관
257
            #endregion
258
            FinalPDFResult _result = new FinalPDFResult();
259
            RemFinalPDFObject remObj = null;
260
            try
261
            {
262
                string _finalID = shortGuid();
263
                int _DocTotalPages = -1;
264
                string docItemId;
265

    
266

    
267
                using (CIEntities _ci = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
268
                {
269
                    var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
270

    
271
                    if (_doc.Count() > 0)
272
                    {
273
                        _DocTotalPages = _doc.First().PAGE_COUNT;
274
                        docItemId = _doc.First().DOCUMENT_ID;
275
                    }
276
                    else
277
                    {
278
                        _result.Status = FinalStatus.Error;
279
                        _result.Exception = "페이지 정보를 가져올 수 없습니다.";
280
                        return _result;
281
                    }
282
                }
283
                if (_DocTotalPages > 0)
284
                {
285
                    FINAL_PDF fm = new FINAL_PDF()
286
                    {
287
                        ID = _finalID,
288
                        PROJECT_NO = ProjectNo,
289
                        DOCINFO_ID = DocInfoID,
290
                        DOCUMENT_ID = docItemId,
291
                        MARKUPINFO_ID = MarkupInfoID,
292
                        CREATE_USER_ID = CreateUserID,
293
                        TOTAL_PAGE = _DocTotalPages,
294
                        CREATE_DATETIME = DateTime.Now,
295
                        STATUS = (int)IFinalPDF.FinalStatus.Insert
296
                    };
297
                    using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
298
                    {
299
                        _entity.AddToFINAL_PDF(fm);
300
                        _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
301
                    };
302

    
303
                    System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
304
                    if (_ch == null)
305
                    {
306
                        chan = new TcpChannel();
307
                        _ChanID = chan.ChannelName;
308
                        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
309
                        // Create an instance of the remote object
310

    
311

    
312
                        using (KCOMEntities ec = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
313
                        {
314

    
315
                            //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
316
                            //                          "tcp://localhost:9092/remFinalPDF");
317
                            remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
318
                                                      //"tcp://192.168.0.67:9092/remFinalPDF");
319
                                                      "tcp://localhost:9092/remFinalPDF");
320
                        }
321

    
322
                        //"tcp://localhost:8080/remFinalPDF");
323

    
324
                        _result = remObj.SetFinalPDF(ProjectNo, _finalID);
325
                        _result.FinalID = _finalID;
326
                        _result.Status = FinalStatus.Success;
327

    
328
                        //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
329
                        //fa.MakeFinalPDF(fm);
330
                    }
331
                    else
332
                    {
333
                        _ChanID = _ch.ChannelName;
334
                    }
335
                }
336
            }
337
            catch (Exception ex)
338
            {
339
                _result.Status = FinalStatus.Error;
340

    
341
                if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
342
                    _result.Exception = "Final Server Not Connection";
343
                else _result.Exception = ex.ToString();
344
            }
345
            finally
346
            {
347
                remObj = null;
348
                if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
349
                    System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
350

    
351
                GC.Collect(2);
352
            }
353
            return _result;
354
        }
355
        #endregion
356

    
357

    
358
        [OperationContract]
359
        public bool GetConversionState(KCOM_BasicParam param)
360
        {
361
            using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(param.projectNo).ToString()))
362
            {
363
                var doc = entity.DOCINFO.Where(data => data.DOCUMENT_ID == param.documentID).FirstOrDefault();
364
                if (doc != null)
365
                {
366
                    var count = doc.DOCPAGE.Where(data => data.DOCINFO_ID == doc.ID).Count();
367
                    if (doc.PAGE_COUNT == count)  //페이지 수가 일치하는지
368
                    {
369
                        return true;
370
                    }
371
                    else //페이지 수가 일치하지 않는 경우
372
                    {
373
                        KCOMEntities entity_kcom = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString());
374
                        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();
375

    
376
                        if (lst != null || lst.Count >= 1)
377
                        {
378
                            //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_PAGECOUNT"), param.documentID, param.projectNo);
379
                            //이메일 클라이언트를 구현해야함
380
                        }
381
                        return false;
382
                    }
383
                }
384
                else
385
                {
386
                    //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_CONVERTFAILED"), param.documentID, param.projectNo);
387
                    //이메일 클라이언트를 구현해야함
388
                    return false;
389
                }
390
            }
391
        }
392

    
393
        [OperationContract]
394
        public List<VPRevision> GetVPRevisionHistory(string ProjectNo, string vpNo, string DocumentId)
395
        {
396
            List<VPRevision> _result = new List<VPRevision>();
397
            try
398
            {
399
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
400
                {
401
                    var _vpList = (from docitem in entity.DOCUMENT_ITEM
402
                                   where docitem.DOCUMENT_NO == vpNo
403
                                   select new VPRevision
404
                                   {
405
                                       RevNo = docitem.REVISION,
406
                                       GroupNo = docitem.GROUP_NO,
407
                                       FROM_VENDOR = docitem.ORIGINAL_FILE,
408
                                       DOCUMENT_ID = docitem.DOCUMENT_ID,
409
                                       TO_VENDOR = docitem.RESULT_FILE,
410
                                       RESULT = docitem.RESULT,
411
                                       DocNo = docitem.DOCUMENT_NO,
412
                                       EnsembleLink = docitem.ENSEMBLEINFO_URL,
413
                                       //IsSyncPossible = docitem.DOCUMENT_ID == DocumentId ? false : entity.DOCINFO.Where(d => d.DOCUMENT_ID == docitem.DOCUMENT_ID).ToList().Count > 0 ? true : false
414
                                   });
415
                    _result = _vpList.ToList();
416
                    foreach (var vp in _result)
417
                    {
418
                        if (entity.DOCINFO.Where(d => d.DOCUMENT_ID == vp.DOCUMENT_ID).ToList().Count > 0)
419
                            vp.IsSyncPossible = true;
420
                        else
421
                            vp.IsSyncPossible = false;
422
                    }
423
                    _result = _result.OrderByDescending(r => UInt64.Parse(System.Text.RegularExpressions.Regex.Replace(r.GroupNo, @"\D", ""))).ToList();
424
                }
425
            }
426
            catch (Exception)
427
            {
428

    
429
                throw;
430
            }
431
            finally
432
            {
433
                GC.Collect(2);
434
            }
435
            return _result;
436
        }
437

    
438
        [OperationContract]
439
        public VPRevision GetVPRevisionFirstOrDefault(string ProjectNo, string DocumentId)
440
        {
441
            VPRevision _result = null;
442
            try
443
            {
444
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
445
                {
446
                    _result = (from docitem in entity.DOCUMENT_ITEM
447
                     where docitem.DOCUMENT_ID == DocumentId
448
                     select new VPRevision
449
                     {
450
                         RevNo = docitem.REVISION,
451
                         GroupNo = docitem.GROUP_NO,
452
                         FROM_VENDOR = docitem.ORIGINAL_FILE,
453
                         DOCUMENT_ID = docitem.DOCUMENT_ID,
454
                         TO_VENDOR = docitem.RESULT_FILE,
455
                         RESULT = docitem.RESULT
456
                     }).FirstOrDefault();
457
                }
458
            }
459
            catch (Exception)
460
            {
461
                throw;
462
            }
463
            finally
464
            {
465
                GC.Collect(2);
466
            }
467
            return _result;
468
        }
469

    
470
        [OperationContract]
471
        public DOCINFO GetDocInfo(KCOM_BasicParam param)
472
        {
473
            DOCINFO _result = null;
474
            try
475
            {
476
                // 차후 아래의 코드로 변경
477
                //using (CI_Entities ModelDeeview = new CI_Entities(DaelimCiConnectionString.ToString()))
478
                CIEntities ModelDeeview = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(param.projectNo).ToString());
479

    
480
                var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID);
481
                if (docinfo.Count() > 0)
482
                {
483
                    _result = docinfo.First();
484
                    _result.MARKUP_INFO.Clear();
485

    
486
                }
487
                return _result;
488

    
489
            }
490
            catch (Exception ex)
491
            {
492
                System.Diagnostics.Trace.WriteLine("GetDocInfo Error : " + ex);
493
            }
494
            finally
495
            {
496
                GC.Collect(2);
497
            }
498
            return null;
499
        }
500

    
501
        [OperationContract]
502
        public bool GetCheckSystemAdmin(string UserID)
503
        {
504
            using (KCOMEntities uc = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
505
            {
506
                var user = uc.PROPERTIES.Where(data => data.TYPE == "Administrator" && data.PROPERTY.Contains(UserID)).FirstOrDefault();
507
                if (user != null)
508
                {
509
                    return true;
510
                }
511
                else
512
                {
513
                    return false;
514
                }
515
            }
516
            GC.Collect(2);
517
        }
518

    
519
        [OperationContract]
520
        public DOCUMENT_ITEM GetDocumentItemInfo(KCOM_BasicParam param)
521
        {
522
            ///param : prjNo, documentId, userId
523
            DOCUMENT_ITEM _result = null;
524

    
525
            try
526
            {
527
                CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(param.projectNo).ToString());
528

    
529
                var _items = entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == param.documentID);
530

    
531
                if (_items.Count() > 0)
532
                {
533
                    _result = _items.First();
534

    
535
                    return _result;
536
                }
537
                //else
538
                //{
539
                //    Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_DOCUMENTNOTFOUND"), param.documentID, param.projectNo);
540
                //}
541
            }
542
            catch (Exception ex)
543
            {
544
                System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex);
545
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
546
            }
547

    
548
            return _result;
549
        }
550
        /// <summary>
551
        /// DOCUMENT_ITEM Table 의 ID 로 Item 을 Select
552
        /// </summary>
553
        /// <param name="ensemble_id"></param>
554
        /// <returns></returns>
555
        [OperationContract]
556
        public string GetDocItemID(string ensemble_id)
557
        {
558
            ///param : prjNo, documentId, userId
559
            string _result = string.Empty;
560

    
561
            try
562
            {
563
                CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("markus").ToString());
564

    
565
                var _items = entity.DOCUMENT_ITEM.Where(data => data.ID == ensemble_id).FirstOrDefault();
566
                if(_items != null)
567
                    _result = _items.DOCUMENT_ID;
568
            }
569
            catch (Exception ex)
570
            {
571
                //System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex);
572
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
573
            }
574

    
575
            return _result;
576
        }
577
        public string UserGO(MARKUP_INFO item)
578
        {
579
            if (item != null)
580
            {
581
                return item.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID;
582
            }
583
            return null;
584
        }
585
        
586
        [OperationContract]
587
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
588
        {
589
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
590
            try
591
            {
592
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
593
                {
594
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
595

    
596
                    var markupList = from markup in markupListData
597
                                     orderby markup.CREATE_TIME descending
598
                                     select new MarkupInfoItem
599
                                     {
600
                                         MarkupInfoID = markup.ID,
601
                                         UserID = markup.USER_ID,
602
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
603
                                         CreateTime = markup.CREATE_TIME,
604
                                         Consolidate = markup.CONSOLIDATE,
605
                                         Description = markup.DESCRIPTION,
606
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
607
                                         PartConsolidate = markup.PART_CONSOLIDATE,
608
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
609
                                     };
610

    
611
                    if (markupList.Count() > 0)
612
                    {
613
                        _result = markupList.ToList();
614
                    }
615

    
616
                    _result.ForEach(r =>
617
                    {
618

    
619
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
620
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
621
                                        orderby markupData.PAGENUMBER
622
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList();
623
                    });
624

    
625
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
626
                    Random random = new Random();
627
                    
628
                    using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
629
                    {
630
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
631
                                             where property.TYPE == "DisplayColor"
632
                                             select property).ToList();
633
                    }                    
634

    
635
                    foreach (var item in _result)
636
                    {
637
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID).FirstOrDefault();
638
                        
639
                        if (_member != null)
640
                        {
641
                            item.UserName = _member.NAME;
642
                            item.Depatment = _member.DEPARTMENT;
643
                        }
644

    
645
                        if (_ColorsProperties.Count > 0)
646
                        {
647
                            int colorIdx = random.Next(0, _ColorsProperties.Count() - 1);
648
                            #region 부서별로 색상을 지정하고자 할때
649
                            /// 일단 의견을 들어보자구!
650
                            #endregion
651
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
652
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
653
                        }
654
                        else
655
                        {
656
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
657
                        }
658
                    }
659
                }
660
            }
661
            catch (Exception EX)
662
            {
663
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
664
                return _result;
665
            }
666
            finally
667
            {
668
                GC.Collect(2);
669
            }
670

    
671
            return _result;
672
        }
673

    
674

    
675
        /*
676
        [OperationContract]
677
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
678
        {
679
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
680
            try
681
            {
682
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
683
                {
684
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
685

    
686
                    var markupList = from markup in markupListData
687
                                     orderby markup.CREATE_TIME descending
688
                                     select new MarkupInfoItem
689
                                     {
690
                                         MarkupInfoID = markup.ID,
691
                                         UserID = markup.USER_ID,
692
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
693
                                         CreateTime = markup.CREATE_TIME,
694
                                         Consolidate = markup.CONSOLIDATE,
695
                                         Description = markup.DESCRIPTION,
696
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
697
                                         PartConsolidate = markup.PART_CONSOLIDATE,
698
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
699
                                     };
700

    
701
                    if (markupList.Count() > 0)
702
                    {
703
                        _result = markupList.ToList();
704
                    }
705

    
706
                    _result.ForEach(r =>
707
                    {
708

    
709
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
710
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
711
                                        orderby markupData.PAGENUMBER
712
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID }).ToList();
713
                    });
714

    
715
                    Random random = new Random();
716

    
717
                    _MemberDeptColors memberDeptColors = new _MemberDeptColors();
718
                    _MemberDeptColorsInfo memberDeptColorsInfo = new _MemberDeptColorsInfo();
719

    
720

    
721
                    memberDeptColors._memberDeptColors = (from memberdeptcolor in entity.MEMBER_DEPT_COLOR
722
                                                              //where memberdeptcolor.DEPARTMENT == "DisplayColor"
723
                                                          select memberdeptcolor).ToList();
724
                    memberDeptColorsInfo._memberDeptColorsInfo = (from memberdeptcolorinfo in entity.MEMBER_DEPT_COLORINFO
725
                                                                      //where memberdeptcolor.DEPARTMENT == "DisplayColor"
726
                                                                  select memberdeptcolorinfo).ToList();
727

    
728

    
729
                    foreach (var item in _result)
730
                    {
731
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
732

    
733
                        if (_member.Count() > 0)
734
                        {
735
                            item.UserName = _member.First().NAME;
736
                            item.Depatment = _member.First().DEPARTMENT;
737
                        }
738

    
739
                        foreach (var dept in memberDeptColors._memberDeptColors)
740
                        {//dept 지정  색상 
741
                            if (dept.DEPARTMENT == item.Depatment)
742
                            {
743
                                var colorlist = memberDeptColorsInfo._memberDeptColorsInfo.Where(d => d.COLORID == dept.COLORID).ToList();
744

    
745
                                int colorIdx = random.Next(1, colorlist.Count());
746
                                if (colorlist.Count > 0)
747
                                {
748
                                    item.DisplayColor = "#FF" + colorlist[colorIdx].DISPLAYCOLOR;
749
                                    memberDeptColorsInfo._memberDeptColorsInfo.Remove(colorlist[colorIdx]);
750
                                    break;
751
                                }
752
                                else
753
                                {
754
                                    item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
755
                                    break;
756
                                }
757
                            }
758
                        }
759

    
760

    
761
                        if (item.DisplayColor == null)
762
                        {
763
                            foreach (var dept in memberDeptColors._memberDeptColors)
764
                            {
765
                                if (dept.DEPARTMENT == null)
766
                                {
767
                                    dept.DEPARTMENT = item.Depatment;
768
                                    var colorlist = memberDeptColorsInfo._memberDeptColorsInfo.Where(d => d.COLORID == dept.COLORID).ToList();
769
                                    int colorIdx = random.Next(1, colorlist.Count());
770
                                    if (colorlist.Count > 0)
771
                                    {
772
                                        item.DisplayColor = "#FF" + colorlist[colorIdx].DISPLAYCOLOR;
773
                                        memberDeptColorsInfo._memberDeptColorsInfo.Remove(colorlist[colorIdx]);
774
                                        break;
775
                                    }
776
                                    else
777
                                    {
778
                                        item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
779
                                        break;
780
                                    }
781
                                }
782
                            }
783
                        }
784

    
785
                        if (item.DisplayColor == null)
786
                        {
787
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
788
                        }
789
                    }
790
                }
791
            }
792
            catch (Exception EX)
793
            {
794
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
795
                return _result;
796
            }
797
            finally
798
            {
799
                GC.Collect(2);
800
            }
801

    
802
            return _result;
803
        }
804

    
805
        /*
806
        [OperationContract]
807
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
808
        {
809
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
810
            try
811
            {
812
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
813
                {
814
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
815
                    //foreach (var item in markupListData)
816
                    //{
817
                    //    if (!item.AVOID_CONSOLIDATE.HasValue)
818
                    //    {
819
                    //        item.AVOID_CONSOLIDATE = 0;
820
                    //    }
821
                    //}
822

    
823
                    var markupList = from markup in markupListData
824
                                     orderby markup.CREATE_TIME descending
825
                                     select new MarkupInfoItem
826
                                     {
827
                                         MarkupInfoID = markup.ID,
828
                                         UserID = markup.USER_ID,
829
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
830
                                         CreateTime = markup.CREATE_TIME,
831
                                         Consolidate = markup.CONSOLIDATE,
832
                                         Description = markup.DESCRIPTION,
833
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
834
                                         PartConsolidate = markup.PART_CONSOLIDATE,
835
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
836
                                     };
837

    
838

    
839

    
840
                    if (markupList.Count() > 0)
841
                    {
842
                        _result = markupList.ToList();
843
                    }
844

    
845

    
846

    
847
                    _result.ForEach(r =>
848
                    {
849

    
850
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
851
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
852
                                        orderby markupData.PAGENUMBER
853
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID, Group_ID = markupData.GROUP_ID ?? 0 }).ToList();
854
                    });
855

    
856
                    _ColorsProperties colors = new _ColorsProperties();
857
                    Random random = new Random();
858

    
859
                    using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
860
                    {
861
                        colors._colorsProperties = (from property in kcomEntity.PROPERTIES
862
                                             where property.TYPE == "DisplayColor"
863
                                             select property).ToList();
864
                    }
865
                    List<DeptColor> deptColor = new List<DeptColor>();
866

    
867
                    List<DeptColor> listTest = new List<DeptColor>();
868
                    //Dictionary<string, string> d = new Dictionary<string, string>();
869
                    var list = new List<KeyValuePair<string, string>>();
870
                    foreach (var test in colors._colorsProperties)
871
                    {
872
                        list.Add(new KeyValuePair<string, string>(test.PROPERTY, test.VALUE));
873
                        //d.Add(test.PROPERTY, test.VALUE);
874
                        listTest.Add(new DeptColor { Property = test.PROPERTY,DisplayColor = test.VALUE});
875
                    }
876
                    
877

    
878
                    foreach (var item in _result)
879
                    {
880
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
881

    
882
                        if (_member.Count() > 0)
883
                        {
884
                            item.UserName = _member.First().NAME;
885
                            item.Depatment = _member.First().DEPARTMENT;
886
                        }
887

    
888
                        if (colors._colorsProperties.Count > 0)
889
                        {
890
                            int colorIdx = random.Next(1, colors._colorsProperties.Count());
891
                            #region 부서별로 색상을 지정하고자 할때
892

    
893
                            if(deptColor.Count > 0)
894
                            {
895
                                foreach (var dept in deptColor)
896
                                {
897
                                    if (dept.Depatment == item.Depatment)
898
                                    {
899
                                        //list에서 deptColor.Property의 값 중 상위의 데이터를 뽑아서 지정하고 list에서 삭제 
900
                                        item.DisplayColor = "#FF" + list.Where(p => p.Key == dept.Property).FirstOrDefault().Value;
901
                                        list.Remove(new KeyValuePair<string, string>(dept.Property, dept.DisplayColor));
902
                                        break;
903
                                    }
904
                                    else
905
                                    {
906
                                        item.DisplayColor = "#FF" + colors._colorsProperties[colorIdx].VALUE;
907
                                        deptColor.Add(new DeptColor { DisplayColor = item.DisplayColor, Depatment = item.Depatment, Property = colors._colorsProperties[colorIdx].PROPERTY });
908
                                        colors._colorsProperties.RemoveAll(p => p.PROPERTY.Equals(colors._colorsProperties[colorIdx].PROPERTY)); //같은 계열의 색상은 지운다
909
                                        break;
910
                                    }
911
                                }
912
                            }
913
                            else
914
                            {
915
                                item.DisplayColor = "#FF" + colors._colorsProperties[colorIdx].VALUE;
916
                                deptColor.Add(new DeptColor { DisplayColor = item.DisplayColor, Depatment = item.Depatment, Property = colors._colorsProperties[colorIdx].PROPERTY });
917
                                colors._colorsProperties.RemoveAll(p => p.PROPERTY.Equals(colors._colorsProperties[colorIdx].PROPERTY)); //같은 계열의 색상은 지운다
918
                            }                                                     
919
                            #endregion
920
                        }
921
                        else
922
                        {
923
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
924
                        }
925
                    }
926
                }
927
            }
928
            catch (Exception EX)
929
            {
930
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
931
                return _result;
932
            }
933
            finally
934
            {
935
                GC.Collect(2);
936
            }
937

    
938
            return _result;
939
        }
940
        */
941
        [OperationContract]
942
        public List<MarkupInfoItem> GetSyncMarkupInfoItems(string ProjectNo, string DocInfoId, string currentUser)
943
        {
944
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
945
            try
946
            {
947
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
948
                {
949
                    var docItem = entity.DOCINFO.Where(data => data.DOCUMENT_ID == DocInfoId).FirstOrDefault();
950
                    if (docItem == null)
951
                    {
952
                        return null;
953
                    }
954
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == docItem.ID).ToList();
955

    
956
                    var markupList = from markup in markupListData
957
                                     where markup.USER_ID == currentUser || markup.CONSOLIDATE == 1
958
                                     orderby markup.CREATE_TIME descending
959
                                     select new MarkupInfoItem
960
                                     {
961
                                         MarkupInfoID = markup.ID,
962
                                         UserID = markup.USER_ID,
963
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
964
                                         CreateTime = markup.CREATE_TIME,
965
                                         Consolidate = markup.CONSOLIDATE,
966
                                         Description = markup.DESCRIPTION,
967
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
968
                                         PartConsolidate = markup.PART_CONSOLIDATE,
969
                                     };
970

    
971

    
972

    
973
                    if (markupList.Count() > 0)
974
                    {
975
                        _result = markupList.ToList();
976
                    }
977

    
978

    
979

    
980
                    _result.ForEach(r =>
981
                    {
982

    
983
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
984
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
985
                                        orderby markupData.PAGENUMBER
986
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList();
987
                    });
988

    
989
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
990
                    Random random = new Random();
991

    
992
                    using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
993
                    {
994
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
995
                                             where property.TYPE == "DisplayColor"
996
                                             select property).ToList();
997
                    }
998

    
999
                    foreach (var item in _result)
1000
                    {
1001
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
1002

    
1003
                        if (_member.Count() > 0)
1004
                        {
1005
                            item.UserName = _member.First().NAME;
1006
                            item.Depatment = _member.First().DEPARTMENT;
1007
                        }
1008

    
1009
                        if (_ColorsProperties.Count > 0)
1010
                        {
1011
                            int colorIdx = random.Next(1, _ColorsProperties.Count());
1012
                            #region 부서별로 색상을 지정하고자 할때
1013
                            /// 일단 의견을 들어보자구!
1014
                            #endregion
1015
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
1016
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
1017
                            //item.DisplayColor = "#FF" + _Colors.First();
1018
                            //_Colors.Remove(_Colors.First());
1019
                        }
1020
                        else
1021
                        {
1022
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
1023
                        }
1024
                    }
1025
                }
1026
            }
1027
            catch (Exception EX)
1028
            {
1029
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
1030
                return _result;
1031
            }
1032
            finally
1033
            {
1034
                GC.Collect(2);
1035
            }
1036

    
1037
            return _result;
1038
        }
1039

    
1040

    
1041
        //[OperationContract]
1042
        //[ServiceKnownType(typeof(MEMBER))]
1043
        //public List<MEMBER> GetUserData(string ProjectNo, string UserID)
1044
        //{
1045
        //    List<MEMBER> _result = new List<MEMBER>();
1046

    
1047
        //    using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1048
        //    {
1049
        //        var _UserList = from member in entity.MEMBER
1050
        //                        where member.ID == UserID
1051
        //                        select member;
1052
        //        _result = _UserList.ToList();
1053
        //    }
1054
        //    //GC.Collect(2);
1055
        //    return _result;
1056
        //}
1057

    
1058
        [OperationContract]
1059
        [ServiceKnownType(typeof(MEMBER))]
1060
        public List<MEMBER> GetUserData(string ProjectNo, string UserID)
1061
        {
1062
            List<MEMBER> _result = new List<MEMBER>();
1063

    
1064
            using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1065
            {
1066
                var _UserList = from member in entity.MEMBER
1067
                                where member.ID == UserID
1068
                                select member;
1069
                _result = _UserList.ToList();
1070
            }
1071
            //GC.Collect(2);
1072
            return _result;
1073
        }
1074

    
1075

    
1076
        [OperationContract]
1077
        public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정
1078
        {
1079
            List<string> _result = new List<string>();
1080

    
1081
            try
1082
            {
1083
                KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString());
1084
                var YourEnginner = (from dept in entity.PROPERTIES
1085
                                    where dept.TYPE == "DeptName" && UserDept.Contains(dept.VALUE)
1086
                                    select dept).FirstOrDefault();
1087

    
1088
                if (YourEnginner != null)
1089
                {
1090
                    _result = (from dept in entity.PROPERTIES
1091
                               where dept.PROPERTY == YourEnginner.PROPERTY
1092
                               select dept.VALUE).ToList();
1093
                    return _result;
1094
                }
1095
                else
1096
                {
1097
                    return null;
1098
                }
1099
            }
1100
            catch (Exception ex)
1101
            {
1102
                System.Diagnostics.Debug.WriteLine(ex.Message);
1103
            }
1104
            finally
1105
            {
1106
                GC.Collect(2);
1107
            }
1108
            return _result;
1109
        }
1110

    
1111
        [OperationContract]
1112
        public bool DeleteMarkup(string ProjectNo, string MarkupInfoID)
1113
        {
1114
            bool _result = false;
1115
            try
1116
            {
1117
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1118
                {
1119

    
1120
                    MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault();
1121

    
1122
                    if (instance == null)
1123
                    {
1124
                        return false;
1125
                    }
1126
                    MARKUP_INFO_VERSION version = instance.MARKUP_INFO_VERSION.FirstOrDefault();
1127

    
1128

    
1129
                    version.MARKUP_DATA.ToList().ForEach(data =>
1130
                    {
1131
                        Entity.MARKUP_DATA.DeleteObject(data);
1132
                        Entity.SaveChanges();
1133
                    });
1134

    
1135
                    Entity.MARKUP_INFO_VERSION.DeleteObject(version);
1136
                    Entity.SaveChanges();
1137

    
1138
                    Entity.MARKUP_INFO.DeleteObject(instance);
1139
                    Entity.SaveChanges();
1140

    
1141
                }
1142
                _result = true;
1143
            }
1144
            catch (Exception ex)
1145
            {
1146
                System.Diagnostics.Trace.WriteLine(ex, "SaveMarkup");
1147
            }
1148
            finally
1149
            {
1150
                GC.Collect(2);
1151
            }
1152
            return _result;
1153
        }
1154

    
1155
        #region Favorite
1156
        [OperationContract]
1157
        public bool SetFavoriteVP(string prjNo, string userID, string groupNo, string docNo, string rev, int SavePageNo, string documentItemID, string VPDescription, IKCOM.FAVORITE_FLAG flag)
1158
        {
1159

    
1160
            using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1161
            {
1162
                try
1163
                {
1164
                    entity.FAVORITE_DOC.AddObject(new FAVORITE_DOC
1165
                    {
1166
                        ID = shortGuid(),
1167
                        PROJECT_NO = prjNo,
1168
                        DOCUMENT_ID = documentItemID,
1169
                        GROUP_NO = groupNo,
1170
                        DOCUMENT_NO = docNo,
1171
                        MEMBER_USER_ID = userID,
1172
                        DESCRIPTION = VPDescription,
1173
                        CREATE_TIME = DateTime.Now,
1174
                        REVISION = rev,
1175
                        FLAG = (int)flag,
1176
                        PAGE_NO = SavePageNo,
1177
                    });
1178
                    entity.SaveChanges();
1179
                }
1180
                catch (Exception)
1181
                {
1182
                    return false;
1183
                }
1184

    
1185
                return true;
1186
            }
1187
        }
1188

    
1189
        //[OperationContract]
1190
        //public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
1191
        //{
1192
        //    using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1193
        //    {
1194

    
1195
        //        int flagString = Convert.ToInt32(IKCOM.FAVORITE_FLAG.Personal);                
1196
        //        List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
1197
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
1198
        //            flagString).ToList().ForEach(data => favoriteListSet.Add(data));
1199
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data));
1200
        //        favoriteListSet = favoriteListSet.Distinct().ToList();
1201
        //        return favoriteListSet;
1202
        //    }
1203
        //}
1204
        //[OperationContract]
1205
        //public bool EditFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime, int state, string description)
1206
        //{
1207
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1208
        //    {
1209
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1210
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1211

    
1212
        //        try
1213
        //        {
1214

    
1215

    
1216
        //            if (favoriteSet.Count > 0)
1217
        //            {
1218
        //                var FavoriteVP_Instance = favoriteSet.First();
1219

    
1220
        //                FavoriteVP_Instance.Description = description;
1221
        //                FavoriteVP_Instance.Flag = state;
1222

    
1223
        //                dc.SaveChanges();
1224

    
1225
        //                return true;
1226
        //            }
1227
        //            else
1228
        //            {
1229
        //                return false;
1230
        //            }
1231
        //        }
1232
        //        catch (Exception)
1233
        //        {
1234
        //            return false;
1235
        //        }
1236
        //    }
1237
        //}
1238
        //[OperationContract]
1239
        //public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime)
1240
        //{
1241

    
1242
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1243
        //    {
1244
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1245
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1246

    
1247
        //        try
1248
        //        {
1249

    
1250

    
1251
        //            if (favoriteSet.Count > 0)
1252
        //            {
1253
        //                favoriteSet.ForEach(data => dc.FavoriteVP.DeleteObject(data));
1254
        //                dc.SaveChanges();
1255
        //                return true;
1256
        //            }
1257
        //            else
1258
        //            {
1259
        //                return false;
1260
        //            }
1261
        //        }
1262
        //        catch (Exception)
1263
        //        {
1264
        //            return false;
1265
        //        }
1266
        //    }
1267
        //}
1268
        #endregion
1269

    
1270
        [OperationContract]
1271
        public bool SaveMarkupData(MarkupInfoItem UserState,string project_no,string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1272
        {
1273
            using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1274
            {     
1275
                #region Docinfo 정보 가져오기
1276

    
1277
                string docinfoid_ = (from info in Entity.DOCINFO
1278
                                     where info.DOCUMENT_ID == doc_id
1279
                                     && info.PROJECT_NO == project_no
1280
                                     select info.ID
1281
                                     ).First().ToString();
1282
                #endregion
1283

    
1284
                #region Markup_Info 저장
1285

    
1286
                MARKUP_INFO markup_info = new MARKUP_INFO();
1287
                try
1288
                {
1289
                    markup_info = (from info in Entity.MARKUP_INFO
1290
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
1291
                                   select info).FirstOrDefault();
1292
                }
1293
                catch (Exception)
1294
                {
1295
                    markup_info = null;
1296
                }
1297

    
1298
                //markup_info가 없을 경우 생성
1299
                if (markup_info == null)
1300
                {
1301
                    //MarkupInfo 저장
1302
                    markup_info = new MARKUP_INFO
1303
                    {
1304
                        ID = UserState.MarkupInfoID,
1305
                        DOCINFO_ID = docinfoid_,
1306
                        USER_ID = user_id,
1307
                        CREATE_TIME = DateTime.Now,
1308
                        CONSOLIDATE = UserState.Consolidate,
1309
                        AVOID_CONSOLIDATE = UserState.AvoidConsolidate,
1310
                        PART_CONSOLIDATE = UserState.PartConsolidate,
1311
                        DESCRIPTION = UserState.Description,
1312
                        UPDATE_TIME = DateTime.Now
1313
                    };
1314
                    Entity.MARKUP_INFO.AddObject(markup_info);
1315
                }
1316
                //markup_info가 있을 경우 업데이트
1317
                else
1318
                {
1319
                    markup_info.UPDATE_TIME = DateTime.Now;
1320
                }
1321
                Entity.SaveChanges();
1322
                #endregion
1323

    
1324
                #region Markup_Info_Version 저장
1325

    
1326
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1327

    
1328
                try
1329
                {
1330
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1331
                                           where info.MARKUPINFO_ID == markup_info.ID
1332
                                           select info).FirstOrDefault();
1333
                }
1334
                catch (Exception)
1335
                {
1336
                    markup_info_version = null;
1337
                }
1338

    
1339
                //markup_info_version 없을 경우 생성
1340
                if (markup_info_version == null)
1341
                {
1342
                    //MarkupInfo_version 저장
1343
                    markup_info_version = new MARKUP_INFO_VERSION()
1344
                    {
1345
                        ID = UserState.MarkupVersionID,
1346
                        MARKUPINFO_ID = markup_info.ID,
1347
                        CREATE_DATE = DateTime.Now
1348
                    };
1349
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1350
                    Entity.SaveChanges();
1351
                }
1352
                #endregion
1353

    
1354
                
1355
                Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1356
                {
1357
                    Entity.MARKUP_DATA.DeleteObject(item);
1358
                });
1359
                Entity.SaveChanges();
1360

    
1361
                try
1362
                {
1363
                    mlmarkup_data.ForEach(value =>
1364
                    {
1365
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1366
                        {
1367
                            ID = value.ID,
1368
                            DATA = value.DATA,
1369
                            DATA_TYPE = value.DATA_TYPE,
1370
                            PAGENUMBER = value.PAGENUMBER,
1371
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1372
                            SYMBOL_ID = value.SYMBOL_ID,
1373
                            //GROUP_ID = value.GROUP_ID
1374
                        });
1375
                    });
1376
                    Entity.SaveChanges();
1377
                }
1378
                catch (Exception)
1379
                {
1380
                    return false;
1381
                }
1382
            }
1383
            return true;
1384
        }
1385

    
1386
        //[OperationContract]
1387
        //public long AddMarkupDataGroup(MARKUP_DATA_GROUP mARKUP_DATA_GROUP, string ProjectNo)
1388
        //{
1389
        //    try
1390
        //    {
1391
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1392
        //        {
1393
        //            Entity.AddToMARKUP_DATA_GROUP(mARKUP_DATA_GROUP);
1394
        //            //MARKUP_DATA_GROUP tt = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == id).FirstOrDefault();
1395
        //            Entity.SaveChanges();
1396

    
1397
        //            return Entity.MARKUP_DATA_GROUP.ToList().LastOrDefault().ID;
1398
        //        }
1399
        //    }
1400
        //    catch (Exception)
1401
        //    {
1402
        //        return 0;
1403
        //    }
1404
        //}
1405
        //[OperationContract]
1406
        //public bool UpdateMarkupDataGroup(long Group_ID, string ProjectNo)
1407
        //{
1408
        //    try
1409
        //    {
1410
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1411
        //        {
1412
        //            var UpdateItem = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == Group_ID).FirstOrDefault();
1413
        //            UpdateItem.STATE = 1;
1414
        //            Entity.SaveChanges();
1415
        //        }
1416
        //    }
1417
        //    catch (Exception)
1418
        //    {
1419
        //        return false;
1420
        //    }
1421
        //    return true;
1422
        //}
1423
        [OperationContract]
1424
        public bool UpdateMarkupData(string CommentID, long Group_ID, string ProjectNo)
1425
        {
1426
            try
1427
            {
1428
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1429
                {
1430
                    var UpdateItem = Entity.MARKUP_DATA.Where(info => info.ID == CommentID).FirstOrDefault();
1431
                    //UpdateItem.GROUP_ID = Group_ID;
1432
                    Entity.SaveChanges();
1433
                }
1434
            }
1435
            catch (Exception)
1436
            {
1437
                return false;
1438
            }
1439
            return true;
1440
        }
1441

    
1442
        [OperationContract]
1443
        public bool SaveSymbol(SYMBOL_PRIVATE symbol_private)
1444
        {
1445
            try
1446
            {
1447
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
1448
                {
1449
                    uc.AddToSYMBOL_PRIVATE(symbol_private);
1450
                    uc.SaveChanges();
1451
                }
1452
            }
1453
            catch(Exception)
1454
            {
1455
                return false;
1456
            }
1457
            return true;
1458
        }
1459
        [OperationContract]
1460
        public bool AddPublicSymbol(SYMBOL_PUBLIC symbol)
1461
        {
1462
            try
1463
            {
1464
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
1465
                {
1466
                    uc.AddToSYMBOL_PUBLIC(symbol);
1467
                    uc.SaveChanges();
1468
                }
1469
            }
1470
            catch (Exception)
1471
            {
1472
                return false;
1473
            }
1474
            return true;
1475
        }
1476
        [OperationContract]
1477
        public bool DeleteSymbol(string symbol_id, int type)
1478
        {
1479
            try
1480
            {
1481
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1482
                {
1483
                    if (type == 0)
1484
                    {
1485
                        string delItem_ID = symbol_id;
1486
                        var delitem = Entity.SYMBOL_PRIVATE.Where(data => data.ID == delItem_ID).FirstOrDefault();
1487
                        Entity.SYMBOL_PRIVATE.DeleteObject(delitem);
1488
                        Entity.SaveChanges();
1489
                    }
1490
                    else
1491
                    {
1492
                        string delItem_ID = symbol_id;
1493
                        var delitem = Entity.SYMBOL_PUBLIC.Where(data => data.ID == delItem_ID).FirstOrDefault();
1494
                        Entity.SYMBOL_PUBLIC.DeleteObject(delitem);
1495
                        Entity.SaveChanges();
1496
                    }
1497
                }
1498
            }
1499
            catch(Exception)
1500
            {
1501
                return false;
1502
            }
1503
            return true;
1504
        }
1505

    
1506
        [OperationContract]
1507
        public bool RenameSymbol(string symbol_id, string name, int type)
1508
        {
1509
            try
1510
            {
1511
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1512
                {
1513
                    if (type == 0)
1514
                    {
1515
                        var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == symbol_id).FirstOrDefault();
1516
                        UpdateItem.NAME = name;
1517
                        Entity.SaveChanges();
1518
                    }
1519
                    else
1520
                    {
1521
                        var UpdateItem = Entity.SYMBOL_PUBLIC.Where(info => info.ID == symbol_id).FirstOrDefault();
1522
                        UpdateItem.NAME = name;
1523
                        Entity.SaveChanges();
1524
                    }
1525
                }
1526
            }
1527
            catch (Exception)
1528
            {
1529
                return false;
1530
            }
1531
            return true;
1532
        }
1533

    
1534
        [OperationContract]
1535
        public bool AddCheckListHistory(string project_no, CHECK_LIST_HISTORY Check_History)
1536
        {
1537
            try
1538
            {                
1539
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1540
                {
1541
                    Entity.CHECK_LIST_HISTORY.AddObject(Check_History);
1542
                    Entity.SaveChanges();  
1543
                }
1544
            }
1545
            catch (Exception)
1546
            {
1547
                return false;
1548
            }
1549
            return true;
1550
        }
1551
        [OperationContract]
1552
        public bool SaveCheckListHistory(string project_no, string rev, CHECK_LIST_HISTORY Check_History)
1553
        {
1554
            try
1555
            {
1556
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1557
                {
1558
                    var item = Entity.CHECK_LIST_HISTORY.Where(info => info.REVISION == rev).FirstOrDefault();
1559
                    item = Check_History;
1560
                    Entity.SaveChanges();
1561
                }
1562
            }
1563
            catch (Exception)
1564
            {
1565
                return false;
1566
            }
1567
            return true;
1568
        }
1569
        [OperationContract]
1570
        public bool SaveCheckList(string project_no, string _id, CHECK_LIST Check_value)
1571
        {
1572
            try
1573
            {
1574
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1575
                {
1576
                    var item = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1577
                    item.TODOLIST = Check_value.TODOLIST;
1578
                    item.REMARK = Check_value.REMARK;
1579
                    item.STATUS = Check_value.STATUS;
1580
                    item.VENDOR = Check_value.VENDOR;
1581
                    item.REPLY = Check_value.REPLY;
1582
                    item.IMAGE_URL = Check_value.IMAGE_URL;
1583
                    item.IMAGE_ANCHOR = Check_value.IMAGE_ANCHOR;
1584
                    item.UPDATE_TIME = Check_value.UPDATE_TIME;
1585
                    if(Check_value.STATUS == "False")
1586
                    {
1587
                        item.STATUS_DESC_OPEN = Check_value.STATUS_DESC_OPEN;
1588
                    }
1589
                    else
1590
                    {
1591
                        item.STATUS_DESC_CLOSE = Check_value.STATUS_DESC_CLOSE;
1592
                    }                     
1593
                    Entity.SaveChanges();
1594
                }
1595
            }
1596
            catch (Exception)
1597
            {
1598
                return false;
1599
            }
1600
            return true;
1601
        }
1602
        [OperationContract]
1603
        public bool AddCheckList(string project_no, CHECK_LIST Check_value)
1604
        {
1605
            try
1606
            {
1607
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1608
                {
1609
                    Entity.CHECK_LIST.AddObject(Check_value);
1610
                    Entity.SaveChanges();
1611
                }
1612
            }
1613
            catch (Exception)
1614
            {
1615
                return false;
1616
            }
1617
            return true;
1618
        }
1619

    
1620
        [OperationContract]
1621
        public CHECK_LIST GetCheckList(string project_no, string _id)
1622
        {
1623
            CHECK_LIST Check_value = new CHECK_LIST();
1624
            try
1625
            {
1626
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1627
                {
1628
                    Check_value = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1629
                }
1630
            }
1631
            catch (Exception)
1632
            {
1633
                return null;
1634
            }
1635
            return Check_value;
1636
        }
1637
        [OperationContract]
1638
        public List<CHECK_LIST> GetUserCheckList(string project_no, string user_id, string doc_no)
1639
        {
1640
            List<CHECK_LIST> list = new List<CHECK_LIST>();
1641
            try
1642
            {
1643
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1644
                {
1645
                    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();
1646
                }
1647
            }
1648
            catch (Exception)
1649
            {
1650
                return null;
1651
            }
1652
            return list;
1653
        }
1654
        [OperationContract]
1655
        public List<CHECK_LIST_HISTORY> GetCheckListHistory(string project_no, string _id)
1656
        {
1657
            List<CHECK_LIST_HISTORY> history = new List<CHECK_LIST_HISTORY>();
1658
            try
1659
            {
1660
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1661
                {
1662
                    history = Entity.CHECK_LIST_HISTORY.Where(data => data.CHECKLIST_ID == _id).ToList();
1663
                }
1664
            }
1665
            catch (Exception)
1666
            {
1667
                return null;
1668
            }
1669
            return history;
1670
        }
1671
        [OperationContract]
1672
        public CHECK_LIST_HISTORY GetCheckListHistoryFirstOrDefault(string project_no, string checklist_id, string rev)
1673
        {
1674
            CHECK_LIST_HISTORY Check_Item = new CHECK_LIST_HISTORY();
1675
            try
1676
            {
1677
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1678
                {   
1679
                    Check_Item = Entity.CHECK_LIST_HISTORY.Where(info => info.CHECKLIST_ID == checklist_id && info.REVISION == rev).FirstOrDefault();
1680
                }
1681
            }
1682
            catch (Exception)
1683
            {
1684
                return null;
1685
            }
1686
            return Check_Item;
1687
        }
1688
        [OperationContract]
1689
        public bool SavePageAngle(string project_no, List<DOCPAGE> _mldocpage)
1690
        {
1691
            try
1692
            {
1693
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1694
                {
1695
                    KCOMDataModel.DataModel.DOCPAGE _docpage = new KCOMDataModel.DataModel.DOCPAGE();
1696
                    _mldocpage.ForEach(data =>
1697
                    {
1698
                        _docpage = (from info in Entity.DOCPAGE
1699
                                    where info.ID == data.ID
1700
                                    select info).FirstOrDefault();
1701

    
1702
                        if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE)
1703
                        {
1704
                            _docpage.PAGE_ANGLE = data.PAGE_ANGLE;
1705
                        }
1706
                    });
1707

    
1708
                    Entity.SaveChanges();
1709
                }
1710
            }
1711
            catch (Exception)
1712
            {
1713
                return false;
1714
            }
1715
            return true;
1716
        }
1717

    
1718
        [OperationContract]
1719
        public MARKUP_INFO GetMarkupInfo(string project_no, string _id)
1720
        {
1721
            MARKUP_INFO markupInfo = new MARKUP_INFO();
1722

    
1723
            try
1724
            {
1725
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1726
                {
1727
                    markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1728
                }
1729
            }
1730
            catch (Exception)
1731
            {
1732
                return null;
1733
            }
1734
            return markupInfo;
1735
        }
1736

    
1737
        [OperationContract]
1738
        public List<string> GetMarkupDataListperPage(string project_no, string _markupinfoid, int _pageNo)
1739
        {
1740
            List<string> markupdata = new List<string>();
1741
            MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1742
            try
1743
            {
1744
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1745
                {
1746
                    markup_info_version = (from version in Entity.MARKUP_INFO_VERSION
1747
                                           where version.MARKUPINFO_ID == _markupinfoid
1748
                                           orderby version.CREATE_DATE descending
1749
                                           select version).First();
1750
                    markupdata = (from data in Entity.MARKUP_DATA
1751
                                  where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo
1752
                                  select data.DATA).ToList();
1753
                }
1754
            }
1755
            catch (Exception)
1756
            {
1757
                return null;
1758
            }
1759
            return markupdata;
1760
        }
1761

    
1762
        [OperationContract]
1763
        public List<MarkupKeyValue> GetMarkupDataForPage(string project_no, string _markupinfoid, int _pageNo)
1764
        {
1765
            List<MarkupKeyValue> markupdata = new List<MarkupKeyValue>();
1766

    
1767
            MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1768
            try
1769
            {
1770
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1771
                {
1772
                    markup_info_version = (from version in Entity.MARKUP_INFO_VERSION
1773
                                           where version.MARKUPINFO_ID == _markupinfoid
1774
                                           orderby version.CREATE_DATE descending
1775
                                           select version).First();
1776

    
1777
                    markupdata = (from data in Entity.MARKUP_DATA
1778
                                  where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo
1779
                                  select new MarkupKeyValue { ID = data.ID, Data = data.DATA }).ToList();
1780
                }
1781
            }
1782
            catch (Exception)
1783
            {
1784
                return null;
1785
            }
1786
            return markupdata;
1787
        }
1788

    
1789
        [OperationContract]
1790
        public bool AddMarkupInfo(string project_no, MARKUP_INFO value)
1791
        {
1792
            try
1793
            {
1794
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1795
                {
1796
                    Entity.MARKUP_INFO.AddObject(value);
1797
                    Entity.SaveChanges();
1798
                }
1799
            }
1800
            catch (Exception)
1801
            {
1802
                return false;
1803
            }
1804
            return true;
1805
        }
1806

    
1807
        [OperationContract]
1808
        public bool AddMarkupInfoVersion(string project_no, MARKUP_INFO_VERSION value)
1809
        {
1810
            try
1811
            {
1812
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1813
                {
1814
                    Entity.MARKUP_INFO_VERSION.AddObject(value);
1815
                    Entity.SaveChanges();
1816
                }
1817
            }
1818
            catch (Exception)
1819
            {
1820
                return false;
1821
            }
1822
            return true;
1823
        }
1824

    
1825
        [OperationContract]
1826
        public bool AddMarkupData(string project_no, MARKUP_DATA value)
1827
        {
1828
            try
1829
            {
1830
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1831
                {
1832
                    Entity.MARKUP_DATA.AddObject(value);
1833
                    Entity.SaveChanges();
1834
                }
1835
            }
1836
            catch (Exception)
1837
            {
1838
                return false;
1839
            }
1840
            return true;
1841
        }
1842

    
1843
        [OperationContract]
1844
        public bool AvoidMarkupInfo(string project_no, string _doc_id)
1845
        {
1846
            try
1847
            {
1848
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1849
                {
1850
                    var item = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1851
                    item.AVOID_CONSOLIDATE = 1;
1852
                    Entity.SaveChanges();
1853
                }
1854
            }
1855
            catch (Exception)
1856
            {
1857
                return false;
1858
            }
1859
            return true;
1860
        }
1861

    
1862
        [OperationContract]
1863
        public bool SaveMarkupInfo(string project_no, string _id, MARKUP_INFO value)
1864
        {
1865
            try
1866
            {
1867
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1868
                {
1869
                    var item = Entity.MARKUP_INFO.Where(info => info.ID == _id).FirstOrDefault();
1870
                    item = value;                    
1871
                    Entity.SaveChanges();
1872
                }
1873
            }
1874
            catch (Exception)
1875
            {
1876
                return false;
1877
            }
1878
            return true;
1879
        }
1880
        [OperationContract]
1881
        public List<MARKUP_DATA> GetMarkupDataList(string project_no, string _versionid)
1882
        {
1883
            List<MARKUP_DATA> mlresult = new List<MARKUP_DATA>();
1884

    
1885
            try
1886
            {
1887
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1888
                {
1889
                    mlresult = Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == _versionid).ToList();
1890
                }
1891
            }
1892
            catch (Exception)
1893
            {
1894
                return null;
1895
            }
1896
            return mlresult;
1897
        }
1898

    
1899
        [OperationContract]
1900
        public bool Consolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
1901
        {
1902
            try
1903
            {
1904
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1905
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1906
                {
1907
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.CONSOLIDATE == 1).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1908
                    if (markupInfo != null)
1909
                    {
1910
                        markupInfo.AVOID_CONSOLIDATE = 1;
1911
                    }
1912

    
1913
                    foreach (MarkupInfoItem item in markupInfoItems)
1914
                    {
1915
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1916
                        {
1917
                            instanceDataSet.Add(d);
1918
                        });
1919
                    }
1920

    
1921
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1922
                    info.ID = shortGuid();
1923
                    info.CONSOLIDATE = 1;
1924
                    info.CREATE_TIME = DateTime.Now;
1925
                    info.DOCINFO_ID = _doc_id;
1926
                    info.UPDATE_TIME = DateTime.Now;
1927
                    info.USER_ID = _user_id;
1928
                    info.AVOID_CONSOLIDATE = 0;
1929

    
1930
                    Entity.MARKUP_INFO.AddObject(info);
1931
                    Entity.SaveChanges();
1932

    
1933

    
1934
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1935
                    {
1936
                        ID = shortGuid(),
1937
                        CREATE_DATE = DateTime.Now,
1938
                        MARKUP_INFO = info,
1939
                    };
1940
                    Entity.SaveChanges();
1941

    
1942
                    foreach (var item in instanceDataSet)
1943
                    {
1944
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1945
                        {
1946
                            ID = shortGuid(),
1947
                            DATA = item.DATA,
1948
                            DATA_TYPE = item.DATA_TYPE,
1949
                            PAGENUMBER = item.PAGENUMBER,
1950
                            MARKUP_INFO_VERSION = info2,
1951
                            SYMBOL_ID = item.SYMBOL_ID,
1952
                            //GROUP_ID = item.GROUP_ID
1953
                        });
1954
                    }
1955
                    Entity.SaveChanges();
1956

    
1957

    
1958
                }
1959
            }
1960
            catch (Exception)
1961
            {
1962
                return false;
1963
            }
1964
            return true;
1965
        }
1966

    
1967

    
1968
        [OperationContract]
1969
        public FinalPDFResult ConsolidateMergedPDF(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems, string ProjectNo, string DocInfoID, string CreateUserID)
1970
        {
1971
            bool consolidate = false;
1972
            try
1973
            {
1974
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1975
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
1976
                {
1977
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1978
                    if (markupInfo.CONSOLIDATE == 1)
1979
                    {
1980
                        markupInfo.AVOID_CONSOLIDATE = 1;
1981
                    }
1982

    
1983
                    foreach (MarkupInfoItem item in markupInfoItems)
1984
                    {
1985
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1986
                        {
1987
                            instanceDataSet.Add(d);
1988
                        });
1989
                    }
1990

    
1991
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1992
                    info.ID = shortGuid();
1993
                    info.CONSOLIDATE = 1;
1994
                    info.CREATE_TIME = DateTime.Now;
1995
                    info.DOCINFO_ID = _doc_id;
1996
                    info.UPDATE_TIME = DateTime.Now;
1997
                    info.USER_ID = _user_id;
1998
                    info.AVOID_CONSOLIDATE = 0;
1999

    
2000
                    Entity.MARKUP_INFO.AddObject(info);
2001
                    Entity.SaveChanges();
2002

    
2003

    
2004
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2005
                    {
2006
                        ID = shortGuid(),
2007
                        CREATE_DATE = DateTime.Now,
2008
                        MARKUP_INFO = info,
2009
                    };
2010
                    Entity.SaveChanges();
2011

    
2012
                    foreach (var item in instanceDataSet)
2013
                    {
2014
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2015
                        {
2016
                            ID = shortGuid(),
2017
                            DATA = item.DATA,
2018
                            DATA_TYPE = item.DATA_TYPE,
2019
                            PAGENUMBER = item.PAGENUMBER,
2020
                            MARKUP_INFO_VERSION = info2,
2021
                            SYMBOL_ID = item.SYMBOL_ID,
2022
                            //GROUP_ID = item.GROUP_ID
2023
                        });
2024
                    }
2025
                    Entity.SaveChanges();
2026

    
2027

    
2028
                }
2029
                consolidate = true;
2030
            }
2031
            catch (Exception)
2032
            {
2033
                consolidate = false;
2034
            }
2035
            FinalPDFResult _result = new FinalPDFResult();
2036
            if (consolidate == true)
2037
            {
2038
                RemFinalPDFObject remObj = null;
2039
                try
2040
                {
2041
                    string _finalID = shortGuid();
2042
                    int _DocTotalPages = -1;
2043
                    string docItemId;
2044

    
2045

    
2046
                    using (CIEntities _ci = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
2047
                    {
2048
                        var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
2049

    
2050
                        if (_doc.Count() > 0)
2051
                        {
2052
                            _DocTotalPages = _doc.First().PAGE_COUNT;
2053
                            docItemId = _doc.First().DOCUMENT_ID;
2054
                        }
2055
                        else
2056
                        {
2057
                            _result.Status = FinalStatus.Error;
2058
                            _result.Exception = "페이지 정보를 가져올 수 없습니다.";
2059
                            return _result;
2060
                        }
2061
                    }
2062

    
2063
                    var Items = GetMarkupInfoItems(ProjectNo, DocInfoID);
2064
                    if (_DocTotalPages > 0)
2065
                    {
2066
                        var item2 = Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
2067
                        FINAL_PDF fm = new FINAL_PDF()
2068
                        {
2069
                            ID = _finalID,
2070
                            PROJECT_NO = ProjectNo,
2071
                            DOCINFO_ID = DocInfoID,
2072
                            DOCUMENT_ID = docItemId,
2073
                            MARKUPINFO_ID = item2.MarkupInfoID,
2074
                            CREATE_USER_ID = CreateUserID,
2075
                            TOTAL_PAGE = _DocTotalPages,
2076
                            CREATE_DATETIME = DateTime.Now,
2077
                            STATUS = (int)IFinalPDF.FinalStatus.Insert
2078
                        };
2079
                        using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2080
                        {
2081
                            _entity.AddToFINAL_PDF(fm);
2082
                            _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
2083
                        };
2084

    
2085
                        System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
2086
                        if (_ch == null)
2087
                        {
2088
                            chan = new TcpChannel();
2089
                            _ChanID = chan.ChannelName;
2090
                            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
2091
                            // Create an instance of the remote object
2092

    
2093

    
2094
                            using (KCOMEntities ec = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2095
                            {
2096

    
2097
                                //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2098
                                //                          "tcp://localhost:9092/remFinalPDF");
2099
                                remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2100
                                                          //"tcp://192.168.0.67:9092/remFinalPDF");
2101
                                                          "tcp://192.168.0.67:9092/remFinalPDF");
2102
                            }
2103

    
2104
                            //"tcp://localhost:8080/remFinalPDF");
2105

    
2106
                            _result = remObj.SetFinalPDF(ProjectNo, _finalID);
2107
                            _result.FinalID = _finalID;
2108
                            _result.Status = FinalStatus.Success;
2109

    
2110
                            //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
2111
                            //fa.MakeFinalPDF(fm);
2112
                        }
2113
                        else
2114
                        {
2115
                            _ChanID = _ch.ChannelName;
2116
                        }
2117
                    }
2118
                }
2119
                catch (Exception ex)
2120
                {
2121
                    _result.Status = FinalStatus.Error;
2122

    
2123
                    if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
2124
                        _result.Exception = "Final Server Not Connection";
2125
                }
2126
                finally
2127
                {
2128
                    remObj = null;
2129
                    if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
2130
                        System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
2131

    
2132
                    GC.Collect(2);
2133
                }
2134
            }
2135
            return _result;
2136
        }
2137
        [OperationContract]
2138
        public bool TeamConsolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
2139
        {
2140
            try
2141
            {
2142
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
2143
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2144
                {
2145
                    string user_dept = Entity.MEMBER.Where(m => m.ID == _user_id).FirstOrDefault().DEPARTMENT;
2146
                    var markupInfos = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id
2147
                    && entity.PART_CONSOLIDATE == 1
2148
                    ).OrderByDescending(j => j.CREATE_TIME).ToList();
2149
                    foreach (var markupinfo in markupInfos)
2150
                    {
2151
                        string markupdept = Entity.MEMBER.Where(m => m.ID == markupinfo.USER_ID).FirstOrDefault().DEPARTMENT;
2152
                        if (user_dept == markupdept)
2153
                        {
2154
                            markupinfo.AVOID_CONSOLIDATE = 1;
2155
                        }
2156
                    }
2157

    
2158
                    foreach (MarkupInfoItem item in markupInfoItems)
2159
                    {
2160
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2161
                        {
2162
                            instanceDataSet.Add(d);
2163
                        });
2164
                    }
2165

    
2166
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2167
                    info.ID = shortGuid();
2168
                    info.PART_CONSOLIDATE = 1;
2169
                    info.CREATE_TIME = DateTime.Now;
2170
                    info.DOCINFO_ID = _doc_id;
2171
                    info.UPDATE_TIME = DateTime.Now;
2172
                    info.USER_ID = _user_id;
2173
                    info.AVOID_CONSOLIDATE = 0;
2174

    
2175
                    Entity.MARKUP_INFO.AddObject(info);
2176
                    Entity.SaveChanges();
2177

    
2178

    
2179
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2180
                    {
2181
                        ID = shortGuid(),
2182
                        CREATE_DATE = DateTime.Now,
2183
                        MARKUP_INFO = info,
2184
                    };
2185
                    Entity.SaveChanges();
2186

    
2187
                    foreach (var item in instanceDataSet)
2188
                    {
2189
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2190
                        {
2191
                            ID = shortGuid(),
2192
                            DATA = item.DATA,
2193
                            DATA_TYPE = item.DATA_TYPE,
2194
                            PAGENUMBER = item.PAGENUMBER,
2195
                            MARKUP_INFO_VERSION = info2,
2196
                            SYMBOL_ID = item.SYMBOL_ID,
2197
                            //GROUP_ID = item.GROUP_ID
2198
                        });
2199
                    }
2200
                    Entity.SaveChanges();
2201

    
2202

    
2203
                }
2204
            }
2205
            catch (Exception)
2206
            {
2207
                return false;
2208
            }
2209
            return true;
2210
        }
2211

    
2212
        [OperationContract]
2213
        [ServiceKnownType(typeof(MEMBER))]
2214
        public MEMBER GetMember(string project_no, string user_id)
2215
        {
2216
            MEMBER rstmember = new MEMBER();
2217
            try
2218
            {
2219
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2220
                {
2221
                    var tmp = (from member in Entity.MEMBER
2222
                                    where member.ID == user_id && member.PROJECT_NO == project_no
2223
                                    select member).FirstOrDefault();
2224
                    rstmember.DEPARTMENT = tmp.DEPARTMENT;
2225
                    rstmember.ID = tmp.ID;
2226
                    rstmember.NAME = tmp.NAME;
2227
                }
2228
            }
2229
            catch (Exception)
2230
            {
2231
                return null;
2232
            }
2233
            return rstmember;
2234
        }
2235

    
2236
        [OperationContract]
2237
        public List<SYMBOL_PRIVATE> GetSymbolList(string user_id)
2238
        {
2239
            List<SYMBOL_PRIVATE> Custom_List = new List<SYMBOL_PRIVATE>();
2240

    
2241
            try
2242
            {
2243
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2244
                {
2245
                    Custom_List = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == user_id).ToList();
2246
                }
2247
            }
2248
            catch (Exception)
2249
            {
2250
                return null;
2251
            }
2252
            return Custom_List;
2253
        }
2254
        [OperationContract]
2255
        public List<string> GetPublicSymbolDeptList()
2256
        {
2257
            List<string> Custom_List = new List<string>();
2258
            try
2259
            {
2260
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2261
                {
2262
                    Custom_List = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).Distinct().ToList();
2263
                }
2264
            }
2265
            catch (Exception)
2266
            {
2267
                return null;
2268
            }
2269
            return Custom_List;
2270
        }
2271
        [OperationContract]
2272
        public List<SYMBOL_PUBLIC> GetPublicSymbolList(string dept)
2273
        {
2274
            List<SYMBOL_PUBLIC> Custom_List = new List<SYMBOL_PUBLIC>();
2275
            try
2276
            {
2277
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2278
                {
2279
                    if(!string.IsNullOrEmpty(dept))
2280
                    {
2281
                        Custom_List = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == dept).ToList();
2282
                    }
2283
                    else
2284
                    {
2285
                        Custom_List = Entity.SYMBOL_PUBLIC.ToList();
2286
                    }
2287
                    
2288
                }
2289
            }
2290
            catch (Exception)
2291
            {
2292
                return null;
2293
            }
2294
            return Custom_List;
2295
        }
2296

    
2297
        /// <summary>
2298
        /// 
2299
        /// </summary>
2300
        /// <param name="id">symbol id</param>
2301
        /// <param name="type"> 0 : PRIVATE, 1 : PUBLIC</param>
2302
        /// <returns></returns>
2303
        [OperationContract]
2304
        public string GetSymbolData(string id, int type)
2305
        {
2306
            string result;
2307
            try
2308
            {
2309
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2310
                {
2311
                    if(type == 0)
2312
                    {
2313
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA;
2314
                    }
2315
                    else
2316
                    {
2317
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA;
2318
                    }
2319
                }
2320
            }
2321
            catch (Exception)
2322
            {
2323
                return null;
2324
            }
2325
            return result;
2326
        }
2327
        [OperationContract]
2328
        public string GetSymbolImageURL(string id, int type)
2329
        {
2330
            string result;
2331
            try
2332
            {
2333
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2334
                {
2335
                    if (type == 0)
2336
                    {
2337
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2338
                    }
2339
                    else
2340
                    {
2341
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2342
                    }
2343
                }
2344
            }
2345
            catch (Exception)
2346
            {
2347
                return null;
2348
            }
2349
            return result;
2350
        }
2351
        [OperationContract]
2352
        public string GetSignData(string project_no, string user_id)
2353
        {
2354
            string result = null;
2355
            try
2356
            {
2357
                string ifsign = getEnsembleSign(user_id);
2358
                if (string.IsNullOrEmpty(ifsign))
2359
                {
2360
                    var ModelWFConnectionString = ConnectStringBuilder.ProjectCIConnectString(project_no).ToString();
2361
                    if (null != ModelWFConnectionString)
2362
                    {
2363
                        using (CIEntities entity = new CIEntities(ModelWFConnectionString))
2364
                        {
2365
                            var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2366
                            if (_sign.Count() > 0)
2367
                            {
2368
                                result = _sign.First().SIGN_STR;
2369
                            }
2370
                            else
2371
                            {
2372
                                return null;
2373
                            }
2374
                        }
2375
                    }
2376
                }
2377
                else
2378
                {
2379
                    result = ifsign;
2380
                }
2381

    
2382
            }
2383
            catch (Exception)
2384
            {
2385
                return null;
2386
            }
2387
            return result;
2388
        }
2389

    
2390
        [OperationContract]        
2391
        public string GetProjectName(string project_no)
2392
        {
2393
            string result = null;
2394

    
2395
            try
2396
            {
2397
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
2398
                {
2399
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
2400
                }
2401
            }
2402
            catch (Exception)
2403
            {
2404
                return null;
2405
            }
2406
            return result;
2407
        }
2408

    
2409
        [OperationContract]
2410
        public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev)
2411
        {
2412
            List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>();
2413
            
2414
            try
2415
            {
2416
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2417
                {
2418
                    result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no
2419
                    && i.DOCUMENT_NO == doc_no
2420
                    && i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList();
2421
                }
2422
            }
2423
            catch (Exception)
2424
            {
2425
                return null;
2426
            }
2427
            return result;
2428
        }
2429

    
2430
        [OperationContract]
2431
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
2432
        {
2433
            DOCINFO docinfo = null;
2434

    
2435
            try
2436
            {
2437
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2438
                {
2439
                    docinfo = (from info in Entity.DOCINFO
2440
                              where info.DOCUMENT_ID == doc_id
2441
                              && info.PROJECT_NO == project_no
2442
                              select info).First();
2443
                }
2444
            }
2445
            catch (Exception)
2446
            {
2447
                return null;
2448
            }
2449
            return docinfo;
2450
        }
2451

    
2452
        [OperationContract]
2453
        public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList)
2454
        {
2455
            MarkupInfoItem _result = null;
2456
            List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>();
2457
            try
2458
            {
2459
                using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2460
                {
2461
                    var docitem = (from info in Entity.DOCINFO
2462
                               where info.DOCUMENT_ID == doc_id
2463
                               && info.PROJECT_NO == project_no
2464
                               select info).First();
2465

    
2466
                    foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO)
2467
                    {
2468
                        var member = (from mem in Entity.MEMBER
2469
                                     where mem.ID == markinfo.USER_ID
2470
                                     select mem).First();
2471
                        string displaycolor = null;
2472
                        try
2473
                        {
2474
                            displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor;
2475
                        }
2476
                        catch(Exception)
2477
                        {
2478
                            displaycolor = "#FFFFFF";
2479
                        }
2480
                        
2481
                        _result = new MarkupInfoItem
2482
                        {
2483
                            MarkupInfoID = markinfo.ID,
2484
                            Consolidate = markinfo.CONSOLIDATE,
2485
                            CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME,
2486
                            DisplayColor = displaycolor,
2487
                            UserID = markinfo.USER_ID,
2488
                            UserName = member.NAME,
2489
                            Depatment = member.DEPARTMENT,
2490
                        };
2491

    
2492
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
2493
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
2494

    
2495
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
2496
                        {
2497
                            MarkupItem markitem = new MarkupItem()
2498
                            {
2499
                                ID = markdata.ID,
2500
                                PageNumber = markdata.PAGENUMBER,
2501
                            };
2502
                            _result.MarkupList.Add(markitem);
2503
                        }
2504

    
2505
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
2506

    
2507
                        markupinfo.Add(_result);
2508
                    }
2509
                }
2510
            }
2511
            catch (Exception)
2512
            {
2513
                return null;
2514
            }
2515
            return markupinfo;
2516
        }
2517

    
2518
        [OperationContract]
2519
        public bool AddMessage(string project_no, TALK value)
2520
        {
2521
            try
2522
            {
2523
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2524
                {                    
2525
                    entity.TALK.AddObject(value);
2526
                    entity.SaveChanges();
2527
                }
2528
            }
2529
            catch (Exception)
2530
            {
2531
                return false;
2532
            }
2533
            return true;
2534
        }
2535

    
2536
        [OperationContract]
2537
        public List<TALK> GetMessage(string project_no, string doc_id)
2538
        {
2539
            List<TALK> result = new List<TALK>();
2540
            try
2541
            {
2542
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2543
                {
2544
                    result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList();                        
2545
                }
2546
            }
2547
            catch (Exception)
2548
            {
2549
                return result;
2550
            }
2551
            return result;
2552
        }
2553

    
2554

    
2555
        #region Legacy System I/F
2556
        /// <summary>
2557
        /// Ensemble+ Sign Data Return
2558
        /// </summary>
2559
        /// <param name="user_id"></param>
2560
        /// <returns></returns>
2561
        private string getEnsembleSign(string user_id)
2562
        {
2563
            string result = string.Empty;
2564
            string soapurl = string.Empty;
2565
            try
2566
            {
2567
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2568
                {
2569
                    var item = Entity.PROPERTIES.Where(d => d.TYPE == "UpLoadServiceUrl").FirstOrDefault();
2570
                    soapurl = item.VALUE;
2571
                }
2572
                WebClient webClient = new WebClient();
2573
                string data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ens=\"http://EnsemblePlus.Webservice\"> <soapenv:Header/> <soapenv:Body> <ens:checkoutSignImage>"
2574
                    + "<ens:sUserNo>" + user_id + "</ens:sUserNo>"
2575
                    + "</ens:checkoutSignImage> </soapenv:Body></soapenv:Envelope>";
2576
                webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
2577
                webClient.Headers.Add("SOAPAction", "http://EnsemblePlus.Webservice");
2578
                var _result = webClient.UploadString(new Uri(soapurl), data);
2579
                XmlDocument xmlDoc = new XmlDocument();
2580
                xmlDoc.LoadXml(_result);
2581
                XmlNodeList list = xmlDoc.GetElementsByTagName("checkoutSignImageResponse");
2582
                foreach (XmlNode xn in list)
2583
                {
2584
                    result = xn["checkoutSignImageReturn"].InnerText;
2585
                }
2586
                if (!result.Contains("No business object"))
2587
                {
2588
                    return result;
2589
                }
2590
                else
2591
                {
2592
                    return null;
2593
                }
2594
            }
2595
            catch (Exception ex)
2596
            {
2597
                return null;
2598
            }
2599

    
2600

    
2601
        }
2602
        #endregion
2603

    
2604
        #region Final Service
2605
        [OperationContract]
2606
        [ServiceKnownType(typeof(DOCINFO))]                
2607
        public DOCINFO FinalPDF_GetDocinfo(string project_no, string docinfo_id)
2608
        {
2609
            DOCINFO docinfo = null;
2610

    
2611
            try
2612
            {
2613
                using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2614
                {
2615
                    var doc = _entity.DOCINFO.Where(x => x.ID == docinfo_id).FirstOrDefault();
2616
                    if(doc != null)
2617
                    {
2618
                        docinfo = new DOCINFO()
2619
                        {
2620
                            ID = doc.ID,
2621
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2622
                            PAGE_COUNT = doc.PAGE_COUNT,
2623
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2624
                            PROJECT_NO = doc.PROJECT_NO
2625
                        };
2626
                    }                    
2627
                }
2628
            }
2629
            catch (Exception)
2630
            {
2631
                throw;
2632
            }
2633
            return docinfo;
2634
        }
2635
        [OperationContract]
2636
        [ServiceKnownType(typeof(DOCUMENT_ITEM))]
2637
        public DOCUMENT_ITEM FinalPDF_GetDocumentItem(string project_no, string document_id)
2638
        {
2639
            DOCUMENT_ITEM item = null;
2640

    
2641
            try
2642
            {
2643
                using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2644
                {
2645
                    var doc = _entity.DOCUMENT_ITEM.Where(x => x.DOCUMENT_ID == document_id).FirstOrDefault();
2646
                    if(doc != null)
2647
                    {
2648
                        item = new DOCUMENT_ITEM()
2649
                        {
2650
                            ID = doc.ID,
2651
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2652
                            PROJECT_NO = doc.PROJECT_NO,
2653
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2654
                            DOCUMENT_NO = doc.DOCUMENT_NO,
2655
                            DOCUMENT_NAME = doc.DOCUMENT_NAME,
2656
                            ENSEMBLEINFO_URL = doc.ENSEMBLEINFO_URL,
2657
                            GROUP_NO = doc.GROUP_NO,
2658
                            RESULT = doc.RESULT,
2659
                            REVISION = doc.REVISION,
2660
                            RESULT_FILE = doc.RESULT_FILE
2661
                        };
2662
                    }
2663
                    
2664
                }
2665
            }
2666
            catch (Exception)
2667
            {
2668
                throw;
2669
            }
2670
            return item;
2671
        }
2672
        [OperationContract]
2673
        [ServiceKnownType(typeof(MARKUP_DATA))]
2674
        public List<MARKUP_DATA> FinalPDF_GetMarkupdata(string project_no, string docinfo_id)
2675
        {
2676
            List<MARKUP_DATA> results = new List<MARKUP_DATA>();
2677

    
2678
            try
2679
            {
2680
                //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2681
                using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2682
                {
2683
                    var datas = _entity.MARKUP_DATA.Where(x => x.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO_ID == docinfo_id
2684
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1
2685
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.AVOID_CONSOLIDATE == 0
2686
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.PART_CONSOLIDATE == 0).ToList();
2687
                    foreach (var data in datas)
2688
                    {
2689
                        MARKUP_DATA d = new MARKUP_DATA()
2690
                        {
2691
                            ID = data.ID,
2692
                            //GROUP_ID = data.GROUP_ID,
2693
                            SYMBOL_ID = data.SYMBOL_ID,
2694
                            DATA = data.DATA,
2695
                            DATA_TYPE = data.DATA_TYPE,
2696
                            MARKUPINFO_VERSION_ID = data.MARKUPINFO_VERSION_ID,
2697
                            PAGENUMBER = data.PAGENUMBER
2698
                        };
2699
                        results.Add(d);
2700
                    }
2701
                }
2702
            }
2703
            catch (Exception)
2704
            {
2705
                throw;
2706
            }
2707
            return results;
2708
        }
2709
        [OperationContract]
2710
        [ServiceKnownType(typeof(MARKUP_INFO))]
2711
        public MARKUP_INFO FinalPDF_GetMarkupinfo(string project_no, string docinfo_id)
2712
        {
2713
            MARKUP_INFO markupInfo = null;
2714

    
2715
            try
2716
            {
2717
                using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2718
                {
2719
                    var tmp = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo_id && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0).FirstOrDefault();
2720
                    if (tmp != null)
2721
                    {
2722
                        markupInfo = new MARKUP_INFO()
2723
                        {
2724
                            ID = tmp.ID,
2725
                            DOCINFO_ID = tmp.DOCINFO_ID,
2726
                            USER_ID = tmp.USER_ID
2727
                        };
2728
                    }                    
2729
                }
2730
            }
2731
            catch (Exception)
2732
            {
2733
                throw;
2734
            }
2735
            return markupInfo;
2736
        }
2737
        [OperationContract]
2738
        [ServiceKnownType(typeof(FINAL_PDF))]
2739
        public List<FINAL_PDF> FinalPDF_GetFinalPDFs(string final_id)
2740
        {
2741
            List<FINAL_PDF> results = new List<FINAL_PDF>();
2742

    
2743
            try
2744
            {
2745
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2746
                {
2747
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == final_id).ToList();
2748
                    foreach(var final in finalList)
2749
                    {
2750
                        FINAL_PDF pdf = new FINAL_PDF()
2751
                        {
2752
                            ID = final.ID,
2753
                            DOCINFO_ID = final.DOCINFO_ID,
2754
                            DOCUMENT_ID = final.DOCUMENT_ID,
2755
                            STATUS = final.STATUS,
2756
                            CURRENT_PAGE = final.CURRENT_PAGE,
2757
                            CREATE_DATETIME = final.CREATE_DATETIME,
2758
                            START_DATETIME = final.START_DATETIME,
2759
                            END_DATETIME = final.END_DATETIME,
2760
                            EXCEPTION = final.EXCEPTION,
2761
                            PROJECT_NO = final.PROJECT_NO,
2762
                            TOTAL_PAGE = final.TOTAL_PAGE,
2763
                            MARKUPINFO_ID = final.MARKUPINFO_ID,
2764
                            CREATE_USER_ID = final.CREATE_USER_ID
2765
                        };
2766
                        results.Add(pdf);
2767
                    }
2768
                }
2769
            }
2770
            catch (Exception)
2771
            {
2772
                throw;
2773
            }
2774
            return results;
2775
        }
2776
        [OperationContract]
2777
        [ServiceKnownType(typeof(DOCPAGE))]
2778
        public List<DOCPAGE> FinalPDF_GetDocpage(string project_no, string docinfo_id)
2779
        {
2780
            List<DOCPAGE> results = new List<DOCPAGE>();
2781

    
2782
            try
2783
            {
2784
                using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2785
                {
2786
                    var pages = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == docinfo_id).OrderBy(x => x.PAGE_NUMBER).ToList();
2787
                    foreach(var page in pages)
2788
                    {
2789
                        DOCPAGE p = new DOCPAGE()
2790
                        {
2791
                            PAGE_ANGLE = page.PAGE_ANGLE,
2792
                            PAGE_NUMBER = page.PAGE_NUMBER,
2793
                            PAGE_HEIGHT = page.PAGE_HEIGHT,
2794
                            PAGE_WIDTH = page.PAGE_WIDTH,
2795
                            DOCINFO_ID = page.DOCINFO_ID                            
2796
                        };
2797
                        results.Add(p);
2798
                    }                    
2799
                }
2800
            }
2801
            catch (Exception)
2802
            {
2803
                throw;
2804
            }
2805
            return results;
2806
        }
2807
        [OperationContract]        
2808
        public bool FinalPDF_SetFinalPDFStatus(string final_id, FinalStatus status)
2809
        {
2810
            bool result = false;
2811

    
2812
            try
2813
            {
2814
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2815
                {
2816
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2817
                    if(tmp != null)
2818
                    {
2819
                        switch(status)
2820
                        {
2821
                            case FinalStatus.Create:
2822
                                tmp.START_DATETIME = DateTime.Now;
2823
                                break;
2824
                            case FinalStatus.Success:
2825
                                tmp.END_DATETIME = DateTime.Now;
2826
                                tmp.EXCEPTION = string.Empty;
2827
                                break;                                
2828
                        }
2829
                        tmp.STATUS = (int)status;
2830
                        _entity.SaveChanges();
2831
                        result = true;                        
2832
                    }
2833
                }                    
2834
            }
2835
            catch (Exception)
2836
            {
2837
                throw;
2838
            }
2839
            return result;
2840
        }
2841

    
2842
        /// <summary>
2843
        /// 현재 진행중인 Final PDF 가 없거나 Success 일 경우에만 true return
2844
        /// </summary>
2845
        /// <param name="DocInfoID"></param>
2846
        /// <param name="MarkupInfoID"></param>
2847
        /// <param name="CreateUserID"></param>
2848
        /// <returns></returns>
2849
        [OperationContract]
2850
        public bool FinalPDF_GetFinalPDFStatus(string DocInfoID, string MarkupInfoID, string CreateUserID)
2851
        {
2852
            bool result = false;
2853

    
2854
            try
2855
            {
2856
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2857
                {
2858
                    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();
2859
                    if (finalpdf != null)
2860
                    {
2861
                        if (finalpdf.STATUS == (int)FinalStatus.Success)
2862
                        {
2863
                            result = true;
2864
                        }
2865
                    }
2866
                    else
2867
                        result = true;
2868
                }
2869
            }
2870
            catch (Exception)
2871
            {
2872
                throw;
2873
            }
2874
            return result;
2875
        }
2876

    
2877
        [OperationContract]
2878
        public bool FinalPDF_SetCurrentPage(string final_id, int currentpage)
2879
        {
2880
            bool result = false;
2881

    
2882
            try
2883
            {
2884
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2885
                {
2886
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2887
                    if (tmp != null)
2888
                    {
2889
                        tmp.CURRENT_PAGE = currentpage;
2890
                        _entity.SaveChanges();
2891
                        result = true;
2892
                    }
2893
                }
2894
            }
2895
            catch (Exception)
2896
            {
2897
                throw;
2898
            }
2899
            return result;
2900
        }
2901
        [OperationContract]
2902
        public bool FinalPDF_SetError(string final_id, string msg)
2903
        {
2904
            bool result = false;
2905

    
2906
            try
2907
            {
2908
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
2909
                {
2910
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2911
                    if (tmp != null)
2912
                    {                        
2913
                        tmp.STATUS = (int)FinalStatus.Error;
2914
                        tmp.EXCEPTION = DateTime.Now.ToShortDateString() + " " + msg;                        
2915
                        _entity.SaveChanges();
2916
                        result = true;
2917
                    }
2918
                }
2919
            }
2920
            catch (Exception)
2921
            {
2922
                throw;
2923
            }
2924
            return result;
2925
        }
2926

    
2927
        [OperationContract]
2928
        public bool FinalPDF_SetFinalResultPath(string project_no, string document_id, string url)
2929
        {
2930
            bool result = false;
2931

    
2932
            try
2933
            {
2934
                using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2935
                {
2936
                    var item = _entity.DOCUMENT_ITEM.Where(d => d.DOCUMENT_ID == document_id).FirstOrDefault();
2937
                    if (item != null)
2938
                    {
2939
                        item.RESULT_FILE = url;
2940
                        _entity.SaveChanges();
2941
                        result = true;
2942
                    }
2943
                }
2944
            }
2945
            catch (Exception)
2946
            {
2947
                throw;
2948
            }
2949
            return result;
2950
        }
2951
        [OperationContract]
2952
        [ServiceKnownType(typeof(MEMBER))]
2953
        public MEMBER FinalPDF_GetCommentMember(string project_no, string markupdata_id)
2954
        {
2955
            MEMBER member = null;
2956
            try
2957
            {
2958
                using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2959
                {
2960
                    var data = _entity.MARKUP_DATA.Where(x => x.ID == markupdata_id).FirstOrDefault();
2961
                    string user_id = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
2962
                    var person = _entity.MEMBER.Where(p => p.ID == user_id).FirstOrDefault();
2963
                    if(person != null)
2964
                    {
2965
                        member = new MEMBER()
2966
                        {
2967
                            ID = user_id,
2968
                            NAME = person.NAME,
2969
                            DEPARTMENT = person.DEPARTMENT
2970
                        };
2971
                    }
2972
                }
2973
            }
2974
            catch (Exception)
2975
            {
2976
                throw;
2977
            }
2978
            return member;
2979
        }
2980

    
2981
        [OperationContract]
2982
        [ServiceKnownType(typeof(PROPERTIES))]
2983
        public List<PROPERTIES> FinalPDF_GetProperties(string project_no)
2984
        {
2985
            List<PROPERTIES> results = new List<PROPERTIES>();
2986
            try
2987
            {
2988
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
2989
                {
2990
                    var _items = _entity.PROPERTIES.Where(x => x.PROPERTY == project_no).ToList();
2991
                    foreach(var item in _items)
2992
                    {
2993
                        PROPERTIES pROPERTIES = new PROPERTIES()
2994
                        {
2995
                            ID = item.ID,
2996
                            PROPERTY = item.PROPERTY,
2997
                            TYPE = item.TYPE,
2998
                            VALUE = item.VALUE
2999
                        };
3000
                        results.Add(pROPERTIES);
3001
                    }
3002
                }
3003

    
3004
            }
3005
            catch (Exception)
3006
            {
3007
                throw;
3008
            }
3009
            return results;
3010
        }
3011
        #endregion
3012
    }    
3013
}
클립보드 이미지 추가 (최대 크기: 500 MB)