프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 0f065e57

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

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

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

    
39
        private Common.DocumentSet _CurrentDoc { get; set; }
40
        public Common.DocumentSet CurrentDoc
41
        {
42
            get
43
            {
44
                return _CurrentDoc;
45
            }
46
            set
47
            {
48
                if (value != CurrentDoc)
49
                {
50
                    _CurrentDoc = value;
51
                    NotifyPropertyChanged();
52
                }
53
            }
54
        }
55
        public void ServiceOn()
56
        {
57
            BaseClient = new ServiceDeepViewClient(App._binding, App._EndPoint);            
58
            
59
            BaseClient.GetDocInfoCompleted += BaseClient_GetDocInfoCompleted; //문서 섬네일, 페이지크기, 마크업 정보 [3]
60
            BaseClient.GetConversionStateCompleted += BaseClient_GetConversionStateCompleted;  //컨버팅의 여부 [2] 
61
            BaseClient.GetSystemDataCompleted += BaseClient_GetSystemDataCompleted; //시스템 정보 [1] 
62
            BaseClient.GetDocumentItemInfoCompleted += BaseClient_GetDocumentItemInfoCompleted; // 문서 자체의 정보 [4]
63
            BaseClient.GetMarkupInfoItemsCompleted += BaseClient_GetMarkupInfoItemsCompleted; 
64
            BaseClient.GetDeptDataCompleted += BaseClient_GetDeptDataCompleted; 
65
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted; 
66
            BaseClient.GetVPRevisionHistoryCompleted += BaseClient_GetVPRevisionHistoryCompleted;
67
            BaseClient.SetFinalPDFCompleted += BaseClient_SetFinalPDFCompleted; 
68
            BaseClient.GetCompareRectCompleted += BaseClient_GetCompareRectCompleted; 
69
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted; 
70
            BaseClient.DelFavoriteVPCompleted += BaseClient_DelFavoriteVPCompleted; 
71
            BaseClient.EditFavoriteVPCompleted += BaseClient_EditFavoriteVPCompleted; 
72
        }
73

    
74
        
75

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

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

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

    
106

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

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

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

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

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

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

    
159
            if (e.Result != null && e.Error == null)
160
            {
161
                gridViewHistory.ItemsSource = e.Result;
162
            }
163
            ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
164
        }
165

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

    
170
            SetDisplayColor(ViewerDataModel.Instance._markupInfoList.ToList(), App.ViewInfo.UserID);
171
        }
172

    
173
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
174
        {
175
            Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
176

    
177
            if (e.Result != null)
178
            {
179
                e.Result.Sort();
180
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
181
            }
182
        }
183
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }   
184

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

    
189
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
190
            ViewerDataModel.Instance.MarkupControls.Clear();
191
            if (e.Result != null)
192
            {
193
                var pureItem = e.Result;
194
                if(pureItem.Count > 0)
195
                {
196
                    ViewerDataModel.Instance.MarkupList_USER.Clear();
197
                }
198

    
199
                pureItem.ToList().ForEach(d => d.MarkupList.ForEach(p =>
200
                {
201

    
202
                   if (d.UserID == App.ViewInfo.UserID)
203
                    {
204
                        d.userDelete = true;
205
                        d.DisplayColor = "#FFFF0000";
206

    
207
                        ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
208
                        {
209
                            Data = p.Data,
210
                            Data_Type = p.Data_Type,
211
                            ID = p.ID,
212
                            IsUpdate = false,
213
                            MarkupInfoID = d.MarkupInfoID,
214
                            PageNumber = p.PageNumber,
215
                        });
216
                    }
217
                    else
218
                    {
219
                        ViewerDataModel.Instance.MarkupList_Pre.Add(new MarkupItemEx
220
                        {
221
                            Data = p.Data,
222
                            Data_Type = p.Data_Type,
223
                            ID = p.ID,
224
                            IsUpdate = false,
225
                            MarkupInfoID = d.MarkupInfoID,
226
                            PageNumber = p.PageNumber,
227
                        });
228
                    }
229
                    //if (p.ID ==App.ViewInfo.UserID)
230
                    //{
231
                    //    d.userDelete = true;
232
                    //    d.DisplayColor = "#FFFF0000";
233
                    //}
234
                }));
235

    
236
                var currentUser = e.Result.Where(data => data.UserID == userData.ID).FirstOrDefault();
