프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ 6a19b48d

이력 | 보기 | 이력해설 | 다운로드 (139 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 6a19b48d taeseongkim
using Newtonsoft.Json.Linq;
21 787a4489 KangIngu
22
namespace KCOM_API
23
{
24
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ServiceDeepView" in code, svc and config file together.
25
    // 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.
26
    [ServiceContract(Namespace = "")]
27
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
28
    public partial class ServiceDeepView : System.Web.Services.WebService
29
    {
30 0585d5cc taeseongkim
        public ServiceDeepView()
31
        {
32 e1c892f7 taeseongkim
            //System.Diagnostics.Debug.WriteLine(OperationContext.Current.RequestContext.RequestMessage.Headers.Action.ToString());
33 0585d5cc taeseongkim
        }
34
35 ffddbe4e djkim
        /// <summary>
36
        /// Client Version 과 Server Version 을 비교하여 Server Version 이 최신이면 다운로드 url 리턴.
37
        /// </summary>
38
        /// <param name="is64BitProcess">64bit = true, 32bit = false</param>
39
        /// <param name="markusVer">client version</param>
40
        /// <returns></returns>
41 264c9309 ljiyeon
        [OperationContract]
42
        public string GetVersionData(bool is64BitProcess, string markusVer)
43
        {
44
            string url = null;
45 d71b4688 ljiyeon
46 264c9309 ljiyeon
            try
47
            {
48 ffddbe4e djkim
                Version client_version = new Version(markusVer);
49
                
50
                //DB에서 version 정보와 다운로드 url 을 Select
51
                PROPERTIES dbvalue = null;
52 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
53
                using (KCOMEntities uc = new KCOMEntities(sConnString))
54 ffddbe4e djkim
                {
55
                    string wherestr = string.Empty;
56
                    if (is64BitProcess)
57 264c9309 ljiyeon
                    {
58 ffddbe4e djkim
                        wherestr = "Update_x64";                        
59 264c9309 ljiyeon
                    }
60
                    else
61
                    {
62 075cbfcf taeseongkim
                        wherestr = "Update_x86";                        
63 ffddbe4e djkim
                    }
64
                    dbvalue = uc.PROPERTIES.Where(data => data.TYPE == wherestr).FirstOrDefault();
65
                }
66
67
                //서버 버전이 최신이면 0보다 큰값 리턴
68
                Version server_version = new Version(dbvalue.PROPERTY);
69
                int result = server_version.CompareTo(client_version);  
70
                if (result > 0)
71
                {
72
                    url = dbvalue.VALUE;
73 264c9309 ljiyeon
                }
74
            }
75 0585d5cc taeseongkim
            catch (Exception ex)
76 264c9309 ljiyeon
            {
77 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetVersionData : " + ex.ToString());
78
79 264c9309 ljiyeon
                url = null;
80
            }
81
            return url;
82
        }
83 ff01c725 humkyung
    
84 787a4489 KangIngu
85
        [OperationContract]
86
        public KCOM_SystemInfo GetSystemData()
87
        {
88
            try
89
            {
90 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
91
                using (KCOMEntities uc = new KCOMEntities(sConnString))
92 787a4489 KangIngu
                {
93
                    var SystemInfoSet = uc.PROPERTIES.Where(data => data.TYPE == "SystemInfo").ToList();
94
95
                    KCOM_SystemInfo sysInfo = new KCOM_SystemInfo();
96
97
                    var url = SystemInfoSet.Where(data => data.PROPERTY == "Url").FirstOrDefault();
98
                    if (url != null)
99
                    {
100
                        sysInfo.HostName = url.VALUE;
101
                    }
102
103 43e1d368 taeseongkim
                    var port = SystemInfoSet.Where(data => data.PROPERTY == "Port").FirstOrDefault();
104
                    if (port != null)
105 787a4489 KangIngu
                    {
106 43e1d368 taeseongkim
                        sysInfo.HostPort = port.VALUE;
107 787a4489 KangIngu
                    }
108 9a1ce1db KangIngu
109 43e1d368 taeseongkim
                    var stamp = uc.PROPERTIES.Where(data => data.TYPE == "STAMP").FirstOrDefault();
110
                    if(stamp != null)
111 9a1ce1db KangIngu
                    {
112 43e1d368 taeseongkim
                        sysInfo.STAMP = stamp.VALUE;
113
114 9a1ce1db KangIngu
                    }
115 43e1d368 taeseongkim
116
                    var stampContents = uc.PROPERTIES.Where(data => data.TYPE == "STAMP_CONTENTS");
117
118
                    if (stampContents?.Count() > 0)
119
                    {
120
                        sysInfo.STAMP_CONTENTS = stampContents.ToDictionary(x => x.PROPERTY, x => x.VALUE);
121
                    }
122
123 787a4489 KangIngu
                    return sysInfo;
124
                }
125
            }
126
            catch (Exception ex)
127
            {
128 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetSystemData : " + ex.ToString());
129
130 787a4489 KangIngu
            }
131
            return null;
132 24c5e56c taeseongkim
            //GC.Collect(2);
133 787a4489 KangIngu
        }
134
135
        private static string shortGuid()
136 e1c892f7 taeseongkim
        { 
137 787a4489 KangIngu
            byte[] bytes = new byte[16];
138
            using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create())
139
            {
140
                provider.GetBytes(bytes);
141
            }
142
143
            var guid = new Guid(bytes);
144
145
            return Convert.ToBase64String(guid.ToByteArray())
146
                .Substring(0, 10)
147
                .Replace("/", "")
148
                .Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x");
149
        }
150
151
152
        [OperationContract]
153 992a98b4 KangIngu
        public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
154
        {
155 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
156
            using (KCOMEntities dc = new KCOMEntities(sConnString))
157 992a98b4 KangIngu
            {
158
159
                int flagString = Convert.ToInt32(FAVORITE_FLAG.Personal);
160
                List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
161
                //dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
162
                //    flagString).ToList().ForEach(data => favoriteListSet.Add(data));
163
164
165
                //dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data));
166
167
                favoriteListSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID && data.DOCUMENT_ID == sharepointItemID).ToList();
168
169
                //favoriteListSet = favoriteListSet.Distinct().ToList();
170
                return favoriteListSet;
171
            }
172
        }
173 0585d5cc taeseongkim
174 992a98b4 KangIngu
        [OperationContract]
175
        public bool EditFavoriteVP(string prjNo, string userID, string docID, int state, string description)
176
        {
177 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
178
            using (KCOMEntities dc = new KCOMEntities(sConnString))
179 992a98b4 KangIngu
            {
180
                //List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
181
                //    && data.PAGE_NO == SavePageNo && data.CREATE_TIME == createTime).ToList();
182
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
183
                    && data.ID == docID).ToList();
184
                try
185
                {
186
187
                    if (favoriteSet.Count > 0)
188
                    {
189
                        var FavoriteVP_Instance = favoriteSet.First();
190
191
                        FavoriteVP_Instance.DESCRIPTION = description;
192
                        FavoriteVP_Instance.FLAG = state;
193
194
                        dc.SaveChanges();
195
196
                        return true;
197
                    }
198
                    else
199
                    {
200
                        return false;
201
                    }
202
                }
203 0585d5cc taeseongkim
                catch (Exception ex)
204 992a98b4 KangIngu
                {
205 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - EditFavoriteVP : " + ex.ToString());
206
207 992a98b4 KangIngu
                    return false;
208
                }
209
            }
210
        }
211
212
        [OperationContract]
213
        public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string docID)
214
        {
215 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
216
            using (KCOMEntities dc = new KCOMEntities(sConnString))
217 992a98b4 KangIngu
            {
218
219
                List<FAVORITE_DOC> favoriteSet = dc.FAVORITE_DOC.Where(data => data.PROJECT_NO == prjNo && data.MEMBER_USER_ID == userID
220
                    && data.ID == docID).ToList();
221
222
                try
223
                {
224
                    if (favoriteSet.Count > 0)
225
                    {
226
                        favoriteSet.ForEach(data => dc.FAVORITE_DOC.DeleteObject(data));
227
                        dc.SaveChanges();
228
                        return true;
229
                    }
230
                    else
231
                    {
232
                        return false;
233
                    }
234
                }
235 0585d5cc taeseongkim
                catch (Exception ex)
236 992a98b4 KangIngu
                {
237 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - DelFavoriteVP : " + ex.ToString());
238
239 992a98b4 KangIngu
                    return false;
240
                }
241
            }
242
        }
243
244 9294fed6 humkyung
        /// <summary>
245
        /// 두 페이지를 비교하여 결과를 리턴한다
246
        /// </summary>
247
        /// <param name="projectNo"></param>
248
        /// <param name="originDocItem_ID"></param>
249
        /// <param name="targetDocItem_ID"></param>
250
        /// <param name="originPageNo"></param>
251
        /// <param name="targetPageNo"></param>
252
        /// <param name="isInternalAddress"></param>
253
        /// <returns></returns>
254 992a98b4 KangIngu
        [OperationContract]
255 d9cf7d6e djkim
        public List<Rect> GetCompareRect(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress)
256 787a4489 KangIngu
        {
257 6b6e937c taeseongkim
            List<Rect> result = new List<Rect>();
258
259 72424099 taeseongkim
            try
260
            {
261
                string originFile = "";
262
                string targetFile = "";
263 a874198d humkyung
264 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);
265
                string sTagetFolder = targetDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(targetDocItem_ID) / 100).ToString() : (targetDocItem_ID.Length >= 5 ? targetDocItem_ID.Substring(0, 5) : targetDocItem_ID);
266 a1142a6b taeseongkim
267 72424099 taeseongkim
                if (Boolean.Parse(isInternalAddress))
268
                {
269
                    originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sOriginFolder, originDocItem_ID, originPageNo);
270
                    targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sTagetFolder, targetDocItem_ID, targetPageNo);
271
                }
272
                else
273
                {
274
                    originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo);
275
                    targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo);
276
                }
277 787a4489 KangIngu
278 5b5d9b1f taeseongkim
                using (Markus.Image.ImageCompare compareLib = new Markus.Image.ImageCompare())
279 72424099 taeseongkim
                {
280
                    result = compareLib.CompareReturnRects(originFile, targetFile, new System.Drawing.Size(20, 20));
281
                }
282
            }
283
            catch (Exception ex)
284 6b6e937c taeseongkim
            {
285 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetCompareRect : " + ex.ToString());
286 72424099 taeseongkim
                //throw new FaultException(ex.ToString() + " Inner Exception : " + ex.InnerException?.ToString());
287 6b6e937c taeseongkim
            }
288 0585d5cc taeseongkim
289 787a4489 KangIngu
290
            return result;
291
        }
292
293 3212270d taeseongkim
        /// <summary>
294
        /// 두 페이지를 비교하여 결과를 리턴한다
295
        /// </summary>
296
        /// <param name="projectNo"></param>
297
        /// <param name="originDocItem_ID"></param>
298
        /// <param name="targetDocItem_ID"></param>
299
        /// <param name="originPageNo"></param>
300
        /// <param name="targetPageNo"></param>
301
        /// <param name="isInternalAddress"></param>
302
        /// <returns></returns>
303
        [OperationContract]
304
        public List<Rect> GetComparefixSize(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo,Size FixSize, string isInternalAddress)
305
        {
306
            List<Rect> result = new List<Rect>();
307
308
            try
309
            {
310
                string originFile = "";
311
                string targetFile = "";
312
313
                string sOriginFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID);
314
                string sTagetFolder = targetDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(targetDocItem_ID) / 100).ToString() : (targetDocItem_ID.Length >= 5 ? targetDocItem_ID.Substring(0, 5) : targetDocItem_ID);
315
316
                if (Boolean.Parse(isInternalAddress))
317
                {
318
                    originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sOriginFolder, originDocItem_ID, originPageNo);
319
                    targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sTagetFolder, targetDocItem_ID, targetPageNo);
320
                }
321
                else
322
                {
323
                    originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo);
324
                    targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo);
325
                }
326
327
                using (Markus.Image.ImageCompare compareLib = new Markus.Image.ImageCompare())
328
                {
329
330
                    result = compareLib.CompareReturnRects(originFile, targetFile, new System.Drawing.Size(20, 20));
331
                }
332
            }
333
            catch (Exception ex)
334
            {
335
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetCompareRect : " + ex.ToString());
336
                //throw new FaultException(ex.ToString() + " Inner Exception : " + ex.InnerException?.ToString());
337
            }
338
339
340
            return result;
341
        }
342
343 6b6e937c taeseongkim
        //[OperationContract]
344
        //public List<Rect> GetCompareRect_old(string projectNo, string originDocItem_ID, string targetDocItem_ID, string originPageNo, string targetPageNo, string isInternalAddress)
345
        //{
346
        //    System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
347
348
        //    stopwatch.Start();
349
350
        //    string originFile = "";
351
        //    string targetFile = "";
352
353
        //    string sFolder = originDocItem_ID.All(char.IsDigit) ? (Convert.ToUInt32(originDocItem_ID) / 100).ToString() : (originDocItem_ID.Length >= 5 ? originDocItem_ID.Substring(0, 5) : originDocItem_ID);
354
        //    if (Boolean.Parse(isInternalAddress))
355
        //    {
356
        //        originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, originDocItem_ID, originPageNo);
357
        //        targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath, projectNo, sFolder, targetDocItem_ID, targetPageNo);
358
        //    }
359
        //    else
360
        //    {
361
        //        originFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, originDocItem_ID, originPageNo);
362
        //        targetFile = String.Format(KCOM_API.Properties.Settings.Default.TileSoucePath_SUB, projectNo, targetDocItem_ID, targetPageNo);
363
        //    }
364
365
        //    CompareLib compareLib = new CompareLib();
366
367
        //    var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
368
        //    var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
369
370
        //    string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
371
        //    var result = compareLib.GetBoundBoxInImage(outPutFile);
372
373
        //    System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks));
374
375
        //    return result;
376
        //}
377
378 787a4489 KangIngu
379
        #region Final PDF
380
        private string _ChanID = null;
381
        TcpChannel chan = null;
382
        [OperationContract]
383
        public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUserID)
