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