237
                //var currentUser = e.Result.Where(data => data.UserID == "H2014410").FirstOrDefault();
238
                if (currentUser == null)
239
                {
240
                    var infoId = Events.Save.shortGuid();
241
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
242
                    {
243
                        CreateTime = DateTime.Now,
244
                        Depatment = userData.DEPARTMENT,
245
                        DisplayColor = "#FFFF0000",
246
                        UserID = userData.ID,
247
                        UserName = userData.NAME,
248
                        PageCount = 1,
249
                        Description = "",
250
                        MarkupInfoID = infoId,
251
                        MarkupList = null,
252
                        MarkupVersionID = Events.Save.shortGuid(),
253
                        Consolidate = 0,
254
                        PartConsolidate = 0,
255
                        userDelete = true,
256
                        AvoidConsolidate = 0,
257
                        IsPreviewUser = true
258
                    };
259

    
260
                    App.Custom_ViewInfoId = infoId;
261
                    //pureItem.Insert(0,PreviewUserMarkupInfoItem);
262
                }
263
                else
264
                {
265
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
266
                }
267

    
268
                //pureItem.ForEach(d => d.MarkupList = null);
269
                //ViewerDataModel.Instance._markupInfoList = new ObservableCollection<MarkupInfoItem>(pureItem);
270
                ViewerDataModel.Instance._markupInfoList = SetDisplayColor(pureItem, _ViewInfo.UserID);
271
                //ViewerDataModel.Instance._markupInfoList = SetDisplayColor(e.Result, _ViewInfo.UserID);
272

    
273

    
274

    
275
                //if (e.Result.Where(data => data.UserID == userData.ID).FirstOrDefault() == null)
276
                //{
277

    
278
                //    PreviewUserMarkupInfoItem = new MarkupInfoItem
279
                //    {
280
                //        CreateTime = DateTime.Now,
281
                //        Depatment = userData.DEPARTMENT,
282
                //        DisplayColor = "#FFFF0000",
283
                //        UserID = userData.ID,
284
                //        UserName = userData.NAME + "(임시저장)",
285
                //        PageCount = 1,
286
                //        Description = "",
287
                //        MarkupInfoID = Events.Save.shortGuid(),
288
                //        MarkupList = null,
289
                //        MarkupVersionID = Events.Save.shortGuid(),
290
                //        Consolidate = 0,
291
                //        PartConsolidate = 0,
292
                //        userDelete = true,
293
                //        AvoidConsolidate = 0,
294
                //        IsPreviewUser = true
295
                //    };
296
                //    ViewerDataModel.Instance._markupInfoList.Add(PreviewUserMarkupInfoItem);
297
                //}
298

    
299

    
300

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

    
303
                markupItem.ForEach(data =>
304
                {
305
                    if (data.Depatment == null)
306
                    {
307
                        data.Depatment = "Unknown";
308
                        //BaseClient.NoticeAccountErrorAsync(_ViewInfo.ProjectNO, data.UserID);
309
                    }
310
                });
311
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
312
				SetCommentPages();
313

    
314
                //this.gridViewMarkup.SelectedItem = this.gridViewMarkup.Items[0];
315
                var select_item = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.Consolidate == Convert.ToInt32(true)).FirstOrDefault();
316
                this.gridViewMarkup.SelectedItem = select_item;
317

    
318

    
319

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

    
322
                //markupItem.ForEach(data =>
323
                //{
324
                //    if (data.Depatment == null)
325
                //    {
326
                //        data.Depatment = "Unknown";
327
                //        //BaseClient.NoticeAccountErrorAsync(_ViewInfo.ProjectNO, data.UserID);
328
                //    }
329
                //});
330

    
331
                //markupItem.Where(data => Convert.ToBoolean(data.Consolidate) && !Convert.ToBoolean(data.PartConsolidate)).ToList().ForEach(data => data.Depatment = "Consolidation");
332

    
333
                //var root = markupItem.Where(data => data.Depatment.Contains("SUB_")).ToList();
334

    
335
                //foreach (var item in root)
336
                //{
337
                //    item.Depatment = item.Depatment.Replace("SUB_", "");
338
                //}
339
                //gridViewMarkup.ItemsSource = markupItem;
340

    
341
                //SetCommentPages(); //색상을 불러오는 내용
