프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ 77cdac33

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

1 787a4489 KangIngu
using IFinalPDF;
2
using IKCOM;
3
using KCOMDataModel.Common;
4
using KCOMDataModel.DataModel;
5
using System;
6
using System.Collections.Generic;
7 2ab012e8 djkim
using System.Collections.ObjectModel;
8 ff01c725 humkyung
using System.Configuration;
9 787a4489 KangIngu
using System.Linq;
10 dfb95d0f djkim
using System.Net;
11 787a4489 KangIngu
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 ff01c725 humkyung
using System.Web.Services;
17 787a4489 KangIngu
using System.Windows;
18 dfb95d0f djkim
using System.Xml;
19 315ae55e taeseongkim
using ColorSelector;
20 787a4489 KangIngu
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 0585d5cc taeseongkim
        public ServiceDeepView()
30
        {
31 e1c892f7 taeseongkim
            //System.Diagnostics.Debug.WriteLine(OperationContext.Current.RequestContext.RequestMessage.Headers.Action.ToString());
32 0585d5cc taeseongkim
        }
33
34 ffddbe4e djkim
        /// <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 264c9309 ljiyeon
        [OperationContract]
41
        public string GetVersionData(bool is64BitProcess, string markusVer)
42
        {
43
            string url = null;
44 d71b4688 ljiyeon
45 264c9309 ljiyeon
            try
46
            {
47 ffddbe4e djkim
                Version client_version = new Version(markusVer);
48
                
49
                //DB에서 version 정보와 다운로드 url 을 Select
50
                PROPERTIES dbvalue = null;
51 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
52
                using (KCOMEntities uc = new KCOMEntities(sConnString))
53 ffddbe4e djkim
                {
54
                    string wherestr = string.Empty;
55
                    if (is64BitProcess)
56 264c9309 ljiyeon
                    {
57 ffddbe4e djkim
                        wherestr = "Update_x64";                        
58 264c9309 ljiyeon
                    }
59
                    else
60
                    {
61 075cbfcf taeseongkim
                        wherestr = "Update_x86";                        
62 ffddbe4e djkim
                    }
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 264c9309 ljiyeon
                }
73
            }
74 0585d5cc taeseongkim
            catch (Exception ex)
75 264c9309 ljiyeon
            {
76 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetVersionData : " + ex.ToString());
77
78 264c9309 ljiyeon
                url = null;
79
            }
80
            return url;
81
        }
82 ff01c725 humkyung
    
83 787a4489 KangIngu
84
        [OperationContract]
85
        public KCOM_SystemInfo GetSystemData()
86
        {
87
            try
88
            {
89 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
90
                using (KCOMEntities uc = new KCOMEntities(sConnString))
91 787a4489 KangIngu
                {
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 9a1ce1db KangIngu
108
                    url = uc.PROPERTIES.Where(data => data.TYPE == "STAMP").FirstOrDefault();
109
                    if(url != null)
110
                    {
111
                        sysInfo.STAMP = url.VALUE;
112
                    }
113 787a4489 KangIngu
                    return sysInfo;
114
                }
115
            }
116
            catch (Exception ex)
117
            {
118 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetSystemData : " + ex.ToString());
119
120 787a4489 KangIngu
            }
121
            return null;
122 24c5e56c taeseongkim
            //GC.Collect(2);
123 787a4489 KangIngu
        }
124
125
        private static string shortGuid()
126 e1c892f7 taeseongkim
        { 
127 787a4489 KangIngu
            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 992a98b4 KangIngu
        public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
144
        {
145 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
146
            using (KCOMEntities dc = new KCOMEntities(sConnString))
147 992a98b4 KangIngu
            {
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 0585d5cc taeseongkim
164 992a98b4 KangIngu
        [OperationContract]
165
        public bool EditFavoriteVP(string prjNo, string userID, string docID, int state, string description)
166
        {
167 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
168
            using (KCOMEntities dc = new KCOMEntities(sConnString))
169 992a98b4 KangIngu
            {
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 0585d5cc taeseongkim
                catch (Exception ex)
194 992a98b4 KangIngu
                {
195 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - EditFavoriteVP : " + ex.ToString());
196
197 992a98b4 KangIngu
                    return false;
198
                }
199
            }
200
        }
201
202
        [OperationContract]
203
        public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string docID)
204
        {
205 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
206
            using (KCOMEntities dc = new KCOMEntities(sConnString))
207 992a98b4 KangIngu
            {
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 0585d5cc taeseongkim
                catch (Exception ex)
226 992a98b4 KangIngu
                {
227 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - DelFavoriteVP : " + ex.ToString());
228
229 992a98b4 KangIngu
                    return false;
230
                }
231
            }
232
        }
233
234 9294fed6 humkyung
        /// <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 992a98b4 KangIngu
        [OperationContract]
245 d9cf7d6e djkim
        public List<Rect> GetCompareRect(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress)
246 787a4489 KangIngu
        {
247 6b6e937c taeseongkim
            List<Rect> result = new List<Rect>();
248
249 72424099 taeseongkim
            try
250
            {
251
                string originFile = "";
252
                string targetFile = "";
253 a874198d humkyung
254 72424099 taeseongkim
                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 a1142a6b taeseongkim
257 72424099 taeseongkim
                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 787a4489 KangIngu
268 5b5d9b1f taeseongkim
                using (Markus.Image.ImageCompare compareLib = new Markus.Image.ImageCompare())
269 72424099 taeseongkim
                {
270
                    result = compareLib.CompareReturnRects(originFile, targetFile, new System.Drawing.Size(20, 20));
271
                }
272
            }
273
            catch (Exception ex)
274 6b6e937c taeseongkim
            {
275 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetCompareRect : " + ex.ToString());
276 72424099 taeseongkim
                //throw new FaultException(ex.ToString() + " Inner Exception : " + ex.InnerException?.ToString());
277 6b6e937c taeseongkim
            }
278 0585d5cc taeseongkim
279 787a4489 KangIngu
280
            return result;
281
        }
282
283 3212270d taeseongkim
        /// <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 6b6e937c taeseongkim
        //[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 787a4489 KangIngu
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 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
386
                using (CIEntities _ci = new CIEntities(sCIConnString))
387 787a4489 KangIngu
                {
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 ff01c725 humkyung
417
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
418
                    using (KCOMEntities _entity = new KCOMEntities(sConnString))
419 787a4489 KangIngu
                    {
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 ff01c725 humkyung
                        using (KCOMEntities ec = new KCOMEntities(sConnString))
433 787a4489 KangIngu
                        {
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 55bf7ac2 taeseongkim
                                                      KCOM_API.Properties.Settings.Default.FinalService);
440 787a4489 KangIngu
                        }
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 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - SetFinalPDF : " + ex.ToString());
460
461 787a4489 KangIngu
                _result.Status = FinalStatus.Error;
462
463
                if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
464
                    _result.Exception = "Final Server Not Connection";
465 b734b65d djkim
                else _result.Exception = ex.ToString();
466 787a4489 KangIngu
            }
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 ff01c725 humkyung
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
484
            using (CIEntities entity = new CIEntities(sCIConnString))
485 787a4489 KangIngu
            {
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 ff01c725 humkyung
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
497
                        KCOMEntities entity_kcom = new KCOMEntities(sConnString);
498 787a4489 KangIngu
                        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 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
524
                using (CIEntities entity = new CIEntities(sCIConnString))
525 787a4489 KangIngu
                {
526
                    var _vpList = (from docitem in entity.DOCUMENT_ITEM
527 0585d5cc taeseongkim
                                   where docitem.PROJECT_NO == ProjectNo && docitem.DOCUMENT_NO == vpNo
528 787a4489 KangIngu
                                   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 c91f45f3 djkim
                                       DocNo = docitem.DOCUMENT_NO,
537 ab5aa762 taeseongkim
                                       //EnsembleLink = docitem.ENSEMBLEINFO_URL,
538 c0977e97 djkim
                                       //IsSyncPossible = docitem.DOCUMENT_ID == DocumentId ? false : entity.DOCINFO.Where(d => d.DOCUMENT_ID == docitem.DOCUMENT_ID).ToList().Count > 0 ? true : false
539 787a4489 KangIngu
                                   });
540
                    _result = _vpList.ToList();
541 c0977e97 djkim
                    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 ff01c725 humkyung
549
                    //_result = _result.OrderByDescending(r => UInt64.Parse(System.Text.RegularExpressions.Regex.Replace(r.GroupNo, @"\D", ""))).ToList();
550 f65e6c02 taeseongkim
                    _result =  _result.OrderByDescending(r => r.GroupNo).ToList();
551 787a4489 KangIngu
                }
552
            }
553 ff01c725 humkyung
            catch (Exception ex)
554 787a4489 KangIngu
            {
555 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetVPRevisionHistory : " + ex.ToString());
556 787a4489 KangIngu
            }
557
            finally
558
            {
559 24c5e56c taeseongkim
                //GC.Collect(2);
560 787a4489 KangIngu
            }
561 0585d5cc taeseongkim
562 787a4489 KangIngu
            return _result;
563
        }
564
565
        [OperationContract]
566 2ab012e8 djkim
        public VPRevision GetVPRevisionFirstOrDefault(string ProjectNo, string DocumentId)
567
        {
568
            VPRevision _result = null;
569
            try
570
            {
571 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
572
                using (CIEntities entity = new CIEntities(sCIConnString))
573 2ab012e8 djkim
                {
574
                    _result = (from docitem in entity.DOCUMENT_ITEM
575 0585d5cc taeseongkim
                     where docitem.PROJECT_NO == ProjectNo && docitem.DOCUMENT_ID == DocumentId
576 2ab012e8 djkim
                     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 0585d5cc taeseongkim
            catch (Exception ex)
588 2ab012e8 djkim
            {
589 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetVPRevisionFirstOrDefault : " + ex.ToString());
590 2ab012e8 djkim
            }
591
            finally
592
            {
593 24c5e56c taeseongkim
                //GC.Collect(2);
594 2ab012e8 djkim
            }
595
            return _result;
596
        }
597
598
        [OperationContract]
599 787a4489 KangIngu
        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 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
607
                CIEntities ModelDeeview = new CIEntities(sCIConnString);
608 787a4489 KangIngu
609 683a4a8f djkim
                var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID && doc.PROJECT_NO == param.projectNo);
610 787a4489 KangIngu
                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 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDocInfo : " + ex.ToString());
622 787a4489 KangIngu
            }
623
            finally
624
            {
625 24c5e56c taeseongkim
                //GC.Collect(2);
626 787a4489 KangIngu
            }
627
            return null;
628
        }
629
630
        [OperationContract]
631
        public bool GetCheckSystemAdmin(string UserID)
