프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 101da246

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

1 787a4489 KangIngu
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 036650a0 humkyung
using MarkupToPDF.Controls.Parsing;
19 787a4489 KangIngu
20
namespace KCOM.Views
21
{
22
    public partial class MainMenu : UserControl, INotifyPropertyChanged
23 29010418 ljiyeon
    {
24 787a4489 KangIngu
        const string DeepZoomUrl = @"http://{baseUrl}/TileSource/{TileSourcePath}/{ItemsPath}/{SharepointItemID}/{PageNo}.jpg";
25
        public ServiceDeepViewClient BaseClient;
26
        public ViewInfo _ViewInfo;
27
        public DOCINFO _DocInfo;
28
        public DOCUMENT_ITEM _DocItem;
29
        public MEMBER userData;
30
31
        public event PropertyChangedEventHandler PropertyChanged;
32
        private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
33
        {
34
            if (PropertyChanged != null)
35
            {
36
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
37
            }
38
        }
39
40
        private Common.DocumentSet _CurrentDoc { get; set; }
41
        public Common.DocumentSet CurrentDoc
42
        {
43
            get
44
            {
45
                return _CurrentDoc;
46
            }
47
            set
48
            {
49
                if (value != CurrentDoc)
50
                {
51
                    _CurrentDoc = value;
52
                    NotifyPropertyChanged();
53
                }
54
            }
55
        }
56
        public void ServiceOn()
57
        {
58 29010418 ljiyeon
            BaseClient = new ServiceDeepViewClient(App._binding, App._EndPoint);
59
60 787a4489 KangIngu
            BaseClient.GetDocInfoCompleted += BaseClient_GetDocInfoCompleted; //문서 섬네일, 페이지크기, 마크업 정보 [3]
61 0f065e57 ljiyeon
            BaseClient.GetConversionStateCompleted += BaseClient_GetConversionStateCompleted;  //컨버팅의 여부 [2] 
62
            BaseClient.GetSystemDataCompleted += BaseClient_GetSystemDataCompleted; //시스템 정보 [1] 
63 787a4489 KangIngu
            BaseClient.GetDocumentItemInfoCompleted += BaseClient_GetDocumentItemInfoCompleted; // 문서 자체의 정보 [4]
64 29010418 ljiyeon
            BaseClient.GetMarkupInfoItemsCompleted += BaseClient_GetMarkupInfoItemsCompleted;
65
            BaseClient.GetDeptDataCompleted += BaseClient_GetDeptDataCompleted;
66
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted;
67 787a4489 KangIngu
            BaseClient.GetVPRevisionHistoryCompleted += BaseClient_GetVPRevisionHistoryCompleted;
68 29010418 ljiyeon
            BaseClient.SetFinalPDFCompleted += BaseClient_SetFinalPDFCompleted;
69
            BaseClient.GetCompareRectCompleted += BaseClient_GetCompareRectCompleted;
70
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted;
71
            BaseClient.DelFavoriteVPCompleted += BaseClient_DelFavoriteVPCompleted;
72
            BaseClient.EditFavoriteVPCompleted += BaseClient_EditFavoriteVPCompleted;
73 992a98b4 KangIngu
        }
74
75 29010418 ljiyeon
76 992a98b4 KangIngu
77
        private void BaseClient_EditFavoriteVPCompleted(object sender, EditFavoriteVPCompletedEventArgs e)
78
        {
79 0f065e57 ljiyeon
            Logger.sendResLog("EditFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
80
            
81 53880c83 ljiyeon
            if (e.Error == null && e.Result != false)
82 992a98b4 KangIngu
            {
83 0f065e57 ljiyeon
                Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1);
84 992a98b4 KangIngu
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
85
            }
86
            else
87
            {
88
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
89
            }
90
        }
91
92
        private void BaseClient_DelFavoriteVPCompleted(object sender, DelFavoriteVPCompletedEventArgs e)
93
        {
94 0f065e57 ljiyeon
            Logger.sendResLog("DelFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
95
96 53880c83 ljiyeon
            if (e.Error == null && e.Result != false)
97 992a98b4 KangIngu
            {
98 0f065e57 ljiyeon
                Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1);
99 992a98b4 KangIngu
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
100
            }
101
            else
102
            {
103
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
104
            }
105 787a4489 KangIngu
        }
106
107 992a98b4 KangIngu
108 787a4489 KangIngu
        private void BaseClient_GetCompareRectCompleted(object sender, GetCompareRectCompletedEventArgs e)
109
        {
110 0f065e57 ljiyeon
            Logger.sendResLog("GetCompareRectCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
111
112 787a4489 KangIngu
            if (e.Error != null || e.Result == null)
113
            {
114
                DialogMessage_Alert("Compare 기능을 원활히 실행하기 위한 데이터가 부족합니다", "안내");
115
            }
116
            else
117
            {
118
                e.Result.ForEach(d =>
119
                {
120
                    d.Width = d.Width * 3;
121
                    d.Height = d.Height * 3;
122
                    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
123
                    System.Windows.Shapes.Ellipse myEllipse = new System.Windows.Shapes.Ellipse();
124
                    myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
125
                    myEllipse.Opacity = 1;
126
                    myEllipse.Width = d.Width;
127
                    myEllipse.Height = d.Height;
128
                    Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
129
                    Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
130
                    myEllipse.RenderTransformOrigin = point;
131
                    canvas_compareBorder.Children.Add(myEllipse);
132
                });
133
134
                da.From = 0.8;
135
                da.To = 0;
136
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
137
                da.AutoReverse = true;
138
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
139
            }
140
        }
141
142
        private void BaseClient_SetFinalPDFCompleted(object sender, SetFinalPDFCompletedEventArgs e)
143
        {
144 0f065e57 ljiyeon
            Logger.sendResLog("SetFinalPDFCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
145 787a4489 KangIngu
146 29010418 ljiyeon
            if (e.Error != null || e.Result.Status == FinalStatus.Error)
147 787a4489 KangIngu
            {
148
                DialogMessage_Alert("최종 파일을 만드는데 문제가 발생하였습니다", "안내");
149
            }
150
            else
151
            {
152 992a98b4 KangIngu
                DialogMessage_Alert("최종 파일 생성 중입니다. 문서관리시스템을 확인해주세요", "안내");
153 787a4489 KangIngu
            }
154
        }
155
156
        private void BaseClient_GetVPRevisionHistoryCompleted(object sender, GetVPRevisionHistoryCompletedEventArgs e)
157
        {
158 0f065e57 ljiyeon
            Logger.sendResLog("GetVPRevisionHistoryCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
159
160 787a4489 KangIngu
            if (e.Result != null && e.Error == null)
161
            {
162
                gridViewHistory.ItemsSource = e.Result;
163
            }
164 6707a5c7 ljiyeon
            ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
165 787a4489 KangIngu
        }
166
167
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
168
        {
169 0f065e57 ljiyeon
            Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
170
171 787a4489 KangIngu
            SetDisplayColor(ViewerDataModel.Instance._markupInfoList.ToList(), App.ViewInfo.UserID);
172
        }
173
174
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
175
        {
176 0f065e57 ljiyeon
            Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
177
178 787a4489 KangIngu
            if (e.Result != null)
179
            {
180
                e.Result.Sort();
181
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
182
            }
183
        }
184 29010418 ljiyeon
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
185 787a4489 KangIngu
186
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
187
        {
188 0f065e57 ljiyeon
            Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
189
190 787a4489 KangIngu
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
191
            ViewerDataModel.Instance.MarkupControls.Clear();
192
            if (e.Result != null)
193
            {
194
                var pureItem = e.Result;
195 29010418 ljiyeon
                if (pureItem.Count > 0)
196 787a4489 KangIngu
                {
197
                    ViewerDataModel.Instance.MarkupList_USER.Clear();
198
                }
199
200
                pureItem.ToList().ForEach(d => d.MarkupList.ForEach(p =>
201
                {
202 29010418 ljiyeon
                    if (d.UserID == App.ViewInfo.UserID)
203 787a4489 KangIngu
                    {
204
                        d.userDelete = true;
205
                        d.DisplayColor = "#FFFF0000";
206
207
                        ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
208
                        {
209
                            Data = p.Data,
210
                            Data_Type = p.Data_Type,
211
                            ID = p.ID,
212
                            IsUpdate = false,
213
                            MarkupInfoID = d.MarkupInfoID,
214
                            PageNumber = p.PageNumber,
215 c8e9b3e4 ljiyeon
                            Symbol_ID = p.Symbol_ID,
216 53880c83 ljiyeon
                            Group_ID = p.Group_ID
217 787a4489 KangIngu
                        });
218
                    }
219
                    else
220
                    {
221
                        ViewerDataModel.Instance.MarkupList_Pre.Add(new MarkupItemEx
222
                        {
223
                            Data = p.Data,
224
                            Data_Type = p.Data_Type,
225
                            ID = p.ID,
226
                            IsUpdate = false,
227
                            MarkupInfoID = d.MarkupInfoID,
228
                            PageNumber = p.PageNumber,
229 c8e9b3e4 ljiyeon
                            Symbol_ID = p.Symbol_ID,
230 53880c83 ljiyeon
                            Group_ID = p.Group_ID
231 787a4489 KangIngu
                        });
232
                    }
233
                    //if (p.ID ==App.ViewInfo.UserID)
234
                    //{
235
                    //    d.userDelete = true;
236
                    //    d.DisplayColor = "#FFFF0000";
237
                    //}
238
                }));
239
240
                var currentUser = e.Result.Where(data => data.UserID == userData.ID).FirstOrDefault();
241
                //var currentUser = e.Result.Where(data => data.UserID == "H2014410").FirstOrDefault();
242
                if (currentUser == null)
243
                {
244
                    var infoId = Events.Save.shortGuid();
245
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
246
                    {
247
                        CreateTime = DateTime.Now,
248
                        Depatment = userData.DEPARTMENT,
249
                        DisplayColor = "#FFFF0000",
250
                        UserID = userData.ID,
251
                        UserName = userData.NAME,
252
                        PageCount = 1,
253
                        Description = "",
254
                        MarkupInfoID = infoId,
255
                        MarkupList = null,
256
                        MarkupVersionID = Events.Save.shortGuid(),
257
                        Consolidate = 0,
258
                        PartConsolidate = 0,
259
                        userDelete = true,
260
                        AvoidConsolidate = 0,
261
                        IsPreviewUser = true
262
                    };
263
264
                    App.Custom_ViewInfoId = infoId;
265
                    //pureItem.Insert(0,PreviewUserMarkupInfoItem);
266
                }
267
                else
268
                {
269
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
270
                }
271
272
                //pureItem.ForEach(d => d.MarkupList = null);
273
                //ViewerDataModel.Instance._markupInfoList = new ObservableCollection<MarkupInfoItem>(pureItem);
274
                ViewerDataModel.Instance._markupInfoList = SetDisplayColor(pureItem, _ViewInfo.UserID);
275
                //ViewerDataModel.Instance._markupInfoList = SetDisplayColor(e.Result, _ViewInfo.UserID);
276
277
278
279
                //if (e.Result.Where(data => data.UserID == userData.ID).FirstOrDefault() == null)
280
                //{
281
282
                //    PreviewUserMarkupInfoItem = new MarkupInfoItem
283
                //    {
284
                //        CreateTime = DateTime.Now,
285
                //        Depatment = userData.DEPARTMENT,
286
                //        DisplayColor = "#FFFF0000",
287
                //        UserID = userData.ID,
288
                //        UserName = userData.NAME + "(임시저장)",
289
                //        PageCount = 1,
290
                //        Description = "",
291
                //        MarkupInfoID = Events.Save.shortGuid(),
292
                //        MarkupList = null,
293
                //        MarkupVersionID = Events.Save.shortGuid(),
294
                //        Consolidate = 0,
295
                //        PartConsolidate = 0,
296
                //        userDelete = true,
297
                //        AvoidConsolidate = 0,
298
                //        IsPreviewUser = true
299
                //    };
300
                //    ViewerDataModel.Instance._markupInfoList.Add(PreviewUserMarkupInfoItem);
301
                //}
302
303
304
305
                var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList(); //Consolidation 된 데이터가 최상단에 올 수 있도록 변경
306
307
                markupItem.ForEach(data =>
308
                {
309
                    if (data.Depatment == null)
310
                    {
311
                        data.Depatment = "Unknown";
312
                        //BaseClient.NoticeAccountErrorAsync(_ViewInfo.ProjectNO, data.UserID);
313
                    }
314
                });
315
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
316 29010418 ljiyeon
                SetCommentPages();
317 992a98b4 KangIngu
318
                var select_item = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.Consolidate == Convert.ToInt32(true)).FirstOrDefault();
319
                this.gridViewMarkup.SelectedItem = select_item;
320 787a4489 KangIngu
            }
321
        }
322
323
        private void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
324
        {
325
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
326
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
327
            //{
328
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
329
            //}
330
331
            if (ViewerDataModel.Instance.PageNumber == 0)
332
            {
333
                ViewerDataModel.Instance.PageNumber = 1;
334
            }
335
            if (e.AddedItems.Count() > 0)
336
            {
337
                foreach (var item in gridSelectionItem)
338
                {
339
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
340
                    //{
341
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
342
                    //});
343
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
344
                    {
345 661b7416 humkyung
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
346 787a4489 KangIngu
                    });
347
                }
348
            }
349
            else if (e.RemovedItems.Count > 0)
350
            {
351
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
352
353
                (from A in _infoItem
354
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
355
                 where A.MarkupInfoID == B.MarkupInfoID
356
                 select B).ToList().ForEach(data =>
357
                 {
358
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
359
                 });
360
            }
361
        }
362 e7dd7ae8 humkyung
363
        /// <summary>
364
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
365
        /// </summary>
366
        /// <param name="sender"></param>
367
        /// <param name="e"></param>
368 787a4489 KangIngu
        private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
369
        {
370
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
371
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
372
            var resultA = (from item_Select in dataSet
373
                           from item_Non in dataSet_User
374
                           where item_Select == item_Non
375
                           select item_Non).ToList();
376
377
            if (resultA.Count() >= 2)
378
            {
379
                RadWindow.Confirm(new DialogParameters
380
                {
381 b9b01f8e ljiyeon
                    Owner = Application.Current.MainWindow,
382 787a4489 KangIngu
                    Header = "안내",
383
                    Content = "동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?",
384
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
385
                    {
386
                        if (e.AddedItems.Count() == 1)
387
                        {
388
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
389
                            var result = instanceItem.Consolidate;
390
391
                            //dataSet.Where(data => data.UserID == "H2011357").ToList().ForEach(data => lstbox.SelectedItems.Remove(data));
392
                            if (ea.DialogResult.Value)
393
                            {
394
                                ConsolidationMethod();
395
                            }
396
                            else
397
                            {
398
                                ((RadGridView)sender).SelectedItem = null;
399
                            }
400
                        }
401
                    }),
402
                    Theme = new Windows8Theme(),
403
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
404
                });
405
            }
406
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
407
            {
408 6b5d33c6 djkim
                EmptyControlCheck();
409
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
410
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
411
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
412
                #region 코멘트 보기
413
                if (e.AddedItems.Count() > 0)
414
                {
415
                    foreach (var item in gridSelectionItem)
416
                    {
417
                        if ((item.UserID == App.ViewInfo.UserID) && (this.pageNavigator.CurrentPage != null))
418
                        {
419 101da246 humkyung
                            var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
420
                            if (controls.Count == 0)
421 6b5d33c6 djkim
                            {
422 101da246 humkyung
                                var instance = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
423 6b5d33c6 djkim
                                foreach (var markup in instance)
424
                                {
425 661b7416 humkyung
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
426
                                        item.MarkupInfoID, markup.ID);
427 6b5d33c6 djkim
                                }
428
                            }
429 101da246 humkyung
430
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
431
                            foreach (var control in controls)
432 6b5d33c6 djkim
                            {
433 101da246 humkyung
                                control.Visibility = Visibility.Visible;
434 6b5d33c6 djkim
                            }
435
                        }
436
                        else if (this.pageNavigator.CurrentPage != null)
437
                        {
438 101da246 humkyung
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
439
                            if (controls.Count == 0)
440
                            {
441
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
442
                                foreach (var markup in instance)
443
                                {
444
                                    MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "",
445
                                        item.MarkupInfoID, markup.ID);
446
                                }
447
                            }
448
449
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
450
                            foreach (var control in controls)
451 6b5d33c6 djkim
                            {
452 e7dd7ae8 humkyung
                                control.Visibility = Visibility.Visible;
453 6b5d33c6 djkim
                            }
454
                        }
455
                    }
456
                }
457
                #endregion
458
                #region 코멘트 숨기기
459
                else if (e.RemovedItems.Count > 0)
460
                {
461
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
462
463
                    (from A in _infoItem
464
                     from B in Common.ViewerDataModel.Instance.MarkupControls
465
                     where A.MarkupInfoID == B.MarkupInfoID
466
                     select B).ToList().ForEach(data =>
467
                     {
468 e7dd7ae8 humkyung
                         data.Visibility = Visibility.Hidden;
469 6b5d33c6 djkim
                     });
470
471
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
472
                    if (myComment != null)
473
                    {
474
                        ChangeCommentReact();
475
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
476
                        {
477 e7dd7ae8 humkyung
                            markupitem.Visibility = Visibility.Hidden;
478 6b5d33c6 djkim
                        });
479
                    }
480
                }
