프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ fdfa126d

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