프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ ef8fafdf

이력 | 보기 | 이력해설 | 다운로드 (68 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;
40
        public List<int> MarkupSortList = new List<int>();
41

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

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

    
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.GetCompareRectCompleted += BaseClient_GetCompareRectCompleted;
82
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted;
83
            BaseClient.DelFavoriteVPCompleted += BaseClient_DelFavoriteVPCompleted;
84
            BaseClient.EditFavoriteVPCompleted += BaseClient_EditFavoriteVPCompleted;
85
        }
86

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

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

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

    
117
        /// <summary>
118
        /// Compare 결과를 받아 화면에 표시한다
119
        /// </summary>
120
        /// <param name="sender"></param>
121
        /// <param name="e"></param>
122
        private void BaseClient_GetCompareRectCompleted(object sender, GetCompareRectCompletedEventArgs e)
123
        {
124
            if (e.Error != null || e.Result == null)
125
            {
126
                if (e.Error != null)
127
                {
128
                    DialogMessage_Alert(e.Error.ToString(), "Error");
129
                }
130
                else
131
                {
132
                    DialogMessage_Alert("Compare 기능을 원활히 실행하기 위한 데이터가 부족합니다", "안내");
133
                }
134
            }
135
            else
136
            {
137
                e.Result.ForEach(d =>
138
                {
139
                    d.Width = d.Width;
140
                    d.Height = d.Height;
141
                    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
142
                    System.Windows.Shapes.Rectangle myEllipse = new System.Windows.Shapes.Rectangle();
143
                    myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(150, 33, 215, 119));
144
                    myEllipse.Opacity = 1;
145
                    myEllipse.Width = d.Width;
146
                    myEllipse.Height = d.Height;
147
                    Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
148
                    Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
149
                    myEllipse.RenderTransformOrigin = point;
150
                    canvas_compareBorder.Children.Add(myEllipse);
151
                });
152
                canvas_compareBorder.Visibility = Visibility.Visible;
153
                da.From = 1;
154
                da.To = 0.5;
155
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
156
                da.AutoReverse = true;
157
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
158
            }
159
        }
160

    
161
        private void BaseClient_SetFinalPDFCompleted(object sender, SetFinalPDFCompletedEventArgs e)
162
        {
163
            //Logger.sendResLog("SetFinalPDFCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
164
            string errormsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFError", "MSG", "최종 파일을 만드는데 문제가 발생하였습니다");
165
            string successmsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFSuccess", "MSG", "최종 파일 생성 중입니다. 문서관리시스템을 확인해주세요");
166
            if (e.Error != null || e.Result.Status == FinalStatus.Error)
167
            {
168
                DialogMessage_Alert(errormsg, "안내");
169
            }
170
            else
171
            {
172
                DialogMessage_Alert(successmsg, "안내");
173
            }
174
        }
175

    
176
        private void BaseClient_GetVPRevisionHistoryCompleted(object sender, GetVPRevisionHistoryCompletedEventArgs e)
177
        {
178
            //Logger.sendResLog("GetVPRevisionHistoryCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.Count + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
179

    
180
            if (e.Result != null && e.Error == null)
181
            {
182
                List<VPRevision> list = e.Result;
183
                foreach (var item in list)
184
                {
185

    
186
                    if (App.isExternal)
187
                    {
188
                        var sBaseServiceURL = CommonLib.Common.GetConfigString("ExternalOriginalFileUrl", "URL", "", App.isExternal);
189

    
190
                        if (!string.IsNullOrWhiteSpace(item.TO_VENDOR))
191
                        {
192
                            var toUri = new Uri(HttpUtility.UrlDecode(item.TO_VENDOR));
193
                            item.TO_VENDOR = $"{sBaseServiceURL}{toUri.LocalPath}";
194
                        }
195

    
196
                        if (!string.IsNullOrWhiteSpace(item.FROM_VENDOR))
197
                        {
198
                            var fromUri = new Uri(HttpUtility.UrlDecode(item.FROM_VENDOR));
199
                            item.FROM_VENDOR = $"{sBaseServiceURL}{fromUri.LocalPath}";
200
                        }
201
                    }
202
                    else
203
                    {
204
                        item.TO_VENDOR = HttpUtility.UrlDecode(item.TO_VENDOR);
205
                        item.FROM_VENDOR = HttpUtility.UrlDecode(item.FROM_VENDOR);
206
                        item.EnsembleLink = HttpUtility.UrlDecode(item.EnsembleLink);
207
                    }
208
                }
209
                //int result;
210
                //bool iCheck = true;
211
                //foreach (var li in list)
212
                //{                    
213
                //    iCheck = int.TryParse(li.GroupNo, out result);
214
                //    if (!iCheck)
215
                //        break;
216
                //}
217
                //if(iCheck)
218
                    gridViewHistory.ItemsSource = list.OrderByDescending(x => x.GroupNo); //20240611 LJY string 인거 전달드림 slip no 내림차순으로 그냥 해달라고 요청
219
                //else
220
                //    gridViewHistory.ItemsSource = list.OrderByDescending(x => x.RevNo);
221

    
222
            }
223
            //TempFile.TempLoad();
224
        }
