프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 84c48033

이력 | 보기 | 이력해설 | 다운로드 (40.6 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
using Telerik.Windows.Data;
20
using System.Web;
21

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

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

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

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

    
77

    
78

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

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

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

    
109

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

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

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

    
144
        private void BaseClient_SetFinalPDFCompleted(object sender, SetFinalPDFCompletedEventArgs e)
145
        {
146
            Logger.sendResLog("SetFinalPDFCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
147
            string errormsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFError", "MSG", "최종 파일을 만드는데 문제가 발생하였습니다");
148
            string successmsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFSuccess", "MSG", "최종 파일 생성 중입니다. 문서관리시스템을 확인해주세요");
149
            if (e.Error != null || e.Result.Status == FinalStatus.Error)
150
            {
151
                DialogMessage_Alert(errormsg, "안내");
152
            }
153
            else
154
            {
155
                DialogMessage_Alert(successmsg, "안내");
156
            }
157
        }
158

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

    
163
            if (e.Result != null && e.Error == null)
164
            {
165
                List<VPRevision> list = e.Result;
166
                foreach (var item in list)
167
                {
168
                    item.FROM_VENDOR = HttpUtility.UrlDecode(item.FROM_VENDOR);
169
                }
170
                gridViewHistory.ItemsSource = list;
171

    
172
            }
173
            TempFile.TempLoad();
174
        }
175

    
176
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
177
        {
178
            Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
179

    
180
            foreach(var info in ViewerDataModel.Instance._markupInfoList)
181
            {
182
                if(info.UserID == App.ViewInfo.UserID)
183
                {
184
                    info.userDelete = true;
185
                    info.DisplayColor = "FFFF0000";
186
                }
187
                else
188
                {
189
                    info.userDelete = false;
190
                }
191
            }
192
        }
193

    
194
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
195
        {
196
            Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
197

    
198
            if (e.Result != null)
199
            {
200
                e.Result.Sort();
201
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
202
            }
203
        }
204
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
205

    
206
        /// <summary>
207
        /// 문서 정보를 가져온다
208
        /// </summary>
209
        /// <param name="sender"></param>
210
        /// <param name="e"></param>
211
        private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
212
        {
213
            Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
214

    
215
            if (e.Error != null)
216
            {
217
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
218
                return;
219
            }
220

    
221
            var MainUrl = DeepZoomUrl.Replace("{baseUrl}", App.SystemInfo.HostName);
222
            MainUrl = MainUrl.Replace("{TileSourcePath}", _ViewInfo.ProjectNO + "_Tile");
223
            MainUrl = MainUrl.Replace("{ItemsPath}", (Convert.ToInt64(_ViewInfo.DocumentItemID) / 100).ToString());
224
            MainUrl = MainUrl.Replace("{SharepointItemID}", _ViewInfo.DocumentItemID);
225
            MainUrl = MainUrl.Replace(@"http://http://", @"http://");
226

    
227
            _DocInfo = e.Result;
228
            _DocInfo.ORIGINAL_FILE = HttpUtility.UrlDecode(_DocInfo.ORIGINAL_FILE);
229
            foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
230
            {
231
                ViewerDataModel.Instance.Document_Info.Add(item);
232
            }
233
            Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
234
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
235
            CurrentDoc = new Common.DocumentSet
236
            {
237
                docInfo = _DocInfo,
238
                Document_Id = _DocInfo.DOCUMENT_ID,
239
                Document_NO = _DocItem.DOCUMENT_NO,
240
                File_Original = _DocInfo.ORIGINAL_FILE,
241
                File_Result = _DocItem.RESULT_FILE,
242
                Group_No = _DocItem.GROUP_NO,
243
                ProjectNo = _DocItem.PROJECT_NO,
244
                Revision = _DocItem.REVISION,
245
            };
246
            var instanceMain = this.ParentOfType<MainWindow>();
247
            instanceMain.dzTopMenu.tlcurrentPage.Text = _DocInfo.PAGE_COUNT.ToString();
248
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = _DocInfo.PAGE_COUNT.ToString();
249
            string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
250
            instanceMain.TitleText.Text = apptitle;
251
            instanceMain.Title = apptitle;
252
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
253

    
254
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
255

    
256
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
257

    
258
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
259
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
260
        }
261

    
262
        /// <summary>
263
        /// get markupinfo and markupitem from database
264
        ///  - 1. called when document is loaded
265
        ///  - 2. called when user do consolidation
266
        /// </summary>
267
        /// <param name="sender"></param>
268
        /// <param name="e"></param>
269
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
270
        {
271
            Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
272

    
273
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
274
            ViewerDataModel.Instance.MarkupControls.Clear();
275
            if (e.Result != null)
276
            {
277
                ViewerDataModel.Instance._markupInfoList.Clear();
278
                if (e.Result.Count > 0)
279
                {
280
                    ViewerDataModel.Instance.MyMarkupList.Clear();
281
                }
282

    
283
                foreach(var info in e.Result)
284
                {
285
                    if (info.UserID == App.ViewInfo.UserID)
286
                    {
287
                        info.userDelete = true;
288
                        info.DisplayColor = "#FFFF0000";
289
                    }
290
                    else
291
                    {
292
                        info.userDelete = false;
293
                    }
294
                    ViewerDataModel.Instance._markupInfoList.Add(info);
295
                }
296

    
297
                e.Result.ToList().ForEach(d => d.MarkupList.ForEach(p =>
298
                {
299
                    if (d.UserID == App.ViewInfo.UserID)
300
                    {
301
                        d.userDelete = true;
302
                        d.DisplayColor = "#FFFF0000";
303

    
304
                        MarkupItemEx markup = new MarkupItemEx
305
                        {
306
                            Data = p.Data,
307
                            Data_Type = p.Data_Type,
308
                            ID = p.ID,
309
                            IsUpdate = false,
310
                            MarkupInfoID = d.MarkupInfoID,
311
                            PageNumber = p.PageNumber,
312
                            Symbol_ID = p.Symbol_ID,
313
                            //Group_ID = p.Group_ID
314
                        };
315
                        ViewerDataModel.Instance.MyMarkupList.Add(markup);
316

    
317
			            var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, d.DisplayColor, "",
318
                                        d.MarkupInfoID, markup.ID);
319
                        control.Visibility = Visibility.Hidden;
320
                    }
321
                    else
322
                    {
323
                        MarkupItemEx markup = new MarkupItemEx
324
                        {
325
                            Data = p.Data,
326
                            Data_Type = p.Data_Type,
327
                            ID = p.ID,
328
                            IsUpdate = false,
329
                            MarkupInfoID = d.MarkupInfoID,
330
                            PageNumber = p.PageNumber,
331
                            Symbol_ID = p.Symbol_ID,
332
                            //Group_ID = p.Group_ID
333
                        };
334
                        ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
335

    
336
			            var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, d.DisplayColor, "",
337
                                        d.MarkupInfoID, markup.ID);
338
                        control.Visibility = Visibility.Hidden;
339
                    }
340
                }));
341

    
342
                var currentUser = e.Result.Where(data => data.UserID == App.ViewInfo.UserID && data.AvoidConsolidate == 0).FirstOrDefault();
343
                if (currentUser == null)
344
                {
345
                    /// create a new markupinfo to do comments
346
                    var infoId = Commons.shortGuid();
347
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
348
                    {
349
                        CreateTime = DateTime.Now,
350
                        Depatment = userData.DEPARTMENT,
351
                        DisplayColor = "#FFFF0000",
352
                        UserID = userData.ID,
353
                        UserName = userData.NAME,
354
                        PageCount = 1,
355
                        Description = "",
356
                        MarkupInfoID = infoId,
357
                        MarkupList = null,
358
                        MarkupVersionID = Commons.shortGuid(),
359
                        Consolidate = 0,
360
                        PartConsolidate = 0,
361
                        userDelete = true,
362
                        AvoidConsolidate = 0,
363
                        IsPreviewUser = false
364
                    };
365

    
366
                    App.Custom_ViewInfoId = infoId;
367

    
368
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
369
                }
370
                else
371
                {
372
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
373
                }
374

    
375
                foreach(var info in e.Result)
376
                {
377
                    if (info.UserID == App.ViewInfo.UserID) info.DisplayColor = "#FFFF0000";
378
                }
379

    
380
                /// Consolidation 된 데이터가 최상단에 올 수 있도록 변경
381
                var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList();
382
                markupItem.ForEach(data =>
383
                {
384
                    if (data.Depatment == null) data.Depatment = "Unknown";
385
                });
386
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
387
                SetCommentPages();
388

    
389
                var SelectedItem = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.UpdateTime).FirstOrDefault();
