프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 16231f58

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

1
using Microsoft.AspNet.SignalR.Client;
2
using IKCOM;
3
using KCOM.Common;
4
using KCOM.ServiceDeepView;
5
using KCOMDataModel.DataModel;
6
using Newtonsoft.Json;
7
using System;
8
using System.Collections.Generic;
9
using System.Collections.ObjectModel;
10
using System.ComponentModel;
11
using System.Linq;
12
using System.Runtime.CompilerServices;
13
using System.Text;
14
using System.Windows;
15
using System.Windows.Controls;
16
using Telerik.Windows.Controls;
17
using MarkupToPDF.Controls.Parsing;
18
using Telerik.Windows.Data;
19
using System.Web;
20
using System.ServiceModel.Security;
21

    
22
namespace KCOM.Views
23
{
24
    public partial class MainMenu : UserControl, INotifyPropertyChanged
25
    {
26
        //const string DeepZoomUrl = @"http://{baseUrl}/TileSource/{TileSourcePath}/{ItemsPath}/{SharepointItemID}/{PageNo}.jpg";
27
        public ServiceDeepViewClient BaseClient;
28
        public KcomService.ServiceDeepViewClient BaseTaskClient
29
        {
30
            get {
31
                var service = new KcomService.ServiceDeepViewClient(App._binding, App._EndPoint);
32
                return service;
33
            }
34
        }
35

    
36
        public ViewInfo _ViewInfo;
37
        public DOCINFO _DocInfo;
38
        public DOCUMENT_ITEM _DocItem;
39
        public MEMBER userData { get; set; }
40

    
41
        public event PropertyChangedEventHandler PropertyChanged;
42
        private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
43
        {
44
            if (PropertyChanged != null)
45
            {
46
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
47
            }
48
        }
49

    
50
        private Common.DocumentSet _CurrentDoc { get; set; }
51
        public Common.DocumentSet CurrentDoc
52
        {
53
            get
54
            {
55
                return _CurrentDoc;
56
            }
57
            set
58
            {
59
                if (value != CurrentDoc)
60
                {
61
                    _CurrentDoc = value;
62
                    NotifyPropertyChanged();
63
                }
64
            }
65
        }
66
        public void ServiceOn()
67
        {
68
            //BaseTaskClient = new KcomService.ServiceDeepViewClient(App._binding, App._EndPoint);
69
            BaseClient = new ServiceDeepViewClient(App._binding, App._EndPoint);
70

    
71
            #region 이벤트 핸들러 등록
72
            BaseClient.GetDocInfoCompleted += BaseClient_GetDocInfoCompleted; //문서 섬네일, 페이지크기, 마크업 정보 [3]
73
            BaseClient.GetConversionStateCompleted += BaseClient_GetConversionStateCompleted;  //컨버팅의 여부 [2] 
74
            BaseClient.GetSystemDataCompleted += BaseClient_GetSystemDataCompleted; //시스템 정보 [1] 
75
            BaseClient.GetDocumentItemInfoCompleted += BaseClient_GetDocumentItemInfoCompleted; // 문서 자체의 정보 [4]
76
            BaseClient.GetMarkupInfoItemsCompleted += BaseClient_GetMarkupInfoItemsCompleted;
77
            BaseClient.GetDeptDataCompleted += BaseClient_GetDeptDataCompleted;
78
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted;
79
            BaseClient.GetVPRevisionHistoryCompleted += BaseClient_GetVPRevisionHistoryCompleted;
80
            BaseClient.SetFinalPDFCompleted += BaseClient_SetFinalPDFCompleted;
81
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted;
82
            BaseClient.DelFavoriteVPCompleted += BaseClient_DelFavoriteVPCompleted;
83
            BaseClient.EditFavoriteVPCompleted += BaseClient_EditFavoriteVPCompleted;
84

    
85
            BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
86
            BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
87
            #endregion
88
        }
89

    
90
        private void BaseClient_EditFavoriteVPCompleted(object sender, EditFavoriteVPCompletedEventArgs e)
91
        {
92
            //Logger.sendResLog("EditFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
93
            
94
            if (e.Error == null && e.Result != false)
95
            {
96
                //Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1);
97
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
98
            }
99
            else
100
            {
101
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
102
            }
103
        }
104

    
105
        private void BaseClient_DelFavoriteVPCompleted(object sender, DelFavoriteVPCompletedEventArgs e)
106
        {
107
            //Logger.sendResLog("DelFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
108

    
109
            if (e.Error == null && e.Result != false)
110
            {
111
                //Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1);
112
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
113
            }
114
            else
115
            {
116
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
117
            }
118
        }
119

    
120
        /// <summary>
121
        /// Compare 결과를 받아 화면에 표시한다
122
        /// </summary>
123
        /// <param name="sender"></param>
124
        /// <param name="e"></param>
125

    
126
        /// <summary>
127
        /// FinalPDF를 수행 후 관련 메시지를 표시한다.
128
        /// </summary>
129
        /// <param name="sender"></param>
130
        /// <param name="e"></param>
131
        private void BaseClient_SetFinalPDFCompleted(object sender, SetFinalPDFCompletedEventArgs e)
132
        {
133
            if (e.Error != null || e.Result.Status == FinalStatus.Error)
134
            {
135
                string errormsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFError", "MSG", $"최종 파일을 만드는데 문제가 발생하였습니다{System.Environment.NewLine}{e.Result.Exception}");
136
                DialogMessage_Alert(errormsg, "안내");
137
            }
138
            else
139
            {
140
                string successmsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFSuccess", "MSG", "최종 파일 생성 중입니다. 문서관리시스템을 확인해주세요");
141
                DialogMessage_Alert(successmsg, "안내");
142
            }
143
        }
144

    
145
        private void BaseClient_GetVPRevisionHistoryCompleted(object sender, GetVPRevisionHistoryCompletedEventArgs e)
146
        {
147
            //Logger.sendResLog("GetVPRevisionHistoryCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.Count + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
148

    
149
            if (e.Result != null && e.Error == null)
150
            {
151
                List<VPRevision> list = e.Result;
152
                foreach (var item in list)
153
                {
154

    
155
                    if (App.isExternal)
156
                    {
157
                        var sBaseServiceURL = CommonLib.Common.GetConfigString("ExternalOriginalFileUrl", "URL", "", App.isExternal);
158

    
159
                        if (!string.IsNullOrWhiteSpace(item.TO_VENDOR))
160
                        {
161
                            var toUri = new Uri(HttpUtility.UrlDecode(item.TO_VENDOR));
162
                            item.TO_VENDOR = $"{sBaseServiceURL}{toUri.LocalPath}";
163
                        }
164

    
165
                        if (!string.IsNullOrWhiteSpace(item.FROM_VENDOR))
166
                        {
167
                            var fromUri = new Uri(HttpUtility.UrlDecode(item.FROM_VENDOR));
168
                            item.FROM_VENDOR = $"{sBaseServiceURL}{fromUri.LocalPath}";
169
                        }
170
                    }
171
                    else
172
                    {
173
                        item.TO_VENDOR = HttpUtility.UrlDecode(item.TO_VENDOR);
174
                        item.FROM_VENDOR = HttpUtility.UrlDecode(item.FROM_VENDOR);
175
                        item.EnsembleLink = HttpUtility.UrlDecode(item.EnsembleLink);
176
                    }
177
                }
178
                //int result;
179
                //bool iCheck = true;
180
                //foreach (var li in list)
181
                //{                    
182
                //    iCheck = int.TryParse(li.GroupNo, out result);
183
                //    if (!iCheck)
184
                //        break;
185
                //}
186
                //if(iCheck)
187
                    gridViewHistory.ItemsSource = list.OrderByDescending(x => x.GroupNo); //20240611 LJY string 인거 전달드림 slip no 내림차순으로 그냥 해달라고 요청
188
                //else
189
                //    gridViewHistory.ItemsSource = list.OrderByDescending(x => x.RevNo);
190

    
191
            }
192
            //TempFile.TempLoad();
193
        }
194

    
195
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
196
        {
197
            //Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
198

    
199
            foreach(var info in ViewerDataModel.Instance._markupInfoList)
200
            {
201
                if(info.UserID == App.ViewInfo.UserID)
202
                {
203
                    info.userDelete = true;
204
                    info.DisplayColor = "#FFFF0000";
205
                }
206
                else
207
                {
208
                    info.userDelete = false;
209
                }
210
            }
211
        }
212

    
213
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
214
        {
215
            if (e.Error == null)
216
            {
217
                //Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.Count + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
218
            }
219
            else
220
            {
221
                //Logger.sendResLog("GetDeptDataCompleted",  "\r Error :" + e.Error, 1);
222
            }
223

    
224
            if (e.Result != null)
225
            {
226
                e.Result.Sort();
227
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
228
            }
229
        }
230

    
231
        /// <summary>
232
        /// ???
233
        /// </summary>
234
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
235

    
236
        /// <summary>
237
        /// 문서 정보를 가져온다
238
        /// </summary>
239
        /// <param name="sender"></param>
240
        /// <param name="e"></param>
241
        private async void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
242
        {
243
            ////Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
244

    
245
            if (e.Error != null)
246
            {
247
                DialogMessage_Alert("The page cannot be displayed.", "Alert");
248
            }
249
            else if (e.Result == null)
250
            {
251
                DialogMessage_Alert("Document information is missing.", "Alert");
252
            }
253
            else
254
            {
255
                string sFolder = _ViewInfo.DocumentItemID.All(char.IsDigit) ? (Convert.ToUInt64(_ViewInfo.DocumentItemID) / 100).ToString() : (_ViewInfo.DocumentItemID.Length >= 5 ? _ViewInfo.DocumentItemID.Substring(0, 5) : _ViewInfo.DocumentItemID);
256

    
257
                /// 화면의 좌측 Thumbnail의 주소
258
                var MainUrl = string.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal).Replace("png", "jpg"), _ViewInfo.ProjectNO, sFolder, _ViewInfo.DocumentItemID, "{PageNo}");
259
                _DocInfo = e.Result;
260
                _DocInfo.ORIGINAL_FILE = HttpUtility.UrlDecode(_DocInfo.ORIGINAL_FILE);
261
                foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
262
                {
263
                    ViewerDataModel.Instance.Document_Info.Add(item);
264
                }
265
                //Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
266
                CurrentDoc = new Common.DocumentSet
267
                {
268
                    docInfo = _DocInfo,
269
                    Document_Id = _DocInfo.DOCUMENT_ID,
270
                    File_Original = _DocInfo.ORIGINAL_FILE,
271

    
272
                    Document_NO = _DocItem?.DOCUMENT_NO,
273
                    File_Result = _DocItem?.RESULT_FILE,
274
                    Group_No = _DocItem?.GROUP_NO,
275
                    ProjectNo = _DocItem?.PROJECT_NO,
276
                    Revision = _DocItem?.REVISION,
277
                };
278

    
279
                var instanceMain = this.ParentOfType<MainWindow>();
280
                string firstpage = "1";
281
                string lastpage = _DocInfo.PAGE_COUNT.ToString();
282
                instanceMain.dzTopMenu.tlcurrentPage.Text = firstpage;
283
                instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = lastpage;
284
                App.MarkusVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
285

    
286
                string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem?.DOCUMENT_NO, _DocItem?.REVISION, App.MarkusVersion);
287

    
288
                instanceMain.Title = apptitle;
289

    
290
                #region 페이지 이미지를 로컬에 저장
291
                string tempStoragePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName());
