프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 26ec6226

이력 | 보기 | 이력해설 | 다운로드 (59.5 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
                _DocInfo = e.Result;
274
                _DocInfo.ORIGINAL_FILE = HttpUtility.UrlDecode(_DocInfo.ORIGINAL_FILE);
275
                foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
276
                {
277
                    ViewerDataModel.Instance.Document_Info.Add(item);
278
                }
279
                //Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
280
                CurrentDoc = new Common.DocumentSet
281
                {
282
                    docInfo = _DocInfo,
283
                    Document_Id = _DocInfo.DOCUMENT_ID,
284
                    File_Original = _DocInfo.ORIGINAL_FILE,
285

    
286
                    Document_NO = _DocItem?.DOCUMENT_NO,
287
                    File_Result = _DocItem?.RESULT_FILE,
288
                    Group_No = _DocItem?.GROUP_NO,
289
                    ProjectNo = _DocItem?.PROJECT_NO,
290
                    Revision = _DocItem?.REVISION,
291
                };
292

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

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

    
302
                instanceMain.Title = apptitle;
303

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

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

    
309
                #endregion
310

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

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

    
318
        private void pageNavigator_ThumbInitialized(object sender,EventArgs e)
319
        {
320
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
321

    
322
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
323
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
324

    
325
            /// 기존 임시파일 정리
326
            #region 단어 검색용 파일 다운로드
327

    
328
            DownloadOriginalFile();
329

    
330
            #endregion
331

    
332
            //Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
333
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
334

    
335
        }
336

    
337

    
338
        /// <summary>
339
        /// get markupinfo and markupitem from database
340
        ///  - 1. called when document is loaded
341
        ///  - 2. called when user do consolidation
342
        /// </summary>
343
        /// <param name="sender"></param>
344
        /// <param name="e"></param>
345
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
346
        {
347
            //Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.Count + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
348

    
349
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
350
            ViewerDataModel.Instance.MarkupControls.Clear();
351

    
352
            try
353
            {
354

    
355
                if (e.Result != null)
356
                {
357
                    ViewerDataModel.Instance._markupInfoList.Clear();
358
                    if (e.Result.Count > 0) ViewerDataModel.Instance.MyMarkupList.Clear();
359

    
360
                    foreach (var info in e.Result)
361
                    {
362
                        if (info.Depatment == null) info.Depatment = "Unknown";
363

    
364
                        if (info.UserID == App.ViewInfo.UserID)
365
                        {
366
                            info.userDelete = true;
367
                            info.DisplayColor = "#FFFF0000";
368
                        }
369
                        else
370
                        {
371
                            info.userDelete = false;
372
                        }
373

    
374
                        ViewerDataModel.Instance._markupInfoList.Add(info);
375
                    }
376

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

    
379
                    userInfoList.ToList().ForEach(x => ViewerDataModel.Instance._markupUserList.Add(x));
380

    
381
                    e.Result.ToList().ForEach(d =>
382
                    {
383
                        if (d.MarkupList != null)
384
                        {
385
                            d.MarkupList.ForEach(p =>
386
                            {
387
                                if (d.UserID == App.ViewInfo.UserID)
388
                                {
389
                                    d.userDelete = true;
390
                                    d.DisplayColor = "#FFFF0000";
391

    
392
                                    MarkupItemEx markup = new MarkupItemEx
393
                                    {
394
                                        Data = p.Data,
395
                                        Data_Type = p.Data_Type,
396
                                        ID = p.ID,
397
                                        IsUpdate = false,
398
                                        MarkupInfoID = d.MarkupInfoID,
399
                                        PageNumber = p.PageNumber,
400
                                        Symbol_ID = p.Symbol_ID,
401
                                        //Group_ID = p.Group_ID
402
                                    };
403
                                    ViewerDataModel.Instance.MyMarkupList.Add(markup);
404
                                }
405
                                else
406
                                {
407
                                    MarkupItemEx markup = new MarkupItemEx
408
                                    {
409
                                        Data = p.Data,
410
                                        Data_Type = p.Data_Type,
411
                                        ID = p.ID,
412
                                        IsUpdate = false,
413
                                        MarkupInfoID = d.MarkupInfoID,
414
                                        PageNumber = p.PageNumber,
415
                                        Symbol_ID = p.Symbol_ID,
416
                                        //Group_ID = p.Group_ID
417
                                    };
418
                                    ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
419
                                }
420
                            });
421
                        }
422
                    });
423

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

    
426
                    if (currentUser == null)
427
                    {
428
                        /// create a new markupinfo to do comments
429
                        /// 
430
                        if (App.ViewInfo.NewCommentPermission)
431
                        {
432
                            var infoId = Commons.shortGuid();
433
                            PreviewUserMarkupInfoItem = new MarkupInfoItem
434
                            {
435
                                CreateTime = DateTime.Now,
436
                                UpdateTime = DateTime.Now,
437
                                Depatment = userData.DEPARTMENT,
438
                                DisplayColor = "#FFFF0000",
439
                                UserID = userData.ID,
440
                                UserName = userData.NAME,
441
                                PageCount = 1,
442
                                Description = "",
443
                                MarkupInfoID = infoId,
444
                                MarkupList = null,
445
                                MarkupVersionID = Commons.shortGuid(),
446
                                Consolidate = 0,
447
                                PartConsolidate = 0,
448
                                userDelete = true,
449
                                AvoidConsolidate = 0,
450
                                IsPreviewUser = false
451
                            };
452

    
453
                            App.Custom_ViewInfoId = infoId;
454

    
455
                            ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
456
                        }
457
                    }
458
                    else
459
                    {
460
                        App.Custom_ViewInfoId = currentUser.MarkupInfoID;
461
                    }
462

    
463
                    ViewerDataModel.Instance.SyncPageNumber = 1;
464

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

    
468
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
469

    
470
                    SetCommentPages(null);
471

    
472
                    // GRIDVIEW에서 팀별 GROUPING
473
                    // 효성은 안함
474
#if (Hyosung)
475
#else
476
                    /// create a group descriptor
477
                    gridViewMarkup.GroupDescriptors.Clear();
478
                    GroupDescriptor descriptor = new GroupDescriptor();
479
                    descriptor.Member = "Depatment";
480
                    descriptor.DisplayContent = "DEPT";
481
                    //descriptor.SortDirection = ListSortDirection.Ascending;
482
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
483
#endif
484

    
485
                    GridViewMarkup_Sorting(gridViewMarkup, new GridViewSortingEventArgs(gridViewMarkup.Columns[0], SortingState.None, SortingState.None));
486

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

    
489
                    if (PreviewUserMarkupInfoItem != null)
490
                    {
491
                        this.gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
492
                    }
493
                    else if (SelectedItem != null)
494
                    {
495
                        this.gridViewMarkup.SelectedItem = SelectedItem;
496
                    }
497
                    else if (ViewerDataModel.Instance._markupInfoList.Count() > 0)
498
                    {
499
                        this.gridViewMarkup.SelectedItem = ViewerDataModel.Instance._markupInfoList.First();
500
                    }
501
                }
502
            }
503
            catch (Exception ex) 
504
            {
505
                App.FileLogger.Fatal(ex);
506
            }
507
            finally
508
            {
509
                if(!ViewerDataModel.Instance.SystemMain.dzMainMenu.btnFinalPDF.IsEnabled)
510
                {
511
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.btnFinalPDF.IsEnabled = true;
512
                }
513

    
514
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.btnConsolidate.IsEnabled)
515
                {
516
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.btnConsolidate.IsEnabled = true;
517
                }
518
            }
519
        }