390
                this.gridViewMarkup.SelectedItem = (PreviewUserMarkupInfoItem != null) ? PreviewUserMarkupInfoItem : SelectedItem;
391

    
392
                /// create a group descriptor
393
                gridViewMarkup.GroupDescriptors.Clear();
394
                GroupDescriptor descriptor = new GroupDescriptor();
395
                descriptor.Member = "Depatment";
396
                descriptor.DisplayContent = "DEPT";
397
                descriptor.SortDirection = ListSortDirection.Ascending;
398
                gridViewMarkup.GroupDescriptors.Add(descriptor);
399
                /// up to here
400
            }
401
        }
402

    
403
        private void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
404
        {
405
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
406
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
407
            //{
408
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
409
            //}
410

    
411
            if (ViewerDataModel.Instance.PageNumber == 0)
412
            {
413
                ViewerDataModel.Instance.PageNumber = 1;
414
            }
415
            if (e.AddedItems.Count() > 0)
416
            {
417
                foreach (var item in gridSelectionItem)
418
                {
419
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
420
                    //{
421
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
422
                    //});
423
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
424
                    {
425
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
426
                    });
427
                }
428
            }
429
            else if (e.RemovedItems.Count > 0)
430
            {
431
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
432

    
433
                (from A in _infoItem
434
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
435
                 where A.MarkupInfoID == B.MarkupInfoID
436
                 select B).ToList().ForEach(data =>
437
                 {
438
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
439
                 });
440
            }
