프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 99b9f32a

이력 | 보기 | 이력해설 | 다운로드 (50.3 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

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

    
32
        public ViewInfo _ViewInfo;
33
        public DOCINFO _DocInfo;
34
        public DOCUMENT_ITEM _DocItem;
35
        public MEMBER userData;
36
        public List<int> MarkupSortList = new List<int>();
37

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

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

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

    
83

    
84

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

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

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

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

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

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

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

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

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

    
194
                        if (!string.IsNullOrWhiteSpace(item.FROM_VENDOR))
195
                        {
196
                            var fromUri = new Uri(HttpUtility.UrlDecode(item.FROM_VENDOR));
197
                            item.FROM_VENDOR = $"{sBaseServiceURL}{fromUri.LocalPath}";
198
                        }
199
                    }
200
                    else
201
                    {
202

    
203
                        item.FROM_VENDOR = HttpUtility.UrlDecode(item.FROM_VENDOR);
204
                    }
205
                }
206

    
207
                gridViewHistory.ItemsSource = list.OrderByDescending(x=>x.RevNo);
208
            }
209
            //TempFile.TempLoad();
210
        }
211

    
212
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
213
        {
214
            //Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
215

    
216
            foreach(var info in ViewerDataModel.Instance._markupInfoList)
217
            {
218
                if(info.UserID == App.ViewInfo.UserID)
219
                {
220
                    info.userDelete = true;
221
                    info.DisplayColor = "#FFFF0000";
222
                }
223
                else
224
                {
225
                    info.userDelete = false;
226
                }
227
            }
228
        }
229

    
230
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
231
        {
232
            if (e.Error == null)
233
            {
234
                //Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.Count + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
235
            }
236
            else
237
            {
238
                //Logger.sendResLog("GetDeptDataCompleted",  "\r Error :" + e.Error, 1);
239
            }
240

    
241
            if (e.Result != null)
242
            {
243
                e.Result.Sort();
244
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
245
            }
246
        }
247

    
248
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
249

    
250
        /// <summary>
251
        /// 문서 정보를 가져온다
252
        /// </summary>
253
        /// <param name="sender"></param>
254
        /// <param name="e"></param>
255
        private async void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
256
        {
257
            ////Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
258

    
259
            if (e.Error != null)
260
            {
261
                DialogMessage_Alert("The page cannot be displayed.", "Alert");
262
            }
263
            else if (e.Result == null)
264
            {
265
                DialogMessage_Alert("Document information is missing.", "Alert");
266
            }
267
            else
268
            {
269
                //string sFolder = _ViewInfo.DocumentItemID.All(char.IsDigit) ? (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString() : (_ViewInfo.DocumentItemID.Length >= 5 ? _ViewInfo.DocumentItemID.Substring(0, 5) : _ViewInfo.DocumentItemID);
270

    
271
                /// 화면의 좌측 Thumbnail의 주소
272
                //var MainUrl = string.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal).Replace("png", "jpg"), _ViewInfo.ProjectNO, sFolder, _ViewInfo.DocumentItemID, "{PageNo}");
273

    
274
                // SEC 전용 
275
                var MainUrl = string.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID);
276

    
277
                _DocInfo = e.Result;
278
                _DocInfo.ORIGINAL_FILE = HttpUtility.UrlDecode(_DocInfo.ORIGINAL_FILE);
279
                foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
280
                {
281
                    ViewerDataModel.Instance.Document_Info.Add(item);
282
                }
283
                //Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
284
                CurrentDoc = new Common.DocumentSet
285
                {
286
                    docInfo = _DocInfo,
287
                    Document_Id = _DocInfo.DOCUMENT_ID,
288
                    File_Original = _DocInfo.ORIGINAL_FILE,
289

    
290
                    Document_NO = _DocItem?.DOCUMENT_NO,
291
                    File_Result = _DocItem?.RESULT_FILE,
292
                    Group_No = _DocItem?.GROUP_NO,
293
                    ProjectNo = _DocItem?.PROJECT_NO,   
294
                    Revision = _DocItem?.REVISION,
295
                };
296

    
297
                var instanceMain = this.ParentOfType<MainWindow>();
298
                string firstpage = "1";
299
                string lastpage = _DocInfo.PAGE_COUNT.ToString();
300
                instanceMain.dzTopMenu.tlcurrentPage.Text = firstpage;
301
                instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = lastpage;
302
                App.MarkusVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
303

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

    
306
                instanceMain.Title = apptitle;
307

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

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

    
313
                #endregion
314

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

    
317
                //App.SamplePageStorage = new PageManager.PageStorage(MainUrl.Replace("png", "jpg"), tempStoragePath, "jpg", _DocInfo.PAGE_COUNT);
318
                await this.pageNavigator.SetPageNaviAsync(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
319

    
320
                //this.pageNavigator._thumbnailItems = new ObservableCollection<ThumbnailItem>
321
                //{
322
                //    new ThumbnailItem
323
                //    {
324
                //        Angle = 0,
325
                //        DisplayColorItems = new List<SetColorMarkupItem>(),
326
                //        Height = 100,
327
                //        Width = 100,
328
                //        ImageUri = new Uri("http://localhost"),
329
                //        IsActive = true,
330
                //        PageNumber = 1,
331
                //        PageUri = new Uri(MainUrl.Replace("jpg", "png")),
332
                //    }
333
                //};
334

    
335
                //this.pageNavigator.ChangePage(1);
336
            }
337
        }