481
                #endregion
482 787a4489 KangIngu
            }
483
        }
484
485
        private static ObservableCollection<MarkupInfoItem> SetDisplayColor(List<MarkupInfoItem> MarkupInfoList, string userID)
486
        {
487
            //var random = new Random();
488
            ObservableCollection<MarkupInfoItem> _result = new ObservableCollection<MarkupInfoItem>();
489
490
            MarkupInfoList.ForEach(delegate (MarkupInfoItem infoitem)
491
            {
492
                if (userID == infoitem.UserID)
493
                {
494
                    infoitem.userDelete = true;
495
                    infoitem.DisplayColor = "#FFFF0000";
496
                }
497
                else
498
                {
499
                    infoitem.userDelete = false;
500
501
                    #region sample code
502
503
                    //string _ColorStr = "#FF";
504
505
                    //for (int i = 0; i < infoitem.Depatment.Count(); i++)
506
                    //{
507
                    //    _ColorStr += Convert.ToByte(infoitem.Depatment[i]);
508
                    //}
509
510
                    //if (_ColorStr.Length < 9)
511
                    //{
512
                    //    for (int i = 0; i < 9 - _ColorStr.Length; i++)
513
                    //    {
514
                    //        _ColorStr += "F";
515
                    //    }
516
                    //}
517
                    //else
518
                    //{
519
                    //    _ColorStr = _ColorStr.Substring(0,9);
520
                    //}
521
                    //System.Diagnostics.Debug.WriteLine(_ColorStr);
522
                    //infoitem.DisplayColor = _ColorStr;// String.Format("#FF{0:X6}", random.Next(0x1000000)); 
523
                    #endregion
524
                }
525
526
                _result.Add(infoitem);
527
            });
528
529
            return _result;
530
        }
