프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ eeb0a39c

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

1
using Microsoft.AspNet.SignalR.Client;
2
using IKCOM;
3
using KCOM.Common;
4
using KCOM.ServiceDeepView;
5
using KCOMDataModel.DataModel;
6
using Newtonsoft.Json;
7
using RestSharp;
8
using System;
9
using System.Collections.Generic;
10
using System.Collections.ObjectModel;
11
using System.ComponentModel;
12
using System.Linq;
13
using System.Runtime.CompilerServices;
14
using System.Text;
15
using System.Windows;
16
using System.Windows.Controls;
17
using Telerik.Windows.Controls;
18
using MarkupToPDF.Controls.Parsing;
19
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 KcomService.ServiceDeepViewClient BaseTaskClient;
29
        public ViewInfo _ViewInfo;
30
        public DOCINFO _DocInfo;
31
        public DOCUMENT_ITEM _DocItem;
32
        public MEMBER userData;
33

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

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

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

    
79

    
80

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

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

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

    
111
        /// <summary>
112
        /// Compare 결과를 받아 화면에 표시한다
113
        /// </summary>
114
        /// <param name="sender"></param>
115
        /// <param name="e"></param>
116
        private void BaseClient_GetCompareRectCompleted(object sender, GetCompareRectCompletedEventArgs e)
117
        {
118
            if (e.Error != null || e.Result == null)
119
            {
120
                if (e.Error != null)
121
                {
122
                    DialogMessage_Alert(e.Error.ToString(), "Error");
123
                }
124
                else
125
                {
126
                    DialogMessage_Alert("Compare 기능을 원활히 실행하기 위한 데이터가 부족합니다", "안내");
127
                }
128
            }
129
            else
130
            {
131
                e.Result.ForEach(d =>
132
                {
133
                    d.Width = d.Width * 3;
134
                    d.Height = d.Height * 3;
135
                    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
136
                    System.Windows.Shapes.Rectangle myEllipse = new System.Windows.Shapes.Rectangle();
137
                    myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100,255,8,0));
138
                    myEllipse.Opacity = 0.8;
139
                    myEllipse.Width = d.Width;
140
                    myEllipse.Height = d.Height;
141
                    Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
142
                    Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
143
                    myEllipse.RenderTransformOrigin = point;
144
                    canvas_compareBorder.Children.Add(myEllipse);
145
                });
146

    
147
                da.From = 0.8;
148
                da.To = 0.1;
149
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
150
                da.AutoReverse = true;
151
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
152
            }
153
        }
154

    
155
        private void BaseClient_SetFinalPDFCompleted(object sender, SetFinalPDFCompletedEventArgs e)
