프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 24c5e56c

이력 | 보기 | 이력해설 | 다운로드 (47.4 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 System;
8
using System.Collections.Generic;
9
using System.Collections.ObjectModel;
10
using System.ComponentModel;
11
using System.Linq;
12
using System.Runtime.CompilerServices;
13
using System.Text;
14
using System.Windows;
15
using System.Windows.Controls;
16
using Telerik.Windows.Controls;
17 036650a0 humkyung
using MarkupToPDF.Controls.Parsing;
18 fddb48f7 ljiyeon
using Telerik.Windows.Data;
19 90a0bfa9 djkim
using System.Web;
20 787a4489 KangIngu
21
namespace KCOM.Views
22
{
23
    public partial class MainMenu : UserControl, INotifyPropertyChanged
24 29010418 ljiyeon
    {
25 eb5cdefc djkim
        //const string DeepZoomUrl = @"http://{baseUrl}/TileSource/{TileSourcePath}/{ItemsPath}/{SharepointItemID}/{PageNo}.jpg";
26 787a4489 KangIngu
        public ServiceDeepViewClient BaseClient;
27 6b6e937c taeseongkim
        public KcomService.ServiceDeepViewClient BaseTaskClient;
28 787a4489 KangIngu
        public ViewInfo _ViewInfo;
29
        public DOCINFO _DocInfo;
30
        public DOCUMENT_ITEM _DocItem;
31
        public MEMBER userData;
32 be72bfd6 taeseongkim
        public List<int> MarkupSortList = new List<int>();
33 787a4489 KangIngu
34
        public event PropertyChangedEventHandler PropertyChanged;
35
        private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
36
        {
37
            if (PropertyChanged != null)
38
            {
39
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
40
            }
41
        }
42
43
        private Common.DocumentSet _CurrentDoc { get; set; }
44
        public Common.DocumentSet CurrentDoc
45
        {
46
            get
47
            {
48
                return _CurrentDoc;
49
            }
50
            set
51
            {
52
                if (value != CurrentDoc)
53
                {
54
                    _CurrentDoc = value;
55
                    NotifyPropertyChanged();
56
                }
57
            }
58
        }
59
        public void ServiceOn()
60
        {
61 6b6e937c taeseongkim
            BaseTaskClient = new KcomService.ServiceDeepViewClient(App._binding, App._EndPoint);
62 29010418 ljiyeon
            BaseClient = new ServiceDeepViewClient(App._binding, App._EndPoint);
63
64 787a4489 KangIngu
            BaseClient.GetDocInfoCompleted += BaseClient_GetDocInfoCompleted; //문서 섬네일, 페이지크기, 마크업 정보 [3]
65 0f065e57 ljiyeon
            BaseClient.GetConversionStateCompleted += BaseClient_GetConversionStateCompleted;  //컨버팅의 여부 [2] 
66
            BaseClient.GetSystemDataCompleted += BaseClient_GetSystemDataCompleted; //시스템 정보 [1] 
67 787a4489 KangIngu
            BaseClient.GetDocumentItemInfoCompleted += BaseClient_GetDocumentItemInfoCompleted; // 문서 자체의 정보 [4]
68 29010418 ljiyeon
            BaseClient.GetMarkupInfoItemsCompleted += BaseClient_GetMarkupInfoItemsCompleted;
69
            BaseClient.GetDeptDataCompleted += BaseClient_GetDeptDataCompleted;
70
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted;
71 787a4489 KangIngu
            BaseClient.GetVPRevisionHistoryCompleted += BaseClient_GetVPRevisionHistoryCompleted;
72 29010418 ljiyeon
            BaseClient.SetFinalPDFCompleted += BaseClient_SetFinalPDFCompleted;
73
            BaseClient.GetCompareRectCompleted += BaseClient_GetCompareRectCompleted;
74
            BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted;
75
            BaseClient.DelFavoriteVPCompleted += BaseClient_DelFavoriteVPCompleted;
76
            BaseClient.EditFavoriteVPCompleted += BaseClient_EditFavoriteVPCompleted;
77 992a98b4 KangIngu
        }
78
79 29010418 ljiyeon
80 992a98b4 KangIngu
81
        private void BaseClient_EditFavoriteVPCompleted(object sender, EditFavoriteVPCompletedEventArgs e)
82
        {
83 0f065e57 ljiyeon
            Logger.sendResLog("EditFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
84
            
85 53880c83 ljiyeon
            if (e.Error == null && e.Result != false)
86 992a98b4 KangIngu
            {
87 0f065e57 ljiyeon
                Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1);
88 992a98b4 KangIngu
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
89
            }
90
            else
91
            {
92
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
93
            }
94
        }
95
96
        private void BaseClient_DelFavoriteVPCompleted(object sender, DelFavoriteVPCompletedEventArgs e)
97
        {
98 0f065e57 ljiyeon
            Logger.sendResLog("DelFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
99
100 53880c83 ljiyeon
            if (e.Error == null && e.Result != false)
101 992a98b4 KangIngu
            {
102 0f065e57 ljiyeon
                Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1);
103 992a98b4 KangIngu
                BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID);
104
            }
105
            else
106
            {
107
                DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning");
108
            }
109 787a4489 KangIngu
        }
110
111 9294fed6 humkyung
        /// <summary>
112
        /// Compare 결과를 받아 화면에 표시한다
113
        /// </summary>
114
        /// <param name="sender"></param>
115
        /// <param name="e"></param>
116 787a4489 KangIngu
        private void BaseClient_GetCompareRectCompleted(object sender, GetCompareRectCompletedEventArgs e)
117
        {
118
            if (e.Error != null || e.Result == null)
119
            {
120 9294fed6 humkyung
                if (e.Error != null)
121
                {
122
                    DialogMessage_Alert(e.Error.ToString(), "Error");
123
                }
124
                else
125
                {
126
                    DialogMessage_Alert("Compare 기능을 원활히 실행하기 위한 데이터가 부족합니다", "안내");
127
                }
128 787a4489 KangIngu
            }
129
            else
130
            {
131
                e.Result.ForEach(d =>
132
                {
133
                    d.Width = d.Width * 3;
134
                    d.Height = d.Height * 3;
135
                    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
136 a1142a6b taeseongkim
                    System.Windows.Shapes.Rectangle myEllipse = new System.Windows.Shapes.Rectangle();
137
                    myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100,255,8,0));
138
                    myEllipse.Opacity = 0.8;
139 787a4489 KangIngu
                    myEllipse.Width = d.Width;
140
                    myEllipse.Height = d.Height;
141
                    Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
142
                    Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
143
                    myEllipse.RenderTransformOrigin = point;
144
                    canvas_compareBorder.Children.Add(myEllipse);
145
                });
146
147
                da.From = 0.8;
148 a1142a6b taeseongkim
                da.To = 0.1;
149 787a4489 KangIngu
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
150
                da.AutoReverse = true;
151
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
152
            }
153
        }
