프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 3d425b19

이력 | 보기 | 이력해설 | 다운로드 (38 KB)

1 787a4489 KangIngu
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 6c781c0c djkim
    {        
23 787a4489 KangIngu
        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 6c781c0c djkim
            BaseClient = new ServiceDeepViewClient(App._binding, App._EndPoint);            
58
            
59 787a4489 KangIngu
            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 992a98b4 KangIngu
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted;
70
            BaseClient.DelFavoriteVPCompleted += BaseClient_DelFavoriteVPCompleted;
71 6c781c0c djkim
            BaseClient.EditFavoriteVPCompleted += BaseClient_EditFavoriteVPCompleted;            
72 992a98b4 KangIngu
        }
73
74 6c781c0c djkim
        
75 992a98b4 KangIngu
76
        private void BaseClient_EditFavoriteVPCompleted(object sender, EditFavoriteVPCompletedEventArgs e)
77
        {
78
            if (e.Error == null && e.Result != null)
79
            {
80
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
81
            }
82
            else
83
            {
84
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
85
            }
86
        }
87
88
        private void BaseClient_DelFavoriteVPCompleted(object sender, DelFavoriteVPCompletedEventArgs e)
89
        {
90
            if (e.Error == null && e.Result != null)
91
            {
92
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
93
            }
94
            else
95
            {
96
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
97
            }
98 787a4489 KangIngu
        }
99
100 992a98b4 KangIngu
101 787a4489 KangIngu
        private void BaseClient_GetCompareRectCompleted(object sender, GetCompareRectCompletedEventArgs e)
102
        {
103
            if (e.Error != null || e.Result == null)
104
            {
105
                DialogMessage_Alert("Compare 기능을 원활히 실행하기 위한 데이터가 부족합니다", "안내");
106
            }
107
            else
108
            {
109
                e.Result.ForEach(d =>
110
                {
111
                    d.Width = d.Width * 3;
112
                    d.Height = d.Height * 3;
113
                    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
114
                    System.Windows.Shapes.Ellipse myEllipse = new System.Windows.Shapes.Ellipse();
115
                    myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
116
                    myEllipse.Opacity = 1;
117
                    myEllipse.Width = d.Width;
118
                    myEllipse.Height = d.Height;
119
                    Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
120
                    Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
121
                    myEllipse.RenderTransformOrigin = point;
122
                    canvas_compareBorder.Children.Add(myEllipse);
123
                });
124
125
                da.From = 0.8;
126
                da.To = 0;
127
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
128
                da.AutoReverse = true;
129
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
130
            }
131
        }
132
133
        private void BaseClient_SetFinalPDFCompleted(object sender, SetFinalPDFCompletedEventArgs e)
134
        {
135
136
            if (e.Error !=null || e.Result.Status == FinalStatus.Error)
137
            {
138
                DialogMessage_Alert("최종 파일을 만드는데 문제가 발생하였습니다", "안내");
139
            }
140
            else
141
            {
142 992a98b4 KangIngu
                DialogMessage_Alert("최종 파일 생성 중입니다. 문서관리시스템을 확인해주세요", "안내");
143 787a4489 KangIngu
            }
144
        }
145
146
        private void BaseClient_GetVPRevisionHistoryCompleted(object sender, GetVPRevisionHistoryCompletedEventArgs e)
147
        {
148
            if (e.Result != null && e.Error == null)
149
            {
150
                gridViewHistory.ItemsSource = e.Result;
151
            }
152
        }
153
154
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
155
        {
156
            SetDisplayColor(ViewerDataModel.Instance._markupInfoList.ToList(), App.ViewInfo.UserID);
157
        }
158
159
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
160
        {
161
            if (e.Result != null)
162
            {
163
                e.Result.Sort();
164
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
165
            }
166
        }