632
        {
633 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
634
            using (KCOMEntities uc = new KCOMEntities(sConnString))
635 787a4489 KangIngu
            {
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 24c5e56c taeseongkim
            //GC.Collect(2);
647 787a4489 KangIngu
        }
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 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
658
                CIEntities entity = new CIEntities(sCIConnString);
659 ac91e747 taeseongkim
               
660 0585d5cc taeseongkim
                var _items = entity.DOCUMENT_ITEM.Where(data => data.PROJECT_NO == param.projectNo && data.DOCUMENT_ID == param.documentID);
661 787a4489 KangIngu
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 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDocumentItemInfo : " + ex.ToString());
676 ac91e747 taeseongkim
677
                new FaultException("GetDocumentItemInfo Error - "  + ex.ToString());
678 ff01c725 humkyung
                //throw new FaultException(ex.ToString());
679 787a4489 KangIngu
                //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 35afe17c djkim
        /// <summary>
685
        /// DOCUMENT_ITEM Table 의 ID 로 Item 을 Select
686
        /// </summary>
687 5ded1e5a djkim
        /// 대림의 경우 Interface ID(Document 의 ID) 를 parameter 로 전달
688
        /// 넘어온 ID를 통해 document id 를 확인하는 과정이 필요
689 35afe17c djkim
        /// <param name="ensemble_id"></param>
690
        /// <returns></returns>
691 c0977e97 djkim
        [OperationContract]
692
        public string GetDocItemID(string ensemble_id)
693
        {
694
            ///param : prjNo, documentId, userId
695
            string _result = string.Empty;
696
697
            try
698
            {
699 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
700
                CIEntities entity = new CIEntities(sCIConnString);
701 787a4489 KangIngu
702 c0977e97 djkim
                var _items = entity.DOCUMENT_ITEM.Where(data => data.ID == ensemble_id).FirstOrDefault();
703 35afe17c djkim
                if(_items != null)
704
                    _result = _items.DOCUMENT_ID;
705 c0977e97 djkim
            }
706
            catch (Exception ex)
707
            {
708 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDocItemID : " + ex.ToString());
709 c0977e97 djkim
                //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 787a4489 KangIngu
        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 53880c83 ljiyeon
        
724
        [OperationContract]
725
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
726
        {
727
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
728
            try
729
            {
730 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
731
                using (CIEntities entity = new CIEntities(sCIConnString))
732 53880c83 ljiyeon
                {
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 c0977e97 djkim
                                        select new MarkupItem { ID = markupData.ID, PageNumber = markupData.PAGENUMBER, Data = markupData.DATA, Data_Type = markupData.DATA_TYPE, Symbol_ID = markupData.SYMBOL_ID}).ToList();
762 53880c83 ljiyeon
                    });
763
764 c0977e97 djkim
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
765 53880c83 ljiyeon
                    Random random = new Random();
766 ff01c725 humkyung
767
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
768
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
769 c0977e97 djkim
                    {
770
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
771
                                             where property.TYPE == "DisplayColor"
772
                                             select property).ToList();
773 315ae55e taeseongkim
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 a1142a6b taeseongkim
                    }
788
789
                    bool IsProjectNoPass = Properties.Settings.Default.IsProjectNoPass;
790 53880c83 ljiyeon
791
                    foreach (var item in _result)
792
                    {
793 a1142a6b taeseongkim
                        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 c0977e97 djkim
                        
798 a1142a6b taeseongkim
                        if (memberQuery.Count() > 0)
799 53880c83 ljiyeon
                        {
800 a1142a6b taeseongkim
                            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 53880c83 ljiyeon
                        }
806
807 c0977e97 djkim
                        if (_ColorsProperties.Count > 0)
808 53880c83 ljiyeon
                        {
809 c0977e97 djkim
                            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 53880c83 ljiyeon
                        }
816 c0977e97 djkim
                        else
817 53880c83 ljiyeon
                        {
818
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
819 c0977e97 djkim
                        }
820 53880c83 ljiyeon
                    }
821
                }
822
            }
823 0585d5cc taeseongkim
            catch (Exception ex)
824 53880c83 ljiyeon
            {
825 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetMarkupInfoItems : " + ex.ToString());
826
827 53880c83 ljiyeon
                return _result;
828
            }
829
            finally
830
            {
831 24c5e56c taeseongkim
                //GC.Collect(2);
832 53880c83 ljiyeon
            }
833
834
            return _result;
835
        }
836
837 787a4489 KangIngu
        [OperationContract]
838
        public List<MarkupInfoItem> GetSyncMarkupInfoItems(string ProjectNo, string DocInfoId, string currentUser)