384
        {
385
            #region 임시보관
386
            #endregion
387
            FinalPDFResult _result = new FinalPDFResult();
388
            RemFinalPDFObject remObj = null;
389
            try
390
            {
391
                string _finalID = shortGuid();
392
                int _DocTotalPages = -1;
393
                string docItemId;
394
395 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
396
                using (CIEntities _ci = new CIEntities(sCIConnString))
397 787a4489 KangIngu
                {
398
                    var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
399
400
                    if (_doc.Count() > 0)
401
                    {
402
                        _DocTotalPages = _doc.First().PAGE_COUNT;
403
                        docItemId = _doc.First().DOCUMENT_ID;
404
                    }
405
                    else
406
                    {
407
                        _result.Status = FinalStatus.Error;
408
                        _result.Exception = "페이지 정보를 가져올 수 없습니다.";
409
                        return _result;
410
                    }
411
                }
412
                if (_DocTotalPages > 0)
413
                {
414
                    FINAL_PDF fm = new FINAL_PDF()
415
                    {
416
                        ID = _finalID,
417
                        PROJECT_NO = ProjectNo,
418
                        DOCINFO_ID = DocInfoID,
419
                        DOCUMENT_ID = docItemId,
420
                        MARKUPINFO_ID = MarkupInfoID,
421
                        CREATE_USER_ID = CreateUserID,
422
                        TOTAL_PAGE = _DocTotalPages,
423
                        CREATE_DATETIME = DateTime.Now,
424
                        STATUS = (int)IFinalPDF.FinalStatus.Insert
425
                    };
426 ff01c725 humkyung
427
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
428
                    using (KCOMEntities _entity = new KCOMEntities(sConnString))
429 787a4489 KangIngu
                    {
430
                        _entity.AddToFINAL_PDF(fm);
431
                        _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
432
                    };
433
434 6a19b48d taeseongkim
                    if(KCOM_API.Properties.Settings.Default.FinalService.StartsWith("tcp"))
435 787a4489 KangIngu
                    {
436 6a19b48d taeseongkim
                        System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
437
                        if (_ch == null)
438 787a4489 KangIngu
                        {
439 6a19b48d taeseongkim
                            chan = new TcpChannel();
440
                            _ChanID = chan.ChannelName;
441
                            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
442
                            // Create an instance of the remote object
443 787a4489 KangIngu
444 6a19b48d taeseongkim
                            using (KCOMEntities ec = new KCOMEntities(sConnString))
445
                            {
446
447
                                //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
448
                                //                          "tcp://localhost:9092/remFinalPDF");
449
                                remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
450
                                                          //"tcp://192.168.0.67:9092/remFinalPDF");
451
                                                          KCOM_API.Properties.Settings.Default.FinalService);
452
                            }
453 787a4489 KangIngu
454 6a19b48d taeseongkim
                            //"tcp://localhost:8080/remFinalPDF");
455 787a4489 KangIngu
456 6a19b48d taeseongkim
                            _result = remObj.SetFinalPDF(ProjectNo, _finalID);
457
                            _result.FinalID = _finalID;
458
                            _result.Status = FinalStatus.Success;
459 787a4489 KangIngu
460 6a19b48d taeseongkim
                            //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
461
                            //fa.MakeFinalPDF(fm);
462
                        }
463
                        else
464
                        {
465
                            _ChanID = _ch.ChannelName;
466
                        }
467 787a4489 KangIngu
                    }
468
                    else
469
                    {
470 6a19b48d taeseongkim
                        System.Net.WebClient client = new System.Net.WebClient();
471
                        var convertResult = client.DownloadString($"{KCOM_API.Properties.Settings.Default.FinalService}/Rest/FinalAdd?ProjectNo={ProjectNo}&FinalID={_finalID}");
472
473
                        JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings());
474
                        
475
                        if(jObject["FinalAddResult"].ToString() == true.ToString())
476
                        {
477
                            _result.FinalID = _finalID;
478
                            _result.Status = FinalStatus.Success;
479
                        }
480 787a4489 KangIngu
                    }
481 6a19b48d taeseongkim
482 787a4489 KangIngu
                }
483
            }
484
            catch (Exception ex)
485
            {
486 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - SetFinalPDF : " + ex.ToString());
487
488 787a4489 KangIngu
                _result.Status = FinalStatus.Error;
489
490
                if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
491
                    _result.Exception = "Final Server Not Connection";
492 b734b65d djkim
                else _result.Exception = ex.ToString();
493 787a4489 KangIngu
            }
494
            finally
495
            {
496
                remObj = null;
497
                if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
498
                    System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
499
500
                GC.Collect(2);
501
            }
502
            return _result;
503
        }
504
        #endregion
505
506
507
        [OperationContract]
508
        public bool GetConversionState(KCOM_BasicParam param)
509
        {
510 ff01c725 humkyung
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
511
            using (CIEntities entity = new CIEntities(sCIConnString))
512 787a4489 KangIngu
            {
513
                var doc = entity.DOCINFO.Where(data => data.DOCUMENT_ID == param.documentID).FirstOrDefault();
514
                if (doc != null)
515
                {
516
                    var count = doc.DOCPAGE.Where(data => data.DOCINFO_ID == doc.ID).Count();
517
                    if (doc.PAGE_COUNT == count)  //페이지 수가 일치하는지
518
                    {
519
                        return true;
520
                    }
521
                    else //페이지 수가 일치하지 않는 경우
522
                    {
523 ff01c725 humkyung
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
524
                        KCOMEntities entity_kcom = new KCOMEntities(sConnString);
525 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();
526
527
                        if (lst != null || lst.Count >= 1)
528
                        {
529
                            //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_PAGECOUNT"), param.documentID, param.projectNo);
530
                            //이메일 클라이언트를 구현해야함
531
                        }
532
                        return false;
533
                    }
534
                }
535
                else
536
                {
537
                    //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_CONVERTFAILED"), param.documentID, param.projectNo);
538
                    //이메일 클라이언트를 구현해야함
539
                    return false;
540
                }
541
            }
542
        }
543
544
        [OperationContract]
545
        public List<VPRevision> GetVPRevisionHistory(string ProjectNo, string vpNo, string DocumentId)
546
        {
547
            List<VPRevision> _result = new List<VPRevision>();
548
            try
549
            {
550 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
551
                using (CIEntities entity = new CIEntities(sCIConnString))
552 787a4489 KangIngu
                {
553
                    var _vpList = (from docitem in entity.DOCUMENT_ITEM
554 0585d5cc taeseongkim
                                   where docitem.PROJECT_NO == ProjectNo && docitem.DOCUMENT_NO == vpNo
555 787a4489 KangIngu
                                   select new VPRevision
556
                                   {
557
                                       RevNo = docitem.REVISION,
558
                                       GroupNo = docitem.GROUP_NO,
559
                                       FROM_VENDOR = docitem.ORIGINAL_FILE,
560
                                       DOCUMENT_ID = docitem.DOCUMENT_ID,
561
                                       TO_VENDOR = docitem.RESULT_FILE,
562
                                       RESULT = docitem.RESULT,
563 c91f45f3 djkim
                                       DocNo = docitem.DOCUMENT_NO,
564 ab5aa762 taeseongkim
                                       //EnsembleLink = docitem.ENSEMBLEINFO_URL,
565 c0977e97 djkim
                                       //IsSyncPossible = docitem.DOCUMENT_ID == DocumentId ? false : entity.DOCINFO.Where(d => d.DOCUMENT_ID == docitem.DOCUMENT_ID).ToList().Count > 0 ? true : false
566 787a4489 KangIngu
                                   });
567
                    _result = _vpList.ToList();
568 c0977e97 djkim
                    foreach (var vp in _result)
569
                    {
570
                        if (entity.DOCINFO.Where(d => d.DOCUMENT_ID == vp.DOCUMENT_ID).ToList().Count > 0)
571
                            vp.IsSyncPossible = true;
572
                        else
573
                            vp.IsSyncPossible = false;
574
                    }
575 ff01c725 humkyung
576
                    //_result = _result.OrderByDescending(r => UInt64.Parse(System.Text.RegularExpressions.Regex.Replace(r.GroupNo, @"\D", ""))).ToList();
577 f65e6c02 taeseongkim
                    _result =  _result.OrderByDescending(r => r.GroupNo).ToList();
578 787a4489 KangIngu
                }
579
            }
580 ff01c725 humkyung
            catch (Exception ex)
581 787a4489 KangIngu
            {
582 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetVPRevisionHistory : " + ex.ToString());
583 787a4489 KangIngu
            }
584
            finally
585
            {
586 24c5e56c taeseongkim
                //GC.Collect(2);
587 787a4489 KangIngu
            }
588 0585d5cc taeseongkim
589 787a4489 KangIngu
            return _result;
590
        }
591
592
        [OperationContract]
593 2ab012e8 djkim
        public VPRevision GetVPRevisionFirstOrDefault(string ProjectNo, string DocumentId)
594
        {
595
            VPRevision _result = null;
596
            try
597
            {
598 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
599
                using (CIEntities entity = new CIEntities(sCIConnString))
600 2ab012e8 djkim
                {
601
                    _result = (from docitem in entity.DOCUMENT_ITEM
602 0585d5cc taeseongkim
                     where docitem.PROJECT_NO == ProjectNo && docitem.DOCUMENT_ID == DocumentId
603 2ab012e8 djkim
                     select new VPRevision
604
                     {
605
                         RevNo = docitem.REVISION,
606
                         GroupNo = docitem.GROUP_NO,
607
                         FROM_VENDOR = docitem.ORIGINAL_FILE,
608
                         DOCUMENT_ID = docitem.DOCUMENT_ID,
609
                         TO_VENDOR = docitem.RESULT_FILE,
610
                         RESULT = docitem.RESULT
611
                     }).FirstOrDefault();
612
                }
613
            }
614 0585d5cc taeseongkim
            catch (Exception ex)
615 2ab012e8 djkim
            {
616 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetVPRevisionFirstOrDefault : " + ex.ToString());
617 2ab012e8 djkim
            }
618
            finally
619
            {
620 24c5e56c taeseongkim
                //GC.Collect(2);
621 2ab012e8 djkim
            }
622
            return _result;
623
        }
624
625
        [OperationContract]
626 787a4489 KangIngu
        public DOCINFO GetDocInfo(KCOM_BasicParam param)
627
        {
628
            DOCINFO _result = null;
629
            try
630
            {
631
                // 차후 아래의 코드로 변경
632
                //using (CI_Entities ModelDeeview = new CI_Entities(DaelimCiConnectionString.ToString()))
633 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
634
                CIEntities ModelDeeview = new CIEntities(sCIConnString);
635 787a4489 KangIngu
636 683a4a8f djkim
                var docinfo = ModelDeeview.DOCINFO.Where(doc => doc.DOCUMENT_ID == param.documentID && doc.PROJECT_NO == param.projectNo);
637 787a4489 KangIngu
                if (docinfo.Count() > 0)
638
                {
639
                    _result = docinfo.First();
640
                    _result.MARKUP_INFO.Clear();
641
642
                }
643
                return _result;
644
645
            }
646
            catch (Exception ex)
647
            {
648 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDocInfo : " + ex.ToString());
649 787a4489 KangIngu
            }
650
            finally
651
            {
652 24c5e56c taeseongkim
                //GC.Collect(2);
653 787a4489 KangIngu
            }
654
            return null;
655
        }
656
657
        [OperationContract]
658
        public bool GetCheckSystemAdmin(string UserID)
659
        {
660 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
661
            using (KCOMEntities uc = new KCOMEntities(sConnString))
662 787a4489 KangIngu
            {
663
                var user = uc.PROPERTIES.Where(data => data.TYPE == "Administrator" && data.PROPERTY.Contains(UserID)).FirstOrDefault();
664
                if (user != null)
665
                {
666
                    return true;
667
                }
668
                else
669
                {
670
                    return false;
671
                }
672
            }
673 24c5e56c taeseongkim
            //GC.Collect(2);
674 787a4489 KangIngu
        }
675
676
        [OperationContract]
677
        public DOCUMENT_ITEM GetDocumentItemInfo(KCOM_BasicParam param)
678
        {
679
            ///param : prjNo, documentId, userId
680
            DOCUMENT_ITEM _result = null;
681
682
            try
683
            {
684 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
685
                CIEntities entity = new CIEntities(sCIConnString);
686 ac91e747 taeseongkim
               
687 0585d5cc taeseongkim
                var _items = entity.DOCUMENT_ITEM.Where(data => data.PROJECT_NO == param.projectNo && data.DOCUMENT_ID == param.documentID);
688 787a4489 KangIngu
689
                if (_items.Count() > 0)
690
                {
691
                    _result = _items.First();
692
693
                    return _result;
694
                }
695
                //else
696
                //{
697
                //    Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, Resources.ResourceManager.GetString("MSG_ERROR_DOCUMENTNOTFOUND"), param.documentID, param.projectNo);
698
                //}
699
            }
700
            catch (Exception ex)
701
            {
702 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDocumentItemInfo : " + ex.ToString());
703 ac91e747 taeseongkim
704
                new FaultException("GetDocumentItemInfo Error - "  + ex.ToString());
705 ff01c725 humkyung
                //throw new FaultException(ex.ToString());
706 787a4489 KangIngu
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
707
            }
708
709
            return _result;
710
        }
711 35afe17c djkim
        /// <summary>
712
        /// DOCUMENT_ITEM Table 의 ID 로 Item 을 Select
713
        /// </summary>
714 5ded1e5a djkim
        /// 대림의 경우 Interface ID(Document 의 ID) 를 parameter 로 전달
715
        /// 넘어온 ID를 통해 document id 를 확인하는 과정이 필요
716 35afe17c djkim
        /// <param name="ensemble_id"></param>
717
        /// <returns></returns>
718 c0977e97 djkim
        [OperationContract]
719
        public string GetDocItemID(string ensemble_id)
720
        {
721
            ///param : prjNo, documentId, userId
722
            string _result = string.Empty;
723
724
            try
725
            {
726 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
727
                CIEntities entity = new CIEntities(sCIConnString);
728 787a4489 KangIngu
729 c0977e97 djkim
                var _items = entity.DOCUMENT_ITEM.Where(data => data.ID == ensemble_id).FirstOrDefault();
730 35afe17c djkim
                if(_items != null)
731
                    _result = _items.DOCUMENT_ID;
732 c0977e97 djkim
            }
733
            catch (Exception ex)
734
            {
735 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDocItemID : " + ex.ToString());
736 c0977e97 djkim
                //System.Diagnostics.Trace.WriteLine("GetVendorItemInfo Error : " + ex);
737
                //Common.Helper.SystemErrorNotify(SERVICE_NAME.API, LEVEL.MEDIUM, ERROR_TYPE.CONVERT, "GetDocumentItemInfo / " + ex.Message, param.documentID, param.projectNo);
738
            }
739
740
            return _result;
741
        }
742 787a4489 KangIngu
        public string UserGO(MARKUP_INFO item)
743
        {
744
            if (item != null)
745
            {
746
                return item.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID;
747
            }
748
            return null;
749
        }
750 53880c83 ljiyeon
        
751
        [OperationContract]
752
        public List<MarkupInfoItem> GetMarkupInfoItems(string ProjectNo, string DocInfoId)
753
        {
754
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
755
            try
756
            {
757 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
758
                using (CIEntities entity = new CIEntities(sCIConnString))
759 53880c83 ljiyeon
                {
760
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == DocInfoId).ToList();
761
762
                    var markupList = from markup in markupListData
763
                                     orderby markup.CREATE_TIME descending
764
                                     select new MarkupInfoItem
765
                                     {
766
                                         MarkupInfoID = markup.ID,
767
                                         UserID = markup.USER_ID,
768
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
769
                                         CreateTime = markup.CREATE_TIME,
770
                                         Consolidate = markup.CONSOLIDATE,
771
                                         Description = markup.DESCRIPTION,
772
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
773
                                         PartConsolidate = markup.PART_CONSOLIDATE,
774
                                         UpdateTime = DateTime.Parse(markup.UPDATE_TIME.ToString()),
775
                                     };
776
777
                    if (markupList.Count() > 0)
778
                    {
779
                        _result = markupList.ToList();
780
                    }
781
782
                    _result.ForEach(r =>
783
                    {
784
785
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
786
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
787
                                        orderby markupData.PAGENUMBER
788 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();
789 53880c83 ljiyeon
                    });
790
791 c0977e97 djkim
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
792 53880c83 ljiyeon
                    Random random = new Random();
793 ff01c725 humkyung
794
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
795
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
796 c0977e97 djkim
                    {
797
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
798
                                             where property.TYPE == "DisplayColor"
799
                                             select property).ToList();
800 315ae55e taeseongkim
801
                    }
802
803 4fcb686a taeseongkim
                    if (_ColorsProperties.Count() != _result.GroupBy(x=>x.UserID).Count())
804 315ae55e taeseongkim
                    {
805
                        ColorGenerator uniqueColorGenerator = new ColorGenerator(System.Drawing.Color.Red); // 2303 = (int)Color.Red
806
807
                        uniqueColorGenerator.GetEnumerator(_result.Count());
808
809
                        for (int i = 0; i < _result.Count(); i++)
810
                        {
811
                             var c = uniqueColorGenerator.GetNext();
812
                            _ColorsProperties.Add(new PROPERTIES { VALUE = String.Format("{0:X2}{1:X2}{2:X2}",c.R, c.G,c.B) });
813
                        }
814 a1142a6b taeseongkim
                    }
815
816
                    bool IsProjectNoPass = Properties.Settings.Default.IsProjectNoPass;
817 53880c83 ljiyeon
818 4fcb686a taeseongkim
                    foreach (var item in _result.GroupBy(x=>x.UserID))
819 53880c83 ljiyeon
                    {
820 a1142a6b taeseongkim
                        string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
821
822
                        System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery 
823 4fcb686a taeseongkim
                                      = entity.CreateQuery<System.Data.Common.DbDataRecord>(query,new System.Data.Objects.ObjectParameter("userId",item.Key));
824
825 a1142a6b taeseongkim
                        if (memberQuery.Count() > 0)
826 53880c83 ljiyeon
                        {
827 a1142a6b taeseongkim
                            string userName = memberQuery.First()["NAME"]?.ToString().Trim();
828
                            string depatment = memberQuery.First()["DEPARTMENT"]?.ToString().Trim();
829
830 4fcb686a taeseongkim
                            PROPERTIES deptColor = _ColorsProperties[0];
831
832
                            _ColorsProperties.RemoveAt(0);
833
                            //PROPERTIES deptColor = _ColorsProperties.Find(c => c.PROPERTY == depatment);
834
835
                            //if (_ColorsProperties.Count > 0)
836
                            //{
837
                            //    if (deptColor == null)
838
                            //    {
839
                            //        item.DisplayColor = "#FF" + _ColorsProperties[0].VALUE;
840
                            //        _ColorsProperties.RemoveAt(0);
841
                            //    }
842
                            //    else
843
                            //    {
844
                            //        item.DisplayColor = "#FF" + deptColor.VALUE;
845
                            //        _ColorsProperties.Remove(deptColor);
846
                            //    }
847
                            //}
848
849
                            foreach (var markupInfo in item)
850
                            {
851
                                markupInfo.DisplayColor = "#FF" + deptColor.VALUE;
852
                                markupInfo.UserName = userName;
853
                                markupInfo.Depatment = depatment;
854
                            }
855 c0977e97 djkim
                        }
856 53880c83 ljiyeon
                    }
857 4fcb686a taeseongkim
858
                       
859
                    //else
860
                    //{
861
                    //    item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
862
                    //}
863 53880c83 ljiyeon
                }