167 992a98b4 KangIngu
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }   
168 787a4489 KangIngu
169
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
170
        {
171
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
172
            ViewerDataModel.Instance.MarkupControls.Clear();
173
            if (e.Result != null)
174
            {
175
                var pureItem = e.Result;
176
                if(pureItem.Count > 0)
177
                {
178
                    ViewerDataModel.Instance.MarkupList_USER.Clear();
179
                }
180
181
                pureItem.ToList().ForEach(d => d.MarkupList.ForEach(p =>
182
                {
183
184
                   if (d.UserID == App.ViewInfo.UserID)
185
                    {
186
                        d.userDelete = true;
187
                        d.DisplayColor = "#FFFF0000";
188
189
                        ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
190
                        {
191
                            Data = p.Data,
192
                            Data_Type = p.Data_Type,
193
                            ID = p.ID,
194
                            IsUpdate = false,
195
                            MarkupInfoID = d.MarkupInfoID,
196
                            PageNumber = p.PageNumber,
197
                        });
198
                    }
199
                    else
200
                    {
201
                        ViewerDataModel.Instance.MarkupList_Pre.Add(new MarkupItemEx
202
                        {
203
                            Data = p.Data,
204
                            Data_Type = p.Data_Type,
205
                            ID = p.ID,
206
                            IsUpdate = false,
207
                            MarkupInfoID = d.MarkupInfoID,
208
                            PageNumber = p.PageNumber,
209
                        });
210
                    }
211
                    //if (p.ID ==App.ViewInfo.UserID)
212
                    //{
213
                    //    d.userDelete = true;
214
                    //    d.DisplayColor = "#FFFF0000";
215
                    //}
216
                }));
217
218
                var currentUser = e.Result.Where(data => data.UserID == userData.ID).FirstOrDefault();
219
                //var currentUser = e.Result.Where(data => data.UserID == "H2014410").FirstOrDefault();
220
                if (currentUser == null)
221
                {
222
                    var infoId = Events.Save.shortGuid();
223
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
224
                    {
225
                        CreateTime = DateTime.Now,
226
                        Depatment = userData.DEPARTMENT,
227
                        DisplayColor = "#FFFF0000",
228
                        UserID = userData.ID,
229
                        UserName = userData.NAME,
230
                        PageCount = 1,
231
                        Description = "",
232
                        MarkupInfoID = infoId,
233
                        MarkupList = null,
234
                        MarkupVersionID = Events.Save.shortGuid(),
235
                        Consolidate = 0,
236
                        PartConsolidate = 0,
237
                        userDelete = true,
238
                        AvoidConsolidate = 0,
239
                        IsPreviewUser = true
240
                    };
241
242
                    App.Custom_ViewInfoId = infoId;
243
                    //pureItem.Insert(0,PreviewUserMarkupInfoItem);
244
                }
245
                else
246
                {
247
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
248
                }
249
250
                //pureItem.ForEach(d => d.MarkupList = null);
251
                //ViewerDataModel.Instance._markupInfoList = new ObservableCollection<MarkupInfoItem>(pureItem);
252
                ViewerDataModel.Instance._markupInfoList = SetDisplayColor(pureItem, _ViewInfo.UserID);
253
                //ViewerDataModel.Instance._markupInfoList = SetDisplayColor(e.Result, _ViewInfo.UserID);
254
255
256
257
                //if (e.Result.Where(data => data.UserID == userData.ID).FirstOrDefault() == null)
258
                //{
259
260
                //    PreviewUserMarkupInfoItem = new MarkupInfoItem
261
                //    {
262
                //        CreateTime = DateTime.Now,
263
                //        Depatment = userData.DEPARTMENT,
264
                //        DisplayColor = "#FFFF0000",
265
                //        UserID = userData.ID,
266
                //        UserName = userData.NAME + "(임시저장)",
267
                //        PageCount = 1,
268
                //        Description = "",
269
                //        MarkupInfoID = Events.Save.shortGuid(),
270
                //        MarkupList = null,
271
                //        MarkupVersionID = Events.Save.shortGuid(),
272
                //        Consolidate = 0,
273
                //        PartConsolidate = 0,
274
                //        userDelete = true,
275
                //        AvoidConsolidate = 0,
276
                //        IsPreviewUser = true
277
                //    };
278
                //    ViewerDataModel.Instance._markupInfoList.Add(PreviewUserMarkupInfoItem);
279
                //}
280
281
282
283
                var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList(); //Consolidation 된 데이터가 최상단에 올 수 있도록 변경
284
285
                markupItem.ForEach(data =>
286
                {
287
                    if (data.Depatment == null)
288
                    {
289
                        data.Depatment = "Unknown";
290
                        //BaseClient.NoticeAccountErrorAsync(_ViewInfo.ProjectNO, data.UserID);
291
                    }
292
                });
293
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
294
				SetCommentPages();
295 992a98b4 KangIngu
296
                //this.gridViewMarkup.SelectedItem = this.gridViewMarkup.Items[0];
297
                var select_item = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.Consolidate == Convert.ToInt32(true)).FirstOrDefault();
