프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 26ec6226

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

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