프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ 0d97ab05

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