225

    
226
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
227
        {
228
            //Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
229

    
230
            foreach(var info in ViewerDataModel.Instance._markupInfoList)
231
            {
232
                if(info.UserID == App.ViewInfo.UserID)
233
                {
234
                    info.userDelete = true;
235
                    info.DisplayColor = "#FFFF0000";
236
                }
237
                else
238
                {
239
                    info.userDelete = false;
240
                }
241
            }
242
        }
243

    
244
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
245
        {
246
            if (e.Error == null)
247
            {
248
                //Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.Count + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
249
            }
250
            else
251
            {
252
                //Logger.sendResLog("GetDeptDataCompleted",  "\r Error :" + e.Error, 1);
253
            }
254

    
255
            if (e.Result != null)
256
            {
257
                e.Result.Sort();
258
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
259
            }
260
        }
261

    
262
        /// <summary>
263
        /// ???
264
        /// </summary>
265
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
266

    
267
        /// <summary>
268
        /// 문서 정보를 가져온다
269
        /// </summary>
270
        /// <param name="sender"></param>
271
        /// <param name="e"></param>
272
        private async void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
273
        {
274
            ////Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
275

    
276
            if (e.Error != null)
277
            {
278
                DialogMessage_Alert("The page cannot be displayed.", "Alert");
279
            }
280
            else if (e.Result == null)
281
            {
282
                DialogMessage_Alert("Document information is missing.", "Alert");
283
            }
284
            else
285
            {
286
                string sFolder = _ViewInfo.DocumentItemID.All(char.IsDigit) ? (Convert.ToUInt64(_ViewInfo.DocumentItemID) / 100).ToString() : (_ViewInfo.DocumentItemID.Length >= 5 ? _ViewInfo.DocumentItemID.Substring(0, 5) : _ViewInfo.DocumentItemID);
287

    
288
                /// 화면의 좌측 Thumbnail의 주소
289
                var MainUrl = string.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal).Replace("png", "jpg"), _ViewInfo.ProjectNO, sFolder, _ViewInfo.DocumentItemID, "{PageNo}");
290
                _DocInfo = e.Result;
291
                _DocInfo.ORIGINAL_FILE = HttpUtility.UrlDecode(_DocInfo.ORIGINAL_FILE);
292
                foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
293
                {
294
                    ViewerDataModel.Instance.Document_Info.Add(item);
295
                }
296
                //Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
297
                CurrentDoc = new Common.DocumentSet
298
                {
299
                    docInfo = _DocInfo,
300
                    Document_Id = _DocInfo.DOCUMENT_ID,
301
                    File_Original = _DocInfo.ORIGINAL_FILE,
302

    
303
                    Document_NO = _DocItem?.DOCUMENT_NO,
304
                    File_Result = _DocItem?.RESULT_FILE,
305
                    Group_No = _DocItem?.GROUP_NO,
306
                    ProjectNo = _DocItem?.PROJECT_NO,
307
                    Revision = _DocItem?.REVISION,
308
                };
309

    
310
                var instanceMain = this.ParentOfType<MainWindow>();
311
                string firstpage = "1";
312
                string lastpage = _DocInfo.PAGE_COUNT.ToString();
313
                instanceMain.dzTopMenu.tlcurrentPage.Text = firstpage;
314
                instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = lastpage;
315
                App.MarkusVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
316

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

    
319
                instanceMain.Title = apptitle;
320

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

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

    
326
                #endregion
327

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

    
330
                //App.SamplePageStorage = new PageManager.PageStorage(MainUrl.Replace("png", "jpg"), tempStoragePath, "jpg", _DocInfo.PAGE_COUNT);
331
                await this.pageNavigator.SetPageNaviAsync(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
332
            }
333
        }
334

    
335
        private void pageNavigator_ThumbInitialized(object sender,EventArgs e)
336
        {
337
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
338

    
339
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
340
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
341

    
342
            /// 기존 임시파일 정리
343
            #region 단어 검색용 파일 다운로드
344

    
345
            DownloadOriginalFile();
346

    
347
            #endregion
348

    
349
            //Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
350
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
351

    
352
        }
353

    
354

    
355
        /// <summary>
356
        /// get markupinfo and markupitem from database
357
        ///  - 1. called when document is loaded
358
        ///  - 2. called when user do consolidation
359
        /// </summary>
360
        /// <param name="sender"></param>
361
        /// <param name="e"></param>