531
532
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
533
        {
534 0f065e57 ljiyeon
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
535
536 787a4489 KangIngu
            if (e.Result != null)
537
            {
538
                _DocItem = e.Result;
539
540
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
541
                {
542
                    //장원
543
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
544
                }
545 29010418 ljiyeon
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
546 787a4489 KangIngu
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
547
            }
548
            else
549
            {
550
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
551
                {
552 0f065e57 ljiyeon
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
553
554 787a4489 KangIngu
                    if (ea.Error == null)
555
                    {
556
                        if (ea.Result)
557
                        {
558
                            this._ViewInfo.isAdmin = true;
559 0f065e57 ljiyeon
                            Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
560 787a4489 KangIngu
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
561
                        }
562
                        else
563
                        {
564
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
565
                            DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
566
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
567
                        }
568
569
                    }
570
                    else
571
                    {
572
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
573
                    }
574
                };
575 0f065e57 ljiyeon
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
576 787a4489 KangIngu
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
577
            }
578
        }
579
580
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
581
        {
582 0f065e57 ljiyeon
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
583
584 787a4489 KangIngu
            if (e.Error == null && e.Result != null)
585
            {
586
                App.SystemInfo = e.Result;
587
588
                //App.urlPort_DB = App.SystemInfo.HostPort;
589
                //App.urlHost_DB = App.SystemInfo.HostName;
590 0f065e57 ljiyeon
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
591 787a4489 KangIngu
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
592
593
                //if (App.urlHost.Contains("localhost"))
594
                //{
595
                //    App.urlHost = App.urlHost_DB;
596
                //}
597
            }
598
        }
