프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ d60f94ee

이력 | 보기 | 이력해설 | 다운로드 (129 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
using ColorSelector;
20

    
21
namespace KCOM_API
22
{
23
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ServiceDeepView" in code, svc and config file together.
24
    // NOTE: In order to launch WCF Test Client for testing this service, please select ServiceDeepView.svc or ServiceDeepView.svc.cs at the Solution Explorer and start debugging.
25
    [ServiceContract(Namespace = "")]
26
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
27
    public partial class ServiceDeepView : System.Web.Services.WebService
28
    {
29
        public ServiceDeepView()
30
        {
31
            //System.Diagnostics.Debug.WriteLine(OperationContext.Current.RequestContext.RequestMessage.Headers.Action.ToString());
32
        }
33

    
34
        /// <summary>
35
        /// Client Version 과 Server Version 을 비교하여 Server Version 이 최신이면 다운로드 url 리턴.
36
        /// </summary>
37
        /// <param name="is64BitProcess">64bit = true, 32bit = false</param>
38
        /// <param name="markusVer">client version</param>
39
        /// <returns></returns>
40
        [OperationContract]
41
        public string GetVersionData(bool is64BitProcess, string markusVer)
42
        {
43
            string url = null;
44

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

    
66
                //서버 버전이 최신이면 0보다 큰값 리턴
67
                Version server_version = new Version(dbvalue.PROPERTY);
68
                int result = server_version.CompareTo(client_version);  
69
                if (result > 0)
70
                {
71
                    url = dbvalue.VALUE;
72
                }
73
            }
74
            catch (Exception ex)
75
            {
76
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetVersionData : " + ex.ToString());
77

    
78
                url = null;
79
            }
80
            return url;
81
        }
82
    
83

    
84
        [OperationContract]
85
        public KCOM_SystemInfo GetSystemData()
86
        {
87
            try
88
            {
89
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
90
                using (KCOMEntities uc = new KCOMEntities(sConnString))
91
                {
92
                    var SystemInfoSet = uc.PROPERTIES.Where(data => data.TYPE == "SystemInfo").ToList();
93

    
94
                    KCOM_SystemInfo sysInfo = new KCOM_SystemInfo();
95

    
96
                    var url = SystemInfoSet.Where(data => data.PROPERTY == "Url").FirstOrDefault();
97
                    if (url != null)
98
                    {
99
                        sysInfo.HostName = url.VALUE;
100
                    }
101

    
102
                    url = SystemInfoSet.Where(data => data.PROPERTY == "Port").FirstOrDefault();
103
                    if (url != null)
104
                    {
105
                        sysInfo.HostPort = url.VALUE;
106
                    }
107

    
108
                    url = uc.PROPERTIES.Where(data => data.TYPE == "STAMP").FirstOrDefault();
109
                    if(url != null)
110
                    {
111
                        sysInfo.STAMP = url.VALUE;
112
                    }
113
                    return sysInfo;
114
                }
115
            }
116
            catch (Exception ex)
117
            {
118
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetSystemData : " + ex.ToString());
119

    
120
            }
121
            return null;
122
            //GC.Collect(2);
123
        }
124

    
125
        private static string shortGuid()
126
        { 
127
            byte[] bytes = new byte[16];
128
            using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create())
129
            {
130
                provider.GetBytes(bytes);
131
            }
132

    
133
            var guid = new Guid(bytes);
134

    
135
            return Convert.ToBase64String(guid.ToByteArray())
136
                .Substring(0, 10)
137
                .Replace("/", "")
138
                .Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x");
139
        }
140

    
141

    
142
        [OperationContract]
143
        public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
144
        {
145
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
146
            using (KCOMEntities dc = new KCOMEntities(sConnString))
147
            {
148

    
149
                int flagString = Convert.ToInt32(FAVORITE_FLAG.Personal);
150
                List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
151
                //dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
152
                //    flagString).ToList().ForEach(data => favoriteListSet.Add(data));
153

    
154

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

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

    
159
                //favoriteListSet = favoriteListSet.Distinct().ToList();
160
                return favoriteListSet;
161
            }
162
        }
163

    
164
        [OperationContract]
165
        public bool EditFavoriteVP(string prjNo, string userID, string docID, int state, string description)
166
        {
167
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
168
            using (KCOMEntities dc = new KCOMEntities(sConnString))
169
            {
170
                //List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
171
                //    && data.PAGE_NO == SavePageNo && data.CREATE_TIME == createTime).ToList();
172
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
173
                    && data.ID == docID).ToList();
174
                try
175
                {
176

    
177
                    if (favoriteSet.Count > 0)
178
                    {
179
                        var FavoriteVP_Instance = favoriteSet.First();
180

    
181
                        FavoriteVP_Instance.DESCRIPTION = description;
182
                        FavoriteVP_Instance.FLAG = state;
183

    
184
                        dc.SaveChanges();
185

    
186
                        return true;
187
                    }
188
                    else
189
                    {
190
                        return false;
191
                    }
192
                }
193
                catch (Exception ex)
194
                {
195
                    System.Diagnostics.Debug.WriteLine("KCOM_API - EditFavoriteVP : " + ex.ToString());
196

    
197
                    return false;
198
                }
199
            }
200
        }
201

    
202
        [OperationContract]
203
        public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string docID)
204
        {
205
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
206
            using (KCOMEntities dc = new KCOMEntities(sConnString))
207
            {
208

    
209
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
210
                    && data.ID == docID).ToList();
211

    
212
                try
213
                {
214
                    if (favoriteSet.Count > 0)
215
                    {
216
                        favoriteSet.ForEach(data => dc.FAVORITE_DOC.DeleteObject(data));
217
                        dc.SaveChanges();
218
                        return true;
219
                    }
220
                    else
221
                    {
222
                        return false;
223
                    }
224
                }
225
                catch (Exception ex)
226
                {
227
                    System.Diagnostics.Debug.WriteLine("KCOM_API - DelFavoriteVP : " + ex.ToString());
228

    
229
                    return false;
230
                }
231
            }
232
        }
233

    
234
        /// <summary>
235
        /// 두 페이지를 비교하여 결과를 리턴한다
236
        /// </summary>
237
        /// <param name="projectNo"></param>
238
        /// <param name="originDocItem_ID"></param>
239
        /// <param name="targetDocItem_ID"></param>
240
        /// <param name="originPageNo"></param>
241
        /// <param name="targetPageNo"></param>
242
        /// <param name="isInternalAddress"></param>
243
        /// <returns></returns>
244
        [OperationContract]
245
        public List<Rect> GetCompareRect(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress)
246
        {
247
            List<Rect> result = new List<Rect>();
248

    
249
            try
250
            {
251
                string originFile = "";
252
                string targetFile = "";
253

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

    
257
                if (Boolean.Parse(isInternalAddress))
258
                {
259
                    originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sOriginFolder, originDocItem_ID, originPageNo);
260
                    targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sTagetFolder, targetDocItem_ID, targetPageNo);
261
                }
262
                else
263
                {
264
                    originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo);
265
                    targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo);
266
                }
267

    
268
                using (Markus.Image.ImageCompare compareLib = new Markus.Image.ImageCompare())
269
                {
270
                    result = compareLib.CompareReturnRects(originFile, targetFile, new System.Drawing.Size(20, 20));
271
                }
272
            }
273
            catch (Exception ex)
274
            {
275
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetCompareRect : " + ex.ToString());
276
                //throw new FaultException(ex.ToString() + " Inner Exception : " + ex.InnerException?.ToString());
277
            }
278

    
279

    
280
            return result;
281
        }
282

    
283
        /// <summary>
284
        /// 두 페이지를 비교하여 결과를 리턴한다
285
        /// </summary>
286
        /// <param name="projectNo"></param>
287
        /// <param name="originDocItem_ID"></param>
288
        /// <param name="targetDocItem_ID"></param>
289
        /// <param name="originPageNo"></param>
290
        /// <param name="targetPageNo"></param>
291
        /// <param name="isInternalAddress"></param>
292
        /// <returns></returns>
293
        [OperationContract]
294
        public List<Rect> GetComparefixSize(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo,Size FixSize, string isInternalAddress)
295
        {
296
            List<Rect> result = new List<Rect>();
297

    
298
            try
299
            {
300
                string originFile = "";
301
                string targetFile = "";
302

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

    
306
                if (Boolean.Parse(isInternalAddress))
307
                {
308
                    originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sOriginFolder, originDocItem_ID, originPageNo);
309
                    targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sTagetFolder, targetDocItem_ID, targetPageNo);
310
                }
311
                else
312
                {
313
                    originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo);
314
                    targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo);
315
                }
316

    
317
                using (Markus.Image.ImageCompare compareLib = new Markus.Image.ImageCompare())
318
                {
319

    
320
                    result = compareLib.CompareReturnRects(originFile, targetFile, new System.Drawing.Size(20, 20));
321
                }
322
            }
323
            catch (Exception ex)
324
            {
325
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetCompareRect : " + ex.ToString());
326
                //throw new FaultException(ex.ToString() + " Inner Exception : " + ex.InnerException?.ToString());
327
            }
328

    
329

    
330
            return result;
331
        }
332

    
333
        //[OperationContract]
334
        //public List<Rect> GetCompareRect_old(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress)
335
        //{
336
        //    System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
337

    
338
        //    stopwatch.Start();
339

    
340
        //    string originFile = "";
341
        //    string targetFile = "";
342

    
343
        //    string sFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID);
344
        //    if (Boolean.Parse(isInternalAddress))
345
        //    {
346
        //        originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, originDocItem_ID, originPageNo);
347
        //        targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, targetDocItem_ID, targetPageNo);
348
        //    }
349
        //    else
350
        //    {
351
        //        originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo);
352
        //        targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo);
353
        //    }
354

    
355
        //    CompareLib compareLib = new CompareLib();
356

    
357
        //    var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
358
        //    var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
359

    
360
        //    string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
361
        //    var result = compareLib.GetBoundBoxInImage(outPutFile);
362

    
363
        //    System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks));
364

    
365
        //    return result;
366
        //}
367

    
368

    
369
        #region Final PDF
370
        private string _ChanID = null;
371
        TcpChannel chan = null;
372
        [OperationContract]
373
        public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUserID)