156
        {
157
            Logger.sendResLog("SetFinalPDFCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
158
            string errormsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFError", "MSG", "최종 파일을 만드는데 문제가 발생하였습니다");
159
            string successmsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFSuccess", "MSG", "최종 파일 생성 중입니다. 문서관리시스템을 확인해주세요");
160
            if (e.Error != null || e.Result.Status == FinalStatus.Error)
161
            {
162
                DialogMessage_Alert(errormsg, "안내");
163
            }
164
            else
165
            {
166
                DialogMessage_Alert(successmsg, "안내");
167
            }
168
        }
169

    
170
        private void BaseClient_GetVPRevisionHistoryCompleted(object sender, GetVPRevisionHistoryCompletedEventArgs e)
171
        {
172
            Logger.sendResLog("GetVPRevisionHistoryCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
173

    
174
            if (e.Result != null && e.Error == null)
175
            {
176
                List<VPRevision> list = e.Result;
177
                foreach (var item in list)
178
                {
179

    
180
                    if (App.isExternal)
181
                    {
182
                        var sBaseServiceURL = CommonLib.Common.GetConfigString("ExternalOriginalFileUrl", "URL", "", App.isExternal);
183

    
184
                        if (!string.IsNullOrWhiteSpace(item.TO_VENDOR))
185
                        {
186
                            var toUri = new Uri(HttpUtility.UrlDecode(item.TO_VENDOR));
187
                            item.TO_VENDOR = $"{sBaseServiceURL}{toUri.LocalPath}";
188
                        }
189

    
190
                        if (!string.IsNullOrWhiteSpace(item.FROM_VENDOR))
191
                        {
192
                            var fromUri = new Uri(HttpUtility.UrlDecode(item.FROM_VENDOR));
193
                            item.FROM_VENDOR = $"{sBaseServiceURL}{fromUri.LocalPath}";
194
                        }
195
                    }
196
                    else
197
                    {
198

    
199
                        item.FROM_VENDOR = HttpUtility.UrlDecode(item.FROM_VENDOR);
200
                    }
201
                }
202
                gridViewHistory.ItemsSource = list;
203
            }
204
            //TempFile.TempLoad();
205
        }
206

    
207
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
208
        {
209
            Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
210

    
211
            foreach(var info in ViewerDataModel.Instance._markupInfoList)
212
            {
213
                if(info.UserID == App.ViewInfo.UserID)
214
                {
215
                    info.userDelete = true;
216
                    info.DisplayColor = "FFFF0000";
217
                }
218
                else
219
                {
220
                    info.userDelete = false;
221
                }
222
            }
223
        }
224

    
225
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
226
        {
227
            Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
228

    
229
            if (e.Result != null)
230
            {
231
                e.Result.Sort();
232
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
233
            }
234
        }
235
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
236

    
237
        /// <summary>
238
        /// 문서 정보를 가져온다
239
        /// </summary>
240
        /// <param name="sender"></param>
241
        /// <param name="e"></param>
242
        private async void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
243
        {
244
            Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
245

    
246
            if (e.Error != null)
247
            {
248
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
249
                return;
250
            }
251

    
252
            string sFolder = _ViewInfo.DocumentItemID.All(char.IsDigit) ? (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString() : (_ViewInfo.DocumentItemID.Length >= 5 ? _ViewInfo.DocumentItemID.Substring(0, 5) : _ViewInfo.DocumentItemID);
253
            var MainUrl = string.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal).Replace("png","jpg"), _ViewInfo.ProjectNO, sFolder, _ViewInfo.DocumentItemID, "{PageNo}");
254
            _DocInfo = e.Result;
255
            _DocInfo.ORIGINAL_FILE = HttpUtility.UrlDecode(_DocInfo.ORIGINAL_FILE);
256
            foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
257
            {
258
                ViewerDataModel.Instance.Document_Info.Add(item);
259
            }
260
            Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
261
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
262
            CurrentDoc = new Common.DocumentSet
263
            {
264
                docInfo = _DocInfo,
265
                Document_Id = _DocInfo.DOCUMENT_ID,
266
                Document_NO = _DocItem.DOCUMENT_NO,
267
                File_Original = _DocInfo.ORIGINAL_FILE,
268
                File_Result = _DocItem.RESULT_FILE,
269
                Group_No = _DocItem.GROUP_NO,
270
                ProjectNo = _DocItem.PROJECT_NO,
271
                Revision = _DocItem.REVISION,
272
            };
273
            var instanceMain = this.ParentOfType<MainWindow>();
274
            string firstpage = "1";
275
            string lastpage = _DocInfo.PAGE_COUNT.ToString();
276
            instanceMain.dzTopMenu.tlcurrentPage.Text = firstpage;
277
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = lastpage;
278
            string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
279
            instanceMain.TitleText.Text = apptitle;
280
            instanceMain.Title = apptitle;
281

    
282
            #region 페이지 이미지를 로컬에 저장
283
            string tempStoragePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(),"MARKUS", System.IO.Path.GetRandomFileName());
284

    
285
            //.Replace("jpg", "png")을 붙이는 이유는 MainUrl에 확장명이 jpg로 설정한 경우가 있기 때문
286

    
287
            #endregion
288
            App.PageStorage = new PageManager.PageStorage(MainUrl.Replace("jpg", "png"), tempStoragePath, _DocInfo.PAGE_COUNT);
289

    
290
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
291

    
292
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
293

    
294
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
295

    
296
            #region 단어 검색용 파일 다운로드
297

    
298
            await DownloadOriginalFileAsync();
299
        
300

    
301
            #endregion
302

    
303
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
304
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
305

    
306
        }