599
600
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
601
        {
602 0f065e57 ljiyeon
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
603
604 53880c83 ljiyeon
            if (e.Error == null && e.Result == true)
605 787a4489 KangIngu
            {
606 0f065e57 ljiyeon
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
607
608 787a4489 KangIngu
                BaseClient.GetDocumentItemInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID, userID = _ViewInfo.UserID });
609
610 992a98b4 KangIngu
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
611 787a4489 KangIngu
                {
612 0f065e57 ljiyeon
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
613 6c781c0c djkim
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
614
                    if (userData != null)
615 787a4489 KangIngu
                    {
616 0f065e57 ljiyeon
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
617 6c781c0c djkim
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
618 787a4489 KangIngu
                    }
619 6c781c0c djkim
                    else
620
                    {
621
                        userData = new MEMBER();
622
                        userData.DEPARTMENT = "ALL";
623 0f065e57 ljiyeon
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
624 6c781c0c djkim
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
625 29010418 ljiyeon
                    }
626 787a4489 KangIngu
                }
627
            }
628
            else
629
            {
630
                DialogMessage_Alert("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!"
631
                                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
632
                //System.Windows.Forms.MessageBox.Show("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!"
633
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
634
                //this.ParentOfType<MainPage>().DialogMessage_Alert("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!"
635
                //                                                   + "\n\n" + "현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다." + "\n" + "잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다", "Warning");
636
                //System.Windows.Browser.HtmlPage.Window.Invoke("close");
637
            }
638
        }