374
        {
375
            #region 임시보관
376
            #endregion
377
            FinalPDFResult _result = new FinalPDFResult();
378
            RemFinalPDFObject remObj = null;
379
            try
380
            {
381
                string _finalID = shortGuid();
382
                int _DocTotalPages = -1;
383
                string docItemId;
384

    
385
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
386
                using (CIEntities _ci = new CIEntities(sCIConnString))
387
                {
388
                    var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
389

    
390
                    if (_doc.Count() > 0)
391
                    {
392
                        _DocTotalPages = _doc.First().PAGE_COUNT;
393
                        docItemId = _doc.First().DOCUMENT_ID;
394
                    }
395
                    else
396
                    {
397
                        _result.Status = FinalStatus.Error;
398
                        _result.Exception = "페이지 정보를 가져올 수 없습니다.";
399
                        return _result;
400
                    }
401
                }
402
                if (_DocTotalPages > 0)
403
                {
404
                    FINAL_PDF fm = new FINAL_PDF()
405
                    {
406
                        ID = _finalID,
407
                        PROJECT_NO = ProjectNo,
408
                        DOCINFO_ID = DocInfoID,
409
                        DOCUMENT_ID = docItemId,
410
                        MARKUPINFO_ID = MarkupInfoID,
411
                        CREATE_USER_ID = CreateUserID,
412
                        TOTAL_PAGE = _DocTotalPages,
413
                        CREATE_DATETIME = DateTime.Now,
414
                        STATUS = (int)IFinalPDF.FinalStatus.Insert
415
                    };
416

    
417
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
418
                    using (KCOMEntities _entity = new KCOMEntities(sConnString))
419
                    {
420
                        _entity.AddToFINAL_PDF(fm);
421
                        _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
422
                    };
423

    
424
                    System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
425
                    if (_ch == null)
426
                    {
427
                        chan = new TcpChannel();
428
                        _ChanID = chan.ChannelName;
429
                        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
430
                        // Create an instance of the remote object
431

    
432
                        using (KCOMEntities ec = new KCOMEntities(sConnString))
433
                        {
434

    
435
                            //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
436
                            //                          "tcp://localhost:9092/remFinalPDF");
437
                            remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
438
                                                      //"tcp://192.168.0.67:9092/remFinalPDF");
439
                                                      KCOM_API.Properties.Settings.Default.FinalService);
440
                        }
441

    
442
                        //"tcp://localhost:8080/remFinalPDF");
443

    
444
                        _result = remObj.SetFinalPDF(ProjectNo, _finalID);
445
                        _result.FinalID = _finalID;
446
                        _result.Status = FinalStatus.Success;
447

    
448
                        //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
449
                        //fa.MakeFinalPDF(fm);
450
                    }
451
                    else
452
                    {
453
                        _ChanID = _ch.ChannelName;
454
                    }
455
                }
456
            }
457
            catch (Exception ex)
458
            {
459
                System.Diagnostics.Debug.WriteLine("KCOM_API - SetFinalPDF : " + ex.ToString());
460

    
461
                _result.Status = FinalStatus.Error;
462

    
463
                if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
464
                    _result.Exception = "Final Server Not Connection";
465
                else _result.Exception = ex.ToString();
466
            }
467
            finally
468
            {
469
                remObj = null;
470
                if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
471
                    System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
472

    
473
                GC.Collect(2);
474
            }
475
            return _result;
476
        }
477
        #endregion
478

    
479

    
480
        [OperationContract]
481
        public bool GetConversionState(KCOM_BasicParam param)
482
        {
483
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
484
            using (CIEntities entity = new CIEntities(sCIConnString))
485
            {
486
                var doc = entity.DOCINFO.Where(data => data.DOCUMENT_ID == param.documentID).FirstOrDefault();
487
                if (doc != null)
488
                {
489
                    var count = doc.DOCPAGE.Where(data => data.DOCINFO_ID == doc.ID).Count();
490
                    if (doc.PAGE_COUNT == count)  //페이지 수가 일치하는지
491
                    {
492
                        return true;
493
                    }
494
                    else //페이지 수가 일치하지 않는 경우
495
                    {
496
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
497
                        KCOMEntities entity_kcom = new KCOMEntities(sConnString);
498
                        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();
499

    
500
                        if (lst != null || lst.Count >= 1)
501
                        {
502
                            //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_PAGECOUNT"), param.documentID, param.projectNo);
503
                            //이메일 클라이언트를 구현해야함
504
                        }
505
                        return false;
506
                    }
507
                }
508
                else
509
                {
510
                    //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_CONVERTFAILED"), param.documentID, param.projectNo);
511
                    //이메일 클라이언트를 구현해야함
512
                    return false;
513
                }
514
            }
515
        }
516

    
517
        [OperationContract]
518
        public List<VPRevision> GetVPRevisionHistory(string ProjectNo, string vpNo, string DocumentId)
519
        {
520
            List<VPRevision> _result = new List<VPRevision>();
521
            try
522
            {
523
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
524
                using (CIEntities entity = new CIEntities(sCIConnString))
525
                {
526
                    var _vpList = (from docitem in entity.DOCUMENT_ITEM
527
                                   where docitem.PROJECT_NO == ProjectNo && docitem.DOCUMENT_NO == vpNo
528
                                   select new VPRevision
529
                                   {
530
                                       RevNo = docitem.REVISION,
531
                                       GroupNo = docitem.GROUP_NO,
532
                                       FROM_VENDOR = docitem.ORIGINAL_FILE,
533
                                       DOCUMENT_ID = docitem.DOCUMENT_ID,
534
                                       TO_VENDOR = docitem.RESULT_FILE,
535
                                       RESULT = docitem.RESULT,
536
                                       DocNo = docitem.DOCUMENT_NO,
537
                                       //EnsembleLink = docitem.ENSEMBLEINFO_URL,
538
                                       //IsSyncPossible = docitem.DOCUMENT_ID == DocumentId ? false : entity.DOCINFO.Where(d => d.DOCUMENT_ID == docitem.DOCUMENT_ID).ToList().Count > 0 ? true : false
539
                                   });
540
                    _result = _vpList.ToList();
541
                    foreach (var vp in _result)
542
                    {
543
                        if (entity.DOCINFO.Where(d => d.DOCUMENT_ID == vp.DOCUMENT_ID).ToList().Count > 0)
544
                            vp.IsSyncPossible = true;
545
                        else
546
                            vp.IsSyncPossible = false;
547
                    }
548

    
549
                    //_result = _result.OrderByDescending(r => UInt64.Parse(System.Text.RegularExpressions.Regex.Replace(r.GroupNo, @"\D", ""))).ToList();
550
                    _result =  _result.OrderByDescending(r => r.GroupNo).ToList();
551
                }
552
            }
553
            catch (Exception ex)
554
            {
555
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetVPRevisionHistory : " + ex.ToString());
556
            }
557
            finally
558
            {
559
                //GC.Collect(2);
560
            }
561

    
562
            return _result;
563
        }
564

    
565
        [OperationContract]
566
        public VPRevision GetVPRevisionFirstOrDefault(string ProjectNo, string DocumentId)
567
        {
568
            VPRevision _result = null;
569
            try
570
            {
571
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
572
                using (CIEntities entity = new CIEntities(sCIConnString))
573
                {
574
                    _result = (from docitem in entity.DOCUMENT_ITEM
575
                     where docitem.PROJECT_NO == ProjectNo && docitem.DOCUMENT_ID == DocumentId
576
                     select new VPRevision
577
                     {
578
                         RevNo = docitem.REVISION,
579
                         GroupNo = docitem.GROUP_NO,
580
                         FROM_VENDOR = docitem.ORIGINAL_FILE,
581
                         DOCUMENT_ID = docitem.DOCUMENT_ID,
582
                         TO_VENDOR = docitem.RESULT_FILE,
583
                         RESULT = docitem.RESULT
584
                     }).FirstOrDefault();
585
                }
586
            }
587
            catch (Exception ex)
588
            {
589
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetVPRevisionFirstOrDefault : " + ex.ToString());
590
            }
591
            finally
592
            {
593
                //GC.Collect(2);
594
            }
595
            return _result;
596
        }
597

    
598
        [OperationContract]
599
        public DOCINFO GetDocInfo(KCOM_BasicParam param)
600
        {
601
            DOCINFO _result = null;
602
            try
603
            {
604
                // 차후 아래의 코드로 변경
605
                //using (CI_Entities ModelDeeview = new CI_Entities(DaelimCiConnectionString.ToString()))
606
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
607
                CIEntities ModelDeeview = new CIEntities(sCIConnString);
608

    
609
                var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID && doc.PROJECT_NO == param.projectNo);
610
                if (docinfo.Count() > 0)
611
                {
612
                    _result = docinfo.First();
613
                    _result.MARKUP_INFO.Clear();
614

    
615
                }
616
                return _result;
617

    
618
            }
619
            catch (Exception ex)
620
            {
621
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDocInfo : " + ex.ToString());
622
            }
623
            finally
624
            {
625
                //GC.Collect(2);
626
            }
627
            return null;
628
        }
629

    
630
        [OperationContract]
631
        public bool GetCheckSystemAdmin(string UserID)
632
        {
633
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
634
            using (KCOMEntities uc = new KCOMEntities(sConnString))
635
            {
636
                var user = uc.PROPERTIES.Where(data => data.TYPE == "Administrator" && data.PROPERTY.Contains(UserID)).FirstOrDefault();
637
                if (user != null)
638
                {
639
                    return true;
640
                }
641
                else
642
                {
643
                    return false;
644
                }
645
            }
646
            //GC.Collect(2);
647
        }
648

    
649
        [OperationContract]
650
        public DOCUMENT_ITEM GetDocumentItemInfo(KCOM_BasicParam param)
651
        {
652
            ///param : prjNo, documentId, userId
653
            DOCUMENT_ITEM _result = null;
654

    
655
            try
656
            {
657
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
658
                CIEntities entity = new CIEntities(sCIConnString);
659
               
660
                var _items = entity.DOCUMENT_ITEM.Where(data => data.PROJECT_NO == param.projectNo && data.DOCUMENT_ID == param.documentID);
661

    
662
                if (_items.Count() > 0)
663
                {
664
                    _result = _items.First();
665

    
666
                    return _result;
667
                }
668
                //else
669
                //{
670
                //    Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_DOCUMENTNOTFOUND"), param.documentID, param.projectNo);
671
                //}
672
            }
673
            catch (Exception ex)
674
            {
675
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDocumentItemInfo : " + ex.ToString());
676

    
677
                new FaultException("GetDocumentItemInfo Error - "  + ex.ToString());
678
                //throw new FaultException(ex.ToString());
679
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
680
            }
681

    
682
            return _result;
683
        }