154
155
        private void BaseClient_SetFinalPDFCompleted(object sender, SetFinalPDFCompletedEventArgs e)
156
        {
157 0f065e57 ljiyeon
            Logger.sendResLog("SetFinalPDFCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
158 84c48033 djkim
            string errormsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFError", "MSG", "최종 파일을 만드는데 문제가 발생하였습니다");
159
            string successmsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFSuccess", "MSG", "최종 파일 생성 중입니다. 문서관리시스템을 확인해주세요");
160 29010418 ljiyeon
            if (e.Error != null || e.Result.Status == FinalStatus.Error)
161 787a4489 KangIngu
            {
162 84c48033 djkim
                DialogMessage_Alert(errormsg, "안내");
163 787a4489 KangIngu
            }
164
            else
165
            {
166 84c48033 djkim
                DialogMessage_Alert(successmsg, "안내");
167 787a4489 KangIngu
            }
168
        }
169
170
        private void BaseClient_GetVPRevisionHistoryCompleted(object sender, GetVPRevisionHistoryCompletedEventArgs e)
171
        {
172 0f065e57 ljiyeon
            Logger.sendResLog("GetVPRevisionHistoryCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
173
174 787a4489 KangIngu
            if (e.Result != null && e.Error == null)
175
            {
176 90a0bfa9 djkim
                List<VPRevision> list = e.Result;
177
                foreach (var item in list)
178
                {
179 24ac2a04 taeseongkim
180
                    if (App.isExternal)
181
                    {
182 f35c95d8 taeseongkim
                        var sBaseServiceURL = CommonLib.Common.GetConfigString("ExternalOriginalFileUrl", "URL", "", App.isExternal);
183 24ac2a04 taeseongkim
184 db545833 taeseongkim
                        if (!string.IsNullOrWhiteSpace(item.TO_VENDOR))
185
                        {
186
                            var toUri = new Uri(HttpUtility.UrlDecode(item.TO_VENDOR));
187
                            item.TO_VENDOR = $"{sBaseServiceURL}{toUri.LocalPath}";
188
                        }
189
190
                        if (!string.IsNullOrWhiteSpace(item.FROM_VENDOR))
191
                        {
192
                            var fromUri = new Uri(HttpUtility.UrlDecode(item.FROM_VENDOR));
193
                            item.FROM_VENDOR = $"{sBaseServiceURL}{fromUri.LocalPath}";
194
                        }
195 24ac2a04 taeseongkim
                    }
196
                    else
197
                    {
198
199
                        item.FROM_VENDOR = HttpUtility.UrlDecode(item.FROM_VENDOR);
200
                    }
201 90a0bfa9 djkim
                }
202
                gridViewHistory.ItemsSource = list;
203 787a4489 KangIngu
            }
204 f9fb5500 ljiyeon
            //TempFile.TempLoad();
205 787a4489 KangIngu
        }
206
207
        private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e)
208
        {
209 0f065e57 ljiyeon
            Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
210
211 d128ceb2 humkyung
            foreach(var info in ViewerDataModel.Instance._markupInfoList)
212
            {
213
                if(info.UserID == App.ViewInfo.UserID)
214
                {
215
                    info.userDelete = true;
216
                    info.DisplayColor = "FFFF0000";
217
                }
218
                else
219
                {
220
                    info.userDelete = false;
221
                }
222
            }
223 787a4489 KangIngu
        }
224
225
        private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e)
226
        {
227 0585d5cc taeseongkim
            if (e.Error == null)
228
            {
229
                Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
230
            }
231
            else
232
            {
233
                Logger.sendResLog("GetDeptDataCompleted",  "\r Error :" + e.Error, 1);
234
            }
235 0f065e57 ljiyeon
236 787a4489 KangIngu
            if (e.Result != null)
237
            {
238
                e.Result.Sort();
239
                //cbSymbolPublic.ItemsSource = e.Result.ToList();
240
            }
241
        }
