프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ b7637656

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

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

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

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

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

    
74
        
75

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

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

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

    
106

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
207
                        ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
208
                        {
209
                            Data = p.Data,
210
                            Data_Type = p.Data_Type,
211
                            ID = p.ID,
212
                            IsUpdate = false,
213
                            MarkupInfoID = d.MarkupInfoID,
214
                            PageNumber = p.PageNumber,
215
                            Symbol_ID = p.Symbol_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
                        });
230
                    }
231
                    //if (p.ID ==App.ViewInfo.UserID)
232
                    //{
233
                    //    d.userDelete = true;
234
                    //    d.DisplayColor = "#FFFF0000";
235
                    //}
236
                }));
237

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

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

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

    
275

    
276

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

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

    
301

    
302

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

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

    
316
                //this.gridViewMarkup.SelectedItem = this.gridViewMarkup.Items[0];
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

    
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
        private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
434
        {
435
            //this.ParentOfType<MainPage>().ReleaseAdorner();
436

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

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

    
458
                            //dataSet.Where(data => data.UserID == "H2011357").ToList().ForEach(data => lstbox.SelectedItems.Remove(data));
459
                            if (ea.DialogResult.Value)
460
                            {
461
                                ConsolidationMethod();
462
                            }
463
                            else
464
                            {
465
                                ((RadGridView)sender).SelectedItem = null;
466
                            }
467
                        }
468
                    }),
469
                    Theme = new Windows8Theme(),
470
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
471
                });
472
            }
473
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
474
            {
475
                MarkupUserListDisplay();
476
            }
477
        }
478

    
479
        private static ObservableCollection<MarkupInfoItem> SetDisplayColor(List<MarkupInfoItem> MarkupInfoList, string userID)
480
        {
481
            //var random = new Random();
482
            ObservableCollection<MarkupInfoItem> _result = new ObservableCollection<MarkupInfoItem>();
483

    
484
            MarkupInfoList.ForEach(delegate (MarkupInfoItem infoitem)
485
            {
486
                if (userID == infoitem.UserID)
487
                {
488
                    infoitem.userDelete = true;
489
                    infoitem.DisplayColor = "#FFFF0000";
490
                }
491
                else
492
                {
493
                    infoitem.userDelete = false;
494

    
495
                    #region sample code
496

    
497
                    //string _ColorStr = "#FF";
498

    
499
                    //for (int i = 0; i < infoitem.Depatment.Count(); i++)
500
                    //{
501
                    //    _ColorStr += Convert.ToByte(infoitem.Depatment[i]);
502
                    //}
503

    
504
                    //if (_ColorStr.Length < 9)
505
                    //{
506
                    //    for (int i = 0; i < 9 - _ColorStr.Length; i++)
507
                    //    {
508
                    //        _ColorStr += "F";
509
                    //    }
510
                    //}
511
                    //else
512
                    //{
513
                    //    _ColorStr = _ColorStr.Substring(0,9);
514
                    //}
515
                    //System.Diagnostics.Debug.WriteLine(_ColorStr);
516
                    //infoitem.DisplayColor = _ColorStr;// String.Format("#FF{0:X6}", random.Next(0x1000000)); 
517
                    #endregion
518
                }
519

    
520
                _result.Add(infoitem);
521
            });
522

    
523
            return _result;
524
        }
525

    
526
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
527
        {
528
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
529

    
530
            if (e.Result != null)
531
            {
532
                _DocItem = e.Result;
533

    
534
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
535
                {
536
                    //장원
537
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
538
                }
539
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID , 1);
540
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
541
            }
542
            else
543
            {
544
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
545
                {
546
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
547

    
548
                    if (ea.Error == null)
549
                    {
550
                        if (ea.Result)
551
                        {
552
                            this._ViewInfo.isAdmin = true;
553
                            Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
554
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
555
                        }
556
                        else
557
                        {
558
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
559
                            DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
560
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
561
                        }
562

    
563
                    }
564
                    else
565
                    {
566
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
567
                    }
568
                };
569
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
570
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
571
            }
572
        }
573

    
574
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
575
        {
576
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
577

    
578
            if (e.Error == null && e.Result != null)
579
            {
580
                App.SystemInfo = e.Result;
581

    
582
                //App.urlPort_DB = App.SystemInfo.HostPort;
583
                //App.urlHost_DB = App.SystemInfo.HostName;
584
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
585
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
586

    
587
                //if (App.urlHost.Contains("localhost"))
588
                //{
589
                //    App.urlHost = App.urlHost_DB;
590
                //}
591
            }
592
        }
593

    
594
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
595
        {
596
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
597

    
598
            if (e.Error == null && e.Result != null && e.Result)
599
            {
600
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
601

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

    
604
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
605
                {
606
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
607
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
608
                    if (userData != null)
609
                    {
610
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
611
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
612
                    }
613
                    else
614
                    {
615
                        userData = new MEMBER();
616
                        userData.DEPARTMENT = "ALL";
617
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
618
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
619
                    }          
620
                }
621
            }
622
            else
623
            {
624
                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!"
625
                                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
626
                //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!"
627
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
628
                //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!"
629
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
630
                //System.Windows.Browser.HtmlPage.Window.Invoke("close");
631
            }
632
        }
633
        
634

    
635
        private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
