프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 16f1ded9

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