362
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
363
        {
364
            //Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.Count + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
365

    
366
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
367
            ViewerDataModel.Instance.MarkupControls.Clear();
368

    
369
            try
370
            {
371

    
372
                if (e.Result != null)
373
                {
374
                    ViewerDataModel.Instance._markupInfoList.Clear();
375
                    if (e.Result.Count > 0) ViewerDataModel.Instance.MyMarkupList.Clear();
376

    
377
                    foreach (var info in e.Result)
378
                    {
379
                        if (info.Depatment == null) info.Depatment = "Unknown";
380

    
381
                        else if (info.UserID == App.ViewInfo.UserID)
382
                        {
383
                            if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission) //조회모드는 delete 버튼 모두 비활성화
384
                            {
385
                                info.userDelete = false;
386
                            }
387
                            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가 있을 경우
388
                            {
389
                                if(App.ViewInfo.NewCommentPermission && e.Result.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1 && x.MarkupInfoID == info.MarkupInfoID).Count() > 0)                                
390
                                    info.userDelete = true;                                
391
                            }
392
                            else if(App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission) //Consolidation Mode 일 때는 해당 Comment Layer의 Status가 Avoid or Consolidation인 것만 Delete 버튼 활성화
393
                            {
394
                                if(info.AvoidConsolidate == 1 || info.Consolidate == 1)
395
                                    info.userDelete = true;
396
                            }
397
                            else
398
                            {
399
                                info.userDelete = true;
400
                            }                               
401
                            info.DisplayColor = "#FFFF0000";
402
                        }
403
                        else
404
                        {
405
                            info.userDelete = false;
406
                        }
407

    
408
                        ViewerDataModel.Instance._markupInfoList.Add(info);
409
                    }
410

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

    
413
                    userInfoList.ToList().ForEach(x => ViewerDataModel.Instance._markupUserList.Add(x));
414

    
415
                    e.Result.ToList().ForEach(d =>
416
                    {
417
                        if (d.MarkupList != null)
418
                        {
419
                            d.MarkupList.ForEach(p =>
420
                            {
421
                                if (d.UserID == App.ViewInfo.UserID)
422
                                {
423
                                    if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission) //조회모드는 delete 버튼 모두 비활성화
424
                                    {
425
                                        d.userDelete = false;
426
                                    }
427
                                    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가 있을 경우
428
                                    {
429
                                        if (App.ViewInfo.NewCommentPermission && e.Result.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1 && x.MarkupInfoID == d.MarkupInfoID).Count() > 0)
430
                                            d.userDelete = true;
431
                                    }
432
                                    else if (App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission) //Consolidation Mode 일 때는 해당 Comment Layer의 Status가 Avoid or Consolidation인 것만 Delete 버튼 활성화
433
                                    {
434
                                        if (d.AvoidConsolidate == 1 || d.Consolidate == 1)
435
                                            d.userDelete = true;
436
                                    }
437
                                    else
438
                                    {
439
                                        d.userDelete = true;
440
                                    }
441
                                    d.DisplayColor = "#FFFF0000";
442
                                    MarkupItemEx markup = new MarkupItemEx
443
                                    {
444
                                        Data = p.Data,
445
                                        Data_Type = p.Data_Type,
446
                                        ID = p.ID,
447
                                        IsUpdate = false,
448
                                        MarkupInfoID = d.MarkupInfoID,
449
                                        PageNumber = p.PageNumber,
450
                                        Symbol_ID = p.Symbol_ID,
451
                                        //Group_ID = p.Group_ID
452
                                    };
453
                                    ViewerDataModel.Instance.MyMarkupList.Add(markup);
454
                                }
455
                                else
456
                                {
457
                                    MarkupItemEx markup = new MarkupItemEx
458
                                    {
459
                                        Data = p.Data,
460
                                        Data_Type = p.Data_Type,
461
                                        ID = p.ID,
462
                                        IsUpdate = false,
463
                                        MarkupInfoID = d.MarkupInfoID,
464
                                        PageNumber = p.PageNumber,
465
                                        Symbol_ID = p.Symbol_ID,
466
                                        //Group_ID = p.Group_ID
467
                                    };
468
                                    ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
469
                                }
470
                            });
471
                        }
472
                    });
473

    
474
                    var currentUser = e.Result.Find(data => data.UserID == App.ViewInfo.UserID && data.AvoidConsolidate == 0);
475
                    if (currentUser == null)
476
                    {
477
                        /// create a new markupinfo to do comments
478
                        if (App.ViewInfo.NewCommentPermission)
479
                        {
480
                            var infoId = Commons.shortGuid();
481
                            PreviewUserMarkupInfoItem = new MarkupInfoItem
482
                            {
483
                                CreateTime = DateTime.Now,
484
                                UpdateTime = DateTime.Now,
485
                                Depatment = userData.DEPARTMENT,
486
                                DisplayColor = "#FFFF0000",
487
                                UserID = userData.ID,
488
                                UserName = userData.NAME,
489
                                PageCount = 1,
490
                                Description = "",
491
                                MarkupInfoID = infoId,
492
                                MarkupList = null,
493
                                MarkupVersionID = Commons.shortGuid(),
494
                                Consolidate = 0,
495
                                PartConsolidate = 0,
496
                                userDelete = true,
497
                                AvoidConsolidate = 0,
498
                                IsPreviewUser = false
499
                            };
500

    
501
                            App.Custom_ViewInfoId = infoId;
502

    
503
                            ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
504
                        }
505
                    }
