프로젝트

일반

사용자정보

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

markus / KCOM / Services / BaseServices.cs @ d3161976

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

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