338

    
339
        private void pageNavigator_ThumbInitialized(object sender,EventArgs e)
340
        {
341
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
342

    
343
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
344
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
345

    
346
            /// 기존 임시파일 정리
347
            #region 단어 검색용 파일 다운로드
348

    
349
            DownloadOriginalFile();
350

    
351
            #endregion
352

    
353
            //Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
354
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
355

    
356
        }
357

    
358

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

    
370
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
371
            ViewerDataModel.Instance.MarkupControls.Clear();
372

    
373
            try
374
            {
375

    
376
                if (e.Result != null)
377
                {
378
                    ViewerDataModel.Instance._markupInfoList.Clear();
379
                    if (e.Result.Count > 0) ViewerDataModel.Instance.MyMarkupList.Clear();
380

    
381
                    foreach (var info in e.Result)
382
                    {
383
                        if (info.Depatment == null) info.Depatment = "Unknown";
384

    
385
                        if (info.UserID == App.ViewInfo.UserID)
386
                        {
387
                            info.userDelete = true;
388
                            info.DisplayColor = "#FFFF0000";
389
                        }
390
                        else
391
                        {
392
                            info.userDelete = false;
393
                        }
394

    
395
                        ViewerDataModel.Instance._markupInfoList.Add(info);
396
                    }
397

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

    
400
                    userInfoList.ToList().ForEach(x => ViewerDataModel.Instance._markupUserList.Add(x));
401

    
402
                    e.Result.ToList().ForEach(d =>
403
                    {
404
                        if (d.MarkupList != null)
405
                        {
406
                            d.MarkupList.ForEach(p =>
407
                            {
408
                                if (d.UserID == App.ViewInfo.UserID)
409
                                {
410
                                    d.userDelete = true;
411
                                    d.DisplayColor = "#FFFF0000";
412

    
413
                                    MarkupItemEx markup = new MarkupItemEx
414
                                    {
415
                                        Data = p.Data,
416
                                        Data_Type = p.Data_Type,
417
                                        ID = p.ID,
418
                                        IsUpdate = false,
419
                                        MarkupInfoID = d.MarkupInfoID,
420
                                        PageNumber = p.PageNumber,
421
                                        Symbol_ID = p.Symbol_ID,
422
                                        //Group_ID = p.Group_ID
423
                                    };
424
                                    ViewerDataModel.Instance.MyMarkupList.Add(markup);
425
                                }
426
                                else
427
                                {
428
                                    MarkupItemEx markup = new MarkupItemEx
429
                                    {
430
                                        Data = p.Data,
431
                                        Data_Type = p.Data_Type,
432
                                        ID = p.ID,
433
                                        IsUpdate = false,
434
                                        MarkupInfoID = d.MarkupInfoID,
435
                                        PageNumber = p.PageNumber,
436
                                        Symbol_ID = p.Symbol_ID,
437
                                        //Group_ID = p.Group_ID
438
                                    };
439
                                    ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
440
                                }
441
                            });
442
                        }
443
                    });
444

    
445
                    var currentUser = e.Result.Where(data => data.UserID == App.ViewInfo.UserID && data.AvoidConsolidate == 0).FirstOrDefault();
446

    
447
                    if (currentUser == null)
448
                    {
449
                        /// create a new markupinfo to do comments
450
                        /// 
451
                        if (App.ViewInfo.NewCommentPermission)
452
                        {
453
                            var infoId = Commons.shortGuid();
454
                            PreviewUserMarkupInfoItem = new MarkupInfoItem
455
                            {
456
                                CreateTime = DateTime.Now,
457
                                UpdateTime = DateTime.Now,
458
                                Depatment = userData.DEPARTMENT,
459
                                DisplayColor = "#FFFF0000",
460
                                UserID = userData.ID,
461
                                UserName = userData.NAME,
462
                                PageCount = 1,
463
                                Description = "",
464
                                MarkupInfoID = infoId,
465
                                MarkupList = null,
466
                                MarkupVersionID = Commons.shortGuid(),
467
                                Consolidate = 0,
468
                                PartConsolidate = 0,
469
                                userDelete = true,
470
                                AvoidConsolidate = 0,
471
                                IsPreviewUser = false
472
                            };
473

    
474
                            App.Custom_ViewInfoId = infoId;
475

    
476
                            ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
477
                        }
478
                    }
479
                    else
480
                    {
481
                        App.Custom_ViewInfoId = currentUser.MarkupInfoID;
482
                    }
483

    
484
                    ViewerDataModel.Instance.SyncPageNumber = 1;
485

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

    
489
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
490

    
491
                    SetCommentPages(null);
492

    
493
                    // GRIDVIEW에서 팀별 GROUPING
494
                    // 효성은 안함
495
#if (Hyosung)
496
#else
497
                    /// create a group descriptor
498
                    gridViewMarkup.GroupDescriptors.Clear();
499
                    GroupDescriptor descriptor = new GroupDescriptor();
500
                    descriptor.Member = "Depatment";
501
                    descriptor.DisplayContent = "DEPT";
502
                    //descriptor.SortDirection = ListSortDirection.Ascending;
503
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
504
#endif
505

    
506
                    GridViewMarkup_Sorting(gridViewMarkup, new GridViewSortingEventArgs(gridViewMarkup.Columns[0], SortingState.None, SortingState.None));
507

    
508
                    var SelectedItem = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.UpdateTime).FirstOrDefault();
509

    
510
                    if (PreviewUserMarkupInfoItem != null)
511
                    {
512
                        this.gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
513
                    }
514
                    else if (SelectedItem != null)
515
                    {
516
                        this.gridViewMarkup.SelectedItem = SelectedItem;
517
                    }
518
                    else if (ViewerDataModel.Instance._markupInfoList.Count() > 0)
519
                    {
520
                        this.gridViewMarkup.SelectedItem = ViewerDataModel.Instance._markupInfoList.First();
521
                    }
522
                }