839
        {
840
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
841
            try
842
            {
843 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
844
                using (CIEntities entity = new CIEntities(sCIConnString))
845 787a4489 KangIngu
                {
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 ab5aa762 taeseongkim
                                        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 787a4489 KangIngu
                    });
892
893
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
894
                    Random random = new Random();
895
896 ff01c725 humkyung
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
897
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
898 787a4489 KangIngu
                    {
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 a1142a6b taeseongkim
                        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 787a4489 KangIngu
911 a1142a6b taeseongkim
                        if (memberQuery.Count() > 0)
912 787a4489 KangIngu
                        {
913 a1142a6b taeseongkim
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 787a4489 KangIngu
                        }
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 0585d5cc taeseongkim
            catch (Exception ex)
940 787a4489 KangIngu
            {
941 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetSyncMarkupInfoItems : " + ex.ToString());
942 787a4489 KangIngu
                return _result;
943
            }
944
            finally
945
            {
946 24c5e56c taeseongkim
                //GC.Collect(2);
947 787a4489 KangIngu
            }
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 2ab012e8 djkim
        [OperationContract]
971
        [ServiceKnownType(typeof(MEMBER))]
972
        public List<MEMBER> GetUserData(string ProjectNo, string UserID)
973
        {
974
            List<MEMBER> _result = new List<MEMBER>();
975 787a4489 KangIngu
976 ff01c725 humkyung
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
977 285635d3 taeseongkim
978 ff01c725 humkyung
            using (CIEntities entity = new CIEntities(sCIConnString))
979 2ab012e8 djkim
            {
980 285635d3 taeseongkim
                _result = GetMemberQuery(entity, UserID);
981 2ab012e8 djkim
            }
982
            //GC.Collect(2);
983
            return _result;
984
        }
985 787a4489 KangIngu
986
987
        [OperationContract]
988
        public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정
989
        {
990
            List<string> _result = new List<string>();
991
992
            try
993
            {
994 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
995
                KCOMEntities entity = new KCOMEntities(sConnString);
996 787a4489 KangIngu
                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 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDeptData : " + ex.ToString());
1015 787a4489 KangIngu
            }
1016
            finally
1017
            {
1018 24c5e56c taeseongkim
                //GC.Collect(2);
1019 787a4489 KangIngu
            }
1020
            return _result;
1021
        }
1022
1023
        [OperationContract]
1024
        public bool DeleteMarkup(string ProjectNo, string MarkupInfoID)
1025
        {
1026
            bool _result = false;
1027
            try
1028
            {
1029 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1030
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(sCIConnString))
1031 787a4489 KangIngu
                {
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 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - DeleteMarkup : " + ex.ToString());
1060 787a4489 KangIngu
            }
1061
            finally
1062
            {
1063 24c5e56c taeseongkim
                //GC.Collect(2);
1064 787a4489 KangIngu
            }
1065
            return _result;
1066
        }
1067 992a98b4 KangIngu
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 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1073
            using (KCOMEntities entity = new KCOMEntities(sConnString))
1074 992a98b4 KangIngu
            {
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 0585d5cc taeseongkim
                catch (Exception ex)
1094 992a98b4 KangIngu
                {
1095 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SetFavoriteVP : " + ex.ToString());
1096 992a98b4 KangIngu
                    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 24c5e56c taeseongkim
        //        catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1147 992a98b4 KangIngu
        //        {
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 24c5e56c taeseongkim
        //        catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1177 992a98b4 KangIngu
        //        {
1178
        //            return false;
1179
        //        }
1180
        //    }
1181
        //}
1182
        #endregion
1183 2ab012e8 djkim
1184
        [OperationContract]
1185
        public bool SaveMarkupData(MarkupInfoItem UserState,string project_no,string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1186
        {
1187 6b6e937c taeseongkim
            
1188 ff01c725 humkyung
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1189
            using (CIEntities Entity = new CIEntities(sCIConnString))
1190 2ab012e8 djkim
            {     
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 0585d5cc taeseongkim
                catch (Exception ex)
1210 2ab012e8 djkim
                {
1211 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SaveMarkupData Get markup_info: " + ex.ToString());
1212 2ab012e8 djkim
                    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 0585d5cc taeseongkim
                catch (Exception ex)
1252 2ab012e8 djkim
                {
1253 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SaveMarkupData  Get markup_info_version : " + ex.ToString());
1254 2ab012e8 djkim
                    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 77cdac33 taeseongkim
1278 2ab012e8 djkim
                Entity.SaveChanges();
1279 6b6e937c taeseongkim
1280
                try
1281
                {
1282
                    mlmarkup_data.ForEach(value =>
1283
                    {
1284
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1285
                        {
1286
                            ID = value.ID,
1287
                            DATA = value.DATA,
1288
                            DATA_TYPE = value.DATA_TYPE,
1289
                            PAGENUMBER = value.PAGENUMBER,
1290
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1291
                            SYMBOL_ID = value.SYMBOL_ID,
1292
                            //GROUP_ID = value.GROUP_ID
1293
                        });
1294 b42dd24d taeseongkim
1295
                        
1296 6b6e937c taeseongkim
                    });
1297
                    Entity.SaveChanges();
1298 b42dd24d taeseongkim
1299
                    if (Properties.Settings.Default.Properties["CLIENT_VERSION"] != null)
1300
                    {
1301
                        string sql = $"UPDATE MARKUP_DATA SET REMARK = '{Properties.Settings.Default.CLIENT_VERSION} {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }' WHERE ID = @ID";
1302
1303
                        mlmarkup_data.ForEach(value =>
1304
                        {
1305
                            var param = new System.Data.Common.DbParameter[] { new System.Data.SqlClient.SqlParameter { ParameterName = "ID", Value = value.ID } };
1306
                            var result = Entity.ExecuteStoreCommand(sql, param);
1307
                        });
1308
1309
                        Entity.SaveChanges();
1310
                    }
1311 6b6e937c taeseongkim
                }
1312 0585d5cc taeseongkim
                catch (Exception ex)
1313 6b6e937c taeseongkim
                {
1314 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SaveMarkupData  set mlmarkup_data : " + ex.ToString());
1315 6b6e937c taeseongkim
                    return false;
1316
                }
1317
            }
1318
            return true;
1319
        }
1320
1321
        [OperationContract]
1322
        public bool SavePageMarkupData(MarkupInfoItem UserState,int PageNo, string project_no, string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1323
        {
1324
1325
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1326
            using (CIEntities Entity = new CIEntities(sCIConnString))
1327
            {
1328
                #region Docinfo 정보 가져오기
1329
1330
                string docinfoid_ = (from info in Entity.DOCINFO
1331
                                     where info.DOCUMENT_ID == doc_id
1332
                                     && info.PROJECT_NO == project_no
1333
                                     select info.ID
1334
                                     ).First().ToString();
1335
                #endregion
1336
1337
                #region Markup_Info 저장
1338
1339
                MARKUP_INFO markup_info = new MARKUP_INFO();
1340
                try
1341
                {
1342
                    markup_info = (from info in Entity.MARKUP_INFO
1343
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
1344
                                   select info).FirstOrDefault();
1345
                }
1346 0585d5cc taeseongkim
                catch (Exception ex)
1347 6b6e937c taeseongkim
                {
1348 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SavePageMarkupData : " + ex.ToString());
1349
1350 6b6e937c taeseongkim
                    markup_info = null;
1351
                }
1352
1353
                //markup_info가 없을 경우 생성
1354
                if (markup_info == null)
1355
                {
1356
                    //MarkupInfo 저장
1357
                    markup_info = new MARKUP_INFO
1358
                    {
1359
                        ID = UserState.MarkupInfoID,
1360
                        DOCINFO_ID = docinfoid_,
1361
                        USER_ID = user_id,
1362
                        CREATE_TIME = DateTime.Now,
1363
                        CONSOLIDATE = UserState.Consolidate,
1364
                        AVOID_CONSOLIDATE = UserState.AvoidConsolidate,
1365
                        PART_CONSOLIDATE = UserState.PartConsolidate,
1366
                        DESCRIPTION = UserState.Description,
1367
                        UPDATE_TIME = DateTime.Now
1368
                    };
1369
                    Entity.MARKUP_INFO.AddObject(markup_info);
1370
                }
1371
                //markup_info가 있을 경우 업데이트
1372
                else
1373
                {
1374
                    markup_info.UPDATE_TIME = DateTime.Now;
1375
                }
1376
                Entity.SaveChanges();
1377
                #endregion
1378
1379
                #region Markup_Info_Version 저장
1380
1381
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1382
1383
                try
1384
                {
1385
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1386
                                           where info.MARKUPINFO_ID == markup_info.ID
1387
                                           select info).FirstOrDefault();
1388
                }
1389 0585d5cc taeseongkim
                catch (Exception ex)
1390 6b6e937c taeseongkim
                {
1391 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SavePageMarkupData get markup_info_version : " + ex.ToString());
1392 6b6e937c taeseongkim
                    markup_info_version = null;
1393
                }
1394
1395
                //markup_info_version 없을 경우 생성
1396
                if (markup_info_version == null)
1397
                {
1398
                    //MarkupInfo_version 저장
1399
                    markup_info_version = new MARKUP_INFO_VERSION()
1400
                    {
1401
                        ID = UserState.MarkupVersionID,
1402
                        MARKUPINFO_ID = markup_info.ID,
1403
                        CREATE_DATE = DateTime.Now
1404
                    };
1405
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1406
                    Entity.SaveChanges();
1407
                }
1408
                #endregion
1409
1410
1411
                Entity.MARKUP_DATA.Where(data =>  data.PAGENUMBER == PageNo && data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1412
                {
1413
                    Entity.MARKUP_DATA.DeleteObject(item);
1414
                });
1415
                Entity.SaveChanges();
1416 2ab012e8 djkim
1417
                try
1418
                {
1419
                    mlmarkup_data.ForEach(value =>
1420
                    {
1421
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1422
                        {
1423
                            ID = value.ID,
1424
                            DATA = value.DATA,
1425
                            DATA_TYPE = value.DATA_TYPE,
1426
                            PAGENUMBER = value.PAGENUMBER,
1427 c8e9b3e4 ljiyeon
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1428 53880c83 ljiyeon
                            SYMBOL_ID = value.SYMBOL_ID,
1429 c0977e97 djkim
                            //GROUP_ID = value.GROUP_ID
1430 2ab012e8 djkim
                        });
1431
                    });
1432
                    Entity.SaveChanges();
1433
                }
1434 0585d5cc taeseongkim
                catch (Exception ex)
1435 2ab012e8 djkim
                {
1436 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SavePageMarkupData set mlmarkup_data : " + ex.ToString());
1437 2ab012e8 djkim
                    return false;
1438
                }
1439
            }
1440
            return true;
1441
        }
1442
1443 c0977e97 djkim
        //[OperationContract]
1444
        //public long AddMarkupDataGroup(MARKUP_DATA_GROUP mARKUP_DATA_GROUP, string ProjectNo)
1445
        //{
1446
        //    try
1447
        //    {
1448
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1449
        //        {
1450
        //            Entity.AddToMARKUP_DATA_GROUP(mARKUP_DATA_GROUP);
1451
        //            //MARKUP_DATA_GROUP tt = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == id).FirstOrDefault();
1452
        //            Entity.SaveChanges();
1453 53880c83 ljiyeon
1454 c0977e97 djkim
        //            return Entity.MARKUP_DATA_GROUP.ToList().LastOrDefault().ID;
1455
        //        }
1456
        //    }
1457 24c5e56c taeseongkim
        //    catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1458 c0977e97 djkim
        //    {
1459
        //        return 0;
1460
        //    }
1461
        //}
1462
        //[OperationContract]
1463
        //public bool UpdateMarkupDataGroup(long Group_ID, string ProjectNo)
1464
        //{
1465
        //    try
1466
        //    {
1467
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1468
        //        {
1469
        //            var UpdateItem = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == Group_ID).FirstOrDefault();
1470
        //            UpdateItem.STATE = 1;
1471
        //            Entity.SaveChanges();
1472
        //        }
1473
        //    }
1474 24c5e56c taeseongkim
        //    catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1475 c0977e97 djkim
        //    {
1476
        //        return false;
1477
        //    }
1478
        //    return true;
1479
        //}
1480 53880c83 ljiyeon
        [OperationContract]
1481
        public bool UpdateMarkupData(string CommentID, long Group_ID, string ProjectNo)
1482
        {
1483
            try
1484
            {
1485 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1486
                using (CIEntities Entity = new CIEntities(sCIConnString))
1487 53880c83 ljiyeon
                {
1488
                    var UpdateItem = Entity.MARKUP_DATA.Where(info => info.ID == CommentID).FirstOrDefault();
1489 c0977e97 djkim
                    //UpdateItem.GROUP_ID = Group_ID;
1490 53880c83 ljiyeon
                    Entity.SaveChanges();
1491
                }
1492
            }
1493 0585d5cc taeseongkim
            catch (Exception ex)
1494 53880c83 ljiyeon
            {
1495 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - UpdateMarkupData: " + ex.ToString());
1496 53880c83 ljiyeon
                return false;
1497
            }
1498
            return true;
1499
        }
1500 2ab012e8 djkim
1501
        [OperationContract]
1502
        public bool SaveSymbol(SYMBOL_PRIVATE symbol_private)
1503
        {
1504
            try
1505
            {
1506 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1507
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
1508 2ab012e8 djkim
                {
1509
                    uc.AddToSYMBOL_PRIVATE(symbol_private);
1510
                    uc.SaveChanges();
1511
                }
1512
            }
1513 0585d5cc taeseongkim
            catch (Exception ex)
1514 2ab012e8 djkim
            {
1515 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - SaveSymbol: " + ex.ToString());
1516 2ab012e8 djkim
                return false;
1517
            }
1518
            return true;
1519
        }
1520
        [OperationContract]
1521 498f0fc9 ljiyeon
        public bool AddPublicSymbol(SYMBOL_PUBLIC symbol)
1522
        {
1523
            try
1524
            {
1525 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1526
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
1527 498f0fc9 ljiyeon
                {
1528
                    uc.AddToSYMBOL_PUBLIC(symbol);
1529
                    uc.SaveChanges();
1530
                }
1531
            }
1532 0585d5cc taeseongkim
            catch (Exception ex)
1533 498f0fc9 ljiyeon
            {
1534 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - AddPublicSymbol: " + ex.ToString());
1535 498f0fc9 ljiyeon
                return false;
1536
            }
1537
            return true;
1538
        }
1539
        [OperationContract]
1540
        public bool DeleteSymbol(string symbol_id, int type)
1541 2ab012e8 djkim
        {
1542
            try
1543
            {
1544 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1545
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
1546 2ab012e8 djkim
                {
1547 498f0fc9 ljiyeon
                    if (type == 0)
1548
                    {
1549
                        string delItem_ID = symbol_id;
1550
                        var delitem = Entity.SYMBOL_PRIVATE.Where(data => data.ID == delItem_ID).FirstOrDefault();
1551
                        Entity.SYMBOL_PRIVATE.DeleteObject(delitem);
1552
                        Entity.SaveChanges();
1553
                    }
1554
                    else
1555
                    {
1556
                        string delItem_ID = symbol_id;
1557
                        var delitem = Entity.SYMBOL_PUBLIC.Where(data => data.ID == delItem_ID).FirstOrDefault();
1558
                        Entity.SYMBOL_PUBLIC.DeleteObject(delitem);
1559
                        Entity.SaveChanges();
1560
                    }
1561 2ab012e8 djkim
                }
1562
            }
1563 0585d5cc taeseongkim
            catch (Exception ex)
1564 2ab012e8 djkim
            {
1565 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - DeleteSymbol : " + ex.ToString());
1566
1567 2ab012e8 djkim
                return false;
1568
            }
1569
            return true;
1570
        }
1571
1572
        [OperationContract]
1573 498f0fc9 ljiyeon
        public bool RenameSymbol(string symbol_id, string name, int type)
1574 2ab012e8 djkim
        {
1575
            try
1576
            {
1577 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1578
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
1579 2ab012e8 djkim
                {
1580 498f0fc9 ljiyeon
                    if (type == 0)
1581
                    {
1582
                        var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == symbol_id).FirstOrDefault();
1583
                        UpdateItem.NAME = name;
1584
                        Entity.SaveChanges();
1585
                    }
1586
                    else
1587
                    {
1588
                        var UpdateItem = Entity.SYMBOL_PUBLIC.Where(info => info.ID == symbol_id).FirstOrDefault();
1589
                        UpdateItem.NAME = name;
1590
                        Entity.SaveChanges();
1591
                    }
1592 2ab012e8 djkim
                }
1593
            }
1594 0585d5cc taeseongkim
            catch (Exception ex)
1595 2ab012e8 djkim
            {
1596 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - RenameSymbol: " + ex.ToString());
1597 2ab012e8 djkim
                return false;
1598
            }
1599
            return true;
1600
        }
1601
1602
        [OperationContract]
1603
        public bool AddCheckListHistory(string project_no, CHECK_LIST_HISTORY Check_History)
1604
        {
1605
            try
1606 ff01c725 humkyung
            {
1607
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1608
                using (CIEntities Entity = new CIEntities(sCIConnString))
1609 2ab012e8 djkim
                {
1610
                    Entity.CHECK_LIST_HISTORY.AddObject(Check_History);
1611
                    Entity.SaveChanges();  
1612
                }
1613
            }
1614 0585d5cc taeseongkim
            catch (Exception ex)
1615 2ab012e8 djkim
            {
1616 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - AddCheckListHistory: " + ex.ToString());
1617 2ab012e8 djkim
                return false;
1618
            }
1619
            return true;
1620
        }
1621
        [OperationContract]
1622
        public bool SaveCheckListHistory(string project_no, string rev, CHECK_LIST_HISTORY Check_History)
1623
        {
1624
            try
1625
            {
1626 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1627
                using (CIEntities Entity = new CIEntities(sCIConnString))
1628 2ab012e8 djkim
                {
1629
                    var item = Entity.CHECK_LIST_HISTORY.Where(info => info.REVISION == rev).FirstOrDefault();
1630
                    item = Check_History;
1631
                    Entity.SaveChanges();
1632
                }
1633
            }
1634 0585d5cc taeseongkim
            catch (Exception ex)
1635 2ab012e8 djkim
            {
1636 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - SaveCheckListHistory: " + ex.ToString());
1637 2ab012e8 djkim
                return false;
1638
            }
1639
            return true;
1640
        }
1641
        [OperationContract]
1642
        public bool SaveCheckList(string project_no, string _id, CHECK_LIST Check_value)
1643
        {
1644
            try
1645
            {
1646 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1647
                using (CIEntities Entity = new CIEntities(sCIConnString))
1648 2ab012e8 djkim
                {
1649
                    var item = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1650
                    item.TODOLIST = Check_value.TODOLIST;
1651
                    item.REMARK = Check_value.REMARK;
1652
                    item.STATUS = Check_value.STATUS;
1653
                    item.VENDOR = Check_value.VENDOR;
1654
                    item.REPLY = Check_value.REPLY;
1655
                    item.IMAGE_URL = Check_value.IMAGE_URL;
1656
                    item.IMAGE_ANCHOR = Check_value.IMAGE_ANCHOR;
1657
                    item.UPDATE_TIME = Check_value.UPDATE_TIME;
1658 5de0c110 ljiyeon
                    if(Check_value.STATUS == "False")
1659
                    {
1660
                        item.STATUS_DESC_OPEN = Check_value.STATUS_DESC_OPEN;
1661
                    }
1662
                    else
1663
                    {
1664
                        item.STATUS_DESC_CLOSE = Check_value.STATUS_DESC_CLOSE;
1665
                    }                     
1666 2ab012e8 djkim
                    Entity.SaveChanges();
1667
                }
1668
            }
1669 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1670 2ab012e8 djkim
                return false;
1671
            }
1672
            return true;
1673
        }
1674
        [OperationContract]
1675
        public bool AddCheckList(string project_no, CHECK_LIST Check_value)
1676
        {
1677
            try
1678
            {
1679 24c5e56c taeseongkim
               
1680 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1681
                using (CIEntities Entity = new CIEntities(sCIConnString))
1682 2ab012e8 djkim
                {
1683
                    Entity.CHECK_LIST.AddObject(Check_value);
1684
                    Entity.SaveChanges();
1685
                }
1686
            }
1687 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1688 2ab012e8 djkim
                return false;
1689
            }
1690
            return true;
1691
        }
1692
1693
        [OperationContract]
1694
        public CHECK_LIST GetCheckList(string project_no, string _id)
1695
        {
1696
            CHECK_LIST Check_value = new CHECK_LIST();
1697
            try
1698
            {
1699 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1700
                using (CIEntities Entity = new CIEntities(sCIConnString))
1701 2ab012e8 djkim
                {
1702
                    Check_value = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1703
                }
1704
            }
1705 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1706 2ab012e8 djkim
                return null;
1707
            }
1708
            return Check_value;
1709
        }
1710
        [OperationContract]
1711
        public List<CHECK_LIST> GetUserCheckList(string project_no, string user_id, string doc_no)
1712
        {
1713
            List<CHECK_LIST> list = new List<CHECK_LIST>();
1714
            try
1715
            {
1716 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1717
                using (CIEntities Entity = new CIEntities(sCIConnString))
1718 2ab012e8 djkim
                {
1719
                    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();
1720
                }
1721
            }
1722 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1723 2ab012e8 djkim
                return null;
1724
            }
1725
            return list;
1726
        }