307

    
308
        /// <summary>
309
        /// get markupinfo and markupitem from database
310
        ///  - 1. called when document is loaded
311
        ///  - 2. called when user do consolidation
312
        /// </summary>
313
        /// <param name="sender"></param>
314
        /// <param name="e"></param>
315
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
316
        {
317
            Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
318

    
319
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
320
            ViewerDataModel.Instance.MarkupControls.Clear();
321
            if (e.Result != null)
322
            {
323
                ViewerDataModel.Instance._markupInfoList.Clear();
324
                if (e.Result.Count > 0) ViewerDataModel.Instance.MyMarkupList.Clear();
325

    
326
                foreach(var info in e.Result)
327
                {
328
                    if (info.UserID == App.ViewInfo.UserID)
329
                    {
330
                        info.userDelete = true;
331
                        info.DisplayColor = "#FFFF0000";
332
                    }
333
                    else
334
                    {
335
                        info.userDelete = false;
336
                    }
337
                    ViewerDataModel.Instance._markupInfoList.Add(info);
338
                }
339

    
340
                var userInfoList = ViewerDataModel.Instance._markupInfoList.GroupBy(f => f.UserID).Select(f=>new MarkupUserInfo { UserId = f.Key, UserName = f.First().UserName });
341

    
342
                userInfoList.ToList().ForEach(x => ViewerDataModel.Instance._markupUserList.Add(x));
343

    
344
                e.Result.ToList().ForEach(d => d.MarkupList.ForEach(p =>
345
                {
346
                    if (d.UserID == App.ViewInfo.UserID)
347
                    {
348
                        d.userDelete = true;
349
                        d.DisplayColor = "#FFFF0000";
350

    
351
                        MarkupItemEx markup = new MarkupItemEx
352
                        {
353
                            Data = p.Data,
354
                            Data_Type = p.Data_Type,
355
                            ID = p.ID,
356
                            IsUpdate = false,
357
                            MarkupInfoID = d.MarkupInfoID,
358
                            PageNumber = p.PageNumber,
359
                            Symbol_ID = p.Symbol_ID,
360
                            //Group_ID = p.Group_ID
361
                        };
362
                        ViewerDataModel.Instance.MyMarkupList.Add(markup);
363
                    }
364
                    else
365
                    {
366
                        MarkupItemEx markup = new MarkupItemEx
367
                        {
368
                            Data = p.Data,
369
                            Data_Type = p.Data_Type,
370
                            ID = p.ID,
371
                            IsUpdate = false,
372
                            MarkupInfoID = d.MarkupInfoID,
373
                            PageNumber = p.PageNumber,
374
                            Symbol_ID = p.Symbol_ID,
375
                            //Group_ID = p.Group_ID
376
                        };
377
                        ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
378
                    }
379
                }));
380

    
381
                var currentUser = e.Result.Where(data => data.UserID == App.ViewInfo.UserID && data.AvoidConsolidate == 0).FirstOrDefault();
382
                if (currentUser == null)
383
                {
384
                    /// create a new markupinfo to do comments
385
                    var infoId = Commons.shortGuid();
386
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
387
                    {
388
                        CreateTime = DateTime.Now,
389
                        UpdateTime = DateTime.Now,
390
                        Depatment = userData.DEPARTMENT,
391
                        DisplayColor = "#FFFF0000",
392
                        UserID = userData.ID,
393
                        UserName = userData.NAME,
394
                        PageCount = 1,
395
                        Description = "",
396
                        MarkupInfoID = infoId,
397
                        MarkupList = null,
398
                        MarkupVersionID = Commons.shortGuid(),
399
                        Consolidate = 0,
400
                        PartConsolidate = 0,
401
                        userDelete = true,
402
                        AvoidConsolidate = 0,
403
                        IsPreviewUser = false
404
                    };
405

    
406
                    App.Custom_ViewInfoId = infoId;
407

    
408
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
409
                }
410
                else
411
                {
412
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
413
                }
414

    
415
                foreach(var info in e.Result)
416
                {
417
                    if (info.UserID == App.ViewInfo.UserID) info.DisplayColor = "#FFFF0000";
418
                }
419

    
420
                ViewerDataModel.Instance.PageNumber = 1;
421

    
422
                /// Consolidation 된 데이터가 최상단에 올 수 있도록 변경
423
                var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList();
424
                markupItem.ForEach(data =>
425
                {
426
                    if (data.Depatment == null) data.Depatment = "Unknown";
427
                });
428
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
429
                SetCommentPages();
430

    
431
                var SelectedItem = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.UpdateTime).FirstOrDefault();
432
                this.gridViewMarkup.SelectedItem = (PreviewUserMarkupInfoItem != null) ? PreviewUserMarkupInfoItem : SelectedItem;
433
                
434
                /// create a group descriptor
435
                gridViewMarkup.GroupDescriptors.Clear();
436
                GroupDescriptor descriptor = new GroupDescriptor();
437
                descriptor.Member = "Depatment";
438
                descriptor.DisplayContent = "DEPT";
439
                //descriptor.SortDirection = ListSortDirection.Ascending;
440
                gridViewMarkup.GroupDescriptors.Add(descriptor);
441
                /// up to here
442
            }
