프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ d128ceb2

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

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

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

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

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

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

    
75

    
76

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

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

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

    
107

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

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

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

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

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

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

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

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

    
171
            foreach(var info in ViewerDataModel.Instance._markupInfoList)
172
            {
173
                if(info.UserID == App.ViewInfo.UserID)
174
                {
175
                    info.userDelete = true;
176
                    info.DisplayColor = "FFFF0000";
177
                }
178
                else
179
                {
180
                    info.userDelete = false;
181
                }
182
            }
183
        }
184

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

    
189
            if (e.Result != null)
190
            {
191
                e.Result.Sort();
192
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
193
            }
194
        }
195
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
196

    
197
        /// <summary>
198
        /// get markupinfo and markupitem from database
199
        /// </summary>
200
        /// <param name="sender"></param>
201
        /// <param name="e"></param>
202
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
203
        {
204
            Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
205

    
206
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
207
            ViewerDataModel.Instance.MarkupControls.Clear();
208
            if (e.Result != null)
209
            {
210
                ViewerDataModel.Instance._markupInfoList.Clear();
211
                var pureItem = e.Result;
212
                if (pureItem.Count > 0)
213
                {
214
                    ViewerDataModel.Instance.MarkupList_USER.Clear();
215
                }
216

    
217
                foreach(var info in e.Result)
218
                {
219
                    if (info.UserID == App.ViewInfo.UserID)
220
                    {
221
                        info.userDelete = true;
222
                        info.DisplayColor = "#FFFF0000";
223
                    }
224
                    else
225
                    {
226
                        info.userDelete = false;
227
                    }
228
                    ViewerDataModel.Instance._markupInfoList.Add(info);
229
                }
230

    
231
                pureItem.ToList().ForEach(d => d.MarkupList.ForEach(p =>
232
                {
233
                    if (d.UserID == App.ViewInfo.UserID)
234
                    {
235
                        d.userDelete = true;
236
                        d.DisplayColor = "#FFFF0000";
237

    
238
                        MarkupItemEx markup = new MarkupItemEx
239
                        {
240
                            Data = p.Data,
241
                            Data_Type = p.Data_Type,
242
                            ID = p.ID,
243
                            IsUpdate = false,
244
                            MarkupInfoID = d.MarkupInfoID,
245
                            PageNumber = p.PageNumber,
246
                            Symbol_ID = p.Symbol_ID,
247
                            Group_ID = p.Group_ID
248
                        };
249
                        ViewerDataModel.Instance.MarkupList_USER.Add(markup);
250

    
251
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, d.DisplayColor, "",
252
                                        d.MarkupInfoID, markup.ID);
253
                        control.Visibility = Visibility.Hidden;
254
                    }
255
                    else
256
                    {
257
                        MarkupItemEx markup = new MarkupItemEx
258
                        {
259
                            Data = p.Data,
260
                            Data_Type = p.Data_Type,
261
                            ID = p.ID,
262
                            IsUpdate = false,
263
                            MarkupInfoID = d.MarkupInfoID,
264
                            PageNumber = p.PageNumber,
265
                            Symbol_ID = p.Symbol_ID,
266
                            Group_ID = p.Group_ID
267
                        };
268
                        ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
269

    
270
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, d.DisplayColor, "",
271
                                        d.MarkupInfoID, markup.ID);
272
                        control.Visibility = Visibility.Hidden;
273
                    }
274
                }));
275

    
276
                var currentUser = e.Result.Where(data => data.UserID == userData.ID).FirstOrDefault();
277
                if (currentUser == null)
278
                {
279
                    var infoId = Commons.shortGuid();
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 = infoId,
290
                        MarkupList = null,
291
                        MarkupVersionID = Commons.shortGuid(),
292
                        Consolidate = 0,
293
                        PartConsolidate = 0,
294
                        userDelete = true,
295
                        AvoidConsolidate = 0,
296
                        IsPreviewUser = true
297
                    };
298

    
299
                    App.Custom_ViewInfoId = infoId;
300
                }
301
                else
302
                {
303
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
304
                }
305

    
306
                foreach(var info in pureItem)