506
                    else
507
                    {
508
                        App.Custom_ViewInfoId = currentUser.MarkupInfoID;
509
                    }
510

    
511
                    ViewerDataModel.Instance.SyncPageNumber = 1;
512

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

    
516
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
517

    
518
                    SetCommentPages(null);
519

    
520
                    // GRIDVIEW에서 팀별 GROUPING
521
                    // 효성은 안함
522
#if (Hyosung)
523
#else
524
                    /// create a group descriptor
525
                    gridViewMarkup.GroupDescriptors.Clear();
526
                    GroupDescriptor descriptor = new GroupDescriptor();
527
                    descriptor.Member = "Depatment";
528
                    descriptor.DisplayContent = "DEPT";
529
                    //descriptor.SortDirection = ListSortDirection.Ascending;
530
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
531
#endif
532

    
533
                    GridViewMarkup_Sorting(gridViewMarkup, new GridViewSortingEventArgs(gridViewMarkup.Columns[0], SortingState.None, SortingState.None));
534

    
535
                    SelectInitialMarkupInfo();
536
                }
537
            }
538
            catch (Exception ex) 
539
            {
540
                App.FileLogger.Fatal(ex);
541
            }
542
            finally
543
            {
544
                if(!ViewerDataModel.Instance.SystemMain.dzMainMenu.btnFinalPDF.IsEnabled)
545
                {
546
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.btnFinalPDF.IsEnabled = true;
547
                }
548

    
549
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.btnConsolidate.IsEnabled)
550
                {
551
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.btnConsolidate.IsEnabled = true;
552
                }
553
            }
554
        }
555

    
556
        /// <summary>
557
        /// 프로그램이 로딩되고 난 후 맨처음으로 MarkupInfo를 선택한다. 
558
        /// </summary>
559
        private void SelectInitialMarkupInfo()
560
        {
561
            if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
562
            {
563
                #region Consolidate 항목이 있으면 Consolidate 항목만 추가
564
                if (ViewerDataModel.Instance._markupInfoList.Any(x => x.Consolidate == 1 && x.AvoidConsolidate == 0))
565
                {
566
                    var Consolidates = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0).ToList();
567
                    Consolidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
568
                }
569
                #endregion
570
                #region Consolidate 항목이 없을 경우에는 사용자 별로 AvoidConsolidate를 제외한 우선 순위가 높은(Team,Comment)항목들을 선택
571
                else
572
                {
573
                    var MarkupInfoColl = ViewerDataModel.Instance._markupInfoList.Where(x => x.AvoidConsolidate == 0).ToList();
574

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

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

    
587
                    Candidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
588
                }
589
                #endregion
590
            }
591
            else if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)   /// Eng'r Comment Mode
592
            {
593
                var MarkupInfoColl = ViewerDataModel.Instance._markupInfoList.Where(x => x.AvoidConsolidate == 0).ToList();
594

    
595
                #region Team consolidate 항목 선택
596
                var Candidates = MarkupInfoColl.Where(x => x.PartConsolidate == 1 && x.AvoidConsolidate == 0).ToList();
597
                MarkupInfoColl.RemoveAll(x => Candidates.Exists(y => y.UserID == x.UserID));
598
                #endregion
599

    
600
                #region 추가되지 않은 사용자들을 추가
601
                foreach (var item in MarkupInfoColl.Where(x => !Candidates.Exists(y => y.UserID == x.UserID)))
602
                {
603
                    Candidates.Add(item);
604
                }
605
                #endregion
606

    
607
                Candidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
608
            }
609
            else if (App.ViewInfo.CreateFinalPDFPermission)    /// Orig Comment Model
610
            {
611
                if (ViewerDataModel.Instance._markupInfoList.Any(x => x.Consolidate == 1 && x.AvoidConsolidate == 0))
612
                {
613
                    var Consolidates = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0).ToList();
614
                    Consolidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
615
                }
616
                else if (ViewerDataModel.Instance._markupInfoList.Any(x => x.PartConsolidate == 1 && x.AvoidConsolidate == 0))
617
                {
618
                    var MarkupInfoColl = ViewerDataModel.Instance._markupInfoList.Where(x => x.AvoidConsolidate == 0).ToList();
619

    
620
                    #region Team consolidate 항목 선택
621
                    var Candidates = MarkupInfoColl.Where(x => x.PartConsolidate == 1 && x.AvoidConsolidate == 0).ToList();
622
                    MarkupInfoColl.RemoveAll(x => Candidates.Exists(y => y.UserID == x.UserID));
623
                    #endregion
624

    
625
                    #region 추가되지 않은 사용자들을 추가
626
                    foreach (var item in MarkupInfoColl.Where(x => !Candidates.Exists(y => y.UserID == x.UserID)))
627
                    {
628
                        Candidates.Add(item);
629
                    }
630
                    #endregion
631

    
632
                    Candidates.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
633
                }
