프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ fddb48f7

이력 | 보기 | 이력해설 | 다운로드 (40.4 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
using Telerik.Windows.Data;
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 ViewInfo _ViewInfo;
28
        public DOCINFO _DocInfo;
29
        public DOCUMENT_ITEM _DocItem;
30
        public MEMBER userData;
31

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

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

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

    
76

    
77

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

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

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

    
108

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
380
                gridViewMarkup.GroupDescriptors.Clear();
381
                GroupDescriptor descriptor = new GroupDescriptor();
382
                descriptor.Member = "Depatment";
383
                descriptor.DisplayContent = "DEPT";
384
                descriptor.SortDirection = ListSortDirection.Ascending;
385
                gridViewMarkup.GroupDescriptors.Add(descriptor);
386
            }
387
        }
388

    
389
        private void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
390
        {
391
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
392
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
393
            //{
394
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
395
            //}
396

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

    
419
                (from A in _infoItem
420
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
421
                 where A.MarkupInfoID == B.MarkupInfoID
422
                 select B).ToList().ForEach(data =>
423
                 {
424
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
425
                 });
426
            }
427
        }
428

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

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

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

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

    
514
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
515
                            foreach (var control in controls)
516
                            {
517
                                control.Visibility = Visibility.Visible;
518
                            }
519
                        }
520
                    }
521
                }
522
                #endregion
523
                #region 코멘트 숨기기
524
                else if (e.RemovedItems.Count > 0)
525
                {
526
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
527

    
528
                    (from A in _infoItem
529
                     from B in Common.ViewerDataModel.Instance.MarkupControls
530
                     where A.MarkupInfoID == B.MarkupInfoID
531
                     select B).ToList().ForEach(data =>
532
                     {
533
                         data.Visibility = Visibility.Hidden;                         
534
                     });
535

    
536

    
537
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
538
                    if (myComment != null)
539
                    {
540
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
541
                        {
542
                            markupitem.Visibility = Visibility.Hidden;
543
                        });
544
                    }
545
                }
546
                #endregion
547
            }
548
        }
549

    
550
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
551
        {
552
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
553

    
554
            if (e.Result != null)
555
            {
556
                _DocItem = e.Result;
557

    
558
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
559
                {
560
                    //장원
561
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
562
                }
563
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
564
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
565
            }
566
            else
567
            {
568
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
569
                {
570
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
571

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

    
587
                    }
588
                    else
589
                    {
590
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
591
                    }
592
                };
593
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
594
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
595
            }
596
        }
597

    
598
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
599
        {
600
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
601

    
602
            if (e.Error == null && e.Result != null)
603
            {
604
                App.SystemInfo = e.Result;
605

    
606
                //App.urlPort_DB = App.SystemInfo.HostPort;
607
                //App.urlHost_DB = App.SystemInfo.HostName;
608
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
609
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
610

    
611
                //if (App.urlHost.Contains("localhost"))
612
                //{
613
                //    App.urlHost = App.urlHost_DB;
614
                //}
615
            }
616
        }
617

    
618
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
619
        {
620
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
621

    
622
            if (e.Error == null && e.Result == true)
623
            {
624
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
625

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

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

    
658
        
659

    
660

    
661
        public void SetView(ViewInfo info)
662
        {
663
            this._ViewInfo = info;
664
            if (!(App.ViewInfo.ProjectNO == "000000" || App.ViewInfo.ProjectNO == "000001"))
665
            {
666
                ViewerDataModel.Instance.SystemMain.dzTopMenu.btnTopStamp.Visibility = Visibility.Collapsed;
667
            }
668
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
669
            BaseClient.GetSystemDataAsync();
670
        }
671

    
672
        public void HubSet()
673
        {
674

    
675
            // 허브 연결 구성
676
            var hubConnection = new HubConnection(global::KCOM.Properties.Settings.Default.HubAddress);
677
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
678

    
679

    
680
            // 허브 연결 
681
            hubConnection.Start().ContinueWith(task =>
682
            {
683
                if (task.IsFaulted)
684
                {
685
                    Console.WriteLine("There was an error opening the connection:{0}",
686
                                      task.Exception.GetBaseException());
687
                }
688
                else
689
                {
690
                    Console.WriteLine("Connected :: " + task.Id);
691
                }
692

    
693
            }).Wait();
694

    
695

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

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

    
740
            //    if (status)
741
            //    {
742
            //        // 프로그램 시작 
743
            //        Console.WriteLine("connection status : " + status);
744
            //    }
745
            //    else
746
            //    {
747
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
748
            //        hubConnection.Stop();
749
            //    }
750
            //});
751

    
752
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
753
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
754
                Console.WriteLine("Noficiation Message : " + msg)
755
            );
756

    
757

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

    
761
            //Console.ReadKey();
762

    
763
            //hubConnection.Stop();
764
        }
765

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

    
806
            foreach (var item in gridSelectionItem)
807
            {
808
                if (item.UserID == App.ViewInfo.UserID)
809
                {
810
                    ViewerDataModel.Instance.MyMarkupList.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_USER, item.DisplayColor, "", 
813
                            item.MarkupInfoID, markupitem.ID);
814
                    });
815
                }
816
                else
817
                {
818
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
819
                    {
820
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
821
                    });
822
                }
823
            }
824
        }
825
    }
826
}
클립보드 이미지 추가 (최대 크기: 500 MB)