292

    
293
                //.Replace("jpg", "png")을 붙이는 이유는 MainUrl에 확장명이 jpg로 설정한 경우가 있기 때문
294

    
295
                #endregion
296

    
297
                App.PageStorage = new PageManager.PageStorage(MainUrl.Replace("jpg", "png"), tempStoragePath, "png", _DocInfo.PAGE_COUNT, 1);
298

    
299
                //App.SamplePageStorage = new PageManager.PageStorage(MainUrl.Replace("png", "jpg"), tempStoragePath, "jpg", _DocInfo.PAGE_COUNT);
300
                await this.pageNavigator.SetPageNaviAsync(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
301
            }
302
        }
303

    
304
        private void pageNavigator_ThumbInitialized(object sender,EventArgs e)
305
        {
306
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
307

    
308
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
309
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
310

    
311
            /// 기존 임시파일 정리
312
            #region 단어 검색용 파일 다운로드
313

    
314
            DownloadOriginalFile();
315

    
316
            #endregion
317

    
318
            //Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
319
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
320

    
321
        }
322

    
323

    
324
        /// <summary>
325
        /// get markupinfo and markupitem from database
326
        ///  - 1. called when document is loaded
327
        ///  - 2. called when user do consolidation
328
        /// </summary>
329
        /// <param name="sender"></param>