520

    
521
        private void GridViewMarkup_Sorting(object sender, GridViewSortingEventArgs e)
522
        {
523
            IEnumerable<IKCOM.MarkupInfoItem> markuplist = e.DataControl.ItemsSource as IEnumerable<IKCOM.MarkupInfoItem>;
524

    
525
            if(markuplist == null)
526
            {
527
                e.Cancel = true;
528
                return;
529
            }
530

    
531
            if(e.NewSortingState == SortingState.None)
532
            {
533
                markuplist = markuplist.OrderByDescending(x => SortIndex(x))
534
                                            .ThenBy(x => x.Depatment)
535
                                            .ThenBy(x => x.UserID);
536

    
537
                e.DataControl.ItemsSource = markuplist.ToList();
538
            }
539
        }
540

    
541

    
542
        // 마크업 리스트 정렬
543
        private int SortIndex(IKCOM.MarkupInfoItem markupInfoItem)
544
        {
545
            int result = 0;
546

    
547
            // Consolidate은 최상단
548
            if (markupInfoItem.Consolidate == 1)
549
            {
550
                result += 2;
551
            }
552

    
553
            /// Consolidate 다음으로 우선순위
554
            if (markupInfoItem.UserID == App.ViewInfo.UserID)
555
            {
556
                result += 1;
557
            }
558

    
559
            return result;
560
        }