1727
        [OperationContract]
1728
        public List<CHECK_LIST_HISTORY> GetCheckListHistory(string project_no, string _id)
1729
        {
1730
            List<CHECK_LIST_HISTORY> history = new List<CHECK_LIST_HISTORY>();
1731
            try
1732
            {
1733 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1734
                using (CIEntities Entity = new CIEntities(sCIConnString))
1735 2ab012e8 djkim
                {
1736
                    history = Entity.CHECK_LIST_HISTORY.Where(data => data.CHECKLIST_ID == _id).ToList();
1737
                }
1738
            }
1739 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1740 2ab012e8 djkim
                return null;
1741
            }
1742
            return history;
1743
        }
1744
        [OperationContract]
1745
        public CHECK_LIST_HISTORY GetCheckListHistoryFirstOrDefault(string project_no, string checklist_id, string rev)
1746
        {
1747
            CHECK_LIST_HISTORY Check_Item = new CHECK_LIST_HISTORY();
1748
            try
1749
            {
1750 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1751
                using (CIEntities Entity = new CIEntities(sCIConnString))
1752 2ab012e8 djkim
                {   
1753
                    Check_Item = Entity.CHECK_LIST_HISTORY.Where(info => info.CHECKLIST_ID == checklist_id && info.REVISION == rev).FirstOrDefault();
1754
                }
1755
            }
1756 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1757 2ab012e8 djkim
                return null;
1758
            }
1759
            return Check_Item;
1760
        }
1761
        [OperationContract]
1762
        public bool SavePageAngle(string project_no, List<DOCPAGE> _mldocpage)
1763
        {
1764
            try
1765
            {
1766 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1767
                using (CIEntities Entity = new CIEntities(sCIConnString))
1768 2ab012e8 djkim
                {
1769
                    KCOMDataModel.DataModel.DOCPAGE _docpage = new KCOMDataModel.DataModel.DOCPAGE();
1770
                    _mldocpage.ForEach(data =>
1771
                    {
1772
                        _docpage = (from info in Entity.DOCPAGE
1773
                                    where info.ID == data.ID
1774
                                    select info).FirstOrDefault();
1775
1776
                        if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE)
1777
                        {
1778
                            _docpage.PAGE_ANGLE = data.PAGE_ANGLE;
1779
                        }
1780
                    });
1781
1782
                    Entity.SaveChanges();
1783
                }
1784
            }
1785 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1786 2ab012e8 djkim
                return false;
1787
            }
1788
            return true;
1789
        }
1790
1791
        [OperationContract]
1792
        public MARKUP_INFO GetMarkupInfo(string project_no, string _id)
1793
        {
1794
            MARKUP_INFO markupInfo = new MARKUP_INFO();
1795
1796
            try
1797
            {
1798 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1799
                using (CIEntities Entity = new CIEntities(sCIConnString))
1800 2ab012e8 djkim
                {
1801
                    markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1802
                }
1803
            }
1804 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1805 2ab012e8 djkim
                return null;
1806
            }
1807
            return markupInfo;
1808
        }
1809
1810
        [OperationContract]
1811
        public List<string> GetMarkupDataListperPage(string project_no, string _markupinfoid, int _pageNo)
1812
        {
1813
            List<string> markupdata = new List<string>();
1814
            MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1815
            try
1816
            {
1817 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1818
                using (CIEntities Entity = new CIEntities(sCIConnString))
1819 2ab012e8 djkim
                {
1820
                    markup_info_version = (from version in Entity.MARKUP_INFO_VERSION
1821
                                           where version.MARKUPINFO_ID == _markupinfoid
1822
                                           orderby version.CREATE_DATE descending
1823
                                           select version).First();
1824
                    markupdata = (from data in Entity.MARKUP_DATA
1825
                                  where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo
1826
                                  select data.DATA).ToList();
1827
                }
1828
            }
1829 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1830 2ab012e8 djkim
                return null;
1831
            }
1832
            return markupdata;
1833
        }
1834
1835
        [OperationContract]
1836
        public bool AddMarkupInfo(string project_no, MARKUP_INFO value)
1837
        {
1838
            try
1839
            {
1840 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1841
                using (CIEntities Entity = new CIEntities(sCIConnString))
1842 2ab012e8 djkim
                {
1843
                    Entity.MARKUP_INFO.AddObject(value);
1844
                    Entity.SaveChanges();
1845
                }
1846
            }
1847 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1848 2ab012e8 djkim
                return false;
1849
            }
1850
            return true;
1851
        }
1852
1853
        [OperationContract]
1854
        public bool AddMarkupInfoVersion(string project_no, MARKUP_INFO_VERSION value)
1855
        {
1856
            try
1857
            {
1858 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1859
                using (CIEntities Entity = new CIEntities(sCIConnString))
1860 2ab012e8 djkim
                {
1861
                    Entity.MARKUP_INFO_VERSION.AddObject(value);
1862
                    Entity.SaveChanges();
1863
                }
1864
            }
1865 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1866 2ab012e8 djkim
                return false;
1867
            }
1868
            return true;
1869
        }
1870
1871
        [OperationContract]
1872
        public bool AddMarkupData(string project_no, MARKUP_DATA value)
1873
        {
1874
            try
1875
            {
1876 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1877
                using (CIEntities Entity = new CIEntities(sCIConnString))
1878 2ab012e8 djkim
                {
1879
                    Entity.MARKUP_DATA.AddObject(value);
1880
                    Entity.SaveChanges();
1881
                }
1882
            }
1883 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1884 2ab012e8 djkim
                return false;
1885
            }
1886
            return true;
1887
        }
1888
1889
        [OperationContract]
1890
        public bool AvoidMarkupInfo(string project_no, string _doc_id)
1891
        {
1892
            try
1893
            {
1894 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1895
                using (CIEntities Entity = new CIEntities(sCIConnString))
1896 2ab012e8 djkim
                {
1897
                    var item = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1898
                    item.AVOID_CONSOLIDATE = 1;
1899
                    Entity.SaveChanges();
1900
                }
1901
            }
1902 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1903 2ab012e8 djkim
                return false;
1904
            }
1905
            return true;
1906
        }
1907
1908
        [OperationContract]
1909
        public bool SaveMarkupInfo(string project_no, string _id, MARKUP_INFO value)
1910
        {
1911
            try
1912
            {
1913 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1914
                using (CIEntities Entity = new CIEntities(sCIConnString))
1915 2ab012e8 djkim
                {
1916
                    var item = Entity.MARKUP_INFO.Where(info => info.ID == _id).FirstOrDefault();
1917
                    item = value;                    
1918
                    Entity.SaveChanges();
1919
                }
1920
            }
1921 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1922 2ab012e8 djkim
                return false;
1923
            }
1924
            return true;
1925
        }
1926
        [OperationContract]
1927
        public List<MARKUP_DATA> GetMarkupDataList(string project_no, string _versionid)
1928
        {
1929
            List<MARKUP_DATA> mlresult = new List<MARKUP_DATA>();
1930
1931
            try
1932
            {
1933 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1934
                using (CIEntities Entity = new CIEntities(sCIConnString))
1935 2ab012e8 djkim
                {
1936
                    mlresult = Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == _versionid).ToList();
1937
                }
1938
            }
1939 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1940 2ab012e8 djkim
                return null;
1941
            }
1942
            return mlresult;
1943
        }
1944
1945
        [OperationContract]
1946
        public bool Consolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
1947
        {
1948
            try
1949
            {
1950
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1951 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1952
                using (CIEntities Entity = new CIEntities(sCIConnString))
1953 2ab012e8 djkim
                {
1954 0c624340 djkim
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.CONSOLIDATE == 1).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1955
                    if (markupInfo != null)
1956 2ab012e8 djkim
                    {
1957
                        markupInfo.AVOID_CONSOLIDATE = 1;
1958
                    }
1959
1960
                    foreach (MarkupInfoItem item in markupInfoItems)
1961
                    {
1962
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
1963
                        {
1964
                            instanceDataSet.Add(d);
1965
                        });
1966
                    }
1967
1968
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
1969
                    info.ID = shortGuid();
1970
                    info.CONSOLIDATE = 1;
1971
                    info.CREATE_TIME = DateTime.Now;
1972
                    info.DOCINFO_ID = _doc_id;
1973
                    info.UPDATE_TIME = DateTime.Now;
1974
                    info.USER_ID = _user_id;
1975
                    info.AVOID_CONSOLIDATE = 0;
1976
1977
                    Entity.MARKUP_INFO.AddObject(info);
1978
                    Entity.SaveChanges();
1979
1980
1981
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
1982
                    {
1983
                        ID = shortGuid(),
1984
                        CREATE_DATE = DateTime.Now,
1985
                        MARKUP_INFO = info,
1986
                    };
1987
                    Entity.SaveChanges();
1988
1989
                    foreach (var item in instanceDataSet)
1990
                    {
1991
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
1992
                        {
1993
                            ID = shortGuid(),
1994
                            DATA = item.DATA,
1995
                            DATA_TYPE = item.DATA_TYPE,
1996
                            PAGENUMBER = item.PAGENUMBER,
1997 c8e9b3e4 ljiyeon
                            MARKUP_INFO_VERSION = info2,
1998 53880c83 ljiyeon
                            SYMBOL_ID = item.SYMBOL_ID,
1999 c0977e97 djkim
                            //GROUP_ID = item.GROUP_ID
2000 2ab012e8 djkim
                        });
2001
                    }