523
            }
524
            catch (Exception ex) 
525
            {
526
                App.FileLogger.Fatal(ex);
527
            }
528
            finally
529
            {
530
                if(!ViewerDataModel.Instance.SystemMain.dzMainMenu.btnFinalPDF.IsEnabled)
531
                {
532
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.btnFinalPDF.IsEnabled = true;
533
                }
534

    
535
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.btnConsolidate.IsEnabled)
536
                {
537
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.btnConsolidate.IsEnabled = true;
538
                }
539
            }
540
        }
541

    
542
        private void GridViewMarkup_Sorting(object sender, GridViewSortingEventArgs e)
543
        {
544
            IEnumerable<IKCOM.MarkupInfoItem> markuplist = e.DataControl.ItemsSource as IEnumerable<IKCOM.MarkupInfoItem>;
545

    
546
            if(markuplist == null)
547
            {
548
                e.Cancel = true;
549
                return;
550
            }
551

    
552
            if(e.NewSortingState == SortingState.None)
553
            {
554
                markuplist = markuplist.OrderByDescending(x => SortIndex(x))
555
                                            .ThenBy(x => x.Depatment)
556
                                            .ThenBy(x => x.UserID);
557

    
558
                e.DataControl.ItemsSource = markuplist.ToList();
559
            }
560
        }
