프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ 9294fed6

이력 | 보기 | 이력해설 | 다운로드 (125 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.Configuration;
10
using System.Linq;
11
using System.Net;
12
using System.Runtime.Remoting.Channels.Tcp;
13
using System.Runtime.Serialization;
14
using System.ServiceModel;
15
using System.ServiceModel.Activation;
16
using System.Text;
17
using System.Web.Services;
18
using System.Windows;
19
using System.Xml;
20

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

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

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

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

    
87
                    KCOM_SystemInfo sysInfo = new KCOM_SystemInfo();
88

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

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

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

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

    
124
            var guid = new Guid(bytes);
125

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

    
132

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

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

    
145

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

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

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

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

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

    
174
                        dc.SaveChanges();
175

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

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

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

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

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

    
236
            string sFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID);
237
            if (Boolean.Parse(isInternalAddress))
238
            {
239
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, originDocItem_ID, originPageNo);
240
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, targetDocItem_ID, targetPageNo);
241
            }
242
            else
243
            {
244
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  originDocItem_ID, originPageNo);
245
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  targetDocItem_ID, targetPageNo);
246
            }
247

    
248
            CompareLib compareLib = new CompareLib();
249

    
250
            var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
251
            var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
252

    
253
            string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
254
            var result = compareLib.GetBoundBoxInImage(outPutFile);
255

    
256
            return result;
257
        }
258

    
259

    
260
        #region Final PDF
261
        private string _ChanID = null;
262
        TcpChannel chan = null;
263
        [OperationContract]
264
        public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUserID)
265
        {
266
            #region 임시보관
267
            #endregion
268
            FinalPDFResult _result = new FinalPDFResult();
269
            RemFinalPDFObject remObj = null;
270
            try
271
            {
272
                string _finalID = shortGuid();
273
                int _DocTotalPages = -1;
274
                string docItemId;
275

    
276
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
277
                using (CIEntities _ci = new CIEntities(sCIConnString))
278
                {
279
                    var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
280

    
281
                    if (_doc.Count() > 0)
282
                    {
283
                        _DocTotalPages = _doc.First().PAGE_COUNT;
284
                        docItemId = _doc.First().DOCUMENT_ID;
285
                    }
286
                    else
287
                    {
288
                        _result.Status = FinalStatus.Error;
289
                        _result.Exception = "페이지 정보를 가져올 수 없습니다.";
290
                        return _result;
291
                    }
292
                }
293
                if (_DocTotalPages > 0)
294
                {
295
                    FINAL_PDF fm = new FINAL_PDF()
296
                    {
297
                        ID = _finalID,
298
                        PROJECT_NO = ProjectNo,
299
                        DOCINFO_ID = DocInfoID,
300
                        DOCUMENT_ID = docItemId,
301
                        MARKUPINFO_ID = MarkupInfoID,
302
                        CREATE_USER_ID = CreateUserID,
303
                        TOTAL_PAGE = _DocTotalPages,
304
                        CREATE_DATETIME = DateTime.Now,
305
                        STATUS = (int)IFinalPDF.FinalStatus.Insert
306
                    };
307

    
308
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
309
                    using (KCOMEntities _entity = new KCOMEntities(sConnString))
310
                    {
311
                        _entity.AddToFINAL_PDF(fm);
312
                        _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
313
                    };
314

    
315
                    System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
316
                    if (_ch == null)
317
                    {
318
                        chan = new TcpChannel();
319
                        _ChanID = chan.ChannelName;
320
                        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
321
                        // Create an instance of the remote object
322

    
323
                        using (KCOMEntities ec = new KCOMEntities(sConnString))
324
                        {
325

    
326
                            //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
327
                            //                          "tcp://localhost:9092/remFinalPDF");
328
                            remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
329
                                                      //"tcp://192.168.0.67:9092/remFinalPDF");
330
                                                      "tcp://localhost:9092/remFinalPDF");
331
                        }
332

    
333
                        //"tcp://localhost:8080/remFinalPDF");
334

    
335
                        _result = remObj.SetFinalPDF(ProjectNo, _finalID);
336
                        _result.FinalID = _finalID;
337
                        _result.Status = FinalStatus.Success;
338

    
339
                        //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
340
                        //fa.MakeFinalPDF(fm);
341
                    }
342
                    else
343
                    {
344
                        _ChanID = _ch.ChannelName;
345
                    }
346
                }
347
            }
348
            catch (Exception ex)
349
            {
350
                _result.Status = FinalStatus.Error;
351

    
352
                if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
353
                    _result.Exception = "Final Server Not Connection";
354
                else _result.Exception = ex.ToString();
355
            }
356
            finally
357
            {
358
                remObj = null;
359
                if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
360
                    System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
361

    
362
                GC.Collect(2);
363
            }
364
            return _result;
365
        }
366
        #endregion
367

    
368

    
369
        [OperationContract]
370
        public bool GetConversionState(KCOM_BasicParam param)
371
        {
372
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
373
            using (CIEntities entity = new CIEntities(sCIConnString))
374
            {
375
                var doc = entity.DOCINFO.Where(data => data.DOCUMENT_ID == param.documentID).FirstOrDefault();
376
                if (doc != null)
377
                {
378
                    var count = doc.DOCPAGE.Where(data => data.DOCINFO_ID == doc.ID).Count();
379
                    if (doc.PAGE_COUNT == count)  //페이지 수가 일치하는지
380
                    {
381
                        return true;
382
                    }
383
                    else //페이지 수가 일치하지 않는 경우
384
                    {
385
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
386
                        KCOMEntities entity_kcom = new KCOMEntities(sConnString);
387
                        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();
388

    
389
                        if (lst != null || lst.Count >= 1)
390
                        {
391
                            //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_PAGECOUNT"), param.documentID, param.projectNo);
392
                            //이메일 클라이언트를 구현해야함
393
                        }
394
                        return false;
395
                    }
396
                }
397
                else
398
                {
399
                    //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_CONVERTFAILED"), param.documentID, param.projectNo);
400
                    //이메일 클라이언트를 구현해야함
401
                    return false;
402
                }
403
            }
404
        }
405

    
406
        [OperationContract]
407
        public List<VPRevision> GetVPRevisionHistory(string ProjectNo, string vpNo, string DocumentId)
408
        {
409
            List<VPRevision> _result = new List<VPRevision>();
410
            try
411
            {
412
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
413
                using (CIEntities entity = new CIEntities(sCIConnString))
414
                {
415
                    var _vpList = (from docitem in entity.DOCUMENT_ITEM
416
                                   where docitem.DOCUMENT_NO == vpNo
417
                                   select new VPRevision
418
                                   {
419
                                       RevNo = docitem.REVISION,
420
                                       GroupNo = docitem.GROUP_NO,
421
                                       FROM_VENDOR = docitem.ORIGINAL_FILE,
422
                                       DOCUMENT_ID = docitem.DOCUMENT_ID,
423
                                       TO_VENDOR = docitem.RESULT_FILE,
424
                                       RESULT = docitem.RESULT,
425
                                       DocNo = docitem.DOCUMENT_NO,
426
                                       EnsembleLink = docitem.ENSEMBLEINFO_URL,
427
                                       //IsSyncPossible = docitem.DOCUMENT_ID == DocumentId ? false : entity.DOCINFO.Where(d => d.DOCUMENT_ID == docitem.DOCUMENT_ID).ToList().Count > 0 ? true : false
428
                                   });
429
                    _result = _vpList.ToList();
430
                    foreach (var vp in _result)
431
                    {
432
                        if (entity.DOCINFO.Where(d => d.DOCUMENT_ID == vp.DOCUMENT_ID).ToList().Count > 0)
433
                            vp.IsSyncPossible = true;
434
                        else
435
                            vp.IsSyncPossible = false;
436
                    }
437

    
438
                    //_result = _result.OrderByDescending(r => UInt64.Parse(System.Text.RegularExpressions.Regex.Replace(r.GroupNo, @"\D", ""))).ToList();
439
                    _result = _result.OrderByDescending(r => r.GroupNo).ToList();
440
                }
441
            }
442
            catch (Exception ex)
443
            {
444

    
445
                throw ex;
446
            }
447
            finally
448
            {
449
                GC.Collect(2);
450
            }
451
            return _result;
452
        }
453

    
454
        [OperationContract]
455
        public VPRevision GetVPRevisionFirstOrDefault(string ProjectNo, string DocumentId)
456
        {
457
            VPRevision _result = null;
458
            try
459
            {
460
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
461
                using (CIEntities entity = new CIEntities(sCIConnString))
462
                {
463
                    _result = (from docitem in entity.DOCUMENT_ITEM
464
                     where docitem.DOCUMENT_ID == DocumentId
465
                     select new VPRevision
466
                     {
467
                         RevNo = docitem.REVISION,
468
                         GroupNo = docitem.GROUP_NO,
469
                         FROM_VENDOR = docitem.ORIGINAL_FILE,
470
                         DOCUMENT_ID = docitem.DOCUMENT_ID,
471
                         TO_VENDOR = docitem.RESULT_FILE,
472
                         RESULT = docitem.RESULT
473
                     }).FirstOrDefault();
474
                }
475
            }
476
            catch (Exception)
477
            {
478
                throw;
479
            }
480
            finally
481
            {
482
                GC.Collect(2);
483
            }
484
            return _result;
485
        }
486

    
487
        [OperationContract]
488
        public DOCINFO GetDocInfo(KCOM_BasicParam param)
489
        {
490
            DOCINFO _result = null;
491
            try
492
            {
493
                // 차후 아래의 코드로 변경
494
                //using (CI_Entities ModelDeeview = new CI_Entities(DaelimCiConnectionString.ToString()))
495
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
496
                CIEntities ModelDeeview = new CIEntities(sCIConnString);
497

    
498
                var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID && doc.PROJECT_NO == param.projectNo);
499
                if (docinfo.Count() > 0)
500
                {
501
                    _result = docinfo.First();
502
                    _result.MARKUP_INFO.Clear();
503

    
504
                }
505
                return _result;
506

    
507
            }
508
            catch (Exception ex)
509
            {
510
                System.Diagnostics.Trace.WriteLine("GetDocInfo Error : " + ex);
511
            }
512
            finally
513
            {
514
                GC.Collect(2);
515
            }
516
            return null;
517
        }
518

    
519
        [OperationContract]
520
        public bool GetCheckSystemAdmin(string UserID)
521
        {
522
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
523
            using (KCOMEntities uc = new KCOMEntities(sConnString))
524
            {
525
                var user = uc.PROPERTIES.Where(data => data.TYPE == "Administrator" && data.PROPERTY.Contains(UserID)).FirstOrDefault();
526
                if (user != null)
527
                {
528
                    return true;
529
                }
530
                else
531
                {
532
                    return false;
533
                }
534
            }
535
            GC.Collect(2);
536
        }
537

    
538
        [OperationContract]
539
        public DOCUMENT_ITEM GetDocumentItemInfo(KCOM_BasicParam param)
