프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ f4ec4218

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

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

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

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

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

    
178
                    if (App.isExternal)
179
                    {
180
                        var sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", App.isExternal);
181

    
182
                        var toUri = new Uri(HttpUtility.UrlDecode(item.TO_VENDOR));
183
                        var fromUri = new Uri(HttpUtility.UrlDecode(item.FROM_VENDOR));
184

    
185
                        item.TO_VENDOR = $"{sBaseServiceURL}{toUri.LocalPath}";
186
                        item.FROM_VENDOR = $"{sBaseServiceURL}{fromUri.LocalPath}";
187
                        
188
                    }
189
                    else
190
                    {
191

    
192
                        item.FROM_VENDOR = HttpUtility.UrlDecode(item.FROM_VENDOR);
193
                    }
194
                }
195
                gridViewHistory.ItemsSource = list;
196
            }
197
            //TempFile.TempLoad();
198
        }
199

    
200
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
201
        {
202
            Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
203

    
204
            foreach(var info in ViewerDataModel.Instance._markupInfoList)
205
            {
206
                if(info.UserID == App.ViewInfo.UserID)
207
                {
208
                    info.userDelete = true;
209
                    info.DisplayColor = "FFFF0000";
210
                }
211
                else
212
                {
213
                    info.userDelete = false;
214
                }
215
            }
216
        }
217

    
218
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
219
        {
220
            Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
221

    
222
            if (e.Result != null)
223
            {
224
                e.Result.Sort();
225
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
226
            }
227
        }
228
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
229

    
230
        /// <summary>
231
        /// 문서 정보를 가져온다
232
        /// </summary>
233
        /// <param name="sender"></param>
234
        /// <param name="e"></param>
235
        private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
236
        {
237
            Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
238

    
239
            if (e.Error != null)
240
            {
241
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
242
                return;
243
            }
244

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

    
276
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
277

    
278
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
279

    
280
            #region 단어 검색용 파일 다운로드
281

    
282
            var task = DownloadOriginalFileAsync();
283
            task.ConfigureAwait(false);
284

    
285
            #endregion
286

    
287
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
288
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
289

    
290
        }
291

    
292
        /// <summary>
293
        /// get markupinfo and markupitem from database
294
        ///  - 1. called when document is loaded
295
        ///  - 2. called when user do consolidation
296
        /// </summary>
297
        /// <param name="sender"></param>
298
        /// <param name="e"></param>