443
        }
444

    
445
        private void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
446
        {
447
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
448
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
449
            //{
450
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
451
            //}
452

    
453
            if (ViewerDataModel.Instance.PageNumber == 0)
454
            {
455
                ViewerDataModel.Instance.PageNumber = 1;
456
            }
457
            if (e.AddedItems.Count() > 0)
458
            {
459
                foreach (var item in gridSelectionItem)
460
                {
461
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
462
                    //{
463
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
464
                    //});
465
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
466
                    {
467
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
468
                    });
469
                }
470
            }
471
            else if (e.RemovedItems.Count > 0)
472
            {
473
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
474

    
475
                (from A in _infoItem
476
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
477
                 where A.MarkupInfoID == B.MarkupInfoID
478
                 select B).ToList().ForEach(data =>
479
                 {
480
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
481
                 });
482
            }
483
        }
484

    
485
        /// <summary>
486
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
487
        /// </summary>
488
        /// <param name="sender"></param>
489
        /// <param name="e"></param>
490
        private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
491
        {
492
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
493

    
494
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
495
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
496
            var resultA = (from item_Select in dataSet
497
                           from item_Non in dataSet_User
498
                           where item_Select == item_Non
499
                           select item_Non).ToList();
500

    
501
            if (resultA.Count() >= 2)
502
            {
503
                // 동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?
504
                RadWindow.Confirm(new DialogParameters
505
                {
506
                    Owner = Application.Current.MainWindow,
507
                    Header = "Info",
508
                    Content = "Selected more than two identical user data. Do you want to select consolidation?",
509
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
510
                    {
511
                        if (e.AddedItems.Count() == 1)
512
                        {
513
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
514
                            gridViewMarkup.SelectedItem = null;
515

    
516
                        
517
                            if (ea.DialogResult.Value)
518
                            {
519
                                if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
520
                                {
521
                                    gridViewMarkup.SelectedItem = instanceItem;
522
                                }
523
                                else
524
                                {
525
                                    //1. Consolidations이 있다면 하나 선택
526
                                    var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
527

    
528
                                    if (Consolidations.Count() > 0)
529
                                    {
530
                                        gridViewMarkup.SelectedItem = Consolidations.First();
531
                                    }
532
                                }
533
                              
534
                            }
535
                            else {
536
                                //1. Consolidations 아닌게 있다면 Change
537
                                var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
538

    
539
                                if(notConsolidations.Count() > 0) {
540
                                    gridViewMarkup.SelectedItem = notConsolidations.First();
541
                                }
542
                                else {//1. Consolidations 아닌게 없다면 그대로
543
                                    gridViewMarkup.SelectedItem = instanceItem;
544
                                }
545
                                
546
                            }
547
                        }
548
                    }),
549
                    Theme = new Windows8Theme(),
550
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
551
                });
552
            }