540
        {
541
            ///param : prjNo, documentId, userId
542
            DOCUMENT_ITEM _result = null;
543

    
544
            try
545
            {
546
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
547
                CIEntities entity = new CIEntities(sCIConnString);
548

    
549
                var _items = entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == param.documentID);
550

    
551
                if (_items.Count() > 0)
552
                {
553
                    _result = _items.First();
554

    
555
                    return _result;
556
                }
557
                //else
558
                //{
559
                //    Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_DOCUMENTNOTFOUND"), param.documentID, param.projectNo);
560
                //}
561
            }
562
            catch (Exception ex)
563
            {
564
                System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex);
565
                _result = new DOCUMENT_ITEM { RESULT_FILE = ex.ToString() };
566
                //throw new FaultException(ex.ToString());
567
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
568
            }
569

    
570
            return _result;
571
        }
572
        /// <summary>
573
        /// DOCUMENT_ITEM Table 의 ID 로 Item 을 Select
574
        /// </summary>
575
        /// 대림의 경우 Interface ID(Document 의 ID) 를 parameter 로 전달
576
        /// 넘어온 ID를 통해 document id 를 확인하는 과정이 필요
577
        /// <param name="ensemble_id"></param>
578
        /// <returns></returns>
579
        [OperationContract]
580
        public string GetDocItemID(string ensemble_id)
581
        {
582
            ///param : prjNo, documentId, userId
583
            string _result = string.Empty;
584

    
585
            try
586
            {
587
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
588
                CIEntities entity = new CIEntities(sCIConnString);
589

    
590
                var _items = entity.DOCUMENT_ITEM.Where(data => data.ID == ensemble_id).FirstOrDefault();
591
                if(_items != null)
592
                    _result = _items.DOCUMENT_ID;
593
            }
594
            catch (Exception ex)
595
            {
596
                //System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex);
597
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
598
            }
599

    
600
            return _result;
601
        }
602
        public string UserGO(MARKUP_INFO item)
603
        {
604
            if (item != null)
605
            {
606
                return item.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID;
607
            }
608
            return null;
609
        }
610
        
611
        [OperationContract]
612
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
613
        {
614
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
615
            try
616
            {
617
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
618
                using (CIEntities entity = new CIEntities(sCIConnString))
619
                {
620
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
621

    
622
                    var markupList = from markup in markupListData
623
                                     orderby markup.CREATE_TIME descending
624
                                     select new MarkupInfoItem
625
                                     {
626
                                         MarkupInfoID = markup.ID,
627
                                         UserID = markup.USER_ID,
628
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
629
                                         CreateTime = markup.CREATE_TIME,
630
                                         Consolidate = markup.CONSOLIDATE,
631
                                         Description = markup.DESCRIPTION,
632
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
633
                                         PartConsolidate = markup.PART_CONSOLIDATE,
634
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
635
                                     };
636

    
637
                    if (markupList.Count() > 0)
638
                    {
639
                        _result = markupList.ToList();
640
                    }
641

    
642
                    _result.ForEach(r =>
643
                    {
644

    
645
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
646
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
647
                                        orderby markupData.PAGENUMBER
648
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList();
649
                    });
650

    
651
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
652
                    Random random = new Random();
653

    
654
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
655
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
656
                    {
657
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
658
                                             where property.TYPE == "DisplayColor"
659
                                             select property).ToList();
660
                    }                    
661

    
662
                    foreach (var item in _result)
663
                    {
664
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID && member.PROJECT_NO == ProjectNo).FirstOrDefault();
665
                        
666
                        if (_member != null)
667
                        {
668
                            item.UserName = _member.NAME;
669
                            item.Depatment = _member.DEPARTMENT;
670
                        }
671

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

    
698
            return _result;
699
        }
700

    
701

    
702
        /*
703
        [OperationContract]
704
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
705
        {
706
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
707
            try
708
            {
709
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
710
                {
711
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
712

    
713
                    var markupList = from markup in markupListData
714
                                     orderby markup.CREATE_TIME descending
715
                                     select new MarkupInfoItem
716
                                     {
717
                                         MarkupInfoID = markup.ID,
718
                                         UserID = markup.USER_ID,
719
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
720
                                         CreateTime = markup.CREATE_TIME,
721
                                         Consolidate = markup.CONSOLIDATE,
722
                                         Description = markup.DESCRIPTION,
723
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
724
                                         PartConsolidate = markup.PART_CONSOLIDATE,
725
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
726
                                     };
727

    
728
                    if (markupList.Count() > 0)
729
                    {
730
                        _result = markupList.ToList();
731
                    }
732

    
733
                    _result.ForEach(r =>
734
                    {
735

    
736
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
737
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
738
                                        orderby markupData.PAGENUMBER
739
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID }).ToList();
740
                    });
741

    
742
                    Random random = new Random();
743

    
744
                    _MemberDeptColors memberDeptColors = new _MemberDeptColors();
745
                    _MemberDeptColorsInfo memberDeptColorsInfo = new _MemberDeptColorsInfo();
746

    
747

    
748
                    memberDeptColors._memberDeptColors = (from memberdeptcolor in entity.MEMBER_DEPT_COLOR
749
                                                              //where memberdeptcolor.DEPARTMENT == "DisplayColor"
750
                                                          select memberdeptcolor).ToList();
751
                    memberDeptColorsInfo._memberDeptColorsInfo = (from memberdeptcolorinfo in entity.MEMBER_DEPT_COLORINFO
752
                                                                      //where memberdeptcolor.DEPARTMENT == "DisplayColor"
753
                                                                  select memberdeptcolorinfo).ToList();
754

    
755

    
756
                    foreach (var item in _result)
757
                    {
758
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
759

    
760
                        if (_member.Count() > 0)
761
                        {
762
                            item.UserName = _member.First().NAME;
763
                            item.Depatment = _member.First().DEPARTMENT;
764
                        }
765

    
766
                        foreach (var dept in memberDeptColors._memberDeptColors)
767
                        {//dept 지정  색상 
768
                            if (dept.DEPARTMENT == item.Depatment)
769
                            {
770
                                var colorlist = memberDeptColorsInfo._memberDeptColorsInfo.Where(d => d.COLORID == dept.COLORID).ToList();
771

    
772
                                int colorIdx = random.Next(1, colorlist.Count());
773
                                if (colorlist.Count > 0)
774
                                {
775
                                    item.DisplayColor = "#FF" + colorlist[colorIdx].DISPLAYCOLOR;
776
                                    memberDeptColorsInfo._memberDeptColorsInfo.Remove(colorlist[colorIdx]);
777
                                    break;
778
                                }
779
                                else
780
                                {
781
                                    item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
782
                                    break;
783
                                }
784
                            }
785
                        }
786

    
787

    
788
                        if (item.DisplayColor == null)
789
                        {
790
                            foreach (var dept in memberDeptColors._memberDeptColors)
791
                            {
792
                                if (dept.DEPARTMENT == null)
793
                                {
794
                                    dept.DEPARTMENT = item.Depatment;
795
                                    var colorlist = memberDeptColorsInfo._memberDeptColorsInfo.Where(d => d.COLORID == dept.COLORID).ToList();
796
                                    int colorIdx = random.Next(1, colorlist.Count());
797
                                    if (colorlist.Count > 0)
798
                                    {
799
                                        item.DisplayColor = "#FF" + colorlist[colorIdx].DISPLAYCOLOR;
800
                                        memberDeptColorsInfo._memberDeptColorsInfo.Remove(colorlist[colorIdx]);
801
                                        break;
802
                                    }
803
                                    else
804
                                    {
805
                                        item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
806
                                        break;
807
                                    }
808
                                }
809
                            }
810
                        }
811

    
812
                        if (item.DisplayColor == null)
813
                        {
814
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
815
                        }
816
                    }
817
                }
818
            }
819
            catch (Exception EX)
820
            {
821
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
822
                return _result;
823
            }
824
            finally
825
            {
826
                GC.Collect(2);
827
            }
828

    
829
            return _result;
830
        }
831

    
832
        /*
833
        [OperationContract]
834
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
835
        {
836
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
837
            try
838
            {
839
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
840
                {
841
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
842
                    //foreach (var item in markupListData)
843
                    //{
844
                    //    if (!item.AVOID_CONSOLIDATE.HasValue)
845
                    //    {
846
                    //        item.AVOID_CONSOLIDATE = 0;
847
                    //    }
848
                    //}
849

    
850
                    var markupList = from markup in markupListData
851
                                     orderby markup.CREATE_TIME descending
852
                                     select new MarkupInfoItem
853
                                     {
854
                                         MarkupInfoID = markup.ID,
855
                                         UserID = markup.USER_ID,
856
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
857
                                         CreateTime = markup.CREATE_TIME,
858
                                         Consolidate = markup.CONSOLIDATE,
859
                                         Description = markup.DESCRIPTION,
860
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
861
                                         PartConsolidate = markup.PART_CONSOLIDATE,
862
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
863
                                     };
864

    
865

    
866

    
867
                    if (markupList.Count() > 0)
868
                    {
869
                        _result = markupList.ToList();
870
                    }
871

    
872

    
873

    
874
                    _result.ForEach(r =>
875
                    {
876

    
877
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
878
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
879
                                        orderby markupData.PAGENUMBER
880
                                        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();
881
                    });
882

    
883
                    _ColorsProperties colors = new _ColorsProperties();
884
                    Random random = new Random();
885

    
886
                    using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
887
                    {
888
                        colors._colorsProperties = (from property in kcomEntity.PROPERTIES
889
                                             where property.TYPE == "DisplayColor"
890
                                             select property).ToList();
891
                    }
892
                    List<DeptColor> deptColor = new List<DeptColor>();
893

    
894
                    List<DeptColor> listTest = new List<DeptColor>();
895
                    //Dictionary<string, string> d = new Dictionary<string, string>();
896
                    var list = new List<KeyValuePair<string, string>>();
897
                    foreach (var test in colors._colorsProperties)
898
                    {
899
                        list.Add(new KeyValuePair<string, string>(test.PROPERTY, test.VALUE));
900
                        //d.Add(test.PROPERTY, test.VALUE);
901
                        listTest.Add(new DeptColor { Property = test.PROPERTY,DisplayColor = test.VALUE});
902
                    }
903
                    
904

    
905
                    foreach (var item in _result)
906
                    {
907
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
908

    
909
                        if (_member.Count() > 0)
910
                        {
911
                            item.UserName = _member.First().NAME;
912
                            item.Depatment = _member.First().DEPARTMENT;
913
                        }
914

    
915
                        if (colors._colorsProperties.Count > 0)
916
                        {
917
                            int colorIdx = random.Next(1, colors._colorsProperties.Count());
918
                            #region 부서별로 색상을 지정하고자 할때
919

    
920
                            if(deptColor.Count > 0)
921
                            {
922
                                foreach (var dept in deptColor)
923
                                {
924
                                    if (dept.Depatment == item.Depatment)
925
                                    {
926
                                        //list에서 deptColor.Property의 값 중 상위의 데이터를 뽑아서 지정하고 list에서 삭제 
927
                                        item.DisplayColor = "#FF" + list.Where(p => p.Key == dept.Property).FirstOrDefault().Value;
928
                                        list.Remove(new KeyValuePair<string, string>(dept.Property, dept.DisplayColor));
929
                                        break;
930
                                    }
931
                                    else
932
                                    {
933
                                        item.DisplayColor = "#FF" + colors._colorsProperties[colorIdx].VALUE;
934
                                        deptColor.Add(new DeptColor { DisplayColor = item.DisplayColor, Depatment = item.Depatment, Property = colors._colorsProperties[colorIdx].PROPERTY });
935
                                        colors._colorsProperties.RemoveAll(p => p.PROPERTY.Equals(colors._colorsProperties[colorIdx].PROPERTY)); //같은 계열의 색상은 지운다
936
                                        break;
937
                                    }
938
                                }
939
                            }
940
                            else
941
                            {
942
                                item.DisplayColor = "#FF" + colors._colorsProperties[colorIdx].VALUE;
943
                                deptColor.Add(new DeptColor { DisplayColor = item.DisplayColor, Depatment = item.Depatment, Property = colors._colorsProperties[colorIdx].PROPERTY });
944
                                colors._colorsProperties.RemoveAll(p => p.PROPERTY.Equals(colors._colorsProperties[colorIdx].PROPERTY)); //같은 계열의 색상은 지운다
945
                            }                                                     
946
                            #endregion
947
                        }
948
                        else
949
                        {
950
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
951
                        }
952
                    }
953
                }
954
            }
955
            catch (Exception EX)
956
            {
957
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
958
                return _result;
959
            }
960
            finally
961
            {
962
                GC.Collect(2);
963
            }
964

    
965
            return _result;
966
        }
967
        */
968
        [OperationContract]
969
        public List<MarkupInfoItem> GetSyncMarkupInfoItems(string ProjectNo, string DocInfoId, string currentUser)
970
        {
971
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
972
            try
973
            {
974
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
975
                using (CIEntities entity = new CIEntities(sCIConnString))
976
                {
977
                    var docItem = entity.DOCINFO.Where(data => data.DOCUMENT_ID == DocInfoId).FirstOrDefault();
978
                    if (docItem == null)
979
                    {
980
                        return null;
981
                    }
982
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == docItem.ID).ToList();
983

    
984
                    var markupList = from markup in markupListData
985
                                     where markup.USER_ID == currentUser || markup.CONSOLIDATE == 1
986
                                     orderby markup.CREATE_TIME descending
987
                                     select new MarkupInfoItem
988
                                     {
989
                                         MarkupInfoID = markup.ID,
990
                                         UserID = markup.USER_ID,
991
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
992
                                         CreateTime = markup.CREATE_TIME,
993
                                         Consolidate = markup.CONSOLIDATE,
994
                                         Description = markup.DESCRIPTION,
995
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
996
                                         PartConsolidate = markup.PART_CONSOLIDATE,
997
                                     };
998

    
999

    
1000

    
1001
                    if (markupList.Count() > 0)
1002
                    {
1003
                        _result = markupList.ToList();
1004
                    }
1005

    
1006

    
1007

    
1008
                    _result.ForEach(r =>
1009
                    {
1010

    
1011
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
1012
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
1013
                                        orderby markupData.PAGENUMBER
1014
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList();
1015
                    });
1016

    
1017
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
1018
                    Random random = new Random();
1019

    
1020
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1021
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
1022
                    {
1023
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
1024
                                             where property.TYPE == "DisplayColor"
1025
                                             select property).ToList();
1026
                    }
1027

    
1028
                    foreach (var item in _result)
1029
                    {
1030
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
1031

    
1032
                        if (_member.Count() > 0)
1033
                        {
1034
                            item.UserName = _member.First().NAME;
1035
                            item.Depatment = _member.First().DEPARTMENT;
1036
                        }
1037

    
1038
                        if (_ColorsProperties.Count > 0)
1039
                        {
1040
                            int colorIdx = random.Next(1, _ColorsProperties.Count());
1041
                            #region 부서별로 색상을 지정하고자 할때
1042
                            /// 일단 의견을 들어보자구!
1043
                            #endregion
1044
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
1045
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
1046
                            //item.DisplayColor = "#FF" + _Colors.First();
1047
                            //_Colors.Remove(_Colors.First());
1048
                        }
1049
                        else
1050
                        {
1051
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
1052
                        }
1053
                    }
1054
                }
1055
            }