242 0585d5cc taeseongkim
243 29010418 ljiyeon
        public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; }
244 787a4489 KangIngu
245 35a96e24 humkyung
        /// <summary>
246 d62c0439 humkyung
        /// 문서 정보를 가져온다
247
        /// </summary>
248
        /// <param name="sender"></param>
249
        /// <param name="e"></param>
250 eeb0a39c taeseongkim
        private async void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e)
251 d62c0439 humkyung
        {
252 72424099 taeseongkim
            //Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
253 d62c0439 humkyung
254
            if (e.Error != null)
255
            {
256 503cb09e taeseongkim
                DialogMessage_Alert("The page cannot be displayed.", "Alert");
257 d62c0439 humkyung
            }
258 5aa6a59a taeseongkim
            else if (e.Result == null)
259 d62c0439 humkyung
            {
260 cdb2c0a2 taeseongkim
                DialogMessage_Alert("Document information is missing.", "Alert");
261 d62c0439 humkyung
            }
262 cdb2c0a2 taeseongkim
            else
263 d62c0439 humkyung
            {
264 cdb2c0a2 taeseongkim
                string sFolder = _ViewInfo.DocumentItemID.All(char.IsDigit) ? (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString() : (_ViewInfo.DocumentItemID.Length >= 5 ? _ViewInfo.DocumentItemID.Substring(0, 5) : _ViewInfo.DocumentItemID);
265
                var MainUrl = string.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal).Replace("png", "jpg"), _ViewInfo.ProjectNO, sFolder, _ViewInfo.DocumentItemID, "{PageNo}");
266
                _DocInfo = e.Result;
267
                _DocInfo.ORIGINAL_FILE = HttpUtility.UrlDecode(_DocInfo.ORIGINAL_FILE);
268
                foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER))
269
                {
270
                    ViewerDataModel.Instance.Document_Info.Add(item);
271
                }
272
                Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
273
                CurrentDoc = new Common.DocumentSet
274
                {
275
                    docInfo = _DocInfo,
276
                    Document_Id = _DocInfo.DOCUMENT_ID,
277
                    File_Original = _DocInfo.ORIGINAL_FILE,
278 0585d5cc taeseongkim
279 cdb2c0a2 taeseongkim
                    Document_NO = _DocItem?.DOCUMENT_NO,
280
                    File_Result = _DocItem?.RESULT_FILE,
281
                    Group_No = _DocItem?.GROUP_NO,
282
                    ProjectNo = _DocItem?.PROJECT_NO,
283
                    Revision = _DocItem?.REVISION,
284
                };
285 0585d5cc taeseongkim
286 cdb2c0a2 taeseongkim
                var instanceMain = this.ParentOfType<MainWindow>();
287
                string firstpage = "1";
288
                string lastpage = _DocInfo.PAGE_COUNT.ToString();
289
                instanceMain.dzTopMenu.tlcurrentPage.Text = firstpage;
290
                instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = lastpage;
291
                string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem?.DOCUMENT_NO, _DocItem?.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
292 d33ef543 taeseongkim
293 cdb2c0a2 taeseongkim
                instanceMain.Title = apptitle;
294 eeb0a39c taeseongkim
295 cdb2c0a2 taeseongkim
                #region 페이지 이미지를 로컬에 저장
296
                string tempStoragePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName());
297 eeb0a39c taeseongkim
298 cdb2c0a2 taeseongkim
                //.Replace("jpg", "png")을 붙이는 이유는 MainUrl에 확장명이 jpg로 설정한 경우가 있기 때문
299 eeb0a39c taeseongkim
300 cdb2c0a2 taeseongkim
                #endregion
301
                App.PageStorage = new PageManager.PageStorage(MainUrl.Replace("jpg", "png"), tempStoragePath, "png", _DocInfo.PAGE_COUNT);
302 eeb0a39c taeseongkim
303 cdb2c0a2 taeseongkim
                await this.pageNavigator.SetPageNaviAsync(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
304
            }
305 54a28343 taeseongkim
        }
306 d62c0439 humkyung
307 3b81b385 taeseongkim
        private void pageNavigator_ThumbInitialized(object sender,EventArgs e)
308 54a28343 taeseongkim
        {
309
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
310 d62c0439 humkyung
311 54a28343 taeseongkim
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
312 d62c0439 humkyung
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
313
314 6af42ff0 taeseongkim
            #region 단어 검색용 파일 다운로드
315
316 3b81b385 taeseongkim
            DownloadOriginalFileAsync().RunAndForget();
317 6af42ff0 taeseongkim
318
            #endregion
319
320 d62c0439 humkyung
            Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1);
321 6af42ff0 taeseongkim
            BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id);
322
323 d62c0439 humkyung
        }
324
325 54a28343 taeseongkim
326 d62c0439 humkyung
        /// <summary>
327 35a96e24 humkyung
        /// get markupinfo and markupitem from database
328 a36a37c3 humkyung
        ///  - 1. called when document is loaded
329
        ///  - 2. called when user do consolidation
330 35a96e24 humkyung
        /// </summary>
331
        /// <param name="sender"></param>
332
        /// <param name="e"></param>
333 787a4489 KangIngu
        private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e)
