프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ d62c0439

이력 | 보기 | 이력해설 | 다운로드 (40 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 RestSharp;
8
using System;
9
using System.Collections.Generic;
10
using System.Collections.ObjectModel;
11
using System.ComponentModel;
12
using System.Linq;
13
using System.Runtime.CompilerServices;
14
using System.Text;
15
using System.Windows;
16
using System.Windows.Controls;
17
using Telerik.Windows.Controls;
18
using MarkupToPDF.Controls.Parsing;
19

    
20
namespace KCOM.Views
21
{
22
    public partial class MainMenu : UserControl, INotifyPropertyChanged
23
    {
24
        const string DeepZoomUrl = @"http://{baseUrl}/TileSource/{TileSourcePath}/{ItemsPath}/{SharepointItemID}/{PageNo}.jpg";
25
        public ServiceDeepViewClient BaseClient;
26
        public ViewInfo _ViewInfo;
27
        public DOCINFO _DocInfo;
28
        public DOCUMENT_ITEM _DocItem;
29
        public MEMBER userData;
30

    
31
        public event PropertyChangedEventHandler PropertyChanged;
32
        private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
33
        {
34
            if (PropertyChanged != null)
35
            {
36
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
37
            }
38
        }
39

    
40
        private Common.DocumentSet _CurrentDoc { get; set; }
41
        public Common.DocumentSet CurrentDoc
42
        {
43
            get
44
            {
45
                return _CurrentDoc;
46
            }
47
            set
48
            {
49
                if (value != CurrentDoc)
50
                {
51
                    _CurrentDoc = value;
52
                    NotifyPropertyChanged();
53
                }
54
            }
55
        }
56
        public void ServiceOn()
57
        {
58
            BaseClient = new ServiceDeepViewClient(App._binding, App._EndPoint);
59

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

    
75

    
76

    
77
        private void BaseClient_EditFavoriteVPCompleted(object sender, EditFavoriteVPCompletedEventArgs e)
78
        {
79
            Logger.sendResLog("EditFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
80
            
81
            if (e.Error == null && e.Result != false)
82
            {
83
                Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1);
84
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
85
            }
86
            else
87
            {
88
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
89
            }
90
        }
91

    
92
        private void BaseClient_DelFavoriteVPCompleted(object sender, DelFavoriteVPCompletedEventArgs e)
93
        {
94
            Logger.sendResLog("DelFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
95

    
96
            if (e.Error == null && e.Result != false)
97
            {
98
                Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1);
99
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
100
            }
101
            else
102
            {
103
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
104
            }
105
        }
106

    
107

    
108
        private void BaseClient_GetCompareRectCompleted(object sender, GetCompareRectCompletedEventArgs e)
109
        {
110
            Logger.sendResLog("GetCompareRectCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
111

    
112
            if (e.Error != null || e.Result == null)
113
            {
114
                DialogMessage_Alert("Compare 기능을 원활히 실행하기 위한 데이터가 부족합니다", "안내");
115
            }
116
            else
117
            {
118
                e.Result.ForEach(d =>
119
                {
120
                    d.Width = d.Width * 3;
121
                    d.Height = d.Height * 3;
122
                    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
123
                    System.Windows.Shapes.Ellipse myEllipse = new System.Windows.Shapes.Ellipse();
124
                    myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
125
                    myEllipse.Opacity = 1;
126
                    myEllipse.Width = d.Width;
127
                    myEllipse.Height = d.Height;
128
                    Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
129
                    Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
130
                    myEllipse.RenderTransformOrigin = point;
131
                    canvas_compareBorder.Children.Add(myEllipse);
132
                });
133

    
134
                da.From = 0.8;
135
                da.To = 0;
136
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
137
                da.AutoReverse = true;
138
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
139
            }
140
        }
141

    
142
        private void BaseClient_SetFinalPDFCompleted(object sender, SetFinalPDFCompletedEventArgs e)
143
        {
144
            Logger.sendResLog("SetFinalPDFCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
145

    
146
            if (e.Error != null || e.Result.Status == FinalStatus.Error)
147
            {
148
                DialogMessage_Alert("최종 파일을 만드는데 문제가 발생하였습니다", "안내");
149
            }
150
            else
151
            {
152
                DialogMessage_Alert("최종 파일 생성 중입니다. 문서관리시스템을 확인해주세요", "안내");
153
            }
154
        }
155

    
156
        private void BaseClient_GetVPRevisionHistoryCompleted(object sender, GetVPRevisionHistoryCompletedEventArgs e)
157
        {
158
            Logger.sendResLog("GetVPRevisionHistoryCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
159

    
160
            if (e.Result != null && e.Error == null)
161
            {
162
                gridViewHistory.ItemsSource = e.Result;
163
            }
164
            TempFile.TempLoad();
165
        }
166

    
167
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
168
        {
169
            Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
170

    
171
            foreach(var info in ViewerDataModel.Instance._markupInfoList)
172
            {
173
                if(info.UserID == App.ViewInfo.UserID)
174
                {
175
                    info.userDelete = true;
176
                    info.DisplayColor = "FFFF0000";
177
                }
178
                else
179
                {
180
                    info.userDelete = false;
181
                }
182
            }
183
        }
184

    
185
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
186
        {
187
            Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
188

    
189
            if (e.Result != null)
190
            {
191
                e.Result.Sort();
192
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
193
            }
194
        }
195
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
196

    
197
        /// <summary>
198
        /// 문서 정보를 가져온다
199
        /// </summary>
200
        /// <param name="sender"></param>
201
        /// <param name="e"></param>
202
        private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
203
        {
204
            Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
205

    
206
            if (e.Error != null)
207
            {
208
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
209
                return;
210
            }
211

    
212
            var MainUrl = DeepZoomUrl.Replace("{baseUrl}", App.SystemInfo.HostName);
213
            MainUrl = MainUrl.Replace("{TileSourcePath}", _ViewInfo.ProjectNO + "_Tile");
214
            MainUrl = MainUrl.Replace("{ItemsPath}", (Convert.ToInt64(_ViewInfo.DocumentItemID) / 100).ToString());
215
            MainUrl = MainUrl.Replace("{SharepointItemID}", _ViewInfo.DocumentItemID);
216
            MainUrl = MainUrl.Replace(@"http://http://", @"http://");
217

    
218
            _DocInfo = e.Result;
219
            foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
220
            {
221
                ViewerDataModel.Instance.Document_Info.Add(item);
222
            }
223
            Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
224
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
225
            CurrentDoc = new Common.DocumentSet
226
            {
227
                docInfo = _DocInfo,
228
                Document_Id = _DocInfo.DOCUMENT_ID,
229
                Document_NO = _DocItem.DOCUMENT_NO,
230
                File_Original = _DocInfo.ORIGINAL_FILE,
231
                File_Result = _DocItem.RESULT_FILE,
232
                Group_No = _DocItem.GROUP_NO,
233
                ProjectNo = _DocItem.PROJECT_NO,
234
                Revision = _DocItem.REVISION,
235
            };
236
            var instanceMain = this.ParentOfType<MainWindow>();
237
            instanceMain.dzTopMenu.tlcurrentPage.Text = _DocInfo.PAGE_COUNT.ToString();
238
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = _DocInfo.PAGE_COUNT.ToString();
239
            string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
240
            instanceMain.TitleText.Text = apptitle;
241
            instanceMain.Title = apptitle;
242
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
243

    
244
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
245

    
246
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
247

    
248
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
249
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
250
        }
251

    
252
        /// <summary>
253
        /// get markupinfo and markupitem from database
254
        /// </summary>
255
        /// <param name="sender"></param>
256
        /// <param name="e"></param>
257
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
258
        {
259
            Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
260

    
261
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
262
            ViewerDataModel.Instance.MarkupControls.Clear();
263
            if (e.Result != null)
264
            {
265
                ViewerDataModel.Instance._markupInfoList.Clear();
266
                var pureItem = e.Result;
267
                if (pureItem.Count > 0)
268
                {
269
                    ViewerDataModel.Instance.MyMarkupList.Clear();
270
                }
271

    
272
                foreach(var info in e.Result)
273
                {
274
                    if (info.UserID == App.ViewInfo.UserID)
275
                    {
276
                        info.userDelete = true;
277
                        info.DisplayColor = "#FFFF0000";
278
                    }
279
                    else
280
                    {
281
                        info.userDelete = false;
282
                    }
283
                    ViewerDataModel.Instance._markupInfoList.Add(info);
284
                }
285

    
286
                pureItem.ToList().ForEach(d => d.MarkupList.ForEach(p =>
287
                {
288
                    if (d.UserID == App.ViewInfo.UserID)
289
                    {
290
                        d.userDelete = true;
291
                        d.DisplayColor = "#FFFF0000";
292

    
293
                        MarkupItemEx markup = new MarkupItemEx
294
                        {
295
                            Data = p.Data,
296
                            Data_Type = p.Data_Type,
297
                            ID = p.ID,
298
                            IsUpdate = false,
299
                            MarkupInfoID = d.MarkupInfoID,
300
                            PageNumber = p.PageNumber,
301
                            Symbol_ID = p.Symbol_ID,
302
                            Group_ID = p.Group_ID
303
                        };
304
                        ViewerDataModel.Instance.MyMarkupList.Add(markup);
305

    
306
			            var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, d.DisplayColor, "",
307
                                        d.MarkupInfoID, markup.ID);
308
                        control.Visibility = Visibility.Hidden;
309
                    }
310
                    else
311
                    {
312
                        MarkupItemEx markup = new MarkupItemEx
313
                        {
314
                            Data = p.Data,
315
                            Data_Type = p.Data_Type,
316
                            ID = p.ID,
317
                            IsUpdate = false,
318
                            MarkupInfoID = d.MarkupInfoID,
319
                            PageNumber = p.PageNumber,
320
                            Symbol_ID = p.Symbol_ID,
321
                            Group_ID = p.Group_ID
322
                        };
323
                        ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
324

    
325
			            var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, d.DisplayColor, "",
326
                                        d.MarkupInfoID, markup.ID);
327
                        control.Visibility = Visibility.Hidden;
328
                    }
329
                }));
330

    
331
                var currentUser = e.Result.Where(data => data.UserID == userData.ID).FirstOrDefault();
332
                if (currentUser == null)
333
                {
334
                    var infoId = Commons.shortGuid();
335
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
336
                    {
337
                        CreateTime = DateTime.Now,
338
                        Depatment = userData.DEPARTMENT,
339
                        DisplayColor = "#FFFF0000",
340
                        UserID = userData.ID,
341
                        UserName = userData.NAME,
342
                        PageCount = 1,
343
                        Description = "",
344
                        MarkupInfoID = infoId,
345
                        MarkupList = null,
346
                        MarkupVersionID = Commons.shortGuid(),
347
                        Consolidate = 0,
348
                        PartConsolidate = 0,
349
                        userDelete = true,
350
                        AvoidConsolidate = 0,
351
                        IsPreviewUser = true
352
                    };
353

    
354
                    App.Custom_ViewInfoId = infoId;
355
                }
356
                else
357
                {
358
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
359
                }
360

    
361
                foreach(var info in pureItem)
362
                {
363
                    if (info.UserID == App.ViewInfo.UserID) info.DisplayColor = "#FFFF0000";
364
                }
365

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

    
369
                markupItem.ForEach(data =>
370
                {
371
                    if (data.Depatment == null) data.Depatment = "Unknown";
372
                });
373
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
374
                SetCommentPages();
375

    
376
                var select_item = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.Consolidate == Convert.ToInt32(true)).FirstOrDefault();
377
                this.gridViewMarkup.SelectedItem = select_item;
378
            }
379
        }
380

    
381
        private void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
382
        {
383
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
384
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
385
            //{
386
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
387
            //}
388

    
389
            if (ViewerDataModel.Instance.PageNumber == 0)
390
            {
391
                ViewerDataModel.Instance.PageNumber = 1;
392
            }
393
            if (e.AddedItems.Count() > 0)
394
            {
395
                foreach (var item in gridSelectionItem)
396
                {
397
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
398
                    //{
399
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
400
                    //});
401
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
402
                    {
403
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
404
                    });
405
                }
406
            }
407
            else if (e.RemovedItems.Count > 0)
408
            {
409
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
410

    
411
                (from A in _infoItem
412
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
413
                 where A.MarkupInfoID == B.MarkupInfoID
414
                 select B).ToList().ForEach(data =>
415
                 {
416
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
417
                 });
418
            }
419
        }
420

    
421
        /// <summary>
422
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
423
        /// </summary>
424
        /// <param name="sender"></param>
425
        /// <param name="e"></param>
426
        private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
427
        {
428
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
429
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
430
            var resultA = (from item_Select in dataSet
431
                           from item_Non in dataSet_User
432
                           where item_Select == item_Non
433
                           select item_Non).ToList();
434

    
435
            if (resultA.Count() >= 2)
436
            {
437
                RadWindow.Confirm(new DialogParameters
438
                {
439
                    Owner = Application.Current.MainWindow,
440
                    Header = "안내",
441
                    Content = "동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?",
442
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
443
                    {
444
                        if (e.AddedItems.Count() == 1)
445
                        {
446
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
447
                            var result = instanceItem.Consolidate;
448

    
449
                            if (ea.DialogResult.Value)
450
                            {
451
                                ConsolidationMethod();
452
                            }
453
                            else
454
                            {
455
                                ((RadGridView)sender).SelectedItem = null;
456
                            }
457
                        }
458
                    }),
459
                    Theme = new Windows8Theme(),
460
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
461
                });
462
            }
463
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
464
            {
465
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
466
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
467
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
468
                #region 코멘트 보기
469
                if (e.AddedItems.Count() > 0)
470
                {
471
                    foreach (var item in gridSelectionItem)
472
                    {
473
                        if ((item.UserID == App.ViewInfo.UserID) && (this.pageNavigator.CurrentPage != null))
474
                        {
475
                            var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
476
                            if (controls.Count == 0)
477
                            {
478
                                var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
479
                                foreach (var markup in instance)
480
                                {
481
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
482
                                        item.MarkupInfoID, markup.ID);
483
                                }
484
                            }
485

    
486
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
487
                            foreach (var control in controls)
488
                            {
489
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
490
                                control.Visibility = Visibility.Visible;
491
                            }
492
                        }
493
                        else if (this.pageNavigator.CurrentPage != null)
494
                        {
495
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
496
                            if (controls.Count == 0)
497
                            {
498
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
499
                                foreach (var markup in instance)
500
                                {
501
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "",
502
                                        item.MarkupInfoID, markup.ID);
503
                                }
504
                            }
505

    
506
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
507
                            foreach (var control in controls)
508
                            {
509
                                control.Visibility = Visibility.Visible;
510
                            }
511
                        }
512
                    }
513
                }
514
                #endregion
515
                #region 코멘트 숨기기
516
                else if (e.RemovedItems.Count > 0)
517
                {
518
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
519

    
520
                    (from A in _infoItem
521
                     from B in Common.ViewerDataModel.Instance.MarkupControls
522
                     where A.MarkupInfoID == B.MarkupInfoID
523
                     select B).ToList().ForEach(data =>
524
                     {
525
                         data.Visibility = Visibility.Hidden;                         
526
                     });
527

    
528

    
529
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
530
                    if (myComment != null)
531
                    {
532
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
533
                        {
534
                            markupitem.Visibility = Visibility.Hidden;
535
                        });
536
                    }
537
                }
538
                #endregion
539
            }