1056
            catch (Exception EX)
1057
            {
1058
                System.Diagnostics.Debug.WriteLine(this.GetType().ToString() + " " + EX);
1059
                return _result;
1060
            }
1061
            finally
1062
            {
1063
                GC.Collect(2);
1064
            }
1065

    
1066
            return _result;
1067
        }
1068

    
1069

    
1070
        //[OperationContract]
1071
        //[ServiceKnownType(typeof(MEMBER))]
1072
        //public List<MEMBER> GetUserData(string ProjectNo, string UserID)
1073
        //{
1074
        //    List<MEMBER> _result = new List<MEMBER>();
1075

    
1076
        //    using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1077
        //    {
1078
        //        var _UserList = from member in entity.MEMBER
1079
        //                        where member.ID == UserID
1080
        //                        select member;
1081
        //        _result = _UserList.ToList();
1082
        //    }
1083
        //    //GC.Collect(2);
1084
        //    return _result;
1085
        //}
1086

    
1087
        [OperationContract]
1088
        [ServiceKnownType(typeof(MEMBER))]
1089
        public List<MEMBER> GetUserData(string ProjectNo, string UserID)
1090
        {
1091
            List<MEMBER> _result = new List<MEMBER>();
1092

    
1093
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1094
            using (CIEntities entity = new CIEntities(sCIConnString))
1095
            {
1096
                var _UserList = from member in entity.MEMBER
1097
                                where member.ID == UserID
1098
                                select member;
1099
                _result = _UserList.ToList();
1100
            }
1101
            //GC.Collect(2);
1102
            return _result;
1103
        }
1104

    
1105

    
1106
        [OperationContract]
1107
        public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정
1108
        {
1109
            List<string> _result = new List<string>();
1110

    
1111
            try
1112
            {
1113
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1114
                KCOMEntities entity = new KCOMEntities(sConnString);
1115
                var YourEnginner = (from dept in entity.PROPERTIES
1116
                                    where dept.TYPE == "DeptName" && UserDept.Contains(dept.VALUE)
1117
                                    select dept).FirstOrDefault();
1118

    
1119
                if (YourEnginner != null)
1120
                {
1121
                    _result = (from dept in entity.PROPERTIES
1122
                               where dept.PROPERTY == YourEnginner.PROPERTY
1123
                               select dept.VALUE).ToList();
1124
                    return _result;
1125
                }
1126
                else
1127
                {
1128
                    return null;
1129
                }
1130
            }
1131
            catch (Exception ex)
1132
            {
1133
                System.Diagnostics.Debug.WriteLine(ex.Message);
1134
            }
1135
            finally
1136
            {
1137
                GC.Collect(2);
1138
            }
1139
            return _result;
1140
        }
1141

    
1142
        [OperationContract]
1143
        public bool DeleteMarkup(string ProjectNo, string MarkupInfoID)
1144
        {
1145
            bool _result = false;
1146
            try
1147
            {
1148
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1149
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(sCIConnString))
1150
                {
1151

    
1152
                    MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault();
1153

    
1154
                    if (instance == null)
1155
                    {
1156
                        return false;
1157
                    }
1158
                    MARKUP_INFO_VERSION version = instance.MARKUP_INFO_VERSION.FirstOrDefault();
1159

    
1160

    
1161
                    version.MARKUP_DATA.ToList().ForEach(data =>
1162
                    {
1163
                        Entity.MARKUP_DATA.DeleteObject(data);
1164
                        Entity.SaveChanges();
1165
                    });
1166

    
1167
                    Entity.MARKUP_INFO_VERSION.DeleteObject(version);
1168
                    Entity.SaveChanges();
1169

    
1170
                    Entity.MARKUP_INFO.DeleteObject(instance);
1171
                    Entity.SaveChanges();
1172

    
1173
                }
1174
                _result = true;
1175
            }
1176
            catch (Exception ex)
1177
            {
1178
                System.Diagnostics.Trace.WriteLine(ex, "SaveMarkup");
1179
            }
1180
            finally
1181
            {
1182
                GC.Collect(2);
1183
            }
1184
            return _result;
1185
        }
1186

    
1187
        #region Favorite
1188
        [OperationContract]
1189
        public bool SetFavoriteVP(string prjNo, string userID, string groupNo, string docNo, string rev, int SavePageNo, string documentItemID, string VPDescription, IKCOM.FAVORITE_FLAG flag)
1190
        {
1191
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1192
            using (KCOMEntities entity = new KCOMEntities(sConnString))
1193
            {
1194
                try
1195
                {
1196
                    entity.FAVORITE_DOC.AddObject(new FAVORITE_DOC
1197
                    {
1198
                        ID = shortGuid(),
1199
                        PROJECT_NO = prjNo,
1200
                        DOCUMENT_ID = documentItemID,
1201
                        GROUP_NO = groupNo,
1202
                        DOCUMENT_NO = docNo,
1203
                        MEMBER_USER_ID = userID,
1204
                        DESCRIPTION = VPDescription,
1205
                        CREATE_TIME = DateTime.Now,
1206
                        REVISION = rev,
1207
                        FLAG = (int)flag,
1208
                        PAGE_NO = SavePageNo,
1209
                    });
1210
                    entity.SaveChanges();
1211
                }
1212
                catch (Exception)
1213
                {
1214
                    return false;
1215
                }
1216

    
1217
                return true;
1218
            }
1219
        }
1220

    
1221
        //[OperationContract]
1222
        //public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
1223
        //{
1224
        //    using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1225
        //    {
1226

    
1227
        //        int flagString = Convert.ToInt32(IKCOM.FAVORITE_FLAG.Personal);                
1228
        //        List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
1229
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
1230
        //            flagString).ToList().ForEach(data => favoriteListSet.Add(data));
1231
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data));
1232
        //        favoriteListSet = favoriteListSet.Distinct().ToList();
1233
        //        return favoriteListSet;
1234
        //    }
1235
        //}
1236
        //[OperationContract]
1237
        //public bool EditFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime, int state, string description)
1238
        //{
1239
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1240
        //    {
1241
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1242
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1243

    
1244
        //        try
1245
        //        {
1246

    
1247

    
1248
        //            if (favoriteSet.Count > 0)
1249
        //            {
1250
        //                var FavoriteVP_Instance = favoriteSet.First();
1251

    
1252
        //                FavoriteVP_Instance.Description = description;
1253
        //                FavoriteVP_Instance.Flag = state;
1254

    
1255
        //                dc.SaveChanges();
1256

    
1257
        //                return true;
1258
        //            }
1259
        //            else
1260
        //            {
1261
        //                return false;
1262
        //            }
1263
        //        }
1264
        //        catch (Exception)
1265
        //        {
1266
        //            return false;
1267
        //        }
1268
        //    }
1269
        //}
1270
        //[OperationContract]
1271
        //public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime)
1272
        //{
1273

    
1274
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1275
        //    {
1276
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1277
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1278

    
1279
        //        try
1280
        //        {
1281

    
1282

    
1283
        //            if (favoriteSet.Count > 0)
1284
        //            {
1285
        //                favoriteSet.ForEach(data => dc.FavoriteVP.DeleteObject(data));
1286
        //                dc.SaveChanges();
1287
        //                return true;
1288
        //            }
1289
        //            else
1290
        //            {
1291
        //                return false;
1292
        //            }
