프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ 34ac8db7

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