307
                {
308
                    if (info.UserID == App.ViewInfo.UserID) info.DisplayColor = "#FFFF0000";
309
                }
310

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

    
314
                markupItem.ForEach(data =>
315
                {
316
                    if (data.Depatment == null) data.Depatment = "Unknown";
317
                });
318
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
319
                SetCommentPages();
320

    
321
                var select_item = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.Consolidate == Convert.ToInt32(true)).FirstOrDefault();
322
                this.gridViewMarkup.SelectedItem = select_item;
323
            }
324
        }
325

    
326
        private void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
327
        {
328
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
329
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
330
            //{
331
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
332
            //}
333

    
334
            if (ViewerDataModel.Instance.PageNumber == 0)
335
            {
336
                ViewerDataModel.Instance.PageNumber = 1;
337
            }
338
            if (e.AddedItems.Count() > 0)
339
            {
340
                foreach (var item in gridSelectionItem)
341
                {
342
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
343
                    //{
344
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
345
                    //});
346
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
347
                    {
348
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
349
                    });
350
                }
351
            }
352
            else if (e.RemovedItems.Count > 0)
353
            {
354
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
355

    
356
                (from A in _infoItem
357
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
358
                 where A.MarkupInfoID == B.MarkupInfoID
359
                 select B).ToList().ForEach(data =>
360
                 {
361
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
362
                 });
363
            }
364
        }
365

    
366
        /// <summary>
367
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
368
        /// </summary>
369
        /// <param name="sender"></param>
370
        /// <param name="e"></param>
371
        private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
372
        {
373
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
374
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
375
            var resultA = (from item_Select in dataSet
376
                           from item_Non in dataSet_User
377
                           where item_Select == item_Non
378
                           select item_Non).ToList();
379

    
380
            if (resultA.Count() >= 2)
381
            {
382
                RadWindow.Confirm(new DialogParameters
383
                {
384
                    Owner = Application.Current.MainWindow,
385
                    Header = "안내",
386
                    Content = "동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?",
387
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
388
                    {
389
                        if (e.AddedItems.Count() == 1)
390
                        {
391
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
392
                            var result = instanceItem.Consolidate;
393

    
394
                            if (ea.DialogResult.Value)
395
                            {
396
                                ConsolidationMethod();
397
                            }
398
                            else
399
                            {
400
                                ((RadGridView)sender).SelectedItem = null;
401
                            }
402
                        }
403
                    }),
404
                    Theme = new Windows8Theme(),
405
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
406
                });
407
            }
408
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
409
            {
410
                EmptyControlCheck();
411
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
412
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
413
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
414
                #region 코멘트 보기
415
                if (e.AddedItems.Count() > 0)
416
                {
417
                    foreach (var item in gridSelectionItem)
418
                    {
419
                        if ((item.UserID == App.ViewInfo.UserID) && (this.pageNavigator.CurrentPage != null))
420
                        {
421
                            var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
422
                            if (controls.Count == 0)
423
                            {
424
                                var instance = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
425
                                foreach (var markup in instance)
426
                                {
427
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
428
                                        item.MarkupInfoID, markup.ID);
429
                                }
430
                            }
431

    
432
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
433
                            foreach (var control in controls)
434
                            {
435
                                control.Visibility = Visibility.Visible;
436
                            }
437
                        }
438
                        else if (this.pageNavigator.CurrentPage != null)
439
                        {
440
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
441
                            if (controls.Count == 0)
442
                            {
443
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
444
                                foreach (var markup in instance)
445
                                {
446
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "",
447
                                        item.MarkupInfoID, markup.ID);
448
                                }
449
                            }
450

    
451
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
452
                            foreach (var control in controls)
453
                            {
454
                                control.Visibility = Visibility.Visible;
455
                            }
456
                        }
457
                    }
458
                }
459
                #endregion
460
                #region 코멘트 숨기기
461
                else if (e.RemovedItems.Count > 0)