334
        {
335 0f065e57 ljiyeon
            Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
336
337 787a4489 KangIngu
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
338
            ViewerDataModel.Instance.MarkupControls.Clear();
339 be72bfd6 taeseongkim
340 787a4489 KangIngu
            if (e.Result != null)
341
            {
342 d128ceb2 humkyung
                ViewerDataModel.Instance._markupInfoList.Clear();
343 3ffd4b2d humkyung
                if (e.Result.Count > 0) ViewerDataModel.Instance.MyMarkupList.Clear();
344 787a4489 KangIngu
345 0585d5cc taeseongkim
                foreach (var info in e.Result)
346 d128ceb2 humkyung
                {
347 be72bfd6 taeseongkim
                    if (info.Depatment == null) info.Depatment = "Unknown";
348
349 d128ceb2 humkyung
                    if (info.UserID == App.ViewInfo.UserID)
350
                    {
351
                        info.userDelete = true;
352
                        info.DisplayColor = "#FFFF0000";
353
                    }
354
                    else
355
                    {
356
                        info.userDelete = false;
357
                    }
358 be72bfd6 taeseongkim
359 d128ceb2 humkyung
                    ViewerDataModel.Instance._markupInfoList.Add(info);
360
                }
361
362 0585d5cc taeseongkim
                var userInfoList = ViewerDataModel.Instance._markupInfoList.GroupBy(f => f.UserID).Select(f => new MarkupUserInfo { UserId = f.Key, UserName = f.First().UserName });
363 8e5a4a6a taeseongkim
364
                userInfoList.ToList().ForEach(x => ViewerDataModel.Instance._markupUserList.Add(x));
365
366 0585d5cc taeseongkim
                e.Result.ToList().ForEach(d =>
367 787a4489 KangIngu
                {
368 0585d5cc taeseongkim
                    if (d.MarkupList != null)
369 787a4489 KangIngu
                    {
370 0585d5cc taeseongkim
                        d.MarkupList.ForEach(p =>
371 787a4489 KangIngu
                        {
372 0585d5cc taeseongkim
                            if (d.UserID == App.ViewInfo.UserID)
373
                            {
374
                                d.userDelete = true;
375
                                d.DisplayColor = "#FFFF0000";
376
377
                                MarkupItemEx markup = new MarkupItemEx
378
                                {
379
                                    Data = p.Data,
380
                                    Data_Type = p.Data_Type,
381
                                    ID = p.ID,
382
                                    IsUpdate = false,
383
                                    MarkupInfoID = d.MarkupInfoID,
384
                                    PageNumber = p.PageNumber,
385
                                    Symbol_ID = p.Symbol_ID,
386 53deabaf taeseongkim
                                    //Group_ID = p.Group_ID
387
                                };
388 0585d5cc taeseongkim
                                ViewerDataModel.Instance.MyMarkupList.Add(markup);
389
                            }
390
                            else
391
                            {
392
                                MarkupItemEx markup = new MarkupItemEx
393
                                {
394
                                    Data = p.Data,
395
                                    Data_Type = p.Data_Type,
396
                                    ID = p.ID,
397
                                    IsUpdate = false,
398
                                    MarkupInfoID = d.MarkupInfoID,
399
                                    PageNumber = p.PageNumber,
400
                                    Symbol_ID = p.Symbol_ID,
401 53deabaf taeseongkim
                                    //Group_ID = p.Group_ID
402
                                };
403 0585d5cc taeseongkim
                                ViewerDataModel.Instance.MarkupList_Pre.Add(markup);
404
                            }
405
                        });
406 787a4489 KangIngu
                    }
407 0585d5cc taeseongkim
                });
408 787a4489 KangIngu
409 a36a37c3 humkyung
                var currentUser = e.Result.Where(data => data.UserID == App.ViewInfo.UserID && data.AvoidConsolidate == 0).FirstOrDefault();
410 a7372e37 taeseongkim
411 787a4489 KangIngu
                if (currentUser == null)
412
                {
413 a36a37c3 humkyung
                    /// create a new markupinfo to do comments
414 27cf69cd taeseongkim
                    /// 
415
                    if (App.ViewInfo.NewCommentPermission)
416
                    {
417
                        var infoId = Commons.shortGuid();
418
                        PreviewUserMarkupInfoItem = new MarkupInfoItem
419
                        {
420
                            CreateTime = DateTime.Now,
421
                            UpdateTime = DateTime.Now,
422
                            Depatment = userData.DEPARTMENT,
423
                            DisplayColor = "#FFFF0000",
424
                            UserID = userData.ID,
425
                            UserName = userData.NAME,
426
                            PageCount = 1,
427
                            Description = "",
428
                            MarkupInfoID = infoId,
429
                            MarkupList = null,
430
                            MarkupVersionID = Commons.shortGuid(),
431
                            Consolidate = 0,
432
                            PartConsolidate = 0,
433
                            userDelete = true,
434
                            AvoidConsolidate = 0,
435
                            IsPreviewUser = false
436
                        };
437
438
                        App.Custom_ViewInfoId = infoId;
439
440
                        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
441
                    }
442 787a4489 KangIngu
                }
443
                else
444
                {
445
                    App.Custom_ViewInfoId = currentUser.MarkupInfoID;
446
                }
447
448 3ffd4b2d humkyung
                ViewerDataModel.Instance.PageNumber = 1;
449
450 a36a37c3 humkyung
                /// Consolidation 된 데이터가 최상단에 올 수 있도록 변경
451 be72bfd6 taeseongkim
                //var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList();
452
453 787a4489 KangIngu
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
454 53deabaf taeseongkim
455 24c5e56c taeseongkim
                SetCommentPages(null);
456 992a98b4 KangIngu
457 47b95004 taeseongkim
                // GRIDVIEW에서 팀별 GROUPING
458
                // 효성은 안함
459 1f2348b2 taeseongkim
#if (Hyosung)
460
#else
461 a36a37c3 humkyung
                /// create a group descriptor
462 fddb48f7 ljiyeon
                gridViewMarkup.GroupDescriptors.Clear();
463
                GroupDescriptor descriptor = new GroupDescriptor();
464
                descriptor.Member = "Depatment";
465
                descriptor.DisplayContent = "DEPT";
466 dd0f7089 djkim
                //descriptor.SortDirection = ListSortDirection.Ascending;
467 fddb48f7 ljiyeon
                gridViewMarkup.GroupDescriptors.Add(descriptor);
468 47b95004 taeseongkim
#endif
469 be72bfd6 taeseongkim
470 53deabaf taeseongkim
                GridViewMarkup_Sorting(gridViewMarkup, new GridViewSortingEventArgs(gridViewMarkup.Columns[0], SortingState.None, SortingState.None));
471 be72bfd6 taeseongkim
472
                var SelectedItem = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.UpdateTime).FirstOrDefault();
473 53deabaf taeseongkim
474
                if (PreviewUserMarkupInfoItem != null)
475
                {
476
                    this.gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
477
                }
478
                else if (SelectedItem != null)
479
                {
480
                    this.gridViewMarkup.SelectedItem = SelectedItem;
481
                }
482
                else if(ViewerDataModel.Instance._markupInfoList.Count() > 0)
483
                {
484
                    this.gridViewMarkup.SelectedItem = ViewerDataModel.Instance._markupInfoList.First();
485
                }
486 787a4489 KangIngu
            }