441
        }
442

    
443
        /// <summary>
444
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
445
        /// </summary>
446
        /// <param name="sender"></param>
447
        /// <param name="e"></param>
448
        private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
449
        {
450
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
451
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
452
            var resultA = (from item_Select in dataSet
453
                           from item_Non in dataSet_User
454
                           where item_Select == item_Non
455
                           select item_Non).ToList();
456

    
457
            if (resultA.Count() >= 2)
458
            {
459
                RadWindow.Confirm(new DialogParameters
460
                {
461
                    Owner = Application.Current.MainWindow,
462
                    Header = "안내",
463
                    Content = "동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?",
464
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
465
                    {
466
                        if (e.AddedItems.Count() == 1)
467
                        {
468
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
469
                            var result = instanceItem.Consolidate;
470

    
471
                            if (ea.DialogResult.Value)
472
                            {
473
                                ConsolidationMethod();
474
                            }
475
                            else
476
                            {
477
                                ((RadGridView)sender).SelectedItem = null;
478
                            }
479
                        }
480
                    }),
481
                    Theme = new Windows8Theme(),
482
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
483
                });
484
            }
485
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
486
            {
487
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
488
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
489
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
490
                #region 코멘트 보기
491
                if (e.AddedItems.Count() > 0)
492
                {
493
                    foreach (var item in gridSelectionItem)
494
                    {
495
                        if ((item.UserID == App.ViewInfo.UserID) && (this.pageNavigator.CurrentPage != null))
496
                        {
497
                            var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
498
                            if (controls.Count == 0)
499
                            {
500
                                var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
501
                                foreach (var markup in instance)
502
                                {
503
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
504
                                        item.MarkupInfoID, markup.ID);
505
                                }
506
                            }
507

    
508
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
509
                            foreach (var control in controls)
510
                            {
511
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
512
                                control.Visibility = Visibility.Visible;
513
                            }
514
                        }
515
                        else if (this.pageNavigator.CurrentPage != null)
516
                        {
517
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
518
                            if (controls.Count == 0)
519
                            {
520
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
521
                                foreach (var markup in instance)
522
                                {
523
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "",
524
                                        item.MarkupInfoID, markup.ID);
525
                                }
526
                            }
527

    
528
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
529
                            foreach (var control in controls)
530
                            {
531
                                control.Visibility = Visibility.Visible;
532
                            }
533
                        }
534
                    }
535
                }
536
                #endregion
537
                #region 코멘트 숨기기
538
                else if (e.RemovedItems.Count > 0)
539
                {
540
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
541

    
542
                    (from A in _infoItem
543
                     from B in Common.ViewerDataModel.Instance.MarkupControls
544
                     where A.MarkupInfoID == B.MarkupInfoID
545
                     select B).ToList().ForEach(data =>
546
                     {
547
                         data.Visibility = Visibility.Hidden;                         
548
                     });
549

    
550

    
551
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
552
                    if (myComment != null)
553
                    {
554
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
555
                        {
556
                            markupitem.Visibility = Visibility.Hidden;
557
                        });
558
                    }