1293
        //        }
1294
        //        catch (Exception)
1295
        //        {
1296
        //            return false;
1297
        //        }
1298
        //    }
1299
        //}
1300
        #endregion
1301

    
1302
        [OperationContract]
1303
        public bool SaveMarkupData(MarkupInfoItem UserState,string project_no,string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1304
        {
1305
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1306
            using (CIEntities Entity = new CIEntities(sCIConnString))
1307
            {     
1308
                #region Docinfo 정보 가져오기
1309

    
1310
                string docinfoid_ = (from info in Entity.DOCINFO
1311
                                     where info.DOCUMENT_ID == doc_id
1312
                                     && info.PROJECT_NO == project_no
1313
                                     select info.ID
1314
                                     ).First().ToString();
1315
                #endregion
1316

    
1317
                #region Markup_Info 저장
1318

    
1319
                MARKUP_INFO markup_info = new MARKUP_INFO();
1320
                try
1321
                {
1322
                    markup_info = (from info in Entity.MARKUP_INFO
1323
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
1324
                                   select info).FirstOrDefault();
1325
                }
1326
                catch (Exception)
1327
                {
1328
                    markup_info = null;
1329
                }
1330

    
1331
                //markup_info가 없을 경우 생성
1332
                if (markup_info == null)
1333
                {
1334
                    //MarkupInfo 저장
1335
                    markup_info = new MARKUP_INFO
1336
                    {
1337
                        ID = UserState.MarkupInfoID,
1338
                        DOCINFO_ID = docinfoid_,
1339
                        USER_ID = user_id,
1340
                        CREATE_TIME = DateTime.Now,
1341
                        CONSOLIDATE = UserState.Consolidate,
1342
                        AVOID_CONSOLIDATE = UserState.AvoidConsolidate,
1343
                        PART_CONSOLIDATE = UserState.PartConsolidate,
1344
                        DESCRIPTION = UserState.Description,
1345
                        UPDATE_TIME = DateTime.Now
1346
                    };
1347
                    Entity.MARKUP_INFO.AddObject(markup_info);
1348
                }
1349
                //markup_info가 있을 경우 업데이트
1350
                else
1351
                {
1352
                    markup_info.UPDATE_TIME = DateTime.Now;
1353
                }
1354
                Entity.SaveChanges();
1355
                #endregion
1356

    
1357
                #region Markup_Info_Version 저장
1358

    
1359
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1360

    
1361
                try
1362
                {
1363
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1364
                                           where info.MARKUPINFO_ID == markup_info.ID
1365
                                           select info).FirstOrDefault();
1366
                }
1367
                catch (Exception)
1368
                {
1369
                    markup_info_version = null;
1370
                }
1371

    
1372
                //markup_info_version 없을 경우 생성
1373
                if (markup_info_version == null)
1374
                {
1375
                    //MarkupInfo_version 저장
1376
                    markup_info_version = new MARKUP_INFO_VERSION()
1377
                    {
1378
                        ID = UserState.MarkupVersionID,
1379
                        MARKUPINFO_ID = markup_info.ID,
1380
                        CREATE_DATE = DateTime.Now
1381
                    };
1382
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1383
                    Entity.SaveChanges();
1384
                }
1385
                #endregion
1386

    
1387
                
1388
                Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1389
                {
1390
                    Entity.MARKUP_DATA.DeleteObject(item);
1391
                });
1392
                Entity.SaveChanges();
1393

    
1394
                try
1395
                {
1396
                    mlmarkup_data.ForEach(value =>
1397
                    {
1398
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1399
                        {
1400
                            ID = value.ID,
1401
                            DATA = value.DATA,
1402
                            DATA_TYPE = value.DATA_TYPE,
1403
                            PAGENUMBER = value.PAGENUMBER,
1404
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1405
                            SYMBOL_ID = value.SYMBOL_ID,
1406
                            //GROUP_ID = value.GROUP_ID
1407
                        });
1408
                    });
1409
                    Entity.SaveChanges();
1410
                }
1411
                catch (Exception)
1412
                {
1413
                    return false;
1414
                }
1415
            }
1416
            return true;
1417
        }
1418

    
1419
        //[OperationContract]
1420
        //public long AddMarkupDataGroup(MARKUP_DATA_GROUP mARKUP_DATA_GROUP, string ProjectNo)
1421
        //{
1422
        //    try
1423
        //    {
1424
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1425
        //        {
1426
        //            Entity.AddToMARKUP_DATA_GROUP(mARKUP_DATA_GROUP);
1427
        //            //MARKUP_DATA_GROUP tt = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == id).FirstOrDefault();
1428
        //            Entity.SaveChanges();
1429

    
1430
        //            return Entity.MARKUP_DATA_GROUP.ToList().LastOrDefault().ID;
1431
        //        }
1432
        //    }
1433
        //    catch (Exception)
1434
        //    {
1435
        //        return 0;
1436
        //    }
1437
        //}
1438
        //[OperationContract]
1439
        //public bool UpdateMarkupDataGroup(long Group_ID, string ProjectNo)
1440
        //{
1441
        //    try
1442
        //    {
1443
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1444
        //        {
1445
        //            var UpdateItem = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == Group_ID).FirstOrDefault();
1446
        //            UpdateItem.STATE = 1;
1447
        //            Entity.SaveChanges();
1448
        //        }
1449
        //    }
1450
        //    catch (Exception)
1451
        //    {
1452
        //        return false;
1453
        //    }
1454
        //    return true;
1455
        //}
1456
        [OperationContract]
1457
        public bool UpdateMarkupData(string CommentID, long Group_ID, string ProjectNo)
1458
        {
1459
            try
1460
            {
1461
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1462
                using (CIEntities Entity = new CIEntities(sCIConnString))
1463
                {
1464
                    var UpdateItem = Entity.MARKUP_DATA.Where(info => info.ID == CommentID).FirstOrDefault();
1465
                    //UpdateItem.GROUP_ID = Group_ID;
1466
                    Entity.SaveChanges();
1467
                }
1468
            }
1469
            catch (Exception)
1470
            {
1471
                return false;
1472
            }
1473
            return true;
1474
        }
1475

    
1476
        [OperationContract]
1477
        public bool SaveSymbol(SYMBOL_PRIVATE symbol_private)
1478
        {
1479
            try
1480
            {
1481
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1482
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
1483
                {
1484
                    uc.AddToSYMBOL_PRIVATE(symbol_private);
1485
                    uc.SaveChanges();
1486
                }
1487
            }
1488
            catch(Exception)
1489
            {
1490
                return false;
1491
            }
1492
            return true;
1493
        }
1494
        [OperationContract]
1495
        public bool AddPublicSymbol(SYMBOL_PUBLIC symbol)
1496
        {
1497
            try
1498
            {
1499
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1500
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
1501
                {
1502
                    uc.AddToSYMBOL_PUBLIC(symbol);
1503
                    uc.SaveChanges();
1504
                }
1505
            }
1506
            catch (Exception)
1507
            {
1508
                return false;
1509
            }
1510
            return true;
1511
        }
1512
        [OperationContract]
1513
        public bool DeleteSymbol(string symbol_id, int type)
1514
        {
1515
            try
1516
            {
1517
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1518
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
1519
                {
1520
                    if (type == 0)
1521
                    {
1522
                        string delItem_ID = symbol_id;
1523
                        var delitem = Entity.SYMBOL_PRIVATE.Where(data => data.ID == delItem_ID).FirstOrDefault();
1524
                        Entity.SYMBOL_PRIVATE.DeleteObject(delitem);
1525
                        Entity.SaveChanges();
1526
                    }
1527
                    else
1528
                    {
1529
                        string delItem_ID = symbol_id;
1530
                        var delitem = Entity.SYMBOL_PUBLIC.Where(data => data.ID == delItem_ID).FirstOrDefault();
1531
                        Entity.SYMBOL_PUBLIC.DeleteObject(delitem);
1532
                        Entity.SaveChanges();
1533
                    }
1534
                }
1535
            }
1536
            catch(Exception)
1537
            {
1538
                return false;
1539
            }
1540
            return true;
1541
        }
1542

    
1543
        [OperationContract]
1544
        public bool RenameSymbol(string symbol_id, string name, int type)
1545
        {
1546
            try
1547
            {
1548
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1549
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
1550
                {
1551
                    if (type == 0)
1552
                    {
1553
                        var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == symbol_id).FirstOrDefault();
1554
                        UpdateItem.NAME = name;
1555
                        Entity.SaveChanges();
1556
                    }
1557
                    else
1558
                    {
1559
                        var UpdateItem = Entity.SYMBOL_PUBLIC.Where(info => info.ID == symbol_id).FirstOrDefault();
1560
                        UpdateItem.NAME = name;
1561
                        Entity.SaveChanges();
1562
                    }
1563
                }
1564
            }
1565
            catch (Exception)
1566
            {
1567
                return false;
1568
            }
1569
            return true;
1570
        }
1571

    
1572
        [OperationContract]
1573
        public bool AddCheckListHistory(string project_no, CHECK_LIST_HISTORY Check_History)
1574
        {
1575
            try
1576
            {
1577
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1578
                using (CIEntities Entity = new CIEntities(sCIConnString))
1579
                {
1580
                    Entity.CHECK_LIST_HISTORY.AddObject(Check_History);
1581
                    Entity.SaveChanges();  
1582
                }
1583
            }
1584
            catch (Exception)
1585
            {
1586
                return false;
1587
            }
1588
            return true;
1589
        }
1590
        [OperationContract]
1591
        public bool SaveCheckListHistory(string project_no, string rev, CHECK_LIST_HISTORY Check_History)
1592
        {
1593
            try
1594
            {
1595
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1596
                using (CIEntities Entity = new CIEntities(sCIConnString))
1597
                {
1598
                    var item = Entity.CHECK_LIST_HISTORY.Where(info => info.REVISION == rev).FirstOrDefault();
1599
                    item = Check_History;
1600
                    Entity.SaveChanges();
1601
                }
1602
            }
1603
            catch (Exception)
1604
            {
1605
                return false;
1606
            }
1607
            return true;
1608
        }
1609
        [OperationContract]
1610
        public bool SaveCheckList(string project_no, string _id, CHECK_LIST Check_value)
1611
        {
1612
            try
1613
            {
1614
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1615
                using (CIEntities Entity = new CIEntities(sCIConnString))
1616
                {
1617
                    var item = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1618
                    item.TODOLIST = Check_value.TODOLIST;
1619
                    item.REMARK = Check_value.REMARK;
1620
                    item.STATUS = Check_value.STATUS;
1621
                    item.VENDOR = Check_value.VENDOR;
1622
                    item.REPLY = Check_value.REPLY;
1623
                    item.IMAGE_URL = Check_value.IMAGE_URL;
1624
                    item.IMAGE_ANCHOR = Check_value.IMAGE_ANCHOR;
1625
                    item.UPDATE_TIME = Check_value.UPDATE_TIME;
1626
                    if(Check_value.STATUS == "False")
1627
                    {
1628
                        item.STATUS_DESC_OPEN = Check_value.STATUS_DESC_OPEN;
1629
                    }
1630
                    else
1631
                    {
1632
                        item.STATUS_DESC_CLOSE = Check_value.STATUS_DESC_CLOSE;
1633
                    }                     
1634
                    Entity.SaveChanges();
1635
                }
1636
            }
1637
            catch (Exception)
1638
            {
1639
                return false;
1640
            }
1641
            return true;
1642
        }
