프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ b4b23404

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

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

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

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

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

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

    
86
                    KCOM_SystemInfo sysInfo = new KCOM_SystemInfo();
87

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

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

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

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

    
123
            var guid = new Guid(bytes);
124

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

    
131

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

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

    
144

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

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

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

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

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

    
173
                        dc.SaveChanges();
174

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

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

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

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

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

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

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

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

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

    
257
            return result;
258
        }
259

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

    
265
        //    stopwatch.Start();
266

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

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

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

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

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

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

    
292
        //    return result;
293
        //}
294

    
295

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

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

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

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

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

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

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

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

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

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

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

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

    
404

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

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

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

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

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

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

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

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

    
540
                }
541
                return _result;
542

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

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

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

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

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

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

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

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

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

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

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

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

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

    
679
                    _result.ForEach(r =>
680
                    {
681

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

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

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

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

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

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

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

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

    
743
            return _result;
744
        }
745

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

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

    
777

    
778

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

    
784

    
785

    
786
                    _result.ForEach(r =>
787
                    {
788

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

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

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

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

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

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

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

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

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

    
858
            return _result;
859
        }
860

    
861

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

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

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

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

    
897

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

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

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

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

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

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

    
952

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

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

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

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

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

    
1009
                return true;
1010
            }
1011
        }
1012

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

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

    
1036
        //        try
1037
        //        {
1038

    
1039

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

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

    
1047
        //                dc.SaveChanges();
1048

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

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

    
1071
        //        try
1072
        //        {
1073

    
1074

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

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

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

    
1110
                #region Markup_Info 저장
1111

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

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

    
1150
                #region Markup_Info_Version 저장
1151

    
1152
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1153

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

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

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

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

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

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

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

    
1228
                #region Markup_Info 저장
1229

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

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

    
1268
                #region Markup_Info_Version 저장
1269

    
1270
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1271

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

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

    
1298

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1873

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

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

    
1897

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

    
1907

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

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

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

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

    
1944

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

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

    
1968

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2121

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

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

    
2145

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

    
2155
        [OperationContract]
2156
        [ServiceKnownType(typeof(MEMBER))]
2157
        public MEMBER GetMember(string project_no, string user_id)
2158
        {
2159
            MEMBER rstmember = new MEMBER();
2160
            try
2161
            {
2162
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2163
                using (CIEntities Entity = new CIEntities(sCIConnString))
2164
                {
2165
                    var tmp = (from member in Entity.MEMBER
2166
                                    where member.ID == user_id && member.PROJECT_NO == project_no
2167
                                    select member).FirstOrDefault();
2168
                    rstmember.DEPARTMENT = tmp.DEPARTMENT;
2169
                    rstmember.ID = tmp.ID;
2170
                    rstmember.NAME = tmp.NAME;
2171
                }
2172
            }
2173
            catch (Exception ex)
2174
            {
2175
                return null;
2176
            }
2177
            return rstmember;
2178
        }
2179

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

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

    
2332
            }
2333
            catch (Exception)
2334
            {
2335
                return null;
2336
            }
2337
            return result;
2338
        }
2339

    
2340
        [OperationContract]        
2341
        public string GetProjectName(string project_no)
2342
        {
2343
            string result = null;
2344

    
2345
            try
2346
            {
2347
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2348
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
2349
                {
2350
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
2351
                }
2352
            }
2353
            catch (Exception)
2354
            {
2355
                return null;
2356
            }
2357
            return result;
2358
        }
2359

    
2360
        [OperationContract]
2361
        public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev)
2362
        {
2363
            List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>();
2364
            
2365
            try
2366
            {
2367
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2368
                using (CIEntities Entity = new CIEntities(sCIConnString))
2369
                {
2370
                    result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no
2371
                    && i.DOCUMENT_NO == doc_no
2372
                    && i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList();
2373
                }
2374
            }
2375
            catch (Exception)
2376
            {
2377
                return null;
2378
            }
2379
            return result;
2380
        }
2381

    
2382
        [OperationContract]