2002
                    Entity.SaveChanges();
2003
2004
2005
                }
2006
            }
2007 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2008 2ab012e8 djkim
                return false;
2009
            }
2010
            return true;
2011
        }
2012
2013 49d444ef ljiyeon
2014
        [OperationContract]
2015
        public FinalPDFResult ConsolidateMergedPDF(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems, string ProjectNo, string DocInfoID, string CreateUserID)
2016
        {
2017
            bool consolidate = false;
2018
            try
2019
            {
2020
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
2021 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2022
                using (CIEntities Entity = new CIEntities(sCIConnString))
2023 49d444ef ljiyeon
                {
2024
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
2025
                    if (markupInfo.CONSOLIDATE == 1)
2026
                    {
2027
                        markupInfo.AVOID_CONSOLIDATE = 1;
2028
                    }
2029
2030
                    foreach (MarkupInfoItem item in markupInfoItems)
2031
                    {
2032
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2033
                        {
2034
                            instanceDataSet.Add(d);
2035
                        });
2036
                    }
2037
2038
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2039
                    info.ID = shortGuid();
2040
                    info.CONSOLIDATE = 1;
2041
                    info.CREATE_TIME = DateTime.Now;
2042
                    info.DOCINFO_ID = _doc_id;
2043
                    info.UPDATE_TIME = DateTime.Now;
2044
                    info.USER_ID = _user_id;
2045
                    info.AVOID_CONSOLIDATE = 0;
2046
2047
                    Entity.MARKUP_INFO.AddObject(info);
2048
                    Entity.SaveChanges();
2049
2050
2051
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2052
                    {
2053
                        ID = shortGuid(),
2054
                        CREATE_DATE = DateTime.Now,
2055
                        MARKUP_INFO = info,
2056
                    };
2057
                    Entity.SaveChanges();
2058
2059
                    foreach (var item in instanceDataSet)
2060
                    {
2061
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2062
                        {
2063
                            ID = shortGuid(),
2064
                            DATA = item.DATA,
2065
                            DATA_TYPE = item.DATA_TYPE,
2066
                            PAGENUMBER = item.PAGENUMBER,
2067
                            MARKUP_INFO_VERSION = info2,
2068 53880c83 ljiyeon
                            SYMBOL_ID = item.SYMBOL_ID,
2069 c0977e97 djkim
                            //GROUP_ID = item.GROUP_ID
2070 49d444ef ljiyeon
                        });
2071
                    }
2072
                    Entity.SaveChanges();
2073
2074
2075
                }
2076
                consolidate = true;
2077
            }
2078 24c5e56c taeseongkim
            catch (Exception ex)
2079 49d444ef ljiyeon
            {
2080 24c5e56c taeseongkim
                System.Diagnostics.Debug.WriteLine(ex);
2081 49d444ef ljiyeon
                consolidate = false;
2082
            }
2083 24c5e56c taeseongkim
2084 49d444ef ljiyeon
            FinalPDFResult _result = new FinalPDFResult();
2085
            if (consolidate == true)
2086
            {
2087
                RemFinalPDFObject remObj = null;
2088
                try
2089
                {
2090
                    string _finalID = shortGuid();
2091
                    int _DocTotalPages = -1;
2092
                    string docItemId;
2093
2094 ff01c725 humkyung
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2095
                    using (CIEntities _ci = new CIEntities(sCIConnString))
2096 49d444ef ljiyeon
                    {
2097
                        var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
2098
2099
                        if (_doc.Count() > 0)
2100
                        {
2101
                            _DocTotalPages = _doc.First().PAGE_COUNT;
2102
                            docItemId = _doc.First().DOCUMENT_ID;
2103
                        }
2104
                        else
2105
                        {
2106
                            _result.Status = FinalStatus.Error;
2107
                            _result.Exception = "페이지 정보를 가져올 수 없습니다.";
2108
                            return _result;
2109
                        }
2110
                    }
2111
2112
                    var Items = GetMarkupInfoItems(ProjectNo, DocInfoID);
2113
                    if (_DocTotalPages > 0)
2114
                    {
2115
                        var item2 = Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
2116
                        FINAL_PDF fm = new FINAL_PDF()
2117
                        {
2118
                            ID = _finalID,
2119
                            PROJECT_NO = ProjectNo,
2120
                            DOCINFO_ID = DocInfoID,
2121
                            DOCUMENT_ID = docItemId,
2122
                            MARKUPINFO_ID = item2.MarkupInfoID,
2123
                            CREATE_USER_ID = CreateUserID,
2124
                            TOTAL_PAGE = _DocTotalPages,
2125
                            CREATE_DATETIME = DateTime.Now,
2126
                            STATUS = (int)IFinalPDF.FinalStatus.Insert
2127
                        };
2128 ff01c725 humkyung
2129
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2130
                        using (KCOMEntities _entity = new KCOMEntities(sConnString))
2131 49d444ef ljiyeon
                        {
2132
                            _entity.AddToFINAL_PDF(fm);
2133
                            _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
2134
                        };
2135
2136
                        System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
2137
                        if (_ch == null)
2138
                        {
2139
                            chan = new TcpChannel();
2140
                            _ChanID = chan.ChannelName;
2141
                            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
2142
                            // Create an instance of the remote object
2143
2144 ff01c725 humkyung
                            using (KCOMEntities ec = new KCOMEntities(sConnString))
2145 49d444ef ljiyeon
                            {
2146
2147
                                //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2148
                                //                          "tcp://localhost:9092/remFinalPDF");
2149
                                remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2150
                                                          //"tcp://192.168.0.67:9092/remFinalPDF");
2151
                                                          "tcp://192.168.0.67:9092/remFinalPDF");
2152
                            }
2153
2154
                            //"tcp://localhost:8080/remFinalPDF");
2155
2156
                            _result = remObj.SetFinalPDF(ProjectNo, _finalID);
2157
                            _result.FinalID = _finalID;
2158
                            _result.Status = FinalStatus.Success;
2159
2160
                            //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
2161
                            //fa.MakeFinalPDF(fm);
2162
                        }
2163
                        else
2164
                        {
2165
                            _ChanID = _ch.ChannelName;
2166
                        }
2167
                    }
2168
                }
2169
                catch (Exception ex)
2170
                {
2171
                    _result.Status = FinalStatus.Error;
2172
2173
                    if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
2174
                        _result.Exception = "Final Server Not Connection";
2175
                }
2176
                finally
2177
                {
2178
                    remObj = null;
2179
                    if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
2180
                        System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
2181
2182
                    GC.Collect(2);
2183
                }
2184
            }
2185
            return _result;
2186
        }
2187 2ab012e8 djkim
        [OperationContract]
2188 04a7385a djkim
        public bool TeamConsolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
2189
        {
2190
            try
2191
            {
2192
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
2193 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2194
                using (CIEntities Entity = new CIEntities(sCIConnString))
2195 04a7385a djkim
                {
2196 285635d3 taeseongkim
                    var members = GetMemberQuery(Entity, _user_id);
2197
2198
                    string user_dept = "";
2199
2200
                    if(members.Count() > 0)
2201
                    {
2202
                        user_dept = members.First().DEPARTMENT;
2203
                    }
2204
                    
2205
                    var markupInfos = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.PART_CONSOLIDATE == 1)
2206
                                        .OrderByDescending(j => j.CREATE_TIME).ToList();
2207
2208 0c624340 djkim
                    foreach (var markupinfo in markupInfos)
2209 04a7385a djkim
                    {
2210 285635d3 taeseongkim
                        string markupdept = "";
2211
2212
                        var markupMembers = GetMemberQuery(Entity, markupinfo.USER_ID);
2213
2214
                        if (markupMembers.Count() > 0)
2215
                        {
2216
                            markupdept = markupMembers.First().DEPARTMENT;
2217
                        }
2218
2219 0c624340 djkim
                        if (user_dept == markupdept)
2220
                        {
2221
                            markupinfo.AVOID_CONSOLIDATE = 1;
2222
                        }
2223 04a7385a djkim
                    }
2224
2225
                    foreach (MarkupInfoItem item in markupInfoItems)
2226
                    {
2227
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2228
                        {
2229
                            instanceDataSet.Add(d);
2230
                        });
2231
                    }
2232
2233
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2234
                    info.ID = shortGuid();
2235
                    info.PART_CONSOLIDATE = 1;
2236
                    info.CREATE_TIME = DateTime.Now;
2237
                    info.DOCINFO_ID = _doc_id;
2238
                    info.UPDATE_TIME = DateTime.Now;
2239
                    info.USER_ID = _user_id;
2240
                    info.AVOID_CONSOLIDATE = 0;
2241
2242
                    Entity.MARKUP_INFO.AddObject(info);
2243
                    Entity.SaveChanges();
2244
2245
2246
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2247
                    {
2248
                        ID = shortGuid(),
2249
                        CREATE_DATE = DateTime.Now,
2250
                        MARKUP_INFO = info,
2251
                    };
2252
                    Entity.SaveChanges();
2253
2254
                    foreach (var item in instanceDataSet)
2255
                    {
2256
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2257
                        {
2258
                            ID = shortGuid(),
2259
                            DATA = item.DATA,
2260
                            DATA_TYPE = item.DATA_TYPE,
2261
                            PAGENUMBER = item.PAGENUMBER,
2262 c8e9b3e4 ljiyeon
                            MARKUP_INFO_VERSION = info2,
2263 53880c83 ljiyeon
                            SYMBOL_ID = item.SYMBOL_ID,
2264 c0977e97 djkim
                            //GROUP_ID = item.GROUP_ID
2265 04a7385a djkim
                        });
2266
                    }
2267
                    Entity.SaveChanges();
2268
2269
2270
                }
2271
            }
2272 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2273 04a7385a djkim
                return false;
2274
            }
2275
            return true;
2276
        }
2277
2278
        [OperationContract]
2279 2ab012e8 djkim
        [ServiceKnownType(typeof(MEMBER))]
2280
        public MEMBER GetMember(string project_no, string user_id)
2281
        {
2282 503cb09e taeseongkim
            MEMBER rstmember = null;
2283 2ab012e8 djkim
            try
2284
            {
2285 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2286
                using (CIEntities Entity = new CIEntities(sCIConnString))
2287 2ab012e8 djkim
                {
2288 285635d3 taeseongkim
                    var members = GetMemberQuery(Entity, user_id);
2289 503cb09e taeseongkim
2290 285635d3 taeseongkim
                    if(members.Count() > 0)
2291
                    {
2292
                        rstmember = members.First();
2293
                    }
2294
                }
2295
            }
2296
            catch (Exception ex)
2297
            {
2298
                return null;
2299
            }
2300
            return rstmember;
2301
        }
2302 503cb09e taeseongkim
2303 285635d3 taeseongkim
        private  List<MEMBER> GetMemberQuery(System.Data.Objects.ObjectContext context, string UserID)
