프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ d0385e5c

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