561

    
562

    
563
        private void GridViewMarkup_Sorted(object sender, GridViewSortedEventArgs e)
564
        {
565

    
566
        }
567

    
568
        private async void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
569
        {
570
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
571
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
572
            //{
573
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
574
            //}
575

    
576
            if (ViewerDataModel.Instance.SyncPageNumber == 0)
577
            {
578
                ViewerDataModel.Instance.SyncPageNumber = 1;
579
            }
580
            if (e.AddedItems.Count() > 0)
581
            {
582
                foreach (var item in gridSelectionItem)
583
                {
584
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
585
                    //{
586
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
587
                    //});
588

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

    
591
                    foreach (var markupitem in pageItems)
592
                    {
593
                       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);
594
                    }
595
                }
596
            }
597
            else if (e.RemovedItems.Count > 0)
598
            {
599
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
600

    
601
                (from A in _infoItem
602
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
603
                 where A.MarkupInfoID == B.MarkupInfoID
604
                 select B).ToList().ForEach(data =>
605
                 {
606
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
607
                 });
608
            }
609
        }
610

    
611
        /// <summary>
612
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
613
        /// </summary>
614
        /// <param name="sender"></param>
615
        /// <param name="e"></param>
616
        private async void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
617
        {
618

    
619
            foreach (var item in e.AddedItems)
620
            {
621
                var cellToSelect = new GridViewCellInfo(item, this.gridViewMarkup.Columns["color"], this.gridViewMarkup);
622

    
623
                if(cellToSelect != null)
624
                {
625

    
626
                }
627
            }
628

    
629
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
630

    
631
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
632
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
633
            var resultA = (from item_Select in dataSet
634
                           from item_Non in dataSet_User
635
                           where item_Select == item_Non
636
                           select item_Non).ToList();
637

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

    
653
                        
654
                            if (ea.DialogResult.Value)
655
                            {
656
                                if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
657
                                {
658
                                    gridViewMarkup.SelectedItem = instanceItem;
659
                                }
660
                                else
661
                                {
662
                                    //1. Consolidations이 있다면 하나 선택
663
                                    var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
664

    
665
                                    if (Consolidations.Count() > 0)
666
                                    {
667
                                        gridViewMarkup.SelectedItem = Consolidations.First();
668
                                    }
669
                                }
670
                              
671
                            }
672
                            else {
673
                                //1. Consolidations 아닌게 있다면 Change
674
                                var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
675

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

    
707
                                foreach (var markup in instance)
708
                                {
709
                                    await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", 
710
                                        item.MarkupInfoID, markup.ID,STAMP_Contents:App.SystemInfo.STAMP_CONTENTS);
711
                                }
712
                            }
713

    
714
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
715
                            foreach (var control in controls)
716
                            {
717
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
718
                                control.Visibility = Visibility.Visible;
719
                            }
720
                        }
721
                        else
722
                        {
723
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
724
                            if (controls.Count == 0)
725
                            {
726
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
727
                                foreach (var markup in instance)
728
                                {
729
                                    await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
730
                                        item.MarkupInfoID, markup.ID);
731
                                }
732
                            }
733

    
734
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
735
                            foreach (var control in controls)
736
                            {
737
                                control.Visibility = Visibility.Visible;
738
                            }
739
                        }
740
                    }
741
                }
742
#endregion
743
#region 코멘트 숨기기
744
                else if (e.RemovedItems.Count > 0)
745
                {
746
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
747

    
748
                    (from A in _infoItem
749
                     from B in Common.ViewerDataModel.Instance.MarkupControls
750
                     where A.MarkupInfoID == B.MarkupInfoID
751
                     select B).ToList().ForEach(data =>
752
                     {
753
                         data.Visibility = Visibility.Hidden;                         
754
                     });
755

    
756

    
757
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
758
                    if (myComment != null)
759
                    {
760
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
761
                        {
762
                            markupitem.Visibility = Visibility.Hidden;
763
                        });
764
                    }