2304
        {
2305
            List<MEMBER> result = new List<MEMBER>();
2306 503cb09e taeseongkim
2307 285635d3 taeseongkim
            try
2308
            {
2309
                string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
2310
2311
                var param = new[] { new System.Data.Objects.ObjectParameter("userId", UserID) };
2312
2313
                System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery
2314
                              = context.CreateQuery<System.Data.Common.DbDataRecord>(query, param);
2315
2316
                if (memberQuery.Count() > 0)
2317
                {
2318
                    foreach (var dataRecord in memberQuery)
2319 503cb09e taeseongkim
                    {
2320 285635d3 taeseongkim
                        MEMBER member = new MEMBER();
2321
2322
                        string userName = dataRecord["NAME"]?.ToString().Trim();
2323
                        string ID = dataRecord["ID"]?.ToString().Trim();
2324
                        string depatment = dataRecord["DEPARTMENT"]?.ToString().Trim();
2325 a7372e37 taeseongkim
2326 285635d3 taeseongkim
                        member.NAME = userName;
2327
                        member.ID = ID;
2328
                        member.DEPARTMENT = depatment;
2329 503cb09e taeseongkim
2330 285635d3 taeseongkim
                        result.Add(member);
2331 503cb09e taeseongkim
                    }
2332 2ab012e8 djkim
                }
2333
            }
2334 ff01c725 humkyung
            catch (Exception ex)
2335 2ab012e8 djkim
            {
2336 285635d3 taeseongkim
                throw new Exception("GetMember(System.Data.Objects.ObjectContext context, string UserID) " , ex);
2337 2ab012e8 djkim
            }
2338 285635d3 taeseongkim
2339
            return result;
2340 2ab012e8 djkim
        }
2341
2342 ff01c725 humkyung
        [WebMethod]
2343 2ab012e8 djkim
        [OperationContract]
2344
        public List<SYMBOL_PRIVATE> GetSymbolList(string user_id)
2345
        {
2346
            List<SYMBOL_PRIVATE> Custom_List = new List<SYMBOL_PRIVATE>();
2347
            try
2348
            {
2349 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2350
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2351 2ab012e8 djkim
                {
2352
                    Custom_List = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == user_id).ToList();
2353
                }
2354
            }
2355 ff01c725 humkyung
            catch (Exception ex)
2356 2ab012e8 djkim
            {
2357
                return null;
2358
            }
2359
            return Custom_List;
2360
        }
2361
        [OperationContract]
2362
        public List<string> GetPublicSymbolDeptList()
2363
        {
2364
            List<string> Custom_List = new List<string>();
2365
            try
2366
            {
2367 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2368
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2369 2ab012e8 djkim
                {
2370 b3251eea ljiyeon
                    Custom_List = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).Distinct().ToList();
2371 2ab012e8 djkim
                }
2372
            }
2373 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2374 2ab012e8 djkim
                return null;
2375
            }
2376
            return Custom_List;
2377
        }
2378
        [OperationContract]
2379
        public List<SYMBOL_PUBLIC> GetPublicSymbolList(string dept)
2380
        {
2381
            List<SYMBOL_PUBLIC> Custom_List = new List<SYMBOL_PUBLIC>();
2382
            try
2383
            {
2384 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2385
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2386 2ab012e8 djkim
                {
2387
                    if(!string.IsNullOrEmpty(dept))
2388
                    {
2389
                        Custom_List = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == dept).ToList();
2390
                    }
2391
                    else
2392
                    {
2393
                        Custom_List = Entity.SYMBOL_PUBLIC.ToList();
2394
                    }
2395
                    
2396
                }
2397
            }
2398 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2399 2ab012e8 djkim
                return null;
2400
            }
2401
            return Custom_List;
2402
        }
2403
2404
        /// <summary>
2405
        /// 
2406
        /// </summary>
2407
        /// <param name="id">symbol id</param>
2408
        /// <param name="type"> 0 : PRIVATE, 1 : PUBLIC</param>
2409
        /// <returns></returns>
2410
        [OperationContract]
2411
        public string GetSymbolData(string id, int type)
2412
        {
2413
            string result;
2414
            try
2415
            {
2416 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2417
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2418 2ab012e8 djkim
                {
2419
                    if(type == 0)
2420
                    {
2421
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA;
2422
                    }
2423
                    else
2424
                    {
2425
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA;
2426
                    }
2427
                }
2428
            }
2429 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2430 2ab012e8 djkim
                return null;
2431
            }
2432
            return result;
2433
        }
2434 53880c83 ljiyeon
        [OperationContract]
2435
        public string GetSymbolImageURL(string id, int type)
2436
        {
2437
            string result;
2438
            try
2439
            {
2440 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2441
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2442 53880c83 ljiyeon
                {
2443
                    if (type == 0)
2444
                    {
2445
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2446
                    }
2447
                    else
2448
                    {
2449
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2450
                    }
2451
                }
2452
            }
2453 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2454 53880c83 ljiyeon
                return null;
2455
            }
2456
            return result;
2457
        }
2458 cf1cc862 taeseongkim
2459 2ab012e8 djkim
        [OperationContract]
2460
        public string GetSignData(string project_no, string user_id)
2461
        {
2462
            string result = null;
2463
            try
2464
            {
2465 dfb95d0f djkim
                string ifsign = getEnsembleSign(user_id);
2466
                if (string.IsNullOrEmpty(ifsign))
2467 2ab012e8 djkim
                {
2468 ff01c725 humkyung
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2469
                    var ModelWFConnectionString = sCIConnString;
2470 dfb95d0f djkim
                    if (null != ModelWFConnectionString)
2471 2ab012e8 djkim
                    {
2472 dfb95d0f djkim
                        using (CIEntities entity = new CIEntities(ModelWFConnectionString))
2473 2ab012e8 djkim
                        {
2474 dfb95d0f djkim
                            var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2475
                            if (_sign.Count() > 0)
2476
                            {
2477
                                result = _sign.First().SIGN_STR;
2478
                            }
2479
                            else
2480
                            {
2481
                                return null;
2482
                            }
2483 2ab012e8 djkim
                        }
2484
                    }
2485
                }
2486 dfb95d0f djkim
                else
2487
                {
2488
                    result = ifsign;
2489
                }
2490
2491 2ab012e8 djkim
            }
2492 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2493 2ab012e8 djkim
                return null;
2494
            }
2495
            return result;
2496
        }
2497
2498 cf1cc862 taeseongkim
        [OperationContract]
2499 74abcf6f taeseongkim
        public string GetSignStrokes(string project_no, string user_id)
2500
        {
2501
            string result = null;
2502
            try
2503
            {
2504
                string ifsign = getEnsembleSign(user_id);
2505
                if (string.IsNullOrEmpty(ifsign))
2506
                {
2507
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2508
                    var ModelWFConnectionString = sCIConnString;
2509
                    if (null != ModelWFConnectionString)
2510
                    {
2511
                        using (CIEntities entity = new CIEntities(ModelWFConnectionString))
2512
                        {
2513
                            var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2514
                            if (_sign.Count() > 0)
2515
                            {
2516
                                result = _sign.First().SIGN_STROKES;
2517
                            }
2518
                            else
2519
                            {
2520
                                return null;
2521
                            }
2522
                        }
2523
                    }
2524
                }
2525
                else
2526
                {
2527
                    result = ifsign;
2528
                }
2529
2530
            }
2531
            catch (Exception ex)
2532
            {
2533
                System.Diagnostics.Debug.WriteLine(ex);
2534
                return null;
2535
            }
2536
            return result;
2537
        }
2538
2539
        [OperationContract]
2540
        public int SetSignData(string user_id,string SignStr,int CropX,int CropY,int CropWidth,int CropHeight)
2541 cf1cc862 taeseongkim
        {
2542
            int result = -1;
2543
2544
            try
2545
            {
2546
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2547
                   
2548
                using (CIEntities entity = new CIEntities(sCIConnString))
2549
                {
2550
                    var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2551
2552 74abcf6f taeseongkim
                    var cropImg = Convert.ToBase64String(SignatureCrop(SignStr, CropX, CropY, CropWidth, CropHeight));
2553
2554 cf1cc862 taeseongkim
                    if (_sign.Count() > 0)
2555
                    {
2556 74abcf6f taeseongkim
                        _sign.First().SIGN_STR = cropImg;
2557 cf1cc862 taeseongkim
                        _sign.First().MODIFY_DATE = DateTime.Now;
2558
                    }
2559
                    else
2560
                    {
2561
                        entity.SIGN_INFO.AddObject(new SIGN_INFO
2562
                        {
2563
                            ID = shortGuid(),
2564
                            MEMBER_USER_ID = user_id,
2565
                            CREATE_DATE = DateTime.Now,
2566 74abcf6f taeseongkim
                            SIGN_STR = cropImg
2567 cf1cc862 taeseongkim
                        });
2568
                    }
2569
2570
                    result = entity.SaveChanges();
2571
                }
2572
            }
2573
            catch (Exception ex)
2574
            {
2575
                System.Diagnostics.Debug.WriteLine(ex);
2576
            }
2577
            return result;
2578
        }
2579
2580 74abcf6f taeseongkim
2581
        [OperationContract]
2582
        public int SetSignStrokes(string user_id, string strokesData)
2583
        {
2584
            int result = -1;
2585
2586
            try
2587
            {
2588
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2589
2590
                using (CIEntities entity = new CIEntities(sCIConnString))
2591
                {
2592
                    var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2593
2594
                    if (_sign.Count() > 0)
2595
                    {
2596
                        _sign.First().SIGN_STROKES = strokesData;
2597
                        _sign.First().MODIFY_DATE = DateTime.Now;
2598
                    }
2599
                    else
2600
                    {
2601
                        entity.SIGN_INFO.AddObject(new SIGN_INFO
2602
                        {
2603
                            ID = shortGuid(),
2604
                            MEMBER_USER_ID = user_id,
2605
                            CREATE_DATE = DateTime.Now,
2606
                            SIGN_STROKES = strokesData
2607
                    });
2608
                    }
2609
2610
                    result = entity.SaveChanges();
2611
                }
2612
            }
2613
            catch (Exception ex)
2614
            {
2615
                System.Diagnostics.Debug.WriteLine(ex);
2616
            }
2617
            return result;
2618
        }
2619
2620
        private byte[] SignatureCrop(string imgStr,int X,int Y,int Width,int Height)
2621
        {
2622
            using (System.IO.MemoryStream readStream = new System.IO.MemoryStream(Convert.FromBase64String(imgStr)))
2623
            {
2624
                using (System.Drawing.Image OriginalImage = System.Drawing.Image.FromStream(readStream))
2625
                {
2626
                    using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Width, Height))
2627
                    {
2628
                        bmp.SetResolution(OriginalImage.HorizontalResolution, OriginalImage.VerticalResolution);
2629
                        using (System.Drawing.Graphics Graphic = System.Drawing.Graphics.FromImage(bmp))
2630
                        {
2631
                            Graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
2632
                            Graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
2633
                            Graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
2634
                            Graphic.DrawImage(OriginalImage, new System.Drawing.Rectangle(0, 0, Width, Height), X, Y, Width, Height, System.Drawing.GraphicsUnit.Pixel);
2635
                            System.IO.MemoryStream ms = new System.IO.MemoryStream();
2636
                            bmp.Save(ms, OriginalImage.RawFormat);
2637
                            return ms.GetBuffer();
2638
                        }
2639
                    }
2640
                }
2641
            }
2642
        }
2643
2644 2ab012e8 djkim
        [OperationContract]        
2645
        public string GetProjectName(string project_no)
2646
        {
2647
            string result = null;
2648
2649
            try
2650
            {
2651 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2652
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
2653 2ab012e8 djkim
                {
2654
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
2655
                }
2656
            }
2657 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2658 2ab012e8 djkim
                return null;
2659
            }
2660
            return result;
2661
        }
2662
2663
        [OperationContract]
2664
        public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev)