298
                this.gridViewMarkup.SelectedItem = select_item;
299
300
301 787a4489 KangIngu
302
                //var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList(); //Consolidation 된 데이터가 최상단에 올 수 있도록 변경
303
304
                //markupItem.ForEach(data =>
305
                //{
306
                //    if (data.Depatment == null)
307
                //    {
308
                //        data.Depatment = "Unknown";
309
                //        //BaseClient.NoticeAccountErrorAsync(_ViewInfo.ProjectNO, data.UserID);
310
                //    }
311
                //});
312
313
                //markupItem.Where(data => Convert.ToBoolean(data.Consolidate) && !Convert.ToBoolean(data.PartConsolidate)).ToList().ForEach(data => data.Depatment = "Consolidation");
314
315
                //var root = markupItem.Where(data => data.Depatment.Contains("SUB_")).ToList();
316
317
                //foreach (var item in root)
318
                //{
319
                //    item.Depatment = item.Depatment.Replace("SUB_", "");
320
                //}
321
                //gridViewMarkup.ItemsSource = markupItem;
322
323
                //SetCommentPages(); //색상을 불러오는 내용
324
325
326
                //if (ViewerDataModel.Instance._markupInfoList.Count() > 0)
327
                //{
328
                //    var com = (from kkk in ViewerDataModel.Instance._markupInfoList where kkk.Consolidate == Convert.ToInt32(true) select kkk).FirstOrDefault();
329
330
                //    if (com != null) //콘솔리데이션이 있는 경우
331
                //    {
332
                //        if (com.UserID == _ViewInfo.UserID)
333
                //        {
334
                //            gridViewMarkup.SelectedItems.Add(com);
335
                //        }
336
                //        else
337
                //        {
338
                //            if (ViewerDataModel.Instance._markupInfoList.Where(p => p.UserID == _ViewInfo.UserID).FirstOrDefault() != null)
339
                //            {
340
                //                gridViewMarkup.SelectedItems.Add(ViewerDataModel.Instance._markupInfoList.Where(p => p.UserID == _ViewInfo.UserID).FirstOrDefault());
341
                //            }
342
343
                //            else
344
                //            {
345
                //                var data = ViewerDataModel.Instance._markupInfoList.Where(p => p.Consolidate == Convert.ToInt32(true)).FirstOrDefault();
346
                //                //DicUserListOpacity.Add(data.UserID, 1);
347
                //                gridViewMarkup.SelectedItems.Add(ViewerDataModel.Instance._markupInfoList.Where(p => p.Consolidate == Convert.ToInt32(true)).FirstOrDefault());
348
                //            }
349
                //        }
350
351
                //    }
352
                //    else
353
                //    {
354
                //        //아무것도 체크 안함
355
                //        //foreach (var item in _markupInfoList)
356
                //        //{
357
                //        //    gridViewMarkup.SelectedItems.Add(item);
358
                //        //} 
359
360
361
                //        if (ViewerDataModel.Instance._markupInfoList.Where(p => p.UserID == _ViewInfo.UserID).FirstOrDefault() != null) //본인것만 체크
362
                //        {
363
                //            gridViewMarkup.SelectedItems.Add(ViewerDataModel.Instance._markupInfoList.Where(p => p.UserID == _ViewInfo.UserID).FirstOrDefault());
364
                //        }
365
                //    }
366
                //}
367
                //else
368
                //{
369
370
                //}
371
            }
372
        }
373
374
        private void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
375
        {
376
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
377
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
378
            //{
379
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
380
            //}
381
382
            if (ViewerDataModel.Instance.PageNumber == 0)
383
            {
384
                ViewerDataModel.Instance.PageNumber = 1;
385
            }
386
            if (e.AddedItems.Count() > 0)
387
            {
388
                foreach (var item in gridSelectionItem)
389
                {
390
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
391
                    //{
392
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
393
                    //});
394
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
395
                    {
396
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
397
                    });
398
                }
399
            }
400
            else if (e.RemovedItems.Count > 0)
401
            {
402
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
403
404
                (from A in _infoItem
405
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
406
                 where A.MarkupInfoID == B.MarkupInfoID
407
                 select B).ToList().ForEach(data =>
408
                 {
409
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
410
                 });
411
            }
412
        }