330
        /// <param name="e"></param>
331
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
332
        {
333
            //Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.Count + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
334

    
335
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
336
            ViewerDataModel.Instance.MarkupControls.Clear();
337

    
338
            try
339
            {
340

    
341
                if (e.Result != null)
342
                {
343
                    ViewerDataModel.Instance._markupInfoList.Clear();
344
                    if (e.Result.Any()) ViewerDataModel.Instance.MyMarkupList.Clear();
345

    
346
                    foreach (var info in e.Result)
347
                    {
348
                        if (info.Depatment == null) info.Depatment = "Unknown";
349

    
350
                        else if (info.UserID == App.ViewInfo.UserID)
351
                        {
352
                            if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission) //조회모드는 delete 버튼 모두 비활성화
353
                            {
354
                                info.userDelete = false;
355
                            }
356
                            else if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission && e.Result.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1).Count() > 0) //Team Consolidation Mode이고 Team Consolidation Layer가 있을 경우
357
                            {
358
                                if(App.ViewInfo.NewCommentPermission && e.Result.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1 && x.MarkupInfoID == info.MarkupInfoID).Count() > 0)                                
359
                                    info.userDelete = true;                                
360
                            }
361
                            else if(App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission) //Consolidation Mode 일 때는 해당 Comment Layer의 Status가 Avoid or Consolidation인 것만 Delete 버튼 활성화
362
                            {
363
                                if(info.AvoidConsolidate == 1 || info.Consolidate == 1)
364
                                    info.userDelete = true;
365
                            }
366
                            else
367
                            {
368
                                info.userDelete = true;
369
                            }                               
370
                            info.DisplayColor = "#FFFF0000";
371
                        }
372
                        else
373
                        {
374
                            info.userDelete = false;
375
                        }
376

    
377
                        ViewerDataModel.Instance._markupInfoList.Add(info);
378
                    }
379

    
380
                    var userInfoList = ViewerDataModel.Instance._markupInfoList.GroupBy(f => f.UserID).Select(f => new MarkupUserInfo { UserId = f.Key, UserName = f.First().UserName });
381

    
382
                    userInfoList.ToList().ForEach(x =>
383
                    {
384
                        ViewerDataModel.Instance._markupUserList.Add(x);
385

    
386
                        if (MarkupToPDF.MarkupContext.GetUserSignItem(x.UserId) == null)
387
                        {
388
                            string signData = BaseClient.GetSignData(App.ViewInfo.ProjectNO, x.UserId);
389
                            string signStrokes = BaseClient.GetSignStrokes(App.ViewInfo.ProjectNO, x.UserId);
390

    
391
                            if (signData != null && signStrokes != null)
392
                            {
393
                                MarkupToPDF.MarkupContext.SetUserSignItem(x.UserId, signData, signStrokes);
394
                            }
395
                        }
396
                    });
397

    
398
                    e.Result.ToList().ForEach(d =>
399
                    {
400
                        if (d.MarkupList != null)
401
                        {
402
                            d.MarkupList.ForEach(p =>
403
                            {
404
                                if (d.UserID == App.ViewInfo.UserID)
405
                                {
406
                                    if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission) //조회모드는 delete 버튼 모두 비활성화
407
                                    {
408
                                        d.userDelete = false;
409
                                    }
410
                                    else if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission && e.Result.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1).Count() > 0)//Team Consolidation Mode이고 Team Consolidation Layer가 있을 경우
411
                                    {
412
                                        if (App.ViewInfo.NewCommentPermission && e.Result.Exists(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1 && x.MarkupInfoID == d.MarkupInfoID))
413
                                            d.userDelete = true;
414
                                    }
415
                                    else if (App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission) //Consolidation Mode 일 때는 해당 Comment Layer의 Status가 Avoid or Consolidation인 것만 Delete 버튼 활성화
416
                                    {
417
                                        if (d.AvoidConsolidate == 1 || d.Consolidate == 1)
418
                                            d.userDelete = true;
419
                                    }
420
                                    else
421
                                    {
422
                                        d.userDelete = true;
423
                                    }
424
                                    d.DisplayColor = "#FFFF0000";
425
                                    MarkupItemEx markup = new MarkupItemEx
426
                                    {
427
                                        Data = p.Data,
428
                                        Data_Type = p.Data_Type,
429
                                        ID = p.ID,
430
                                        IsUpdate = false,
431
                                        MarkupInfoID = d.MarkupInfoID,
432
                                        PageNumber = p.PageNumber,
433
                                        Symbol_ID = p.Symbol_ID,
434
                                        //Group_ID = p.Group_ID
435
                                    };
436
                                    ViewerDataModel.Instance.MyMarkupList.Add(markup);
437
                                }
438
                                else
439
                                {
440
                                    MarkupItemEx markup = new MarkupItemEx
441
                                    {
442
                                        Data = p.Data,
443
                                        Data_Type = p.Data_Type,
444
                                        ID = p.ID,
445
                                        IsUpdate = false,
446
                                        MarkupInfoID = d.MarkupInfoID,
447
                                        PageNumber = p.PageNumber,
448
                                        Symbol_ID = p.Symbol_ID,
449
                                        //Group_ID = p.Group_ID
450
                                    };
451
                                    ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
452
                                }
453
                            });