2665
        {
2666
            List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>();
2667
            
2668
            try
2669
            {
2670 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2671
                using (CIEntities Entity = new CIEntities(sCIConnString))
2672 2ab012e8 djkim
                {
2673
                    result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no
2674
                    && i.DOCUMENT_NO == doc_no
2675
                    && i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList();
2676
                }
2677
            }
2678 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2679 2ab012e8 djkim
                return null;
2680
            }
2681
            return result;
2682
        }
2683
2684
        [OperationContract]
2685
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
2686
        {
2687
            DOCINFO docinfo = null;
2688
2689
            try
2690
            {
2691 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2692
                using (CIEntities Entity = new CIEntities(sCIConnString))
2693 2ab012e8 djkim
                {
2694
                    docinfo = (from info in Entity.DOCINFO
2695
                              where info.DOCUMENT_ID == doc_id
2696
                              && info.PROJECT_NO == project_no
2697
                              select info).First();
2698
                }
2699
            }
2700 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2701 2ab012e8 djkim
                return null;
2702
            }
2703
            return docinfo;
2704
        }
2705
2706
        [OperationContract]
2707
        public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList)
2708
        {
2709
            MarkupInfoItem _result = null;
2710
            List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>();
2711
            try
2712
            {
2713 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2714
                using (CIEntities Entity = new CIEntities(sCIConnString))
2715 2ab012e8 djkim
                {
2716
                    var docitem = (from info in Entity.DOCINFO
2717
                               where info.DOCUMENT_ID == doc_id
2718
                               && info.PROJECT_NO == project_no
2719
                               select info).First();
2720
2721
                    foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO)
2722
                    {
2723 285635d3 taeseongkim
                        var members = GetMemberQuery(Entity, markinfo.USER_ID);
2724
2725
                        MEMBER member = new MEMBER();
2726
2727
                        if (members.Count() > 0)
2728
                        {
2729
                            member = members.First();
2730
                        }
2731
2732 2ab012e8 djkim
                        string displaycolor = null;
2733 285635d3 taeseongkim
2734 2ab012e8 djkim
                        try
2735
                        {
2736
                            displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor;
2737
                        }
2738 0585d5cc taeseongkim
                        catch (Exception ex)
2739 2ab012e8 djkim
                        {
2740 0585d5cc taeseongkim
                            System.Diagnostics.Debug.WriteLine("KCOM_API - GetPrintDocItemList displaycolor : " + ex.ToString());
2741
2742 2ab012e8 djkim
                            displaycolor = "#FFFFFF";
2743
                        }
2744
                        
2745
                        _result = new MarkupInfoItem
2746
                        {
2747
                            MarkupInfoID = markinfo.ID,
2748
                            Consolidate = markinfo.CONSOLIDATE,
2749
                            CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME,
2750
                            DisplayColor = displaycolor,
2751
                            UserID = markinfo.USER_ID,
2752
                            UserName = member.NAME,
2753
                            Depatment = member.DEPARTMENT,
2754
                        };
2755
2756
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
2757
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
2758
2759
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
2760
                        {
2761
                            MarkupItem markitem = new MarkupItem()
2762
                            {
2763
                                ID = markdata.ID,
2764
                                PageNumber = markdata.PAGENUMBER,
2765
                            };
2766
                            _result.MarkupList.Add(markitem);
2767
                        }
2768
2769
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
2770
2771
                        markupinfo.Add(_result);
2772
                    }
2773
                }
2774
            }
2775 285635d3 taeseongkim
            catch (Exception ex)
2776 2ab012e8 djkim
            {
2777
                return null;
2778
            }
2779
            return markupinfo;
2780
        }
2781 04a7385a djkim
2782
        [OperationContract]
2783
        public bool AddMessage(string project_no, TALK value)
2784
        {
2785
            try
2786
            {
2787 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2788
                using (CIEntities entity = new CIEntities(sCIConnString))
2789 04a7385a djkim
                {                    
2790
                    entity.TALK.AddObject(value);
2791
                    entity.SaveChanges();
2792
                }
2793
            }
2794 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2795 04a7385a djkim
                return false;
2796
            }
2797
            return true;
2798
        }
2799
2800
        [OperationContract]
2801
        public List<TALK> GetMessage(string project_no, string doc_id)
2802
        {
2803
            List<TALK> result = new List<TALK>();
2804
            try
2805
            {
2806 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2807
                using (CIEntities entity = new CIEntities(sCIConnString))
2808 04a7385a djkim
                {
2809
                    result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList();                        
2810
                }
2811
            }
2812 ff01c725 humkyung
            catch (Exception ex)
2813 04a7385a djkim
            {
2814
                return result;
2815
            }
2816
            return result;
2817
        }
2818 dfb95d0f djkim
2819
2820
        #region Legacy System I/F
2821
        /// <summary>
2822
        /// Ensemble+ Sign Data Return
2823
        /// </summary>
2824
        /// <param name="user_id"></param>
2825
        /// <returns></returns>
2826
        private string getEnsembleSign(string user_id)
2827
        {
2828 ac4f1e13 taeseongkim
            string result = null;
2829 dfb95d0f djkim
            string soapurl = string.Empty;
2830 ac4f1e13 taeseongkim
2831 dfb95d0f djkim
            try
2832
            {
2833 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2834
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2835 dfb95d0f djkim
                {
2836
                    var item = Entity.PROPERTIES.Where(d => d.TYPE == "UpLoadServiceUrl").FirstOrDefault();
2837 ac4f1e13 taeseongkim
2838
                    if (item != null)
2839
                    {
2840
                        soapurl = item.VALUE;
2841
2842
                        WebClient webClient = new WebClient();
2843
                        string data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ens=\"http://EnsemblePlus.Webservice\"> <soapenv:Header/> <soapenv:Body> <ens:checkoutSignImage>"
2844
                            + "<ens:sUserNo>" + user_id + "</ens:sUserNo>"
2845
                            + "</ens:checkoutSignImage> </soapenv:Body></soapenv:Envelope>";
2846
                        webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
2847
                        webClient.Headers.Add("SOAPAction", "http://EnsemblePlus.Webservice");
2848
                        var _result = webClient.UploadString(new Uri(soapurl), data);
2849
                        XmlDocument xmlDoc = new XmlDocument();
2850
                        xmlDoc.LoadXml(_result);
2851
                        XmlNodeList list = xmlDoc.GetElementsByTagName("checkoutSignImageResponse");
2852
2853
                        foreach (XmlNode xn in list)
2854
                        {
2855
                            result = xn["checkoutSignImageReturn"].InnerText;
2856
                        }
2857
2858
                        if (result.Contains("No business object"))
2859
                        {
2860
                            result = null;
2861
                        }
2862
                    }
2863
                    else
2864
                    {
2865
                        result = null;
2866
                    }
2867 dfb95d0f djkim
                }
2868 ac4f1e13 taeseongkim
             
2869 dfb95d0f djkim
            }
2870
            catch (Exception ex)
2871 ac4f1e13 taeseongkim
            {   
2872
                result = null;
2873 dfb95d0f djkim
            }
2874
2875 ac4f1e13 taeseongkim
            return result;
2876 dfb95d0f djkim
        }
2877
        #endregion
2878 6c9fec59 djkim
2879
        #region Final Service
2880
        [OperationContract]
2881
        [ServiceKnownType(typeof(DOCINFO))]                
2882
        public DOCINFO FinalPDF_GetDocinfo(string project_no, string docinfo_id)
2883
        {
2884
            DOCINFO docinfo = null;
2885
2886
            try
2887
            {
2888 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2889
                using (CIEntities _entity = new CIEntities(sCIConnString))
2890 6c9fec59 djkim
                {
2891
                    var doc = _entity.DOCINFO.Where(x => x.ID == docinfo_id).FirstOrDefault();
2892
                    if(doc != null)
2893
                    {
2894
                        docinfo = new DOCINFO()
2895
                        {
2896
                            ID = doc.ID,
2897
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2898
                            PAGE_COUNT = doc.PAGE_COUNT,
2899
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2900
                            PROJECT_NO = doc.PROJECT_NO
2901
                        };
2902
                    }                    
2903
                }
2904
            }
2905 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2906 6c9fec59 djkim
                throw;
2907
            }
2908
            return docinfo;
2909
        }
2910
        [OperationContract]
2911
        [ServiceKnownType(typeof(DOCUMENT_ITEM))]
2912
        public DOCUMENT_ITEM FinalPDF_GetDocumentItem(string project_no, string document_id)
2913
        {
2914
            DOCUMENT_ITEM item = null;
2915
2916
            try
2917
            {
2918 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2919
                using (CIEntities _entity = new CIEntities(sCIConnString))
2920 6c9fec59 djkim
                {
2921 0585d5cc taeseongkim
                    var doc = _entity.DOCUMENT_ITEM.Where(x => x.PROJECT_NO == project_no &&  x.DOCUMENT_ID == document_id).FirstOrDefault();
2922 6c9fec59 djkim
                    if(doc != null)
2923
                    {
2924
                        item = new DOCUMENT_ITEM()
2925
                        {
2926
                            ID = doc.ID,
2927
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2928
                            PROJECT_NO = doc.PROJECT_NO,
2929
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2930
                            DOCUMENT_NO = doc.DOCUMENT_NO,
2931
                            DOCUMENT_NAME = doc.DOCUMENT_NAME,
2932 ab5aa762 taeseongkim
                            //ENSEMBLEINFO_URL = doc.ENSEMBLEINFO_URL,
2933 6c9fec59 djkim
                            GROUP_NO = doc.GROUP_NO,
2934
                            RESULT = doc.RESULT,
2935
                            REVISION = doc.REVISION,
2936
                            RESULT_FILE = doc.RESULT_FILE
2937
                        };
2938
                    }
2939
                    
2940
                }
2941
            }
2942 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2943 6c9fec59 djkim
                throw;
2944
            }
2945
            return item;
2946
        }
2947
        [OperationContract]
2948
        [ServiceKnownType(typeof(MARKUP_DATA))]
2949
        public List<MARKUP_DATA> FinalPDF_GetMarkupdata(string project_no, string docinfo_id)
2950
        {
2951
            List<MARKUP_DATA> results = new List<MARKUP_DATA>();
2952
2953
            try
2954
            {
2955 c0977e97 djkim
                //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2956 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2957
                using (CIEntities _entity = new CIEntities(sCIConnString))
2958 6c9fec59 djkim
                {
2959
                    var datas = _entity.MARKUP_DATA.Where(x => x.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO_ID == docinfo_id
2960
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1
2961
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.AVOID_CONSOLIDATE == 0
2962
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.PART_CONSOLIDATE == 0).ToList();
2963
                    foreach (var data in datas)
2964
                    {
2965
                        MARKUP_DATA d = new MARKUP_DATA()
2966
                        {
2967
                            ID = data.ID,
2968 c0977e97 djkim
                            //GROUP_ID = data.GROUP_ID,
2969 6c9fec59 djkim
                            SYMBOL_ID = data.SYMBOL_ID,
2970
                            DATA = data.DATA,
2971 abaa85b4 djkim
                            DATA_TYPE = data.DATA_TYPE,
2972
                            MARKUPINFO_VERSION_ID = data.MARKUPINFO_VERSION_ID,
2973
                            PAGENUMBER = data.PAGENUMBER
2974 6c9fec59 djkim
                        };
2975
                        results.Add(d);
2976
                    }
2977
                }
2978
            }
2979 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2980 6c9fec59 djkim
                throw;
2981
            }
2982
            return results;
2983
        }
2984
        [OperationContract]
2985
        [ServiceKnownType(typeof(MARKUP_INFO))]
2986
        public MARKUP_INFO FinalPDF_GetMarkupinfo(string project_no, string docinfo_id)