864
            }
865 0585d5cc taeseongkim
            catch (Exception ex)
866 53880c83 ljiyeon
            {
867 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetMarkupInfoItems : " + ex.ToString());
868
869 53880c83 ljiyeon
                return _result;
870
            }
871
            finally
872
            {
873 24c5e56c taeseongkim
                //GC.Collect(2);
874 53880c83 ljiyeon
            }
875
876
            return _result;
877
        }
878
879 787a4489 KangIngu
        [OperationContract]
880
        public List<MarkupInfoItem> GetSyncMarkupInfoItems(string ProjectNo, string DocInfoId, string currentUser)
881
        {
882
            List<MarkupInfoItem> _result = new List<MarkupInfoItem>();
883
            try
884
            {
885 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
886
                using (CIEntities entity = new CIEntities(sCIConnString))
887 787a4489 KangIngu
                {
888
                    var docItem = entity.DOCINFO.Where(data => data.DOCUMENT_ID == DocInfoId).FirstOrDefault();
889
                    if (docItem == null)
890
                    {
891
                        return null;
892
                    }
893
                    var markupListData = entity.MARKUP_INFO.Where(data => data.DOCINFO_ID == docItem.ID).ToList();
894
895
                    var markupList = from markup in markupListData
896
                                     where markup.USER_ID == currentUser || markup.CONSOLIDATE == 1
897
                                     orderby markup.CREATE_TIME descending
898
                                     select new MarkupInfoItem
899
                                     {
900
                                         MarkupInfoID = markup.ID,
901
                                         UserID = markup.USER_ID,
902
                                         MarkupVersionID = markup.MARKUP_INFO_VERSION.Count() == 0 ? null : markup.MARKUP_INFO_VERSION.OrderByDescending(data => data.CREATE_DATE).FirstOrDefault().ID,
903
                                         CreateTime = markup.CREATE_TIME,
904
                                         Consolidate = markup.CONSOLIDATE,
905
                                         Description = markup.DESCRIPTION,
906
                                         AvoidConsolidate = markup.AVOID_CONSOLIDATE,
907
                                         PartConsolidate = markup.PART_CONSOLIDATE,
908
                                     };
909
910
911
912
                    if (markupList.Count() > 0)
913
                    {
914
                        _result = markupList.ToList();
915
                    }
916
917
918
919
                    _result.ForEach(r =>
920
                    {
921
922
                        r.MarkupList = (from markupData in entity.MARKUP_DATA
923
                                        where markupData.MARKUPINFO_VERSION_ID == r.MarkupVersionID
924
                                        orderby markupData.PAGENUMBER
925 ab5aa762 taeseongkim
                                        select new MarkupItem
926
                                        {
927
                                            ID = markupData.ID,
928
                                            PageNumber = markupData.PAGENUMBER,
929
                                            Data = markupData.DATA,
930
                                            Data_Type = markupData.DATA_TYPE,
931
                                            Symbol_ID = markupData.SYMBOL_ID
932
                                        }).ToList();
933 787a4489 KangIngu
                    });
934
935
                    List<PROPERTIES> _ColorsProperties = new List<PROPERTIES>();
936
                    Random random = new Random();
937
938 ff01c725 humkyung
                    string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
939
                    using (KCOMEntities kcomEntity = new KCOMEntities(sConnString))
940 787a4489 KangIngu
                    {
941
                        _ColorsProperties = (from property in kcomEntity.PROPERTIES
942
                                             where property.TYPE == "DisplayColor"
943
                                             select property).ToList();
944
                    }
945
946
                    foreach (var item in _result)
947
                    {
948 a1142a6b taeseongkim
                        string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
949
950
                        System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery
951
                                      = entity.CreateQuery<System.Data.Common.DbDataRecord>(query, new System.Data.Objects.ObjectParameter("userId", item.UserID));
952 787a4489 KangIngu
953 a1142a6b taeseongkim
                        if (memberQuery.Count() > 0)
954 787a4489 KangIngu
                        {
955 a1142a6b taeseongkim
956
                            string userName = memberQuery.First()["NAME"]?.ToString().Trim();
957
                            string depatment = memberQuery.First()["DEPARTMENT"]?.ToString().Trim();
958
959
                            item.UserName = userName;
960
                            item.Depatment = depatment;
961 787a4489 KangIngu
                        }
962
963
                        if (_ColorsProperties.Count > 0)
964
                        {
965
                            int colorIdx = random.Next(1, _ColorsProperties.Count());
966
                            #region 부서별로 색상을 지정하고자 할때
967
                            /// 일단 의견을 들어보자구!
968
                            #endregion
969
                            item.DisplayColor = "#FF" + _ColorsProperties[colorIdx].VALUE;
970
                            _ColorsProperties.Remove(_ColorsProperties[colorIdx]);
971
                            //item.DisplayColor = "#FF" + _Colors.First();
972
                            //_Colors.Remove(_Colors.First());
973
                        }
974
                        else
975
                        {
976
                            item.DisplayColor = String.Format("#FF{0:X6}", random.Next(0x1000000));
977
                        }
978
                    }
979
                }
980
            }
981 0585d5cc taeseongkim
            catch (Exception ex)
982 787a4489 KangIngu
            {
983 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetSyncMarkupInfoItems : " + ex.ToString());
984 787a4489 KangIngu
                return _result;
985
            }
986
            finally
987
            {
988 24c5e56c taeseongkim
                //GC.Collect(2);
989 787a4489 KangIngu
            }
990
991
            return _result;
992
        }
993
994
995
        //[OperationContract]
996
        //[ServiceKnownType(typeof(MEMBER))]
997
        //public List<MEMBER> GetUserData(string ProjectNo, string UserID)
998
        //{
999
        //    List<MEMBER> _result = new List<MEMBER>();
1000
1001
        //    using (CIEntities entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1002
        //    {
1003
        //        var _UserList = from member in entity.MEMBER
1004
        //                        where member.ID == UserID
1005
        //                        select member;
1006
        //        _result = _UserList.ToList();
1007
        //    }
1008
        //    //GC.Collect(2);
1009
        //    return _result;
1010
        //}
1011
1012 2ab012e8 djkim
        [OperationContract]
1013
        [ServiceKnownType(typeof(MEMBER))]
1014
        public List<MEMBER> GetUserData(string ProjectNo, string UserID)
1015
        {
1016
            List<MEMBER> _result = new List<MEMBER>();
1017 787a4489 KangIngu
1018 ff01c725 humkyung
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1019 285635d3 taeseongkim
1020 ff01c725 humkyung
            using (CIEntities entity = new CIEntities(sCIConnString))
1021 2ab012e8 djkim
            {
1022 285635d3 taeseongkim
                _result = GetMemberQuery(entity, UserID);
1023 2ab012e8 djkim
            }
1024
            //GC.Collect(2);
1025
            return _result;
1026
        }
1027 787a4489 KangIngu
1028
1029
        [OperationContract]
1030
        public List<string> GetDeptData(string UserDept) //그룹 추가 옵션 부여 예정
1031
        {
1032
            List<string> _result = new List<string>();
1033
1034
            try
1035
            {
1036 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1037
                KCOMEntities entity = new KCOMEntities(sConnString);
1038 787a4489 KangIngu
                var YourEnginner = (from dept in entity.PROPERTIES
1039
                                    where dept.TYPE == "DeptName" && UserDept.Contains(dept.VALUE)
1040
                                    select dept).FirstOrDefault();
1041
1042
                if (YourEnginner != null)
1043
                {
1044
                    _result = (from dept in entity.PROPERTIES
1045
                               where dept.PROPERTY == YourEnginner.PROPERTY
1046
                               select dept.VALUE).ToList();
1047
                    return _result;
1048
                }
1049
                else
1050
                {
1051
                    return null;
1052
                }
1053
            }
1054
            catch (Exception ex)
1055
            {
1056 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - GetDeptData : " + ex.ToString());
1057 787a4489 KangIngu
            }
1058
            finally
1059
            {
1060 24c5e56c taeseongkim
                //GC.Collect(2);
1061 787a4489 KangIngu
            }
1062
            return _result;
1063
        }
1064
1065
        [OperationContract]
1066
        public bool DeleteMarkup(string ProjectNo, string MarkupInfoID)
1067
        {
1068
            bool _result = false;
1069
            try
1070
            {
1071 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1072
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(sCIConnString))
1073 787a4489 KangIngu
                {
1074
1075
                    MARKUP_INFO instance = Entity.MARKUP_INFO.Where(root => root.ID == MarkupInfoID).FirstOrDefault();
1076
1077
                    if (instance == null)
1078
                    {
1079
                        return false;
1080
                    }
1081
                    MARKUP_INFO_VERSION version = instance.MARKUP_INFO_VERSION.FirstOrDefault();
1082
1083
1084
                    version.MARKUP_DATA.ToList().ForEach(data =>
1085
                    {
1086
                        Entity.MARKUP_DATA.DeleteObject(data);
1087
                        Entity.SaveChanges();
1088
                    });
1089
1090
                    Entity.MARKUP_INFO_VERSION.DeleteObject(version);
1091
                    Entity.SaveChanges();
1092
1093
                    Entity.MARKUP_INFO.DeleteObject(instance);
1094
                    Entity.SaveChanges();
1095
1096
                }
1097
                _result = true;
1098
            }
1099
            catch (Exception ex)
1100
            {
1101 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - DeleteMarkup : " + ex.ToString());
1102 787a4489 KangIngu
            }
1103
            finally
1104
            {
1105 24c5e56c taeseongkim
                //GC.Collect(2);
1106 787a4489 KangIngu
            }
1107
            return _result;
1108
        }
1109 992a98b4 KangIngu
1110
        #region Favorite
1111
        [OperationContract]
1112
        public bool SetFavoriteVP(string prjNo, string userID, string groupNo, string docNo, string rev, int SavePageNo, string documentItemID, string VPDescription, IKCOM.FAVORITE_FLAG flag)
1113
        {
1114 ff01c725 humkyung
            string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1115
            using (KCOMEntities entity = new KCOMEntities(sConnString))
1116 992a98b4 KangIngu
            {
1117
                try
1118
                {
1119
                    entity.FAVORITE_DOC.AddObject(new FAVORITE_DOC
1120
                    {
1121
                        ID = shortGuid(),
1122
                        PROJECT_NO = prjNo,
1123
                        DOCUMENT_ID = documentItemID,
1124
                        GROUP_NO = groupNo,
1125
                        DOCUMENT_NO = docNo,
1126
                        MEMBER_USER_ID = userID,
1127
                        DESCRIPTION = VPDescription,
1128
                        CREATE_TIME = DateTime.Now,
1129
                        REVISION = rev,
1130
                        FLAG = (int)flag,
1131
                        PAGE_NO = SavePageNo,
1132
                    });
1133
                    entity.SaveChanges();
1134
                }
1135 0585d5cc taeseongkim
                catch (Exception ex)
1136 992a98b4 KangIngu
                {
1137 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SetFavoriteVP : " + ex.ToString());
1138 992a98b4 KangIngu
                    return false;
1139
                }
1140
1141
                return true;
1142
            }
1143
        }
1144
1145
        //[OperationContract]
1146
        //public List<FAVORITE_DOC> GetFavoriteVP(string PrjNo, string userID, string sharepointItemID)
1147
        //{
1148
        //    using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
1149
        //    {
1150
1151
        //        int flagString = Convert.ToInt32(IKCOM.FAVORITE_FLAG.Personal);                
1152
        //        List<FAVORITE_DOC> favoriteListSet = new List<FAVORITE_DOC>();
1153
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.DOCUMENT_ID == sharepointItemID && data.FLAG !=
1154
        //            flagString).ToList().ForEach(data => favoriteListSet.Add(data));
1155
        //        entity.FAVORITE_DOC.Where(data => data.PROJECT_NO == PrjNo && data.MEMBER_USER_ID == userID).ToList().ForEach(data => favoriteListSet.Add(data));
1156
        //        favoriteListSet = favoriteListSet.Distinct().ToList();
1157
        //        return favoriteListSet;
1158
        //    }
1159
        //}
1160
        //[OperationContract]
1161
        //public bool EditFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime, int state, string description)
1162
        //{
1163
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1164
        //    {
1165
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1166
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1167
1168
        //        try
1169
        //        {
1170
1171
1172
        //            if (favoriteSet.Count > 0)
1173
        //            {
1174
        //                var FavoriteVP_Instance = favoriteSet.First();
1175
1176
        //                FavoriteVP_Instance.Description = description;
1177
        //                FavoriteVP_Instance.Flag = state;
1178
1179
        //                dc.SaveChanges();
1180
1181
        //                return true;
1182
        //            }
1183
        //            else
1184
        //            {
1185
        //                return false;
1186
        //            }
1187
        //        }
1188 24c5e56c taeseongkim
        //        catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1189 992a98b4 KangIngu
        //        {
1190
        //            return false;
1191
        //        }
1192
        //    }
1193
        //}
1194
        //[OperationContract]
1195
        //public bool DelFavoriteVP(string prjNo, string userID, int SavePageNo, string sharepointItemID, DateTime createTime)
1196
        //{
1197
1198
        //    using (DeepViewEntities dc = new DeepViewEntities(ConnectStringBuilder.DeepViewConnectionString().ToString()))
1199
        //    {
1200
        //        List<FavoriteVP> favoriteSet = dc.FavoriteVP.Where(data => data.ProjectNo == prjNo && data.CreateUserID == userID
1201
        //            && data.PageNo == SavePageNo && data.CreateTime == createTime).ToList();
1202
1203
        //        try
1204
        //        {
1205
1206
1207
        //            if (favoriteSet.Count > 0)
1208
        //            {
1209
        //                favoriteSet.ForEach(data => dc.FavoriteVP.DeleteObject(data));
1210
        //                dc.SaveChanges();
1211
        //                return true;
1212
        //            }