639 29010418 ljiyeon
640 e7dd7ae8 humkyung
        /// <summary>
641
        /// 문서 정보를 가져온다
642
        /// </summary>
643
        /// <param name="sender"></param>
644
        /// <param name="e"></param>
645 787a4489 KangIngu
        private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
646
        {
647 0f065e57 ljiyeon
            Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
648
649 787a4489 KangIngu
            if (e.Error != null)
650
            {
651
                DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert");
652
                return;
653
            }
654 29010418 ljiyeon
655 787a4489 KangIngu
            var MainUrl = DeepZoomUrl.Replace("{baseUrl}", App.SystemInfo.HostName);
656
            MainUrl = MainUrl.Replace("{TileSourcePath}", _ViewInfo.ProjectNO + "_Tile");
657
            MainUrl = MainUrl.Replace("{ItemsPath}", (Convert.ToInt64(_ViewInfo.DocumentItemID) / 100).ToString());
658
            MainUrl = MainUrl.Replace("{SharepointItemID}", _ViewInfo.DocumentItemID);
659
            MainUrl = MainUrl.Replace(@"http://http://", @"http://");
660
661
            _DocInfo = e.Result;
662 f38fed51 KangIngu
            foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
663 787a4489 KangIngu
            {
664
                ViewerDataModel.Instance.Document_Info.Add(item);
665
            }
666 0f065e57 ljiyeon
            Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
667 787a4489 KangIngu
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
668
            CurrentDoc = new Common.DocumentSet
669
            {
670
                docInfo = _DocInfo,
671
                Document_Id = _DocInfo.DOCUMENT_ID,
672
                Document_NO = _DocItem.DOCUMENT_NO,
673
                File_Original = _DocInfo.ORIGINAL_FILE,
674
                File_Result = _DocItem.RESULT_FILE,
675
                Group_No = _DocItem.GROUP_NO,
676
                ProjectNo = _DocItem.PROJECT_NO,
677
                Revision = _DocItem.REVISION,
678
            };
679
            var instanceMain = this.ParentOfType<MainWindow>();
680
            instanceMain.dzTopMenu.tlcurrentPage.Text = _DocInfo.PAGE_COUNT.ToString();
681 992a98b4 KangIngu
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = _DocInfo.PAGE_COUNT.ToString();
682 4590804a djkim
            string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
683 d2cd1e16 djkim
            instanceMain.TitleText.Text = apptitle;
684
            instanceMain.Title = apptitle;
685 787a4489 KangIngu
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
686
687
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
688 6707a5c7 ljiyeon
689
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
690
691 0f065e57 ljiyeon
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
692 29010418 ljiyeon
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
693 787a4489 KangIngu
        }