342

    
343

    
344
                //if (ViewerDataModel.Instance._markupInfoList.Count() > 0)
345
                //{
346
                //    var com = (from kkk in ViewerDataModel.Instance._markupInfoList where kkk.Consolidate == Convert.ToInt32(true) select kkk).FirstOrDefault();
347

    
348
                //    if (com != null) //콘솔리데이션이 있는 경우
349
                //    {
350
                //        if (com.UserID == _ViewInfo.UserID)
351
                //        {
352
                //            gridViewMarkup.SelectedItems.Add(com);
353
                //        }
354
                //        else
355
                //        {
356
                //            if (ViewerDataModel.Instance._markupInfoList.Where(p => p.UserID == _ViewInfo.UserID).FirstOrDefault() != null)
357
                //            {
358
                //                gridViewMarkup.SelectedItems.Add(ViewerDataModel.Instance._markupInfoList.Where(p => p.UserID == _ViewInfo.UserID).FirstOrDefault());
359
                //            }
360

    
361
                //            else
362
                //            {
363
                //                var data = ViewerDataModel.Instance._markupInfoList.Where(p => p.Consolidate == Convert.ToInt32(true)).FirstOrDefault();
364
                //                //DicUserListOpacity.Add(data.UserID, 1);
365
                //                gridViewMarkup.SelectedItems.Add(ViewerDataModel.Instance._markupInfoList.Where(p => p.Consolidate == Convert.ToInt32(true)).FirstOrDefault());
366
                //            }
367
                //        }
368

    
369
                //    }
370
                //    else
371
                //    {
372
                //        //아무것도 체크 안함
373
                //        //foreach (var item in _markupInfoList)
374
                //        //{
375
                //        //    gridViewMarkup.SelectedItems.Add(item);
376
                //        //} 
377

    
378

    
379
                //        if (ViewerDataModel.Instance._markupInfoList.Where(p => p.UserID == _ViewInfo.UserID).FirstOrDefault() != null) //본인것만 체크
380
                //        {
381
                //            gridViewMarkup.SelectedItems.Add(ViewerDataModel.Instance._markupInfoList.Where(p => p.UserID == _ViewInfo.UserID).FirstOrDefault());
382
                //        }
383
                //    }
384
                //}
385
                //else
386
                //{
387

    
388
                //}
389
            }
390
        }
391

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

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

    
422
                (from A in _infoItem
423
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
424
                 where A.MarkupInfoID == B.MarkupInfoID
425
                 select B).ToList().ForEach(data =>
426
                 {
427
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
428
                 });
429
            }
430
        }
431
        private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
432
        {
433
            //this.ParentOfType<MainPage>().ReleaseAdorner();
434

    
435
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
436
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
437
            var resultA = (from item_Select in dataSet
438
                           from item_Non in dataSet_User
439
                           where item_Select == item_Non
440
                           select item_Non).ToList();
441

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

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

    
499
                                    if (test == null)
500
                                    {
501
                                        foreach (var markup in instance)
502
                                        {
503
                                            layerControl.markupParseEx(markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markup.ID);
504
                                        }
505
                                    }
506
                                }
507
                            }
508
                            else if(this.pageNavigator.CurrentPage != null)
509
                            {
510
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
511
                                foreach (var markup in instance)
512
                                {
513
                                    layerControl.markupParse(markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
514
                                }
515
                            }
516
                        }
517
                    //}
518
                }
519
                #endregion
520
                #region 코멘트 숨기기
521
                else if (e.RemovedItems.Count > 0)
522
                {
523
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
524

    
525
                    (from A in _infoItem
526
                     from B in Common.ViewerDataModel.Instance.MarkupControls
527
                     where A.MarkupInfoID == B.MarkupInfoID
528
                     select B).ToList().ForEach(data =>
529
                     {
530
                         Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
531
                     });
532

    
533
                    //var myComment = _infoItem.Where(d => d.MarkupInfoID == App.Custom_ViewInfoId).FirstOrDefault();
534
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
535
                    if (myComment != null)
536
                    {
537
                        ChangeCommentReact();
538
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
539
                          {
540
                              if (markupitem.IsNew)
541
                              {
542
                                  var root = layerControl.MarkupToString(markupitem, App.ViewInfo.UserID);
543
                                  ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
544
                                  {
545
                                      ID = markupitem.CommentID,
546
                                      Data = root.ConvertData,
547
                                      Data_Type = root.DATA_TYPE,
548
                                      MarkupInfoID = markupitem.MarkupInfoID,
549
                                      PageNumber = this.pageNavigator.CurrentPage.PageNumber,
550
                                  });
551
                              }
552
                              Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(markupitem);
553
                          });
