프로젝트

일반

사용자정보

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

markus / KCOM_API / ServiceDeepView.svc.cs @ 075cbfcf

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