프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ e7dd7ae8

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

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

    
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 != false)
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 != false)
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
                    if (d.UserID == App.ViewInfo.UserID)
202
                    {
203
                        d.userDelete = true;
204
                        d.DisplayColor = "#FFFF0000";
205

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

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

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

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

    
276

    
277

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

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

    
302

    
303

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

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

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

    
320

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

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

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

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

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

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

    
344

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

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

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

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

    
379

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

    
389
                //}
390
            }
391
        }
392

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

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

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

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

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

    
461
                            //dataSet.Where(data => data.UserID == "H2011357").ToList().ForEach(data => lstbox.SelectedItems.Remove(data));
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

    
492
                            var instance = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
493
                            var my_item = Common.ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault();
494
                            Common.ViewerDataModel.Instance.current_page_commentcnt = Common.ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().Count;
495
                            if (my_item == null)
496
                            {
497
                                foreach (var markup in instance)
498
                                {
499
                                    layerControl.markupParseEx(markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markup.ID);
500
                                }
501
                            }
502
                            else
503
                            {
504
                                foreach(var control in Common.ViewerDataModel.Instance.MarkupControls_USER)
505
                                {
506
                                    control.Visibility = Visibility.Visible;
507
                                }
508
                            }
509
                        }
510
                        else if (this.pageNavigator.CurrentPage != null)
511
                        {
512
                            foreach(var control in ViewerDataModel.Instance.MarkupControls)
513
                            {
514
                                control.Visibility = Visibility.Visible;
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
                         data.Visibility = Visibility.Hidden;
531
                     });
532

    
533
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
534
                    if (myComment != null)
535
                    {
536
                        ChangeCommentReact();
537
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
538
                        {
539
                            markupitem.Visibility = Visibility.Hidden;
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
                        });
553
                    }
554
                }
555
                #endregion
556
            }
557
        }
558

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

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

    
575
                    #region sample code
576

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

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

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

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

    
603
            return _result;
604
        }
605

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
769

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

    
781
        public void HubSet()
782
        {
783

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

    
788

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

    
802
            }).Wait();
803

    
804

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

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

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

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

    
866

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

    
870
            //Console.ReadKey();
871

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

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

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