413
        private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
414
        {
415
            //this.ParentOfType<MainPage>().ReleaseAdorner();
416
417
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
418
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
419
            var resultA = (from item_Select in dataSet
420
                           from item_Non in dataSet_User
421
                           where item_Select == item_Non
422
                           select item_Non).ToList();
423
424
            if (resultA.Count() >= 2)
425
            {
426
                RadWindow.Confirm(new DialogParameters
427
                {
428
                    Header = "안내",
429
                    Content = "동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?",
430
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
431
                    {
432
                        if (e.AddedItems.Count() == 1)
433
                        {
434
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
435
                            var result = instanceItem.Consolidate;
436
437
                            //dataSet.Where(data => data.UserID == "H2011357").ToList().ForEach(data => lstbox.SelectedItems.Remove(data));
438
                            if (ea.DialogResult.Value)
439
                            {
440
                                ConsolidationMethod();
441
                            }
442
                            else
443
                            {
444
                                ((RadGridView)sender).SelectedItem = null;
445
                            }
446
                        }
447
                    }),
448
                    Theme = new Windows8Theme(),
449
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
450
                });
451
            }
452
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
453
            {
454
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
455
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
456
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
457
                MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
458
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
459
                #region 코멘트 보기
460
                if (e.AddedItems.Count() > 0)
461
                {
462
                    foreach (var item in gridSelectionItem)
463
                    {
464 64f6713a humkyung
                            if ((item.UserID == App.ViewInfo.UserID) && (this.pageNavigator.CurrentPage != null))
465 787a4489 KangIngu
                            {
466 6c781c0c djkim
                            
467 787a4489 KangIngu
                                var instance = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
468
                                var my_item = Common.ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault();
469
470
                                if (my_item == null)
471
                                {
472
                                    foreach (var markup in instance)
473
                                    {
474
                                        layerControl.markupParseEx(markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markup.ID);
475
                                    }
476
                                }
477
                                else
478
                                {
479
                                    var test = instance.Where(data => data.MarkupInfoID == my_item.MarkupInfoID).FirstOrDefault();
480
481
                                    if (test == null)
482
                                    {
483
                                        foreach (var markup in instance)
484
                                        {
485
                                            layerControl.markupParseEx(markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markup.ID);
486
                                        }
487
                                    }
488
                                }
489
                            }
490 64f6713a humkyung
                            else if(this.pageNavigator.CurrentPage != null)
491 787a4489 KangIngu
                            {
492
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
493
                                foreach (var markup in instance)
494
                                {
495
                                    layerControl.markupParse(markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
496
                                }
497
                            }
498
                        }
499
                    //}
500
                }
501
                #endregion
502
                #region 코멘트 숨기기
503
                else if (e.RemovedItems.Count > 0)
504
                {
505
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
506
507
                    (from A in _infoItem
508
                     from B in Common.ViewerDataModel.Instance.MarkupControls
509
                     where A.MarkupInfoID == B.MarkupInfoID
510
                     select B).ToList().ForEach(data =>
511
                     {
512
                         Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
513
                     });
514
515
                    //var myComment = _infoItem.Where(d => d.MarkupInfoID == App.Custom_ViewInfoId).FirstOrDefault();
516
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
517
                    if (myComment != null)
518
                    {
519
                        ChangeCommentReact();
520
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
521
                          {
522
                              if (markupitem.IsNew)
523
                              {
524
                                  var root = layerControl.MarkupToString(markupitem, App.ViewInfo.UserID);
525
                                  ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
526
                                  {
527
                                      ID = markupitem.CommentID,
528
                                      Data = root.ConvertData,
529
                                      Data_Type = root.DATA_TYPE,
530
                                      MarkupInfoID = markupitem.MarkupInfoID,
531
                                      PageNumber = this.pageNavigator.CurrentPage.PageNumber,
532
                                  });
533
                              }
534
                              Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(markupitem);
535
                          });
536
                    }
537
                }
538
                #endregion
539
            }
540
        }
541
542
        private static ObservableCollection<MarkupInfoItem> SetDisplayColor(List<MarkupInfoItem> MarkupInfoList, string userID)