634
                else
635
                {
636
                    var Comments = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 0 && x.AvoidConsolidate == 0).ToList();
637
                    Comments.ForEach(x => gridViewMarkup.SelectedItems.Add(x));
638
                }
639
            }
640

    
641
            if (!gridViewMarkup.SelectedItems.Any())
642
            {
643
                var SelectedItem = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.UpdateTime).FirstOrDefault();
644

    
645
                if (PreviewUserMarkupInfoItem != null)
646
                {
647
                    this.gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
648
                }
649
                else if (SelectedItem != null)
650
                {
651
                    this.gridViewMarkup.SelectedItem = SelectedItem;
652
                }
653
                else if (ViewerDataModel.Instance._markupInfoList.Any())
654
                {
655
                    this.gridViewMarkup.SelectedItem = ViewerDataModel.Instance._markupInfoList[0];
656
                }
657
            }
658
        }
659

    
660
        private void GridViewMarkup_Sorting(object sender, GridViewSortingEventArgs e)
661
        {
662
            IEnumerable<IKCOM.MarkupInfoItem> markuplist = e.DataControl.ItemsSource as IEnumerable<IKCOM.MarkupInfoItem>;
663

    
664
            if(markuplist == null)
665
            {
666
                e.Cancel = true;
667
                return;
668
            }
669

    
670
            if(e.NewSortingState == SortingState.None)
671
            {
672
                markuplist = markuplist.OrderByDescending(x => SortIndex(x))
673
                                            .ThenBy(x => x.Depatment)
674
                                            .ThenBy(x => x.UserID);
675

    
676
                e.DataControl.ItemsSource = markuplist.ToList();
677
            }
678
        }
679

    
680

    
681
        // 마크업 리스트 정렬
682
        private int SortIndex(IKCOM.MarkupInfoItem markupInfoItem)
683
        {
684
            int result = 0;
685

    
686
            // Consolidate은 최상단
687
            if (markupInfoItem.Consolidate == 1)
688
            {
689
                result += 2;
690
            }
691

    
692
            /// Consolidate 다음으로 우선순위
693
            if (markupInfoItem.UserID == App.ViewInfo.UserID)
694
            {
695
                result += 1;
696
            }
697

    
698
            return result;
699
        }
700

    
701

    
702
        private void GridViewMarkup_Sorted(object sender, GridViewSortedEventArgs e)
703
        {
704

    
705
        }
706

    
707
        private async void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
708
        {
709
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
710
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
711
            //{
712
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
713
            //}
714

    
715
            if (ViewerDataModel.Instance.SyncPageNumber == 0)
716
            {
717
                ViewerDataModel.Instance.SyncPageNumber = 1;
718
            }
719
            if (e.AddedItems.Count() > 0)
720
            {
721
                foreach (var item in gridSelectionItem)
722
                {
723
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
724
                    //{
725
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
726
                    //});
727

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

    
730
                    foreach (var markupitem in pageItems)
731
                    {
732
                       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);
733
                    }
734
                }
735
            }
736
            else if (e.RemovedItems.Count > 0)
737
            {
738
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
739

    
740
                (from A in _infoItem
741
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
742
                 where A.MarkupInfoID == B.MarkupInfoID
743
                 select B).ToList().ForEach(data =>
744
                 {
745
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
746
                 });
747
            }
748
        }
749

    
750
        /// <summary>
751
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
752
        /// </summary>
753
        /// <param name="sender"></param>
754
        /// <param name="e"></param>
755
        private async void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