765
                }
766
#endregion
767
            }
768
        }
769

    
770
        private async void gridViewMarkup_SelectedCellsChanged(object sender, Telerik.Windows.Controls.GridView.GridViewSelectedCellsChangedEventArgs e)
771
        {
772
            if (e.AddedCells.Count() > 0)
773
            {
774
                if(e.AddedCells[0].Column.Name == "color")
775
                {
776

    
777
                }
778
                else
779
                {
780
                    List<MarkupInfoItem> removeItems = new List<MarkupInfoItem>();
781

    
782
                    if (!gridViewMarkup.SelectedItems.Contains(e.AddedCells[0].Item))
783
                    {
784
                        gridViewMarkup.SelectedItems.Add(e.AddedCells[0].Item);
785
                    }
786
                    else
787
                    {
788
                        gridViewMarkup.Unselect(new[] { e.AddedCells[0].Item });
789

    
790
                        removeItems.Add(e.AddedCells[0].Item as MarkupInfoItem);
791
                    }
792

    
793
                    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
794

    
795
                    var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
796
                    var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
797
                    var resultA = (from item_Select in dataSet
798
                                   from item_Non in dataSet_User
799
                                   where item_Select == item_Non
800
                                   select item_Non).ToList();
801

    
802
                    if (resultA.Count() >= 2)
803
                    {
804
                        // 동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?
805
                        RadWindow.Confirm(new DialogParameters
806
                        {
807
                            Owner = Application.Current.MainWindow,
808
                            Header = "Info",
809
                            Content = "Selected more than two identical user data. Do you want to select consolidation?",
810
                            Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
811
                            {
812
                                if (gridViewMarkup.SelectedItems.Count() == 1)
813
                                {
814
                                    MarkupInfoItem instanceItem = gridViewMarkup.SelectedItems.FirstOrDefault() as MarkupInfoItem;
815
                                    gridViewMarkup.SelectedItem = null;
816

    
817

    
818
                                    if (ea.DialogResult.Value)
819
                                    {
820
                                        if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
821
                                        {
822
                                            gridViewMarkup.SelectedItem = instanceItem;
823
                                        }
824
                                        else
825
                                        {
826
                                            //1. Consolidations이 있다면 하나 선택
827
                                            var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
828

    
829
                                            if (Consolidations.Count() > 0)
830
                                            {
831
                                                gridViewMarkup.SelectedItem = Consolidations.First();
832
                                            }
833
                                        }
834

    
835
                                    }
836
                                    else
837
                                    {
838
                                        //1. Consolidations 아닌게 있다면 Change
839
                                        var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
840

    
841
                                        if (notConsolidations.Count() > 0)
842
                                        {
843
                                            gridViewMarkup.SelectedItem = notConsolidations.First();
844
                                        }
845
                                        else
846
                                        {//1. Consolidations 아닌게 없다면 그대로
847
                                            gridViewMarkup.SelectedItem = instanceItem;
848
                                        }
849

    
850
                                    }
851
                                }
852
                            }),
853
                            Theme = new Windows8Theme(),
854
                            ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
855
                        });
856
                    }
857
                    else //파라미터로 넘어온 사용자가 걸리지 않은 경우
858
                    {
859
                        List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
860
                        List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
861
                        List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
862
                        #region 코멘트 보기
863
                        if (gridViewMarkup.SelectedItems.Count() > 0 && this.pageNavigator.CurrentPage != null)
864
                        {
865
                            foreach (var item in gridSelectionItem)
866
                            {
867
                                if (item.UserID == App.ViewInfo.UserID)
868
                                {
869
                                    var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
870
                                    if (controls.Count == 0)
871
                                    {
872
                                        var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
873

    
874
                                        foreach (var markup in instance)
875
                                        {
876
                                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
877
                                                item.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
878
                                        }
879
                                    }
880

    
881
                                    controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
882
                                    foreach (var control in controls)
883
                                    {
884
                                        Logger.sendCheckLog(String.Format("=={0}", control), 1);
885
                                        control.Visibility = Visibility.Visible;
886
                                    }
887
                                }
888
                                else
889
                                {
890
                                    var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
891
                                    if (controls.Count == 0)
892
                                    {
893
                                        var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
894
                                        foreach (var markup in instance)
895
                                        {
896
                                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "",
897
                                                item.MarkupInfoID, markup.ID);
898
                                        }
899
                                    }
900

    
901
                                    controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
902
                                    foreach (var control in controls)
903
                                    {
904
                                        control.Visibility = Visibility.Visible;
905
                                    }
906
                                }
907
                            }
908
                        }
909
                        #endregion
910
                        #region 코멘트 숨기기
911
                        else if (removeItems.Count > 0)
912
                        {
913
                            (from A in removeItems
914
                             from B in Common.ViewerDataModel.Instance.MarkupControls
915
                             where A.MarkupInfoID == B.MarkupInfoID
916
                             select B).ToList().ForEach(data =>
917
                             {
918
                                 data.Visibility = Visibility.Hidden;
919
                             });
920

    
921

    
922
                            var myComment = removeItems.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
923
                            if (myComment != null)
924
                            {
925
                                Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
926
                                {
927
                                    markupitem.Visibility = Visibility.Hidden;
928
                                });
929
                            }
930
                        }
931
                        #endregion
932
                    }