1213
        //            else
1214
        //            {
1215
        //                return false;
1216
        //            }
1217
        //        }
1218 24c5e56c taeseongkim
        //        catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1219 992a98b4 KangIngu
        //        {
1220
        //            return false;
1221
        //        }
1222
        //    }
1223
        //}
1224
        #endregion
1225 2ab012e8 djkim
1226
        [OperationContract]
1227
        public bool SaveMarkupData(MarkupInfoItem UserState,string project_no,string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1228
        {
1229 6b6e937c taeseongkim
            
1230 ff01c725 humkyung
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1231
            using (CIEntities Entity = new CIEntities(sCIConnString))
1232 2ab012e8 djkim
            {     
1233
                #region Docinfo 정보 가져오기
1234
1235
                string docinfoid_ = (from info in Entity.DOCINFO
1236
                                     where info.DOCUMENT_ID == doc_id
1237
                                     && info.PROJECT_NO == project_no
1238
                                     select info.ID
1239
                                     ).First().ToString();
1240
                #endregion
1241
1242
                #region Markup_Info 저장
1243
1244
                MARKUP_INFO markup_info = new MARKUP_INFO();
1245
                try
1246
                {
1247
                    markup_info = (from info in Entity.MARKUP_INFO
1248
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_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: " + ex.ToString());
1254 2ab012e8 djkim
                    markup_info = null;
1255
                }
1256
1257
                //markup_info가 없을 경우 생성
1258
                if (markup_info == null)
1259
                {
1260
                    //MarkupInfo 저장
1261
                    markup_info = new MARKUP_INFO
1262
                    {
1263
                        ID = UserState.MarkupInfoID,
1264
                        DOCINFO_ID = docinfoid_,
1265
                        USER_ID = user_id,
1266
                        CREATE_TIME = DateTime.Now,
1267
                        CONSOLIDATE = UserState.Consolidate,
1268
                        AVOID_CONSOLIDATE = UserState.AvoidConsolidate,
1269
                        PART_CONSOLIDATE = UserState.PartConsolidate,
1270
                        DESCRIPTION = UserState.Description,
1271
                        UPDATE_TIME = DateTime.Now
1272
                    };
1273
                    Entity.MARKUP_INFO.AddObject(markup_info);
1274
                }
1275
                //markup_info가 있을 경우 업데이트
1276
                else
1277
                {
1278
                    markup_info.UPDATE_TIME = DateTime.Now;
1279
                }
1280
                Entity.SaveChanges();
1281
                #endregion
1282
1283
                #region Markup_Info_Version 저장
1284
1285
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1286
1287
                try
1288
                {
1289
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1290
                                           where info.MARKUPINFO_ID == markup_info.ID
1291
                                           select info).FirstOrDefault();
1292
                }
1293 0585d5cc taeseongkim
                catch (Exception ex)
1294 2ab012e8 djkim
                {
1295 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SaveMarkupData  Get markup_info_version : " + ex.ToString());
1296 2ab012e8 djkim
                    markup_info_version = null;
1297
                }
1298
1299
                //markup_info_version 없을 경우 생성
1300
                if (markup_info_version == null)
1301
                {
1302
                    //MarkupInfo_version 저장
1303
                    markup_info_version = new MARKUP_INFO_VERSION()
1304
                    {
1305
                        ID = UserState.MarkupVersionID,
1306
                        MARKUPINFO_ID = markup_info.ID,
1307
                        CREATE_DATE = DateTime.Now
1308
                    };
1309
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1310
                    Entity.SaveChanges();
1311
                }
1312
                #endregion
1313
1314
                
1315
                Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1316
                {
1317
                    Entity.MARKUP_DATA.DeleteObject(item);
1318
                });
1319 77cdac33 taeseongkim
1320 2ab012e8 djkim
                Entity.SaveChanges();
1321 6b6e937c taeseongkim
1322
                try
1323
                {
1324
                    mlmarkup_data.ForEach(value =>
1325
                    {
1326
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1327
                        {
1328
                            ID = value.ID,
1329
                            DATA = value.DATA,
1330
                            DATA_TYPE = value.DATA_TYPE,
1331
                            PAGENUMBER = value.PAGENUMBER,
1332
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1333
                            SYMBOL_ID = value.SYMBOL_ID,
1334
                            //GROUP_ID = value.GROUP_ID
1335
                        });
1336 b42dd24d taeseongkim
1337
                        
1338 6b6e937c taeseongkim
                    });
1339
                    Entity.SaveChanges();
1340 b42dd24d taeseongkim
1341
                    if (Properties.Settings.Default.Properties["CLIENT_VERSION"] != null)
1342
                    {
1343
                        string sql = $"UPDATE MARKUP_DATA SET REMARK = '{Properties.Settings.Default.CLIENT_VERSION} {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }' WHERE ID = @ID";
1344
1345
                        mlmarkup_data.ForEach(value =>
1346
                        {
1347
                            var param = new System.Data.Common.DbParameter[] { new System.Data.SqlClient.SqlParameter { ParameterName = "ID", Value = value.ID } };
1348
                            var result = Entity.ExecuteStoreCommand(sql, param);
1349
                        });
1350
1351
                        Entity.SaveChanges();
1352
                    }
1353 6b6e937c taeseongkim
                }
1354 0585d5cc taeseongkim
                catch (Exception ex)
1355 6b6e937c taeseongkim
                {
1356 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SaveMarkupData  set mlmarkup_data : " + ex.ToString());
1357 6b6e937c taeseongkim
                    return false;
1358
                }
1359
            }
1360
            return true;
1361
        }
1362
1363
        [OperationContract]
1364
        public bool SavePageMarkupData(MarkupInfoItem UserState,int PageNo, string project_no, string doc_id, string user_id, List<MARKUP_DATA> mlmarkup_data)
1365
        {
1366
1367
            string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1368
            using (CIEntities Entity = new CIEntities(sCIConnString))
1369
            {
1370
                #region Docinfo 정보 가져오기
1371
1372
                string docinfoid_ = (from info in Entity.DOCINFO
1373
                                     where info.DOCUMENT_ID == doc_id
1374
                                     && info.PROJECT_NO == project_no
1375
                                     select info.ID
1376
                                     ).First().ToString();
1377
                #endregion
1378
1379
                #region Markup_Info 저장
1380
1381
                MARKUP_INFO markup_info = new MARKUP_INFO();
1382
                try
1383
                {
1384
                    markup_info = (from info in Entity.MARKUP_INFO
1385
                                   where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id
1386
                                   select info).FirstOrDefault();
1387
                }
1388 0585d5cc taeseongkim
                catch (Exception ex)
1389 6b6e937c taeseongkim
                {
1390 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SavePageMarkupData : " + ex.ToString());
1391
1392 6b6e937c taeseongkim
                    markup_info = null;
1393
                }
1394
1395
                //markup_info가 없을 경우 생성
1396
                if (markup_info == null)
1397
                {
1398
                    //MarkupInfo 저장
1399
                    markup_info = new MARKUP_INFO
1400
                    {
1401
                        ID = UserState.MarkupInfoID,
1402
                        DOCINFO_ID = docinfoid_,
1403
                        USER_ID = user_id,
1404
                        CREATE_TIME = DateTime.Now,
1405
                        CONSOLIDATE = UserState.Consolidate,
1406
                        AVOID_CONSOLIDATE = UserState.AvoidConsolidate,
1407
                        PART_CONSOLIDATE = UserState.PartConsolidate,
1408
                        DESCRIPTION = UserState.Description,
1409
                        UPDATE_TIME = DateTime.Now
1410
                    };
1411
                    Entity.MARKUP_INFO.AddObject(markup_info);
1412
                }
1413
                //markup_info가 있을 경우 업데이트
1414
                else
1415
                {
1416
                    markup_info.UPDATE_TIME = DateTime.Now;
1417
                }
1418
                Entity.SaveChanges();
1419
                #endregion
1420
1421
                #region Markup_Info_Version 저장
1422
1423
                MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1424
1425
                try
1426
                {
1427
                    markup_info_version = (from info in Entity.MARKUP_INFO_VERSION
1428
                                           where info.MARKUPINFO_ID == markup_info.ID
1429
                                           select info).FirstOrDefault();
1430
                }
1431 0585d5cc taeseongkim
                catch (Exception ex)
1432 6b6e937c taeseongkim
                {
1433 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SavePageMarkupData get markup_info_version : " + ex.ToString());
1434 6b6e937c taeseongkim
                    markup_info_version = null;
1435
                }
1436
1437
                //markup_info_version 없을 경우 생성
1438
                if (markup_info_version == null)
1439
                {
1440
                    //MarkupInfo_version 저장
1441
                    markup_info_version = new MARKUP_INFO_VERSION()
1442
                    {
1443
                        ID = UserState.MarkupVersionID,
1444
                        MARKUPINFO_ID = markup_info.ID,
1445
                        CREATE_DATE = DateTime.Now
1446
                    };
1447
                    Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version);
1448
                    Entity.SaveChanges();
1449
                }
1450
                #endregion
1451
1452
1453
                Entity.MARKUP_DATA.Where(data =>  data.PAGENUMBER == PageNo && data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item =>
1454
                {
1455
                    Entity.MARKUP_DATA.DeleteObject(item);
1456
                });
1457
                Entity.SaveChanges();
1458 2ab012e8 djkim
1459
                try
1460
                {
1461
                    mlmarkup_data.ForEach(value =>
1462
                    {
1463
                        Entity.MARKUP_DATA.AddObject(new MARKUP_DATA
1464
                        {
1465
                            ID = value.ID,
1466
                            DATA = value.DATA,
1467
                            DATA_TYPE = value.DATA_TYPE,
1468
                            PAGENUMBER = value.PAGENUMBER,
1469 c8e9b3e4 ljiyeon
                            MARKUPINFO_VERSION_ID = markup_info_version.ID,
1470 53880c83 ljiyeon
                            SYMBOL_ID = value.SYMBOL_ID,
1471 c0977e97 djkim
                            //GROUP_ID = value.GROUP_ID
1472 2ab012e8 djkim
                        });
1473
                    });
1474
                    Entity.SaveChanges();
1475
                }
1476 0585d5cc taeseongkim
                catch (Exception ex)
1477 2ab012e8 djkim
                {
1478 0585d5cc taeseongkim
                    System.Diagnostics.Debug.WriteLine("KCOM_API - SavePageMarkupData set mlmarkup_data : " + ex.ToString());
1479 2ab012e8 djkim
                    return false;
1480
                }
1481
            }
1482
            return true;
1483
        }
1484
1485 c0977e97 djkim
        //[OperationContract]
1486
        //public long AddMarkupDataGroup(MARKUP_DATA_GROUP mARKUP_DATA_GROUP, string ProjectNo)
1487
        //{
1488
        //    try
1489
        //    {
1490
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1491
        //        {
1492
        //            Entity.AddToMARKUP_DATA_GROUP(mARKUP_DATA_GROUP);
1493
        //            //MARKUP_DATA_GROUP tt = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == id).FirstOrDefault();
1494
        //            Entity.SaveChanges();
1495 53880c83 ljiyeon
1496 c0977e97 djkim
        //            return Entity.MARKUP_DATA_GROUP.ToList().LastOrDefault().ID;
1497
        //        }
1498
        //    }
1499 24c5e56c taeseongkim
        //    catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1500 c0977e97 djkim
        //    {
1501
        //        return 0;
1502
        //    }
1503
        //}
1504
        //[OperationContract]
1505
        //public bool UpdateMarkupDataGroup(long Group_ID, string ProjectNo)
1506
        //{
1507
        //    try
1508
        //    {
1509
        //        using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
1510
        //        {
1511
        //            var UpdateItem = Entity.MARKUP_DATA_GROUP.Where(info => info.ID == Group_ID).FirstOrDefault();
1512
        //            UpdateItem.STATE = 1;
1513
        //            Entity.SaveChanges();
1514
        //        }
1515
        //    }
1516 24c5e56c taeseongkim
        //    catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1517 c0977e97 djkim
        //    {
1518
        //        return false;
1519
        //    }
1520
        //    return true;
1521
        //}
1522 53880c83 ljiyeon
        [OperationContract]
1523
        public bool UpdateMarkupData(string CommentID, long Group_ID, string ProjectNo)
1524
        {
1525
            try
1526
            {
1527 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1528
                using (CIEntities Entity = new CIEntities(sCIConnString))
1529 53880c83 ljiyeon
                {
1530
                    var UpdateItem = Entity.MARKUP_DATA.Where(info => info.ID == CommentID).FirstOrDefault();
1531 c0977e97 djkim
                    //UpdateItem.GROUP_ID = Group_ID;
1532 53880c83 ljiyeon
                    Entity.SaveChanges();
1533
                }
1534
            }
1535 0585d5cc taeseongkim
            catch (Exception ex)
1536 53880c83 ljiyeon
            {
1537 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - UpdateMarkupData: " + ex.ToString());
1538 53880c83 ljiyeon
                return false;
1539
            }
1540
            return true;
1541
        }
1542 2ab012e8 djkim
1543
        [OperationContract]
1544
        public bool SaveSymbol(SYMBOL_PRIVATE symbol_private)
1545
        {
1546
            try
1547
            {
1548 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1549
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
1550 2ab012e8 djkim
                {
1551
                    uc.AddToSYMBOL_PRIVATE(symbol_private);
1552
                    uc.SaveChanges();
1553
                }
1554
            }
1555 0585d5cc taeseongkim
            catch (Exception ex)
1556 2ab012e8 djkim
            {
1557 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - SaveSymbol: " + ex.ToString());
1558 2ab012e8 djkim
                return false;
1559
            }
1560
            return true;
1561
        }
1562
        [OperationContract]
1563 498f0fc9 ljiyeon
        public bool AddPublicSymbol(SYMBOL_PUBLIC symbol)
1564
        {
1565
            try
1566
            {
1567 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1568
                using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
1569 498f0fc9 ljiyeon
                {
1570
                    uc.AddToSYMBOL_PUBLIC(symbol);
1571
                    uc.SaveChanges();
1572
                }
1573
            }
1574 0585d5cc taeseongkim
            catch (Exception ex)
1575 498f0fc9 ljiyeon
            {
1576 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - AddPublicSymbol: " + ex.ToString());
1577 498f0fc9 ljiyeon
                return false;
1578
            }
1579
            return true;
1580
        }
1581
        [OperationContract]
1582
        public bool DeleteSymbol(string symbol_id, int type)
1583 2ab012e8 djkim
        {
1584
            try
1585
            {
1586 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1587
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
1588 2ab012e8 djkim
                {
1589 498f0fc9 ljiyeon
                    if (type == 0)
1590
                    {
1591
                        string delItem_ID = symbol_id;
1592
                        var delitem = Entity.SYMBOL_PRIVATE.Where(data => data.ID == delItem_ID).FirstOrDefault();
1593
                        Entity.SYMBOL_PRIVATE.DeleteObject(delitem);
1594
                        Entity.SaveChanges();
1595
                    }
1596
                    else
1597
                    {
1598
                        string delItem_ID = symbol_id;
1599
                        var delitem = Entity.SYMBOL_PUBLIC.Where(data => data.ID == delItem_ID).FirstOrDefault();
1600
                        Entity.SYMBOL_PUBLIC.DeleteObject(delitem);
1601
                        Entity.SaveChanges();
1602
                    }
1603 2ab012e8 djkim
                }
1604
            }
1605 0585d5cc taeseongkim
            catch (Exception ex)
1606 2ab012e8 djkim
            {
1607 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - DeleteSymbol : " + ex.ToString());
1608
1609 2ab012e8 djkim
                return false;
1610
            }
1611
            return true;
1612
        }
1613
1614
        [OperationContract]
1615 498f0fc9 ljiyeon
        public bool RenameSymbol(string symbol_id, string name, int type)