559
                }
560
                #endregion
561
            }
562
        }
563

    
564
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
565
        {
566
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
567

    
568
            if (e.Result != null)
569
            {
570
                _DocItem = e.Result;
571

    
572
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
573
                {
574
                    //장원
575
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
576
                }
577
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
578
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
579
            }
580
            else
581
            {
582
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
583
                {
584
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
585

    
586
                    if (ea.Error == null)
587
                    {
588
                        if (ea.Result)
589
                        {
590
                            this._ViewInfo.isAdmin = true;
591
                            Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
592
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
593
                        }
594
                        else
595
                        {
596
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
597
                            DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
598
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
599
                        }
600

    
601
                    }
602
                    else
603
                    {
604
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
605
                    }
606
                };
607
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
608
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
609
            }
610
        }
611

    
612
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
613
        {
614
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
615

    
616
            if (e.Error == null && e.Result != null)
617
            {
618
                App.SystemInfo = e.Result;
619

    
620
                //App.urlPort_DB = App.SystemInfo.HostPort;
621
                //App.urlHost_DB = App.SystemInfo.HostName;
622
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
623
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
624

    
625
                //if (App.urlHost.Contains("localhost"))
626
                //{
627
                //    App.urlHost = App.urlHost_DB;
628
                //}
629
            }
630
        }
631

    
632
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
633
        {
634
            
635
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
636
            string failedmsg = CommonLib.Common.GetAlertMessageString("GetConversionStateFailed", "MSG", "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!\n\n현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다.\n잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
637
            if (e.Error == null && e.Result == true)
638
            {
639
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
640

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

    
643
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
644
                {
645
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
646
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
647
                    if (userData != null)
648
                    {
649
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
650
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
651
                    }
652
                    else
653
                    {
654
                        userData = new MEMBER();
655
                        userData.DEPARTMENT = "ALL";
656
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
657
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
658
                    }
659
                }
660
            }
661
            else
662
            {
663
                
664
                DialogMessage_Alert(failedmsg, "Warning");
665
            }
666
        }
667

    
668
        
669

    
670

    
671
        public void SetView(ViewInfo info)
672
        {
673
            string docid = BaseClient.GetDocItemID(info.EnsembleID);
674
            this._ViewInfo = info;
675
            if (!string.IsNullOrEmpty(docid))
676
            {
677
                this._ViewInfo.DocumentItemID = docid;
678
            }
679
            
680
            if (!(App.ViewInfo.ProjectNO == "000000" || App.ViewInfo.ProjectNO == "000001"))
681
            {
682
                ViewerDataModel.Instance.SystemMain.dzTopMenu.btnTopStamp.Visibility = Visibility.Collapsed;
683
            }
684
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
685
            BaseClient.GetSystemDataAsync();
686
        }
687

    
688
        public void HubSet()
689
        {
690

    
691
            // 허브 연결 구성
692
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
693
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
694

    
695

    
696
            // 허브 연결 
697
            hubConnection.Start().ContinueWith(task =>
698
            {
699
                if (task.IsFaulted)
700
                {
701
                    Console.WriteLine("There was an error opening the connection:{0}",
702
                                      task.Exception.GetBaseException());
703
                }
704
                else
705
                {
706
                    Console.WriteLine("Connected :: " + task.Id);
707
                }
708

    
709
            }).Wait();
710

    
711

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

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

    
756
            //    if (status)
757
            //    {
758
            //        // 프로그램 시작 
759
            //        Console.WriteLine("connection status : " + status);
760
            //    }
761
            //    else
762
            //    {
763
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
764
            //        hubConnection.Stop();
765
            //    }
766
            //});
767

    
768
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
769
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
770
                Console.WriteLine("Noficiation Message : " + msg)
771
            );
772

    
773

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

    
777
            //Console.ReadKey();
778

    
779
            //hubConnection.Stop();
780
        }
781

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

    
822
            foreach (var item in gridSelectionItem)
823
            {
824
                if (item.UserID == App.ViewInfo.UserID)
825
                {
826
                    ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
827
                    {
828
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
829
                            item.MarkupInfoID, markupitem.ID);
830
                    });
831
                }
832
                else
833
                {
834
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
835
                    {
836
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
837
                    });
838
                }
839
            }
840
        }
841
    }
842
}
클립보드 이미지 추가 (최대 크기: 500 MB)