684
        /// <summary>
685
        /// DOCUMENT_ITEM Table 의 ID 로 Item 을 Select
686
        /// </summary>
687
        /// 대림의 경우 Interface ID(Document 의 ID) 를 parameter 로 전달
688
        /// 넘어온 ID를 통해 document id 를 확인하는 과정이 필요
689
        /// <param name="ensemble_id"></param>
690
        /// <returns></returns>
691
        [OperationContract]
692
        public string GetDocItemID(string ensemble_id)
693
        {
694
            ///param : prjNo, documentId, userId
695
            string _result = string.Empty;
696

    
697
            try
698
            {
699
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
700
                CIEntities entity = new CIEntities(sCIConnString);
701

    
702
                var _items = entity.DOCUMENT_ITEM.Where(data => data.ID == ensemble_id).FirstOrDefault();
703
                if(_items != null)
704
                    _result = _items.DOCUMENT_ID;
705
            }
706
            catch (Exception ex)
707
            {
708
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDocItemID : " + ex.ToString());
709
                //System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex);
710
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
711
            }
712

    
713
            return _result;
714
        }
715
        public string UserGO(MARKUP_INFO item)
716
        {
717
            if (item != null)
718
            {
719
                return item.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID;
720
            }
721
            return null;
722
        }
723
        
724
        [OperationContract]
725
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
726
        {
727
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
728
            try
729
            {
730
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
731
                using (CIEntities entity = new CIEntities(sCIConnString))
732
                {
733
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
734

    
735
                    var markupList = from markup in markupListData
736
                                     orderby markup.CREATE_TIME descending
737
                                     select new MarkupInfoItem
738
                                     {
739
                                         MarkupInfoID = markup.ID,
740
                                         UserID = markup.USER_ID,
741
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
742
                                         CreateTime = markup.CREATE_TIME,
743
                                         Consolidate = markup.CONSOLIDATE,
744
                                         Description = markup.DESCRIPTION,
745
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
746
                                         PartConsolidate = markup.PART_CONSOLIDATE,
747
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
748
                                     };
749

    
750
                    if (markupList.Count() > 0)
751
                    {
752
                        _result = markupList.ToList();
753
                    }
754

    
755
                    _result.ForEach(r =>
756
                    {
757

    
758
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
759
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
760
                                        orderby markupData.PAGENUMBER
761
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList();
762
                    });
763

    
764
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
765
                    Random random = new Random();
766

    
767
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
768
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
769
                    {
770
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
771
                                             where property.TYPE == "DisplayColor"
772
                                             select property).ToList();
773

    
774
                    }
775

    
776
                    if (_ColorsProperties.Count() == 0)
777
                    {
778
                        ColorGenerator uniqueColorGenerator = new ColorGenerator(System.Drawing.Color.Red); // 2303 = (int)Color.Red
779

    
780
                        uniqueColorGenerator.GetEnumerator(_result.Count());
781

    
782
                        for (int i = 0; i < _result.Count(); i++)
783
                        {
784
                             var c = uniqueColorGenerator.GetNext();
785
                            _ColorsProperties.Add(new PROPERTIES { VALUE = String.Format("{0:X2}{1:X2}{2:X2}",c.R, c.G,c.B) });
786
                        }
787
                    }
788

    
789
                    bool IsProjectNoPass = Properties.Settings.Default.IsProjectNoPass;
790

    
791
                    foreach (var item in _result)
792
                    {
793
                        string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
794

    
795
                        System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery 
796
                                      = entity.CreateQuery<System.Data.Common.DbDataRecord>(query,new System.Data.Objects.ObjectParameter("userId",item.UserID));
797
                        
798
                        if (memberQuery.Count() > 0)
799
                        {
800
                            string userName = memberQuery.First()["NAME"]?.ToString().Trim();
801
                            string depatment = memberQuery.First()["DEPARTMENT"]?.ToString().Trim();
802

    
803
                            item.UserName = userName;
804
                            item.Depatment = depatment;
805
                        }
806

    
807
                        if (_ColorsProperties.Count > 0)
808
                        {
809
                            int colorIdx = random.Next(0, _ColorsProperties.Count() - 1);
810
                            #region 부서별로 색상을 지정하고자 할때
811
                            /// 일단 의견을 들어보자구!
812
                            #endregion
813
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
814
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
815
                        }
816
                        else
817
                        {
818
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
819
                        }
820
                    }
821
                }
822
            }
823
            catch (Exception ex)
824
            {
825
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetMarkupInfoItems : " + ex.ToString());
826

    
827
                return _result;
828
            }
829
            finally
830
            {
831
                //GC.Collect(2);
832
            }
833

    
834
            return _result;
835
        }
836

    
837
        [OperationContract]
838
        public List<MarkupInfoItem> GetSyncMarkupInfoItems(string ProjectNo, string DocInfoId, string currentUser)
839
        {
840
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
841
            try
842
            {
843
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
844
                using (CIEntities entity = new CIEntities(sCIConnString))
845
                {
846
                    var docItem = entity.DOCINFO.Where(data => data.DOCUMENT_ID == DocInfoId).FirstOrDefault();
847
                    if (docItem == null)
848
                    {
849
                        return null;
850
                    }
851
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == docItem.ID).ToList();
852

    
853
                    var markupList = from markup in markupListData
854
                                     where markup.USER_ID == currentUser || markup.CONSOLIDATE == 1
855
                                     orderby markup.CREATE_TIME descending
856
                                     select new MarkupInfoItem
857
                                     {
858
                                         MarkupInfoID = markup.ID,
859
                                         UserID = markup.USER_ID,
860
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
861
                                         CreateTime = markup.CREATE_TIME,
862
                                         Consolidate = markup.CONSOLIDATE,
863
                                         Description = markup.DESCRIPTION,
864
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
865
                                         PartConsolidate = markup.PART_CONSOLIDATE,
866
                                     };
867

    
868

    
869

    
870
                    if (markupList.Count() > 0)
871
                    {
872
                        _result = markupList.ToList();
873
                    }
874

    
875

    
876

    
877
                    _result.ForEach(r =>
878
                    {
879

    
880
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
881
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
882
                                        orderby markupData.PAGENUMBER
883
                                        select new MarkupItem
884
                                        {
885
                                            ID = markupData.ID,
886
                                            PageNumber = markupData.PAGENUMBER,
887
                                            Data = markupData.DATA,
888
                                            Data_Type = markupData.DATA_TYPE,
889
                                            Symbol_ID = markupData.SYMBOL_ID
890
                                        }).ToList();
891
                    });
892

    
893
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
894
                    Random random = new Random();
895

    
896
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
897
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
898
                    {
899
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
900
                                             where property.TYPE == "DisplayColor"
901
                                             select property).ToList();
902
                    }
903

    
904
                    foreach (var item in _result)
905
                    {
906
                        string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
907

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

    
911
                        if (memberQuery.Count() > 0)
912
                        {
913

    
914
                            string userName = memberQuery.First()["NAME"]?.ToString().Trim();
915
                            string depatment = memberQuery.First()["DEPARTMENT"]?.ToString().Trim();
916

    
917
                            item.UserName = userName;
918
                            item.Depatment = depatment;
919
                        }
920

    
921
                        if (_ColorsProperties.Count > 0)
922
                        {
923
                            int colorIdx = random.Next(1, _ColorsProperties.Count());
924
                            #region 부서별로 색상을 지정하고자 할때
925
                            /// 일단 의견을 들어보자구!
926
                            #endregion
927
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
928
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
929
                            //item.DisplayColor = "#FF" + _Colors.First();
930
                            //_Colors.Remove(_Colors.First());
931
                        }
932
                        else
933
                        {
934
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
935
                        }
936
                    }
937
                }
938
            }
939
            catch (Exception ex)
940
            {
941
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetSyncMarkupInfoItems : " + ex.ToString());
942
                return _result;
943
            }
944
            finally
945
            {
946
                //GC.Collect(2);
947
            }
948

    
949
            return _result;
950
        }
951

    
952

    
953
        //[OperationContract]
954
        //[ServiceKnownType(typeof(MEMBER))]
955
        //public List<MEMBER> GetUserData(string ProjectNo, string UserID)
956
        //{
957
        //    List<MEMBER> _result = new List<MEMBER>();
958

    
959
        //    using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
960
        //    {
961
        //        var _UserList = from member in entity.MEMBER
962
        //                        where member.ID == UserID
963
        //                        select member;
964
        //        _result = _UserList.ToList();
965
        //    }
966
        //    //GC.Collect(2);
967
        //    return _result;
968
        //}
969

    
970
        [OperationContract]
971
        [ServiceKnownType(typeof(MEMBER))]
972
        public List<MEMBER> GetUserData(string ProjectNo, string UserID)
973
        {
974
            List<MEMBER> _result = new List<MEMBER>();
975

    
976
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
977

    
978
            using (CIEntities entity = new CIEntities(sCIConnString))
979
            {
980
                _result = GetMemberQuery(entity, UserID);
981
            }
982
            //GC.Collect(2);
983
            return _result;
984
        }
985

    
986

    
987
        [OperationContract]
988
        public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정
989
        {
990
            List<string> _result = new List<string>();
991

    
992
            try
993
            {
994
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
995
                KCOMEntities entity = new KCOMEntities(sConnString);
996
                var YourEnginner = (from dept in entity.PROPERTIES
997
                                    where dept.TYPE == "DeptName" && UserDept.Contains(dept.VALUE)
998
                                    select dept).FirstOrDefault();
999

    
1000
                if (YourEnginner != null)
1001
                {
1002
                    _result = (from dept in entity.PROPERTIES
1003
                               where dept.PROPERTY == YourEnginner.PROPERTY
1004
                               select dept.VALUE).ToList();
1005
                    return _result;
1006
                }
1007
                else
1008
                {
1009
                    return null;
1010
                }
1011
            }
1012
            catch (Exception ex)
1013
            {
1014
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDeptData : " + ex.ToString());
1015
            }
1016
            finally
1017
            {
1018
                //GC.Collect(2);
1019
            }
1020
            return _result;
1021
        }
1022

    
1023
        [OperationContract]
1024
        public bool DeleteMarkup(string ProjectNo, string MarkupInfoID)