1616 2ab012e8 djkim
        {
1617
            try
1618
            {
1619 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
1620
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
1621 2ab012e8 djkim
                {
1622 498f0fc9 ljiyeon
                    if (type == 0)
1623
                    {
1624
                        var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == symbol_id).FirstOrDefault();
1625
                        UpdateItem.NAME = name;
1626
                        Entity.SaveChanges();
1627
                    }
1628
                    else
1629
                    {
1630
                        var UpdateItem = Entity.SYMBOL_PUBLIC.Where(info => info.ID == symbol_id).FirstOrDefault();
1631
                        UpdateItem.NAME = name;
1632
                        Entity.SaveChanges();
1633
                    }
1634 2ab012e8 djkim
                }
1635
            }
1636 0585d5cc taeseongkim
            catch (Exception ex)
1637 2ab012e8 djkim
            {
1638 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - RenameSymbol: " + ex.ToString());
1639 2ab012e8 djkim
                return false;
1640
            }
1641
            return true;
1642
        }
1643
1644
        [OperationContract]
1645
        public bool AddCheckListHistory(string project_no, CHECK_LIST_HISTORY Check_History)
1646
        {
1647
            try
1648 ff01c725 humkyung
            {
1649
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1650
                using (CIEntities Entity = new CIEntities(sCIConnString))
1651 2ab012e8 djkim
                {
1652
                    Entity.CHECK_LIST_HISTORY.AddObject(Check_History);
1653
                    Entity.SaveChanges();  
1654
                }
1655
            }
1656 0585d5cc taeseongkim
            catch (Exception ex)
1657 2ab012e8 djkim
            {
1658 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - AddCheckListHistory: " + ex.ToString());
1659 2ab012e8 djkim
                return false;
1660
            }
1661
            return true;
1662
        }
1663
        [OperationContract]
1664
        public bool SaveCheckListHistory(string project_no, string rev, CHECK_LIST_HISTORY Check_History)
1665
        {
1666
            try
1667
            {
1668 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1669
                using (CIEntities Entity = new CIEntities(sCIConnString))
1670 2ab012e8 djkim
                {
1671
                    var item = Entity.CHECK_LIST_HISTORY.Where(info => info.REVISION == rev).FirstOrDefault();
1672
                    item = Check_History;
1673
                    Entity.SaveChanges();
1674
                }
1675
            }
1676 0585d5cc taeseongkim
            catch (Exception ex)
1677 2ab012e8 djkim
            {
1678 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("KCOM_API - SaveCheckListHistory: " + ex.ToString());
1679 2ab012e8 djkim
                return false;
1680
            }
1681
            return true;
1682
        }
1683
        [OperationContract]
1684
        public bool SaveCheckList(string project_no, string _id, CHECK_LIST Check_value)
1685
        {
1686
            try
1687
            {
1688 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1689
                using (CIEntities Entity = new CIEntities(sCIConnString))
1690 2ab012e8 djkim
                {
1691
                    var item = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1692
                    item.TODOLIST = Check_value.TODOLIST;
1693
                    item.REMARK = Check_value.REMARK;
1694
                    item.STATUS = Check_value.STATUS;
1695
                    item.VENDOR = Check_value.VENDOR;
1696
                    item.REPLY = Check_value.REPLY;
1697
                    item.IMAGE_URL = Check_value.IMAGE_URL;
1698
                    item.IMAGE_ANCHOR = Check_value.IMAGE_ANCHOR;
1699
                    item.UPDATE_TIME = Check_value.UPDATE_TIME;
1700 5de0c110 ljiyeon
                    if(Check_value.STATUS == "False")
1701
                    {
1702
                        item.STATUS_DESC_OPEN = Check_value.STATUS_DESC_OPEN;
1703
                    }
1704
                    else
1705
                    {
1706
                        item.STATUS_DESC_CLOSE = Check_value.STATUS_DESC_CLOSE;
1707
                    }                     
1708 2ab012e8 djkim
                    Entity.SaveChanges();
1709
                }
1710
            }
1711 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1712 2ab012e8 djkim
                return false;
1713
            }
1714
            return true;
1715
        }
1716
        [OperationContract]
1717
        public bool AddCheckList(string project_no, CHECK_LIST Check_value)
1718
        {
1719
            try
1720
            {
1721 24c5e56c taeseongkim
               
1722 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1723
                using (CIEntities Entity = new CIEntities(sCIConnString))
1724 2ab012e8 djkim
                {
1725
                    Entity.CHECK_LIST.AddObject(Check_value);
1726
                    Entity.SaveChanges();
1727
                }
1728
            }
1729 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1730 2ab012e8 djkim
                return false;
1731
            }
1732
            return true;
1733
        }
1734
1735
        [OperationContract]
1736
        public CHECK_LIST GetCheckList(string project_no, string _id)
1737
        {
1738
            CHECK_LIST Check_value = new CHECK_LIST();
1739
            try
1740
            {
1741 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1742
                using (CIEntities Entity = new CIEntities(sCIConnString))
1743 2ab012e8 djkim
                {
1744
                    Check_value = Entity.CHECK_LIST.Where(info => info.ID == _id).FirstOrDefault();
1745
                }
1746
            }
1747 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1748 2ab012e8 djkim
                return null;
1749
            }
1750
            return Check_value;
1751
        }
1752
        [OperationContract]
1753
        public List<CHECK_LIST> GetUserCheckList(string project_no, string user_id, string doc_no)
1754
        {
1755
            List<CHECK_LIST> list = new List<CHECK_LIST>();
1756
            try
1757
            {
1758 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1759
                using (CIEntities Entity = new CIEntities(sCIConnString))
1760 2ab012e8 djkim
                {
1761
                    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();
1762
                }
1763
            }
1764 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1765 2ab012e8 djkim
                return null;
1766
            }
1767
            return list;
1768
        }
1769
        [OperationContract]
1770
        public List<CHECK_LIST_HISTORY> GetCheckListHistory(string project_no, string _id)
1771
        {
1772
            List<CHECK_LIST_HISTORY> history = new List<CHECK_LIST_HISTORY>();
1773
            try
1774
            {
1775 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1776
                using (CIEntities Entity = new CIEntities(sCIConnString))
1777 2ab012e8 djkim
                {
1778
                    history = Entity.CHECK_LIST_HISTORY.Where(data => data.CHECKLIST_ID == _id).ToList();
1779
                }
1780
            }
1781 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1782 2ab012e8 djkim
                return null;
1783
            }
1784
            return history;
1785
        }
1786
        [OperationContract]
1787
        public CHECK_LIST_HISTORY GetCheckListHistoryFirstOrDefault(string project_no, string checklist_id, string rev)
1788
        {
1789
            CHECK_LIST_HISTORY Check_Item = new CHECK_LIST_HISTORY();
1790
            try
1791
            {
1792 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1793
                using (CIEntities Entity = new CIEntities(sCIConnString))
1794 2ab012e8 djkim
                {   
1795
                    Check_Item = Entity.CHECK_LIST_HISTORY.Where(info => info.CHECKLIST_ID == checklist_id && info.REVISION == rev).FirstOrDefault();
1796
                }
1797
            }
1798 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1799 2ab012e8 djkim
                return null;
1800
            }
1801
            return Check_Item;
1802
        }
1803
        [OperationContract]
1804
        public bool SavePageAngle(string project_no, List<DOCPAGE> _mldocpage)
1805
        {
1806
            try
1807
            {
1808 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1809
                using (CIEntities Entity = new CIEntities(sCIConnString))
1810 2ab012e8 djkim
                {
1811
                    KCOMDataModel.DataModel.DOCPAGE _docpage = new KCOMDataModel.DataModel.DOCPAGE();
1812
                    _mldocpage.ForEach(data =>
1813
                    {
1814
                        _docpage = (from info in Entity.DOCPAGE
1815
                                    where info.ID == data.ID
1816
                                    select info).FirstOrDefault();
1817
1818
                        if (_docpage.PAGE_ANGLE != data.PAGE_ANGLE)
1819
                        {
1820
                            _docpage.PAGE_ANGLE = data.PAGE_ANGLE;
1821
                        }
1822
                    });
1823
1824
                    Entity.SaveChanges();
1825
                }
1826
            }
1827 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1828 2ab012e8 djkim
                return false;
1829
            }
1830
            return true;
1831
        }
1832
1833
        [OperationContract]
1834
        public MARKUP_INFO GetMarkupInfo(string project_no, string _id)
1835
        {
1836
            MARKUP_INFO markupInfo = new MARKUP_INFO();
1837
1838
            try
1839
            {
1840 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1841
                using (CIEntities Entity = new CIEntities(sCIConnString))
1842 2ab012e8 djkim
                {
1843
                    markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1844
                }
1845
            }
1846 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1847 2ab012e8 djkim
                return null;
1848
            }
1849
            return markupInfo;
1850
        }
1851
1852
        [OperationContract]
1853
        public List<string> GetMarkupDataListperPage(string project_no, string _markupinfoid, int _pageNo)
1854
        {
1855
            List<string> markupdata = new List<string>();
1856
            MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION();
1857
            try
1858
            {
1859 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1860
                using (CIEntities Entity = new CIEntities(sCIConnString))
1861 2ab012e8 djkim
                {
1862
                    markup_info_version = (from version in Entity.MARKUP_INFO_VERSION
1863
                                           where version.MARKUPINFO_ID == _markupinfoid
1864
                                           orderby version.CREATE_DATE descending
1865
                                           select version).First();
1866
                    markupdata = (from data in Entity.MARKUP_DATA
1867
                                  where data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == _pageNo
1868
                                  select data.DATA).ToList();
1869
                }
1870
            }
1871 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1872 2ab012e8 djkim
                return null;
1873
            }
1874
            return markupdata;
1875
        }
1876
1877
        [OperationContract]
1878
        public bool AddMarkupInfo(string project_no, MARKUP_INFO value)
1879
        {
1880
            try
1881
            {
1882 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1883
                using (CIEntities Entity = new CIEntities(sCIConnString))
1884 2ab012e8 djkim
                {
1885
                    Entity.MARKUP_INFO.AddObject(value);
1886
                    Entity.SaveChanges();
1887
                }
1888
            }
1889 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1890 2ab012e8 djkim
                return false;
1891
            }
1892
            return true;
1893
        }
1894
1895
        [OperationContract]
1896
        public bool AddMarkupInfoVersion(string project_no, MARKUP_INFO_VERSION value)
1897
        {
1898
            try
1899
            {
1900 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1901
                using (CIEntities Entity = new CIEntities(sCIConnString))
1902 2ab012e8 djkim
                {
1903
                    Entity.MARKUP_INFO_VERSION.AddObject(value);
1904
                    Entity.SaveChanges();
1905
                }
1906
            }
1907 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1908 2ab012e8 djkim
                return false;
1909
            }
1910
            return true;
1911
        }
1912
1913
        [OperationContract]
1914
        public bool AddMarkupData(string project_no, MARKUP_DATA value)
1915
        {
1916
            try
1917
            {
1918 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1919
                using (CIEntities Entity = new CIEntities(sCIConnString))
1920 2ab012e8 djkim
                {
1921
                    Entity.MARKUP_DATA.AddObject(value);
1922
                    Entity.SaveChanges();
1923
                }
1924
            }
1925 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1926 2ab012e8 djkim
                return false;
1927
            }
1928
            return true;
1929
        }
1930
1931
        [OperationContract]
1932
        public bool AvoidMarkupInfo(string project_no, string _doc_id)
1933
        {
1934
            try
1935
            {
1936 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1937
                using (CIEntities Entity = new CIEntities(sCIConnString))
1938 2ab012e8 djkim
                {
1939
                    var item = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1940
                    item.AVOID_CONSOLIDATE = 1;
1941
                    Entity.SaveChanges();
1942
                }
1943
            }
1944 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1945 2ab012e8 djkim
                return false;
1946
            }
1947
            return true;
1948
        }
1949
1950
        [OperationContract]
1951
        public bool SaveMarkupInfo(string project_no, string _id, MARKUP_INFO value)
1952
        {
1953
            try
1954
            {
1955 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1956
                using (CIEntities Entity = new CIEntities(sCIConnString))
1957 2ab012e8 djkim
                {
1958
                    var item = Entity.MARKUP_INFO.Where(info => info.ID == _id).FirstOrDefault();
1959
                    item = value;                    
1960
                    Entity.SaveChanges();
1961
                }
1962
            }
1963 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1964 2ab012e8 djkim
                return false;
1965
            }
1966
            return true;
1967
        }
1968
        [OperationContract]
1969
        public List<MARKUP_DATA> GetMarkupDataList(string project_no, string _versionid)
1970
        {
1971
            List<MARKUP_DATA> mlresult = new List<MARKUP_DATA>();
1972
1973
            try
1974
            {
1975 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1976
                using (CIEntities Entity = new CIEntities(sCIConnString))
1977 2ab012e8 djkim
                {
1978
                    mlresult = Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == _versionid).ToList();
1979
                }
1980
            }
1981 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
1982 2ab012e8 djkim
                return null;
1983
            }
1984
            return mlresult;
1985
        }
1986
1987
        [OperationContract]
1988
        public bool Consolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
1989
        {
1990
            try
1991
            {
1992
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
1993 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
1994
                using (CIEntities Entity = new CIEntities(sCIConnString))
1995 2ab012e8 djkim
                {
1996 0c624340 djkim
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.CONSOLIDATE == 1).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
1997
                    if (markupInfo != null)
1998 2ab012e8 djkim
                    {
1999
                        markupInfo.AVOID_CONSOLIDATE = 1;
2000
                    }
2001
2002
                    foreach (MarkupInfoItem item in markupInfoItems)
2003
                    {
2004
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2005
                        {
2006
                            instanceDataSet.Add(d);
2007
                        });
2008
                    }
2009
2010
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2011
                    info.ID = shortGuid();
2012
                    info.CONSOLIDATE = 1;
2013
                    info.CREATE_TIME = DateTime.Now;
2014
                    info.DOCINFO_ID = _doc_id;
2015
                    info.UPDATE_TIME = DateTime.Now;
2016
                    info.USER_ID = _user_id;
2017
                    info.AVOID_CONSOLIDATE = 0;
2018
2019
                    Entity.MARKUP_INFO.AddObject(info);
2020 6a19b48d taeseongkim
         
2021 2ab012e8 djkim
2022
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2023
                    {
2024
                        ID = shortGuid(),
2025
                        CREATE_DATE = DateTime.Now,
2026
                        MARKUP_INFO = info,
2027
                    };
2028
2029
                    foreach (var item in instanceDataSet)
2030
                    {
2031
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2032
                        {
2033
                            ID = shortGuid(),
2034
                            DATA = item.DATA,
2035
                            DATA_TYPE = item.DATA_TYPE,
2036
                            PAGENUMBER = item.PAGENUMBER,
2037 c8e9b3e4 ljiyeon
                            MARKUP_INFO_VERSION = info2,
2038 53880c83 ljiyeon
                            SYMBOL_ID = item.SYMBOL_ID,
2039 c0977e97 djkim
                            //GROUP_ID = item.GROUP_ID
2040 2ab012e8 djkim
                        });
2041
                    }
2042
2043 6a19b48d taeseongkim
                    Entity.SaveChanges();
2044 2ab012e8 djkim
                }
2045
            }
2046 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2047 2ab012e8 djkim
                return false;
2048
            }
2049
            return true;
2050
        }
2051
2052 49d444ef ljiyeon
2053
        [OperationContract]
2054
        public FinalPDFResult ConsolidateMergedPDF(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems, string ProjectNo, string DocInfoID, string CreateUserID)