487
        }
488
489 be72bfd6 taeseongkim
        private void GridViewMarkup_Sorting(object sender, GridViewSortingEventArgs e)
490
        {
491
            IEnumerable<IKCOM.MarkupInfoItem> markuplist = e.DataControl.ItemsSource as IEnumerable<IKCOM.MarkupInfoItem>;
492
493
            if(markuplist == null)
494
            {
495
                e.Cancel = true;
496
                return;
497
            }
498
499
            if(e.NewSortingState == SortingState.None)
500
            {
501
                markuplist = markuplist.OrderByDescending(x => SortIndex(x))
502
                                            .ThenBy(x => x.Depatment)
503
                                            .ThenBy(x => x.UserID);
504
505
                e.DataControl.ItemsSource = markuplist.ToList();
506
            }
507
        }
508
509
510
        // 마크업 리스트 정렬
511
        private int SortIndex(IKCOM.MarkupInfoItem markupInfoItem)
512
        {
513
            int result = 0;
514
515
            // Consolidate은 최상단
516
            if (markupInfoItem.Consolidate == 1)
517
            {
518
                result += 2;
519
            }
520
521
            /// Consolidate 다음으로 우선순위
522
            if (markupInfoItem.UserID == App.ViewInfo.UserID)
523
            {
524
                result += 1;
525
            }
526
527
            return result;
528
        }
529
530
531
        private void GridViewMarkup_Sorted(object sender, GridViewSortedEventArgs e)
532
        {
533
534
        }
535
536 ac4f1e13 taeseongkim
        private async void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
537 787a4489 KangIngu
        {
538
            List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
539
            //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
540
            //{
541
            //    ViewerDataModel.Instance.PageBalanceNumber = 1;
542
            //}
543
544
            if (ViewerDataModel.Instance.PageNumber == 0)
545
            {
546
                ViewerDataModel.Instance.PageNumber = 1;
547
            }
548
            if (e.AddedItems.Count() > 0)
549
            {
550
                foreach (var item in gridSelectionItem)
551
                {
552
                    //item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem)
553
                    //{
554
                    //    layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
555
                    //});
556 ac4f1e13 taeseongkim
557
                    var pageItems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
558
559
                    foreach (var markupitem in pageItems)
560 787a4489 KangIngu
                    {
561 24c5e56c taeseongkim
                       await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
562 ac4f1e13 taeseongkim
                    }
563 787a4489 KangIngu
                }
564
            }
565
            else if (e.RemovedItems.Count > 0)
566
            {
567
                var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
568
569
                (from A in _infoItem
570
                 from B in Common.ViewerDataModel.Instance.MarkupControls_Sync
571
                 where A.MarkupInfoID == B.MarkupInfoID
572
                 select B).ToList().ForEach(data =>
573
                 {
574
                     Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data);
575
                 });
576
            }
577
        }
578 e7dd7ae8 humkyung
579
        /// <summary>
580
        /// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다.
581
        /// </summary>
582
        /// <param name="sender"></param>
583
        /// <param name="e"></param>
584 ac4f1e13 taeseongkim
        private async void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
585 787a4489 KangIngu
        {
586 2089959a taeseongkim
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
587
588 787a4489 KangIngu
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
589
            var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID);
590
            var resultA = (from item_Select in dataSet
591
                           from item_Non in dataSet_User
592
                           where item_Select == item_Non
593
                           select item_Non).ToList();