540
        }
541

    
542
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
543
        {
544
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
545

    
546
            if (e.Result != null)
547
            {
548
                _DocItem = e.Result;
549

    
550
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
551
                {
552
                    //장원
553
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
554
                }
555
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
556
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
557
            }
558
            else
559
            {
560
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
561
                {
562
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
563

    
564
                    if (ea.Error == null)
565
                    {
566
                        if (ea.Result)
567
                        {
568
                            this._ViewInfo.isAdmin = true;
569
                            Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
570
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
571
                        }
572
                        else
573
                        {
574
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
575
                            DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
576
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
577
                        }
578

    
579
                    }
580
                    else
581
                    {
582
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
583
                    }
584
                };
585
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
586
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
587
            }
588
        }
589

    
590
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
591
        {
592
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
593

    
594
            if (e.Error == null && e.Result != null)
595
            {
596
                App.SystemInfo = e.Result;
597

    
598
                //App.urlPort_DB = App.SystemInfo.HostPort;
599
                //App.urlHost_DB = App.SystemInfo.HostName;
600
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
601
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
602

    
603
                //if (App.urlHost.Contains("localhost"))
604
                //{
605
                //    App.urlHost = App.urlHost_DB;
606
                //}
607
            }
608
        }
609

    
610
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
611
        {
612
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
613

    
614
            if (e.Error == null && e.Result == true)
615
            {
616
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
617

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

    
620
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
621
                {
622
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
623
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
624
                    if (userData != null)
625
                    {
626
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
627
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
628
                    }
629
                    else
630
                    {
631
                        userData = new MEMBER();
632
                        userData.DEPARTMENT = "ALL";
633
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
634
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
635
                    }
636
                }
637
            }
638
            else
639
            {
640
                DialogMessage_Alert("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!"
641
                                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
642
                //System.Windows.Forms.MessageBox.Show("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!"
643
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
644
                //this.ParentOfType<MainPage>().DialogMessage_Alert("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!"
645
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
646
                //System.Windows.Browser.HtmlPage.Window.Invoke("close");
647
            }
648
        }
649

    
650
        
651

    
652

    
653
        public void SetView(ViewInfo info)
654
        {
655
            this._ViewInfo = info;
656
            if (!(App.ViewInfo.ProjectNO == "000000" || App.ViewInfo.ProjectNO == "000001"))
657
            {
658
                ViewerDataModel.Instance.SystemMain.dzTopMenu.btnTopStamp.Visibility = Visibility.Collapsed;
659
            }
660
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
661
            BaseClient.GetSystemDataAsync();
662
        }
663

    
664
        public void HubSet()
665
        {
666

    
667
            // 허브 연결 구성
668
            var hubConnection = new HubConnection(global::KCOM.Properties.Settings.Default.HubAddress);
669
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
670

    
671

    
672
            // 허브 연결 
673
            hubConnection.Start().ContinueWith(task =>
674
            {
675
                if (task.IsFaulted)
676
                {
677
                    Console.WriteLine("There was an error opening the connection:{0}",
678
                                      task.Exception.GetBaseException());
679
                }
680
                else
681
                {
682
                    Console.WriteLine("Connected :: " + task.Id);
683
                }
684

    
685
            }).Wait();
686

    
687

    
688
            // [ 프로그램 시작 ]
689
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
690
            //( "method name", arg1, arg2 )
691
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
692
            //{
693
            //    if (task.IsFaulted)
694
            //    {
695
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
696
            //    }
697
            //    else
698
            //    {
699
            //        Console.WriteLine(task.Result);
700
            //    }
701
            //});
702
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID).ContinueWith(task =>
703
            {
704
                if (task.IsFaulted)
705
                {
706
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
707
                }
708
                else
709
                {
710
                    switch (task.Result)
711
                    {
712
                        case "2":
713
                            {
714
                                MessageBox.Show("권한이 없습니다.");
715
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
716
                            }
717
                            break;
718
                        case "404":
719
                            {
720
                                MessageBox.Show("등록된 사용자가 아닙니다.");
721
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
722
                            }
723
                            break;
724
                    }
725
                }
726
            });
727

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

    
732
            //    if (status)
733
            //    {
734
            //        // 프로그램 시작 
735
            //        Console.WriteLine("connection status : " + status);
736
            //    }
737
            //    else
738
            //    {
739
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
740
            //        hubConnection.Stop();
741
            //    }
742
            //});
743

    
744
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
745
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
746
                Console.WriteLine("Noficiation Message : " + msg)
747
            );
