프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ eb5cdefc

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

1
using Microsoft.AspNet.SignalR.Client;
2
using IKCOM;
3
using KCOM.Common;
4
using KCOM.ServiceDeepView;
5
using KCOMDataModel.DataModel;
6
using Newtonsoft.Json;
7
using RestSharp;
8
using System;
9
using System.Collections.Generic;
10
using System.Collections.ObjectModel;
11
using System.ComponentModel;
12
using System.Linq;
13
using System.Runtime.CompilerServices;
14
using System.Text;
15
using System.Windows;
16
using System.Windows.Controls;
17
using Telerik.Windows.Controls;
18
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 = string.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal).Replace("png","jpg"), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, "{PageNo}");
222
            _DocInfo = e.Result;
223
            _DocInfo.ORIGINAL_FILE = HttpUtility.UrlDecode(_DocInfo.ORIGINAL_FILE);
224
            foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
225
            {
226
                ViewerDataModel.Instance.Document_Info.Add(item);
227
            }
228
            Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
229
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
230
            CurrentDoc = new Common.DocumentSet
231
            {
232
                docInfo = _DocInfo,
233
                Document_Id = _DocInfo.DOCUMENT_ID,
234
                Document_NO = _DocItem.DOCUMENT_NO,
235
                File_Original = _DocInfo.ORIGINAL_FILE,
236
                File_Result = _DocItem.RESULT_FILE,
237
                Group_No = _DocItem.GROUP_NO,
238
                ProjectNo = _DocItem.PROJECT_NO,
239
                Revision = _DocItem.REVISION,
240
            };
241
            var instanceMain = this.ParentOfType<MainWindow>();
242
            instanceMain.dzTopMenu.tlcurrentPage.Text = _DocInfo.PAGE_COUNT.ToString();
243
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = _DocInfo.PAGE_COUNT.ToString();
244
            string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
245
            instanceMain.TitleText.Text = apptitle;
246
            instanceMain.Title = apptitle;
247
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
248

    
249
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
250

    
251
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
252

    
253
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
254
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
255
        }
256

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

    
268
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
269
            ViewerDataModel.Instance.MarkupControls.Clear();
270
            if (e.Result != null)
271
            {
272
                ViewerDataModel.Instance._markupInfoList.Clear();
273
                if (e.Result.Count > 0)
274
                {
275
                    ViewerDataModel.Instance.MyMarkupList.Clear();
276
                }
277

    
278
                foreach(var info in e.Result)
279
                {
280
                    if (info.UserID == App.ViewInfo.UserID)
281
                    {
282
                        info.userDelete = true;
283
                        info.DisplayColor = "#FFFF0000";
284
                    }
285
                    else
286
                    {
287
                        info.userDelete = false;
288
                    }
289
                    ViewerDataModel.Instance._markupInfoList.Add(info);
290
                }
291

    
292
                e.Result.ToList().ForEach(d => d.MarkupList.ForEach(p =>
293
                {
294
                    if (d.UserID == App.ViewInfo.UserID)
295
                    {
296
                        d.userDelete = true;
297
                        d.DisplayColor = "#FFFF0000";
298

    
299
                        MarkupItemEx markup = new MarkupItemEx
300
                        {
301
                            Data = p.Data,
302
                            Data_Type = p.Data_Type,
303
                            ID = p.ID,
304
                            IsUpdate = false,
305
                            MarkupInfoID = d.MarkupInfoID,
306
                            PageNumber = p.PageNumber,
307
                            Symbol_ID = p.Symbol_ID,
308
                            //Group_ID = p.Group_ID
309
                        };
310
                        ViewerDataModel.Instance.MyMarkupList.Add(markup);
311

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

    
331
			            var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, d.DisplayColor, "",
332
                                        d.MarkupInfoID, markup.ID);
333
                        control.Visibility = Visibility.Hidden;
334
                    }
335
                }));
336

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

    
361
                    App.Custom_ViewInfoId = infoId;
362

    
363
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
364
                }
365
                else
366
                {
367
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
368
                }
369

    
370
                foreach(var info in e.Result)
371
                {
372
                    if (info.UserID == App.ViewInfo.UserID) info.DisplayColor = "#FFFF0000";
373
                }
374

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

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

    
387
                /// create a group descriptor
388
                gridViewMarkup.GroupDescriptors.Clear();
389
                GroupDescriptor descriptor = new GroupDescriptor();
390
                descriptor.Member = "Depatment";
391
                descriptor.DisplayContent = "DEPT";
392
                descriptor.SortDirection = ListSortDirection.Ascending;
393
                gridViewMarkup.GroupDescriptors.Add(descriptor);
394
                /// up to here
395
            }
396
        }
397

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

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

    
428
                (from A in _infoItem
429
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
430
                 where A.MarkupInfoID == B.MarkupInfoID
431
                 select B).ToList().ForEach(data =>
432
                 {
433
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
434
                 });
435
            }
436
        }
437

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

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

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

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

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

    
537
                    (from A in _infoItem
538
                     from B in Common.ViewerDataModel.Instance.MarkupControls
539
                     where A.MarkupInfoID == B.MarkupInfoID
540
                     select B).ToList().ForEach(data =>
541
                     {
542
                         data.Visibility = Visibility.Hidden;                         
543
                     });
544

    
545

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

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

    
563
            if (e.Result != null)
564
            {
565
                _DocItem = e.Result;
566

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

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

    
596
                    }
597
                    else
598
                    {
599
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
600
                    }
601
                };
602
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
603
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
604
            }
605
        }
606

    
607
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
608
        {
609
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
610

    
611
            if (e.Error == null && e.Result != null)
612
            {
613
                App.SystemInfo = e.Result;
614

    
615
                //App.urlPort_DB = App.SystemInfo.HostPort;
616
                //App.urlHost_DB = App.SystemInfo.HostName;
617
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
618
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
619

    
620
                //if (App.urlHost.Contains("localhost"))
621
                //{
622
                //    App.urlHost = App.urlHost_DB;
623
                //}
624
            }
625
        }
626

    
627
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
628
        {
629
            
630
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
631
            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잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
632
            if (e.Error == null && e.Result == true)
633
            {
634
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
635

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

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

    
663
        
664

    
665

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

    
683
        public void HubSet()
684
        {
685

    
686
            // 허브 연결 구성
687
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
688
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
689

    
690

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

    
704
            }).Wait();
705

    
706

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

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

    
751
            //    if (status)
752
            //    {
753
            //        // 프로그램 시작 
754
            //        Console.WriteLine("connection status : " + status);
755
            //    }
756
            //    else
757
            //    {
758
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
759
            //        hubConnection.Stop();
760
            //    }
761
            //});
762

    
763
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
764
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
765
                Console.WriteLine("Noficiation Message : " + msg)
766
            );
767

    
768

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

    
772
            //Console.ReadKey();
773

    
774
            //hubConnection.Stop();
775
        }
776

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

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