594
595
            if (resultA.Count() >= 2)
596
            {
597 eeb0a39c taeseongkim
                // 동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?
598 787a4489 KangIngu
                RadWindow.Confirm(new DialogParameters
599
                {
600 b9b01f8e ljiyeon
                    Owner = Application.Current.MainWindow,
601 eeb0a39c taeseongkim
                    Header = "Info",
602
                    Content = "Selected more than two identical user data. Do you want to select consolidation?",
603 787a4489 KangIngu
                    Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) =>
604
                    {
605
                        if (e.AddedItems.Count() == 1)
606
                        {
607
                            MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem;
608 8ab0d0b1 송근호
                            gridViewMarkup.SelectedItem = null;
609 787a4489 KangIngu
610 8ab0d0b1 송근호
                        
611 787a4489 KangIngu
                            if (ea.DialogResult.Value)
612
                            {
613 8ab0d0b1 송근호
                                if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1)
614
                                {
615
                                    gridViewMarkup.SelectedItem = instanceItem;
616
                                }
617
                                else
618
                                {
619
                                    //1. Consolidations이 있다면 하나 선택
620
                                    var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1));
621
622
                                    if (Consolidations.Count() > 0)
623
                                    {
624
                                        gridViewMarkup.SelectedItem = Consolidations.First();
625
                                    }
626
                                }
627
                              
628 787a4489 KangIngu
                            }
629 8ab0d0b1 송근호
                            else {
630
                                //1. Consolidations 아닌게 있다면 Change
631
                                var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1));
632
633
                                if(notConsolidations.Count() > 0) {
634
                                    gridViewMarkup.SelectedItem = notConsolidations.First();
635
                                }
636
                                else {//1. Consolidations 아닌게 없다면 그대로
637
                                    gridViewMarkup.SelectedItem = instanceItem;
638
                                }
639
                                
640 787a4489 KangIngu
                            }
641
                        }
642
                    }),
643
                    Theme = new Windows8Theme(),
644
                    ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 },
645
                });
646
            }
647
            else //파라미터로 넘어온 사용자가 걸리지 않은 경우
648
            {
649 6b5d33c6 djkim
                List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
650
                List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
651
                List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
652 47b95004 taeseongkim
#region 코멘트 보기
653 d18ea2bd taeseongkim
                if (e.AddedItems.Count() > 0 && this.pageNavigator.CurrentPage != null)
654 6b5d33c6 djkim
                {
655
                    foreach (var item in gridSelectionItem)
656
                    {
657 3ffd4b2d humkyung
                        if (item.UserID == App.ViewInfo.UserID)
658 6b5d33c6 djkim
                        {
659 101da246 humkyung
                            var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
660
                            if (controls.Count == 0)
661 6b5d33c6 djkim
                            {
662 129ca191 humkyung
                                var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
663 ac4f1e13 taeseongkim
664 6b5d33c6 djkim
                                foreach (var markup in instance)
665
                                {
666 24c5e56c taeseongkim
                                    await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
667 661b7416 humkyung
                                        item.MarkupInfoID, markup.ID);
668 6b5d33c6 djkim
                                }
669
                            }
670 101da246 humkyung
671
                            controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
672
                            foreach (var control in controls)
673 6b5d33c6 djkim
                            {
674 d62c0439 humkyung
                                Logger.sendCheckLog(String.Format("=={0}", control), 1);
675 101da246 humkyung
                                control.Visibility = Visibility.Visible;
676 6b5d33c6 djkim
                            }
677
                        }
678 3ffd4b2d humkyung
                        else
679 6b5d33c6 djkim
                        {
680 101da246 humkyung
                            var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
681
                            if (controls.Count == 0)
682
                            {
683 129ca191 humkyung
                                var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList();
684 101da246 humkyung
                                foreach (var markup in instance)
685
                                {
686 24c5e56c taeseongkim
                                    await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "",
687 101da246 humkyung
                                        item.MarkupInfoID, markup.ID);
688
                                }
689
                            }
690
691
                            controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList();
692
                            foreach (var control in controls)
693 6b5d33c6 djkim
                            {
694 e7dd7ae8 humkyung
                                control.Visibility = Visibility.Visible;
695 6b5d33c6 djkim
                            }
696
                        }
697
                    }
698
                }
699 47b95004 taeseongkim
#endregion
700
#region 코멘트 숨기기
701 6b5d33c6 djkim
                else if (e.RemovedItems.Count > 0)
702
                {
703
                    var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList();
704
705
                    (from A in _infoItem
706
                     from B in Common.ViewerDataModel.Instance.MarkupControls
707
                     where A.MarkupInfoID == B.MarkupInfoID
708
                     select B).ToList().ForEach(data =>
709
                     {
710 b5ac6d6e ljiyeon
                         data.Visibility = Visibility.Hidden;                         
711 6b5d33c6 djkim
                     });
712
713 b5ac6d6e ljiyeon
714 6b5d33c6 djkim
                    var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault();
715
                    if (myComment != null)
716
                    {
717
                        Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem)
718
                        {
719 e7dd7ae8 humkyung
                            markupitem.Visibility = Visibility.Hidden;
720 6b5d33c6 djkim
                        });
721
                    }
722
                }
723 47b95004 taeseongkim
#endregion
724 787a4489 KangIngu
            }
725
        }
726
727
        private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e)