454
                        }
455
                    });
456

    
457
                    var currentUser = e.Result.Find(data => data.UserID == App.ViewInfo.UserID && data.AvoidConsolidate == 0);
458
                    if (currentUser == null)
459
                    {
460
                        /// create a new markupinfo to do comments
461
                        if (App.ViewInfo.NewCommentPermission)
462
                        {
463
                            var infoId = Commons.ShortGuid();
464
                            PreviewUserMarkupInfoItem = new MarkupInfoItem
465
                            {
466
                                CreateTime = DateTime.Now,
467
                                UpdateTime = DateTime.Now,
468
                                Depatment = userData.DEPARTMENT,
469
                                DisplayColor = "#FFFF0000",
470
                                UserID = userData.ID,
471
                                UserName = userData.NAME,
472
                                PageCount = 1,
473
                                Description = "",
474
                                MarkupInfoID = infoId,
475
                                MarkupList = null,
476
                                MarkupVersionID = Commons.ShortGuid(),
477
                                Consolidate = 0,
478
                                PartConsolidate = 0,
479
                                userDelete = true,
480
                                AvoidConsolidate = 0,
481
                                IsPreviewUser = false
482
                            };
483

    
484
                            App.Custom_ViewInfoId = infoId;
485

    
486
                            ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
487
                        }
488
                    }
489
                    else
490
                    {
491
                        App.Custom_ViewInfoId = currentUser.MarkupInfoID;
492
                    }
493

    
494
                    ViewerDataModel.Instance.SyncPageNumber = 1;
495

    
496
                    /// Consolidation 된 데이터가 최상단에 올 수 있도록 변경
497
                    //var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList();
498

    
499
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
500

    
501
                    SetCommentPages(null);
502

    
503
                    // GRIDVIEW에서 팀별 GROUPING
504
                    // 효성은 안함
505
#if (Hyosung)
506
#else
507
                    /// create a group descriptor
508
                    gridViewMarkup.GroupDescriptors.Clear();
509
                    GroupDescriptor descriptor = new GroupDescriptor();
510
                    descriptor.Member = "Depatment";
511
                    descriptor.DisplayContent = "DEPT";
512
                    //descriptor.SortDirection = ListSortDirection.Ascending;
513
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
514
#endif
515

    
516
                    GridViewMarkup_Sorting(gridViewMarkup, new GridViewSortingEventArgs(gridViewMarkup.Columns[0], SortingState.None, SortingState.None));
517

    
518
                    SelectInitialMarkupInfo();
519
                }
520
            }
521
            catch (Exception ex) 
522
            {
523
                App.FileLogger.Fatal(ex);
524
            }
525
            finally
526
            {
527
                if(!ViewerDataModel.Instance.SystemMain.dzMainMenu.btnFinalPDF.IsEnabled)
528
                {
529
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.btnFinalPDF.IsEnabled = true;
530
                }
531

    
532
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.btnConsolidate.IsEnabled)
533
                {
534
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.btnConsolidate.IsEnabled = true;
535
                }
536
            }
537
        }
538

    
539
        /// <summary>
540
        /// 프로그램이 로딩되고 난 후 맨처음으로 MarkupInfo를 선택한다. 
541
        /// </summary>
542
        private void SelectInitialMarkupInfo()
543
        {
544
            if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
545
            {
546
                #region Consolidate 항목이 있으면 Consolidate 항목만 추가
547
                if (ViewerDataModel.Instance._markupInfoList.Any(x => x.Consolidate == 1 && x.AvoidConsolidate == 0))
548
                {
549
                    var Consolidates = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0).ToList();
550
                    Consolidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
551
                }
552
                #endregion
553
                #region Consolidate 항목이 없을 경우에는 사용자 별로 AvoidConsolidate를 제외한 우선 순위가 높은(Team,Comment)항목들을 선택
554
                else
555
                {
556
                    var MarkupInfoColl = ViewerDataModel.Instance._markupInfoList.Where(x => x.AvoidConsolidate == 0).ToList();
557

    
558
                    #region Team consolidate 항목 선택
559
                    var Candidates = MarkupInfoColl.Where(x => x.PartConsolidate == 1 && x.AvoidConsolidate == 0).ToList();
560
                    MarkupInfoColl.RemoveAll(x => Candidates.Exists(y => y.UserID == x.UserID));
561
                    #endregion
562

    
563
                    #region 추가되지 않은 사용자들을 추가
564
                    foreach (var item in MarkupInfoColl.Where(x => !Candidates.Exists(y => y.UserID == x.UserID)))
565
                    {
566
                        Candidates.Add(item);
567
                    }
568
                    #endregion
569

    
570
                    Candidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
571
                }
572
                #endregion
573
            }
574
            else if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)   /// Eng'r Comment Mode
