프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ ff01c725

이력 | 보기 | 이력해설 | 다운로드 (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

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

    
227
            string originFile = "";
228
            string targetFile = "";
229

    
230
            if (Boolean.Parse(isInternalAddress))
231
            {
232
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, (Convert.ToUInt32(originDocItem_ID) / 100).ToString(), originDocItem_ID, originPageNo);
233
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, (Convert.ToUInt32(targetDocItem_ID) / 100).ToString(), targetDocItem_ID, targetPageNo);
234
            }
235
            else
236
            {
237
                originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  originDocItem_ID, originPageNo);
238
                targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo,  targetDocItem_ID, targetPageNo);
239
            }
240

    
241
            CompareLib compareLib = new CompareLib();
242
            //System.IO.Stream resultOrigin = compareLib.ChangeCmpUrlToPng(originFile);
243
            //System.IO.Stream resultTarget = compareLib.ChangeCmpUrlToPng(targetFile);
244

    
245
            var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
246
            var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
247

    
248
            string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
249
            var result = compareLib.GetBoundBoxInImage(outPutFile);
250

    
251
            return result;
252
        }
253

    
254

    
255

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

    
272
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
273
                using (CIEntities _ci = new CIEntities(sCIConnString))
274
                {
275
                    var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
276

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

    
304
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
305
                    using (KCOMEntities _entity = new KCOMEntities(sConnString))
306
                    {
307
                        _entity.AddToFINAL_PDF(fm);
308
                        _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
309
                    };
310

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

    
319
                        using (KCOMEntities ec = new KCOMEntities(sConnString))
320
                        {
321

    
322
                            //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
323
                            //                          "tcp://localhost:9092/remFinalPDF");
324
                            remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
325
                                                      //"tcp://192.168.0.67:9092/remFinalPDF");
326
                                                      "tcp://localhost:9092/remFinalPDF");
327
                        }
328

    
329
                        //"tcp://localhost:8080/remFinalPDF");
330

    
331
                        _result = remObj.SetFinalPDF(ProjectNo, _finalID);
332
                        _result.FinalID = _finalID;
333
                        _result.Status = FinalStatus.Success;
334

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

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

    
358
                GC.Collect(2);
359
            }
360
            return _result;
361
        }
362
        #endregion
363

    
364

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

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

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

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

    
441
                throw ex;
442
            }
443
            finally
444
            {
445
                GC.Collect(2);
446
            }
447
            return _result;
448
        }
449

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

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

    
494
                var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID && doc.PROJECT_NO == param.projectNo);
495
                if (docinfo.Count() > 0)
496
                {
497
                    _result = docinfo.First();
498
                    _result.MARKUP_INFO.Clear();
499

    
500
                }
501
                return _result;
502

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

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

    
534
        [OperationContract]
535
        public DOCUMENT_ITEM GetDocumentItemInfo(KCOM_BasicParam param)