728
        {
729 0f065e57 ljiyeon
            Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
730
731 787a4489 KangIngu
            if (e.Result != null)
732
            {
733
                _DocItem = e.Result;
734
735
                if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0")
736
                {
737
                    //장원
738
                    _ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", "");
739
                }
740 29010418 ljiyeon
                Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
741 787a4489 KangIngu
                BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
742
            }
743
            else
744
            {
745 0585d5cc taeseongkim
                DialogMessage_Alert("Document Information Not Found.", "Error");
746
747 787a4489 KangIngu
                BaseClient.GetCheckSystemAdminCompleted += (sen, ea) =>
748
                {
749 0f065e57 ljiyeon
                    Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
750
751 787a4489 KangIngu
                    if (ea.Error == null)
752
                    {
753
                        if (ea.Result)
754
                        {
755
                            this._ViewInfo.isAdmin = true;
756 0f065e57 ljiyeon
                            Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
757 787a4489 KangIngu
                            BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
758
                        }
759
                        else
760
                        {
761
                            //System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
762 503cb09e taeseongkim
                            DialogMessage_Alert("You are not belong to this project. Please ask admin for an authority.", "Info");
763 787a4489 KangIngu
                            //this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내");
764
                        }
765
766
                    }
767
                    else
768
                    {
769
                        //System.Windows.Browser.HtmlPage.Window.Invoke("close");
770
                    }
771
                };
772 0f065e57 ljiyeon
                Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1);
773 787a4489 KangIngu
                BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID);
774
            }
775
        }
776
777
        private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e)
778
        {
779 0f065e57 ljiyeon
            Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
780
781 787a4489 KangIngu
            if (e.Error == null && e.Result != null)
782
            {
783
                App.SystemInfo = e.Result;
784
785
                //App.urlPort_DB = App.SystemInfo.HostPort;
786
                //App.urlHost_DB = App.SystemInfo.HostName;
787 0f065e57 ljiyeon
                Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1);
788 787a4489 KangIngu
                BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID });
789
790
                //if (App.urlHost.Contains("localhost"))
791
                //{
792
                //    App.urlHost = App.urlHost_DB;
793
                //}
794
            }
795
        }
796
797
        private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e)
798
        {
799 84c48033 djkim
            
800 0f065e57 ljiyeon
            Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
801 84c48033 djkim
            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잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
802 53880c83 ljiyeon
            if (e.Error == null && e.Result == true)
803 787a4489 KangIngu
            {
804 0f065e57 ljiyeon
                Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1);
805
806 787a4489 KangIngu
                BaseClient.GetDocumentItemInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID, userID = _ViewInfo.UserID });
807
808 992a98b4 KangIngu
                if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "")
809 787a4489 KangIngu
                {
810 0f065e57 ljiyeon
                    Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1);
811 6c781c0c djkim
                    userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
812
                    if (userData != null)
813 787a4489 KangIngu
                    {
814 0f065e57 ljiyeon
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
815 6c781c0c djkim
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
816 787a4489 KangIngu
                    }
817 6c781c0c djkim
                    else
818
                    {
819
                        userData = new MEMBER();
820
                        userData.DEPARTMENT = "ALL";
821 0f065e57 ljiyeon
                        Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1);
822 6c781c0c djkim
                        BaseClient.GetDeptDataAsync(userData.DEPARTMENT);
823 29010418 ljiyeon
                    }
824 787a4489 KangIngu
                }
825
            }
826
            else
827
            {
828 84c48033 djkim
                
829
                DialogMessage_Alert(failedmsg, "Warning");
830 787a4489 KangIngu
            }
831
        }
832 29010418 ljiyeon
833 787a4489 KangIngu
        public void SetView(ViewInfo info)
834 5a6493ad humkyung
        { 
835 787a4489 KangIngu
            this._ViewInfo = info;
836 5a6493ad humkyung
            try
837 5ded1e5a djkim
            {
838 5a6493ad humkyung
                /// 대림의 경우 EnsembleID를 가지고 DocumentItemID를 구함
839
                /// 다른 Site를 대비하여 에러 처리함
840
                string docid = BaseClient.GetDocItemID(info.EnsembleID);
841
                if (!string.IsNullOrEmpty(docid))
842
                {
843
                    this._ViewInfo.DocumentItemID = docid;
844
                }
845 5ded1e5a djkim
            }
846 5a6493ad humkyung
            catch(Exception ex)
847
            {
848
                App.FileLogger.Fatal(ex);
849
            }
850
851 5ded1e5a djkim
            Logger.sendReqLog("GetSystemDataAsync", "", 1);
852 29010418 ljiyeon
            BaseClient.GetSystemDataAsync();
853 787a4489 KangIngu
        }
854
855 992a98b4 KangIngu
        public void HubSet()
856
        {
857
            // 허브 연결 구성
858 84c48033 djkim
            var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal));
859 992a98b4 KangIngu
            IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub");
860
861
862
            // 허브 연결 
863
            hubConnection.Start().ContinueWith(task =>
864
            {
865
                if (task.IsFaulted)
866
                {
867
                    Console.WriteLine("There was an error opening the connection:{0}",
868
                                      task.Exception.GetBaseException());
869 53f96e00 송근호
                    //throw task.Exception.GetBaseException();
870 992a98b4 KangIngu
                }
871
                else
872
                {
873
                    Console.WriteLine("Connected :: " + task.Id);
874
                }
875
876
            }).Wait();