1025
        {
1026
            bool _result = false;
1027
            try
1028
            {
1029
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1030
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(sCIConnString))
1031
                {
1032

    
1033
                    MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault();
1034

    
1035
                    if (instance == null)
1036
                    {
1037
                        return false;
1038
                    }
1039
                    MARKUP_INFO_VERSION version = instance.MARKUP_INFO_VERSION.FirstOrDefault();
1040

    
1041

    
1042
                    version.MARKUP_DATA.ToList().ForEach(data =>
1043
                    {
1044
                        Entity.MARKUP_DATA.DeleteObject(data);
1045
                        Entity.SaveChanges();
1046
                    });
1047

    
1048
                    Entity.MARKUP_INFO_VERSION.DeleteObject(version);
1049
                    Entity.SaveChanges();
1050

    
1051
                    Entity.MARKUP_INFO.DeleteObject(instance);
1052
                    Entity.SaveChanges();
1053

    
1054
                }
1055
                _result = true;
1056
            }
1057
            catch (Exception ex)
1058
            {
1059
                System.Diagnostics.Debug.WriteLine("KCOM_API - DeleteMarkup : " + ex.ToString());
1060
            }
1061
            finally
1062
            {
1063
                //GC.Collect(2);
1064
            }
1065
            return _result;
1066
        }
1067

    
1068
        #region Favorite
1069
        [OperationContract]
1070
        public bool SetFavoriteVP(string prjNo, string userID, string groupNo, string docNo, string rev, int SavePageNo, string documentItemID, string VPDescription, IKCOM.FAVORITE_FLAG flag)
1071
        {
1072
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1073
            using (KCOMEntities entity = new KCOMEntities(sConnString))
1074
            {
1075
                try
1076
                {
1077
                    entity.FAVORITE_DOC.AddObject(new FAVORITE_DOC
1078
                    {
1079
                        ID = shortGuid(),
1080
                        PROJECT_NO = prjNo,
1081
                        DOCUMENT_ID = documentItemID,
1082
                        GROUP_NO = groupNo,
1083
                        DOCUMENT_NO = docNo,
1084
                        MEMBER_USER_ID = userID,
1085
                        DESCRIPTION = VPDescription,
1086
                        CREATE_TIME = DateTime.Now,
1087
                        REVISION = rev,
1088
                        FLAG = (int)flag,
1089
                        PAGE_NO = SavePageNo,
1090
                    });
1091
                    entity.SaveChanges();
1092
                }
1093
                catch (Exception ex)
1094
                {
1095
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SetFavoriteVP : " + ex.ToString());
1096
                    return false;
1097
                }
1098

    
1099
                return true;
1100
            }
1101
        }
1102

    
1103
        //[OperationContract]
1104
        //public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
1105
        //{
1106
        //    using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1107
        //    {
1108

    
1109
        //        int flagString = Convert.ToInt32(IKCOM.FAVORITE_FLAG.Personal);                
1110
        //        List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
1111
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
1112
        //            flagString).ToList().ForEach(data => favoriteListSet.Add(data));
1113
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data));
1114
        //        favoriteListSet = favoriteListSet.Distinct().ToList();
1115
        //        return favoriteListSet;
1116
        //    }
1117
        //}
1118
        //[OperationContract]
1119
        //public bool EditFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime, int state, string description)
1120
        //{
1121
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1122
        //    {
1123
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1124
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1125

    
1126
        //        try
1127
        //        {
1128

    
1129

    
1130
        //            if (favoriteSet.Count > 0)
1131
        //            {
1132
        //                var FavoriteVP_Instance = favoriteSet.First();
1133

    
1134
        //                FavoriteVP_Instance.Description = description;
1135
        //                FavoriteVP_Instance.Flag = state;
1136

    
1137
        //                dc.SaveChanges();
1138

    
1139
        //                return true;
1140
        //            }
1141
        //            else
1142
        //            {
1143
        //                return false;
1144
        //            }
1145
        //        }
1146
        //        catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1147
        //        {
1148
        //            return false;
1149
        //        }
1150
        //    }
1151
        //}
1152
        //[OperationContract]
1153
        //public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime)
1154
        //{
1155

    
1156
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1157
        //    {
1158
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1159
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1160

    
1161
        //        try
1162
        //        {
1163

    
1164

    
1165
        //            if (favoriteSet.Count > 0)
1166
        //            {
1167
        //                favoriteSet.ForEach(data => dc.FavoriteVP.DeleteObject(data));
1168
        //                dc.SaveChanges();
1169
        //                return true;
1170
        //            }
1171
        //            else
1172
        //            {
1173
        //                return false;
1174
        //            }
1175
        //        }
1176
        //        catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1177
        //        {
1178
        //            return false;
1179
        //        }
1180
        //    }
1181
        //}
1182
        #endregion
1183

    
1184
        [OperationContract]
1185
        public bool SaveMarkupData(MarkupInfoItem UserState,string project_no,string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1186
        {
1187
            
1188
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1189
            using (CIEntities Entity = new CIEntities(sCIConnString))
1190
            {     
1191
                #region Docinfo 정보 가져오기
1192

    
1193
                string docinfoid_ = (from info in Entity.DOCINFO
1194
                                     where info.DOCUMENT_ID == doc_id
1195
                                     && info.PROJECT_NO == project_no
1196
                                     select info.ID
1197
                                     ).First().ToString();
1198
                #endregion
1199

    
1200
                #region Markup_Info 저장
1201

    
1202
                MARKUP_INFO markup_info = new MARKUP_INFO();
1203
                try
1204
                {
1205
                    markup_info = (from info in Entity.MARKUP_INFO
1206
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
1207
                                   select info).FirstOrDefault();
1208
                }
1209
                catch (Exception ex)
1210
                {
1211
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SaveMarkupData Get markup_info: " + ex.ToString());
1212
                    markup_info = null;
1213
                }
1214

    
1215
                //markup_info가 없을 경우 생성
1216
                if (markup_info == null)
1217
                {
1218
                    //MarkupInfo 저장
1219
                    markup_info = new MARKUP_INFO
1220
                    {
1221
                        ID = UserState.MarkupInfoID,
1222
                        DOCINFO_ID = docinfoid_,
1223
                        USER_ID = user_id,
1224
                        CREATE_TIME = DateTime.Now,
1225
                        CONSOLIDATE = UserState.Consolidate,
1226
                        AVOID_CONSOLIDATE = UserState.AvoidConsolidate,
1227
                        PART_CONSOLIDATE = UserState.PartConsolidate,
1228
                        DESCRIPTION = UserState.Description,
1229
                        UPDATE_TIME = DateTime.Now
1230
                    };
1231
                    Entity.MARKUP_INFO.AddObject(markup_info);
1232
                }
1233
                //markup_info가 있을 경우 업데이트
1234
                else
1235
                {
1236
                    markup_info.UPDATE_TIME = DateTime.Now;
1237
                }
1238
                Entity.SaveChanges();
1239
                #endregion
1240

    
1241
                #region Markup_Info_Version 저장
1242

    
1243
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1244

    
1245
                try
1246
                {
1247
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1248
                                           where info.MARKUPINFO_ID == markup_info.ID
1249
                                           select info).FirstOrDefault();
1250
                }
1251
                catch (Exception ex)
1252
                {
1253
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SaveMarkupData  Get markup_info_version : " + ex.ToString());
1254
                    markup_info_version = null;
1255
                }
1256

    
1257
                //markup_info_version 없을 경우 생성
1258
                if (markup_info_version == null)
1259
                {
1260
                    //MarkupInfo_version 저장
1261
                    markup_info_version = new MARKUP_INFO_VERSION()
1262
                    {
1263
                        ID = UserState.MarkupVersionID,
1264
                        MARKUPINFO_ID = markup_info.ID,
1265
                        CREATE_DATE = DateTime.Now
1266
                    };
1267
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1268
                    Entity.SaveChanges();
1269
                }
1270
                #endregion
1271

    
1272
                
1273
                Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1274
                {
1275
                    Entity.MARKUP_DATA.DeleteObject(item);
1276
                });
1277
                Entity.SaveChanges();
1278

    
1279
                try
1280
                {
1281
                    mlmarkup_data.ForEach(value =>
1282
                    {
1283
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1284
                        {
1285
                            ID = value.ID,
1286
                            DATA = value.DATA,
1287
                            DATA_TYPE = value.DATA_TYPE,
1288
                            PAGENUMBER = value.PAGENUMBER,
1289
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1290
                            SYMBOL_ID = value.SYMBOL_ID,
1291
                            //GROUP_ID = value.GROUP_ID
1292
                        });
1293
                    });
1294
                    Entity.SaveChanges();
1295
                }
1296
                catch (Exception ex)
1297
                {
1298
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SaveMarkupData  set mlmarkup_data : " + ex.ToString());
1299
                    return false;
1300
                }
1301
            }
1302
            return true;
1303
        }
1304

    
1305
        [OperationContract]
1306
        public bool SavePageMarkupData(MarkupInfoItem UserState,int PageNo, string project_no, string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1307
        {
1308

    
1309
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1310
            using (CIEntities Entity = new CIEntities(sCIConnString))
1311
            {
1312
                #region Docinfo 정보 가져오기
1313

    
1314
                string docinfoid_ = (from info in Entity.DOCINFO
1315
                                     where info.DOCUMENT_ID == doc_id
1316
                                     && info.PROJECT_NO == project_no
1317
                                     select info.ID
1318
                                     ).First().ToString();
1319
                #endregion
1320

    
1321
                #region Markup_Info 저장
1322

    
1323
                MARKUP_INFO markup_info = new MARKUP_INFO();
1324
                try
1325
                {
1326
                    markup_info = (from info in Entity.MARKUP_INFO
1327
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
1328
                                   select info).FirstOrDefault();
1329
                }
1330
                catch (Exception ex)
1331
                {
1332
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SavePageMarkupData : " + ex.ToString());
1333

    
1334
                    markup_info = null;
1335
                }
1336

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

    
1363
                #region Markup_Info_Version 저장
1364

    
1365
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1366

    
1367
                try
1368
                {
1369
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1370
                                           where info.MARKUPINFO_ID == markup_info.ID
1371
                                           select info).FirstOrDefault();
1372
                }
1373
                catch (Exception ex)
1374
                {
1375
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SavePageMarkupData get markup_info_version : " + ex.ToString());
1376
                    markup_info_version = null;
1377
                }
1378

    
1379
                //markup_info_version 없을 경우 생성
1380
                if (markup_info_version == null)
1381
                {
1382
                    //MarkupInfo_version 저장
1383
                    markup_info_version = new MARKUP_INFO_VERSION()
1384
                    {
1385
                        ID = UserState.MarkupVersionID,
1386
                        MARKUPINFO_ID = markup_info.ID,
1387
                        CREATE_DATE = DateTime.Now
1388
                    };
1389
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1390
                    Entity.SaveChanges();
1391
                }
1392
                #endregion
1393

    
1394

    
1395
                Entity.MARKUP_DATA.Where(data =>  data.PAGENUMBER == PageNo && data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1396
                {
1397
                    Entity.MARKUP_DATA.DeleteObject(item);
1398
                });
1399
                Entity.SaveChanges();
1400

    
1401
                try
1402
                {
1403
                    mlmarkup_data.ForEach(value =>
1404
                    {
1405
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1406
                        {
1407
                            ID = value.ID,
1408
                            DATA = value.DATA,
1409
                            DATA_TYPE = value.DATA_TYPE,
1410
                            PAGENUMBER = value.PAGENUMBER,
1411
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1412
                            SYMBOL_ID = value.SYMBOL_ID,
1413
                            //GROUP_ID = value.GROUP_ID
1414
                        });
1415
                    });
1416
                    Entity.SaveChanges();
1417
                }
1418
                catch (Exception ex)
1419
                {
1420
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SavePageMarkupData set mlmarkup_data : " + ex.ToString());
1421
                    return false;
1422
                }
1423
            }