2987
        {
2988
            MARKUP_INFO markupInfo = null;
2989
2990
            try
2991
            {
2992 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2993
                using (CIEntities _entity = new CIEntities(sCIConnString))
2994 6c9fec59 djkim
                {
2995
                    var tmp = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo_id && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0).FirstOrDefault();
2996
                    if (tmp != null)
2997
                    {
2998
                        markupInfo = new MARKUP_INFO()
2999
                        {
3000
                            ID = tmp.ID,
3001
                            DOCINFO_ID = tmp.DOCINFO_ID,
3002
                            USER_ID = tmp.USER_ID
3003
                        };
3004
                    }                    
3005
                }
3006
            }
3007 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3008 6c9fec59 djkim
                throw;
3009
            }
3010
            return markupInfo;
3011
        }
3012
        [OperationContract]
3013 abaa85b4 djkim
        [ServiceKnownType(typeof(FINAL_PDF))]
3014
        public List<FINAL_PDF> FinalPDF_GetFinalPDFs(string final_id)
3015
        {
3016
            List<FINAL_PDF> results = new List<FINAL_PDF>();
3017
3018
            try
3019
            {
3020 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3021
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3022 abaa85b4 djkim
                {
3023
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == final_id).ToList();
3024
                    foreach(var final in finalList)
3025
                    {
3026
                        FINAL_PDF pdf = new FINAL_PDF()
3027
                        {
3028
                            ID = final.ID,
3029
                            DOCINFO_ID = final.DOCINFO_ID,
3030
                            DOCUMENT_ID = final.DOCUMENT_ID,
3031
                            STATUS = final.STATUS,
3032
                            CURRENT_PAGE = final.CURRENT_PAGE,
3033
                            CREATE_DATETIME = final.CREATE_DATETIME,
3034
                            START_DATETIME = final.START_DATETIME,
3035
                            END_DATETIME = final.END_DATETIME,
3036
                            EXCEPTION = final.EXCEPTION,
3037
                            PROJECT_NO = final.PROJECT_NO,
3038
                            TOTAL_PAGE = final.TOTAL_PAGE,
3039
                            MARKUPINFO_ID = final.MARKUPINFO_ID,
3040
                            CREATE_USER_ID = final.CREATE_USER_ID
3041
                        };
3042
                        results.Add(pdf);
3043
                    }
3044
                }
3045
            }
3046 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3047 abaa85b4 djkim
                throw;
3048
            }
3049
            return results;
3050
        }
3051
        [OperationContract]
3052 6c9fec59 djkim
        [ServiceKnownType(typeof(DOCPAGE))]
3053
        public List<DOCPAGE> FinalPDF_GetDocpage(string project_no, string docinfo_id)
3054
        {
3055
            List<DOCPAGE> results = new List<DOCPAGE>();
3056
3057
            try
3058
            {
3059 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3060
                using (CIEntities _entity = new CIEntities(sCIConnString))
3061 6c9fec59 djkim
                {
3062
                    var pages = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == docinfo_id).OrderBy(x => x.PAGE_NUMBER).ToList();
3063
                    foreach(var page in pages)
3064
                    {
3065
                        DOCPAGE p = new DOCPAGE()
3066
                        {
3067
                            PAGE_ANGLE = page.PAGE_ANGLE,
3068
                            PAGE_NUMBER = page.PAGE_NUMBER,
3069
                            PAGE_HEIGHT = page.PAGE_HEIGHT,
3070
                            PAGE_WIDTH = page.PAGE_WIDTH,
3071
                            DOCINFO_ID = page.DOCINFO_ID                            
3072
                        };
3073
                        results.Add(p);
3074
                    }                    
3075
                }
3076
            }
3077 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3078 6c9fec59 djkim
                throw;
3079
            }
3080
            return results;
3081
        }
3082 abaa85b4 djkim
        [OperationContract]        
3083
        public bool FinalPDF_SetFinalPDFStatus(string final_id, FinalStatus status)
3084
        {
3085
            bool result = false;
3086
3087
            try
3088
            {
3089 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3090
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3091 abaa85b4 djkim
                {
3092
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
3093
                    if(tmp != null)
3094
                    {
3095
                        switch(status)
3096
                        {
3097
                            case FinalStatus.Create:
3098
                                tmp.START_DATETIME = DateTime.Now;
3099
                                break;
3100
                            case FinalStatus.Success:
3101
                                tmp.END_DATETIME = DateTime.Now;
3102
                                tmp.EXCEPTION = string.Empty;
3103
                                break;                                
3104
                        }
3105
                        tmp.STATUS = (int)status;
3106
                        _entity.SaveChanges();
3107
                        result = true;                        
3108
                    }
3109
                }                    
3110
            }
3111 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3112 abaa85b4 djkim
                throw;
3113
            }
3114
            return result;
3115
        }
3116
3117 3c71b3a5 taeseongkim
        /// <summary>
3118
        /// 현재 진행중인 Final PDF 가 없거나 Success 일 경우에만 true return
3119
        /// </summary>
3120
        /// <param name="DocInfoID"></param>
3121
        /// <param name="MarkupInfoID"></param>
3122
        /// <param name="CreateUserID"></param>
3123
        /// <returns></returns>
3124 abaa85b4 djkim
        [OperationContract]
3125 3b62305d ljiyeon
        public bool FinalPDF_GetFinalPDFStatus(string DocInfoID, string MarkupInfoID, string CreateUserID)
3126
        {
3127
            bool result = false;
3128
3129
            try
3130
            {
3131 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3132
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3133 3b62305d ljiyeon
                {
3134 76688e76 djkim
                    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();
3135 3b62305d ljiyeon
                    if (finalpdf != null)
3136
                    {
3137 3c71b3a5 taeseongkim
                        if (finalpdf.STATUS == (int)FinalStatus.Success)
3138 3b62305d ljiyeon
                        {
3139
                            result = true;
3140
                        }
3141
                    }
3142 3c71b3a5 taeseongkim
                    else
3143
                        result = true;
3144 3b62305d ljiyeon
                }
3145
            }
3146 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3147 3b62305d ljiyeon
                throw;
3148
            }
3149
            return result;
3150
        }
3151
3152
        [OperationContract]
3153 abaa85b4 djkim
        public bool FinalPDF_SetCurrentPage(string final_id, int currentpage)
3154
        {
3155
            bool result = false;
3156
3157
            try
3158
            {
3159 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3160
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3161 abaa85b4 djkim
                {
3162
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
3163
                    if (tmp != null)
3164
                    {
3165
                        tmp.CURRENT_PAGE = currentpage;
3166
                        _entity.SaveChanges();
3167
                        result = true;
3168
                    }
3169
                }
3170
            }
3171 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3172 abaa85b4 djkim
                throw;
3173
            }
3174
            return result;
3175
        }
3176
        [OperationContract]
3177
        public bool FinalPDF_SetError(string final_id, string msg)
3178
        {
3179
            bool result = false;
3180
3181
            try
3182
            {
3183 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3184
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3185 abaa85b4 djkim
                {
3186
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
3187
                    if (tmp != null)
3188
                    {                        
3189
                        tmp.STATUS = (int)FinalStatus.Error;
3190
                        tmp.EXCEPTION = DateTime.Now.ToShortDateString() + " " + msg;                        
3191
                        _entity.SaveChanges();
3192
                        result = true;
3193
                    }
3194
                }
3195
            }
3196 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3197 abaa85b4 djkim
                throw;
3198
            }
3199
            return result;
3200
        }
3201
3202
        [OperationContract]
3203
        public bool FinalPDF_SetFinalResultPath(string project_no, string document_id, string url)
3204
        {
3205
            bool result = false;
3206
3207
            try
3208
            {
3209 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3210
                using (CIEntities _entity = new CIEntities(sCIConnString))
3211 abaa85b4 djkim
                {
3212 0585d5cc taeseongkim
                    var item = _entity.DOCUMENT_ITEM.Where(d =>d.PROJECT_NO == project_no && d.DOCUMENT_ID == document_id).FirstOrDefault();
3213 abaa85b4 djkim
                    if (item != null)
3214
                    {
3215
                        item.RESULT_FILE = url;
3216
                        _entity.SaveChanges();
3217
                        result = true;
3218
                    }
3219
                }
3220
            }
3221 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3222 abaa85b4 djkim
                throw;
3223
            }
3224
            return result;
3225
        }
3226 bae83c92 taeseongkim
3227
        [OperationContract]
3228
        public bool SaveLog(string project_no, string document_id, string Log)
3229
        {
3230
            bool result = false;
3231
3232
            try
3233
            {
3234
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3235
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3236
                {
3237
                    _entity.AddToERROR_LOG(new ERROR_LOG
3238
                    {
3239
                        PROJECT_NO = project_no,
3240
                        DOCUMENT_ID = document_id,
3241
                        CONTENTS = Log,
3242
                        CREATE_DATETIME = DateTime.Now.ToString("yyMMddssmm"),
3243
                        CODE = "",
3244
                        TYPE = "Markus Log",
3245
                        LEVEL = "",
3246
                        SERVICE_NAME = "Markus",
3247
                    });
3248
3249
                    _entity.SaveChanges();
3250
                }
3251
            }
3252
            catch (Exception ex)
3253
            {
3254
            }
3255
3256
            return result;
3257
        }
3258
3259 abaa85b4 djkim
        [OperationContract]
3260
        [ServiceKnownType(typeof(MEMBER))]
3261
        public MEMBER FinalPDF_GetCommentMember(string project_no, string markupdata_id)
3262
        {
3263
            MEMBER member = null;
3264
            try
3265
            {
3266 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3267
                using (CIEntities _entity = new CIEntities(sCIConnString))
3268 abaa85b4 djkim
                {
3269
                    var data = _entity.MARKUP_DATA.Where(x => x.ID == markupdata_id).FirstOrDefault();
3270
                    string user_id = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
3271 285635d3 taeseongkim
3272
                    var person = GetMemberQuery(_entity,user_id);
3273
3274
                    if(person.Count() > 0)
3275 abaa85b4 djkim
                    {
3276 285635d3 taeseongkim
                        member = person.First();
3277 abaa85b4 djkim
                    }
3278
                }
3279
            }
3280 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3281 abaa85b4 djkim
                throw;
3282
            }
3283 285635d3 taeseongkim
3284 abaa85b4 djkim
            return member;
3285
        }
3286
3287
        [OperationContract]
3288
        [ServiceKnownType(typeof(PROPERTIES))]
3289
        public List<PROPERTIES> FinalPDF_GetProperties(string project_no)
3290
        {
3291
            List<PROPERTIES> results = new List<PROPERTIES>();
3292
            try
3293
            {
3294 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3295
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3296 abaa85b4 djkim
                {
3297
                    var _items = _entity.PROPERTIES.Where(x => x.PROPERTY == project_no).ToList();
3298
                    foreach(var item in _items)
3299
                    {
3300
                        PROPERTIES pROPERTIES = new PROPERTIES()
3301
                        {
3302
                            ID = item.ID,
3303
                            PROPERTY = item.PROPERTY,
3304
                            TYPE = item.TYPE,
3305
                            VALUE = item.VALUE
3306
                        };
3307
                        results.Add(pROPERTIES);
3308
                    }
3309
                }
3310
3311
            }
3312 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3313 abaa85b4 djkim
                throw;
3314
            }
3315
            return results;
3316
        }
3317 6c9fec59 djkim
        #endregion
3318 ffddbe4e djkim
    }    
3319 787a4489 KangIngu
}
클립보드 이미지 추가 (최대 크기: 500 MB)