462
                {
463
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
464

    
465
                    (from A in _infoItem
466
                     from B in Common.ViewerDataModel.Instance.MarkupControls
467
                     where A.MarkupInfoID == B.MarkupInfoID
468
                     select B).ToList().ForEach(data =>
469
                     {
470
                         data.Visibility = Visibility.Hidden;                         
471
                     });
472

    
473

    
474
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
475
                    if (myComment != null)
476
                    {
477
                        ChangeCommentReact();
478
                        
479
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
480
                        {
481
                            markupitem.Visibility = Visibility.Hidden;
482
                        });
483
                        
484

    
485
                    }
486
                }
487
                #endregion
488
            }
489
        }
490

    
491
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
492
        {
493
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
494

    
495
            if (e.Result != null)
496
            {
497
                _DocItem = e.Result;
498

    
499
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
500
                {
501
                    //장원
502
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
503
                }
504
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
505
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
506
            }
507
            else
508
            {
509
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
510
                {
511
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
512

    
513
                    if (ea.Error == null)
514
                    {
515
                        if (ea.Result)
516
                        {
517
                            this._ViewInfo.isAdmin = true;
518
                            Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
519
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
520
                        }
521
                        else
522
                        {
523
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
524
                            DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
525
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
526
                        }
527

    
528
                    }
529
                    else
530
                    {
531
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
532
                    }
533
                };
534
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
535
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
536
            }
537
        }
538

    
539
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
540
        {
541
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
542

    
543
            if (e.Error == null && e.Result != null)
544
            {
545
                App.SystemInfo = e.Result;
546

    
547
                //App.urlPort_DB = App.SystemInfo.HostPort;
548
                //App.urlHost_DB = App.SystemInfo.HostName;
549
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
550
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
551

    
552
                //if (App.urlHost.Contains("localhost"))
553
                //{
554
                //    App.urlHost = App.urlHost_DB;
555
                //}
556
            }
557
        }
558

    
559
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
560
        {
561
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
562

    
563
            if (e.Error == null && e.Result == true)
564
            {
565
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
566

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

    
569
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
570
                {
571
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
572
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
573
                    if (userData != null)
574
                    {
575
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
576
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
577
                    }
578
                    else
579
                    {
580
                        userData = new MEMBER();
581
                        userData.DEPARTMENT = "ALL";
582
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
583
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
584
                    }
585
                }
586
            }
587
            else
588
            {
589
                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!"
590
                                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
591
                //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!"
592
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
593
                //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!"
594
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
595
                //System.Windows.Browser.HtmlPage.Window.Invoke("close");
596
            }
597
        }
598

    
599
        /// <summary>
600
        /// 문서 정보를 가져온다
601
        /// </summary>
602
        /// <param name="sender"></param>
603
        /// <param name="e"></param>
604
        private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
605
        {
606
            Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
607

    
608
            if (e.Error != null)
609
            {
610
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
611
                return;
612
            }
613

    
614
            var MainUrl = DeepZoomUrl.Replace("{baseUrl}", App.SystemInfo.HostName);
615
            MainUrl = MainUrl.Replace("{TileSourcePath}", _ViewInfo.ProjectNO + "_Tile");
616
            MainUrl = MainUrl.Replace("{ItemsPath}", (Convert.ToInt64(_ViewInfo.DocumentItemID) / 100).ToString());
617
            MainUrl = MainUrl.Replace("{SharepointItemID}", _ViewInfo.DocumentItemID);
618
            MainUrl = MainUrl.Replace(@"http://http://", @"http://");
619

    
620
            _DocInfo = e.Result;
621
            foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
622
            {
623
                ViewerDataModel.Instance.Document_Info.Add(item);
624
            }
625
            Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
626
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
627
            CurrentDoc = new Common.DocumentSet
628
            {
629
                docInfo = _DocInfo,
630
                Document_Id = _DocInfo.DOCUMENT_ID,
631
                Document_NO = _DocItem.DOCUMENT_NO,
632
                File_Original = _DocInfo.ORIGINAL_FILE,
633
                File_Result = _DocItem.RESULT_FILE,
634
                Group_No = _DocItem.GROUP_NO,
635
                ProjectNo = _DocItem.PROJECT_NO,
636
                Revision = _DocItem.REVISION,
637
            };
638
            var instanceMain = this.ParentOfType<MainWindow>();
639
            instanceMain.dzTopMenu.tlcurrentPage.Text = _DocInfo.PAGE_COUNT.ToString();
640
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = _DocInfo.PAGE_COUNT.ToString();
641
            string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
642
            instanceMain.TitleText.Text = apptitle;
643
            instanceMain.Title = apptitle;
644
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
645

    
646
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
647

    
648
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
649

    
650
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
651
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
652
        }