2383
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
2384
        {
2385
            DOCINFO docinfo = null;
2386

    
2387
            try
2388
            {
2389
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2390
                using (CIEntities Entity = new CIEntities(sCIConnString))
2391
                {
2392
                    docinfo = (from info in Entity.DOCINFO
2393
                              where info.DOCUMENT_ID == doc_id
2394
                              && info.PROJECT_NO == project_no
2395
                              select info).First();
2396
                }
2397
            }
2398
            catch (Exception)
2399
            {
2400
                return null;
2401
            }
2402
            return docinfo;
2403
        }
2404

    
2405
        [OperationContract]
2406
        public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList)
2407
        {
2408
            MarkupInfoItem _result = null;
2409
            List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>();
2410
            try
2411
            {
2412
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2413
                using (CIEntities Entity = new CIEntities(sCIConnString))
2414
                {
2415
                    var docitem = (from info in Entity.DOCINFO
2416
                               where info.DOCUMENT_ID == doc_id
2417
                               && info.PROJECT_NO == project_no
2418
                               select info).First();
2419

    
2420
                    foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO)
2421
                    {
2422
                        var member = (from mem in Entity.MEMBER
2423
                                     where mem.ID == markinfo.USER_ID
2424
                                     select mem).First();
2425
                        string displaycolor = null;
2426
                        try
2427
                        {
2428
                            displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor;
2429
                        }
2430
                        catch(Exception)
2431
                        {
2432
                            displaycolor = "#FFFFFF";
2433
                        }
2434
                        
2435
                        _result = new MarkupInfoItem
2436
                        {
2437
                            MarkupInfoID = markinfo.ID,
2438
                            Consolidate = markinfo.CONSOLIDATE,
2439
                            CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME,
2440
                            DisplayColor = displaycolor,
2441
                            UserID = markinfo.USER_ID,
2442
                            UserName = member.NAME,
2443
                            Depatment = member.DEPARTMENT,
2444
                        };
2445

    
2446
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
2447
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
2448

    
2449
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
2450
                        {
2451
                            MarkupItem markitem = new MarkupItem()
2452
                            {
2453
                                ID = markdata.ID,
2454
                                PageNumber = markdata.PAGENUMBER,
2455
                            };
2456
                            _result.MarkupList.Add(markitem);
2457
                        }
2458

    
2459
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
2460

    
2461
                        markupinfo.Add(_result);
2462
                    }
2463
                }
2464
            }
2465
            catch (Exception)
2466
            {
2467
                return null;
2468
            }
2469
            return markupinfo;
2470
        }
2471

    
2472
        [OperationContract]
2473
        public bool AddMessage(string project_no, TALK value)
2474
        {
2475
            try
2476
            {
2477
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2478
                using (CIEntities entity = new CIEntities(sCIConnString))
2479
                {                    
2480
                    entity.TALK.AddObject(value);
2481
                    entity.SaveChanges();
2482
                }
2483
            }
2484
            catch (Exception)
2485
            {
2486
                return false;
2487
            }
2488
            return true;
2489
        }
2490

    
2491
        [OperationContract]
2492
        public List<TALK> GetMessage(string project_no, string doc_id)
2493
        {
2494
            List<TALK> result = new List<TALK>();
2495
            try
2496
            {
2497
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2498
                using (CIEntities entity = new CIEntities(sCIConnString))
2499
                {
2500
                    result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList();                        
2501
                }
2502
            }
2503
            catch (Exception ex)
2504
            {
2505
                return result;
2506
            }
2507
            return result;
2508
        }
2509

    
2510

    
2511
        #region Legacy System I/F
2512
        /// <summary>
2513
        /// Ensemble+ Sign Data Return
2514
        /// </summary>
2515
        /// <param name="user_id"></param>
2516
        /// <returns></returns>
2517
        private string getEnsembleSign(string user_id)
