프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 036650a0

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

1
using Microsoft.AspNet.SignalR.Client;
2
using IKCOM;
3
using KCOM.Common;
4
using KCOM.ServiceDeepView;
5
using KCOMDataModel.DataModel;
6
using Newtonsoft.Json;
7
using RestSharp;
8
using System;
9
using System.Collections.Generic;
10
using System.Collections.ObjectModel;
11
using System.ComponentModel;
12
using System.Linq;
13
using System.Runtime.CompilerServices;
14
using System.Text;
15
using System.Windows;
16
using System.Windows.Controls;
17
using Telerik.Windows.Controls;
18
using MarkupToPDF.Controls.Parsing;
19

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

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

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

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

    
75

    
76

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

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

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

    
107

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

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

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

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

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

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

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

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

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

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

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

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

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

    
200
                pureItem.ToList().ForEach(d => d.MarkupList.ForEach(p =>
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
                            Symbol_ID = p.Symbol_ID,
216
                            Group_ID = p.Group_ID
217
                        });
218
                    }
219
                    else
220
                    {
221
                        ViewerDataModel.Instance.MarkupList_Pre.Add(new MarkupItemEx
222
                        {
223
                            Data = p.Data,
224
                            Data_Type = p.Data_Type,
225
                            ID = p.ID,
226
                            IsUpdate = false,
227
                            MarkupInfoID = d.MarkupInfoID,
228
                            PageNumber = p.PageNumber,
229
                            Symbol_ID = p.Symbol_ID,
230
                            Group_ID = p.Group_ID
231
                        });
232
                    }
233
                    //if (p.ID ==App.ViewInfo.UserID)
234
                    //{
235
                    //    d.userDelete = true;
236
                    //    d.DisplayColor = "#FFFF0000";
237
                    //}
238
                }));
239

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

    
264
                    App.Custom_ViewInfoId = infoId;
265
                    //pureItem.Insert(0,PreviewUserMarkupInfoItem);
266
                }
267
                else
268
                {
269
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
270
                }
271

    
272
                //pureItem.ForEach(d => d.MarkupList = null);
273
                //ViewerDataModel.Instance._markupInfoList = new ObservableCollection<MarkupInfoItem>(pureItem);
274
                ViewerDataModel.Instance._markupInfoList = SetDisplayColor(pureItem, _ViewInfo.UserID);
275
                //ViewerDataModel.Instance._markupInfoList = SetDisplayColor(e.Result, _ViewInfo.UserID);
276

    
277

    
278

    
279
                //if (e.Result.Where(data => data.UserID == userData.ID).FirstOrDefault() == null)
280
                //{
281

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

    
303

    
304

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

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

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

    
321

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

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

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

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

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

    
343
                //SetCommentPages(); //색상을 불러오는 내용
344

    
345

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

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

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

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

    
380

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

    
390
                //}
391
            }
392
        }
393

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

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

    
424
                (from A in _infoItem
425
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
426
                 where A.MarkupInfoID == B.MarkupInfoID
427
                 select B).ToList().ForEach(data =>
428
                 {
429
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
430
                 });
431
            }
432
        }
433

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

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

    
462
                            if (ea.DialogResult.Value)
463
                            {
464
                                ConsolidationMethod();
465
                            }
466
                            else
467
                            {
468
                                ((RadGridView)sender).SelectedItem = null;
469
                            }
470
                        }
471
                    }),
472
                    Theme = new Windows8Theme(),
473
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
474
                });
475
            }