2055
        {
2056
            bool consolidate = false;
2057
            try
2058
            {
2059
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
2060 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2061
                using (CIEntities Entity = new CIEntities(sCIConnString))
2062 49d444ef ljiyeon
                {
2063
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
2064
                    if (markupInfo.CONSOLIDATE == 1)
2065
                    {
2066
                        markupInfo.AVOID_CONSOLIDATE = 1;
2067
                    }
2068
2069
                    foreach (MarkupInfoItem item in markupInfoItems)
2070
                    {
2071
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2072
                        {
2073
                            instanceDataSet.Add(d);
2074
                        });
2075
                    }
2076
2077
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2078
                    info.ID = shortGuid();
2079
                    info.CONSOLIDATE = 1;
2080
                    info.CREATE_TIME = DateTime.Now;
2081
                    info.DOCINFO_ID = _doc_id;
2082
                    info.UPDATE_TIME = DateTime.Now;
2083
                    info.USER_ID = _user_id;
2084
                    info.AVOID_CONSOLIDATE = 0;
2085
2086
                    Entity.MARKUP_INFO.AddObject(info);
2087
                    Entity.SaveChanges();
2088
2089
2090
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2091
                    {
2092
                        ID = shortGuid(),
2093
                        CREATE_DATE = DateTime.Now,
2094
                        MARKUP_INFO = info,
2095
                    };
2096
                    Entity.SaveChanges();
2097
2098
                    foreach (var item in instanceDataSet)
2099
                    {
2100
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2101
                        {
2102
                            ID = shortGuid(),
2103
                            DATA = item.DATA,
2104
                            DATA_TYPE = item.DATA_TYPE,
2105
                            PAGENUMBER = item.PAGENUMBER,
2106
                            MARKUP_INFO_VERSION = info2,
2107 53880c83 ljiyeon
                            SYMBOL_ID = item.SYMBOL_ID,
2108 c0977e97 djkim
                            //GROUP_ID = item.GROUP_ID
2109 49d444ef ljiyeon
                        });
2110
                    }
2111
                    Entity.SaveChanges();
2112
2113
2114
                }
2115
                consolidate = true;
2116
            }
2117 24c5e56c taeseongkim
            catch (Exception ex)
2118 49d444ef ljiyeon
            {
2119 24c5e56c taeseongkim
                System.Diagnostics.Debug.WriteLine(ex);
2120 49d444ef ljiyeon
                consolidate = false;
2121
            }
2122 24c5e56c taeseongkim
2123 49d444ef ljiyeon
            FinalPDFResult _result = new FinalPDFResult();
2124
            if (consolidate == true)
2125
            {
2126
                RemFinalPDFObject remObj = null;
2127
                try
2128
                {
2129
                    string _finalID = shortGuid();
2130
                    int _DocTotalPages = -1;
2131
                    string docItemId;
2132
2133 ff01c725 humkyung
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2134
                    using (CIEntities _ci = new CIEntities(sCIConnString))
2135 49d444ef ljiyeon
                    {
2136
                        var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
2137
2138
                        if (_doc.Count() > 0)
2139
                        {
2140
                            _DocTotalPages = _doc.First().PAGE_COUNT;
2141
                            docItemId = _doc.First().DOCUMENT_ID;
2142
                        }
2143
                        else
2144
                        {
2145
                            _result.Status = FinalStatus.Error;
2146
                            _result.Exception = "페이지 정보를 가져올 수 없습니다.";
2147
                            return _result;
2148
                        }
2149
                    }
2150
2151
                    var Items = GetMarkupInfoItems(ProjectNo, DocInfoID);
2152
                    if (_DocTotalPages > 0)
2153
                    {
2154
                        var item2 = Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
2155
                        FINAL_PDF fm = new FINAL_PDF()
2156
                        {
2157
                            ID = _finalID,
2158
                            PROJECT_NO = ProjectNo,
2159
                            DOCINFO_ID = DocInfoID,
2160
                            DOCUMENT_ID = docItemId,
2161
                            MARKUPINFO_ID = item2.MarkupInfoID,
2162
                            CREATE_USER_ID = CreateUserID,
2163
                            TOTAL_PAGE = _DocTotalPages,
2164
                            CREATE_DATETIME = DateTime.Now,
2165
                            STATUS = (int)IFinalPDF.FinalStatus.Insert
2166
                        };
2167 ff01c725 humkyung
2168
                        string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2169
                        using (KCOMEntities _entity = new KCOMEntities(sConnString))
2170 49d444ef ljiyeon
                        {
2171
                            _entity.AddToFINAL_PDF(fm);
2172
                            _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
2173
                        };
2174
2175
                        System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
2176
                        if (_ch == null)
2177
                        {
2178
                            chan = new TcpChannel();
2179
                            _ChanID = chan.ChannelName;
2180
                            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
2181
                            // Create an instance of the remote object
2182
2183 ff01c725 humkyung
                            using (KCOMEntities ec = new KCOMEntities(sConnString))
2184 49d444ef ljiyeon
                            {
2185
2186
                                //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2187
                                //                          "tcp://localhost:9092/remFinalPDF");
2188
                                remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
2189
                                                          //"tcp://192.168.0.67:9092/remFinalPDF");
2190
                                                          "tcp://192.168.0.67:9092/remFinalPDF");
2191
                            }
2192
2193
                            //"tcp://localhost:8080/remFinalPDF");
2194
2195
                            _result = remObj.SetFinalPDF(ProjectNo, _finalID);
2196
                            _result.FinalID = _finalID;
2197
                            _result.Status = FinalStatus.Success;
2198
2199
                            //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
2200
                            //fa.MakeFinalPDF(fm);
2201
                        }
2202
                        else
2203
                        {
2204
                            _ChanID = _ch.ChannelName;
2205
                        }
2206
                    }
2207
                }
2208
                catch (Exception ex)
2209
                {
2210
                    _result.Status = FinalStatus.Error;
2211
2212
                    if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
2213
                        _result.Exception = "Final Server Not Connection";
2214
                }
2215
                finally
2216
                {
2217
                    remObj = null;
2218
                    if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
2219
                        System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
2220
2221
                    GC.Collect(2);
2222
                }
2223
            }
2224
            return _result;
2225
        }
2226 2ab012e8 djkim
        [OperationContract]
2227 04a7385a djkim
        public bool TeamConsolidate(string project_no, string _user_id, string _doc_id, List<MarkupInfoItem> markupInfoItems)
2228
        {
2229
            try
2230
            {
2231
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
2232 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2233
                using (CIEntities Entity = new CIEntities(sCIConnString))
2234 04a7385a djkim
                {
2235 285635d3 taeseongkim
                    var members = GetMemberQuery(Entity, _user_id);
2236
2237
                    string user_dept = "";
2238
2239
                    if(members.Count() > 0)
2240
                    {
2241
                        user_dept = members.First().DEPARTMENT;
2242
                    }
2243
                    
2244
                    var markupInfos = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _doc_id && entity.PART_CONSOLIDATE == 1)
2245
                                        .OrderByDescending(j => j.CREATE_TIME).ToList();
2246
2247 0c624340 djkim
                    foreach (var markupinfo in markupInfos)
2248 04a7385a djkim
                    {
2249 285635d3 taeseongkim
                        string markupdept = "";
2250
2251
                        var markupMembers = GetMemberQuery(Entity, markupinfo.USER_ID);
2252
2253
                        if (markupMembers.Count() > 0)
2254
                        {
2255
                            markupdept = markupMembers.First().DEPARTMENT;
2256
                        }
2257
2258 0c624340 djkim
                        if (user_dept == markupdept)
2259
                        {
2260
                            markupinfo.AVOID_CONSOLIDATE = 1;
2261
                        }
2262 04a7385a djkim
                    }
2263
2264
                    foreach (MarkupInfoItem item in markupInfoItems)
2265
                    {
2266
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
2267
                        {
2268
                            instanceDataSet.Add(d);
2269
                        });
2270
                    }
2271
2272
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
2273
                    info.ID = shortGuid();
2274
                    info.PART_CONSOLIDATE = 1;
2275
                    info.CREATE_TIME = DateTime.Now;
2276
                    info.DOCINFO_ID = _doc_id;
2277
                    info.UPDATE_TIME = DateTime.Now;
2278
                    info.USER_ID = _user_id;
2279
                    info.AVOID_CONSOLIDATE = 0;
2280
2281
                    Entity.MARKUP_INFO.AddObject(info);
2282
                    Entity.SaveChanges();
2283
2284
2285
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
2286
                    {
2287
                        ID = shortGuid(),
2288
                        CREATE_DATE = DateTime.Now,
2289
                        MARKUP_INFO = info,
2290
                    };
2291
                    Entity.SaveChanges();
2292
2293
                    foreach (var item in instanceDataSet)
2294
                    {
2295
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
2296
                        {
2297
                            ID = shortGuid(),
2298
                            DATA = item.DATA,
2299
                            DATA_TYPE = item.DATA_TYPE,
2300
                            PAGENUMBER = item.PAGENUMBER,
2301 c8e9b3e4 ljiyeon
                            MARKUP_INFO_VERSION = info2,
2302 53880c83 ljiyeon
                            SYMBOL_ID = item.SYMBOL_ID,
2303 c0977e97 djkim
                            //GROUP_ID = item.GROUP_ID
2304 04a7385a djkim
                        });
2305
                    }
2306
                    Entity.SaveChanges();
2307
2308
2309
                }
2310
            }
2311 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2312 04a7385a djkim
                return false;
2313
            }
2314
            return true;
2315
        }
2316
2317
        [OperationContract]
2318 2ab012e8 djkim
        [ServiceKnownType(typeof(MEMBER))]
2319
        public MEMBER GetMember(string project_no, string user_id)
2320
        {
2321 503cb09e taeseongkim
            MEMBER rstmember = null;
2322 2ab012e8 djkim
            try
2323
            {
2324 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2325
                using (CIEntities Entity = new CIEntities(sCIConnString))
2326 2ab012e8 djkim
                {
2327 285635d3 taeseongkim
                    var members = GetMemberQuery(Entity, user_id);
2328 503cb09e taeseongkim
2329 285635d3 taeseongkim
                    if(members.Count() > 0)
2330
                    {
2331
                        rstmember = members.First();
2332
                    }
2333
                }
2334
            }
2335
            catch (Exception ex)
2336
            {
2337
                return null;
2338
            }
2339
            return rstmember;
2340
        }
2341 503cb09e taeseongkim
2342 285635d3 taeseongkim
        private  List<MEMBER> GetMemberQuery(System.Data.Objects.ObjectContext context, string UserID)
2343
        {
2344
            List<MEMBER> result = new List<MEMBER>();
2345 503cb09e taeseongkim
2346 285635d3 taeseongkim
            try
2347
            {
2348
                string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
2349
2350
                var param = new[] { new System.Data.Objects.ObjectParameter("userId", UserID) };
2351
2352
                System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery
2353
                              = context.CreateQuery<System.Data.Common.DbDataRecord>(query, param);
2354
2355
                if (memberQuery.Count() > 0)
2356
                {
2357
                    foreach (var dataRecord in memberQuery)
2358 503cb09e taeseongkim
                    {
2359 285635d3 taeseongkim
                        MEMBER member = new MEMBER();
2360
2361
                        string userName = dataRecord["NAME"]?.ToString().Trim();
2362
                        string ID = dataRecord["ID"]?.ToString().Trim();
2363
                        string depatment = dataRecord["DEPARTMENT"]?.ToString().Trim();
2364 a7372e37 taeseongkim
2365 285635d3 taeseongkim
                        member.NAME = userName;
2366
                        member.ID = ID;
2367
                        member.DEPARTMENT = depatment;
2368 503cb09e taeseongkim
2369 285635d3 taeseongkim
                        result.Add(member);
2370 503cb09e taeseongkim
                    }
2371 2ab012e8 djkim
                }
2372
            }
2373 ff01c725 humkyung
            catch (Exception ex)
2374 2ab012e8 djkim
            {
2375 285635d3 taeseongkim
                throw new Exception("GetMember(System.Data.Objects.ObjectContext context, string UserID) " , ex);
2376 2ab012e8 djkim
            }
2377 285635d3 taeseongkim
2378
            return result;
2379 2ab012e8 djkim
        }
2380
2381 ff01c725 humkyung
        [WebMethod]
2382 2ab012e8 djkim
        [OperationContract]
2383
        public List<SYMBOL_PRIVATE> GetSymbolList(string user_id)
2384
        {
2385
            List<SYMBOL_PRIVATE> Custom_List = new List<SYMBOL_PRIVATE>();
2386
            try
2387
            {
2388 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2389
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2390 2ab012e8 djkim
                {
2391
                    Custom_List = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == user_id).ToList();
2392
                }
2393
            }
2394 ff01c725 humkyung
            catch (Exception ex)
2395 2ab012e8 djkim
            {
2396
                return null;
2397
            }
2398
            return Custom_List;
2399
        }
2400
        [OperationContract]
2401
        public List<string> GetPublicSymbolDeptList()
2402
        {
2403
            List<string> Custom_List = new List<string>();
2404
            try
2405
            {
2406 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2407
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2408 2ab012e8 djkim
                {
2409 b3251eea ljiyeon
                    Custom_List = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).Distinct().ToList();
2410 2ab012e8 djkim
                }
2411
            }
2412 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2413 2ab012e8 djkim
                return null;
2414
            }
2415
            return Custom_List;
2416
        }
2417
        [OperationContract]
2418
        public List<SYMBOL_PUBLIC> GetPublicSymbolList(string dept)
2419
        {
2420
            List<SYMBOL_PUBLIC> Custom_List = new List<SYMBOL_PUBLIC>();
2421
            try
2422
            {
2423 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2424
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2425 2ab012e8 djkim
                {
2426
                    if(!string.IsNullOrEmpty(dept))
2427
                    {
2428
                        Custom_List = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == dept).ToList();
2429
                    }
2430
                    else
2431
                    {
2432
                        Custom_List = Entity.SYMBOL_PUBLIC.ToList();
2433
                    }
2434
                    
2435
                }
2436
            }
2437 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2438 2ab012e8 djkim
                return null;
2439
            }
2440
            return Custom_List;
2441
        }
2442
2443
        /// <summary>
2444
        /// 
2445
        /// </summary>
2446
        /// <param name="id">symbol id</param>
2447
        /// <param name="type"> 0 : PRIVATE, 1 : PUBLIC</param>
2448
        /// <returns></returns>
2449
        [OperationContract]
2450
        public string GetSymbolData(string id, int type)
2451
        {
2452
            string result;
2453
            try
2454
            {
2455 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2456
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2457 2ab012e8 djkim
                {
2458
                    if(type == 0)
2459
                    {
2460
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA;
2461
                    }
2462
                    else
2463
                    {
2464
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA;
2465
                    }
2466
                }
2467
            }
2468 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2469 2ab012e8 djkim
                return null;
2470
            }
2471
            return result;
2472
        }
2473 53880c83 ljiyeon
        [OperationContract]
2474
        public string GetSymbolImageURL(string id, int type)
2475
        {
2476
            string result;
2477
            try
2478
            {
2479 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2480
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2481 53880c83 ljiyeon
                {
2482
                    if (type == 0)
2483
                    {
2484
                        result = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2485
                    }
2486
                    else
2487
                    {
2488
                        result = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().IMAGE_URL;
2489
                    }
2490
                }
2491
            }
2492 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2493 53880c83 ljiyeon
                return null;
2494
            }
2495
            return result;
2496
        }
2497 cf1cc862 taeseongkim
2498 2ab012e8 djkim
        [OperationContract]
2499
        public string GetSignData(string project_no, string user_id)
2500
        {
2501
            string result = null;
2502
            try
2503
            {
2504 dfb95d0f djkim
                string ifsign = getEnsembleSign(user_id);
2505
                if (string.IsNullOrEmpty(ifsign))
2506 2ab012e8 djkim
                {
2507 ff01c725 humkyung
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2508
                    var ModelWFConnectionString = sCIConnString;
2509 dfb95d0f djkim
                    if (null != ModelWFConnectionString)
2510 2ab012e8 djkim
                    {
2511 dfb95d0f djkim
                        using (CIEntities entity = new CIEntities(ModelWFConnectionString))
2512 2ab012e8 djkim
                        {
2513 dfb95d0f djkim
                            var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2514
                            if (_sign.Count() > 0)
2515
                            {
2516
                                result = _sign.First().SIGN_STR;
2517
                            }
2518
                            else
2519
                            {
2520
                                return null;
2521
                            }
2522 2ab012e8 djkim
                        }
2523
                    }
2524
                }
2525 dfb95d0f djkim
                else
2526
                {
2527
                    result = ifsign;
2528
                }
2529
2530 2ab012e8 djkim
            }
2531 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2532 2ab012e8 djkim
                return null;
2533
            }