2518
        {
2519
            string result = string.Empty;
2520
            string soapurl = string.Empty;
2521
            try
2522
            {
2523
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2524
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2525
                {
2526
                    var item = Entity.PROPERTIES.Where(d => d.TYPE == "UpLoadServiceUrl").FirstOrDefault();
2527
                    soapurl = item.VALUE;
2528
                }
2529
                WebClient webClient = new WebClient();
2530
                string data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ens=\"http://EnsemblePlus.Webservice\"> <soapenv:Header/> <soapenv:Body> <ens:checkoutSignImage>"
2531
                    + "<ens:sUserNo>" + user_id + "</ens:sUserNo>"
2532
                    + "</ens:checkoutSignImage> </soapenv:Body></soapenv:Envelope>";
2533
                webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
2534
                webClient.Headers.Add("SOAPAction", "http://EnsemblePlus.Webservice");
2535
                var _result = webClient.UploadString(new Uri(soapurl), data);
2536
                XmlDocument xmlDoc = new XmlDocument();
2537
                xmlDoc.LoadXml(_result);
2538
                XmlNodeList list = xmlDoc.GetElementsByTagName("checkoutSignImageResponse");
2539
                foreach (XmlNode xn in list)
2540
                {
2541
                    result = xn["checkoutSignImageReturn"].InnerText;
2542
                }
2543
                if (!result.Contains("No business object"))
2544
                {
2545
                    return result;
2546
                }
2547
                else
2548
                {
2549
                    return null;
2550
                }
2551
            }
2552
            catch (Exception ex)
2553
            {
2554
                return null;
2555
            }
2556

    
2557

    
2558
        }
2559
        #endregion
2560

    
2561
        #region Final Service
2562
        [OperationContract]
2563
        [ServiceKnownType(typeof(DOCINFO))]                
2564
        public DOCINFO FinalPDF_GetDocinfo(string project_no, string docinfo_id)
2565
        {
2566
            DOCINFO docinfo = null;
2567

    
2568
            try
2569
            {
2570
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2571
                using (CIEntities _entity = new CIEntities(sCIConnString))
2572
                {
2573
                    var doc = _entity.DOCINFO.Where(x => x.ID == docinfo_id).FirstOrDefault();
2574
                    if(doc != null)
2575
                    {
2576
                        docinfo = new DOCINFO()
2577
                        {
2578
                            ID = doc.ID,
2579
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2580
                            PAGE_COUNT = doc.PAGE_COUNT,
2581
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2582
                            PROJECT_NO = doc.PROJECT_NO
2583
                        };
2584
                    }                    
2585
                }
2586
            }
2587
            catch (Exception)
2588
            {
2589
                throw;
2590
            }
2591
            return docinfo;
2592
        }
2593
        [OperationContract]
2594
        [ServiceKnownType(typeof(DOCUMENT_ITEM))]
2595
        public DOCUMENT_ITEM FinalPDF_GetDocumentItem(string project_no, string document_id)
2596
        {
2597
            DOCUMENT_ITEM item = null;
2598

    
2599
            try
2600
            {
2601
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2602
                using (CIEntities _entity = new CIEntities(sCIConnString))
2603
                {
2604
                    var doc = _entity.DOCUMENT_ITEM.Where(x => x.DOCUMENT_ID == document_id).FirstOrDefault();
2605
                    if(doc != null)
2606
                    {
2607
                        item = new DOCUMENT_ITEM()
2608
                        {
2609
                            ID = doc.ID,
2610
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2611
                            PROJECT_NO = doc.PROJECT_NO,
2612
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2613
                            DOCUMENT_NO = doc.DOCUMENT_NO,
2614
                            DOCUMENT_NAME = doc.DOCUMENT_NAME,
2615
                            //ENSEMBLEINFO_URL = doc.ENSEMBLEINFO_URL,
2616
                            GROUP_NO = doc.GROUP_NO,
2617
                            RESULT = doc.RESULT,
2618
                            REVISION = doc.REVISION,
2619
                            RESULT_FILE = doc.RESULT_FILE
2620
                        };
2621
                    }
2622
                    
2623
                }
2624
            }
2625
            catch (Exception)
2626
            {
2627
                throw;
2628
            }
2629
            return item;
2630
        }