553
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
554
            {
555
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
556
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
557
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
558
                #region 코멘트 보기
559
                if (e.AddedItems.Count() > 0)
560
                {
561
                    foreach (var item in gridSelectionItem)
562
                    {
563
                        if (item.UserID == App.ViewInfo.UserID)
564
                        {
565
                            var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
566
                            if (controls.Count == 0)
567
                            {
568
                                var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
569
                                foreach (var markup in instance)
570
                                {
571
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
572
                                        item.MarkupInfoID, markup.ID);
573
                                }
574
                            }
575

    
576
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
577
                            foreach (var control in controls)
578
                            {
579
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
580
                                control.Visibility = Visibility.Visible;
581
                            }
582
                        }
583
                        else
584
                        {
585
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
586
                            if (controls.Count == 0)
587
                            {
588
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
589
                                foreach (var markup in instance)
590
                                {
591
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "",
592
                                        item.MarkupInfoID, markup.ID);
593
                                }
594
                            }
595

    
596
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
597
                            foreach (var control in controls)
598
                            {
599
                                control.Visibility = Visibility.Visible;
600
                            }
601
                        }
602
                    }
603
                }
604
                #endregion
605
                #region 코멘트 숨기기
606
                else if (e.RemovedItems.Count > 0)
607
                {
608
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
609

    
610
                    (from A in _infoItem
611
                     from B in Common.ViewerDataModel.Instance.MarkupControls
612
                     where A.MarkupInfoID == B.MarkupInfoID
613
                     select B).ToList().ForEach(data =>
614
                     {
615
                         data.Visibility = Visibility.Hidden;                         
616
                     });
617

    
618

    
619
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
620
                    if (myComment != null)
621
                    {
622
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
623
                        {
624
                            markupitem.Visibility = Visibility.Hidden;
625
                        });
626
                    }
627
                }
628
                #endregion
629
            }
630
        }
631

    
632
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
633
        {
634
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
635

    
636
            if (e.Result != null)
637
            {
638
                _DocItem = e.Result;
639

    
640
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
641
                {
642
                    //장원
643
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
644
                }
645
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
646
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
647
            }
648
            else
649
            {
650
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
651
                {
652
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
653

    
654
                    if (ea.Error == null)
655
                    {
656
                        if (ea.Result)
657
                        {
658
                            this._ViewInfo.isAdmin = true;
659
                            Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
660
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
661
                        }
662
                        else
663
                        {
664
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
665
                            DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
666
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
667
                        }
668

    
669
                    }
670
                    else
671
                    {
672
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
673
                    }
674
                };
675
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
676
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
677
            }
678
        }
679

    
680
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
681
        {
682
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
683

    
684
            if (e.Error == null && e.Result != null)
685
            {
686
                App.SystemInfo = e.Result;
687

    
688
                //App.urlPort_DB = App.SystemInfo.HostPort;
689
                //App.urlHost_DB = App.SystemInfo.HostName;
690
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
691
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
692

    
693
                //if (App.urlHost.Contains("localhost"))
694
                //{
695
                //    App.urlHost = App.urlHost_DB;
696
                //}
697
            }
698
        }
699

    
700
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
701
        {
702
            
703
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
704
            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잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
705
            if (e.Error == null && e.Result == true)
706
            {
707
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
708

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

    
711
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
712
                {
713
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
714
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
715
                    if (userData != null)
716
                    {
717
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
718
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
719
                    }
720
                    else
721
                    {
722
                        userData = new MEMBER();
723
                        userData.DEPARTMENT = "ALL";
724
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
725
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
726
                    }
727
                }
728
            }
729
            else
730
            {
731
                
732
                DialogMessage_Alert(failedmsg, "Warning");
733
            }
734
        }
735

    
736
        public void SetView(ViewInfo info)