1643
        [OperationContract]
1644
        public bool AddCheckList(string project_no, CHECK_LIST Check_value)
1645
        {
1646
            try
1647
            {
1648
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1649
                using (CIEntities Entity = new CIEntities(sCIConnString))
1650
                {
1651
                    Entity.CHECK_LIST.AddObject(Check_value);
1652
                    Entity.SaveChanges();
1653
                }
1654
            }
1655
            catch (Exception)
1656
            {
1657
                return false;
1658
            }
1659
            return true;
1660
        }
1661

    
1662
        [OperationContract]
1663
        public CHECK_LIST GetCheckList(string project_no, string _id)
1664
        {
1665
            CHECK_LIST Check_value = new CHECK_LIST();
1666
            try
1667
            {
1668
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1669
                using (CIEntities Entity = new CIEntities(sCIConnString))
1670
                {
1671
                    Check_value = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1672
                }
1673
            }
1674
            catch (Exception)
1675
            {
1676
                return null;
1677
            }
1678
            return Check_value;
1679
        }
1680
        [OperationContract]
1681
        public List<CHECK_LIST> GetUserCheckList(string project_no, string user_id, string doc_no)
1682
        {
1683
            List<CHECK_LIST> list = new List<CHECK_LIST>();
1684
            try
1685
            {
1686
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1687
                using (CIEntities Entity = new CIEntities(sCIConnString))
1688
                {
1689
                    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();
1690
                }
1691
            }
1692
            catch (Exception)
1693
            {
1694
                return null;
1695
            }
1696
            return list;
1697
        }
1698
        [OperationContract]
1699
        public List<CHECK_LIST_HISTORY> GetCheckListHistory(string project_no, string _id)
1700
        {
1701
            List<CHECK_LIST_HISTORY> history = new List<CHECK_LIST_HISTORY>();
1702
            try
1703
            {
1704
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1705
                using (CIEntities Entity = new CIEntities(sCIConnString))
1706
                {
1707
                    history = Entity.CHECK_LIST_HISTORY.Where(data => data.CHECKLIST_ID == _id).ToList();
1708
                }
1709
            }
1710
            catch (Exception)
1711
            {
1712
                return null;
1713
            }
1714
            return history;
1715
        }
1716
        [OperationContract]
1717
        public CHECK_LIST_HISTORY GetCheckListHistoryFirstOrDefault(string project_no, string checklist_id, string rev)
1718
        {
1719
            CHECK_LIST_HISTORY Check_Item = new CHECK_LIST_HISTORY();
1720
            try
1721
            {
1722
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1723
                using (CIEntities Entity = new CIEntities(sCIConnString))
1724
                {   
1725
                    Check_Item = Entity.CHECK_LIST_HISTORY.Where(info => info.CHECKLIST_ID == checklist_id && info.REVISION == rev).FirstOrDefault();
1726
                }
1727
            }
1728
            catch (Exception)
1729
            {
1730
                return null;
1731
            }
1732
            return Check_Item;
1733
        }
1734
        [OperationContract]
1735
        public bool SavePageAngle(string project_no, List<DOCPAGE> _mldocpage)
1736
        {
1737
            try
1738
            {
1739
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1740
                using (CIEntities Entity = new CIEntities(sCIConnString))
1741
                {
1742
                    KCOMDataModel.DataModel.DOCPAGE _docpage = new KCOMDataModel.DataModel.DOCPAGE();
1743
                    _mldocpage.ForEach(data =>
1744
                    {
1745
                        _docpage = (from info in Entity.DOCPAGE
1746
                                    where info.ID == data.ID
1747
                                    select info).FirstOrDefault();
1748

    
1749
                        if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE)
1750
                        {
1751
                            _docpage.PAGE_ANGLE = data.PAGE_ANGLE;
1752
                        }
1753
                    });
1754

    
1755
                    Entity.SaveChanges();
1756
                }
1757
            }
1758
            catch (Exception)
1759
            {
1760
                return false;
1761
            }
1762
            return true;
1763
        }
1764

    
1765
        [OperationContract]
1766
        public MARKUP_INFO GetMarkupInfo(string project_no, string _id)
1767
        {
1768
            MARKUP_INFO markupInfo = new MARKUP_INFO();
1769

    
1770
            try
1771
            {
1772
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1773
                using (CIEntities Entity = new CIEntities(sCIConnString))
1774
                {
1775
                    markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1776
                }
1777
            }
1778
            catch (Exception)
1779
            {
1780
                return null;
1781
            }
1782
            return markupInfo;
1783
        }
1784

    
1785
        [OperationContract]
1786
        public List<string> GetMarkupDataListperPage(string project_no, string _markupinfoid, int _pageNo)
1787
        {
1788
            List<string> markupdata = new List<string>();
1789
            MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1790
            try
1791
            {
1792
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1793
                using (CIEntities Entity = new CIEntities(sCIConnString))
1794
                {
1795
                    markup_info_version = (from version in Entity.MARKUP_INFO_VERSION
1796
                                           where version.MARKUPINFO_ID == _markupinfoid
1797
                                           orderby version.CREATE_DATE descending
1798
                                           select version).First();
1799
                    markupdata = (from data in Entity.MARKUP_DATA
1800
                                  where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo
1801
                                  select data.DATA).ToList();
1802
                }
1803
            }
1804
            catch (Exception)
1805
            {
1806
                return null;
1807
            }
1808
            return markupdata;
1809
        }
1810

    
1811
        [OperationContract]
1812
        public bool AddMarkupInfo(string project_no, MARKUP_INFO value)
1813
        {
1814
            try
1815
            {
1816
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1817
                using (CIEntities Entity = new CIEntities(sCIConnString))
1818
                {
1819
                    Entity.MARKUP_INFO.AddObject(value);
1820
                    Entity.SaveChanges();
1821
                }
1822
            }
1823
            catch (Exception)
1824
            {
1825
                return false;
1826
            }
1827
            return true;
1828
        }
1829

    
1830
        [OperationContract]
1831
        public bool AddMarkupInfoVersion(string project_no, MARKUP_INFO_VERSION value)
1832
        {
1833
            try
1834
            {
1835
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1836
                using (CIEntities Entity = new CIEntities(sCIConnString))
1837
                {
1838
                    Entity.MARKUP_INFO_VERSION.AddObject(value);
1839
                    Entity.SaveChanges();
1840
                }
1841
            }
1842
            catch (Exception)
1843
            {
1844
                return false;
1845
            }
1846
            return true;
1847
        }
1848

    
1849
        [OperationContract]
1850
        public bool AddMarkupData(string project_no, MARKUP_DATA value)
1851
        {
1852
            try
1853
            {
1854
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1855
                using (CIEntities Entity = new CIEntities(sCIConnString))
1856
                {
1857
                    Entity.MARKUP_DATA.AddObject(value);
1858
                    Entity.SaveChanges();
1859
                }
1860
            }
1861
            catch (Exception)
1862
            {
1863
                return false;
1864
            }
1865
            return true;
1866
        }
1867

    
1868
        [OperationContract]
1869
        public bool AvoidMarkupInfo(string project_no, string _doc_id)
1870
        {
1871
            try
1872
            {
1873
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1874
                using (CIEntities Entity = new CIEntities(sCIConnString))
1875
                {
1876
                    var item = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1877
                    item.AVOID_CONSOLIDATE = 1;
1878
                    Entity.SaveChanges();
1879
                }
1880
            }
1881
            catch (Exception)
1882
            {
1883
                return false;
1884
            }
1885
            return true;
1886
        }
1887

    
1888
        [OperationContract]
1889
        public bool SaveMarkupInfo(string project_no, string _id, MARKUP_INFO value)
1890
        {
1891
            try
1892
            {
1893
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1894
                using (CIEntities Entity = new CIEntities(sCIConnString))
1895
                {
1896
                    var item = Entity.MARKUP_INFO.Where(info => info.ID == _id).FirstOrDefault();
1897
                    item = value;                    
1898
                    Entity.SaveChanges();
1899
                }
1900
            }
1901
            catch (Exception)
1902
            {
1903
                return false;
1904
            }
1905
            return true;
1906
        }
1907
        [OperationContract]
1908
        public List<MARKUP_DATA> GetMarkupDataList(string project_no, string _versionid)
1909
        {
1910
            List<MARKUP_DATA> mlresult = new List<MARKUP_DATA>();
1911

    
1912
            try
1913
            {
1914
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1915
                using (CIEntities Entity = new CIEntities(sCIConnString))
1916
                {
1917
                    mlresult = Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == _versionid).ToList();
1918
                }
1919
            }
1920
            catch (Exception)
1921
            {
1922
                return null;
1923
            }
1924
            return mlresult;
1925
        }
1926

    
1927
        [OperationContract]
1928
        public bool Consolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
1929
        {
1930
            try
1931
            {
1932
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1933
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1934
                using (CIEntities Entity = new CIEntities(sCIConnString))
1935
                {
1936
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.CONSOLIDATE == 1).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1937
                    if (markupInfo != null)
1938
                    {
1939
                        markupInfo.AVOID_CONSOLIDATE = 1;
1940
                    }
1941

    
1942
                    foreach (MarkupInfoItem item in markupInfoItems)
1943
                    {
1944
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1945
                        {
1946
                            instanceDataSet.Add(d);
1947
                        });
1948
                    }
1949

    
1950
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1951
                    info.ID = shortGuid();
1952
                    info.CONSOLIDATE = 1;
1953
                    info.CREATE_TIME = DateTime.Now;
1954
                    info.DOCINFO_ID = _doc_id;
1955
                    info.UPDATE_TIME = DateTime.Now;
1956
                    info.USER_ID = _user_id;
1957
                    info.AVOID_CONSOLIDATE = 0;
1958

    
1959
                    Entity.MARKUP_INFO.AddObject(info);
1960
                    Entity.SaveChanges();
1961

    
1962

    
1963
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1964
                    {
1965
                        ID = shortGuid(),
1966
                        CREATE_DATE = DateTime.Now,
1967
                        MARKUP_INFO = info,
1968
                    };
1969
                    Entity.SaveChanges();
1970

    
1971
                    foreach (var item in instanceDataSet)
1972
                    {
1973
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1974
                        {
1975
                            ID = shortGuid(),
1976
                            DATA = item.DATA,
1977
                            DATA_TYPE = item.DATA_TYPE,
1978
                            PAGENUMBER = item.PAGENUMBER,
1979
                            MARKUP_INFO_VERSION = info2,
1980
                            SYMBOL_ID = item.SYMBOL_ID,
1981
                            //GROUP_ID = item.GROUP_ID
1982
                        });
1983
                    }
1984
                    Entity.SaveChanges();
1985

    
1986

    
1987
                }
1988
            }
1989
            catch (Exception)
1990
            {
1991
                return false;
1992
            }
1993
            return true;
1994
        }
1995

    
1996

    
1997
        [OperationContract]
1998
        public FinalPDFResult ConsolidateMergedPDF(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems, string ProjectNo, string DocInfoID, string CreateUserID)