2631
        [OperationContract]
2632
        [ServiceKnownType(typeof(MARKUP_DATA))]
2633
        public List<MARKUP_DATA> FinalPDF_GetMarkupdata(string project_no, string docinfo_id)
2634
        {
2635
            List<MARKUP_DATA> results = new List<MARKUP_DATA>();
2636

    
2637
            try
2638
            {
2639
                //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2640
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2641
                using (CIEntities _entity = new CIEntities(sCIConnString))
2642
                {
2643
                    var datas = _entity.MARKUP_DATA.Where(x => x.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO_ID == docinfo_id
2644
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1
2645
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.AVOID_CONSOLIDATE == 0
2646
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.PART_CONSOLIDATE == 0).ToList();
2647
                    foreach (var data in datas)
2648
                    {
2649
                        MARKUP_DATA d = new MARKUP_DATA()
2650
                        {
2651
                            ID = data.ID,
2652
                            //GROUP_ID = data.GROUP_ID,
2653
                            SYMBOL_ID = data.SYMBOL_ID,
2654
                            DATA = data.DATA,
2655
                            DATA_TYPE = data.DATA_TYPE,
2656
                            MARKUPINFO_VERSION_ID = data.MARKUPINFO_VERSION_ID,
2657
                            PAGENUMBER = data.PAGENUMBER
2658
                        };
2659
                        results.Add(d);
2660
                    }
2661
                }
2662
            }
2663
            catch (Exception)
2664
            {
2665
                throw;
2666
            }
2667
            return results;
2668
        }
2669
        [OperationContract]
2670
        [ServiceKnownType(typeof(MARKUP_INFO))]
2671
        public MARKUP_INFO FinalPDF_GetMarkupinfo(string project_no, string docinfo_id)
2672
        {
2673
            MARKUP_INFO markupInfo = null;
2674

    
2675
            try
2676
            {
2677
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2678
                using (CIEntities _entity = new CIEntities(sCIConnString))
2679
                {
2680
                    var tmp = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo_id && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0).FirstOrDefault();
2681
                    if (tmp != null)
2682
                    {
2683
                        markupInfo = new MARKUP_INFO()
2684
                        {
2685
                            ID = tmp.ID,
2686
                            DOCINFO_ID = tmp.DOCINFO_ID,
2687
                            USER_ID = tmp.USER_ID
2688
                        };
2689
                    }                    
2690
                }
2691
            }
2692
            catch (Exception)
2693
            {
2694
                throw;
2695
            }
2696
            return markupInfo;
2697
        }
2698
        [OperationContract]
2699
        [ServiceKnownType(typeof(FINAL_PDF))]
2700
        public List<FINAL_PDF> FinalPDF_GetFinalPDFs(string final_id)
2701
        {
2702
            List<FINAL_PDF> results = new List<FINAL_PDF>();
2703

    
2704
            try
2705
            {
2706
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2707
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2708
                {
2709
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == final_id).ToList();
2710
                    foreach(var final in finalList)
2711
                    {
2712
                        FINAL_PDF pdf = new FINAL_PDF()
2713
                        {
2714
                            ID = final.ID,
2715
                            DOCINFO_ID = final.DOCINFO_ID,
2716
                            DOCUMENT_ID = final.DOCUMENT_ID,
2717
                            STATUS = final.STATUS,
2718
                            CURRENT_PAGE = final.CURRENT_PAGE,
2719
                            CREATE_DATETIME = final.CREATE_DATETIME,
2720
                            START_DATETIME = final.START_DATETIME,
2721
                            END_DATETIME = final.END_DATETIME,
2722
                            EXCEPTION = final.EXCEPTION,
2723
                            PROJECT_NO = final.PROJECT_NO,
2724
                            TOTAL_PAGE = final.TOTAL_PAGE,
2725
                            MARKUPINFO_ID = final.MARKUPINFO_ID,
2726
                            CREATE_USER_ID = final.CREATE_USER_ID
2727
                        };
2728
                        results.Add(pdf);
2729
                    }
2730
                }
2731
            }