756
        {
757

    
758
            foreach (var item in e.AddedItems)
759
            {
760
                var cellToSelect = new GridViewCellInfo(item, this.gridViewMarkup.Columns["color"], this.gridViewMarkup);
761

    
762
                if(cellToSelect != null)
763
                {
764

    
765
                }
766
            }
767

    
768
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
769

    
770
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
771
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
772
            var resultA = (from item_Select in dataSet
773
                           from item_Non in dataSet_User
774
                           where item_Select == item_Non
775
                           select item_Non).ToList();
776

    
777
            if (resultA.Count() >= 2)
778
            {
779
                // 동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?
780
                RadWindow.Confirm(new DialogParameters
781
                {
782
                    Owner = Application.Current.MainWindow,
783
                    Header = "Info",
784
                    Content = "Selected more than two identical user data. Do you want to select consolidation?",
785
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
786
                    {
787
                        if(ea.DialogResult == null)
788
                        {
789
                            return;
790
                        }
791
                        if (e.AddedItems.Count() == 1)
792
                        {
793
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
794
                            gridViewMarkup.SelectedItem = null;
795

    
796
                        
797
                            if (ea.DialogResult.Value)
798
                            {
799
                                if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
800
                                {
801
                                    gridViewMarkup.SelectedItem = instanceItem;
802
                                }
803
                                else
804
                                {
805
                                    //1. Consolidations이 있다면 하나 선택
806
                                    var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
807

    
808
                                    if (Consolidations.Count() > 0)
809
                                    {
810
                                        gridViewMarkup.SelectedItem = Consolidations.First();
811
                                    }
812
                                }
813
                              
814
                            }
815
                            else {
816
                                //1. Consolidations 아닌게 있다면 Change
817
                                var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
818

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

    
850
                                foreach (var markup in instance)
851
                                {
852
                                    await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", 
853
                                        item.MarkupInfoID, markup.ID,STAMP_Contents:App.SystemInfo.STAMP_CONTENTS);
854
                                }
855
                            }
856

    
857
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
858
                            foreach (var control in controls)
859
                            {
860
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
861
                                control.Visibility = Visibility.Visible;
862
                            }
863
                        }
864
                        else
865
                        {
866
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
867
                            if (controls.Count == 0)
868
                            {
869
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
870
                                foreach (var markup in instance)
871
                                {
872
                                    await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
873
                                        item.MarkupInfoID, markup.ID);
874
                                }
875
                            }
876

    
877
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
878
                            foreach (var control in controls)
879
                            {
880
                                control.Visibility = Visibility.Visible;
881
                            }
882
                        }
883
                    }
884
                }
885
#endregion
886
#region 코멘트 숨기기
887
                else if (e.RemovedItems.Count > 0)
888
                {
889
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
890

    
891
                    (from A in _infoItem
892
                     from B in Common.ViewerDataModel.Instance.MarkupControls
893
                     where A.MarkupInfoID == B.MarkupInfoID
894
                     select B).ToList().ForEach(data =>
895
                     {
896
                         data.Visibility = Visibility.Hidden;                         
897
                     });
898

    
899

    
900
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
901
                    if (myComment != null)
902
                    {
903
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
904
                        {
905
                            markupitem.Visibility = Visibility.Hidden;
906
                        });
907
                    }
908
                }
909
#endregion
910
            }
911
        }
912

    
913
        private async void gridViewMarkup_SelectedCellsChanged(object sender, Telerik.Windows.Controls.GridView.GridViewSelectedCellsChangedEventArgs e)
914
        {
915
            if (e.AddedCells.Count() > 0)
916
            {
917
                if(e.AddedCells[0].Column.Name == "color")
918
                {
919

    
920
                }
921
                else
922
                {
923
                    List<MarkupInfoItem> removeItems = new List<MarkupInfoItem>();
924

    
925
                    if (!gridViewMarkup.SelectedItems.Contains(e.AddedCells[0].Item))
926
                    {
927
                        gridViewMarkup.SelectedItems.Add(e.AddedCells[0].Item);
928
                    }
929
                    else
930
                    {
931
                        gridViewMarkup.Unselect(new[] { e.AddedCells[0].Item });
932

    
933
                        removeItems.Add(e.AddedCells[0].Item as MarkupInfoItem);
934
                    }
935

    
936
                    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
937

    
938
                    var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
939
                    var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
940
                    var resultA = (from item_Select in dataSet
941
                                   from item_Non in dataSet_User
942
                                   where item_Select == item_Non
943
                                   select item_Non).ToList();
944

    
945
                    if (resultA.Count() >= 2)
946
                    {
947
                        // 동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?
948
                        RadWindow.Confirm(new DialogParameters
949
                        {
950
                            Owner = Application.Current.MainWindow,
951
                            Header = "Info",
952
                            Content = "Selected more than two identical user data. Do you want to select consolidation?",
953
                            Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
954
                            {
955
                                if (ea.DialogResult == null)
956
                                {
957
                                    return;
958
                                }
959
                                if (gridViewMarkup.SelectedItems.Count() == 1)
960
                                {
961
                                    MarkupInfoItem instanceItem = gridViewMarkup.SelectedItems.FirstOrDefault() as MarkupInfoItem;
962
                                    gridViewMarkup.SelectedItem = null;
963

    
964

    
965
                                    if (ea.DialogResult.Value)
966
                                    {
967
                                        if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
968
                                        {
969
                                            gridViewMarkup.SelectedItem = instanceItem;
970
                                        }
971
                                        else
972
                                        {
973
                                            //1. Consolidations이 있다면 하나 선택
974
                                            var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
975

    
976
                                            if (Consolidations.Count() > 0)
977
                                            {
978
                                                gridViewMarkup.SelectedItem = Consolidations.First();
979
                                            }
980
                                        }
981

    
982
                                    }
983
                                    else
984
                                    {
985
                                        //1. Consolidations 아닌게 있다면 Change
986
                                        var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
987

    
988
                                        if (notConsolidations.Count() > 0)
989
                                        {
990
                                            gridViewMarkup.SelectedItem = notConsolidations.First();
991
                                        }
992
                                        else
993
                                        {//1. Consolidations 아닌게 없다면 그대로
994
                                            gridViewMarkup.SelectedItem = instanceItem;
995
                                        }
996

    
997
                                    }
998
                                }
999
                            }),
1000
                            Theme = new Windows8Theme(),
1001
                            ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
1002
                        });
1003
                    }
1004
                    else //파라미터로 넘어온 사용자가 걸리지 않은 경우
1005
                    {
1006
                        List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
1007
                        List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1008
                        List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
1009
                        #region 코멘트 보기
1010
                        if (gridViewMarkup.SelectedItems.Count() > 0 && this.pageNavigator.CurrentPage != null)
1011
                        {
1012
                            foreach (var item in gridSelectionItem)
1013
                            {
1014
                                if (item.UserID == App.ViewInfo.UserID)
1015
                                {
1016
                                    var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
1017
                                    if (controls.Count == 0)
1018
                                    {
1019
                                        var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
1020

    
1021
                                        foreach (var markup in instance)
1022
                                        {
1023
                                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
1024
                                                item.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1025
                                        }
1026
                                    }
1027

    
1028
                                    controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
1029
                                    foreach (var control in controls)
1030
                                    {
1031
                                        Logger.sendCheckLog(String.Format("=={0}", control), 1);
1032
                                        control.Visibility = Visibility.Visible;
1033
                                    }
1034
                                }
1035
                                else
1036
                                {
1037
                                    var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
1038
                                    if (controls.Count == 0)
1039
                                    {
1040
                                        var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
1041
                                        foreach (var markup in instance)
1042
                                        {
1043
                                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
1044
                                                item.MarkupInfoID, markup.ID);
1045
                                        }
1046
                                    }
1047

    
1048
                                    controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
1049
                                    foreach (var control in controls)
1050
                                    {
1051
                                        control.Visibility = Visibility.Visible;
1052
                                    }
1053
                                }
1054
                            }
1055
                        }
1056
                        #endregion
1057
                        #region 코멘트 숨기기
1058
                        else if (removeItems.Count > 0)
1059
                        {
1060
                            (from A in removeItems
1061
                             from B in Common.ViewerDataModel.Instance.MarkupControls
1062
                             where A.MarkupInfoID == B.MarkupInfoID
1063
                             select B).ToList().ForEach(data =>
1064
                             {
1065
                                 data.Visibility = Visibility.Hidden;
1066
                             });
1067

    
1068

    
1069
                            var myComment = removeItems.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
1070
                            if (myComment != null)
1071
                            {
1072
                                Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
1073
                                {
1074
                                    markupitem.Visibility = Visibility.Hidden;
1075
                                });
1076
                            }
1077
                        }
1078
                        #endregion
1079
                    }