694
695
696
        public void SetView(ViewInfo info)
697
        {
698
            this._ViewInfo = info;
699
            if (!(App.ViewInfo.ProjectNO == "000000" || App.ViewInfo.ProjectNO == "000001"))
700
            {
701
                ViewerDataModel.Instance.SystemMain.dzTopMenu.btnTopStamp.Visibility = Visibility.Collapsed;
702
            }
703 0f065e57 ljiyeon
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
704 29010418 ljiyeon
            BaseClient.GetSystemDataAsync();
705 787a4489 KangIngu
        }
706
707 992a98b4 KangIngu
        public void HubSet()
708
        {
709
710
            // 허브 연결 구성
711 9a1ce1db KangIngu
            var hubConnection = new HubConnection(global::KCOM.Properties.Settings.Default.HubAddress);
712 992a98b4 KangIngu
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
713
714
715
            // 허브 연결 
716
            hubConnection.Start().ContinueWith(task =>
717
            {
718
                if (task.IsFaulted)
719
                {
720
                    Console.WriteLine("There was an error opening the connection:{0}",
721
                                      task.Exception.GetBaseException());
722
                }
723
                else
724
                {
725
                    Console.WriteLine("Connected :: " + task.Id);
726
                }
727
728
            }).Wait();
729
730
731
            // [ 프로그램 시작 ]
732
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
733
            //( "method name", arg1, arg2 )
734
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
735
            //{
736
            //    if (task.IsFaulted)
737
            //    {
738
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
739
            //    }
740
            //    else
741
            //    {
742
            //        Console.WriteLine(task.Result);
743
            //    }
744
            //});
745
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID).ContinueWith(task =>
746
            {
747
                if (task.IsFaulted)
748
                {
749
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
750
                }
751
                else
752
                {
753 29010418 ljiyeon
                    switch (task.Result)
754 992a98b4 KangIngu
                    {
755 53393bae KangIngu
                        case "2":
756
                            {
757
                                MessageBox.Show("권한이 없습니다.");
758
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
759
                            }
760
                            break;
761
                        case "404":
762
                            {
763
                                MessageBox.Show("등록된 사용자가 아닙니다.");
764
                                System.Diagnostics.Process.GetCurrentProcess().Kill();
765
                            }
766
                            break;
767 992a98b4 KangIngu
                    }
768
                }
769
            });