2732
            catch (Exception)
2733
            {
2734
                throw;
2735
            }
2736
            return results;
2737
        }
2738
        [OperationContract]
2739
        [ServiceKnownType(typeof(DOCPAGE))]
2740
        public List<DOCPAGE> FinalPDF_GetDocpage(string project_no, string docinfo_id)
2741
        {
2742
            List<DOCPAGE> results = new List<DOCPAGE>();
2743

    
2744
            try
2745
            {
2746
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2747
                using (CIEntities _entity = new CIEntities(sCIConnString))
2748
                {
2749
                    var pages = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == docinfo_id).OrderBy(x => x.PAGE_NUMBER).ToList();
2750
                    foreach(var page in pages)
2751
                    {
2752
                        DOCPAGE p = new DOCPAGE()
2753
                        {
2754
                            PAGE_ANGLE = page.PAGE_ANGLE,
2755
                            PAGE_NUMBER = page.PAGE_NUMBER,
2756
                            PAGE_HEIGHT = page.PAGE_HEIGHT,
2757
                            PAGE_WIDTH = page.PAGE_WIDTH,
2758
                            DOCINFO_ID = page.DOCINFO_ID                            
2759
                        };
2760
                        results.Add(p);
2761
                    }                    
2762
                }
2763
            }
2764
            catch (Exception)
2765
            {
2766
                throw;
2767
            }
2768
            return results;
2769
        }
2770
        [OperationContract]        
2771
        public bool FinalPDF_SetFinalPDFStatus(string final_id, FinalStatus status)
2772
        {
2773
            bool result = false;
2774

    
2775
            try
2776
            {
2777
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2778
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2779
                {
2780
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2781
                    if(tmp != null)
2782
                    {
2783
                        switch(status)
2784
                        {
2785
                            case FinalStatus.Create:
2786
                                tmp.START_DATETIME = DateTime.Now;
2787
                                break;
2788
                            case FinalStatus.Success:
2789
                                tmp.END_DATETIME = DateTime.Now;
2790
                                tmp.EXCEPTION = string.Empty;
2791
                                break;                                
2792
                        }
2793
                        tmp.STATUS = (int)status;
2794
                        _entity.SaveChanges();
2795
                        result = true;                        
2796
                    }
2797
                }                    
2798
            }
2799
            catch (Exception)
2800
            {
2801
                throw;
2802
            }
2803
            return result;
2804
        }
2805

    
2806
        /// <summary>
2807
        /// 현재 진행중인 Final PDF 가 없거나 Success 일 경우에만 true return
2808
        /// </summary>
2809
        /// <param name="DocInfoID"></param>
2810
        /// <param name="MarkupInfoID"></param>
2811
        /// <param name="CreateUserID"></param>
2812
        /// <returns></returns>
2813
        [OperationContract]
2814
        public bool FinalPDF_GetFinalPDFStatus(string DocInfoID, string MarkupInfoID, string CreateUserID)
2815
        {
2816
            bool result = false;
2817

    
2818
            try
2819
            {
2820
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2821
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2822
                {
2823
                    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();
2824
                    if (finalpdf != null)
2825
                    {
2826
                        if (finalpdf.STATUS == (int)FinalStatus.Success)
2827
                        {
2828
                            result = true;
2829
                        }
2830
                    }
2831
                    else
2832
                        result = true;
2833
                }
2834
            }
2835
            catch (Exception)
2836
            {
2837
                throw;
2838
            }
2839
            return result;
2840
        }
2841

    
2842
        [OperationContract]
2843
        public bool FinalPDF_SetCurrentPage(string final_id, int currentpage)