575
            {
576
                var MarkupInfoColl = ViewerDataModel.Instance._markupInfoList.Where(x => x.AvoidConsolidate == 0).ToList();
577

    
578
                #region Team consolidate 항목 선택
579
                var Candidates = MarkupInfoColl.Where(x => x.PartConsolidate == 1 && x.AvoidConsolidate == 0).ToList();
580
                MarkupInfoColl.RemoveAll(x => Candidates.Exists(y => y.UserID == x.UserID));
581
                #endregion
582

    
583
                #region 추가되지 않은 사용자들을 추가
584
                foreach (var item in MarkupInfoColl.Where(x => !Candidates.Exists(y => y.UserID == x.UserID)))
585
                {
586
                    Candidates.Add(item);
587
                }
588
                #endregion
589

    
590
                Candidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
591
            }
592
            else if (App.ViewInfo.CreateFinalPDFPermission)    /// Orig Comment Model
593
            {
594
                if (ViewerDataModel.Instance._markupInfoList.Any(x => x.Consolidate == 1 && x.AvoidConsolidate == 0))
595
                {
596
                    var Consolidates = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0).ToList();
597
                    Consolidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
598
                }
599
                else if (ViewerDataModel.Instance._markupInfoList.Any(x => x.PartConsolidate == 1 && x.AvoidConsolidate == 0))
600
                {
601
                    var MarkupInfoColl = ViewerDataModel.Instance._markupInfoList.Where(x => x.AvoidConsolidate == 0).ToList();
602

    
603
                    #region Team consolidate 항목 선택
604
                    var Candidates = MarkupInfoColl.Where(x => x.PartConsolidate == 1 && x.AvoidConsolidate == 0).ToList();
605
                    MarkupInfoColl.RemoveAll(x => Candidates.Exists(y => y.UserID == x.UserID));
606
                    #endregion
607

    
608
                    #region 추가되지 않은 사용자들을 추가
609
                    foreach (var item in MarkupInfoColl.Where(x => !Candidates.Exists(y => y.UserID == x.UserID)))
610
                    {
611
                        Candidates.Add(item);
612
                    }
613
                    #endregion
614

    
615
                    Candidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
616
                }
617
                else
618
                {
619
                    var Comments = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 0 && x.AvoidConsolidate == 0).ToList();
620
                    Comments.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
621
                }
622
            }
623

    
624
            if (!gridViewMarkup.SelectedItems.Any())
625
            {
626
                var SelectedItem = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.UpdateTime).FirstOrDefault();
627

    
628
                if (PreviewUserMarkupInfoItem != null)
629
                {
630
                    this.gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
631
                }
632
                else if (SelectedItem != null)
633
                {
634
                    this.gridViewMarkup.SelectedItem = SelectedItem;
635
                }
636
                else if (ViewerDataModel.Instance._markupInfoList.Any())
637
                {
638
                    this.gridViewMarkup.SelectedItem = ViewerDataModel.Instance._markupInfoList[0];
639
                }
640
            }
641
        }
642

    
643
        private void GridViewMarkup_Sorting(object sender, GridViewSortingEventArgs e)
644
        {
645
            IEnumerable<IKCOM.MarkupInfoItem> markuplist = e.DataControl.ItemsSource as IEnumerable<IKCOM.MarkupInfoItem>;
646

    
647
            if(markuplist == null)
648
            {
649
                e.Cancel = true;
650
                return;
651
            }
652

    
653
            if(e.NewSortingState == SortingState.None)
654
            {
655
                markuplist = markuplist.OrderByDescending(x => SortIndex(x))
656
                                            .ThenBy(x => x.Depatment)
657
                                            .ThenBy(x => x.UserID);
658

    
659
                e.DataControl.ItemsSource = markuplist.ToList();
660
            }
661
        }
662

    
663

    
664
        // 마크업 리스트 정렬
665
        private int SortIndex(IKCOM.MarkupInfoItem markupInfoItem)
666
        {
667
            int result = 0;
668

    
669
            // Consolidate은 최상단
670
            if (markupInfoItem.Consolidate == 1)
671
            {
672
                result += 2;
673
            }
674

    
675
            /// Consolidate 다음으로 우선순위
676
            if (markupInfoItem.UserID == App.ViewInfo.UserID)
677
            {
678
                result += 1;
679
            }
680

    
681
            return result;
682
        }
683

    
684

    
685
        private void GridViewMarkup_Sorted(object sender, GridViewSortedEventArgs e)
686
        {
687

    
688
        }
689

    
690
        private async void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
691
        {
692
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
693
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
694
            //{
695
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
696
            //}
697

    
698
            if (ViewerDataModel.Instance.SyncPageNumber == 0)
699
            {
700
                ViewerDataModel.Instance.SyncPageNumber = 1;
701
            }
702
            if (e.AddedItems.Any())
703
            {
704
                foreach (var item in gridSelectionItem)
705
                {
706
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
707
                    //{
708
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
709
                    //});
710

    
711
                    var pageItems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
712

    
713
                    foreach (var markupitem in pageItems)
714
                    {
715
                       await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", item.MarkupInfoID,
716
                           STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
717
                    }
718
                }
719
            }
720
            else if (e.RemovedItems.Any())
721
            {
722
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
723

    
724
                (from A in _infoItem
725
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
726
                 where A.MarkupInfoID == B.MarkupInfoID
727
                 select B).ToList().ForEach(data =>
728
                 {
729
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
730
                 });
731
            }
732
        }
733

    
734
        /// <summary>
735
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
736
        /// </summary>
737
        /// <param name="sender"></param>
738
        /// <param name="e"></param>
739
        private async void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