1999
        {
2000
            bool consolidate = false;
2001
            try
2002
            {
2003
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
2004
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2005
                using (CIEntities Entity = new CIEntities(sCIConnString))
2006
                {
2007
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
2008
                    if (markupInfo.CONSOLIDATE == 1)
2009
                    {
2010
                        markupInfo.AVOID_CONSOLIDATE = 1;
2011
                    }
2012

    
2013
                    foreach (MarkupInfoItem item in markupInfoItems)
2014
                    {
2015
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2016
                        {
2017
                            instanceDataSet.Add(d);
2018
                        });
2019
                    }
2020

    
2021
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2022
                    info.ID = shortGuid();
2023
                    info.CONSOLIDATE = 1;
2024
                    info.CREATE_TIME = DateTime.Now;
2025
                    info.DOCINFO_ID = _doc_id;
2026
                    info.UPDATE_TIME = DateTime.Now;
2027
                    info.USER_ID = _user_id;
2028
                    info.AVOID_CONSOLIDATE = 0;
2029

    
2030
                    Entity.MARKUP_INFO.AddObject(info);
2031
                    Entity.SaveChanges();
2032

    
2033

    
2034
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2035
                    {
2036
                        ID = shortGuid(),
2037
                        CREATE_DATE = DateTime.Now,
2038
                        MARKUP_INFO = info,
2039
                    };
2040
                    Entity.SaveChanges();
2041

    
2042
                    foreach (var item in instanceDataSet)
2043
                    {
2044
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2045
                        {
2046
                            ID = shortGuid(),
2047
                            DATA = item.DATA,
2048
                            DATA_TYPE = item.DATA_TYPE,
2049
                            PAGENUMBER = item.PAGENUMBER,
2050
                            MARKUP_INFO_VERSION = info2,
2051
                            SYMBOL_ID = item.SYMBOL_ID,
2052
                            //GROUP_ID = item.GROUP_ID
2053
                        });
2054
                    }
2055
                    Entity.SaveChanges();
2056

    
2057

    
2058
                }
2059
                consolidate = true;
2060
            }
2061
            catch (Exception)
2062
            {
2063
                consolidate = false;
2064
            }
2065
            FinalPDFResult _result = new FinalPDFResult();
2066
            if (consolidate == true)
2067
            {
2068
                RemFinalPDFObject remObj = null;
2069
                try
2070
                {
2071
                    string _finalID = shortGuid();
2072
                    int _DocTotalPages = -1;
2073
                    string docItemId;
2074

    
2075
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2076
                    using (CIEntities _ci = new CIEntities(sCIConnString))
2077
                    {
2078
                        var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
2079

    
2080
                        if (_doc.Count() > 0)
2081
                        {
2082
                            _DocTotalPages = _doc.First().PAGE_COUNT;
2083
                            docItemId = _doc.First().DOCUMENT_ID;
2084
                        }
2085
                        else
2086
                        {
2087
                            _result.Status = FinalStatus.Error;
2088
                            _result.Exception = "페이지 정보를 가져올 수 없습니다.";
2089
                            return _result;
2090
                        }
2091
                    }
2092

    
2093
                    var Items = GetMarkupInfoItems(ProjectNo, DocInfoID);
2094
                    if (_DocTotalPages > 0)
2095
                    {
2096
                        var item2 = Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
2097
                        FINAL_PDF fm = new FINAL_PDF()
2098
                        {
2099
                            ID = _finalID,
2100
                            PROJECT_NO = ProjectNo,
2101
                            DOCINFO_ID = DocInfoID,
2102
                            DOCUMENT_ID = docItemId,
2103
                            MARKUPINFO_ID = item2.MarkupInfoID,
2104
                            CREATE_USER_ID = CreateUserID,
2105
                            TOTAL_PAGE = _DocTotalPages,
2106
                            CREATE_DATETIME = DateTime.Now,
2107
                            STATUS = (int)IFinalPDF.FinalStatus.Insert
2108
                        };
2109

    
2110
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2111
                        using (KCOMEntities _entity = new KCOMEntities(sConnString))
2112
                        {
2113
                            _entity.AddToFINAL_PDF(fm);
2114
                            _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
2115
                        };
2116

    
2117
                        System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
2118
                        if (_ch == null)
2119
                        {
2120
                            chan = new TcpChannel();
2121
                            _ChanID = chan.ChannelName;
2122
                            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
2123
                            // Create an instance of the remote object
2124

    
2125
                            using (KCOMEntities ec = new KCOMEntities(sConnString))
2126
                            {
2127

    
2128
                                //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2129
                                //                          "tcp://localhost:9092/remFinalPDF");
2130
                                remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2131
                                                          //"tcp://192.168.0.67:9092/remFinalPDF");
2132
                                                          "tcp://192.168.0.67:9092/remFinalPDF");
2133
                            }
2134

    
2135
                            //"tcp://localhost:8080/remFinalPDF");
2136

    
2137
                            _result = remObj.SetFinalPDF(ProjectNo, _finalID);
2138
                            _result.FinalID = _finalID;
2139
                            _result.Status = FinalStatus.Success;
2140

    
2141
                            //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
2142
                            //fa.MakeFinalPDF(fm);
2143
                        }
2144
                        else
2145
                        {
2146
                            _ChanID = _ch.ChannelName;
2147
                        }
2148
                    }
2149
                }
2150
                catch (Exception ex)
2151
                {
2152
                    _result.Status = FinalStatus.Error;
2153

    
2154
                    if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
2155
                        _result.Exception = "Final Server Not Connection";
2156
                }
2157
                finally
2158
                {
2159
                    remObj = null;
2160
                    if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
2161
                        System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
2162

    
2163
                    GC.Collect(2);
2164
                }
2165
            }
2166
            return _result;
2167
        }
2168
        [OperationContract]
2169
        public bool TeamConsolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
2170
        {
2171
            try
2172
            {
2173
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
2174
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2175
                using (CIEntities Entity = new CIEntities(sCIConnString))
2176
                {
2177
                    string user_dept = Entity.MEMBER.Where(m => m.ID == _user_id).FirstOrDefault().DEPARTMENT;
2178
                    var markupInfos = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id
2179
                    && entity.PART_CONSOLIDATE == 1
2180
                    ).OrderByDescending(j => j.CREATE_TIME).ToList();
2181
                    foreach (var markupinfo in markupInfos)
2182
                    {
2183
                        string markupdept = Entity.MEMBER.Where(m => m.ID == markupinfo.USER_ID).FirstOrDefault().DEPARTMENT;
2184
                        if (user_dept == markupdept)
2185
                        {
2186
                            markupinfo.AVOID_CONSOLIDATE = 1;
2187
                        }
2188
                    }
2189

    
2190
                    foreach (MarkupInfoItem item in markupInfoItems)
2191
                    {
2192
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2193
                        {
2194
                            instanceDataSet.Add(d);
2195
                        });
2196
                    }
2197

    
2198
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2199
                    info.ID = shortGuid();
2200
                    info.PART_CONSOLIDATE = 1;
2201
                    info.CREATE_TIME = DateTime.Now;
2202
                    info.DOCINFO_ID = _doc_id;
2203
                    info.UPDATE_TIME = DateTime.Now;
2204
                    info.USER_ID = _user_id;
2205
                    info.AVOID_CONSOLIDATE = 0;
2206

    
2207
                    Entity.MARKUP_INFO.AddObject(info);
2208
                    Entity.SaveChanges();
2209

    
2210

    
2211
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2212
                    {
2213
                        ID = shortGuid(),
2214
                        CREATE_DATE = DateTime.Now,
2215
                        MARKUP_INFO = info,
2216
                    };
2217
                    Entity.SaveChanges();
2218

    
2219
                    foreach (var item in instanceDataSet)
2220
                    {
2221
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2222
                        {
2223
                            ID = shortGuid(),
2224
                            DATA = item.DATA,
2225
                            DATA_TYPE = item.DATA_TYPE,
2226
                            PAGENUMBER = item.PAGENUMBER,
2227
                            MARKUP_INFO_VERSION = info2,
2228
                            SYMBOL_ID = item.SYMBOL_ID,
2229
                            //GROUP_ID = item.GROUP_ID
2230
                        });
2231
                    }
2232
                    Entity.SaveChanges();
2233

    
2234

    
2235
                }
2236
            }
2237
            catch (Exception)
2238
            {
2239
                return false;
2240
            }
2241
            return true;
2242
        }
2243

    
2244
        [OperationContract]
2245
        [ServiceKnownType(typeof(MEMBER))]
2246
        public MEMBER GetMember(string project_no, string user_id)
2247
        {
2248
            MEMBER rstmember = new MEMBER();
2249
            try
2250
            {
2251
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2252
                using (CIEntities Entity = new CIEntities(sCIConnString))
2253
                {
2254
                    var tmp = (from member in Entity.MEMBER
2255
                                    where member.ID == user_id && member.PROJECT_NO == project_no
2256
                                    select member).FirstOrDefault();
2257
                    rstmember.DEPARTMENT = tmp.DEPARTMENT;
2258
                    rstmember.ID = tmp.ID;
2259
                    rstmember.NAME = tmp.NAME;
2260
                }
2261
            }
2262
            catch (Exception ex)
2263
            {
2264
                return null;
2265
            }
2266
            return rstmember;
2267
        }
2268

    
2269
        [WebMethod]
2270
        [OperationContract]
2271
        public List<SYMBOL_PRIVATE> GetSymbolList(string user_id)
2272
        {
2273
            List<SYMBOL_PRIVATE> Custom_List = new List<SYMBOL_PRIVATE>();
2274
            try
2275
            {
2276
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2277
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2278
                {
2279
                    Custom_List = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == user_id).ToList();
2280
                }
2281
            }
2282
            catch (Exception ex)
2283
            {
2284
                return null;
2285
            }
2286
            return Custom_List;
2287
        }
2288
        [OperationContract]
2289
        public List<string> GetPublicSymbolDeptList()
2290
        {
2291
            List<string> Custom_List = new List<string>();
2292
            try
2293
            {
2294
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2295
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2296
                {
2297
                    Custom_List = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).Distinct().ToList();
2298
                }
2299
            }
2300
            catch (Exception)
2301
            {
2302
                return null;
2303
            }
2304
            return Custom_List;
2305
        }
2306
        [OperationContract]
2307
        public List<SYMBOL_PUBLIC> GetPublicSymbolList(string dept)
2308
        {
2309
            List<SYMBOL_PUBLIC> Custom_List = new List<SYMBOL_PUBLIC>();
2310
            try
2311
            {
2312
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2313
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2314
                {
2315
                    if(!string.IsNullOrEmpty(dept))
2316
                    {
2317
                        Custom_List = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == dept).ToList();
2318
                    }
2319
                    else
2320
                    {
2321
                        Custom_List = Entity.SYMBOL_PUBLIC.ToList();
2322
                    }
2323
                    
2324
                }
2325
            }
2326
            catch (Exception)
2327
            {
2328
                return null;
2329
            }
2330
            return Custom_List;
2331
        }
2332

    
2333
        /// <summary>
2334
        /// 
2335
        /// </summary>
2336
        /// <param name="id">symbol id</param>
2337
        /// <param name="type"> 0 : PRIVATE, 1 : PUBLIC</param>