561

    
562

    
563
        // 마크업 리스트 정렬
564
        private int SortIndex(IKCOM.MarkupInfoItem markupInfoItem)
565
        {
566
            int result = 0;
567

    
568
            // Consolidate은 최상단
569
            if (markupInfoItem.Consolidate == 1)
570
            {
571
                result += 2;
572
            }
573

    
574
            /// Consolidate 다음으로 우선순위
575
            if (markupInfoItem.UserID == App.ViewInfo.UserID)
576
            {
577
                result += 1;
578
            }
579

    
580
            return result;
581
        }
582

    
583

    
584
        private void GridViewMarkup_Sorted(object sender, GridViewSortedEventArgs e)
585
        {
586

    
587
        }
588

    
589
        private async void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
590
        {
591
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
592
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
593
            //{
594
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
595
            //}
596

    
597
            if (ViewerDataModel.Instance.SyncPageNumber == 0)
598
            {
599
                ViewerDataModel.Instance.SyncPageNumber = 1;
600
            }
601
            if (e.AddedItems.Count() > 0)
602
            {
603
                foreach (var item in gridSelectionItem)
604
                {
605
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
606
                    //{
607
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
608
                    //});
609

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

    
612
                    foreach (var markupitem in pageItems)
613
                    {
614
                       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);
615
                    }
616
                }
617
            }
618
            else if (e.RemovedItems.Count > 0)
619
            {
620
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
621

    
622
                (from A in _infoItem
623
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
624
                 where A.MarkupInfoID == B.MarkupInfoID
625
                 select B).ToList().ForEach(data =>
626
                 {
627
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
628
                 });
629
            }
630
        }
631

    
632
        /// <summary>
633
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
634
        /// </summary>
635
        /// <param name="sender"></param>
636
        /// <param name="e"></param>
637
        private async void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
638
        {
639
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
640

    
641
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
642
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
643
            var resultA = (from item_Select in dataSet
644
                           from item_Non in dataSet_User
645
                           where item_Select == item_Non
646
                           select item_Non).ToList();
647

    
648
            if (resultA.Count() >= 2)
649
            {
650
                // 동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?
651
                RadWindow.Confirm(new DialogParameters
652
                {
653
                    Owner = Application.Current.MainWindow,
654
                    Header = "Info",
655
                    Content = "Selected more than two identical user data. Do you want to select consolidation?",
656
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
657
                    {
658
                        if (e.AddedItems.Count() == 1)
659
                        {
660
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
661
                            gridViewMarkup.SelectedItem = null;
662

    
663
                        
664
                            if (ea.DialogResult.Value)
665
                            {
666
                                if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
667
                                {
668
                                    gridViewMarkup.SelectedItem = instanceItem;
669
                                }
670
                                else
671
                                {
672
                                    //1. Consolidations이 있다면 하나 선택
673
                                    var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
674

    
675
                                    if (Consolidations.Count() > 0)
676
                                    {
677
                                        gridViewMarkup.SelectedItem = Consolidations.First();
678
                                    }
679
                                }
680
                              
681
                            }
682
                            else {
683
                                //1. Consolidations 아닌게 있다면 Change
684
                                var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
685

    
686
                                if(notConsolidations.Count() > 0) {
687
                                    gridViewMarkup.SelectedItem = notConsolidations.First();
688
                                }
689
                                else {//1. Consolidations 아닌게 없다면 그대로
690
                                    gridViewMarkup.SelectedItem = instanceItem;
691
                                }
692
                                
693
                            }
694
                        }
695
                    }),
696
                    Theme = new Windows8Theme(),
697
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
698
                });
699
            }