536
        {
537
            ///param : prjNo, documentId, userId
538
            DOCUMENT_ITEM _result = null;
539

    
540
            try
541
            {
542
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
543
                CIEntities entity = new CIEntities(sCIConnString);
544

    
545
                var _items = entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == param.documentID);
546

    
547
                if (_items.Count() > 0)
548
                {
549
                    _result = _items.First();
550

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

    
566
            return _result;
567
        }
568
        /// <summary>
569
        /// DOCUMENT_ITEM Table 의 ID 로 Item 을 Select
570
        /// </summary>
571
        /// <param name="ensemble_id"></param>
572
        /// <returns></returns>
573
        [OperationContract]
574
        public string GetDocItemID(string ensemble_id)
575
        {
576
            ///param : prjNo, documentId, userId
577
            string _result = string.Empty;
578

    
579
            try
580
            {
581
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
582
                CIEntities entity = new CIEntities(sCIConnString);
583

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

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

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

    
631
                    if (markupList.Count() > 0)
632
                    {
633
                        _result = markupList.ToList();
634
                    }
635

    
636
                    _result.ForEach(r =>
637
                    {
638

    
639
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
640
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
641
                                        orderby markupData.PAGENUMBER
642
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList();
643
                    });
644

    
645
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
646
                    Random random = new Random();
647

    
648
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
649
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
650
                    {
651
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
652
                                             where property.TYPE == "DisplayColor"
653
                                             select property).ToList();
654
                    }                    
655

    
656
                    foreach (var item in _result)
657
                    {
658
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID).FirstOrDefault();
659
                        
660
                        if (_member != null)
661
                        {
662
                            item.UserName = _member.NAME;
663
                            item.Depatment = _member.DEPARTMENT;
664
                        }
665

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

    
692
            return _result;
693
        }
694

    
695

    
696
        /*
697
        [OperationContract]
698
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
699
        {
700
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
701
            try
702
            {
703
                using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
704
                {
705
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
706

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

    
722
                    if (markupList.Count() > 0)
723
                    {
724
                        _result = markupList.ToList();
725
                    }
726

    
727
                    _result.ForEach(r =>
728
                    {
729

    
730
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
731
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
732
                                        orderby markupData.PAGENUMBER
733
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID }).ToList();
734
                    });
735

    
736
                    Random random = new Random();
737

    
738
                    _MemberDeptColors memberDeptColors = new _MemberDeptColors();
739
                    _MemberDeptColorsInfo memberDeptColorsInfo = new _MemberDeptColorsInfo();
740

    
741

    
742
                    memberDeptColors._memberDeptColors = (from memberdeptcolor in entity.MEMBER_DEPT_COLOR
743
                                                              //where memberdeptcolor.DEPARTMENT == "DisplayColor"
744
                                                          select memberdeptcolor).ToList();
745
                    memberDeptColorsInfo._memberDeptColorsInfo = (from memberdeptcolorinfo in entity.MEMBER_DEPT_COLORINFO
746
                                                                      //where memberdeptcolor.DEPARTMENT == "DisplayColor"
747
                                                                  select memberdeptcolorinfo).ToList();
748

    
749

    
750
                    foreach (var item in _result)
751
                    {
752
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
753

    
754
                        if (_member.Count() > 0)
755
                        {
756
                            item.UserName = _member.First().NAME;
757
                            item.Depatment = _member.First().DEPARTMENT;
758
                        }
759

    
760
                        foreach (var dept in memberDeptColors._memberDeptColors)
761
                        {//dept 지정  색상 
762
                            if (dept.DEPARTMENT == item.Depatment)
763
                            {
764
                                var colorlist = memberDeptColorsInfo._memberDeptColorsInfo.Where(d => d.COLORID == dept.COLORID).ToList();
765

    
766
                                int colorIdx = random.Next(1, colorlist.Count());
767
                                if (colorlist.Count > 0)
768
                                {
769
                                    item.DisplayColor = "#FF" + colorlist[colorIdx].DISPLAYCOLOR;
770
                                    memberDeptColorsInfo._memberDeptColorsInfo.Remove(colorlist[colorIdx]);
771
                                    break;
772
                                }
773
                                else
774
                                {
775
                                    item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
776
                                    break;
777
                                }
778
                            }
779
                        }
780

    
781

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

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

    
823
            return _result;
824
        }
825

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

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

    
859

    
860

    
861
                    if (markupList.Count() > 0)
862
                    {
863
                        _result = markupList.ToList();
864
                    }
865

    
866

    
867

    
868
                    _result.ForEach(r =>
869
                    {
870

    
871
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
872
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
873
                                        orderby markupData.PAGENUMBER
874
                                        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();
875
                    });
876

    
877
                    _ColorsProperties colors = new _ColorsProperties();
878
                    Random random = new Random();
879

    
880
                    using (KCOMEntities kcomEntity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
881
                    {
882
                        colors._colorsProperties = (from property in kcomEntity.PROPERTIES
883
                                             where property.TYPE == "DisplayColor"
884
                                             select property).ToList();
885
                    }
886
                    List<DeptColor> deptColor = new List<DeptColor>();
887

    
888
                    List<DeptColor> listTest = new List<DeptColor>();
889
                    //Dictionary<string, string> d = new Dictionary<string, string>();
890
                    var list = new List<KeyValuePair<string, string>>();
891
                    foreach (var test in colors._colorsProperties)
892
                    {
893
                        list.Add(new KeyValuePair<string, string>(test.PROPERTY, test.VALUE));
894
                        //d.Add(test.PROPERTY, test.VALUE);
895
                        listTest.Add(new DeptColor { Property = test.PROPERTY,DisplayColor = test.VALUE});
896
                    }
897
                    
898

    
899
                    foreach (var item in _result)
900
                    {
901
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
902

    
903
                        if (_member.Count() > 0)
904
                        {
905
                            item.UserName = _member.First().NAME;
906
                            item.Depatment = _member.First().DEPARTMENT;
907
                        }
908

    
909
                        if (colors._colorsProperties.Count > 0)
910
                        {
911
                            int colorIdx = random.Next(1, colors._colorsProperties.Count());
912
                            #region 부서별로 색상을 지정하고자 할때
913

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

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

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

    
993

    
994

    
995
                    if (markupList.Count() > 0)
996
                    {
997
                        _result = markupList.ToList();
998
                    }
999

    
1000

    
1001

    
1002
                    _result.ForEach(r =>
1003
                    {
1004

    
1005
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
1006
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
1007
                                        orderby markupData.PAGENUMBER
1008
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList();
1009
                    });
1010

    
1011
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
1012
                    Random random = new Random();
1013

    
1014
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1015
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
1016
                    {
1017
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
1018
                                             where property.TYPE == "DisplayColor"
1019
                                             select property).ToList();
1020
                    }
1021

    
1022
                    foreach (var item in _result)
1023
                    {
1024
                        var _member = entity.MEMBER.Where(member => member.ID == item.UserID);
1025

    
1026
                        if (_member.Count() > 0)
1027
                        {
1028
                            item.UserName = _member.First().NAME;
1029
                            item.Depatment = _member.First().DEPARTMENT;
1030
                        }
1031

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

    
1060
            return _result;
1061
        }
1062

    
1063

    
1064
        //[OperationContract]
1065
        //[ServiceKnownType(typeof(MEMBER))]
1066
        //public List<MEMBER> GetUserData(string ProjectNo, string UserID)
1067
        //{
1068
        //    List<MEMBER> _result = new List<MEMBER>();
1069

    
1070
        //    using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1071
        //    {
1072
        //        var _UserList = from member in entity.MEMBER
1073
        //                        where member.ID == UserID
1074
        //                        select member;
1075
        //        _result = _UserList.ToList();
1076
        //    }
1077
        //    //GC.Collect(2);
1078
        //    return _result;
1079
        //}
1080

    
1081
        [OperationContract]
1082
        [ServiceKnownType(typeof(MEMBER))]
1083
        public List<MEMBER> GetUserData(string ProjectNo, string UserID)
1084
        {
1085
            List<MEMBER> _result = new List<MEMBER>();
1086

    
1087
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1088
            using (CIEntities entity = new CIEntities(sCIConnString))
1089
            {
1090
                var _UserList = from member in entity.MEMBER
1091
                                where member.ID == UserID
1092
                                select member;
1093
                _result = _UserList.ToList();
1094
            }
1095
            //GC.Collect(2);
1096
            return _result;
1097
        }
1098

    
1099

    
1100
        [OperationContract]
1101
        public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정
1102
        {
1103
            List<string> _result = new List<string>();
1104

    
1105
            try
1106
            {
1107
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1108
                KCOMEntities entity = new KCOMEntities(sConnString);
1109
                var YourEnginner = (from dept in entity.PROPERTIES
1110
                                    where dept.TYPE == "DeptName" && UserDept.Contains(dept.VALUE)
1111
                                    select dept).FirstOrDefault();
1112

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

    
1136
        [OperationContract]
1137
        public bool DeleteMarkup(string ProjectNo, string MarkupInfoID)
1138
        {
1139
            bool _result = false;
1140
            try
1141
            {
1142
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1143
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(sCIConnString))
1144
                {
1145

    
1146
                    MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault();
1147

    
1148
                    if (instance == null)
1149
                    {
1150
                        return false;
1151
                    }
1152
                    MARKUP_INFO_VERSION version = instance.MARKUP_INFO_VERSION.FirstOrDefault();
1153

    
1154

    
1155
                    version.MARKUP_DATA.ToList().ForEach(data =>
1156
                    {
1157
                        Entity.MARKUP_DATA.DeleteObject(data);
1158
                        Entity.SaveChanges();
1159
                    });
1160

    
1161
                    Entity.MARKUP_INFO_VERSION.DeleteObject(version);
1162
                    Entity.SaveChanges();
1163

    
1164
                    Entity.MARKUP_INFO.DeleteObject(instance);
1165
                    Entity.SaveChanges();
1166

    
1167
                }
1168
                _result = true;
1169
            }
1170
            catch (Exception ex)
1171
            {
1172
                System.Diagnostics.Trace.WriteLine(ex, "SaveMarkup");
1173
            }
1174
            finally
1175
            {
1176
                GC.Collect(2);
1177
            }
1178
            return _result;
1179
        }
1180

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

    
1211
                return true;
1212
            }
1213
        }
1214

    
1215
        //[OperationContract]
1216
        //public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
1217
        //{
1218
        //    using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1219
        //    {
1220

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

    
1238
        //        try
1239
        //        {
1240

    
1241

    
1242
        //            if (favoriteSet.Count > 0)
1243
        //            {
1244
        //                var FavoriteVP_Instance = favoriteSet.First();
1245

    
1246
        //                FavoriteVP_Instance.Description = description;
1247
        //                FavoriteVP_Instance.Flag = state;
1248

    
1249
        //                dc.SaveChanges();
1250

    
1251
        //                return true;
1252
        //            }
1253
        //            else
1254
        //            {
1255
        //                return false;
1256
        //            }
1257
        //        }
1258
        //        catch (Exception)
1259
        //        {
1260
        //            return false;
1261
        //        }
1262
        //    }
1263
        //}
1264
        //[OperationContract]
1265
        //public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime)
1266
        //{
1267

    
1268
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1269
        //    {
1270
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1271
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1272

    
1273
        //        try
1274
        //        {
1275

    
1276

    
1277
        //            if (favoriteSet.Count > 0)
1278
        //            {
1279
        //                favoriteSet.ForEach(data => dc.FavoriteVP.DeleteObject(data));
1280
        //                dc.SaveChanges();
1281
        //                return true;
1282
        //            }
1283
        //            else
1284
        //            {
1285
        //                return false;
1286
        //            }
1287
        //        }
1288
        //        catch (Exception)
1289
        //        {
1290
        //            return false;
1291
        //        }
1292
        //    }
1293
        //}
1294
        #endregion
1295

    
1296
        [OperationContract]
1297
        public bool SaveMarkupData(MarkupInfoItem UserState,string project_no,string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1298
        {
1299
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1300
            using (CIEntities Entity = new CIEntities(sCIConnString))
1301
            {     
1302
                #region Docinfo 정보 가져오기
1303

    
1304
                string docinfoid_ = (from info in Entity.DOCINFO
1305
                                     where info.DOCUMENT_ID == doc_id
1306
                                     && info.PROJECT_NO == project_no
1307
                                     select info.ID
1308
                                     ).First().ToString();
1309
                #endregion
1310

    
1311
                #region Markup_Info 저장
1312

    
1313
                MARKUP_INFO markup_info = new MARKUP_INFO();
1314
                try
1315
                {
1316
                    markup_info = (from info in Entity.MARKUP_INFO
1317
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
1318
                                   select info).FirstOrDefault();
1319
                }
1320
                catch (Exception)
1321
                {
1322
                    markup_info = null;
1323
                }
1324

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

    
1351
                #region Markup_Info_Version 저장
1352

    
1353
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1354

    
1355
                try
1356
                {
1357
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1358
                                           where info.MARKUPINFO_ID == markup_info.ID
1359
                                           select info).FirstOrDefault();
1360
                }
1361
                catch (Exception)
1362
                {
1363
                    markup_info_version = null;
1364
                }
1365

    
1366
                //markup_info_version 없을 경우 생성
1367
                if (markup_info_version == null)
1368
                {
1369
                    //MarkupInfo_version 저장
1370
                    markup_info_version = new MARKUP_INFO_VERSION()
1371
                    {
1372
                        ID = UserState.MarkupVersionID,
1373
                        MARKUPINFO_ID = markup_info.ID,
1374
                        CREATE_DATE = DateTime.Now
1375
                    };
1376
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1377
                    Entity.SaveChanges();
1378
                }
1379
                #endregion
1380

    
1381
                
1382
                Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1383
                {
1384
                    Entity.MARKUP_DATA.DeleteObject(item);
1385
                });
1386
                Entity.SaveChanges();
1387

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

    
1413
        //[OperationContract]
1414
        //public long AddMarkupDataGroup(MARKUP_DATA_GROUP mARKUP_DATA_GROUP, string ProjectNo)
1415
        //{
1416
        //    try
1417
        //    {
1418
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1419
        //        {
1420
        //            Entity.AddToMARKUP_DATA_GROUP(mARKUP_DATA_GROUP);
1421
        //            //MARKUP_DATA_GROUP tt = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == id).FirstOrDefault();
1422
        //            Entity.SaveChanges();
1423

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

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

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

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

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

    
1743
                        if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE)
1744
                        {
1745
                            _docpage.PAGE_ANGLE = data.PAGE_ANGLE;
1746
                        }
1747
                    });
1748

    
1749
                    Entity.SaveChanges();
1750
                }
1751
            }
1752
            catch (Exception)
1753
            {
1754
                return false;
1755
            }
1756
            return true;
1757
        }
1758

    
1759
        [OperationContract]
1760
        public MARKUP_INFO GetMarkupInfo(string project_no, string _id)
1761
        {
1762
            MARKUP_INFO markupInfo = new MARKUP_INFO();
1763

    
1764
            try
1765
            {
1766
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1767
                using (CIEntities Entity = new CIEntities(sCIConnString))
1768
                {
1769
                    markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1770
                }
1771
            }
1772
            catch (Exception)
1773
            {
1774
                return null;
1775
            }
1776
            return markupInfo;
1777
        }
1778

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

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

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

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

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

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

    
1906
            try
1907
            {
1908
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1909
                using (CIEntities Entity = new CIEntities(sCIConnString))
1910
                {
1911
                    mlresult = Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == _versionid).ToList();
1912
                }
1913
            }
1914
            catch (Exception)
1915
            {
1916
                return null;
1917
            }
1918
            return mlresult;
1919
        }
1920

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

    
1936
                    foreach (MarkupInfoItem item in markupInfoItems)
1937
                    {
1938
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1939
                        {
1940
                            instanceDataSet.Add(d);
1941
                        });
1942
                    }
1943

    
1944
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1945
                    info.ID = shortGuid();
1946
                    info.CONSOLIDATE = 1;
1947
                    info.CREATE_TIME = DateTime.Now;
1948
                    info.DOCINFO_ID = _doc_id;
1949
                    info.UPDATE_TIME = DateTime.Now;
1950
                    info.USER_ID = _user_id;
1951
                    info.AVOID_CONSOLIDATE = 0;
1952

    
1953
                    Entity.MARKUP_INFO.AddObject(info);
1954
                    Entity.SaveChanges();
1955

    
1956

    
1957
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1958
                    {
1959
                        ID = shortGuid(),
1960
                        CREATE_DATE = DateTime.Now,
1961
                        MARKUP_INFO = info,
1962
                    };
1963
                    Entity.SaveChanges();
1964

    
1965
                    foreach (var item in instanceDataSet)
1966
                    {
1967
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1968
                        {
1969
                            ID = shortGuid(),
1970
                            DATA = item.DATA,
1971
                            DATA_TYPE = item.DATA_TYPE,
1972
                            PAGENUMBER = item.PAGENUMBER,
1973
                            MARKUP_INFO_VERSION = info2,
1974
                            SYMBOL_ID = item.SYMBOL_ID,
1975
                            //GROUP_ID = item.GROUP_ID
1976
                        });
1977
                    }
1978
                    Entity.SaveChanges();
1979

    
1980

    
1981
                }
1982
            }
1983
            catch (Exception)
1984
            {
1985
                return false;
1986
            }
1987
            return true;
1988
        }
1989

    
1990

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

    
2007
                    foreach (MarkupInfoItem item in markupInfoItems)
2008
                    {
2009
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2010
                        {
2011
                            instanceDataSet.Add(d);
2012
                        });
2013
                    }
2014

    
2015
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2016
                    info.ID = shortGuid();
2017
                    info.CONSOLIDATE = 1;
2018
                    info.CREATE_TIME = DateTime.Now;
2019
                    info.DOCINFO_ID = _doc_id;
2020
                    info.UPDATE_TIME = DateTime.Now;
2021
                    info.USER_ID = _user_id;
2022
                    info.AVOID_CONSOLIDATE = 0;
2023

    
2024
                    Entity.MARKUP_INFO.AddObject(info);
2025
                    Entity.SaveChanges();
2026

    
2027

    
2028
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2029
                    {
2030
                        ID = shortGuid(),
2031
                        CREATE_DATE = DateTime.Now,
2032
                        MARKUP_INFO = info,
2033
                    };
2034
                    Entity.SaveChanges();
2035

    
2036
                    foreach (var item in instanceDataSet)
2037
                    {
2038
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2039
                        {
2040
                            ID = shortGuid(),
2041
                            DATA = item.DATA,
2042
                            DATA_TYPE = item.DATA_TYPE,
2043
                            PAGENUMBER = item.PAGENUMBER,
2044
                            MARKUP_INFO_VERSION = info2,
2045
                            SYMBOL_ID = item.SYMBOL_ID,
2046
                            //GROUP_ID = item.GROUP_ID
2047
                        });
2048
                    }
2049
                    Entity.SaveChanges();
2050

    
2051

    
2052
                }
2053
                consolidate = true;
2054
            }
2055
            catch (Exception)
2056
            {
2057
                consolidate = false;
2058
            }
2059
            FinalPDFResult _result = new FinalPDFResult();
2060
            if (consolidate == true)
2061
            {
2062
                RemFinalPDFObject remObj = null;
2063
                try
2064
                {
2065
                    string _finalID = shortGuid();
2066
                    int _DocTotalPages = -1;
2067
                    string docItemId;
2068

    
2069
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2070
                    using (CIEntities _ci = new CIEntities(sCIConnString))
2071
                    {
2072
                        var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
2073

    
2074
                        if (_doc.Count() > 0)
2075
                        {
2076
                            _DocTotalPages = _doc.First().PAGE_COUNT;
2077
                            docItemId = _doc.First().DOCUMENT_ID;
2078
                        }
2079
                        else
2080
                        {
2081
                            _result.Status = FinalStatus.Error;
2082
                            _result.Exception = "페이지 정보를 가져올 수 없습니다.";
2083
                            return _result;
2084
                        }
2085
                    }
2086

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

    
2104
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2105
                        using (KCOMEntities _entity = new KCOMEntities(sConnString))
2106
                        {
2107
                            _entity.AddToFINAL_PDF(fm);
2108
                            _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
2109
                        };
2110

    
2111
                        System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
2112
                        if (_ch == null)
2113
                        {
2114
                            chan = new TcpChannel();
2115
                            _ChanID = chan.ChannelName;
2116
                            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
2117
                            // Create an instance of the remote object
2118

    
2119
                            using (KCOMEntities ec = new KCOMEntities(sConnString))
2120
                            {
2121

    
2122
                                //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2123
                                //                          "tcp://localhost:9092/remFinalPDF");
2124
                                remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2125
                                                          //"tcp://192.168.0.67:9092/remFinalPDF");
2126
                                                          "tcp://192.168.0.67:9092/remFinalPDF");
2127
                            }
2128

    
2129
                            //"tcp://localhost:8080/remFinalPDF");
2130

    
2131
                            _result = remObj.SetFinalPDF(ProjectNo, _finalID);
2132
                            _result.FinalID = _finalID;
2133
                            _result.Status = FinalStatus.Success;
2134

    
2135
                            //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
2136
                            //fa.MakeFinalPDF(fm);
2137
                        }
2138
                        else
2139
                        {
2140
                            _ChanID = _ch.ChannelName;
2141
                        }
2142
                    }
2143
                }
2144
                catch (Exception ex)
2145
                {
2146
                    _result.Status = FinalStatus.Error;
2147

    
2148
                    if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
2149
                        _result.Exception = "Final Server Not Connection";
2150
                }
2151
                finally
2152
                {
2153
                    remObj = null;
2154
                    if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
2155
                        System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
2156

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

    
2184
                    foreach (MarkupInfoItem item in markupInfoItems)
2185
                    {
2186
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2187
                        {
2188
                            instanceDataSet.Add(d);
2189
                        });
2190
                    }
2191

    
2192
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2193
                    info.ID = shortGuid();
2194
                    info.PART_CONSOLIDATE = 1;
2195
                    info.CREATE_TIME = DateTime.Now;
2196
                    info.DOCINFO_ID = _doc_id;
2197
                    info.UPDATE_TIME = DateTime.Now;
2198
                    info.USER_ID = _user_id;
2199
                    info.AVOID_CONSOLIDATE = 0;
2200

    
2201
                    Entity.MARKUP_INFO.AddObject(info);
2202
                    Entity.SaveChanges();
2203

    
2204

    
2205
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2206
                    {
2207
                        ID = shortGuid(),
2208
                        CREATE_DATE = DateTime.Now,
2209
                        MARKUP_INFO = info,
2210
                    };
2211
                    Entity.SaveChanges();
2212

    
2213
                    foreach (var item in instanceDataSet)
2214
                    {
2215
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2216
                        {
2217
                            ID = shortGuid(),
2218
                            DATA = item.DATA,
2219
                            DATA_TYPE = item.DATA_TYPE,
2220
                            PAGENUMBER = item.PAGENUMBER,
2221
                            MARKUP_INFO_VERSION = info2,
2222
                            SYMBOL_ID = item.SYMBOL_ID,
2223
                            //GROUP_ID = item.GROUP_ID
2224
                        });
2225
                    }
2226
                    Entity.SaveChanges();
2227

    
2228

    
2229
                }
2230
            }
2231
            catch (Exception)
2232
            {
2233
                return false;
2234
            }
2235
            return true;
2236
        }
2237

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

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

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

    
2415
            }
2416
            catch (Exception)
2417
            {
2418
                return null;
2419
            }
2420
            return result;
2421
        }
2422

    
2423
        [OperationContract]        
2424
        public string GetProjectName(string project_no)
2425
        {
2426
            string result = null;
2427

    
2428
            try
2429
            {
2430
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2431
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
2432
                {
2433
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
2434
                }
2435
            }
2436
            catch (Exception)
2437
            {
2438
                return null;
2439
            }
2440
            return result;
2441
        }
2442

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

    
2465
        [OperationContract]
2466
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
2467
        {
2468
            DOCINFO docinfo = null;
2469

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

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

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

    
2529
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
2530
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
2531

    
2532
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
2533
                        {
2534
                            MarkupItem markitem = new MarkupItem()
2535
                            {
2536
                                ID = markdata.ID,
2537
                                PageNumber = markdata.PAGENUMBER,
2538
                            };
2539
                            _result.MarkupList.Add(markitem);
2540
                        }
2541

    
2542
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
2543

    
2544
                        markupinfo.Add(_result);
2545
                    }
2546
                }
2547
            }
2548
            catch (Exception)
2549
            {
2550
                return null;
2551
            }
2552
            return markupinfo;
2553
        }
2554

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

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

    
2593

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

    
2640

    
2641
        }
2642
        #endregion
2643

    
2644
        #region Final Service
2645
        [OperationContract]
2646
        [ServiceKnownType(typeof(DOCINFO))]                
2647
        public DOCINFO FinalPDF_GetDocinfo(string project_no, string docinfo_id)
2648
        {
2649
            DOCINFO docinfo = null;
2650

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

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

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

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

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

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

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

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

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

    
2925
        [OperationContract]
2926
        public bool FinalPDF_SetCurrentPage(string final_id, int currentpage)
2927
        {
2928
            bool result = false;
2929

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

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

    
2977
        [OperationContract]
2978
        public bool FinalPDF_SetFinalResultPath(string project_no, string document_id, string url)
2979
        {
2980
            bool result = false;
2981

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

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

    
3057
            }
3058
            catch (Exception)
3059
            {
3060
                throw;
3061
            }
3062
            return results;
3063
        }
3064
        #endregion
3065
    }    
3066
}
클립보드 이미지 추가 (최대 크기: 500 MB)