2338
        /// <returns></returns>
2339
        [OperationContract]
2340
        public string GetSymbolData(string id, int type)
2341
        {
2342
            string result;
2343
            try
2344
            {
2345
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2346
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2347
                {
2348
                    if(type == 0)
2349
                    {
2350
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA;
2351
                    }
2352
                    else
2353
                    {
2354
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA;
2355
                    }
2356
                }
2357
            }
2358
            catch (Exception)
2359
            {
2360
                return null;
2361
            }
2362
            return result;
2363
        }
2364
        [OperationContract]
2365
        public string GetSymbolImageURL(string id, int type)
2366
        {
2367
            string result;
2368
            try
2369
            {
2370
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2371
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2372
                {
2373
                    if (type == 0)
2374
                    {
2375
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2376
                    }
2377
                    else
2378
                    {
2379
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2380
                    }
2381
                }
2382
            }
2383
            catch (Exception)
2384
            {
2385
                return null;
2386
            }
2387
            return result;
2388
        }
2389
        [OperationContract]
2390
        public string GetSignData(string project_no, string user_id)
2391
        {
2392
            string result = null;
2393
            try
2394
            {
2395
                string ifsign = getEnsembleSign(user_id);
2396
                if (string.IsNullOrEmpty(ifsign))
2397
                {
2398
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2399
                    var ModelWFConnectionString = sCIConnString;
2400
                    if (null != ModelWFConnectionString)
2401
                    {
2402
                        using (CIEntities entity = new CIEntities(ModelWFConnectionString))
2403
                        {
2404
                            var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2405
                            if (_sign.Count() > 0)
2406
                            {
2407
                                result = _sign.First().SIGN_STR;
2408
                            }
2409
                            else
2410
                            {
2411
                                return null;
2412
                            }
2413
                        }
2414
                    }
2415
                }
2416
                else
2417
                {
2418
                    result = ifsign;
2419
                }
2420

    
2421
            }
2422
            catch (Exception)
2423
            {
2424
                return null;
2425
            }
2426
            return result;
2427
        }
2428

    
2429
        [OperationContract]        
2430
        public string GetProjectName(string project_no)
2431
        {
2432
            string result = null;
2433

    
2434
            try
2435
            {
2436
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2437
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
2438
                {
2439
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
2440
                }
2441
            }
2442
            catch (Exception)
2443
            {
2444
                return null;
2445
            }
2446
            return result;
2447
        }
2448

    
2449
        [OperationContract]
2450
        public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev)
2451
        {
2452
            List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>();
2453
            
2454
            try
2455
            {
2456
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2457
                using (CIEntities Entity = new CIEntities(sCIConnString))
2458
                {
2459
                    result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no
2460
                    && i.DOCUMENT_NO == doc_no
2461
                    && i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList();
2462
                }
2463
            }
2464
            catch (Exception)
2465
            {
2466
                return null;
2467
            }
2468
            return result;
2469
        }
2470

    
2471
        [OperationContract]
2472
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
2473
        {
2474
            DOCINFO docinfo = null;
2475

    
2476
            try
2477
            {
2478
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2479
                using (CIEntities Entity = new CIEntities(sCIConnString))
2480
                {
2481
                    docinfo = (from info in Entity.DOCINFO
2482
                              where info.DOCUMENT_ID == doc_id
2483
                              && info.PROJECT_NO == project_no
2484
                              select info).First();
2485
                }
2486
            }
2487
            catch (Exception)
2488
            {
2489
                return null;
2490
            }
2491
            return docinfo;
2492
        }
2493

    
2494
        [OperationContract]
2495
        public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList)
2496
        {
2497
            MarkupInfoItem _result = null;
2498
            List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>();
2499
            try
2500
            {
2501
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2502
                using (CIEntities Entity = new CIEntities(sCIConnString))
2503
                {
2504
                    var docitem = (from info in Entity.DOCINFO
2505
                               where info.DOCUMENT_ID == doc_id
2506
                               && info.PROJECT_NO == project_no
2507
                               select info).First();
2508

    
2509
                    foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO)
2510
                    {
2511
                        var member = (from mem in Entity.MEMBER
2512
                                     where mem.ID == markinfo.USER_ID
2513
                                     select mem).First();
2514
                        string displaycolor = null;
2515
                        try
2516
                        {
2517
                            displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor;
2518
                        }
2519
                        catch(Exception)
2520
                        {
2521
                            displaycolor = "#FFFFFF";
2522
                        }
2523
                        
2524
                        _result = new MarkupInfoItem
2525
                        {
2526
                            MarkupInfoID = markinfo.ID,
2527
                            Consolidate = markinfo.CONSOLIDATE,
2528
                            CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME,
2529
                            DisplayColor = displaycolor,
2530
                            UserID = markinfo.USER_ID,
2531
                            UserName = member.NAME,
2532
                            Depatment = member.DEPARTMENT,
2533
                        };
2534

    
2535
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
2536
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
2537

    
2538
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
2539
                        {
2540
                            MarkupItem markitem = new MarkupItem()
2541
                            {
2542
                                ID = markdata.ID,
2543
                                PageNumber = markdata.PAGENUMBER,
2544
                            };
2545
                            _result.MarkupList.Add(markitem);
2546
                        }
2547

    
2548
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
2549

    
2550
                        markupinfo.Add(_result);
2551
                    }
2552
                }
2553
            }
2554
            catch (Exception)
2555
            {
2556
                return null;
2557
            }
2558
            return markupinfo;
2559
        }
2560

    
2561
        [OperationContract]
2562
        public bool AddMessage(string project_no, TALK value)
2563
        {
2564
            try
2565
            {
2566
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2567
                using (CIEntities entity = new CIEntities(sCIConnString))
2568
                {                    
2569
                    entity.TALK.AddObject(value);
2570
                    entity.SaveChanges();
2571
                }
2572
            }
2573
            catch (Exception)
2574
            {
2575
                return false;
2576
            }
2577
            return true;
2578
        }
2579

    
2580
        [OperationContract]
2581
        public List<TALK> GetMessage(string project_no, string doc_id)
2582
        {
2583
            List<TALK> result = new List<TALK>();
2584
            try
2585
            {
2586
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2587
                using (CIEntities entity = new CIEntities(sCIConnString))
2588
                {
2589
                    result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList();                        
2590
                }
2591
            }
2592
            catch (Exception ex)
2593
            {
2594
                return result;
2595
            }
2596
            return result;
2597
        }
2598

    
2599

    
2600
        #region Legacy System I/F
2601
        /// <summary>
2602
        /// Ensemble+ Sign Data Return
2603
        /// </summary>
2604
        /// <param name="user_id"></param>
2605
        /// <returns></returns>
2606
        private string getEnsembleSign(string user_id)
2607
        {
2608
            string result = string.Empty;
2609
            string soapurl = string.Empty;
2610
            try
2611
            {
2612
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2613
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2614
                {
2615
                    var item = Entity.PROPERTIES.Where(d => d.TYPE == "UpLoadServiceUrl").FirstOrDefault();
2616
                    soapurl = item.VALUE;
2617
                }
2618
                WebClient webClient = new WebClient();
2619
                string data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ens=\"http://EnsemblePlus.Webservice\"> <soapenv:Header/> <soapenv:Body> <ens:checkoutSignImage>"
2620
                    + "<ens:sUserNo>" + user_id + "</ens:sUserNo>"
2621
                    + "</ens:checkoutSignImage> </soapenv:Body></soapenv:Envelope>";
2622
                webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
2623
                webClient.Headers.Add("SOAPAction", "http://EnsemblePlus.Webservice");
2624
                var _result = webClient.UploadString(new Uri(soapurl), data);
2625
                XmlDocument xmlDoc = new XmlDocument();
2626
                xmlDoc.LoadXml(_result);
2627
                XmlNodeList list = xmlDoc.GetElementsByTagName("checkoutSignImageResponse");
2628
                foreach (XmlNode xn in list)
2629
                {
2630
                    result = xn["checkoutSignImageReturn"].InnerText;
2631
                }
2632
                if (!result.Contains("No business object"))
2633
                {
2634
                    return result;
2635
                }
2636
                else
2637
                {
2638
                    return null;
2639
                }
2640
            }
2641
            catch (Exception ex)
2642
            {
2643
                return null;
2644
            }
2645

    
2646

    
2647
        }
2648
        #endregion
2649

    
2650
        #region Final Service
2651
        [OperationContract]
2652
        [ServiceKnownType(typeof(DOCINFO))]                
2653
        public DOCINFO FinalPDF_GetDocinfo(string project_no, string docinfo_id)
2654
        {
2655
            DOCINFO docinfo = null;
2656

    
2657
            try
2658
            {
2659
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2660
                using (CIEntities _entity = new CIEntities(sCIConnString))
2661
                {
2662
                    var doc = _entity.DOCINFO.Where(x => x.ID == docinfo_id).FirstOrDefault();
2663
                    if(doc != null)
2664
                    {
2665
                        docinfo = new DOCINFO()
2666
                        {
2667
                            ID = doc.ID,
2668
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2669
                            PAGE_COUNT = doc.PAGE_COUNT,
2670
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2671
                            PROJECT_NO = doc.PROJECT_NO
2672
                        };
2673
                    }                    
2674
                }
2675
            }
2676
            catch (Exception)
2677
            {
2678
                throw;
2679
            }
2680
            return docinfo;
2681
        }
2682
        [OperationContract]
2683
        [ServiceKnownType(typeof(DOCUMENT_ITEM))]
2684
        public DOCUMENT_ITEM FinalPDF_GetDocumentItem(string project_no, string document_id)
2685
        {
2686
            DOCUMENT_ITEM item = null;
2687

    
2688
            try
2689
            {
2690
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2691
                using (CIEntities _entity = new CIEntities(sCIConnString))
2692
                {
2693
                    var doc = _entity.DOCUMENT_ITEM.Where(x => x.DOCUMENT_ID == document_id).FirstOrDefault();
2694
                    if(doc != null)
2695
                    {
2696
                        item = new DOCUMENT_ITEM()
2697
                        {
2698
                            ID = doc.ID,
2699
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2700
                            PROJECT_NO = doc.PROJECT_NO,
2701
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2702
                            DOCUMENT_NO = doc.DOCUMENT_NO,
2703
                            DOCUMENT_NAME = doc.DOCUMENT_NAME,
2704
                            ENSEMBLEINFO_URL = doc.ENSEMBLEINFO_URL,
2705
                            GROUP_NO = doc.GROUP_NO,
2706
                            RESULT = doc.RESULT,
2707
                            REVISION = doc.REVISION,
2708
                            RESULT_FILE = doc.RESULT_FILE
2709
                        };
2710
                    }
2711
                    
2712
                }
2713
            }
2714
            catch (Exception)
2715
            {
2716
                throw;
2717
            }
2718
            return item;
2719
        }
2720
        [OperationContract]
2721
        [ServiceKnownType(typeof(MARKUP_DATA))]
2722
        public List<MARKUP_DATA> FinalPDF_GetMarkupdata(string project_no, string docinfo_id)