700
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
701
            {
702
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
703
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
704
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
705
#region 코멘트 보기
706
                if (e.AddedItems.Count() > 0 && this.pageNavigator.CurrentPage != null)
707
                {
708
                    foreach (var item in gridSelectionItem)
709
                    {
710
                        if (item.UserID == App.ViewInfo.UserID)
711
                        {
712
                            var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
713
                            if (controls.Count == 0)
714
                            {
715
                                var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
716

    
717
                                foreach (var markup in instance)
718
                                {
719
                                    await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", 
720
                                        item.MarkupInfoID, markup.ID,STAMP_Contents:App.SystemInfo.STAMP_CONTENTS);
721
                                }
722
                            }
723

    
724
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
725
                            foreach (var control in controls)
726
                            {
727
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
728
                                control.Visibility = Visibility.Visible;
729
                            }
730
                        }
731
                        else
732
                        {
733
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
734
                            if (controls.Count == 0)
735
                            {
736
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
737
                                foreach (var markup in instance)
738
                                {
739
                                    await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
740
                                        item.MarkupInfoID, markup.ID);
741
                                }
742
                            }
743

    
744
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
745
                            foreach (var control in controls)
746
                            {
747
                                control.Visibility = Visibility.Visible;
748
                            }
749
                        }
750
                    }
751
                }
752
#endregion
753
#region 코멘트 숨기기
754
                else if (e.RemovedItems.Count > 0)
755
                {
756
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
757

    
758
                    (from A in _infoItem
759
                     from B in Common.ViewerDataModel.Instance.MarkupControls
760
                     where A.MarkupInfoID == B.MarkupInfoID
761
                     select B).ToList().ForEach(data =>
762
                     {
763
                         data.Visibility = Visibility.Hidden;                         
764
                     });
765

    
766

    
767
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
768
                    if (myComment != null)
769
                    {
770
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
771
                        {
772
                            markupitem.Visibility = Visibility.Hidden;
773
                        });
774
                    }
775
                }
776
#endregion
777
            }
778
        }
779

    
780
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
781
        {
782
            //Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.DOCUMENT_ID + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
783

    
784
            if (e.Result != null)
785
            {
786
                _DocItem = e.Result;
787

    
788
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
789
                {
790
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
791
                }
792
                ////Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
793
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
794
            }
795
            else
796
            {
797
                DialogMessage_Alert("Document Information Not Found.", "Error");
798

    
799
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
800
                {
801
                    //Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
802

    
803
                    if (ea.Error == null)
804
                    {
805
                        if (ea.Result)
806
                        {
807
                            this._ViewInfo.isAdmin = true;
808
                            //Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
809
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
810
                        }
811
                        else
812
                        {
813
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
814
                            DialogMessage_Alert("You are not belong to this project. Please ask admin for an authority.", "Info");
815
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
816
                        }
817

    
818
                    }
819
                    else
820
                    {
821
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
822
                    }
823
                };
824
                //Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
825
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
826
            }
827
        }
828

    
829
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
830
        {
831
            //Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
832

    
833
            if (e.Error == null && e.Result != null)
834
            {
835
                App.SystemInfo = e.Result;
836

    
837
                //App.urlPort_DB = App.SystemInfo.HostPort;
838
                //App.urlHost_DB = App.SystemInfo.HostName;
839
                //Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
840
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
841

    
842
                //if (App.urlHost.Contains("localhost"))
843
                //{
844
                //    App.urlHost = App.urlHost_DB;
845
                //}
846
            }
847
        }
848

    
849
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
850
        {
851
            
852
            //Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
853
            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잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
854
            if (e.Error == null && e.Result == true)
855
            {
856
                //Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
857

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

    
860
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
861
                {
862
                    //Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
863
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
864
                    if (userData != null)
865
                    {
866
                        //Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
867
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
868
                    }
869
                    else
870
                    {
871
                        userData = new MEMBER();
872
                        userData.DEPARTMENT = "ALL";
873
                        //Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
874
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
875
                    }
876
                }
877
            }
878
            else
879
            {
880
                
881
                DialogMessage_Alert(failedmsg, "Warning");
882
            }
883
        }
884

    
885
        public void SetView(ViewInfo info)
886
        { 
887
            this._ViewInfo = info;
888
            try
889
            {
890
                /// 대림의 경우 EnsembleID를 가지고 DocumentItemID를 구함
891
                /// 다른 Site를 대비하여 에러 처리함
892
                string docid = BaseClient.GetDocItemID(info.EnsembleID);
893
                if (!string.IsNullOrEmpty(docid))
894
                {
895
                    this._ViewInfo.DocumentItemID = docid;
896
                }
897
            }
898
            catch(Exception ex)
899
            {
900

    
901
                //App.FileLogger.Fatal(ex);
902
            }
903

    
904
            //Logger.sendReqLog("GetSystemDataAsync", "", 1);
905

    
906
            BaseClient.GetSystemDataAsync();
907
        }