2534
            return result;
2535
        }
2536
2537 cf1cc862 taeseongkim
        [OperationContract]
2538 74abcf6f taeseongkim
        public string GetSignStrokes(string project_no, string user_id)
2539
        {
2540
            string result = null;
2541
            try
2542
            {
2543
                string ifsign = getEnsembleSign(user_id);
2544
                if (string.IsNullOrEmpty(ifsign))
2545
                {
2546
                    string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2547
                    var ModelWFConnectionString = sCIConnString;
2548
                    if (null != ModelWFConnectionString)
2549
                    {
2550
                        using (CIEntities entity = new CIEntities(ModelWFConnectionString))
2551
                        {
2552
                            var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2553
                            if (_sign.Count() > 0)
2554
                            {
2555
                                result = _sign.First().SIGN_STROKES;
2556
                            }
2557
                            else
2558
                            {
2559
                                return null;
2560
                            }
2561
                        }
2562
                    }
2563
                }
2564
                else
2565
                {
2566
                    result = ifsign;
2567
                }
2568
2569
            }
2570
            catch (Exception ex)
2571
            {
2572
                System.Diagnostics.Debug.WriteLine(ex);
2573
                return null;
2574
            }
2575
            return result;
2576
        }
2577
2578
        [OperationContract]
2579
        public int SetSignData(string user_id,string SignStr,int CropX,int CropY,int CropWidth,int CropHeight)
2580 cf1cc862 taeseongkim
        {
2581
            int result = -1;
2582
2583
            try
2584
            {
2585
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2586
                   
2587
                using (CIEntities entity = new CIEntities(sCIConnString))
2588
                {
2589
                    var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2590
2591 74abcf6f taeseongkim
                    var cropImg = Convert.ToBase64String(SignatureCrop(SignStr, CropX, CropY, CropWidth, CropHeight));
2592
2593 cf1cc862 taeseongkim
                    if (_sign.Count() > 0)
2594
                    {
2595 74abcf6f taeseongkim
                        _sign.First().SIGN_STR = cropImg;
2596 cf1cc862 taeseongkim
                        _sign.First().MODIFY_DATE = DateTime.Now;
2597
                    }
2598
                    else
2599
                    {
2600
                        entity.SIGN_INFO.AddObject(new SIGN_INFO
2601
                        {
2602
                            ID = shortGuid(),
2603
                            MEMBER_USER_ID = user_id,
2604
                            CREATE_DATE = DateTime.Now,
2605 74abcf6f taeseongkim
                            SIGN_STR = cropImg
2606 cf1cc862 taeseongkim
                        });
2607
                    }
2608
2609
                    result = entity.SaveChanges();
2610
                }
2611
            }
2612
            catch (Exception ex)
2613
            {
2614
                System.Diagnostics.Debug.WriteLine(ex);
2615
            }
2616
            return result;
2617
        }
2618
2619 74abcf6f taeseongkim
2620
        [OperationContract]
2621
        public int SetSignStrokes(string user_id, string strokesData)
2622
        {
2623
            int result = -1;
2624
2625
            try
2626
            {
2627
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2628
2629
                using (CIEntities entity = new CIEntities(sCIConnString))
2630
                {
2631
                    var _sign = entity.SIGN_INFO.Where(sin => sin.MEMBER_USER_ID == user_id);
2632
2633
                    if (_sign.Count() > 0)
2634
                    {
2635
                        _sign.First().SIGN_STROKES = strokesData;
2636
                        _sign.First().MODIFY_DATE = DateTime.Now;
2637
                    }
2638
                    else
2639
                    {
2640
                        entity.SIGN_INFO.AddObject(new SIGN_INFO
2641
                        {
2642
                            ID = shortGuid(),
2643
                            MEMBER_USER_ID = user_id,
2644
                            CREATE_DATE = DateTime.Now,
2645
                            SIGN_STROKES = strokesData
2646
                    });
2647
                    }
2648
2649
                    result = entity.SaveChanges();
2650
                }
2651
            }
2652
            catch (Exception ex)
2653
            {
2654
                System.Diagnostics.Debug.WriteLine(ex);
2655
            }
2656
            return result;
2657
        }
2658
2659
        private byte[] SignatureCrop(string imgStr,int X,int Y,int Width,int Height)
2660
        {
2661
            using (System.IO.MemoryStream readStream = new System.IO.MemoryStream(Convert.FromBase64String(imgStr)))
2662
            {
2663
                using (System.Drawing.Image OriginalImage = System.Drawing.Image.FromStream(readStream))
2664
                {
2665
                    using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Width, Height))
2666
                    {
2667
                        bmp.SetResolution(OriginalImage.HorizontalResolution, OriginalImage.VerticalResolution);
2668
                        using (System.Drawing.Graphics Graphic = System.Drawing.Graphics.FromImage(bmp))
2669
                        {
2670
                            Graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
2671
                            Graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
2672
                            Graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
2673
                            Graphic.DrawImage(OriginalImage, new System.Drawing.Rectangle(0, 0, Width, Height), X, Y, Width, Height, System.Drawing.GraphicsUnit.Pixel);
2674
                            System.IO.MemoryStream ms = new System.IO.MemoryStream();
2675
                            bmp.Save(ms, OriginalImage.RawFormat);
2676
                            return ms.GetBuffer();
2677
                        }
2678
                    }
2679
                }
2680
            }
2681
        }
2682
2683 2ab012e8 djkim
        [OperationContract]        
2684
        public string GetProjectName(string project_no)
2685
        {
2686
            string result = null;
2687
2688
            try
2689
            {
2690 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2691
                using (KCOMDataModel.DataModel.KCOMEntities Entity = new KCOMDataModel.DataModel.KCOMEntities(sConnString))
2692 2ab012e8 djkim
                {
2693
                    result = Entity.RUN_PROJECTS.Where(i => i.PROJECT_NO == project_no).FirstOrDefault().PROJECT_NAME.ToString();
2694
                }
2695
            }
2696 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2697 2ab012e8 djkim
                return null;
2698
            }
2699
            return result;
2700
        }
2701
2702
        [OperationContract]
2703
        public List<DOCUMENT_ITEM> GetPreRevSelect(string project_no, string doc_no, string current_rev)
2704
        {
2705
            List<DOCUMENT_ITEM> result = new List<DOCUMENT_ITEM>();
2706
            
2707
            try
2708
            {
2709 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2710
                using (CIEntities Entity = new CIEntities(sCIConnString))
2711 2ab012e8 djkim
                {
2712
                    result = Entity.DOCUMENT_ITEM.Where(i => i.PROJECT_NO == project_no
2713
                    && i.DOCUMENT_NO == doc_no
2714
                    && i.REVISION != current_rev).OrderByDescending(i => i.GROUP_NO).ToList();
2715
                }
2716
            }
2717 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2718 2ab012e8 djkim
                return null;
2719
            }
2720
            return result;
2721
        }
2722
2723
        [OperationContract]
2724
        public DOCINFO GetDocInfoOneSelect(string project_no, string doc_id)
2725
        {
2726
            DOCINFO docinfo = null;
2727
2728
            try
2729
            {
2730 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2731
                using (CIEntities Entity = new CIEntities(sCIConnString))
2732 2ab012e8 djkim
                {
2733
                    docinfo = (from info in Entity.DOCINFO
2734
                              where info.DOCUMENT_ID == doc_id
2735
                              && info.PROJECT_NO == project_no
2736
                              select info).First();
2737
                }
2738
            }
2739 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2740 2ab012e8 djkim
                return null;
2741
            }
2742
            return docinfo;
2743
        }
2744
2745
        [OperationContract]
2746
        public List<MarkupInfoItem> GetPrintDocItemList(string project_no, string doc_id, List<MarkupInfoItem> _markupInfoList)
2747
        {
2748
            MarkupInfoItem _result = null;
2749
            List<MarkupInfoItem> markupinfo = new List<MarkupInfoItem>();
2750
            try
2751
            {
2752 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2753
                using (CIEntities Entity = new CIEntities(sCIConnString))
2754 2ab012e8 djkim
                {
2755
                    var docitem = (from info in Entity.DOCINFO
2756
                               where info.DOCUMENT_ID == doc_id
2757
                               && info.PROJECT_NO == project_no
2758
                               select info).First();
2759
2760
                    foreach (MARKUP_INFO markinfo in docitem.MARKUP_INFO)
2761
                    {
2762 285635d3 taeseongkim
                        var members = GetMemberQuery(Entity, markinfo.USER_ID);
2763
2764
                        MEMBER member = new MEMBER();
2765
2766
                        if (members.Count() > 0)
2767
                        {
2768
                            member = members.First();
2769
                        }
2770
2771 2ab012e8 djkim
                        string displaycolor = null;
2772 285635d3 taeseongkim
2773 2ab012e8 djkim
                        try
2774
                        {
2775
                            displaycolor = _markupInfoList.Where(info => info.MarkupInfoID == markinfo.ID).First().DisplayColor;
2776
                        }
2777 0585d5cc taeseongkim
                        catch (Exception ex)
2778 2ab012e8 djkim
                        {
2779 0585d5cc taeseongkim
                            System.Diagnostics.Debug.WriteLine("KCOM_API - GetPrintDocItemList displaycolor : " + ex.ToString());
2780
2781 2ab012e8 djkim
                            displaycolor = "#FFFFFF";
2782
                        }
2783
                        
2784
                        _result = new MarkupInfoItem
2785
                        {
2786
                            MarkupInfoID = markinfo.ID,
2787
                            Consolidate = markinfo.CONSOLIDATE,
2788
                            CreateTime = markinfo.UPDATE_TIME.HasValue ? markinfo.UPDATE_TIME.Value : markinfo.CREATE_TIME,
2789
                            DisplayColor = displaycolor,
2790
                            UserID = markinfo.USER_ID,
2791
                            UserName = member.NAME,
2792
                            Depatment = member.DEPARTMENT,
2793
                        };
2794
2795
                        _result.MarkupList = new List<IKCOM.MarkupItem>();
2796
                        var markup_Version = markinfo.MARKUP_INFO_VERSION.OrderByDescending(p => p.CREATE_DATE).First();
2797
2798
                        foreach (MARKUP_DATA markdata in markup_Version.MARKUP_DATA)
2799
                        {
2800
                            MarkupItem markitem = new MarkupItem()
2801
                            {
2802
                                ID = markdata.ID,
2803
                                PageNumber = markdata.PAGENUMBER,
2804
                            };
2805
                            _result.MarkupList.Add(markitem);
2806
                        }
2807
2808
                        _result.PageCount = _result.MarkupList.GroupBy(i => i.PageNumber).Count();
2809
2810
                        markupinfo.Add(_result);
2811
                    }
2812
                }
2813
            }
2814 285635d3 taeseongkim
            catch (Exception ex)
2815 2ab012e8 djkim
            {
2816
                return null;
2817
            }
2818
            return markupinfo;
2819
        }
2820 04a7385a djkim
2821
        [OperationContract]
2822
        public bool AddMessage(string project_no, TALK value)
2823
        {
2824
            try
2825
            {
2826 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2827
                using (CIEntities entity = new CIEntities(sCIConnString))
2828 04a7385a djkim
                {                    
2829
                    entity.TALK.AddObject(value);
2830
                    entity.SaveChanges();
2831
                }
2832
            }
2833 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2834 04a7385a djkim
                return false;
2835
            }
2836
            return true;
2837
        }
2838
2839
        [OperationContract]
2840
        public List<TALK> GetMessage(string project_no, string doc_id)
2841
        {
2842
            List<TALK> result = new List<TALK>();
2843
            try
2844
            {
2845 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2846
                using (CIEntities entity = new CIEntities(sCIConnString))
2847 04a7385a djkim
                {
2848
                    result = entity.TALK.Where(data => data.DOCUMENT_ID == doc_id).ToList();                        
2849
                }
2850
            }
2851 ff01c725 humkyung
            catch (Exception ex)
2852 04a7385a djkim
            {
2853
                return result;
2854
            }
2855
            return result;
2856
        }
2857 dfb95d0f djkim
2858
2859
        #region Legacy System I/F
2860
        /// <summary>
2861
        /// Ensemble+ Sign Data Return
2862
        /// </summary>
2863
        /// <param name="user_id"></param>
2864
        /// <returns></returns>
2865
        private string getEnsembleSign(string user_id)
2866
        {
2867 ac4f1e13 taeseongkim
            string result = null;
2868 dfb95d0f djkim
            string soapurl = string.Empty;
2869 ac4f1e13 taeseongkim
2870 dfb95d0f djkim
            try
2871
            {
2872 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
2873
                using (KCOMEntities Entity = new KCOMEntities(sConnString))
2874 dfb95d0f djkim
                {
2875
                    var item = Entity.PROPERTIES.Where(d => d.TYPE == "UpLoadServiceUrl").FirstOrDefault();
2876 ac4f1e13 taeseongkim
2877
                    if (item != null)
2878
                    {
2879
                        soapurl = item.VALUE;
2880
2881
                        WebClient webClient = new WebClient();
2882
                        string data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ens=\"http://EnsemblePlus.Webservice\"> <soapenv:Header/> <soapenv:Body> <ens:checkoutSignImage>"
2883
                            + "<ens:sUserNo>" + user_id + "</ens:sUserNo>"
2884
                            + "</ens:checkoutSignImage> </soapenv:Body></soapenv:Envelope>";
2885
                        webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
2886
                        webClient.Headers.Add("SOAPAction", "http://EnsemblePlus.Webservice");
2887
                        var _result = webClient.UploadString(new Uri(soapurl), data);
2888
                        XmlDocument xmlDoc = new XmlDocument();
2889
                        xmlDoc.LoadXml(_result);
2890
                        XmlNodeList list = xmlDoc.GetElementsByTagName("checkoutSignImageResponse");
2891
2892
                        foreach (XmlNode xn in list)
2893
                        {
2894
                            result = xn["checkoutSignImageReturn"].InnerText;
2895
                        }
2896
2897
                        if (result.Contains("No business object"))
2898
                        {
2899
                            result = null;
2900
                        }
2901
                    }
2902
                    else
2903
                    {
2904
                        result = null;
2905
                    }
2906 dfb95d0f djkim
                }
2907 ac4f1e13 taeseongkim
             
2908 dfb95d0f djkim
            }
2909
            catch (Exception ex)
2910 ac4f1e13 taeseongkim
            {   
2911
                result = null;
2912 dfb95d0f djkim
            }
2913
2914 ac4f1e13 taeseongkim
            return result;
2915 dfb95d0f djkim
        }
2916
        #endregion
2917 6c9fec59 djkim
2918
        #region Final Service
2919
        [OperationContract]
2920
        [ServiceKnownType(typeof(DOCINFO))]                
2921
        public DOCINFO FinalPDF_GetDocinfo(string project_no, string docinfo_id)
2922
        {
2923
            DOCINFO docinfo = null;
2924
2925
            try
2926
            {
2927 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2928
                using (CIEntities _entity = new CIEntities(sCIConnString))
2929 6c9fec59 djkim
                {
2930
                    var doc = _entity.DOCINFO.Where(x => x.ID == docinfo_id).FirstOrDefault();
2931
                    if(doc != null)
2932
                    {
2933
                        docinfo = new DOCINFO()
2934
                        {
2935
                            ID = doc.ID,
2936
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2937
                            PAGE_COUNT = doc.PAGE_COUNT,
2938
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2939
                            PROJECT_NO = doc.PROJECT_NO
2940
                        };
2941
                    }                    
2942
                }
2943
            }
2944 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2945 6c9fec59 djkim
                throw;
2946
            }