770
771
            // 서버에서 클라이언트 호출 ( 프로그램 구동여부 ) : 라이센스 체크 후 응답 ( 반환값 : true, false ) 
772
            //MarkusLicenseProxy.On<bool>("IsConnection", status =>
773
            //{
774
775
            //    if (status)
776
            //    {
777
            //        // 프로그램 시작 
778
            //        Console.WriteLine("connection status : " + status);
779
            //    }
780
            //    else
781
            //    {
782
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
783
            //        hubConnection.Stop();
784
            //    }
785
            //});
786
787
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
788
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
789
                Console.WriteLine("Noficiation Message : " + msg)
790
            );
791
792
793
            // 서버 메서드 호출 
794
            //MarkusLicenseProxy.Invoke<string>("DoSomething", "I'm doing something!!!").Wait();
795
796
            //Console.ReadKey();
797
798
            //hubConnection.Stop();
799
        }
800 787a4489 KangIngu
801 1f1c566e djkim
        public void MarkupUserListDisplay()
802
        {
803
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
804
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
805
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
806 29010418 ljiyeon
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
807 1f1c566e djkim
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
808 29010418 ljiyeon
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
809 f714bef8 djkim
            //foreach (var item in gridSelectionItem)
810
            //{
811
            //    if (item.UserID == App.ViewInfo.UserID)
812
            //    {
813
            //        ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
814
            //        {
815
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
816
            //        });
817
            //    }
818
            //    else
819
            //    {
820
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
821
            //        {
822
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
823
            //        });
824
            //    }
825
            //}
826 29010418 ljiyeon
                (from A in gridSelectionItem
827
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
828
                 where A.MarkupInfoID == B.MarkupInfoID
829
                 select B).ToList().ForEach(data =>
830
                 {
831
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
832
                 });
833 1f1c566e djkim
            (from A in gridSelectionItem
834
             from B in Common.ViewerDataModel.Instance.MarkupControls
835
             where A.MarkupInfoID == B.MarkupInfoID
836
             select B).ToList().ForEach(data =>
837
             {
838
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
839
             });
840
841
            foreach (var item in gridSelectionItem)
842
            {
843
                if (item.UserID == App.ViewInfo.UserID)
844
                {
845
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
846
                    {
847 661b7416 humkyung
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
848
                            item.MarkupInfoID, markupitem.ID);
849 1f1c566e djkim
                    });
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 661b7416 humkyung
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
856 1f1c566e djkim
                    });
857
                }
858
            }
859
        }
860 787a4489 KangIngu
    }
861
}
클립보드 이미지 추가 (최대 크기: 500 MB)