908

    
909
        public void HubSet()
910
        {
911
            // 허브 연결 구성
912
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
913
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
914

    
915

    
916
            // 허브 연결 
917
            hubConnection.Start().ContinueWith(task =>
918
            {
919
                if (task.IsFaulted)
920
                {
921
                    Console.WriteLine("There was an error opening the connection:{0}",
922
                                      task.Exception.GetBaseException());
923
                    //throw task.Exception.GetBaseException();
924
                }
925
                else
926
                {
927
                    Console.WriteLine("Connected :: " + task.Id);
928
                }
929

    
930
            }).Wait();
931

    
932

    
933
            // [ 프로그램 시작 ]
934
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
935
            //( "method name", arg1, arg2 )
936
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
937
            //{
938
            //    if (task.IsFaulted)
939
            //    {
940
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
941
            //    }
942
            //    else
943
            //    {
944
            //        Console.WriteLine(task.Result);
945
            //    }
946
            //});
947
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID,App.ViewInfo.ProjectNO).ContinueWith(task =>
948
            {
949
                if (task.IsFaulted)
950
                {
951
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
952
                    //throw task.Exception.GetBaseException();
953
                }
954
                else
955
                {
956
                    switch (task.Result)
957
                    {
958
                        case "2":
959
                            {
960
                                var result = MessageBox.Show("권한이 없습니다.");
961
                                if (result == MessageBoxResult.OK)
962
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
963
                            }
964
                            break;
965
                        case "404":
966
                            {
967
                                var result = MessageBox.Show("등록된 사용자가 아닙니다.");
968
                                if(result == MessageBoxResult.OK)
969
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
970
                            }
971
                            break;
972
                    }
973
                }
974
            });
975

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

    
980
            //    if (status)
981
            //    {
982
            //        // 프로그램 시작 
983
            //        Console.WriteLine("connection status : " + status);
984
            //    }
985
            //    else
986
            //    {
987
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
988
            //        hubConnection.Stop();
989
            //    }
990
            //});
991

    
992
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
993
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
994
                Console.WriteLine("Noficiation Message : " + msg)
995
            );
996

    
997

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

    
1001
            //Console.ReadKey();
1002

    
1003
            //hubConnection.Stop();
1004
        }
1005

    
1006
        public async void MarkupUserListDisplay()
1007
        {
1008
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
1009
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1010
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
1011
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
1012
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
1013
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
1014
            //foreach (var item in gridSelectionItem)
1015
            //{
1016
            //    if (item.UserID == App.ViewInfo.UserID)
1017
            //    {
1018
            //        ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
1019
            //        {
1020
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
1021
            //        });
1022
            //    }
1023
            //    else
1024
            //    {
1025
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
1026
            //        {
1027
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
1028
            //        });
1029
            //    }
1030
            //}
1031
                (from A in gridSelectionItem
1032
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
1033
                 where A.MarkupInfoID == B.MarkupInfoID
1034
                 select B).ToList().ForEach(data =>
1035
                 {
1036
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
1037
                 });
1038
            (from A in gridSelectionItem
1039
             from B in Common.ViewerDataModel.Instance.MarkupControls
1040
             where A.MarkupInfoID == B.MarkupInfoID
1041
             select B).ToList().ForEach(data =>
1042
             {
1043
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
1044
             });
1045

    
1046
            foreach (var item in gridSelectionItem)
1047
            {
1048

    
1049
                if (item.UserID == App.ViewInfo.UserID)
1050
                {
1051
                    var markupItems = ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
1052

    
1053
                    foreach (var markupitem in markupItems)
1054
                    {
1055
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", 
1056
                                item.MarkupInfoID, markupitem.ID);
1057
                    }
1058
                }
1059
                else
1060
                {
1061
                    var markupItems = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
1062

    
1063
                    foreach (var markupitem in markupItems)
1064
                    {
1065
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1066
                    }
1067
                }
1068
            }
1069
        }
1070
    }
1071
}
클립보드 이미지 추가 (최대 크기: 500 MB)