933
                }
934
            }
935
        }
936

    
937
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
938
        {
939
            //Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result?.DOCUMENT_ID + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
940

    
941
            if (e.Result != null)
942
            {
943
                _DocItem = e.Result;
944

    
945
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
946
                {
947
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
948
                }
949
                ////Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
950
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
951
            }
952
            else
953
            {
954
                DialogMessage_Alert("Document Information Not Found.", "Error");
955

    
956
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
957
                {
958
                    //Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
959

    
960
                    if (ea.Error == null)
961
                    {
962
                        if (ea.Result)
963
                        {
964
                            this._ViewInfo.isAdmin = true;
965
                            //Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
966
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
967
                        }
968
                        else
969
                        {
970
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
971
                            DialogMessage_Alert("You are not belong to this project. Please ask admin for an authority.", "Info");
972
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
973
                        }
974

    
975
                    }
976
                    else
977
                    {
978
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
979
                    }
980
                };
981
                //Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
982
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
983
            }
984
        }
985

    
986
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
987
        {
988
            //Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
989

    
990
            if (e.Error == null && e.Result != null)
991
            {
992
                App.SystemInfo = e.Result;
993

    
994
                //App.urlPort_DB = App.SystemInfo.HostPort;
995
                //App.urlHost_DB = App.SystemInfo.HostName;
996
                //Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
997
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
998

    
999
                //if (App.urlHost.Contains("localhost"))
1000
                //{
1001
                //    App.urlHost = App.urlHost_DB;
1002
                //}
1003
            }
1004
        }
1005

    
1006
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
1007
        {
1008
            
1009
            //Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
1010
            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잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
1011
            if (e.Error == null && e.Result == true)
1012
            {
1013
                //Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
1014

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

    
1017
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
1018
                {
1019
                    //Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
1020
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
1021
                    if (userData != null)
1022
                    {
1023
                        //Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
1024
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
1025
                    }
1026
                    else
1027
                    {
1028
                        userData = new MEMBER();
1029
                        userData.DEPARTMENT = "ALL";
1030
                        //Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
1031
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
1032
                    }
1033
                }
1034
            }
1035
            else
1036
            {
1037
                
1038
                DialogMessage_Alert(failedmsg, "Warning");
1039
            }
1040
        }
1041

    
1042
        public void SetView(ViewInfo info)
1043
        { 
1044
            this._ViewInfo = info;
1045
            try
1046
            {
1047
                /// 대림의 경우 EnsembleID를 가지고 DocumentItemID를 구함
1048
                /// 다른 Site를 대비하여 에러 처리함
1049
                string docid = BaseClient.GetDocItemID(info.EnsembleID);
1050
                if (!string.IsNullOrEmpty(docid))
1051
                {
1052
                    this._ViewInfo.DocumentItemID = docid;
1053
                }
1054
            }
1055
            catch(Exception ex)
1056
            {
1057

    
1058
                //App.FileLogger.Fatal(ex);
1059
            }
1060

    
1061
            //Logger.sendReqLog("GetSystemDataAsync", "", 1);
1062

    
1063
            BaseClient.GetSystemDataAsync();
1064
        }