476
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
477
            {
478
                EmptyControlCheck();
479
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
480
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
481
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
482
                MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
483
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
484
                #region 코멘트 보기
485
                if (e.AddedItems.Count() > 0)
486
                {
487
                    foreach (var item in gridSelectionItem)
488
                    {
489
                        if ((item.UserID == App.ViewInfo.UserID) && (this.pageNavigator.CurrentPage != null))
490
                        {
491
                            var instance = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
492
                            var my_item = Common.ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault();
493
                            Common.ViewerDataModel.Instance.current_page_commentcnt = Common.ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().Count;
494
                            if (my_item == null)
495
                            {
496
                                foreach (var markup in instance)
497
                                {
498
                                    layerControl.markupParseEx(markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markup.ID);
499
                                }
500
                            }
501
                            else
502
                            {
503
                                foreach(var control in Common.ViewerDataModel.Instance.MarkupControls_USER)
504
                                {
505
                                    control.Visibility = Visibility.Visible;
506
                                }
507
                            }
508
                        }
509
                        else if (this.pageNavigator.CurrentPage != null)
510
                        {
511
                            foreach(var control in ViewerDataModel.Instance.MarkupControls)
512
                            {
513
                                control.Visibility = Visibility.Visible;
514
                            }
515
                        }
516
                    }
517
                }
518
                #endregion
519
                #region 코멘트 숨기기
520
                else if (e.RemovedItems.Count > 0)
521
                {
522
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
523

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

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

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

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

    
574
                    #region sample code
575

    
576
                    //string _ColorStr = "#FF";
577

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

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

    
599
                _result.Add(infoitem);
600
            });
601

    
602
            return _result;
603
        }
604

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

    
609
            if (e.Result != null)
610
            {
611
                _DocItem = e.Result;
612

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

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

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

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

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

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

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

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

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

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

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

    
713
        /// <summary>
714
        /// 문서 정보를 가져온다
715
        /// </summary>
716
        /// <param name="sender"></param>
717
        /// <param name="e"></param>
718
        private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
719
        {
720
            Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
721

    
722
            if (e.Error != null)
723
            {
724
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
725
                return;
726
            }
727

    
728
            var MainUrl = DeepZoomUrl.Replace("{baseUrl}", App.SystemInfo.HostName);
729
            MainUrl = MainUrl.Replace("{TileSourcePath}", _ViewInfo.ProjectNO + "_Tile");
730
            MainUrl = MainUrl.Replace("{ItemsPath}", (Convert.ToInt64(_ViewInfo.DocumentItemID) / 100).ToString());
731
            MainUrl = MainUrl.Replace("{SharepointItemID}", _ViewInfo.DocumentItemID);
732
            MainUrl = MainUrl.Replace(@"http://http://", @"http://");
733

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

    
760
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
761

    
762
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
763

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

    
768

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

    
780
        public void HubSet()
781
        {
782

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

    
787

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

    
801
            }).Wait();
802

    
803

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

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

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

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

    
865

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

    
869
            //Console.ReadKey();
870

    
871
            //hubConnection.Stop();
872
        }
873

    
874
        public void MarkupUserListDisplay()
875
        {
876
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
877
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
878
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
879
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
880
            layerControl.ProjectNo = App.ViewInfo.ProjectNO;
881
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
882
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
883
            //foreach (var item in gridSelectionItem)
884
            //{
885
            //    if (item.UserID == App.ViewInfo.UserID)
886
            //    {
887
            //        ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
888
            //        {
889
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
890
            //        });
891
            //    }
892
            //    else
893
            //    {
894
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
895
            //        {
896
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
897
            //        });
898
            //    }
899
            //}
900
                (from A in gridSelectionItem
901
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
902
                 where A.MarkupInfoID == B.MarkupInfoID
903
                 select B).ToList().ForEach(data =>
904
                 {
905
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
906
                 });
907
            (from A in gridSelectionItem
908
             from B in Common.ViewerDataModel.Instance.MarkupControls
909
             where A.MarkupInfoID == B.MarkupInfoID
910
             select B).ToList().ForEach(data =>
911
             {
912
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
913
             });
914

    
915
            foreach (var item in gridSelectionItem)
916
            {
917
                if (item.UserID == App.ViewInfo.UserID)
918
                {
919
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
920
                    {
921
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
922
                    });
923
                }
924
                else
925
                {
926
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
927
                    {
928
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
929
                    });
930
                }
931
            }
932
        }
933
    }
934
}
클립보드 이미지 추가 (최대 크기: 500 MB)