1424
            return true;
1425
        }
1426

    
1427
        //[OperationContract]
1428
        //public long AddMarkupDataGroup(MARKUP_DATA_GROUP mARKUP_DATA_GROUP, string ProjectNo)
1429
        //{
1430
        //    try
1431
        //    {
1432
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1433
        //        {
1434
        //            Entity.AddToMARKUP_DATA_GROUP(mARKUP_DATA_GROUP);
1435
        //            //MARKUP_DATA_GROUP tt = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == id).FirstOrDefault();
1436
        //            Entity.SaveChanges();
1437

    
1438
        //            return Entity.MARKUP_DATA_GROUP.ToList().LastOrDefault().ID;
1439
        //        }
1440
        //    }
1441
        //    catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1442
        //    {
1443
        //        return 0;
1444
        //    }
1445
        //}
1446
        //[OperationContract]
1447
        //public bool UpdateMarkupDataGroup(long Group_ID, string ProjectNo)
1448
        //{
1449
        //    try
1450
        //    {
1451
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1452
        //        {
1453
        //            var UpdateItem = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == Group_ID).FirstOrDefault();
1454
        //            UpdateItem.STATE = 1;
1455
        //            Entity.SaveChanges();
1456
        //        }
1457
        //    }
1458
        //    catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1459
        //    {
1460
        //        return false;
1461
        //    }
1462
        //    return true;
1463
        //}
1464
        [OperationContract]
1465
        public bool UpdateMarkupData(string CommentID, long Group_ID, string ProjectNo)
1466
        {
1467
            try
1468
            {
1469
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1470
                using (CIEntities Entity = new CIEntities(sCIConnString))
1471
                {
1472
                    var UpdateItem = Entity.MARKUP_DATA.Where(info => info.ID == CommentID).FirstOrDefault();
1473
                    //UpdateItem.GROUP_ID = Group_ID;
1474
                    Entity.SaveChanges();
1475
                }
1476
            }
1477
            catch (Exception ex)
1478
            {
1479
                System.Diagnostics.Debug.WriteLine("KCOM_API - UpdateMarkupData: " + ex.ToString());
1480
                return false;
1481
            }
1482
            return true;
1483
        }
1484

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

    
1551
                return false;
1552
            }
1553
            return true;
1554
        }
1555

    
1556
        [OperationContract]
1557
        public bool RenameSymbol(string symbol_id, string name, int type)
1558
        {
1559
            try
1560
            {
1561
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1562
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
1563
                {
1564
                    if (type == 0)
1565
                    {
1566
                        var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == symbol_id).FirstOrDefault();
1567
                        UpdateItem.NAME = name;
1568
                        Entity.SaveChanges();
1569
                    }
1570
                    else
1571
                    {
1572
                        var UpdateItem = Entity.SYMBOL_PUBLIC.Where(info => info.ID == symbol_id).FirstOrDefault();
1573
                        UpdateItem.NAME = name;
1574
                        Entity.SaveChanges();
1575
                    }
1576
                }
1577
            }
1578
            catch (Exception ex)
1579
            {
1580
                System.Diagnostics.Debug.WriteLine("KCOM_API - RenameSymbol: " + ex.ToString());
1581
                return false;
1582
            }
1583
            return true;
1584
        }
1585

    
1586
        [OperationContract]
1587
        public bool AddCheckListHistory(string project_no, CHECK_LIST_HISTORY Check_History)
1588
        {
1589
            try
1590
            {
1591
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1592
                using (CIEntities Entity = new CIEntities(sCIConnString))
1593
                {
1594
                    Entity.CHECK_LIST_HISTORY.AddObject(Check_History);
1595
                    Entity.SaveChanges();  
1596
                }
1597
            }
1598
            catch (Exception ex)
1599
            {
1600
                System.Diagnostics.Debug.WriteLine("KCOM_API - AddCheckListHistory: " + ex.ToString());
1601
                return false;
1602
            }
1603
            return true;
1604
        }
1605
        [OperationContract]
1606
        public bool SaveCheckListHistory(string project_no, string rev, CHECK_LIST_HISTORY Check_History)
1607
        {
1608
            try
1609
            {
1610
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1611
                using (CIEntities Entity = new CIEntities(sCIConnString))
1612
                {
1613
                    var item = Entity.CHECK_LIST_HISTORY.Where(info => info.REVISION == rev).FirstOrDefault();
1614
                    item = Check_History;
1615
                    Entity.SaveChanges();
1616
                }
1617
            }
1618
            catch (Exception ex)
1619
            {
1620
                System.Diagnostics.Debug.WriteLine("KCOM_API - SaveCheckListHistory: " + ex.ToString());
1621
                return false;
1622
            }
1623
            return true;
1624
        }
1625
        [OperationContract]
1626
        public bool SaveCheckList(string project_no, string _id, CHECK_LIST Check_value)
1627
        {
1628
            try
1629
            {
1630
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1631
                using (CIEntities Entity = new CIEntities(sCIConnString))
1632
                {
1633
                    var item = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1634
                    item.TODOLIST = Check_value.TODOLIST;
1635
                    item.REMARK = Check_value.REMARK;
1636
                    item.STATUS = Check_value.STATUS;
1637
                    item.VENDOR = Check_value.VENDOR;
1638
                    item.REPLY = Check_value.REPLY;
1639
                    item.IMAGE_URL = Check_value.IMAGE_URL;
1640
                    item.IMAGE_ANCHOR = Check_value.IMAGE_ANCHOR;
1641
                    item.UPDATE_TIME = Check_value.UPDATE_TIME;
1642
                    if(Check_value.STATUS == "False")
1643
                    {
1644
                        item.STATUS_DESC_OPEN = Check_value.STATUS_DESC_OPEN;
1645
                    }
1646
                    else
1647
                    {
1648
                        item.STATUS_DESC_CLOSE = Check_value.STATUS_DESC_CLOSE;
1649
                    }                     
1650
                    Entity.SaveChanges();
1651
                }
1652
            }
1653
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1654
                return false;
1655
            }
1656
            return true;
1657
        }
1658
        [OperationContract]
1659
        public bool AddCheckList(string project_no, CHECK_LIST Check_value)
1660
        {
1661
            try
1662
            {
1663
               
1664
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1665
                using (CIEntities Entity = new CIEntities(sCIConnString))
1666
                {
1667
                    Entity.CHECK_LIST.AddObject(Check_value);
1668
                    Entity.SaveChanges();
1669
                }
1670
            }
1671
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1672
                return false;
1673
            }
1674
            return true;
1675
        }
1676

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

    
1760
                        if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE)
1761
                        {
1762
                            _docpage.PAGE_ANGLE = data.PAGE_ANGLE;
1763
                        }
1764
                    });
1765

    
1766
                    Entity.SaveChanges();
1767
                }
1768
            }
1769
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1770
                return false;
1771
            }
1772
            return true;
1773
        }
1774

    
1775
        [OperationContract]
1776
        public MARKUP_INFO GetMarkupInfo(string project_no, string _id)
1777
        {
1778
            MARKUP_INFO markupInfo = new MARKUP_INFO();
1779

    
1780
            try
1781
            {
1782
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1783
                using (CIEntities Entity = new CIEntities(sCIConnString))
1784
                {
1785
                    markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1786
                }
1787
            }
1788
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1789
                return null;
1790
            }
1791
            return markupInfo;
1792
        }
1793

    
1794
        [OperationContract]
1795
        public List<string> GetMarkupDataListperPage(string project_no, string _markupinfoid, int _pageNo)
1796
        {
1797
            List<string> markupdata = new List<string>();
1798
            MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1799
            try
1800
            {
1801
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1802
                using (CIEntities Entity = new CIEntities(sCIConnString))
1803
                {
1804
                    markup_info_version = (from version in Entity.MARKUP_INFO_VERSION
1805
                                           where version.MARKUPINFO_ID == _markupinfoid
1806
                                           orderby version.CREATE_DATE descending
1807
                                           select version).First();
1808
                    markupdata = (from data in Entity.MARKUP_DATA
1809
                                  where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo
1810
                                  select data.DATA).ToList();
1811
                }
1812
            }
1813
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1814
                return null;
1815
            }
1816
            return markupdata;
1817
        }
1818

    
1819
        [OperationContract]
1820
        public bool AddMarkupInfo(string project_no, MARKUP_INFO value)
1821
        {
1822
            try
1823
            {
1824
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1825
                using (CIEntities Entity = new CIEntities(sCIConnString))
1826
                {
1827
                    Entity.MARKUP_INFO.AddObject(value);
1828
                    Entity.SaveChanges();
1829
                }
1830
            }
1831
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1832
                return false;
1833
            }
1834
            return true;
1835
        }
1836

    
1837
        [OperationContract]
1838
        public bool AddMarkupInfoVersion(string project_no, MARKUP_INFO_VERSION value)
1839
        {
1840
            try
1841
            {
1842
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1843
                using (CIEntities Entity = new CIEntities(sCIConnString))
1844
                {
1845
                    Entity.MARKUP_INFO_VERSION.AddObject(value);
1846
                    Entity.SaveChanges();
1847
                }
1848
            }
1849
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1850
                return false;
1851
            }