877
878
879
            // [ 프로그램 시작 ]
880
            // 클라이언트에서 서버를 호출 ( 접속 시 )  : 라이센스 체크
881
            //( "method name", arg1, arg2 )
882
            //MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task =>
883
            //{
884
            //    if (task.IsFaulted)
885
            //    {
886
            //        Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
887
            //    }
888
            //    else
889
            //    {
890
            //        Console.WriteLine(task.Result);
891
            //    }
892
            //});
893 0af41bf0 djkim
            MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID,App.ViewInfo.ProjectNO).ContinueWith(task =>
894 992a98b4 KangIngu
            {
895
                if (task.IsFaulted)
896
                {
897
                    Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException());
898 53f96e00 송근호
                    //throw task.Exception.GetBaseException();
899 992a98b4 KangIngu
                }
900
                else
901
                {
902 29010418 ljiyeon
                    switch (task.Result)
903 992a98b4 KangIngu
                    {
904 53393bae KangIngu
                        case "2":
905
                            {
906 0af41bf0 djkim
                                var result = MessageBox.Show("권한이 없습니다.");
907
                                if (result == MessageBoxResult.OK)
908
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
909 53393bae KangIngu
                            }
910
                            break;
911
                        case "404":
912
                            {
913 0af41bf0 djkim
                                var result = MessageBox.Show("등록된 사용자가 아닙니다.");
914
                                if(result == MessageBoxResult.OK)
915
                                    System.Diagnostics.Process.GetCurrentProcess().Kill();
916 53393bae KangIngu
                            }
917
                            break;
918 992a98b4 KangIngu
                    }
919
                }
920 53f96e00 송근호
            });
921 992a98b4 KangIngu
922
            // 서버에서 클라이언트 호출 ( 프로그램 구동여부 ) : 라이센스 체크 후 응답 ( 반환값 : true, false ) 
923
            //MarkusLicenseProxy.On<bool>("IsConnection", status =>
924
            //{
925
926
            //    if (status)
927
            //    {
928
            //        // 프로그램 시작 
929
            //        Console.WriteLine("connection status : " + status);
930
            //    }
931
            //    else
932
            //    {
933
            //        // 프로그램 종료 ( signalr 접속 끊기 )  
934
            //        hubConnection.Stop();
935
            //    }
936
            //});
937
938
            // 공지 메세지 ( 서버에서 클라이언트 호출 ) 
939
            MarkusLicenseProxy.On<string>("MarkusNotification", msg =>
940
                Console.WriteLine("Noficiation Message : " + msg)
941
            );
942
943
944
            // 서버 메서드 호출 
945
            //MarkusLicenseProxy.Invoke<string>("DoSomething", "I'm doing something!!!").Wait();
946
947
            //Console.ReadKey();
948
949
            //hubConnection.Stop();
950
        }
951 787a4489 KangIngu
952 ac4f1e13 taeseongkim
        public async void MarkupUserListDisplay()
953 1f1c566e djkim
        {
954
            List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업
955
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
956
            List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업
957 29010418 ljiyeon
                                                                                                     //MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
958 1f1c566e djkim
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
959 29010418 ljiyeon
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
960 f714bef8 djkim
            //foreach (var item in gridSelectionItem)
961
            //{
962
            //    if (item.UserID == App.ViewInfo.UserID)
963
            //    {
964 d62c0439 humkyung
            //        ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
965 f714bef8 djkim
            //        {
966
            //            layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
967
            //        });
968
            //    }
969
            //    else
970
            //    {
971
            //        ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
972
            //        {
973
            //            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
974
            //        });
975
            //    }
976
            //}
977 29010418 ljiyeon
                (from A in gridSelectionItem
978
                 from B in Common.ViewerDataModel.Instance.MarkupControls_USER
979
                 where A.MarkupInfoID == B.MarkupInfoID
980
                 select B).ToList().ForEach(data =>
981
                 {
982
                     Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data);
983
                 });
984 1f1c566e djkim
            (from A in gridSelectionItem
985
             from B in Common.ViewerDataModel.Instance.MarkupControls
986
             where A.MarkupInfoID == B.MarkupInfoID
987
             select B).ToList().ForEach(data =>
988
             {
989
                 Common.ViewerDataModel.Instance.MarkupControls.Remove(data);
990
             });
991
992
            foreach (var item in gridSelectionItem)
993
            {
994 ac4f1e13 taeseongkim
995 1f1c566e djkim
                if (item.UserID == App.ViewInfo.UserID)
996
                {
997 ac4f1e13 taeseongkim
                    var markupItems = ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
998
999
                    foreach (var markupitem in markupItems)
1000 1f1c566e djkim
                    {
1001 24c5e56c taeseongkim
                        await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
1002 ac4f1e13 taeseongkim
                                item.MarkupInfoID, markupitem.ID);
1003
                    }
1004 1f1c566e djkim
                }
1005
                else
1006
                {
1007 ac4f1e13 taeseongkim
                    var markupItems = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList();
1008
1009
                    foreach (var markupitem in markupItems)
1010 1f1c566e djkim
                    {
1011 24c5e56c taeseongkim
                        await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
1012 ac4f1e13 taeseongkim
                    }
1013 1f1c566e djkim
                }
1014
            }
1015
        }
1016 787a4489 KangIngu
    }
1017
}
클립보드 이미지 추가 (최대 크기: 500 MB)