554
                    }
555
                }
556
                #endregion
557
            }
558
        }
559

    
560
        private static ObservableCollection<MarkupInfoItem> SetDisplayColor(List<MarkupInfoItem> MarkupInfoList, string userID)
561
        {
562
            //var random = new Random();
563
            ObservableCollection<MarkupInfoItem> _result = new ObservableCollection<MarkupInfoItem>();
564

    
565
            MarkupInfoList.ForEach(delegate (MarkupInfoItem infoitem)
566
            {
567
                if (userID == infoitem.UserID)
568
                {
569
                    infoitem.userDelete = true;
570
                    infoitem.DisplayColor = "#FFFF0000";
571
                }
572
                else
573
                {
574
                    infoitem.userDelete = false;
575

    
576
                    #region sample code
577

    
578
                    //string _ColorStr = "#FF";
579

    
580
                    //for (int i = 0; i < infoitem.Depatment.Count(); i++)
581
                    //{
582
                    //    _ColorStr += Convert.ToByte(infoitem.Depatment[i]);
583
                    //}
584

    
585
                    //if (_ColorStr.Length < 9)
586
                    //{
587
                    //    for (int i = 0; i < 9 - _ColorStr.Length; i++)
588
                    //    {
589
                    //        _ColorStr += "F";
590
                    //    }
591
                    //}
592
                    //else
593
                    //{
594
                    //    _ColorStr = _ColorStr.Substring(0,9);
595
                    //}
596
                    //System.Diagnostics.Debug.WriteLine(_ColorStr);
597
                    //infoitem.DisplayColor = _ColorStr;// String.Format("#FF{0:X6}", random.Next(0x1000000)); 
598
                    #endregion
599
                }
600

    
601
                _result.Add(infoitem);
602
            });
603

    
604
            return _result;
605
        }
606

    
607
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
608
        {
609
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
610

    
611
            if (e.Result != null)
612
            {
613
                _DocItem = e.Result;
614

    
615
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
616
                {
617
                    //장원
618
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
619
                }
620
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID , 1);
621
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
622
            }
623
            else
624
            {
625
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
626
                {
627
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
628

    
629
                    if (ea.Error == null)
630
                    {
631
                        if (ea.Result)
632
                        {
633
                            this._ViewInfo.isAdmin = true;
634
                            Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
635
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
636
                        }
637
                        else
638
                        {
639
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
640
                            DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
641
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
642
                        }
643

    
644
                    }
645
                    else
646
                    {
647
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
648
                    }
649
                };
650
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
651
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
652
            }
653
        }
654

    
655
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
656
        {
657
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
658

    
659
            if (e.Error == null && e.Result != null)
660
            {
661
                App.SystemInfo = e.Result;
662

    
663
                //App.urlPort_DB = App.SystemInfo.HostPort;
664
                //App.urlHost_DB = App.SystemInfo.HostName;
665
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
666
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
667

    
668
                //if (App.urlHost.Contains("localhost"))
669
                //{
670
                //    App.urlHost = App.urlHost_DB;
671
                //}
672
            }
673
        }
674

    
675
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
676
        {
677
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
678

    
679
            if (e.Error == null && e.Result != null && e.Result)
680
            {
681
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
682

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

    
685
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
686
                {
687
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
688
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
689
                    if (userData != null)
690
                    {
691
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
692
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
693
                    }
694
                    else
695
                    {
696
                        userData = new MEMBER();
697
                        userData.DEPARTMENT = "ALL";
698
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
699
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
700
                    }          
701
                }
702
            }
703
            else
704
            {
705
                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!"
706
                                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
707
                //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!"
708
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
709
                //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!"
710
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
711
                //System.Windows.Browser.HtmlPage.Window.Invoke("close");
712
            }
713
        }
714
        
715

    
716
        private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