1852
            return true;
1853
        }
1854

    
1855
        [OperationContract]
1856
        public bool AddMarkupData(string project_no, MARKUP_DATA value)
1857
        {
1858
            try
1859
            {
1860
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1861
                using (CIEntities Entity = new CIEntities(sCIConnString))
1862
                {
1863
                    Entity.MARKUP_DATA.AddObject(value);
1864
                    Entity.SaveChanges();
1865
                }
1866
            }
1867
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1868
                return false;
1869
            }
1870
            return true;
1871
        }
1872

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

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

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

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

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

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

    
1961
                    Entity.MARKUP_INFO.AddObject(info);
1962
                    Entity.SaveChanges();
1963

    
1964

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

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

    
1988

    
1989
                }
1990
            }
1991
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1992
                return false;
1993
            }
1994
            return true;
1995
        }
1996

    
1997

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

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

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

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

    
2034

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

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

    
2058

    
2059
                }
2060
                consolidate = true;
2061
            }
2062
            catch (Exception ex)
2063
            {
2064
                System.Diagnostics.Debug.WriteLine(ex);
2065
                consolidate = false;
2066
            }
2067

    
2068
            FinalPDFResult _result = new FinalPDFResult();
2069
            if (consolidate == true)
2070
            {
2071
                RemFinalPDFObject remObj = null;
2072
                try
2073
                {
2074
                    string _finalID = shortGuid();
2075
                    int _DocTotalPages = -1;
2076
                    string docItemId;
2077

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

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

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

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

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

    
2128
                            using (KCOMEntities ec = new KCOMEntities(sConnString))
2129
                            {
2130

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

    
2138
                            //"tcp://localhost:8080/remFinalPDF");
2139

    
2140
                            _result = remObj.SetFinalPDF(ProjectNo, _finalID);
2141
                            _result.FinalID = _finalID;
2142
                            _result.Status = FinalStatus.Success;
2143

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

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

    
2166
                    GC.Collect(2);
2167
                }
2168
            }
2169
            return _result;
2170
        }
2171
        [OperationContract]
2172
        public bool TeamConsolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
2173
        {
2174
            try
2175
            {
2176
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
2177
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2178
                using (CIEntities Entity = new CIEntities(sCIConnString))
2179
                {
2180
                    var members = GetMemberQuery(Entity, _user_id);
2181

    
2182
                    string user_dept = "";
2183

    
2184
                    if(members.Count() > 0)
2185
                    {
2186
                        user_dept = members.First().DEPARTMENT;
2187
                    }
2188
                    
2189
                    var markupInfos = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.PART_CONSOLIDATE == 1)
2190
                                        .OrderByDescending(j => j.CREATE_TIME).ToList();
2191

    
2192
                    foreach (var markupinfo in markupInfos)
2193
                    {
2194
                        string markupdept = "";
2195

    
2196
                        var markupMembers = GetMemberQuery(Entity, markupinfo.USER_ID);
2197

    
2198
                        if (markupMembers.Count() > 0)
2199
                        {
2200
                            markupdept = markupMembers.First().DEPARTMENT;
2201
                        }
2202

    
2203
                        if (user_dept == markupdept)
2204
                        {
2205
                            markupinfo.AVOID_CONSOLIDATE = 1;
2206
                        }
2207
                    }
2208

    
2209
                    foreach (MarkupInfoItem item in markupInfoItems)
2210
                    {
2211
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2212
                        {
2213
                            instanceDataSet.Add(d);
2214
                        });
2215
                    }
2216

    
2217
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2218
                    info.ID = shortGuid();
2219
                    info.PART_CONSOLIDATE = 1;
2220
                    info.CREATE_TIME = DateTime.Now;
2221
                    info.DOCINFO_ID = _doc_id;
2222
                    info.UPDATE_TIME = DateTime.Now;
2223
                    info.USER_ID = _user_id;
2224
                    info.AVOID_CONSOLIDATE = 0;
2225

    
2226
                    Entity.MARKUP_INFO.AddObject(info);
2227
                    Entity.SaveChanges();
2228

    
2229

    
2230
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2231
                    {
2232
                        ID = shortGuid(),
2233
                        CREATE_DATE = DateTime.Now,
2234
                        MARKUP_INFO = info,
2235
                    };
2236
                    Entity.SaveChanges();
2237

    
2238
                    foreach (var item in instanceDataSet)
2239
                    {
2240
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2241
                        {
2242
                            ID = shortGuid(),
2243
                            DATA = item.DATA,
2244
                            DATA_TYPE = item.DATA_TYPE,
2245
                            PAGENUMBER = item.PAGENUMBER,
2246
                            MARKUP_INFO_VERSION = info2,
2247
                            SYMBOL_ID = item.SYMBOL_ID,
2248
                            //GROUP_ID = item.GROUP_ID
2249
                        });
2250
                    }
2251
                    Entity.SaveChanges();
2252

    
2253

    
2254
                }
2255
            }
2256
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2257
                return false;
2258
            }
2259
            return true;
2260
        }
2261

    
2262
        [OperationContract]
2263
        [ServiceKnownType(typeof(MEMBER))]
2264
        public MEMBER GetMember(string project_no, string user_id)
2265
        {
2266
            MEMBER rstmember = null;
2267
            try
2268
            {
2269
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2270
                using (CIEntities Entity = new CIEntities(sCIConnString))
2271
                {
2272
                    var members = GetMemberQuery(Entity, user_id);
2273

    
2274
                    if(members.Count() > 0)
2275
                    {
2276
                        rstmember = members.First();
2277
                    }
2278
                }
2279
            }
2280
            catch (Exception ex)
2281
            {
2282
                return null;
2283
            }
2284
            return rstmember;
2285
        }
2286

    
2287
        private  List<MEMBER> GetMemberQuery(System.Data.Objects.ObjectContext context, string UserID)
2288
        {
2289
            List<MEMBER> result = new List<MEMBER>();
2290

    
2291
            try
2292
            {
2293
                string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
2294

    
2295
                var param = new[] { new System.Data.Objects.ObjectParameter("userId", UserID) };
2296

    
2297
                System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery
2298
                              = context.CreateQuery<System.Data.Common.DbDataRecord>(query, param);
2299

    
2300
                if (memberQuery.Count() > 0)
2301
                {
2302
                    foreach (var dataRecord in memberQuery)
2303
                    {
2304
                        MEMBER member = new MEMBER();
2305

    
2306
                        string userName = dataRecord["NAME"]?.ToString().Trim();
2307
                        string ID = dataRecord["ID"]?.ToString().Trim();
2308
                        string depatment = dataRecord["DEPARTMENT"]?.ToString().Trim();
2309

    
2310
                        member.NAME = userName;
2311
                        member.ID = ID;
2312
                        member.DEPARTMENT = depatment;
2313

    
2314
                        result.Add(member);
2315
                    }
2316
                }
2317
            }
2318
            catch (Exception ex)
2319
            {
2320
                throw new Exception("GetMember(System.Data.Objects.ObjectContext context, string UserID) " , ex);
2321
            }
2322

    
2323
            return result;
2324
        }
2325

    
2326
        [WebMethod]
2327
        [OperationContract]
2328
        public List<SYMBOL_PRIVATE> GetSymbolList(string user_id)
2329
        {
2330
            List<SYMBOL_PRIVATE> Custom_List = new List<SYMBOL_PRIVATE>();
2331
            try
2332
            {
2333
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2334
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2335
                {
2336
                    Custom_List = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == user_id).ToList();
2337
                }
2338
            }
2339
            catch (Exception ex)
2340
            {
2341
                return null;
2342
            }
2343
            return Custom_List;
2344
        }
2345
        [OperationContract]
2346
        public List<string> GetPublicSymbolDeptList()
2347
        {
2348
            List<string> Custom_List = new List<string>();
2349
            try
2350
            {
2351
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2352
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2353
                {
2354
                    Custom_List = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).Distinct().ToList();
2355
                }
2356
            }
2357
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2358
                return null;
2359
            }
2360
            return Custom_List;
2361
        }
2362
        [OperationContract]
2363
        public List<SYMBOL_PUBLIC> GetPublicSymbolList(string dept)
2364
        {
2365
            List<SYMBOL_PUBLIC> Custom_List = new List<SYMBOL_PUBLIC>();
2366
            try
2367
            {
2368
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2369
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2370
                {
2371
                    if(!string.IsNullOrEmpty(dept))
2372
                    {
2373
                        Custom_List = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == dept).ToList();
2374
                    }
2375
                    else
2376
                    {
2377
                        Custom_List = Entity.SYMBOL_PUBLIC.ToList();
2378
                    }
2379
                    
2380
                }
2381
            }
2382
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2383
                return null;
2384
            }
2385
            return Custom_List;
2386
        }
2387

    
2388
        /// <summary>
2389
        /// 
2390
        /// </summary>
2391
        /// <param name="id">symbol id</param>
2392
        /// <param name="type"> 0 : PRIVATE, 1 : PUBLIC</param>
2393
        /// <returns></returns>
2394
        [OperationContract]
2395
        public string GetSymbolData(string id, int type)
2396
        {
2397
            string result;
2398
            try
2399
            {
2400
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2401
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2402
                {
2403
                    if(type == 0)
2404
                    {
2405
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA;
2406
                    }
2407
                    else
2408
                    {
2409
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA;
2410
                    }
2411
                }
2412
            }
2413
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2414
                return null;
2415
            }
2416
            return result;
2417
        }
2418
        [OperationContract]
2419
        public string GetSymbolImageURL(string id, int type)
2420
        {
2421
            string result;
2422
            try
2423
            {
2424
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2425
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2426
                {
2427
                    if (type == 0)
2428
                    {
2429
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2430
                    }
2431
                    else
2432
                    {
2433
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2434
                    }
2435
                }
2436
            }
2437
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2438
                return null;
2439
            }
2440
            return result;
2441
        }
2442
        [OperationContract]
2443
        public string GetSignData(string project_no, string user_id)