653

    
654

    
655
        public void SetView(ViewInfo info)
656
        {
657
            this._ViewInfo = info;
658
            if (!(App.ViewInfo.ProjectNO == "000000" || App.ViewInfo.ProjectNO == "000001"))
659
            {
660
                ViewerDataModel.Instance.SystemMain.dzTopMenu.btnTopStamp.Visibility = Visibility.Collapsed;
661
            }
662
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
663
            BaseClient.GetSystemDataAsync();
664
        }
665

    
666
        public void HubSet()
667
        {
668

    
669
            // 허브 연결 구성
670
            var hubConnection = new HubConnection(global::KCOM.Properties.Settings.Default.HubAddress);
671
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
672

    
673

    
674
            // 허브 연결 
675
            hubConnection.Start().ContinueWith(task =>
676
            {
677
                if (task.IsFaulted)
678
                {
679
                    Console.WriteLine("There was an error opening the connection:{0}",
680
                                      task.Exception.GetBaseException());
681
                }
682
                else
683
                {
684
                    Console.WriteLine("Connected :: " + task.Id);
685
                }
686

    
687
            }).Wait();
688

    
689

    
690
            // [ 프로그램 시작 ]
691
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
692
            //( "method name", arg1, arg2 )
693
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
694
            //{
695
            //    if (task.IsFaulted)
696
            //    {
697
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
698
            //    }
699
            //    else
700
            //    {
701
            //        Console.WriteLine(task.Result);
702
            //    }
703
            //});
704
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID).ContinueWith(task =>
705
            {
706
                if (task.IsFaulted)
707
                {
708
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
709
                }
710
                else
711
                {
712
                    switch (task.Result)
713
                    {
714
                        case "2":
715
                            {
716
                                MessageBox.Show("권한이 없습니다.");
717
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
718
                            }
719
                            break;
720
                        case "404":
721
                            {
722
                                MessageBox.Show("등록된 사용자가 아닙니다.");
723
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
724
                            }
725
                            break;
726
                    }
727
                }
728
            });
729

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

    
734
            //    if (status)
735
            //    {
736
            //        // 프로그램 시작 
737
            //        Console.WriteLine("connection status : " + status);
738
            //    }
739
            //    else
740
            //    {
741
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
742
            //        hubConnection.Stop();
743
            //    }
744
            //});
745

    
746
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
747
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
748
                Console.WriteLine("Noficiation Message : " + msg)
749
            );
750

    
751

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

    
755
            //Console.ReadKey();
756

    
757
            //hubConnection.Stop();
758
        }
759

    
760
        public void MarkupUserListDisplay()
761
        {
762
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
763
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
764
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
765
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
766
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
767
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
768
            //foreach (var item in gridSelectionItem)
769
            //{
770
            //    if (item.UserID == App.ViewInfo.UserID)
771
            //    {
772
            //        ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
773
            //        {
774
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
775
            //        });
776
            //    }
777
            //    else
778
            //    {
779
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
780
            //        {
781
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
782
            //        });
783
            //    }
784
            //}
785
                (from A in gridSelectionItem
786
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
787
                 where A.MarkupInfoID == B.MarkupInfoID
788
                 select B).ToList().ForEach(data =>
789
                 {
790
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
791
                 });
792
            (from A in gridSelectionItem
793
             from B in Common.ViewerDataModel.Instance.MarkupControls
794
             where A.MarkupInfoID == B.MarkupInfoID
795
             select B).ToList().ForEach(data =>
796
             {
797
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
798
             });
799

    
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
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
807
                            item.MarkupInfoID, markupitem.ID);
808
                    });
809
                }
810
                else
811
                {
812
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
813
                    {
814
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
815
                    });
816
                }
817
            }
818
        }
819
    }
820
}
클립보드 이미지 추가 (최대 크기: 500 MB)