프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 38d69491

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

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