2844
        {
2845
            bool result = false;
2846

    
2847
            try
2848
            {
2849
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2850
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2851
                {
2852
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2853
                    if (tmp != null)
2854
                    {
2855
                        tmp.CURRENT_PAGE = currentpage;
2856
                        _entity.SaveChanges();
2857
                        result = true;
2858
                    }
2859
                }
2860
            }
2861
            catch (Exception)
2862
            {
2863
                throw;
2864
            }
2865
            return result;
2866
        }
2867
        [OperationContract]
2868
        public bool FinalPDF_SetError(string final_id, string msg)
2869
        {
2870
            bool result = false;
2871

    
2872
            try
2873
            {
2874
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2875
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2876
                {
2877
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2878
                    if (tmp != null)
2879
                    {                        
2880
                        tmp.STATUS = (int)FinalStatus.Error;
2881
                        tmp.EXCEPTION = DateTime.Now.ToShortDateString() + " " + msg;                        
2882
                        _entity.SaveChanges();
2883
                        result = true;
2884
                    }
2885
                }
2886
            }
2887
            catch (Exception)
2888
            {
2889
                throw;
2890
            }
2891
            return result;
2892
        }
2893

    
2894
        [OperationContract]
2895
        public bool FinalPDF_SetFinalResultPath(string project_no, string document_id, string url)
2896
        {
2897
            bool result = false;
2898

    
2899
            try
2900
            {
2901
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2902
                using (CIEntities _entity = new CIEntities(sCIConnString))
2903
                {
2904
                    var item = _entity.DOCUMENT_ITEM.Where(d => d.DOCUMENT_ID == document_id).FirstOrDefault();
2905
                    if (item != null)
2906
                    {
2907
                        item.RESULT_FILE = url;
2908
                        _entity.SaveChanges();
2909
                        result = true;
2910
                    }
2911
                }
2912
            }
2913
            catch (Exception)
2914
            {
2915
                throw;
2916
            }
2917
            return result;
2918
        }
2919
        [OperationContract]
2920
        [ServiceKnownType(typeof(MEMBER))]
2921
        public MEMBER FinalPDF_GetCommentMember(string project_no, string markupdata_id)
2922
        {
2923
            MEMBER member = null;
2924
            try
2925
            {
2926
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2927
                using (CIEntities _entity = new CIEntities(sCIConnString))
2928
                {
2929
                    var data = _entity.MARKUP_DATA.Where(x => x.ID == markupdata_id).FirstOrDefault();
2930
                    string user_id = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
2931
                    var person = _entity.MEMBER.Where(p => p.ID == user_id).FirstOrDefault();
2932
                    if(person != null)
2933
                    {
2934
                        member = new MEMBER()
2935
                        {
2936
                            ID = user_id,
2937
                            NAME = person.NAME,
2938
                            DEPARTMENT = person.DEPARTMENT
2939
                        };
2940
                    }
2941
                }
2942
            }
2943
            catch (Exception)
2944
            {
2945
                throw;
2946
            }
2947
            return member;
2948
        }
2949

    
2950
        [OperationContract]
2951
        [ServiceKnownType(typeof(PROPERTIES))]
2952
        public List<PROPERTIES> FinalPDF_GetProperties(string project_no)
2953
        {
2954
            List<PROPERTIES> results = new List<PROPERTIES>();
2955
            try
2956
            {
2957
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2958
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2959
                {
2960
                    var _items = _entity.PROPERTIES.Where(x => x.PROPERTY == project_no).ToList();
2961
                    foreach(var item in _items)
2962
                    {
2963
                        PROPERTIES pROPERTIES = new PROPERTIES()
2964
                        {
2965
                            ID = item.ID,
2966
                            PROPERTY = item.PROPERTY,
2967
                            TYPE = item.TYPE,
2968
                            VALUE = item.VALUE
2969
                        };
2970
                        results.Add(pROPERTIES);
2971
                    }
2972
                }
2973

    
2974
            }
2975
            catch (Exception)
2976
            {
2977
                throw;
2978
            }
2979
            return results;
2980
        }
2981
        #endregion
2982
    }    
2983
}
클립보드 이미지 추가 (최대 크기: 500 MB)