737
        { 
738
            this._ViewInfo = info;
739
            try
740
            {
741
                /// 대림의 경우 EnsembleID를 가지고 DocumentItemID를 구함
742
                /// 다른 Site를 대비하여 에러 처리함
743
                string docid = BaseClient.GetDocItemID(info.EnsembleID);
744
                if (!string.IsNullOrEmpty(docid))
745
                {
746
                    this._ViewInfo.DocumentItemID = docid;
747
                }
748
            }
749
            catch(Exception ex)
750
            {
751
                App.FileLogger.Fatal(ex);
752
            }
753

    
754
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
755
            BaseClient.GetSystemDataAsync();
756
        }
757

    
758
        public void HubSet()
759
        {
760
            // 허브 연결 구성
761
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
762
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
763

    
764

    
765
            // 허브 연결 
766
            hubConnection.Start().ContinueWith(task =>
767
            {
768
                if (task.IsFaulted)
769
                {
770
                    Console.WriteLine("There was an error opening the connection:{0}",
771
                                      task.Exception.GetBaseException());
772
                    //throw task.Exception.GetBaseException();
773
                }
774
                else
775
                {
776
                    Console.WriteLine("Connected :: " + task.Id);
777
                }
778

    
779
            }).Wait();
780

    
781

    
782
            // [ 프로그램 시작 ]
783
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
784
            //( "method name", arg1, arg2 )
785
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
786
            //{
787
            //    if (task.IsFaulted)
788
            //    {
789
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
790
            //    }
791
            //    else
792
            //    {
793
            //        Console.WriteLine(task.Result);
794
            //    }
795
            //});
796
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID,App.ViewInfo.ProjectNO).ContinueWith(task =>
797
            {
798
                if (task.IsFaulted)
799
                {
800
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
801
                    //throw task.Exception.GetBaseException();
802
                }
803
                else
804
                {
805
                    switch (task.Result)
806
                    {
807
                        case "2":
808
                            {
809
                                var result = MessageBox.Show("권한이 없습니다.");
810
                                if (result == MessageBoxResult.OK)
811
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
812
                            }
813
                            break;
814
                        case "404":
815
                            {
816
                                var result = MessageBox.Show("등록된 사용자가 아닙니다.");
817
                                if(result == MessageBoxResult.OK)
818
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
819
                            }
820
                            break;
821
                    }
822
                }
823
            });
824

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

    
829
            //    if (status)
830
            //    {
831
            //        // 프로그램 시작 
832
            //        Console.WriteLine("connection status : " + status);
833
            //    }
834
            //    else
835
            //    {
836
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
837
            //        hubConnection.Stop();
838
            //    }
839
            //});
840

    
841
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
842
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
843
                Console.WriteLine("Noficiation Message : " + msg)
844
            );
845

    
846

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

    
850
            //Console.ReadKey();
851

    
852
            //hubConnection.Stop();
853
        }
854

    
855
        public void MarkupUserListDisplay()
856
        {
857
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
858
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
859
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
860
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
861
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
862
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
863
            //foreach (var item in gridSelectionItem)
864
            //{
865
            //    if (item.UserID == App.ViewInfo.UserID)
866
            //    {
867
            //        ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
868
            //        {
869
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
870
            //        });
871
            //    }
872
            //    else
873
            //    {
874
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
875
            //        {
876
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
877
            //        });
878
            //    }
879
            //}
880
                (from A in gridSelectionItem
881
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
882
                 where A.MarkupInfoID == B.MarkupInfoID
883
                 select B).ToList().ForEach(data =>
884
                 {
885
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
886
                 });
887
            (from A in gridSelectionItem
888
             from B in Common.ViewerDataModel.Instance.MarkupControls
889
             where A.MarkupInfoID == B.MarkupInfoID
890
             select B).ToList().ForEach(data =>
891
             {
892
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
893
             });
894

    
895
            foreach (var item in gridSelectionItem)
896
            {
897
                if (item.UserID == App.ViewInfo.UserID)
898
                {
899
                    ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
900
                    {
901
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
902
                            item.MarkupInfoID, markupitem.ID);
903
                    });
904
                }
905
                else
906
                {
907
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
908
                    {
909
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
910
                    });
911
                }
912
            }
913
        }
914
    }
915
}
클립보드 이미지 추가 (최대 크기: 500 MB)