프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 3ffd4b2d

이력 | 보기 | 이력해설 | 다운로드 (39.8 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
            string firstpage = "1";
243
            string lastpage = _DocInfo.PAGE_COUNT.ToString();
244
            instanceMain.dzTopMenu.tlcurrentPage.Text = firstpage;
245
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = lastpage;
246
            string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
247
            instanceMain.TitleText.Text = apptitle;
248
            instanceMain.Title = apptitle;
249
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
250

    
251
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
252

    
253
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
254

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

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

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

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

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

    
298
                        MarkupItemEx markup = new MarkupItemEx
299
                        {
300
                            Data = p.Data,
301
                            Data_Type = p.Data_Type,
302
                            ID = p.ID,
303
                            IsUpdate = false,
304
                            MarkupInfoID = d.MarkupInfoID,
305
                            PageNumber = p.PageNumber,
306
                            Symbol_ID = p.Symbol_ID,
307
                            //Group_ID = p.Group_ID
308
                        };
309
                        ViewerDataModel.Instance.MyMarkupList.Add(markup);
310
                    }
311
                    else
312
                    {
313
                        MarkupItemEx markup = new MarkupItemEx
314
                        {
315
                            Data = p.Data,
316
                            Data_Type = p.Data_Type,
317
                            ID = p.ID,
318
                            IsUpdate = false,
319
                            MarkupInfoID = d.MarkupInfoID,
320
                            PageNumber = p.PageNumber,
321
                            Symbol_ID = p.Symbol_ID,
322
                            //Group_ID = p.Group_ID
323
                        };
324
                        ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
325
                    }
326
                }));
327

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

    
352
                    App.Custom_ViewInfoId = infoId;
353

    
354
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
355
                }
356
                else
357
                {
358
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
359
                }
360

    
361
                foreach(var info in e.Result)
362
                {
363
                    if (info.UserID == App.ViewInfo.UserID) info.DisplayColor = "#FFFF0000";
364
                }
365

    
366
                ViewerDataModel.Instance.PageNumber = 1;
367

    
368
                /// Consolidation 된 데이터가 최상단에 올 수 있도록 변경
369
                var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList();
370
                markupItem.ForEach(data =>
371
                {
372
                    if (data.Depatment == null) data.Depatment = "Unknown";
373
                });
374
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
375
                SetCommentPages();
376

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

    
380
                /// create a group descriptor
381
                gridViewMarkup.GroupDescriptors.Clear();
382
                GroupDescriptor descriptor = new GroupDescriptor();
383
                descriptor.Member = "Depatment";
384
                descriptor.DisplayContent = "DEPT";
385
                descriptor.SortDirection = ListSortDirection.Ascending;
386
                gridViewMarkup.GroupDescriptors.Add(descriptor);
387
                /// up to here
388
            }
389
        }
390

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

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

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

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

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

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

    
496
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
497
                            foreach (var control in controls)
498
                            {
499
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
500
                                control.Visibility = Visibility.Visible;
501
                            }
502
                        }
503
                        else
504
                        {
505
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
506
                            if (controls.Count == 0)
507
                            {
508
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == ViewerDataModel.Instance.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
509
                                foreach (var markup in instance)
510
                                {
511
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "",
512
                                        item.MarkupInfoID, markup.ID);
513
                                }
514
                            }
515

    
516
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
517
                            foreach (var control in controls)
518
                            {
519
                                control.Visibility = Visibility.Visible;
520
                            }
521
                        }
522
                    }
523
                }
524
                #endregion
525
                #region 코멘트 숨기기
526
                else if (e.RemovedItems.Count > 0)
527
                {
528
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
529

    
530
                    (from A in _infoItem
531
                     from B in Common.ViewerDataModel.Instance.MarkupControls
532
                     where A.MarkupInfoID == B.MarkupInfoID
533
                     select B).ToList().ForEach(data =>
534
                     {
535
                         data.Visibility = Visibility.Hidden;                         
536
                     });
537

    
538

    
539
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
540
                    if (myComment != null)
541
                    {
542
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
543
                        {
544
                            markupitem.Visibility = Visibility.Hidden;
545
                        });
546
                    }
547
                }
548
                #endregion
549
            }
550
        }
551

    
552
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
553
        {
554
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
555

    
556
            if (e.Result != null)
557
            {
558
                _DocItem = e.Result;
559

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

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

    
589
                    }
590
                    else
591
                    {
592
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
593
                    }
594
                };
595
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
596
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
597
            }
598
        }
599

    
600
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
601
        {
602
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
603

    
604
            if (e.Error == null && e.Result != null)
605
            {
606
                App.SystemInfo = e.Result;
607

    
608
                //App.urlPort_DB = App.SystemInfo.HostPort;
609
                //App.urlHost_DB = App.SystemInfo.HostName;
610
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
611
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
612

    
613
                //if (App.urlHost.Contains("localhost"))
614
                //{
615
                //    App.urlHost = App.urlHost_DB;
616
                //}
617
            }
618
        }
619

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

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

    
631
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
632
                {
633
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
634
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
635
                    if (userData != null)
636
                    {
637
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
638
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
639
                    }
640
                    else
641
                    {
642
                        userData = new MEMBER();
643
                        userData.DEPARTMENT = "ALL";
644
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
645
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
646
                    }
647
                }
648
            }
649
            else
650
            {
651
                
652
                DialogMessage_Alert(failedmsg, "Warning");
653
            }
654
        }
655

    
656
        
657

    
658

    
659
        public void SetView(ViewInfo info)
660
        {
661
            string docid = BaseClient.GetDocItemID(info.EnsembleID);
662
            this._ViewInfo = info;
663
            if (!string.IsNullOrEmpty(docid))
664
            {
665
                this._ViewInfo.DocumentItemID = docid;
666
            }
667
            
668
            if (!(App.ViewInfo.ProjectNO == "000000" || App.ViewInfo.ProjectNO == "000001"))
669
            {
670
                ViewerDataModel.Instance.SystemMain.dzTopMenu.btnTopStamp.Visibility = Visibility.Collapsed;
671
            }
672
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
673
            BaseClient.GetSystemDataAsync();
674
        }
675

    
676
        public void HubSet()
677
        {
678

    
679
            // 허브 연결 구성
680
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
681
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
682

    
683

    
684
            // 허브 연결 
685
            hubConnection.Start().ContinueWith(task =>
686
            {
687
                if (task.IsFaulted)
688
                {
689
                    Console.WriteLine("There was an error opening the connection:{0}",
690
                                      task.Exception.GetBaseException());
691
                }
692
                else
693
                {
694
                    Console.WriteLine("Connected :: " + task.Id);
695
                }
696

    
697
            }).Wait();
698

    
699

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

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

    
744
            //    if (status)
745
            //    {
746
            //        // 프로그램 시작 
747
            //        Console.WriteLine("connection status : " + status);
748
            //    }
749
            //    else
750
            //    {
751
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
752
            //        hubConnection.Stop();
753
            //    }
754
            //});
755

    
756
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
757
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
758
                Console.WriteLine("Noficiation Message : " + msg)
759
            );
760

    
761

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

    
765
            //Console.ReadKey();
766

    
767
            //hubConnection.Stop();
768
        }
769

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

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