636
        {
637
            Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
638

    
639
            if (e.Error != null)
640
            {
641
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
642
                return;
643
            }
644
            
645
            var MainUrl = DeepZoomUrl.Replace("{baseUrl}", App.SystemInfo.HostName);
646
            MainUrl = MainUrl.Replace("{TileSourcePath}", _ViewInfo.ProjectNO + "_Tile");
647
            MainUrl = MainUrl.Replace("{ItemsPath}", (Convert.ToInt64(_ViewInfo.DocumentItemID) / 100).ToString());
648
            MainUrl = MainUrl.Replace("{SharepointItemID}", _ViewInfo.DocumentItemID);
649
            MainUrl = MainUrl.Replace(@"http://http://", @"http://");
650

    
651
            _DocInfo = e.Result;
652
            foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
653
            {
654
                ViewerDataModel.Instance.Document_Info.Add(item);
655
            }
656
            Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
657
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
658
            CurrentDoc = new Common.DocumentSet
659
            {
660
                docInfo = _DocInfo,
661
                Document_Id = _DocInfo.DOCUMENT_ID,
662
                Document_NO = _DocItem.DOCUMENT_NO,
663
                File_Original = _DocInfo.ORIGINAL_FILE,
664
                File_Result = _DocItem.RESULT_FILE,
665
                Group_No = _DocItem.GROUP_NO,
666
                ProjectNo = _DocItem.PROJECT_NO,
667
                Revision = _DocItem.REVISION,
668
            };
669
            var instanceMain = this.ParentOfType<MainWindow>();
670
            instanceMain.dzTopMenu.tlcurrentPage.Text = _DocInfo.PAGE_COUNT.ToString();
671
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = _DocInfo.PAGE_COUNT.ToString();
672
            string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
673
            instanceMain.TitleText.Text = apptitle;
674
            instanceMain.Title = apptitle;
675
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
676

    
677
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
678

    
679
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
680

    
681
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
682
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);            
683
        }
684

    
685

    
686
        public void SetView(ViewInfo info)
687
        {
688
            this._ViewInfo = info;
689
            if (!(App.ViewInfo.ProjectNO == "000000" || App.ViewInfo.ProjectNO == "000001"))
690
            {
691
                ViewerDataModel.Instance.SystemMain.dzTopMenu.btnTopStamp.Visibility = Visibility.Collapsed;
692
            }
693
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
694
            BaseClient.GetSystemDataAsync();            
695
        }
696

    
697
        public void HubSet()
698
        {
699

    
700
            // 허브 연결 구성
701
            var hubConnection = new HubConnection(global::KCOM.Properties.Settings.Default.HubAddress);
702
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
703

    
704

    
705
            // 허브 연결 
706
            hubConnection.Start().ContinueWith(task =>
707
            {
708
                if (task.IsFaulted)
709
                {
710
                    Console.WriteLine("There was an error opening the connection:{0}",
711
                                      task.Exception.GetBaseException());
712
                }
713
                else
714
                {
715
                    Console.WriteLine("Connected :: " + task.Id);
716
                }
717

    
718
            }).Wait();
719

    
720

    
721
            // [ 프로그램 시작 ]
722
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
723
            //( "method name", arg1, arg2 )
724
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
725
            //{
726
            //    if (task.IsFaulted)
727
            //    {
728
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
729
            //    }
730
            //    else
731
            //    {
732
            //        Console.WriteLine(task.Result);
733
            //    }
734
            //});
735
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID).ContinueWith(task =>
736
            {
737
                if (task.IsFaulted)
738
                {
739
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
740
                }
741
                else
742
                {
743
                    switch(task.Result)
744
                    {
745
                        case "2":
746
                            {
747
                                MessageBox.Show("권한이 없습니다.");
748
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
749
                            }
750
                            break;
751
                        case "404":
752
                            {
753
                                MessageBox.Show("등록된 사용자가 아닙니다.");
754
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
755
                            }
756
                            break;
757
                    }
758
                }
759
            });
760

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

    
765
            //    if (status)
766
            //    {
767
            //        // 프로그램 시작 
768
            //        Console.WriteLine("connection status : " + status);
769
            //    }
770
            //    else
771
            //    {
772
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
773
            //        hubConnection.Stop();
774
            //    }
775
            //});
776

    
777
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
778
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
779
                Console.WriteLine("Noficiation Message : " + msg)
780
            );
781

    
782

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

    
786
            //Console.ReadKey();
787

    
788
            //hubConnection.Stop();
789
        }
790

    
791
        public void MarkupUserListDisplay()
792
        {
793
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
794
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
795
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
796
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
797
            layerControl.ProjectNo = App.ViewInfo.ProjectNO;
798
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
799
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
800
            foreach (var item in gridSelectionItem)
801
            {
802
                if (item.UserID == App.ViewInfo.UserID)
803
                {
804
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
805
                    {
806
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
807
                    });
808
                }
809
                else
810
                {
811
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
812
                    {
813
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
814
                    });
815
                }
816
            }
817
                (from A in gridSelectionItem
818
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
819
                 where A.MarkupInfoID == B.MarkupInfoID
820
                 select B).ToList().ForEach(data =>
821
                 {
822
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
823
                 });
824
            (from A in gridSelectionItem
825
             from B in Common.ViewerDataModel.Instance.MarkupControls
826
             where A.MarkupInfoID == B.MarkupInfoID
827
             select B).ToList().ForEach(data =>
828
             {
829
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
830
             });
831

    
832
            foreach (var item in gridSelectionItem)
833
            {
834
                if (item.UserID == App.ViewInfo.UserID)
835
                {
836
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
837
                    {
838
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
839
                    });
840
                }
841
                else
842
                {
843
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
844
                    {
845
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
846
                    });
847
                }
848
            }
849
        }
850
    }
851
}
클립보드 이미지 추가 (최대 크기: 500 MB)