2444
        {
2445
            string result = null;
2446
            try
2447
            {
2448
                string ifsign = getEnsembleSign(user_id);
2449
                if (string.IsNullOrEmpty(ifsign))
2450
                {
2451
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2452
                    var ModelWFConnectionString = sCIConnString;
2453
                    if (null != ModelWFConnectionString)
2454
                    {
2455
                        using (CIEntities entity = new CIEntities(ModelWFConnectionString))
2456
                        {
2457
                            var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2458
                            if (_sign.Count() > 0)
2459
                            {
2460
                                result = _sign.First().SIGN_STR;
2461
                            }
2462
                            else
2463
                            {
2464
                                return null;
2465
                            }
2466
                        }
2467
                    }
2468
                }
2469
                else
2470
                {
2471
                    result = ifsign;
2472
                }
2473

    
2474
            }
2475
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2476
                return null;
2477
            }
2478
            return result;
2479
        }
2480

    
2481
        [OperationContract]        
2482
        public string GetProjectName(string project_no)
2483
        {
2484
            string result = null;
2485

    
2486
            try
2487
            {
2488
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2489
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
2490
                {
2491
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
2492
                }
2493
            }
2494
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2495
                return null;
2496
            }
2497
            return result;
2498
        }
2499

    
2500
        [OperationContract]
2501
        public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev)
2502
        {
2503
            List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>();
2504
            
2505
            try
2506
            {
2507
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2508
                using (CIEntities Entity = new CIEntities(sCIConnString))
2509
                {
2510
                    result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no
2511
                    && i.DOCUMENT_NO == doc_no
2512
                    && i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList();
2513
                }
2514
            }
2515
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2516
                return null;
2517
            }
2518
            return result;
2519
        }
2520

    
2521
        [OperationContract]
2522
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
2523
        {
2524
            DOCINFO docinfo = null;
2525

    
2526
            try
2527
            {
2528
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2529
                using (CIEntities Entity = new CIEntities(sCIConnString))
2530
                {
2531
                    docinfo = (from info in Entity.DOCINFO
2532
                              where info.DOCUMENT_ID == doc_id
2533
                              && info.PROJECT_NO == project_no
2534
                              select info).First();
2535
                }
2536
            }
2537
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2538
                return null;
2539
            }
2540
            return docinfo;
2541
        }
2542

    
2543
        [OperationContract]
2544
        public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList)
2545
        {
2546
            MarkupInfoItem _result = null;
2547
            List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>();
2548
            try
2549
            {
2550
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2551
                using (CIEntities Entity = new CIEntities(sCIConnString))
2552
                {
2553
                    var docitem = (from info in Entity.DOCINFO
2554
                               where info.DOCUMENT_ID == doc_id
2555
                               && info.PROJECT_NO == project_no
2556
                               select info).First();
2557

    
2558
                    foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO)
2559
                    {
2560
                        var members = GetMemberQuery(Entity, markinfo.USER_ID);
2561

    
2562
                        MEMBER member = new MEMBER();
2563

    
2564
                        if (members.Count() > 0)
2565
                        {
2566
                            member = members.First();
2567
                        }
2568

    
2569
                        string displaycolor = null;
2570

    
2571
                        try
2572
                        {
2573
                            displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor;
2574
                        }
2575
                        catch (Exception ex)
2576
                        {
2577
                            System.Diagnostics.Debug.WriteLine("KCOM_API - GetPrintDocItemList displaycolor : " + ex.ToString());
2578

    
2579
                            displaycolor = "#FFFFFF";
2580
                        }
2581
                        
2582
                        _result = new MarkupInfoItem
2583
                        {
2584
                            MarkupInfoID = markinfo.ID,
2585
                            Consolidate = markinfo.CONSOLIDATE,
2586
                            CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME,
2587
                            DisplayColor = displaycolor,
2588
                            UserID = markinfo.USER_ID,
2589
                            UserName = member.NAME,
2590
                            Depatment = member.DEPARTMENT,
2591
                        };
2592

    
2593
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
2594
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
2595

    
2596
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
2597
                        {
2598
                            MarkupItem markitem = new MarkupItem()
2599
                            {
2600
                                ID = markdata.ID,
2601
                                PageNumber = markdata.PAGENUMBER,
2602
                            };
2603
                            _result.MarkupList.Add(markitem);
2604
                        }
2605

    
2606
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
2607

    
2608
                        markupinfo.Add(_result);
2609
                    }
2610
                }
2611
            }
2612
            catch (Exception ex)
2613
            {
2614
                return null;
2615
            }
2616
            return markupinfo;
2617
        }
2618

    
2619
        [OperationContract]
2620
        public bool AddMessage(string project_no, TALK value)
2621
        {
2622
            try
2623
            {
2624
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2625
                using (CIEntities entity = new CIEntities(sCIConnString))
2626
                {                    
2627
                    entity.TALK.AddObject(value);
2628
                    entity.SaveChanges();
2629
                }
2630
            }
2631
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2632
                return false;
2633
            }
2634
            return true;
2635
        }
2636

    
2637
        [OperationContract]
2638
        public List<TALK> GetMessage(string project_no, string doc_id)
2639
        {
2640
            List<TALK> result = new List<TALK>();
2641
            try
2642
            {
2643
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2644
                using (CIEntities entity = new CIEntities(sCIConnString))
2645
                {
2646
                    result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList();                        
2647
                }
2648
            }
2649
            catch (Exception ex)
2650
            {
2651
                return result;
2652
            }
2653
            return result;
2654
        }
2655

    
2656

    
2657
        #region Legacy System I/F
2658
        /// <summary>
2659
        /// Ensemble+ Sign Data Return
2660
        /// </summary>
2661
        /// <param name="user_id"></param>
2662
        /// <returns></returns>
2663
        private string getEnsembleSign(string user_id)
2664
        {
2665
            string result = null;
2666
            string soapurl = string.Empty;
2667

    
2668
            try
2669
            {
2670
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2671
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2672
                {
2673
                    var item = Entity.PROPERTIES.Where(d => d.TYPE == "UpLoadServiceUrl").FirstOrDefault();
2674

    
2675
                    if (item != null)
2676
                    {
2677
                        soapurl = item.VALUE;
2678

    
2679
                        WebClient webClient = new WebClient();
2680
                        string data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ens=\"http://EnsemblePlus.Webservice\"> <soapenv:Header/> <soapenv:Body> <ens:checkoutSignImage>"
2681
                            + "<ens:sUserNo>" + user_id + "</ens:sUserNo>"
2682
                            + "</ens:checkoutSignImage> </soapenv:Body></soapenv:Envelope>";
2683
                        webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
2684
                        webClient.Headers.Add("SOAPAction", "http://EnsemblePlus.Webservice");
2685
                        var _result = webClient.UploadString(new Uri(soapurl), data);
2686
                        XmlDocument xmlDoc = new XmlDocument();
2687
                        xmlDoc.LoadXml(_result);
2688
                        XmlNodeList list = xmlDoc.GetElementsByTagName("checkoutSignImageResponse");
2689

    
2690
                        foreach (XmlNode xn in list)
2691
                        {
2692
                            result = xn["checkoutSignImageReturn"].InnerText;
2693
                        }
2694

    
2695
                        if (result.Contains("No business object"))
2696
                        {
2697
                            result = null;
2698
                        }
2699
                    }
2700
                    else
2701
                    {
2702
                        result = null;
2703
                    }
2704
                }
2705
             
2706
            }
2707
            catch (Exception ex)
2708
            {   
2709
                result = null;
2710
            }
2711

    
2712
            return result;
2713
        }
2714
        #endregion
2715

    
2716
        #region Final Service
2717
        [OperationContract]
2718
        [ServiceKnownType(typeof(DOCINFO))]                
2719
        public DOCINFO FinalPDF_GetDocinfo(string project_no, string docinfo_id)
2720
        {
2721
            DOCINFO docinfo = null;
2722

    
2723
            try
2724
            {
2725
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2726
                using (CIEntities _entity = new CIEntities(sCIConnString))
2727
                {
2728
                    var doc = _entity.DOCINFO.Where(x => x.ID == docinfo_id).FirstOrDefault();
2729
                    if(doc != null)
2730
                    {
2731
                        docinfo = new DOCINFO()
2732
                        {
2733
                            ID = doc.ID,
2734
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2735
                            PAGE_COUNT = doc.PAGE_COUNT,
2736
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2737
                            PROJECT_NO = doc.PROJECT_NO
2738
                        };
2739
                    }                    
2740
                }
2741
            }
2742
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2743
                throw;
2744
            }
2745
            return docinfo;
2746
        }
2747
        [OperationContract]
2748
        [ServiceKnownType(typeof(DOCUMENT_ITEM))]
2749
        public DOCUMENT_ITEM FinalPDF_GetDocumentItem(string project_no, string document_id)
2750
        {
2751
            DOCUMENT_ITEM item = null;
2752

    
2753
            try
2754
            {
2755
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2756
                using (CIEntities _entity = new CIEntities(sCIConnString))
2757
                {
2758
                    var doc = _entity.DOCUMENT_ITEM.Where(x => x.PROJECT_NO == project_no &&  x.DOCUMENT_ID == document_id).FirstOrDefault();
2759
                    if(doc != null)
2760
                    {
2761
                        item = new DOCUMENT_ITEM()
2762
                        {
2763
                            ID = doc.ID,
2764
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2765
                            PROJECT_NO = doc.PROJECT_NO,
2766
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2767
                            DOCUMENT_NO = doc.DOCUMENT_NO,
2768
                            DOCUMENT_NAME = doc.DOCUMENT_NAME,
2769
                            //ENSEMBLEINFO_URL = doc.ENSEMBLEINFO_URL,
2770
                            GROUP_NO = doc.GROUP_NO,
2771
                            RESULT = doc.RESULT,
2772
                            REVISION = doc.REVISION,
2773
                            RESULT_FILE = doc.RESULT_FILE
2774
                        };
2775
                    }
2776
                    
2777
                }
2778
            }
2779
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2780
                throw;
2781
            }
2782
            return item;
2783
        }
2784
        [OperationContract]
2785
        [ServiceKnownType(typeof(MARKUP_DATA))]
2786
        public List<MARKUP_DATA> FinalPDF_GetMarkupdata(string project_no, string docinfo_id)