740
        {
741

    
742
            foreach (var item in e.AddedItems)
743
            {
744
                var cellToSelect = new GridViewCellInfo(item, this.gridViewMarkup.Columns["color"], this.gridViewMarkup);
745

    
746
                if(cellToSelect != null)
747
                {
748

    
749
                }
750
            }
751

    
752
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
753

    
754
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
755
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
756
            var resultA = (from item_Select in dataSet
757
                           from item_Non in dataSet_User
758
                           where item_Select == item_Non
759
                           select item_Non).ToList();
760

    
761
            if (resultA.Count() >= 2)
762
            {
763
                // 동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?
764
                RadWindow.Confirm(new DialogParameters
765
                {
766
                    Owner = Application.Current.MainWindow,
767
                    Header = "Info",
768
                    Content = "Selected more than two identical user data. Do you want to select consolidation?",
769
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
770
                    {
771
                        if(ea.DialogResult == null)
772
                        {
773
                            return;
774
                        }
775
                        if (e.AddedItems.Count() == 1)
776
                        {
777
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
778
                            gridViewMarkup.SelectedItem = null;
779

    
780
                        
781
                            if (ea.DialogResult.Value)
782
                            {
783
                                if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
784
                                {
785
                                    gridViewMarkup.SelectedItem = instanceItem;
786
                                }
787
                                else
788
                                {
789
                                    //1. Consolidations이 있다면 하나 선택
790
                                    var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
791

    
792
                                    if (Consolidations.Count() > 0)
793
                                    {
794
                                        gridViewMarkup.SelectedItem = Consolidations.First();
795
                                    }
796
                                }
797
                              
798
                            }
799
                            else {
800
                                //1. Consolidations 아닌게 있다면 Change
801
                                var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
802

    
803
                                if(notConsolidations.Count() > 0) {
804
                                    gridViewMarkup.SelectedItem = notConsolidations.First();
805
                                }
806
                                else {//1. Consolidations 아닌게 없다면 그대로
807
                                    gridViewMarkup.SelectedItem = instanceItem;
808
                                }
809
                                
810
                            }
811
                        }
812
                    }),
813
                    Theme = new Windows8Theme(),
814
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
815
                });
816
            }
817
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
818
            {
819
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
820
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
821
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
822
#region 코멘트 보기
823
                if (e.AddedItems.Count() > 0 && this.pageNavigator.CurrentPage != null)
824
                {
825
                    foreach (var item in gridSelectionItem)
826
                    {
827
                        if (item.UserID == App.ViewInfo.UserID)
828
                        {
829
                            var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
830
                            if (controls.Count == 0)
831
                            {
832
                                var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
833

    
834
                                foreach (var markup in instance)
835
                                {
836
                                    await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", 
837
                                        item.MarkupInfoID, markup.ID, STAMP_Contents:App.SystemInfo.STAMP_CONTENTS);
838
                                }
839
                            }
840

    
841
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
842
                            foreach (var control in controls)
843
                            {
844
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
845
                                control.Visibility = Visibility.Visible;
846
                            }
847
                        }
848
                        else
849
                        {
850
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
851
                            if (controls.Count == 0)
852
                            {
853
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
854
                                foreach (var markup in instance)
855
                                {
856
                                    await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
857
                                        item.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
858
                                }
859
                            }
860

    
861
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
862
                            foreach (var control in controls)
863
                            {
864
                                control.Visibility = Visibility.Visible;
865
                            }
866
                        }
867
                    }
868
                }
869
#endregion
870
#region 코멘트 숨기기
871
                else if (e.RemovedItems.Count > 0)
872
                {
873
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
874

    
875
                    (from A in _infoItem
876
                     from B in Common.ViewerDataModel.Instance.MarkupControls
877
                     where A.MarkupInfoID == B.MarkupInfoID
878
                     select B).ToList().ForEach(data =>
879
                     {
880
                         data.Visibility = Visibility.Hidden;                         
881
                     });
882

    
883

    
884
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
885
                    if (myComment != null)
886
                    {
887
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
888
                        {
889
                            markupitem.Visibility = Visibility.Hidden;
890
                        });
891
                    }
892
                }
893
#endregion
894
            }
895
        }
896

    
897
        private async void gridViewMarkup_SelectedCellsChanged(object sender, Telerik.Windows.Controls.GridView.GridViewSelectedCellsChangedEventArgs e)