1080
                }
1081
            }
1082
        }
1083

    
1084
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
1085
        {
1086
            //Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.DOCUMENT_ID + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
1087

    
1088
            if (e.Result != null)
1089
            {
1090
                _DocItem = e.Result;
1091

    
1092
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
1093
                {
1094
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
1095
                }
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
                DialogMessage_Alert("Document Information Not Found.", "Error");
1102

    
1103
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
1104
                {
1105
                    //Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
1106

    
1107
                    if (ea.Error == null)
1108
                    {
1109
                        if (ea.Result)
1110
                        {
1111
                            this._ViewInfo.isAdmin = true;
1112
                            //Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
1113
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
1114
                        }
1115
                        else
1116
                        {
1117
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
1118
                            DialogMessage_Alert("You are not belong to this project. Please ask admin for an authority.", "Info");
1119
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
1120
                        }
1121

    
1122
                    }
1123
                    else
1124
                    {
1125
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
1126
                    }
1127
                };
1128
                //Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
1129
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
1130
            }
1131
        }
1132

    
1133
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
1134
        {
1135
            //Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
1136

    
1137
            if (e.Error == null && e.Result != null)
1138
            {
1139
                App.SystemInfo = e.Result;
1140

    
1141
                //App.urlPort_DB = App.SystemInfo.HostPort;
1142
                //App.urlHost_DB = App.SystemInfo.HostName;
1143
                //Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
1144
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
1145

    
1146
                //if (App.urlHost.Contains("localhost"))
1147
                //{
1148
                //    App.urlHost = App.urlHost_DB;
1149
                //}
1150
            }
1151
        }
1152

    
1153
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
1154
        {
1155
            if (e.Error == null && e.Result)
1156
            {
1157
                //Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
1158

    
1159
                BaseClient.GetDocumentItemInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID, userID = _ViewInfo.UserID });
1160

    
1161
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
1162
                {
1163
                    //Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
1164
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
1165
                    if (userData != null)
1166
                    {
1167
                        //Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
1168
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
1169
                    }
1170
                    else
1171
                    {
1172
                        userData = new MEMBER();
1173
                        userData.DEPARTMENT = "ALL";
1174
                        //Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
1175
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
1176
                    }
1177
                }
1178
            }
1179
            else
1180
            {
1181
                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잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
1182
                DialogMessage_Alert(failedmsg, "Warning");
1183
            }
1184
        }
1185

    
1186
        public void SetView(ViewInfo info)