2787
        {
2788
            List<MARKUP_DATA> results = new List<MARKUP_DATA>();
2789

    
2790
            try
2791
            {
2792
                //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2793
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2794
                using (CIEntities _entity = new CIEntities(sCIConnString))
2795
                {
2796
                    var datas = _entity.MARKUP_DATA.Where(x => x.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO_ID == docinfo_id
2797
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1
2798
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.AVOID_CONSOLIDATE == 0
2799
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.PART_CONSOLIDATE == 0).ToList();
2800
                    foreach (var data in datas)
2801
                    {
2802
                        MARKUP_DATA d = new MARKUP_DATA()
2803
                        {
2804
                            ID = data.ID,
2805
                            //GROUP_ID = data.GROUP_ID,
2806
                            SYMBOL_ID = data.SYMBOL_ID,
2807
                            DATA = data.DATA,
2808
                            DATA_TYPE = data.DATA_TYPE,
2809
                            MARKUPINFO_VERSION_ID = data.MARKUPINFO_VERSION_ID,
2810
                            PAGENUMBER = data.PAGENUMBER
2811
                        };
2812
                        results.Add(d);
2813
                    }
2814
                }
2815
            }
2816
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2817
                throw;
2818
            }
2819
            return results;
2820
        }
2821
        [OperationContract]
2822
        [ServiceKnownType(typeof(MARKUP_INFO))]
2823
        public MARKUP_INFO FinalPDF_GetMarkupinfo(string project_no, string docinfo_id)
2824
        {
2825
            MARKUP_INFO markupInfo = null;
2826

    
2827
            try
2828
            {
2829
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2830
                using (CIEntities _entity = new CIEntities(sCIConnString))
2831
                {
2832
                    var tmp = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo_id && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0).FirstOrDefault();
2833
                    if (tmp != null)
2834
                    {
2835
                        markupInfo = new MARKUP_INFO()
2836
                        {
2837
                            ID = tmp.ID,
2838
                            DOCINFO_ID = tmp.DOCINFO_ID,
2839
                            USER_ID = tmp.USER_ID
2840
                        };
2841
                    }                    
2842
                }
2843
            }
2844
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2845
                throw;
2846
            }
2847
            return markupInfo;
2848
        }
2849
        [OperationContract]
2850
        [ServiceKnownType(typeof(FINAL_PDF))]
2851
        public List<FINAL_PDF> FinalPDF_GetFinalPDFs(string final_id)
2852
        {
2853
            List<FINAL_PDF> results = new List<FINAL_PDF>();
2854

    
2855
            try
2856
            {
2857
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2858
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2859
                {
2860
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == final_id).ToList();
2861
                    foreach(var final in finalList)
2862
                    {
2863
                        FINAL_PDF pdf = new FINAL_PDF()
2864
                        {
2865
                            ID = final.ID,
2866
                            DOCINFO_ID = final.DOCINFO_ID,
2867
                            DOCUMENT_ID = final.DOCUMENT_ID,
2868
                            STATUS = final.STATUS,
2869
                            CURRENT_PAGE = final.CURRENT_PAGE,
2870
                            CREATE_DATETIME = final.CREATE_DATETIME,
2871
                            START_DATETIME = final.START_DATETIME,
2872
                            END_DATETIME = final.END_DATETIME,
2873
                            EXCEPTION = final.EXCEPTION,
2874
                            PROJECT_NO = final.PROJECT_NO,
2875
                            TOTAL_PAGE = final.TOTAL_PAGE,
2876
                            MARKUPINFO_ID = final.MARKUPINFO_ID,
2877
                            CREATE_USER_ID = final.CREATE_USER_ID
2878
                        };
2879
                        results.Add(pdf);
2880
                    }
2881
                }
2882
            }
2883
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2884
                throw;
2885
            }
2886
            return results;
2887
        }
2888
        [OperationContract]
2889
        [ServiceKnownType(typeof(DOCPAGE))]
2890
        public List<DOCPAGE> FinalPDF_GetDocpage(string project_no, string docinfo_id)
2891
        {
2892
            List<DOCPAGE> results = new List<DOCPAGE>();
2893

    
2894
            try
2895
            {
2896
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2897
                using (CIEntities _entity = new CIEntities(sCIConnString))
2898
                {
2899
                    var pages = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == docinfo_id).OrderBy(x => x.PAGE_NUMBER).ToList();
2900
                    foreach(var page in pages)
2901
                    {
2902
                        DOCPAGE p = new DOCPAGE()
2903
                        {
2904
                            PAGE_ANGLE = page.PAGE_ANGLE,
2905
                            PAGE_NUMBER = page.PAGE_NUMBER,
2906
                            PAGE_HEIGHT = page.PAGE_HEIGHT,
2907
                            PAGE_WIDTH = page.PAGE_WIDTH,
2908
                            DOCINFO_ID = page.DOCINFO_ID                            
2909
                        };
2910
                        results.Add(p);
2911
                    }                    
2912
                }
2913
            }
2914
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2915
                throw;
2916
            }
2917
            return results;
2918
        }
2919
        [OperationContract]        
2920
        public bool FinalPDF_SetFinalPDFStatus(string final_id, FinalStatus status)
2921
        {
2922
            bool result = false;
2923

    
2924
            try
2925
            {
2926
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2927
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2928
                {
2929
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
2930
                    if(tmp != null)
2931
                    {
2932
                        switch(status)
2933
                        {
2934
                            case FinalStatus.Create:
2935
                                tmp.START_DATETIME = DateTime.Now;
2936
                                break;
2937
                            case FinalStatus.Success:
2938
                                tmp.END_DATETIME = DateTime.Now;
2939
                                tmp.EXCEPTION = string.Empty;
2940
                                break;                                
2941
                        }
2942
                        tmp.STATUS = (int)status;
2943
                        _entity.SaveChanges();
2944
                        result = true;                        
2945
                    }
2946
                }                    
2947
            }
2948
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2949
                throw;
2950
            }
2951
            return result;
2952
        }
2953

    
2954
        /// <summary>
2955
        /// 현재 진행중인 Final PDF 가 없거나 Success 일 경우에만 true return
2956
        /// </summary>
2957
        /// <param name="DocInfoID"></param>
2958
        /// <param name="MarkupInfoID"></param>
2959
        /// <param name="CreateUserID"></param>
2960
        /// <returns></returns>
2961
        [OperationContract]
2962
        public bool FinalPDF_GetFinalPDFStatus(string DocInfoID, string MarkupInfoID, string CreateUserID)
2963
        {
2964
            bool result = false;
2965

    
2966
            try
2967
            {
2968
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2969
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2970
                {
2971
                    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();
2972
                    if (finalpdf != null)
2973
                    {
2974
                        if (finalpdf.STATUS == (int)FinalStatus.Success)
2975
                        {
2976
                            result = true;
2977
                        }
2978
                    }
2979
                    else
2980
                        result = true;
2981
                }
2982
            }
2983
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2984
                throw;
2985
            }
2986
            return result;
2987
        }
2988

    
2989
        [OperationContract]
2990
        public bool FinalPDF_SetCurrentPage(string final_id, int currentpage)
2991
        {
2992
            bool result = false;
2993

    
2994
            try
2995
            {
2996
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2997
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
2998
                {
2999
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
3000
                    if (tmp != null)
3001
                    {
3002
                        tmp.CURRENT_PAGE = currentpage;
3003
                        _entity.SaveChanges();
3004
                        result = true;
3005
                    }
3006
                }
3007
            }
3008
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3009
                throw;
3010
            }
3011
            return result;
3012
        }
3013
        [OperationContract]
3014
        public bool FinalPDF_SetError(string final_id, string msg)
3015
        {
3016
            bool result = false;
3017

    
3018
            try
3019
            {
3020
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3021
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3022
                {
3023
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
3024
                    if (tmp != null)
3025
                    {                        
3026
                        tmp.STATUS = (int)FinalStatus.Error;
3027
                        tmp.EXCEPTION = DateTime.Now.ToShortDateString() + " " + msg;                        
3028
                        _entity.SaveChanges();
3029
                        result = true;
3030
                    }
3031
                }
3032
            }
3033
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3034
                throw;
3035
            }
3036
            return result;
3037
        }
3038

    
3039
        [OperationContract]
3040
        public bool FinalPDF_SetFinalResultPath(string project_no, string document_id, string url)
3041
        {
3042
            bool result = false;
3043

    
3044
            try
3045
            {
3046
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3047
                using (CIEntities _entity = new CIEntities(sCIConnString))
3048
                {
3049
                    var item = _entity.DOCUMENT_ITEM.Where(d =>d.PROJECT_NO == project_no && d.DOCUMENT_ID == document_id).FirstOrDefault();
3050
                    if (item != null)
3051
                    {
3052
                        item.RESULT_FILE = url;
3053
                        _entity.SaveChanges();
3054
                        result = true;
3055
                    }
3056
                }
3057
            }
3058
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3059
                throw;
3060
            }
3061
            return result;
3062
        }
3063
        [OperationContract]
3064
        [ServiceKnownType(typeof(MEMBER))]
3065
        public MEMBER FinalPDF_GetCommentMember(string project_no, string markupdata_id)
3066
        {
3067
            MEMBER member = null;
3068
            try
3069
            {
3070
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3071
                using (CIEntities _entity = new CIEntities(sCIConnString))
3072
                {
3073
                    var data = _entity.MARKUP_DATA.Where(x => x.ID == markupdata_id).FirstOrDefault();
3074
                    string user_id = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
3075

    
3076
                    var person = GetMemberQuery(_entity,user_id);
3077

    
3078
                    if(person.Count() > 0)
3079
                    {
3080
                        member = person.First();
3081
                    }
3082
                }
3083
            }
3084
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3085
                throw;
3086
            }
3087

    
3088
            return member;
3089
        }
3090

    
3091
        [OperationContract]
3092
        [ServiceKnownType(typeof(PROPERTIES))]
3093
        public List<PROPERTIES> FinalPDF_GetProperties(string project_no)
3094
        {
3095
            List<PROPERTIES> results = new List<PROPERTIES>();
3096
            try
3097
            {
3098
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3099
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3100
                {
3101
                    var _items = _entity.PROPERTIES.Where(x => x.PROPERTY == project_no).ToList();
3102
                    foreach(var item in _items)
3103
                    {
3104
                        PROPERTIES pROPERTIES = new PROPERTIES()
3105
                        {
3106
                            ID = item.ID,
3107
                            PROPERTY = item.PROPERTY,
3108
                            TYPE = item.TYPE,
3109
                            VALUE = item.VALUE
3110
                        };
3111
                        results.Add(pROPERTIES);
3112
                    }
3113
                }
3114

    
3115
            }
3116
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3117
                throw;
3118
            }
3119
            return results;
3120
        }
3121
        #endregion
3122
    }    
3123
}
클립보드 이미지 추가 (최대 크기: 500 MB)