898
        {
899
            if (e.AddedCells.Count() > 0)
900
            {
901
                if(e.AddedCells[0].Column.Name == "color")
902
                {
903

    
904
                }
905
                else
906
                {
907
                    List<MarkupInfoItem> removeItems = new List<MarkupInfoItem>();
908

    
909
                    if (!gridViewMarkup.SelectedItems.Contains(e.AddedCells[0].Item))
910
                    {
911
                        gridViewMarkup.SelectedItems.Add(e.AddedCells[0].Item);
912
                    }
913
                    else
914
                    {
915
                        gridViewMarkup.Unselect(new[] { e.AddedCells[0].Item });
916

    
917
                        removeItems.Add(e.AddedCells[0].Item as MarkupInfoItem);
918
                    }
919

    
920
                    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
921

    
922
                    var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
923
                    var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
924
                    var resultA = (from item_Select in dataSet
925
                                   from item_Non in dataSet_User
926
                                   where item_Select == item_Non
927
                                   select item_Non).ToList();
928

    
929
                    if (resultA.Count() >= 2)
930
                    {
931
                        // 동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?
932
                        RadWindow.Confirm(new DialogParameters
933
                        {
934
                            Owner = Application.Current.MainWindow,
935
                            Header = "Info",
936
                            Content = "Selected more than two identical user data. Do you want to select consolidation?",
937
                            Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
938
                            {
939
                                if (ea.DialogResult == null)
940
                                {
941
                                    return;
942
                                }
943
                                if (gridViewMarkup.SelectedItems.Count() == 1)
944
                                {
945
                                    MarkupInfoItem instanceItem = gridViewMarkup.SelectedItems.FirstOrDefault() as MarkupInfoItem;
946
                                    gridViewMarkup.SelectedItem = null;
947

    
948

    
949
                                    if (ea.DialogResult.Value)
950
                                    {
951
                                        if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
952
                                        {
953
                                            gridViewMarkup.SelectedItem = instanceItem;
954
                                        }
955
                                        else
956
                                        {
957
                                            //1. Consolidations이 있다면 하나 선택
958
                                            var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
959

    
960
                                            if (Consolidations.Count() > 0)
961
                                            {
962
                                                gridViewMarkup.SelectedItem = Consolidations.First();
963
                                            }
964
                                        }
965

    
966
                                    }
967
                                    else
968
                                    {
969
                                        //1. Consolidations 아닌게 있다면 Change
970
                                        var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
971

    
972
                                        if (notConsolidations.Count() > 0)
973
                                        {
974
                                            gridViewMarkup.SelectedItem = notConsolidations.First();
975
                                        }
976
                                        else
977
                                        {//1. Consolidations 아닌게 없다면 그대로
978
                                            gridViewMarkup.SelectedItem = instanceItem;
979
                                        }
980

    
981
                                    }
982
                                }
983
                            }),
984
                            Theme = new Windows8Theme(),
985
                            ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
986
                        });
987
                    }
988
                    else //파라미터로 넘어온 사용자가 걸리지 않은 경우
989
                    {
990
                        List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
991
                        List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
992
                        List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
993
                        #region 코멘트 보기
994
                        if (gridViewMarkup.SelectedItems.Count() > 0 && this.pageNavigator.CurrentPage != null)
995
                        {
996
                            foreach (var item in gridSelectionItem)
997
                            {
998
                                if (item.UserID == App.ViewInfo.UserID)
999
                                {
1000
                                    var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
1001
                                    if (controls.Count == 0)
1002
                                    {
1003
                                        var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
1004

    
1005
                                        foreach (var markup in instance)
1006
                                        {
1007
                                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
1008
                                                item.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1009
                                        }
1010
                                    }
1011

    
1012
                                    controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
1013
                                    foreach (var control in controls)
1014
                                    {
1015
                                        Logger.sendCheckLog(String.Format("=={0}", control), 1);
1016
                                        control.Visibility = Visibility.Visible;
1017
                                    }
1018
                                }
1019
                                else
1020
                                {
1021
                                    var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
1022
                                    if (controls.Count == 0)
1023
                                    {
1024
                                        var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
1025
                                        foreach (var markup in instance)
1026
                                        {
1027
                                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
1028
                                                item.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1029
                                        }
1030
                                    }
1031

    
1032
                                    controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
1033
                                    foreach (var control in controls)
1034
                                    {
1035
                                        control.Visibility = Visibility.Visible;
1036
                                    }
1037
                                }
1038
                            }
1039
                        }
1040
                        #endregion
1041
                        #region 코멘트 숨기기
1042
                        else if (removeItems.Count > 0)
1043
                        {
1044
                            (from A in removeItems
1045
                             from B in Common.ViewerDataModel.Instance.MarkupControls
1046
                             where A.MarkupInfoID == B.MarkupInfoID
1047
                             select B).ToList().ForEach(data =>
1048
                             {
1049
                                 data.Visibility = Visibility.Hidden;
1050
                             });
1051

    
1052

    
1053
                            var myComment = removeItems.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
1054
                            if (myComment != null)
1055
                            {
1056
                                Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
1057
                                {
1058
                                    markupitem.Visibility = Visibility.Hidden;
1059
                                });
1060
                            }
1061
                        }
1062
                        #endregion
1063
                    }
1064
                }
1065
            }
1066
        }
1067

    
1068
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
1069
        {
1070
            //Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.DOCUMENT_ID + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
1071

    
1072
            if (e.Result != null)
1073
            {
1074
                _DocItem = e.Result;
1075

    
1076
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
1077
                {
1078
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
1079
                }
1080
                ////Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
1081
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
1082
            }
1083
            else
1084
            {
1085
                DialogMessage_Alert("Document Information Not Found.", "Error");
1086

    
1087
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
1088
                {
1089
                    //Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
1090

    
1091
                    if (ea.Error == null)
1092
                    {
1093
                        if (ea.Result)
1094
                        {
1095
                            this._ViewInfo.isAdmin = true;
1096
                            //Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
1097
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
1098
                        }
1099
                        else
1100
                        {
1101
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
1102
                            DialogMessage_Alert("You are not belong to this project. Please ask admin for an authority.", "Info");
1103
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
1104
                        }
1105

    
1106
                    }
1107
                    else
1108
                    {
1109
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
1110
                    }
1111
                };
1112
                //Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
1113
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
1114
            }
1115
        }
1116

    
1117
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
1118
        {
1119
            //Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
1120

    
1121
            if (e.Error == null && e.Result != null)
1122
            {
1123
                App.SystemInfo = e.Result;
1124

    
1125
                //App.urlPort_DB = App.SystemInfo.HostPort;
1126
                //App.urlHost_DB = App.SystemInfo.HostName;
1127
                //Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
1128
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
1129

    
1130
                //if (App.urlHost.Contains("localhost"))
1131
                //{
1132
                //    App.urlHost = App.urlHost_DB;
1133
                //}
1134
            }
1135
        }
1136

    
1137
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
1138
        {
1139
            if (e.Error == null && e.Result)
1140
            {
1141
                BaseClient.GetDocumentItemInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID, userID = _ViewInfo.UserID });
1142

    
1143
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
1144
                {
1145
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
1146
                    if (userData != null)
1147
                    {
1148
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
1149
                    }
1150
                    else
1151
                    {
1152
                        userData = new MEMBER();
1153
                        userData.DEPARTMENT = "ALL";
1154
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
1155
                    }
1156
                }
1157
            }
1158
            else