717
        {
718
            Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
719

    
720
            if (e.Error != null)
721
            {
722
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
723
                return;
724
            }
725
            
726
            var MainUrl = DeepZoomUrl.Replace("{baseUrl}", App.SystemInfo.HostName);
727
            MainUrl = MainUrl.Replace("{TileSourcePath}", _ViewInfo.ProjectNO + "_Tile");
728
            MainUrl = MainUrl.Replace("{ItemsPath}", (Convert.ToInt64(_ViewInfo.DocumentItemID) / 100).ToString());
729
            MainUrl = MainUrl.Replace("{SharepointItemID}", _ViewInfo.DocumentItemID);
730
            MainUrl = MainUrl.Replace(@"http://http://", @"http://");
731

    
732
            _DocInfo = e.Result;
733
            foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
734
            {
735
                ViewerDataModel.Instance.Document_Info.Add(item);
736
            }
737
            Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
738
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
739
            CurrentDoc = new Common.DocumentSet
740
            {
741
                docInfo = _DocInfo,
742
                Document_Id = _DocInfo.DOCUMENT_ID,
743
                Document_NO = _DocItem.DOCUMENT_NO,
744
                File_Original = _DocInfo.ORIGINAL_FILE,
745
                File_Result = _DocItem.RESULT_FILE,
746
                Group_No = _DocItem.GROUP_NO,
747
                ProjectNo = _DocItem.PROJECT_NO,
748
                Revision = _DocItem.REVISION,
749
            };
750
            var instanceMain = this.ParentOfType<MainWindow>();
751
            instanceMain.dzTopMenu.tlcurrentPage.Text = _DocInfo.PAGE_COUNT.ToString();
752
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = _DocInfo.PAGE_COUNT.ToString();
753
            string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
754
            instanceMain.TitleText.Text = apptitle;
755
            instanceMain.Title = apptitle;
756
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
757

    
758
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
759

    
760
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
761

    
762
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
763
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);            
764
        }
765

    
766

    
767
        public void SetView(ViewInfo info)
768
        {
769
            this._ViewInfo = info;
770
            if (!(App.ViewInfo.ProjectNO == "000000" || App.ViewInfo.ProjectNO == "000001"))
771
            {
772
                ViewerDataModel.Instance.SystemMain.dzTopMenu.btnTopStamp.Visibility = Visibility.Collapsed;
773
            }
774
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
775
            BaseClient.GetSystemDataAsync();            
776
        }
777

    
778
        public void HubSet()
779
        {
780

    
781
            // 허브 연결 구성
782
            var hubConnection = new HubConnection(global::KCOM.Properties.Settings.Default.HubAddress);
783
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
784

    
785

    
786
            // 허브 연결 
787
            hubConnection.Start().ContinueWith(task =>
788
            {
789
                if (task.IsFaulted)
790
                {
791
                    Console.WriteLine("There was an error opening the connection:{0}",
792
                                      task.Exception.GetBaseException());
793
                }
794
                else
795
                {
796
                    Console.WriteLine("Connected :: " + task.Id);
797
                }
798

    
799
            }).Wait();
800

    
801

    
802
            // [ 프로그램 시작 ]
803
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
804
            //( "method name", arg1, arg2 )
805
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
806
            //{
807
            //    if (task.IsFaulted)
808
            //    {
809
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
810
            //    }
811
            //    else
812
            //    {
813
            //        Console.WriteLine(task.Result);
814
            //    }
815
            //});
816
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID).ContinueWith(task =>
817
            {
818
                if (task.IsFaulted)
819
                {
820
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
821
                }
822
                else
823
                {
824
                    switch(task.Result)
825
                    {
826
                        case "2":
827
                            {
828
                                MessageBox.Show("권한이 없습니다.");
829
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
830
                            }
831
                            break;
832
                        case "404":
833
                            {
834
                                MessageBox.Show("등록된 사용자가 아닙니다.");
835
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
836
                            }
837
                            break;
838
                    }
839
                }
840
            });
841

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

    
846
            //    if (status)
847
            //    {
848
            //        // 프로그램 시작 
849
            //        Console.WriteLine("connection status : " + status);
850
            //    }
851
            //    else
852
            //    {
853
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
854
            //        hubConnection.Stop();
855
            //    }
856
            //});
857

    
858
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
859
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
860
                Console.WriteLine("Noficiation Message : " + msg)
861
            );
862

    
863

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

    
867
            //Console.ReadKey();
868

    
869
            //hubConnection.Stop();
870
        }
871

    
872
    }
873
}
클립보드 이미지 추가 (최대 크기: 500 MB)