299
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
300
        {
301
            Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
302

    
303
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
304
            ViewerDataModel.Instance.MarkupControls.Clear();
305
            if (e.Result != null)
306
            {
307
                ViewerDataModel.Instance._markupInfoList.Clear();
308
                if (e.Result.Count > 0) ViewerDataModel.Instance.MyMarkupList.Clear();
309

    
310
                foreach(var info in e.Result)
311
                {
312
                    if (info.UserID == App.ViewInfo.UserID)
313
                    {
314
                        info.userDelete = true;
315
                        info.DisplayColor = "#FFFF0000";
316
                    }
317
                    else
318
                    {
319
                        info.userDelete = false;
320
                    }
321
                    ViewerDataModel.Instance._markupInfoList.Add(info);
322
                }
323

    
324
                e.Result.ToList().ForEach(d => d.MarkupList.ForEach(p =>
325
                {
326
                    if (d.UserID == App.ViewInfo.UserID)
327
                    {
328
                        d.userDelete = true;
329
                        d.DisplayColor = "#FFFF0000";
330

    
331
                        MarkupItemEx markup = new MarkupItemEx
332
                        {
333
                            Data = p.Data,
334
                            Data_Type = p.Data_Type,
335
                            ID = p.ID,
336
                            IsUpdate = false,
337
                            MarkupInfoID = d.MarkupInfoID,
338
                            PageNumber = p.PageNumber,
339
                            Symbol_ID = p.Symbol_ID,
340
                            //Group_ID = p.Group_ID
341
                        };
342
                        ViewerDataModel.Instance.MyMarkupList.Add(markup);
343
                    }
344
                    else
345
                    {
346
                        MarkupItemEx markup = new MarkupItemEx
347
                        {
348
                            Data = p.Data,
349
                            Data_Type = p.Data_Type,
350
                            ID = p.ID,
351
                            IsUpdate = false,
352
                            MarkupInfoID = d.MarkupInfoID,
353
                            PageNumber = p.PageNumber,
354
                            Symbol_ID = p.Symbol_ID,
355
                            //Group_ID = p.Group_ID
356
                        };
357
                        ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
358
                    }
359
                }));
360

    
361
                var currentUser = e.Result.Where(data => data.UserID == App.ViewInfo.UserID && data.AvoidConsolidate == 0).FirstOrDefault();
362
                if (currentUser == null)
363
                {
364
                    /// create a new markupinfo to do comments
365
                    var infoId = Commons.shortGuid();
366
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
367
                    {
368
                        CreateTime = DateTime.Now,
369
                        UpdateTime = DateTime.Now,
370
                        Depatment = userData.DEPARTMENT,
371
                        DisplayColor = "#FFFF0000",
372
                        UserID = userData.ID,
373
                        UserName = userData.NAME,
374
                        PageCount = 1,
375
                        Description = "",
376
                        MarkupInfoID = infoId,
377
                        MarkupList = null,
378
                        MarkupVersionID = Commons.shortGuid(),
379
                        Consolidate = 0,
380
                        PartConsolidate = 0,
381
                        userDelete = true,
382
                        AvoidConsolidate = 0,
383
                        IsPreviewUser = false
384
                    };
385

    
386
                    App.Custom_ViewInfoId = infoId;
387

    
388
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
389
                }
390
                else
391
                {
392
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
393
                }
394

    
395
                foreach(var info in e.Result)
396
                {
397
                    if (info.UserID == App.ViewInfo.UserID) info.DisplayColor = "#FFFF0000";
398
                }
399

    
400
                ViewerDataModel.Instance.PageNumber = 1;
401

    
402
                /// Consolidation 된 데이터가 최상단에 올 수 있도록 변경
403
                var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList();
404
                markupItem.ForEach(data =>
405
                {
406
                    if (data.Depatment == null) data.Depatment = "Unknown";
407
                });
408
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
409
                SetCommentPages();
410

    
411
                var SelectedItem = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.UpdateTime).FirstOrDefault();
412
                this.gridViewMarkup.SelectedItem = (PreviewUserMarkupInfoItem != null) ? PreviewUserMarkupInfoItem : SelectedItem;
413
                
414
                /// create a group descriptor
415
                gridViewMarkup.GroupDescriptors.Clear();
416
                GroupDescriptor descriptor = new GroupDescriptor();
417
                descriptor.Member = "Depatment";
418
                descriptor.DisplayContent = "DEPT";
419
                //descriptor.SortDirection = ListSortDirection.Ascending;
420
                gridViewMarkup.GroupDescriptors.Add(descriptor);
421
                /// up to here
422
            }
423
        }
424

    
425
        private void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
426
        {
427
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
428
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
429
            //{
430
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
431
            //}
432

    
433
            if (ViewerDataModel.Instance.PageNumber == 0)
434
            {
435
                ViewerDataModel.Instance.PageNumber = 1;
436
            }
437
            if (e.AddedItems.Count() > 0)
438
            {
439
                foreach (var item in gridSelectionItem)
440
                {
441
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
442
                    //{
443
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
444
                    //});
445
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
446
                    {
447
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
448
                    });
449
                }
450
            }
451
            else if (e.RemovedItems.Count > 0)
452
            {
453
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
454

    
455
                (from A in _infoItem
456
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
457
                 where A.MarkupInfoID == B.MarkupInfoID
458
                 select B).ToList().ForEach(data =>
459
                 {
460
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
461
                 });
462
            }
463
        }
464

    
465
        /// <summary>
466
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
467
        /// </summary>
468
        /// <param name="sender"></param>
469
        /// <param name="e"></param>
470
        private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
471
        {
472
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
473

    
474
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
475
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
476
            var resultA = (from item_Select in dataSet
477
                           from item_Non in dataSet_User
478
                           where item_Select == item_Non
479
                           select item_Non).ToList();
480

    
481
            if (resultA.Count() >= 2)
482
            {
483
                RadWindow.Confirm(new DialogParameters
484
                {
485
                    Owner = Application.Current.MainWindow,
486
                    Header = "안내",
487
                    Content = "동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?",
488
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
489
                    {
490
                        if (e.AddedItems.Count() == 1)
491
                        {
492
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
493
                            gridViewMarkup.SelectedItem = null;
494

    
495
                        
496
                            if (ea.DialogResult.Value)
497
                            {
498
                                if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
499
                                {
500
                                    gridViewMarkup.SelectedItem = instanceItem;
501
                                }
502
                                else
503
                                {
504
                                    //1. Consolidations이 있다면 하나 선택
505
                                    var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
506

    
507
                                    if (Consolidations.Count() > 0)
508
                                    {
509
                                        gridViewMarkup.SelectedItem = Consolidations.First();
510
                                    }
511
                                }
512
                              
513
                            }
514
                            else {
515
                                //1. Consolidations 아닌게 있다면 Change
516
                                var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
517

    
518
                                if(notConsolidations.Count() > 0) {
519
                                    gridViewMarkup.SelectedItem = notConsolidations.First();
520
                                }
521
                                else {//1. Consolidations 아닌게 없다면 그대로
522
                                    gridViewMarkup.SelectedItem = instanceItem;
523
                                }
524
                                
525
                            }
526
                        }
527
                    }),
528
                    Theme = new Windows8Theme(),
529
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
530
                });
531
            }
