프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ d1b3a4fe

이력 | 보기 | 이력해설 | 다운로드 (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
        /// 대림의 경우 Interface ID(Document 의 ID) 를 parameter 로 전달
572
        /// 넘어온 ID를 통해 document id 를 확인하는 과정이 필요
573
        /// <param name="ensemble_id"></param>
574
        /// <returns></returns>
575
        [OperationContract]
576
        public string GetDocItemID(string ensemble_id)
577
        {
578
            ///param : prjNo, documentId, userId
579
            string _result = string.Empty;
580

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

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

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

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

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

    
638
                    _result.ForEach(r =>
639
                    {
640

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

    
647
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
648
                    Random random = new Random();
649

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

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

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

    
694
            return _result;
695
        }
696

    
697

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

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

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

    
729
                    _result.ForEach(r =>
730
                    {
731

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

    
738
                    Random random = new Random();
739

    
740
                    _MemberDeptColors memberDeptColors = new _MemberDeptColors();
741
                    _MemberDeptColorsInfo memberDeptColorsInfo = new _MemberDeptColorsInfo();
742

    
743

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

    
751

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

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

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

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

    
783

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

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

    
825
            return _result;
826
        }
827

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

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

    
861

    
862

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

    
868

    
869

    
870
                    _result.ForEach(r =>
871
                    {
872

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

    
879
                    _ColorsProperties colors = new _ColorsProperties();
880
                    Random random = new Random();
881

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

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

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

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

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

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

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

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

    
995

    
996

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

    
1002

    
1003

    
1004
                    _result.ForEach(r =>
1005
                    {
1006

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

    
1013
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
1014
                    Random random = new Random();
1015

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

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

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

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

    
1062
            return _result;
1063
        }
1064

    
1065

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

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

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

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

    
1101

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

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

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

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

    
1148
                    MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault();
1149

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

    
1156

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

    
1163
                    Entity.MARKUP_INFO_VERSION.DeleteObject(version);
1164
                    Entity.SaveChanges();
1165

    
1166
                    Entity.MARKUP_INFO.DeleteObject(instance);
1167
                    Entity.SaveChanges();
1168

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

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

    
1213
                return true;
1214
            }
1215
        }
1216

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

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

    
1240
        //        try
1241
        //        {
1242

    
1243

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

    
1248
        //                FavoriteVP_Instance.Description = description;
1249
        //                FavoriteVP_Instance.Flag = state;
1250

    
1251
        //                dc.SaveChanges();
1252

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

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

    
1275
        //        try
1276
        //        {
1277

    
1278

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

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

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

    
1313
                #region Markup_Info 저장
1314

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

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

    
1353
                #region Markup_Info_Version 저장
1354

    
1355
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1356

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1955
                    Entity.MARKUP_INFO.AddObject(info);
1956
                    Entity.SaveChanges();
1957

    
1958

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

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

    
1982

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

    
1992

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

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

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

    
2026
                    Entity.MARKUP_INFO.AddObject(info);
2027
                    Entity.SaveChanges();
2028

    
2029

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

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

    
2053

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

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

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

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

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

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

    
2121
                            using (KCOMEntities ec = new KCOMEntities(sConnString))
2122
                            {
2123

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

    
2131
                            //"tcp://localhost:8080/remFinalPDF");
2132

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

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

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

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

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

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

    
2203
                    Entity.MARKUP_INFO.AddObject(info);
2204
                    Entity.SaveChanges();
2205

    
2206

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

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

    
2230

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2544
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
2545

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

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

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

    
2595

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

    
2642

    
2643
        }
2644
        #endregion
2645

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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