1065

    
1066
        public void HubSet()
1067
        {
1068
            // 허브 연결 구성
1069
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
1070
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
1071

    
1072

    
1073
            // 허브 연결 
1074
            hubConnection.Start().ContinueWith(task =>
1075
            {
1076
                if (task.IsFaulted)
1077
                {
1078
                    Console.WriteLine("There was an error opening the connection:{0}",
1079
                                      task.Exception.GetBaseException());
1080
                    //throw task.Exception.GetBaseException();
1081
                }
1082
                else
1083
                {
1084
                    Console.WriteLine("Connected :: " + task.Id);
1085
                }
1086

    
1087
            }).Wait();
1088

    
1089

    
1090
            // [ 프로그램 시작 ]
1091
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
1092
            //( "method name", arg1, arg2 )
1093
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
1094
            //{
1095
            //    if (task.IsFaulted)
1096
            //    {
1097
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
1098
            //    }
1099
            //    else
1100
            //    {
1101
            //        Console.WriteLine(task.Result);
1102
            //    }
1103
            //});
1104
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID,App.ViewInfo.ProjectNO).ContinueWith(task =>
1105
            {
1106
                if (task.IsFaulted)
1107
                {
1108
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
1109
                    //throw task.Exception.GetBaseException();
1110
                }
1111
                else
1112
                {
1113
                    switch (task.Result)
1114
                    {
1115
                        case "2":
1116
                            {
1117
                                var result = MessageBox.Show("권한이 없습니다.");
1118
                                if (result == MessageBoxResult.OK)
1119
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
1120
                            }
1121
                            break;
1122
                        case "404":
1123
                            {
1124
                                var result = MessageBox.Show("등록된 사용자가 아닙니다.");
1125
                                if(result == MessageBoxResult.OK)
1126
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
1127
                            }
1128
                            break;
1129
                    }
1130
                }
1131
            });
1132

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

    
1137
            //    if (status)
1138
            //    {
1139
            //        // 프로그램 시작 
1140
            //        Console.WriteLine("connection status : " + status);
1141
            //    }
1142
            //    else
1143
            //    {
1144
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
1145
            //        hubConnection.Stop();
1146
            //    }
1147
            //});
1148

    
1149
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
1150
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
1151
                Console.WriteLine("Noficiation Message : " + msg)
1152
            );
1153

    
1154

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

    
1158
            //Console.ReadKey();
1159

    
1160
            //hubConnection.Stop();
1161
        }
1162

    
1163
        public async void MarkupUserListDisplay()
1164
        {
1165
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
1166
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1167
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
1168
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
1169
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
1170
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
1171
            //foreach (var item in gridSelectionItem)
1172
            //{
1173
            //    if (item.UserID == App.ViewInfo.UserID)
1174
            //    {
1175
            //        ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
1176
            //        {
1177
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
1178
            //        });
1179
            //    }
1180
            //    else
1181
            //    {
1182
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
1183
            //        {
1184
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
1185
            //        });
1186
            //    }
1187
            //}
1188
                (from A in gridSelectionItem
1189
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
1190
                 where A.MarkupInfoID == B.MarkupInfoID
1191
                 select B).ToList().ForEach(data =>
1192
                 {
1193
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
1194
                 });
1195
            (from A in gridSelectionItem
1196
             from B in Common.ViewerDataModel.Instance.MarkupControls
1197
             where A.MarkupInfoID == B.MarkupInfoID
1198
             select B).ToList().ForEach(data =>
1199
             {
1200
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
1201
             });
1202

    
1203
            foreach (var item in gridSelectionItem)
1204
            {
1205

    
1206
                if (item.UserID == App.ViewInfo.UserID)
1207
                {
1208
                    var markupItems = ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
1209

    
1210
                    foreach (var markupitem in markupItems)
1211
                    {
1212
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", 
1213
                                item.MarkupInfoID, markupitem.ID);
1214
                    }
1215
                }
1216
                else
1217
                {
1218
                    var markupItems = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
1219

    
1220
                    foreach (var markupitem in markupItems)
1221
                    {
1222
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, ViewerDataModel.Instance.PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1223
                    }
1224
                }
1225
            }
1226
        }
1227
    }
1228
}
클립보드 이미지 추가 (최대 크기: 500 MB)