1159
            {
1160
                string failedmsg = CommonLib.Common.GetAlertMessageString("GetConversionStateFailed", "MSG", "Too Many V/P Files are uploading instantaneously, This V/P file can not be open now. Please feel free to re-open wait a moment again!\n\n현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다.\n잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
1161
                DialogMessage_Alert(failedmsg, "Warning");
1162
            }
1163
        }
1164

    
1165
        public void SetView(ViewInfo info)
1166
        { 
1167
            this._ViewInfo = info;
1168
            try
1169
            {
1170
                /// 대림의 경우 EnsembleID를 가지고 DocumentItemID를 구함
1171
                /// 다른 Site를 대비하여 에러 처리함
1172
                string docid = BaseClient.GetDocItemID(info.EnsembleID);
1173
                if (!string.IsNullOrEmpty(docid))
1174
                {
1175
                    this._ViewInfo.DocumentItemID = docid;
1176
                }
1177
            }
1178
            catch (Exception ex)
1179
            {
1180

    
1181
                //App.FileLogger.Fatal(ex);
1182
            }
1183

    
1184
            //Logger.sendReqLog("GetSystemDataAsync", "", 1);
1185

    
1186
            BaseClient.GetSystemDataAsync();
1187
        }
1188

    
1189
        public void HubSet()
1190
        {
1191
            // 허브 연결 구성
1192
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
1193
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
1194

    
1195

    
1196
            // 허브 연결 
1197
            hubConnection.Start().ContinueWith(task =>
1198
            {
1199
                if (task.IsFaulted)
1200
                {
1201
                    Console.WriteLine("There was an error opening the connection:{0}",
1202
                                      task.Exception.GetBaseException());
1203
                    //throw task.Exception.GetBaseException();
1204
                }
1205
                else
1206
                {
1207
                    Console.WriteLine("Connected :: " + task.Id);
1208
                }
1209

    
1210
            }).Wait();
1211

    
1212

    
1213
            // [ 프로그램 시작 ]
1214
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
1215
            //( "method name", arg1, arg2 )
1216
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
1217
            //{
1218
            //    if (task.IsFaulted)
1219
            //    {
1220
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
1221
            //    }
1222
            //    else
1223
            //    {
1224
            //        Console.WriteLine(task.Result);
1225
            //    }
1226
            //});
1227
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID,App.ViewInfo.ProjectNO).ContinueWith(task =>
1228
            {
1229
                if (task.IsFaulted)
1230
                {
1231
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
1232
                    //throw task.Exception.GetBaseException();
1233
                }
1234
                else
1235
                {
1236
                    switch (task.Result)
1237
                    {
1238
                        case "2":
1239
                            {
1240
                                var result = MessageBox.Show("권한이 없습니다.");
1241
                                if (result == MessageBoxResult.OK)
1242
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
1243
                            }
1244
                            break;
1245
                        case "404":
1246
                            {
1247
                                var result = MessageBox.Show("등록된 사용자가 아닙니다.");
1248
                                if(result == MessageBoxResult.OK)
1249
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
1250
                            }
1251
                            break;
1252
                    }
1253
                }
1254
            });
1255

    
1256
            // 서버에서 클라이언트 호출 ( 프로그램 구동여부 ) : 라이센스 체크 후 응답 ( 반환값 : true, false ) 
1257
            //MarkusLicenseProxy.On<bool>("IsConnection", status =>
1258
            //{
1259

    
1260
            //    if (status)
1261
            //    {
1262
            //        // 프로그램 시작 
1263
            //        Console.WriteLine("connection status : " + status);
1264
            //    }
1265
            //    else
1266
            //    {
1267
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
1268
            //        hubConnection.Stop();
1269
            //    }
1270
            //});
1271

    
1272
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
1273
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
1274
                Console.WriteLine("Noficiation Message : " + msg)
1275
            );
1276

    
1277

    
1278
            // 서버 메서드 호출 
1279
            //MarkusLicenseProxy.Invoke<string>("DoSomething", "I'm doing something!!!").Wait();
1280

    
1281
            //Console.ReadKey();
1282

    
1283
            //hubConnection.Stop();
1284
        }
1285

    
1286
        public async void MarkupUserListDisplay()
1287
        {
1288
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
1289
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1290
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
1291
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
1292
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
1293
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
1294
            //foreach (var item in gridSelectionItem)
1295
            //{
1296
            //    if (item.UserID == App.ViewInfo.UserID)
1297
            //    {
1298
            //        ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
1299
            //        {
1300
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
1301
            //        });
1302
            //    }
1303
            //    else
1304
            //    {
1305
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
1306
            //        {
1307
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
1308
            //        });
1309
            //    }
1310
            //}
1311
                (from A in gridSelectionItem
1312
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
1313
                 where A.MarkupInfoID == B.MarkupInfoID
1314
                 select B).ToList().ForEach(data =>
1315
                 {
1316
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
1317
                 });
1318
            (from A in gridSelectionItem
1319
             from B in Common.ViewerDataModel.Instance.MarkupControls
1320
             where A.MarkupInfoID == B.MarkupInfoID
1321
             select B).ToList().ForEach(data =>
1322
             {
1323
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
1324
             });
1325

    
1326
            foreach (var item in gridSelectionItem)
1327
            {
1328

    
1329
                if (item.UserID == App.ViewInfo.UserID)
1330
                {
1331
                    var markupItems = ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
1332

    
1333
                    foreach (var markupitem in markupItems)
1334
                    {
1335
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", 
1336
                                item.MarkupInfoID, markupitem.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1337
                    }
1338
                }
1339
                else
1340
                {
1341
                    var markupItems = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
1342

    
1343
                    foreach (var markupitem in markupItems)
1344
                    {
1345
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", item.MarkupInfoID,
1346
                            STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1347
                    }
1348
                }
1349
            }
1350
        }
1351
    }
1352
}
클립보드 이미지 추가 (최대 크기: 500 MB)