532
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
533
            {
534
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
535
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
536
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
537
                #region 코멘트 보기
538
                if (e.AddedItems.Count() > 0)
539
                {
540
                    foreach (var item in gridSelectionItem)
541
                    {
542
                        if (item.UserID == App.ViewInfo.UserID)
543
                        {
544
                            var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
545
                            if (controls.Count == 0)
546
                            {
547
                                var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
548
                                foreach (var markup in instance)
549
                                {
550
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
551
                                        item.MarkupInfoID, markup.ID);
552
                                }
553
                            }
554

    
555
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
556
                            foreach (var control in controls)
557
                            {
558
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
559
                                control.Visibility = Visibility.Visible;
560
                            }
561
                        }
562
                        else
563
                        {
564
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
565
                            if (controls.Count == 0)
566
                            {
567
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
568
                                foreach (var markup in instance)
569
                                {
570
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "",
571
                                        item.MarkupInfoID, markup.ID);
572
                                }
573
                            }
574

    
575
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
576
                            foreach (var control in controls)
577
                            {
578
                                control.Visibility = Visibility.Visible;
579
                            }
580
                        }
581
                    }
582
                }
583
                #endregion
584
                #region 코멘트 숨기기
585
                else if (e.RemovedItems.Count > 0)
586
                {
587
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
588

    
589
                    (from A in _infoItem
590
                     from B in Common.ViewerDataModel.Instance.MarkupControls
591
                     where A.MarkupInfoID == B.MarkupInfoID
592
                     select B).ToList().ForEach(data =>
593
                     {
594
                         data.Visibility = Visibility.Hidden;                         
595
                     });
596

    
597

    
598
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
599
                    if (myComment != null)
600
                    {
601
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
602
                        {
603
                            markupitem.Visibility = Visibility.Hidden;
604
                        });
605
                    }
606
                }
607
                #endregion
608
            }
609
        }
610

    
611
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
612
        {
613
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
614

    
615
            if (e.Result != null)
616
            {
617
                _DocItem = e.Result;
618

    
619
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
620
                {
621
                    //장원
622
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
623
                }
624
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
625
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
626
            }
627
            else
628
            {
629
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
630
                {
631
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
632

    
633
                    if (ea.Error == null)
634
                    {
635
                        if (ea.Result)
636
                        {
637
                            this._ViewInfo.isAdmin = true;
638
                            Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
639
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
640
                        }
641
                        else
642
                        {
643
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
644
                            DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
645
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
646
                        }
647

    
648
                    }
649
                    else
650
                    {
651
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
652
                    }
653
                };
654
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
655
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
656
            }
657
        }
658

    
659
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
660
        {
661
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
662

    
663
            if (e.Error == null && e.Result != null)
664
            {
665
                App.SystemInfo = e.Result;
666

    
667
                //App.urlPort_DB = App.SystemInfo.HostPort;
668
                //App.urlHost_DB = App.SystemInfo.HostName;
669
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
670
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
671

    
672
                //if (App.urlHost.Contains("localhost"))
673
                //{
674
                //    App.urlHost = App.urlHost_DB;
675
                //}
676
            }
677
        }
678

    
679
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
680
        {
681
            
682
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
683
            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잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
684
            if (e.Error == null && e.Result == true)
685
            {
686
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
687

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

    
690
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
691
                {
692
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
693
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
694
                    if (userData != null)
695
                    {
696
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
697
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
698
                    }
699
                    else
700
                    {
701
                        userData = new MEMBER();
702
                        userData.DEPARTMENT = "ALL";
703
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
704
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
705
                    }
706
                }
707
            }
708
            else
709
            {
710
                
711
                DialogMessage_Alert(failedmsg, "Warning");
712
            }
713
        }