543
        {
544
            //var random = new Random();
545
            ObservableCollection<MarkupInfoItem> _result = new ObservableCollection<MarkupInfoItem>();
546
547
            MarkupInfoList.ForEach(delegate (MarkupInfoItem infoitem)
548
            {
549
                if (userID == infoitem.UserID)
550
                {
551
                    infoitem.userDelete = true;
552
                    infoitem.DisplayColor = "#FFFF0000";
553
                }
554
                else
555
                {
556
                    infoitem.userDelete = false;
557
558
                    #region sample code
559
560
                    //string _ColorStr = "#FF";
561
562
                    //for (int i = 0; i < infoitem.Depatment.Count(); i++)
563
                    //{
564
                    //    _ColorStr += Convert.ToByte(infoitem.Depatment[i]);
565
                    //}
566
567
                    //if (_ColorStr.Length < 9)
568
                    //{
569
                    //    for (int i = 0; i < 9 - _ColorStr.Length; i++)
570
                    //    {
571
                    //        _ColorStr += "F";
572
                    //    }
573
                    //}
574
                    //else
575
                    //{
576
                    //    _ColorStr = _ColorStr.Substring(0,9);
577
                    //}
578
                    //System.Diagnostics.Debug.WriteLine(_ColorStr);
579
                    //infoitem.DisplayColor = _ColorStr;// String.Format("#FF{0:X6}", random.Next(0x1000000)); 
580
                    #endregion
581
                }
582
583
                _result.Add(infoitem);
584
            });
585
586
            return _result;
587
        }
588
589
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
590
        {
591
            if (e.Result != null)
592
            {
593
                _DocItem = e.Result;
594
595
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
596
                {
597
                    //장원
598
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
599
                }
600
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
601
            }
602
            else
603
            {
604
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
605
                {
606
                    if (ea.Error == null)
607
                    {
608
                        if (ea.Result)
609
                        {
610
                            this._ViewInfo.isAdmin = true;
611
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
612
                        }
613
                        else
614
                        {
615
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
616
                            DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
617
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
618
                        }
619
620
                    }
621
                    else
622
                    {
623
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
624
                    }
625
                };
626
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
627
            }
628
        }
629
630
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
631
        {
632
            if (e.Error == null && e.Result != null)
633
            {
634
                App.SystemInfo = e.Result;
635
636
                //App.urlPort_DB = App.SystemInfo.HostPort;
637
                //App.urlHost_DB = App.SystemInfo.HostName;
638
639
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
640
641
                //if (App.urlHost.Contains("localhost"))
642
                //{
643
                //    App.urlHost = App.urlHost_DB;
644
                //}
645
            }
646
        }
647
648
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
649
        {
650
            if (e.Error == null && e.Result != null && e.Result)
651
            {
652
                BaseClient.GetDocumentItemInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID, userID = _ViewInfo.UserID });
653
654 992a98b4 KangIngu
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
655 787a4489 KangIngu
                {
656
                    
657 6c781c0c djkim
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
658
                    if (userData != null)
659 787a4489 KangIngu
                    {
660 6c781c0c djkim
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
661 787a4489 KangIngu
                    }
662 6c781c0c djkim
                    else
663
                    {
664
                        userData = new MEMBER();
665
                        userData.DEPARTMENT = "ALL";
666
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
667
                    }          
668 787a4489 KangIngu
                }
669
            }
670
            else
671
            {
672
                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!"
673
                                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
674
                //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!"
675
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
676
                //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!"
677
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
678
                //System.Windows.Browser.HtmlPage.Window.Invoke("close");
679
            }
680
        }
681 6c781c0c djkim
        
682 787a4489 KangIngu
683
        private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