2723
        {
2724
            List<MARKUP_DATA> results = new List<MARKUP_DATA>();
2725

    
2726
            try
2727
            {
2728
                //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2729
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2730
                using (CIEntities _entity = new CIEntities(sCIConnString))
2731
                {
2732
                    var datas = _entity.MARKUP_DATA.Where(x => x.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO_ID == docinfo_id
2733
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1
2734
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.AVOID_CONSOLIDATE == 0
2735
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.PART_CONSOLIDATE == 0).ToList();
2736
                    foreach (var data in datas)
2737
                    {
2738
                        MARKUP_DATA d = new MARKUP_DATA()
2739
                        {
2740
                            ID = data.ID,
2741
                            //GROUP_ID = data.GROUP_ID,
2742
                            SYMBOL_ID = data.SYMBOL_ID,
2743
                            DATA = data.DATA,
2744
                            DATA_TYPE = data.DATA_TYPE,
2745
                            MARKUPINFO_VERSION_ID = data.MARKUPINFO_VERSION_ID,
2746
                            PAGENUMBER = data.PAGENUMBER
2747
                        };
2748
                        results.Add(d);
2749
                    }
2750
                }
2751
            }
2752
            catch (Exception)
2753
            {
2754
                throw;
2755
            }
2756
            return results;
2757
        }
2758
        [OperationContract]
2759
        [ServiceKnownType(typeof(MARKUP_INFO))]
2760
        public MARKUP_INFO FinalPDF_GetMarkupinfo(string project_no, string docinfo_id)
2761
        {
2762
            MARKUP_INFO markupInfo = null;
2763

    
2764
            try
2765
            {
2766
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2767
                using (CIEntities _entity = new CIEntities(sCIConnString))
2768
                {
2769
                    var tmp = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo_id && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0).FirstOrDefault();
2770
                    if (tmp != null)
2771
                    {
2772
                        markupInfo = new MARKUP_INFO()
2773
                        {
2774
                            ID = tmp.ID,
2775
                            DOCINFO_ID = tmp.DOCINFO_ID,
2776
                            USER_ID = tmp.USER_ID
2777
                        };
2778
                    }                    
2779
                }
2780
            }
2781
            catch (Exception)
2782
            {
2783
                throw;
2784
            }
2785
            return markupInfo;
2786
        }
2787
        [OperationContract]
2788
        [ServiceKnownType(typeof(FINAL_PDF))]
2789
        public List<FINAL_PDF> FinalPDF_GetFinalPDFs(string final_id)
2790
        {
2791
            List<FINAL_PDF> results = new List<FINAL_PDF>();
2792

    
2793
            try
2794
            {
2795
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2796
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2797
                {
2798
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == final_id).ToList();
2799
                    foreach(var final in finalList)
2800
                    {
2801
                        FINAL_PDF pdf = new FINAL_PDF()
2802
                        {
2803
                            ID = final.ID,
2804
                            DOCINFO_ID = final.DOCINFO_ID,
2805
                            DOCUMENT_ID = final.DOCUMENT_ID,
2806
                            STATUS = final.STATUS,
2807
                            CURRENT_PAGE = final.CURRENT_PAGE,
2808
                            CREATE_DATETIME = final.CREATE_DATETIME,
2809
                            START_DATETIME = final.START_DATETIME,
2810
                            END_DATETIME = final.END_DATETIME,
2811
                            EXCEPTION = final.EXCEPTION,
2812
                            PROJECT_NO = final.PROJECT_NO,
2813
                            TOTAL_PAGE = final.TOTAL_PAGE,
2814
                            MARKUPINFO_ID = final.MARKUPINFO_ID,
2815
                            CREATE_USER_ID = final.CREATE_USER_ID
2816
                        };
2817
                        results.Add(pdf);
2818
                    }
2819
                }
2820
            }
2821
            catch (Exception)
2822
            {
2823
                throw;
2824
            }
2825
            return results;
2826
        }
2827
        [OperationContract]
2828
        [ServiceKnownType(typeof(DOCPAGE))]
2829
        public List<DOCPAGE> FinalPDF_GetDocpage(string project_no, string docinfo_id)
2830
        {
2831
            List<DOCPAGE> results = new List<DOCPAGE>();
2832

    
2833
            try
2834
            {
2835
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2836
                using (CIEntities _entity = new CIEntities(sCIConnString))
2837
                {
2838
                    var pages = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == docinfo_id).OrderBy(x => x.PAGE_NUMBER).ToList();
2839
                    foreach(var page in pages)
2840
                    {
2841
                        DOCPAGE p = new DOCPAGE()
2842
                        {
2843
                            PAGE_ANGLE = page.PAGE_ANGLE,
2844
                            PAGE_NUMBER = page.PAGE_NUMBER,
2845
                            PAGE_HEIGHT = page.PAGE_HEIGHT,
2846
                            PAGE_WIDTH = page.PAGE_WIDTH,
2847
                            DOCINFO_ID = page.DOCINFO_ID                            
2848
                        };
2849
                        results.Add(p);
2850
                    }                    
2851
                }
2852
            }
2853
            catch (Exception)
2854
            {
2855
                throw;
2856
            }
2857
            return results;
2858
        }
2859
        [OperationContract]        
2860
        public bool FinalPDF_SetFinalPDFStatus(string final_id, FinalStatus status)
2861
        {
2862
            bool result = false;
2863

    
2864
            try
2865
            {
2866
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2867
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2868
                {
2869
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2870
                    if(tmp != null)
2871
                    {
2872
                        switch(status)
2873
                        {
2874
                            case FinalStatus.Create:
2875
                                tmp.START_DATETIME = DateTime.Now;
2876
                                break;
2877
                            case FinalStatus.Success:
2878
                                tmp.END_DATETIME = DateTime.Now;
2879
                                tmp.EXCEPTION = string.Empty;
2880
                                break;                                
2881
                        }
2882
                        tmp.STATUS = (int)status;
2883
                        _entity.SaveChanges();
2884
                        result = true;                        
2885
                    }
2886
                }                    
2887
            }
2888
            catch (Exception)
2889
            {
2890
                throw;
2891
            }
2892
            return result;
2893
        }
2894

    
2895
        /// <summary>
2896
        /// 현재 진행중인 Final PDF 가 없거나 Success 일 경우에만 true return
2897
        /// </summary>
2898
        /// <param name="DocInfoID"></param>
2899
        /// <param name="MarkupInfoID"></param>
2900
        /// <param name="CreateUserID"></param>
2901
        /// <returns></returns>
2902
        [OperationContract]
2903
        public bool FinalPDF_GetFinalPDFStatus(string DocInfoID, string MarkupInfoID, string CreateUserID)
2904
        {
2905
            bool result = false;
2906

    
2907
            try
2908
            {
2909
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2910
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2911
                {
2912
                    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();
2913
                    if (finalpdf != null)
2914
                    {
2915
                        if (finalpdf.STATUS == (int)FinalStatus.Success)
2916
                        {
2917
                            result = true;
2918
                        }
2919
                    }
2920
                    else
2921
                        result = true;
2922
                }
2923
            }
2924
            catch (Exception)
2925
            {
2926
                throw;
2927
            }
2928
            return result;
2929
        }
2930

    
2931
        [OperationContract]
2932
        public bool FinalPDF_SetCurrentPage(string final_id, int currentpage)
2933
        {
2934
            bool result = false;
2935

    
2936
            try
2937
            {
2938
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2939
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2940
                {
2941
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2942
                    if (tmp != null)
2943
                    {
2944
                        tmp.CURRENT_PAGE = currentpage;
2945
                        _entity.SaveChanges();
2946
                        result = true;
2947
                    }
2948
                }
2949
            }
2950
            catch (Exception)
2951
            {
2952
                throw;
2953
            }
2954
            return result;
2955
        }
2956
        [OperationContract]
2957
        public bool FinalPDF_SetError(string final_id, string msg)
2958
        {
2959
            bool result = false;
2960

    
2961
            try
2962
            {
2963
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2964
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2965
                {
2966
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2967
                    if (tmp != null)
2968
                    {                        
2969
                        tmp.STATUS = (int)FinalStatus.Error;
2970
                        tmp.EXCEPTION = DateTime.Now.ToShortDateString() + " " + msg;                        
2971
                        _entity.SaveChanges();
2972
                        result = true;
2973
                    }
2974
                }
2975
            }
2976
            catch (Exception)
2977
            {
2978
                throw;
2979
            }
2980
            return result;
2981
        }
2982

    
2983
        [OperationContract]
2984
        public bool FinalPDF_SetFinalResultPath(string project_no, string document_id, string url)
2985
        {
2986
            bool result = false;
2987

    
2988
            try
2989
            {
2990
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2991
                using (CIEntities _entity = new CIEntities(sCIConnString))
2992
                {
2993
                    var item = _entity.DOCUMENT_ITEM.Where(d => d.DOCUMENT_ID == document_id).FirstOrDefault();
2994
                    if (item != null)
2995
                    {
2996
                        item.RESULT_FILE = url;
2997
                        _entity.SaveChanges();
2998
                        result = true;
2999
                    }
3000
                }
3001
            }
3002
            catch (Exception)
3003
            {
3004
                throw;
3005
            }
3006
            return result;
3007
        }
3008
        [OperationContract]
3009
        [ServiceKnownType(typeof(MEMBER))]
3010
        public MEMBER FinalPDF_GetCommentMember(string project_no, string markupdata_id)
3011
        {
3012
            MEMBER member = null;
3013
            try
3014
            {
3015
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3016
                using (CIEntities _entity = new CIEntities(sCIConnString))
3017
                {
3018
                    var data = _entity.MARKUP_DATA.Where(x => x.ID == markupdata_id).FirstOrDefault();
3019
                    string user_id = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
3020
                    var person = _entity.MEMBER.Where(p => p.ID == user_id).FirstOrDefault();
3021
                    if(person != null)
3022
                    {
3023
                        member = new MEMBER()
3024
                        {
3025
                            ID = user_id,
3026
                            NAME = person.NAME,
3027
                            DEPARTMENT = person.DEPARTMENT
3028
                        };
3029
                    }
3030
                }
3031
            }
3032
            catch (Exception)
3033
            {
3034
                throw;
3035
            }
3036
            return member;
3037
        }
3038

    
3039
        [OperationContract]
3040
        [ServiceKnownType(typeof(PROPERTIES))]
3041
        public List<PROPERTIES> FinalPDF_GetProperties(string project_no)
3042
        {
3043
            List<PROPERTIES> results = new List<PROPERTIES>();
3044
            try
3045
            {
3046
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3047
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3048
                {
3049
                    var _items = _entity.PROPERTIES.Where(x => x.PROPERTY == project_no).ToList();
3050
                    foreach(var item in _items)
3051
                    {
3052
                        PROPERTIES pROPERTIES = new PROPERTIES()
3053
                        {
3054
                            ID = item.ID,
3055
                            PROPERTY = item.PROPERTY,
3056
                            TYPE = item.TYPE,
3057
                            VALUE = item.VALUE
3058
                        };
3059
                        results.Add(pROPERTIES);
3060
                    }
3061
                }
3062

    
3063
            }
3064
            catch (Exception)
3065
            {
3066
                throw;
3067
            }
3068
            return results;
3069
        }
3070
        #endregion
3071
    }    
3072
}
클립보드 이미지 추가 (최대 크기: 500 MB)