714

    
715
        public void SetView(ViewInfo info)
716
        { 
717
            this._ViewInfo = info;
718
            try
719
            {
720
                /// 대림의 경우 EnsembleID를 가지고 DocumentItemID를 구함
721
                /// 다른 Site를 대비하여 에러 처리함
722
                string docid = BaseClient.GetDocItemID(info.EnsembleID);
723
                if (!string.IsNullOrEmpty(docid))
724
                {
725
                    this._ViewInfo.DocumentItemID = docid;
726
                }
727
            }
728
            catch(Exception ex)
729
            {
730
                App.FileLogger.Fatal(ex);
731
            }
732

    
733
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
734
            BaseClient.GetSystemDataAsync();
735
        }
736

    
737
        public void HubSet()
738
        {
739
            // 허브 연결 구성
740
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
741
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
742

    
743

    
744
            // 허브 연결 
745
            hubConnection.Start().ContinueWith(task =>
746
            {
747
                if (task.IsFaulted)
748
                {
749
                    Console.WriteLine("There was an error opening the connection:{0}",
750
                                      task.Exception.GetBaseException());
751
                    //throw task.Exception.GetBaseException();
752
                }
753
                else
754
                {
755
                    Console.WriteLine("Connected :: " + task.Id);
756
                }
757

    
758
            }).Wait();
759

    
760

    
761
            // [ 프로그램 시작 ]
762
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
763
            //( "method name", arg1, arg2 )
764
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
765
            //{
766
            //    if (task.IsFaulted)
767
            //    {
768
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
769
            //    }
770
            //    else
771
            //    {
772
            //        Console.WriteLine(task.Result);
773
            //    }
774
            //});
775
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID,App.ViewInfo.ProjectNO).ContinueWith(task =>
776
            {
777
                if (task.IsFaulted)
778
                {
779
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
780
                    //throw task.Exception.GetBaseException();
781
                }
782
                else
783
                {
784
                    switch (task.Result)
785
                    {
786
                        case "2":
787
                            {
788
                                var result = MessageBox.Show("권한이 없습니다.");
789
                                if (result == MessageBoxResult.OK)
790
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
791
                            }
792
                            break;
793
                        case "404":
794
                            {
795
                                var result = MessageBox.Show("등록된 사용자가 아닙니다.");
796
                                if(result == MessageBoxResult.OK)
797
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
798
                            }
799
                            break;
800
                    }
801
                }
802
            });
803

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

    
808
            //    if (status)
809
            //    {
810
            //        // 프로그램 시작 
811
            //        Console.WriteLine("connection status : " + status);
812
            //    }
813
            //    else
814
            //    {
815
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
816
            //        hubConnection.Stop();
817
            //    }
818
            //});
819

    
820
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
821
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
822
                Console.WriteLine("Noficiation Message : " + msg)
823
            );
824

    
825

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

    
829
            //Console.ReadKey();
830

    
831
            //hubConnection.Stop();
832
        }
833

    
834
        public void MarkupUserListDisplay()
835
        {
836
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
837
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
838
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
839
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
840
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
841
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
842
            //foreach (var item in gridSelectionItem)
843
            //{
844
            //    if (item.UserID == App.ViewInfo.UserID)
845
            //    {
846
            //        ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
847
            //        {
848
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
849
            //        });
850
            //    }
851
            //    else
852
            //    {
853
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
854
            //        {
855
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
856
            //        });
857
            //    }
858
            //}
859
                (from A in gridSelectionItem
860
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
861
                 where A.MarkupInfoID == B.MarkupInfoID
862
                 select B).ToList().ForEach(data =>
863
                 {
864
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
865
                 });
866
            (from A in gridSelectionItem
867
             from B in Common.ViewerDataModel.Instance.MarkupControls
868
             where A.MarkupInfoID == B.MarkupInfoID
869
             select B).ToList().ForEach(data =>
870
             {
871
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
872
             });
873

    
874
            foreach (var item in gridSelectionItem)
875
            {
876
                if (item.UserID == App.ViewInfo.UserID)
877
                {
878
                    ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
879
                    {
880
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
881
                            item.MarkupInfoID, markupitem.ID);
882
                    });
883
                }
884
                else
885
                {
886
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
887
                    {
888
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
889
                    });
890
                }
891
            }
892
        }
893
    }
894
}
클립보드 이미지 추가 (최대 크기: 500 MB)