2947
            return docinfo;
2948
        }
2949
        [OperationContract]
2950
        [ServiceKnownType(typeof(DOCUMENT_ITEM))]
2951
        public DOCUMENT_ITEM FinalPDF_GetDocumentItem(string project_no, string document_id)
2952
        {
2953
            DOCUMENT_ITEM item = null;
2954
2955
            try
2956
            {
2957 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2958
                using (CIEntities _entity = new CIEntities(sCIConnString))
2959 6c9fec59 djkim
                {
2960 0585d5cc taeseongkim
                    var doc = _entity.DOCUMENT_ITEM.Where(x => x.PROJECT_NO == project_no &&  x.DOCUMENT_ID == document_id).FirstOrDefault();
2961 6c9fec59 djkim
                    if(doc != null)
2962
                    {
2963
                        item = new DOCUMENT_ITEM()
2964
                        {
2965
                            ID = doc.ID,
2966
                            ORIGINAL_FILE = doc.ORIGINAL_FILE,
2967
                            PROJECT_NO = doc.PROJECT_NO,
2968
                            DOCUMENT_ID = doc.DOCUMENT_ID,
2969
                            DOCUMENT_NO = doc.DOCUMENT_NO,
2970
                            DOCUMENT_NAME = doc.DOCUMENT_NAME,
2971 ab5aa762 taeseongkim
                            //ENSEMBLEINFO_URL = doc.ENSEMBLEINFO_URL,
2972 6c9fec59 djkim
                            GROUP_NO = doc.GROUP_NO,
2973
                            RESULT = doc.RESULT,
2974
                            REVISION = doc.REVISION,
2975
                            RESULT_FILE = doc.RESULT_FILE
2976
                        };
2977
                    }
2978
                    
2979
                }
2980
            }
2981 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
2982 6c9fec59 djkim
                throw;
2983
            }
2984
            return item;
2985
        }
2986
        [OperationContract]
2987
        [ServiceKnownType(typeof(MARKUP_DATA))]
2988
        public List<MARKUP_DATA> FinalPDF_GetMarkupdata(string project_no, string docinfo_id)
2989
        {
2990
            List<MARKUP_DATA> results = new List<MARKUP_DATA>();
2991
2992
            try
2993
            {
2994 c0977e97 djkim
                //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
2995 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
2996
                using (CIEntities _entity = new CIEntities(sCIConnString))
2997 6c9fec59 djkim
                {
2998
                    var datas = _entity.MARKUP_DATA.Where(x => x.MARKUP_INFO_VERSION.MARKUP_INFO.DOCINFO_ID == docinfo_id
2999
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.CONSOLIDATE == 1
3000
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.AVOID_CONSOLIDATE == 0
3001
                    && x.MARKUP_INFO_VERSION.MARKUP_INFO.PART_CONSOLIDATE == 0).ToList();
3002
                    foreach (var data in datas)
3003
                    {
3004
                        MARKUP_DATA d = new MARKUP_DATA()
3005
                        {
3006
                            ID = data.ID,
3007 c0977e97 djkim
                            //GROUP_ID = data.GROUP_ID,
3008 6c9fec59 djkim
                            SYMBOL_ID = data.SYMBOL_ID,
3009
                            DATA = data.DATA,
3010 abaa85b4 djkim
                            DATA_TYPE = data.DATA_TYPE,
3011
                            MARKUPINFO_VERSION_ID = data.MARKUPINFO_VERSION_ID,
3012
                            PAGENUMBER = data.PAGENUMBER
3013 6c9fec59 djkim
                        };
3014
                        results.Add(d);
3015
                    }
3016
                }
3017
            }
3018 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3019 6c9fec59 djkim
                throw;
3020
            }
3021
            return results;
3022
        }
3023
        [OperationContract]
3024
        [ServiceKnownType(typeof(MARKUP_INFO))]
3025
        public MARKUP_INFO FinalPDF_GetMarkupinfo(string project_no, string docinfo_id)
3026
        {
3027
            MARKUP_INFO markupInfo = null;
3028
3029
            try
3030
            {
3031 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3032
                using (CIEntities _entity = new CIEntities(sCIConnString))
3033 6c9fec59 djkim
                {
3034
                    var tmp = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == docinfo_id && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0).FirstOrDefault();
3035
                    if (tmp != null)
3036
                    {
3037
                        markupInfo = new MARKUP_INFO()
3038
                        {
3039
                            ID = tmp.ID,
3040
                            DOCINFO_ID = tmp.DOCINFO_ID,
3041
                            USER_ID = tmp.USER_ID
3042
                        };
3043
                    }                    
3044
                }
3045
            }
3046 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3047 6c9fec59 djkim
                throw;
3048
            }
3049
            return markupInfo;
3050
        }
3051
        [OperationContract]
3052 abaa85b4 djkim
        [ServiceKnownType(typeof(FINAL_PDF))]
3053
        public List<FINAL_PDF> FinalPDF_GetFinalPDFs(string final_id)
3054
        {
3055
            List<FINAL_PDF> results = new List<FINAL_PDF>();
3056
3057
            try
3058
            {
3059 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3060
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3061 abaa85b4 djkim
                {
3062
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == final_id).ToList();
3063
                    foreach(var final in finalList)
3064
                    {
3065
                        FINAL_PDF pdf = new FINAL_PDF()
3066
                        {
3067
                            ID = final.ID,
3068
                            DOCINFO_ID = final.DOCINFO_ID,
3069
                            DOCUMENT_ID = final.DOCUMENT_ID,
3070
                            STATUS = final.STATUS,
3071
                            CURRENT_PAGE = final.CURRENT_PAGE,
3072
                            CREATE_DATETIME = final.CREATE_DATETIME,
3073
                            START_DATETIME = final.START_DATETIME,
3074
                            END_DATETIME = final.END_DATETIME,
3075
                            EXCEPTION = final.EXCEPTION,
3076
                            PROJECT_NO = final.PROJECT_NO,
3077
                            TOTAL_PAGE = final.TOTAL_PAGE,
3078
                            MARKUPINFO_ID = final.MARKUPINFO_ID,
3079
                            CREATE_USER_ID = final.CREATE_USER_ID
3080
                        };
3081
                        results.Add(pdf);
3082
                    }
3083
                }
3084
            }
3085 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3086 abaa85b4 djkim
                throw;
3087
            }
3088
            return results;
3089
        }
3090
        [OperationContract]
3091 6c9fec59 djkim
        [ServiceKnownType(typeof(DOCPAGE))]
3092
        public List<DOCPAGE> FinalPDF_GetDocpage(string project_no, string docinfo_id)
3093
        {
3094
            List<DOCPAGE> results = new List<DOCPAGE>();
3095
3096
            try
3097
            {
3098 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3099
                using (CIEntities _entity = new CIEntities(sCIConnString))
3100 6c9fec59 djkim
                {
3101
                    var pages = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == docinfo_id).OrderBy(x => x.PAGE_NUMBER).ToList();
3102
                    foreach(var page in pages)
3103
                    {
3104
                        DOCPAGE p = new DOCPAGE()
3105
                        {
3106
                            PAGE_ANGLE = page.PAGE_ANGLE,
3107
                            PAGE_NUMBER = page.PAGE_NUMBER,
3108
                            PAGE_HEIGHT = page.PAGE_HEIGHT,
3109
                            PAGE_WIDTH = page.PAGE_WIDTH,
3110
                            DOCINFO_ID = page.DOCINFO_ID                            
3111
                        };
3112
                        results.Add(p);
3113
                    }                    
3114
                }
3115
            }
3116 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3117 6c9fec59 djkim
                throw;
3118
            }
3119
            return results;
3120
        }
3121 abaa85b4 djkim
        [OperationContract]        
3122
        public bool FinalPDF_SetFinalPDFStatus(string final_id, FinalStatus status)
3123
        {
3124
            bool result = false;
3125
3126
            try
3127
            {
3128 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3129
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3130 abaa85b4 djkim
                {
3131
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
3132
                    if(tmp != null)
3133
                    {
3134
                        switch(status)
3135
                        {
3136
                            case FinalStatus.Create:
3137
                                tmp.START_DATETIME = DateTime.Now;
3138
                                break;
3139
                            case FinalStatus.Success:
3140
                                tmp.END_DATETIME = DateTime.Now;
3141
                                tmp.EXCEPTION = string.Empty;
3142
                                break;                                
3143
                        }
3144
                        tmp.STATUS = (int)status;
3145
                        _entity.SaveChanges();
3146
                        result = true;                        
3147
                    }
3148
                }                    
3149
            }
3150 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3151 abaa85b4 djkim
                throw;
3152
            }
3153
            return result;
3154
        }
3155
3156 3c71b3a5 taeseongkim
        /// <summary>
3157
        /// 현재 진행중인 Final PDF 가 없거나 Success 일 경우에만 true return
3158
        /// </summary>
3159
        /// <param name="DocInfoID"></param>
3160
        /// <param name="MarkupInfoID"></param>
3161
        /// <param name="CreateUserID"></param>
3162
        /// <returns></returns>
3163 abaa85b4 djkim
        [OperationContract]
3164 3b62305d ljiyeon
        public bool FinalPDF_GetFinalPDFStatus(string DocInfoID, string MarkupInfoID, string CreateUserID)
3165
        {
3166
            bool result = false;
3167
3168
            try
3169
            {
3170 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3171
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3172 3b62305d ljiyeon
                {
3173 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();
3174 3b62305d ljiyeon
                    if (finalpdf != null)
3175
                    {
3176 3c71b3a5 taeseongkim
                        if (finalpdf.STATUS == (int)FinalStatus.Success)
3177 3b62305d ljiyeon
                        {
3178
                            result = true;
3179
                        }
3180
                    }
3181 3c71b3a5 taeseongkim
                    else
3182
                        result = true;
3183 3b62305d ljiyeon
                }
3184
            }
3185 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3186 3b62305d ljiyeon
                throw;
3187
            }
3188
            return result;
3189
        }
3190
3191
        [OperationContract]
3192 abaa85b4 djkim
        public bool FinalPDF_SetCurrentPage(string final_id, int currentpage)
3193
        {
3194
            bool result = false;
3195
3196
            try
3197
            {
3198 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3199
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3200 abaa85b4 djkim
                {
3201
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
3202
                    if (tmp != null)
3203
                    {
3204
                        tmp.CURRENT_PAGE = currentpage;
3205
                        _entity.SaveChanges();
3206
                        result = true;
3207
                    }
3208
                }
3209
            }
3210 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3211 abaa85b4 djkim
                throw;
3212
            }
3213
            return result;
3214
        }
3215
        [OperationContract]
3216
        public bool FinalPDF_SetError(string final_id, string msg)
3217
        {
3218
            bool result = false;
3219
3220
            try
3221
            {
3222 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3223
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3224 abaa85b4 djkim
                {
3225
                    var tmp = _entity.FINAL_PDF.Where(x => x.ID == final_id).FirstOrDefault();
3226
                    if (tmp != null)
3227
                    {                        
3228
                        tmp.STATUS = (int)FinalStatus.Error;
3229
                        tmp.EXCEPTION = DateTime.Now.ToShortDateString() + " " + msg;                        
3230
                        _entity.SaveChanges();
3231
                        result = true;
3232
                    }
3233
                }
3234
            }
3235 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3236 abaa85b4 djkim
                throw;
3237
            }
3238
            return result;
3239
        }
3240
3241
        [OperationContract]
3242
        public bool FinalPDF_SetFinalResultPath(string project_no, string document_id, string url)
3243
        {
3244
            bool result = false;
3245
3246
            try
3247
            {
3248 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3249
                using (CIEntities _entity = new CIEntities(sCIConnString))
3250 abaa85b4 djkim
                {
3251 0585d5cc taeseongkim
                    var item = _entity.DOCUMENT_ITEM.Where(d =>d.PROJECT_NO == project_no && d.DOCUMENT_ID == document_id).FirstOrDefault();
3252 abaa85b4 djkim
                    if (item != null)
3253
                    {
3254
                        item.RESULT_FILE = url;
3255
                        _entity.SaveChanges();
3256
                        result = true;
3257
                    }
3258
                }
3259
            }
3260 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3261 abaa85b4 djkim
                throw;
3262
            }
3263
            return result;
3264
        }
3265 bae83c92 taeseongkim
3266
        [OperationContract]
3267
        public bool SaveLog(string project_no, string document_id, string Log)
3268
        {
3269
            bool result = false;
3270
3271
            try
3272
            {
3273
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3274
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3275
                {
3276
                    _entity.AddToERROR_LOG(new ERROR_LOG
3277
                    {
3278
                        PROJECT_NO = project_no,
3279
                        DOCUMENT_ID = document_id,
3280
                        CONTENTS = Log,
3281
                        CREATE_DATETIME = DateTime.Now.ToString("yyMMddssmm"),
3282
                        CODE = "",
3283
                        TYPE = "Markus Log",
3284
                        LEVEL = "",
3285
                        SERVICE_NAME = "Markus",
3286
                    });
3287
3288
                    _entity.SaveChanges();
3289
                }
3290
            }
3291
            catch (Exception ex)
3292
            {
3293
            }
3294
3295
            return result;
3296
        }
3297
3298 abaa85b4 djkim
        [OperationContract]
3299
        [ServiceKnownType(typeof(MEMBER))]
3300
        public MEMBER FinalPDF_GetCommentMember(string project_no, string markupdata_id)
3301
        {
3302
            MEMBER member = null;
3303
            try
3304
            {
3305 ff01c725 humkyung
                string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
3306
                using (CIEntities _entity = new CIEntities(sCIConnString))
3307 abaa85b4 djkim
                {
3308
                    var data = _entity.MARKUP_DATA.Where(x => x.ID == markupdata_id).FirstOrDefault();
3309
                    string user_id = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
3310 285635d3 taeseongkim
3311
                    var person = GetMemberQuery(_entity,user_id);
3312
3313
                    if(person.Count() > 0)
3314 abaa85b4 djkim
                    {
3315 285635d3 taeseongkim
                        member = person.First();
3316 abaa85b4 djkim
                    }
3317
                }
3318
            }
3319 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3320 abaa85b4 djkim
                throw;
3321
            }
3322 285635d3 taeseongkim
3323 abaa85b4 djkim
            return member;
3324
        }
3325
3326
        [OperationContract]
3327
        [ServiceKnownType(typeof(PROPERTIES))]
3328
        public List<PROPERTIES> FinalPDF_GetProperties(string project_no)
3329
        {
3330
            List<PROPERTIES> results = new List<PROPERTIES>();
3331
            try
3332
            {
3333 ff01c725 humkyung
                string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
3334
                using (KCOMEntities _entity = new KCOMEntities(sConnString))
3335 abaa85b4 djkim
                {
3336
                    var _items = _entity.PROPERTIES.Where(x => x.PROPERTY == project_no).ToList();
3337
                    foreach(var item in _items)
3338
                    {
3339
                        PROPERTIES pROPERTIES = new PROPERTIES()
3340
                        {
3341
                            ID = item.ID,
3342
                            PROPERTY = item.PROPERTY,
3343
                            TYPE = item.TYPE,
3344
                            VALUE = item.VALUE
3345
                        };
3346
                        results.Add(pROPERTIES);
3347
                    }
3348
                }
3349
3350
            }
3351 24c5e56c taeseongkim
            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex);
3352 abaa85b4 djkim
                throw;
3353
            }
3354
            return results;
3355
        }
3356 6c9fec59 djkim
        #endregion
3357 ffddbe4e djkim
    }    
3358 787a4489 KangIngu
}
클립보드 이미지 추가 (최대 크기: 500 MB)