748

    
749

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

    
753
            //Console.ReadKey();
754

    
755
            //hubConnection.Stop();
756
        }
757

    
758
        public void MarkupUserListDisplay()
759
        {
760
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
761
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
762
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
763
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
764
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
765
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
766
            //foreach (var item in gridSelectionItem)
767
            //{
768
            //    if (item.UserID == App.ViewInfo.UserID)
769
            //    {
770
            //        ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
771
            //        {
772
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
773
            //        });
774
            //    }
775
            //    else
776
            //    {
777
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
778
            //        {
779
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
780
            //        });
781
            //    }
782
            //}
783
                (from A in gridSelectionItem
784
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
785
                 where A.MarkupInfoID == B.MarkupInfoID
786
                 select B).ToList().ForEach(data =>
787
                 {
788
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
789
                 });
790
            (from A in gridSelectionItem
791
             from B in Common.ViewerDataModel.Instance.MarkupControls
792
             where A.MarkupInfoID == B.MarkupInfoID
793
             select B).ToList().ForEach(data =>
794
             {
795
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
796
             });
797

    
798
            foreach (var item in gridSelectionItem)
799
            {
800
                if (item.UserID == App.ViewInfo.UserID)
801
                {
802
                    ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
803
                    {
804
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
805
                            item.MarkupInfoID, markupitem.ID);
806
                    });
807
                }
808
                else
809
                {
810
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
811
                    {
812
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
813
                    });
814
                }
815
            }
816
        }
817
    }
818
}
클립보드 이미지 추가 (최대 크기: 500 MB)