프로젝트

일반

사용자정보

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

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

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

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