684
        {
685
            if (e.Error != null)
686
            {
687
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
688
                return;
689
            }
690
            
691
            var MainUrl = DeepZoomUrl.Replace("{baseUrl}", App.SystemInfo.HostName);
692
            MainUrl = MainUrl.Replace("{TileSourcePath}", _ViewInfo.ProjectNO + "_Tile");
693
            MainUrl = MainUrl.Replace("{ItemsPath}", (Convert.ToInt64(_ViewInfo.DocumentItemID) / 100).ToString());
694
            MainUrl = MainUrl.Replace("{SharepointItemID}", _ViewInfo.DocumentItemID);
695
            MainUrl = MainUrl.Replace(@"http://http://", @"http://");
696
697
            _DocInfo = e.Result;
698 f38fed51 KangIngu
            foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
699 787a4489 KangIngu
            {
700
                ViewerDataModel.Instance.Document_Info.Add(item);
701
            }
702
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
703
            CurrentDoc = new Common.DocumentSet
704
            {
705
                docInfo = _DocInfo,
706
                Document_Id = _DocInfo.DOCUMENT_ID,
707
                Document_NO = _DocItem.DOCUMENT_NO,
708
                File_Original = _DocInfo.ORIGINAL_FILE,
709
                File_Result = _DocItem.RESULT_FILE,
710
                Group_No = _DocItem.GROUP_NO,
711
                ProjectNo = _DocItem.PROJECT_NO,
712
                Revision = _DocItem.REVISION,
713
            };
714
            var instanceMain = this.ParentOfType<MainWindow>();
715
            instanceMain.dzTopMenu.tlcurrentPage.Text = _DocInfo.PAGE_COUNT.ToString();
716 992a98b4 KangIngu
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = _DocInfo.PAGE_COUNT.ToString();
717 d2cd1e16 djkim
            string apptitle = string.Format("MARKUS - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION);
718
            instanceMain.TitleText.Text = apptitle;
719
            instanceMain.Title = apptitle;
720 787a4489 KangIngu
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
721
722
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
723
            
724 6c781c0c djkim
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);            
725 787a4489 KangIngu
        }
726
727
728
        public void SetView(ViewInfo info)
729
        {
730
            this._ViewInfo = info;
731
            if (!(App.ViewInfo.ProjectNO == "000000" || App.ViewInfo.ProjectNO == "000001"))
732
            {
733
                ViewerDataModel.Instance.SystemMain.dzTopMenu.btnTopStamp.Visibility = Visibility.Collapsed;
734
            }
735
            BaseClient.GetSystemDataAsync();            
736
        }
737
738 992a98b4 KangIngu
        public void HubSet()
739
        {
740
741
            // 허브 연결 구성
742 9a1ce1db KangIngu
            var hubConnection = new HubConnection(global::KCOM.Properties.Settings.Default.HubAddress);
743 992a98b4 KangIngu
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
744
745
746
            // 허브 연결 
747
            hubConnection.Start().ContinueWith(task =>
748
            {
749
                if (task.IsFaulted)
750
                {
751
                    Console.WriteLine("There was an error opening the connection:{0}",
752
                                      task.Exception.GetBaseException());
753
                }
754
                else
755
                {
756
                    Console.WriteLine("Connected :: " + task.Id);
757
                }
758
759
            }).Wait();
760
761
762
            // [ 프로그램 시작 ]
763
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
764
            //( "method name", arg1, arg2 )
765
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
766
            //{
767
            //    if (task.IsFaulted)
768
            //    {
769
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
770
            //    }
771
            //    else
772
            //    {
773
            //        Console.WriteLine(task.Result);
774
            //    }
775
            //});
776
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID).ContinueWith(task =>
777
            {
778
                if (task.IsFaulted)
779
                {
780
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
781
                }
782
                else
783
                {
784 53393bae KangIngu
                    switch(task.Result)
785 992a98b4 KangIngu
                    {
786 53393bae KangIngu
                        case "2":
787
                            {
788
                                MessageBox.Show("권한이 없습니다.");
789
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
790
                            }
791
                            break;
792
                        case "404":
793
                            {
794
                                MessageBox.Show("등록된 사용자가 아닙니다.");
795
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
796
                            }
797
                            break;
798 992a98b4 KangIngu
                    }
799
                }
800
            });
801
802
            // 서버에서 클라이언트 호출 ( 프로그램 구동여부 ) : 라이센스 체크 후 응답 ( 반환값 : true, false ) 
803
            //MarkusLicenseProxy.On<bool>("IsConnection", status =>
804
            //{
805
806
            //    if (status)
807
            //    {
808
            //        // 프로그램 시작 
809
            //        Console.WriteLine("connection status : " + status);
810
            //    }
811
            //    else
812
            //    {
813
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
814
            //        hubConnection.Stop();
815
            //    }
816
            //});
817
818
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
819
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
820
                Console.WriteLine("Noficiation Message : " + msg)
821
            );
822
823
824
            // 서버 메서드 호출 
825
            //MarkusLicenseProxy.Invoke<string>("DoSomething", "I'm doing something!!!").Wait();
826
827
            //Console.ReadKey();
828
829
            //hubConnection.Stop();
830
        }
831 787a4489 KangIngu
832
    }
833
}
클립보드 이미지 추가 (최대 크기: 500 MB)