1187
        { 
1188
            this._ViewInfo = info;
1189
            try
1190
            {
1191
                /// 대림의 경우 EnsembleID를 가지고 DocumentItemID를 구함
1192
                /// 다른 Site를 대비하여 에러 처리함
1193
                string docid = BaseClient.GetDocItemID(info.EnsembleID);
1194
                if (!string.IsNullOrEmpty(docid))
1195
                {
1196
                    this._ViewInfo.DocumentItemID = docid;
1197
                }
1198
            }
1199
            catch (Exception ex)
1200
            {
1201

    
1202
                //App.FileLogger.Fatal(ex);
1203
            }
1204

    
1205
            //Logger.sendReqLog("GetSystemDataAsync", "", 1);
1206

    
1207
            BaseClient.GetSystemDataAsync();
1208
        }
1209

    
1210
        public void HubSet()
1211
        {
1212
            // 허브 연결 구성
1213
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
1214
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
1215

    
1216

    
1217
            // 허브 연결 
1218
            hubConnection.Start().ContinueWith(task =>
1219
            {
1220
                if (task.IsFaulted)
1221
                {
1222
                    Console.WriteLine("There was an error opening the connection:{0}",
1223
                                      task.Exception.GetBaseException());
1224
                    //throw task.Exception.GetBaseException();
1225
                }
1226
                else
1227
                {
1228
                    Console.WriteLine("Connected :: " + task.Id);
1229
                }
1230

    
1231
            }).Wait();
1232

    
1233

    
1234
            // [ 프로그램 시작 ]
1235
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
1236
            //( "method name", arg1, arg2 )
1237
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
1238
            //{
1239
            //    if (task.IsFaulted)
1240
            //    {
1241
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
1242
            //    }
1243
            //    else
1244
            //    {
1245
            //        Console.WriteLine(task.Result);
1246
            //    }
1247
            //});
1248
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID,App.ViewInfo.ProjectNO).ContinueWith(task =>
1249
            {
1250
                if (task.IsFaulted)
1251
                {
1252
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
1253
                    //throw task.Exception.GetBaseException();
1254
                }
1255
                else
1256
                {
1257
                    switch (task.Result)
1258
                    {
1259
                        case "2":
1260
                            {
1261
                                var result = MessageBox.Show("권한이 없습니다.");
1262
                                if (result == MessageBoxResult.OK)
1263
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
1264
                            }
1265
                            break;
1266
                        case "404":
1267
                            {
1268
                                var result = MessageBox.Show("등록된 사용자가 아닙니다.");
1269
                                if(result == MessageBoxResult.OK)
1270
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
1271
                            }
1272
                            break;
1273
                    }
1274
                }
1275
            });
1276

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

    
1281
            //    if (status)
1282
            //    {
1283
            //        // 프로그램 시작 
1284
            //        Console.WriteLine("connection status : " + status);
1285
            //    }
1286
            //    else
1287
            //    {
1288
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
1289
            //        hubConnection.Stop();
1290
            //    }
1291
            //});
1292

    
1293
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
1294
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
1295
                Console.WriteLine("Noficiation Message : " + msg)
1296
            );
1297

    
1298

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

    
1302
            //Console.ReadKey();
1303

    
1304
            //hubConnection.Stop();
1305
        }
1306

    
1307
        public async void MarkupUserListDisplay()
1308
        {
1309
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
1310
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1311
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
1312
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
1313
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
1314
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
1315
            //foreach (var item in gridSelectionItem)
1316
            //{
1317
            //    if (item.UserID == App.ViewInfo.UserID)
1318
            //    {
1319
            //        ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
1320
            //        {
1321
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
1322
            //        });
1323
            //    }
1324
            //    else
1325
            //    {
1326
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
1327
            //        {
1328
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
1329
            //        });
1330
            //    }
1331
            //}
1332
                (from A in gridSelectionItem
1333
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
1334
                 where A.MarkupInfoID == B.MarkupInfoID
1335
                 select B).ToList().ForEach(data =>
1336
                 {
1337
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
1338
                 });
1339
            (from A in gridSelectionItem
1340
             from B in Common.ViewerDataModel.Instance.MarkupControls
1341
             where A.MarkupInfoID == B.MarkupInfoID
1342
             select B).ToList().ForEach(data =>
1343
             {
1344
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
1345
             });
1346

    
1347
            foreach (var item in gridSelectionItem)
1348
            {
1349

    
1350
                if (item.UserID == App.ViewInfo.UserID)
1351
                {
1352
                    var markupItems = ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
1353

    
1354
                    foreach (var markupitem in markupItems)
1355
                    {
1356
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", 
1357
                                item.MarkupInfoID, markupitem.ID);
1358
                    }
1359
                }
1360
                else
1361
                {
1362
                    var markupItems = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
1363

    
1364
                    foreach (var markupitem in markupItems)
1365
                    {
1366
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1367
                    }
1368
                }
1369
            }
1370
        }
1371
    }
1372
}
클립보드 이미지 추가 (최대 크기: 500 MB)