markus / KCOM / Services / BaseServices.cs @ ff01c725
이력 | 보기 | 이력해설 | 다운로드 (41.5 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 RestSharp; |
8 |
using System; |
9 |
using System.Collections.Generic; |
10 |
using System.Collections.ObjectModel; |
11 |
using System.ComponentModel; |
12 |
using System.Linq; |
13 |
using System.Runtime.CompilerServices; |
14 |
using System.Text; |
15 |
using System.Windows; |
16 |
using System.Windows.Controls; |
17 |
using Telerik.Windows.Controls; |
18 |
using MarkupToPDF.Controls.Parsing; |
19 |
using Telerik.Windows.Data; |
20 |
using System.Web; |
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 ViewInfo _ViewInfo; |
29 |
public DOCINFO _DocInfo; |
30 |
public DOCUMENT_ITEM _DocItem; |
31 |
public MEMBER userData; |
32 |
|
33 |
public event PropertyChangedEventHandler PropertyChanged; |
34 |
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") |
35 |
{ |
36 |
if (PropertyChanged != null) |
37 |
{ |
38 |
PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); |
39 |
} |
40 |
} |
41 |
|
42 |
private Common.DocumentSet _CurrentDoc { get; set; } |
43 |
public Common.DocumentSet CurrentDoc |
44 |
{ |
45 |
get |
46 |
{ |
47 |
return _CurrentDoc; |
48 |
} |
49 |
set |
50 |
{ |
51 |
if (value != CurrentDoc) |
52 |
{ |
53 |
_CurrentDoc = value; |
54 |
NotifyPropertyChanged(); |
55 |
} |
56 |
} |
57 |
} |
58 |
public void ServiceOn() |
59 |
{ |
60 |
BaseClient = new ServiceDeepViewClient(App._binding, App._EndPoint); |
61 |
|
62 |
BaseClient.GetDocInfoCompleted += BaseClient_GetDocInfoCompleted; //문서 섬네일, 페이지크기, 마크업 정보 [3] |
63 |
BaseClient.GetConversionStateCompleted += BaseClient_GetConversionStateCompleted; //컨버팅의 여부 [2] |
64 |
BaseClient.GetSystemDataCompleted += BaseClient_GetSystemDataCompleted; //시스템 정보 [1] |
65 |
BaseClient.GetDocumentItemInfoCompleted += BaseClient_GetDocumentItemInfoCompleted; // 문서 자체의 정보 [4] |
66 |
BaseClient.GetMarkupInfoItemsCompleted += BaseClient_GetMarkupInfoItemsCompleted; |
67 |
BaseClient.GetDeptDataCompleted += BaseClient_GetDeptDataCompleted; |
68 |
BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted; |
69 |
BaseClient.GetVPRevisionHistoryCompleted += BaseClient_GetVPRevisionHistoryCompleted; |
70 |
BaseClient.SetFinalPDFCompleted += BaseClient_SetFinalPDFCompleted; |
71 |
BaseClient.GetCompareRectCompleted += BaseClient_GetCompareRectCompleted; |
72 |
BaseClient.DeleteMarkupCompleted += BaseClient_DeleteMarkupCompleted; |
73 |
BaseClient.DelFavoriteVPCompleted += BaseClient_DelFavoriteVPCompleted; |
74 |
BaseClient.EditFavoriteVPCompleted += BaseClient_EditFavoriteVPCompleted; |
75 |
} |
76 |
|
77 |
|
78 |
|
79 |
private void BaseClient_EditFavoriteVPCompleted(object sender, EditFavoriteVPCompletedEventArgs e) |
80 |
{ |
81 |
Logger.sendResLog("EditFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
82 |
|
83 |
if (e.Error == null && e.Result != false) |
84 |
{ |
85 |
Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1); |
86 |
BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID); |
87 |
} |
88 |
else |
89 |
{ |
90 |
DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning"); |
91 |
} |
92 |
} |
93 |
|
94 |
private void BaseClient_DelFavoriteVPCompleted(object sender, DelFavoriteVPCompletedEventArgs e) |
95 |
{ |
96 |
Logger.sendResLog("DelFavoriteVPCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
97 |
|
98 |
if (e.Error == null && e.Result != false) |
99 |
{ |
100 |
Logger.sendReqLog("GetFavoriteVPAsync", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID + "," + App.ViewInfo.DocumentItemID, 1); |
101 |
BaseClient.GetFavoriteVPAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID, App.ViewInfo.DocumentItemID); |
102 |
} |
103 |
else |
104 |
{ |
105 |
DialogMessage_Alert("Unable to delete the file due to a system failure", "Warning"); |
106 |
} |
107 |
} |
108 |
|
109 |
|
110 |
private void BaseClient_GetCompareRectCompleted(object sender, GetCompareRectCompletedEventArgs e) |
111 |
{ |
112 |
Logger.sendResLog("GetCompareRectCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
113 |
|
114 |
if (e.Error != null || e.Result == null) |
115 |
{ |
116 |
DialogMessage_Alert("Compare 기능을 원활히 실행하기 위한 데이터가 부족합니다", "안내"); |
117 |
} |
118 |
else |
119 |
{ |
120 |
e.Result.ForEach(d => |
121 |
{ |
122 |
d.Width = d.Width * 3; |
123 |
d.Height = d.Height * 3; |
124 |
var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d); |
125 |
System.Windows.Shapes.Ellipse myEllipse = new System.Windows.Shapes.Ellipse(); |
126 |
myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red); |
127 |
myEllipse.Opacity = 1; |
128 |
myEllipse.Width = d.Width; |
129 |
myEllipse.Height = d.Height; |
130 |
Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0)); |
131 |
Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0)); |
132 |
myEllipse.RenderTransformOrigin = point; |
133 |
canvas_compareBorder.Children.Add(myEllipse); |
134 |
}); |
135 |
|
136 |
da.From = 0.8; |
137 |
da.To = 0; |
138 |
da.Duration = new Duration(TimeSpan.FromSeconds(1)); |
139 |
da.AutoReverse = true; |
140 |
canvas_compareBorder.BeginAnimation(OpacityProperty, da); |
141 |
} |
142 |
} |
143 |
|
144 |
private void BaseClient_SetFinalPDFCompleted(object sender, SetFinalPDFCompletedEventArgs e) |
145 |
{ |
146 |
Logger.sendResLog("SetFinalPDFCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
147 |
string errormsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFError", "MSG", "최종 파일을 만드는데 문제가 발생하였습니다"); |
148 |
string successmsg = CommonLib.Common.GetAlertMessageString("SetFinalPDFSuccess", "MSG", "최종 파일 생성 중입니다. 문서관리시스템을 확인해주세요"); |
149 |
if (e.Error != null || e.Result.Status == FinalStatus.Error) |
150 |
{ |
151 |
DialogMessage_Alert(errormsg, "안내"); |
152 |
} |
153 |
else |
154 |
{ |
155 |
DialogMessage_Alert(successmsg, "안내"); |
156 |
} |
157 |
} |
158 |
|
159 |
private void BaseClient_GetVPRevisionHistoryCompleted(object sender, GetVPRevisionHistoryCompletedEventArgs e) |
160 |
{ |
161 |
Logger.sendResLog("GetVPRevisionHistoryCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
162 |
|
163 |
if (e.Result != null && e.Error == null) |
164 |
{ |
165 |
List<VPRevision> list = e.Result; |
166 |
foreach (var item in list) |
167 |
{ |
168 |
item.FROM_VENDOR = HttpUtility.UrlDecode(item.FROM_VENDOR); |
169 |
} |
170 |
gridViewHistory.ItemsSource = list; |
171 |
|
172 |
} |
173 |
//TempFile.TempLoad(); |
174 |
} |
175 |
|
176 |
private void BaseClient_DeleteMarkupCompleted(object sender, DeleteMarkupCompletedEventArgs e) |
177 |
{ |
178 |
Logger.sendResLog("DeleteMarkupCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
179 |
|
180 |
foreach(var info in ViewerDataModel.Instance._markupInfoList) |
181 |
{ |
182 |
if(info.UserID == App.ViewInfo.UserID) |
183 |
{ |
184 |
info.userDelete = true; |
185 |
info.DisplayColor = "FFFF0000"; |
186 |
} |
187 |
else |
188 |
{ |
189 |
info.userDelete = false; |
190 |
} |
191 |
} |
192 |
} |
193 |
|
194 |
private void BaseClient_GetDeptDataCompleted(object sender, GetDeptDataCompletedEventArgs e) |
195 |
{ |
196 |
Logger.sendResLog("GetDeptDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
197 |
|
198 |
if (e.Result != null) |
199 |
{ |
200 |
e.Result.Sort(); |
201 |
//cbSymbolPublic.ItemsSource = e.Result.ToList(); |
202 |
} |
203 |
} |
204 |
public MarkupInfoItem PreviewUserMarkupInfoItem { get; set; } |
205 |
|
206 |
/// <summary> |
207 |
/// 문서 정보를 가져온다 |
208 |
/// </summary> |
209 |
/// <param name="sender"></param> |
210 |
/// <param name="e"></param> |
211 |
private void BaseClient_GetDocInfoCompleted(object sender, GetDocInfoCompletedEventArgs e) |
212 |
{ |
213 |
Logger.sendResLog("GetDocInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
214 |
|
215 |
if (e.Error != null) |
216 |
{ |
217 |
DialogMessage_Alert("페이지정보를 가져올 수 없습니다.", "Alert"); |
218 |
return; |
219 |
} |
220 |
|
221 |
string sFolder = _ViewInfo.DocumentItemID.All(char.IsDigit) ? (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString() : (_ViewInfo.DocumentItemID.Length >= 5 ? _ViewInfo.DocumentItemID.Substring(0, 5) : _ViewInfo.DocumentItemID); |
222 |
var MainUrl = string.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal).Replace("png","jpg"), _ViewInfo.ProjectNO, sFolder, _ViewInfo.DocumentItemID, "{PageNo}"); |
223 |
_DocInfo = e.Result; |
224 |
_DocInfo.ORIGINAL_FILE = HttpUtility.UrlDecode(_DocInfo.ORIGINAL_FILE); |
225 |
foreach (var item in _DocInfo.DOCPAGE.OrderBy(order => order.PAGE_NUMBER)) |
226 |
{ |
227 |
ViewerDataModel.Instance.Document_Info.Add(item); |
228 |
} |
229 |
Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1); |
230 |
BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID); |
231 |
CurrentDoc = new Common.DocumentSet |
232 |
{ |
233 |
docInfo = _DocInfo, |
234 |
Document_Id = _DocInfo.DOCUMENT_ID, |
235 |
Document_NO = _DocItem.DOCUMENT_NO, |
236 |
File_Original = _DocInfo.ORIGINAL_FILE, |
237 |
File_Result = _DocItem.RESULT_FILE, |
238 |
Group_No = _DocItem.GROUP_NO, |
239 |
ProjectNo = _DocItem.PROJECT_NO, |
240 |
Revision = _DocItem.REVISION, |
241 |
}; |
242 |
var instanceMain = this.ParentOfType<MainWindow>(); |
243 |
string firstpage = "1"; |
244 |
string lastpage = _DocInfo.PAGE_COUNT.ToString(); |
245 |
instanceMain.dzTopMenu.tlcurrentPage.Text = firstpage; |
246 |
instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = lastpage; |
247 |
string apptitle = string.Format("MARKUS(ver.{2}) - {0}(Rev.{1})", _DocItem.DOCUMENT_NO, _DocItem.REVISION, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); |
248 |
instanceMain.TitleText.Text = apptitle; |
249 |
instanceMain.Title = apptitle; |
250 |
this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl); |
251 |
|
252 |
ViewerDataModel.Instance.MarkupControls_USER.Clear(); |
253 |
|
254 |
//ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad(); |
255 |
|
256 |
Logger.sendReqLog("GetVPRevisionHistoryAsync", CurrentDoc.ProjectNo + "," + CurrentDoc.Document_NO + "," + CurrentDoc.Document_Id, 1); |
257 |
BaseClient.GetVPRevisionHistoryAsync(CurrentDoc.ProjectNo, CurrentDoc.Document_NO, CurrentDoc.Document_Id); |
258 |
} |
259 |
|
260 |
/// <summary> |
261 |
/// get markupinfo and markupitem from database |
262 |
/// - 1. called when document is loaded |
263 |
/// - 2. called when user do consolidation |
264 |
/// </summary> |
265 |
/// <param name="sender"></param> |
266 |
/// <param name="e"></param> |
267 |
private void BaseClient_GetMarkupInfoItemsCompleted(object sender, GetMarkupInfoItemsCompletedEventArgs e) |
268 |
{ |
269 |
Logger.sendResLog("GetMarkupInfoItemsCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
270 |
|
271 |
ViewerDataModel.Instance.MarkupControls_USER.Clear(); |
272 |
ViewerDataModel.Instance.MarkupControls.Clear(); |
273 |
if (e.Result != null) |
274 |
{ |
275 |
ViewerDataModel.Instance._markupInfoList.Clear(); |
276 |
if (e.Result.Count > 0) ViewerDataModel.Instance.MyMarkupList.Clear(); |
277 |
|
278 |
foreach(var info in e.Result) |
279 |
{ |
280 |
if (info.UserID == App.ViewInfo.UserID) |
281 |
{ |
282 |
info.userDelete = true; |
283 |
info.DisplayColor = "#FFFF0000"; |
284 |
} |
285 |
else |
286 |
{ |
287 |
info.userDelete = false; |
288 |
} |
289 |
ViewerDataModel.Instance._markupInfoList.Add(info); |
290 |
} |
291 |
|
292 |
e.Result.ToList().ForEach(d => d.MarkupList.ForEach(p => |
293 |
{ |
294 |
if (d.UserID == App.ViewInfo.UserID) |
295 |
{ |
296 |
d.userDelete = true; |
297 |
d.DisplayColor = "#FFFF0000"; |
298 |
|
299 |
MarkupItemEx markup = new MarkupItemEx |
300 |
{ |
301 |
Data = p.Data, |
302 |
Data_Type = p.Data_Type, |
303 |
ID = p.ID, |
304 |
IsUpdate = false, |
305 |
MarkupInfoID = d.MarkupInfoID, |
306 |
PageNumber = p.PageNumber, |
307 |
Symbol_ID = p.Symbol_ID, |
308 |
//Group_ID = p.Group_ID |
309 |
}; |
310 |
ViewerDataModel.Instance.MyMarkupList.Add(markup); |
311 |
} |
312 |
else |
313 |
{ |
314 |
MarkupItemEx markup = new MarkupItemEx |
315 |
{ |
316 |
Data = p.Data, |
317 |
Data_Type = p.Data_Type, |
318 |
ID = p.ID, |
319 |
IsUpdate = false, |
320 |
MarkupInfoID = d.MarkupInfoID, |
321 |
PageNumber = p.PageNumber, |
322 |
Symbol_ID = p.Symbol_ID, |
323 |
//Group_ID = p.Group_ID |
324 |
}; |
325 |
ViewerDataModel.Instance.MarkupList_Pre.Add(markup); |
326 |
} |
327 |
})); |
328 |
|
329 |
var currentUser = e.Result.Where(data => data.UserID == App.ViewInfo.UserID && data.AvoidConsolidate == 0).FirstOrDefault(); |
330 |
if (currentUser == null) |
331 |
{ |
332 |
/// create a new markupinfo to do comments |
333 |
var infoId = Commons.shortGuid(); |
334 |
PreviewUserMarkupInfoItem = new MarkupInfoItem |
335 |
{ |
336 |
CreateTime = DateTime.Now, |
337 |
UpdateTime = DateTime.Now, |
338 |
Depatment = userData.DEPARTMENT, |
339 |
DisplayColor = "#FFFF0000", |
340 |
UserID = userData.ID, |
341 |
UserName = userData.NAME, |
342 |
PageCount = 1, |
343 |
Description = "", |
344 |
MarkupInfoID = infoId, |
345 |
MarkupList = null, |
346 |
MarkupVersionID = Commons.shortGuid(), |
347 |
Consolidate = 0, |
348 |
PartConsolidate = 0, |
349 |
userDelete = true, |
350 |
AvoidConsolidate = 0, |
351 |
IsPreviewUser = false |
352 |
}; |
353 |
|
354 |
App.Custom_ViewInfoId = infoId; |
355 |
|
356 |
ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem); |
357 |
} |
358 |
else |
359 |
{ |
360 |
App.Custom_ViewInfoId = currentUser.MarkupInfoID; |
361 |
} |
362 |
|
363 |
foreach(var info in e.Result) |
364 |
{ |
365 |
if (info.UserID == App.ViewInfo.UserID) info.DisplayColor = "#FFFF0000"; |
366 |
} |
367 |
|
368 |
ViewerDataModel.Instance.PageNumber = 1; |
369 |
|
370 |
/// Consolidation 된 데이터가 최상단에 올 수 있도록 변경 |
371 |
var markupItem = ViewerDataModel.Instance._markupInfoList.OrderByDescending(p => p.Consolidate == Convert.ToInt32(true)).ToList(); |
372 |
markupItem.ForEach(data => |
373 |
{ |
374 |
if (data.Depatment == null) data.Depatment = "Unknown"; |
375 |
}); |
376 |
gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList; |
377 |
SetCommentPages(); |
378 |
|
379 |
var SelectedItem = ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == App.ViewInfo.UserID).OrderByDescending(order => order.UpdateTime).FirstOrDefault(); |
380 |
this.gridViewMarkup.SelectedItem = (PreviewUserMarkupInfoItem != null) ? PreviewUserMarkupInfoItem : SelectedItem; |
381 |
|
382 |
/// create a group descriptor |
383 |
gridViewMarkup.GroupDescriptors.Clear(); |
384 |
GroupDescriptor descriptor = new GroupDescriptor(); |
385 |
descriptor.Member = "Depatment"; |
386 |
descriptor.DisplayContent = "DEPT"; |
387 |
//descriptor.SortDirection = ListSortDirection.Ascending; |
388 |
gridViewMarkup.GroupDescriptors.Add(descriptor); |
389 |
/// up to here |
390 |
} |
391 |
} |
392 |
|
393 |
private void gridViewRevMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e) |
394 |
{ |
395 |
List<MarkupInfoItem> gridSelectionItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업 |
396 |
//if (ViewerDataModel.Instance.PageBalanceNumber == 0) |
397 |
//{ |
398 |
// ViewerDataModel.Instance.PageBalanceNumber = 1; |
399 |
//} |
400 |
|
401 |
if (ViewerDataModel.Instance.PageNumber == 0) |
402 |
{ |
403 |
ViewerDataModel.Instance.PageNumber = 1; |
404 |
} |
405 |
if (e.AddedItems.Count() > 0) |
406 |
{ |
407 |
foreach (var item in gridSelectionItem) |
408 |
{ |
409 |
//item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageBalanceNumber).ToList().ForEach(delegate (MarkupItem markupitem) |
410 |
//{ |
411 |
// layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID); |
412 |
//}); |
413 |
item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem) |
414 |
{ |
415 |
MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID); |
416 |
}); |
417 |
} |
418 |
} |
419 |
else if (e.RemovedItems.Count > 0) |
420 |
{ |
421 |
var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList(); |
422 |
|
423 |
(from A in _infoItem |
424 |
from B in Common.ViewerDataModel.Instance.MarkupControls_Sync |
425 |
where A.MarkupInfoID == B.MarkupInfoID |
426 |
select B).ToList().ForEach(data => |
427 |
{ |
428 |
Common.ViewerDataModel.Instance.MarkupControls_Sync.Remove(data); |
429 |
}); |
430 |
} |
431 |
} |
432 |
|
433 |
/// <summary> |
434 |
/// 선택한 항목은 Visibility = Visible, 해제한 항목은 Visibility = Hidden 처리한다. |
435 |
/// </summary> |
436 |
/// <param name="sender"></param> |
437 |
/// <param name="e"></param> |
438 |
private void gridViewMarkup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e) |
439 |
{ |
440 |
var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID); |
441 |
var dataSet_User = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(data => data.UserID == _ViewInfo.UserID); |
442 |
var resultA = (from item_Select in dataSet |
443 |
from item_Non in dataSet_User |
444 |
where item_Select == item_Non |
445 |
select item_Non).ToList(); |
446 |
|
447 |
if (resultA.Count() >= 2) |
448 |
{ |
449 |
RadWindow.Confirm(new DialogParameters |
450 |
{ |
451 |
Owner = Application.Current.MainWindow, |
452 |
Header = "안내", |
453 |
Content = "동일한 사용자 데이터가 두개 이상 선택됩니다. Consolidation을 선택할까요?", |
454 |
Closed = new EventHandler<WindowClosedEventArgs>((sen, ea) => |
455 |
{ |
456 |
if (e.AddedItems.Count() == 1) |
457 |
{ |
458 |
MarkupInfoItem instanceItem = e.AddedItems.FirstOrDefault() as MarkupInfoItem; |
459 |
gridViewMarkup.SelectedItem = null; |
460 |
|
461 |
|
462 |
if (ea.DialogResult.Value) |
463 |
{ |
464 |
if (instanceItem.Consolidate == 1 || instanceItem.PartConsolidate == 1) |
465 |
{ |
466 |
gridViewMarkup.SelectedItem = instanceItem; |
467 |
} |
468 |
else |
469 |
{ |
470 |
//1. Consolidations이 있다면 하나 선택 |
471 |
var Consolidations = resultA.Where(item => (item.Consolidate == 1 || item.PartConsolidate == 1)); |
472 |
|
473 |
if (Consolidations.Count() > 0) |
474 |
{ |
475 |
gridViewMarkup.SelectedItem = Consolidations.First(); |
476 |
} |
477 |
} |
478 |
|
479 |
} |
480 |
else { |
481 |
//1. Consolidations 아닌게 있다면 Change |
482 |
var notConsolidations = resultA.Where(item => !(item.Consolidate == 1 || item.PartConsolidate == 1)); |
483 |
|
484 |
if(notConsolidations.Count() > 0) { |
485 |
gridViewMarkup.SelectedItem = notConsolidations.First(); |
486 |
} |
487 |
else {//1. Consolidations 아닌게 없다면 그대로 |
488 |
gridViewMarkup.SelectedItem = instanceItem; |
489 |
} |
490 |
|
491 |
} |
492 |
} |
493 |
}), |
494 |
Theme = new Windows8Theme(), |
495 |
ModalBackground = new System.Windows.Media.SolidColorBrush { Color = System.Windows.Media.Colors.Black, Opacity = 0.6 }, |
496 |
}); |
497 |
} |
498 |
else //파라미터로 넘어온 사용자가 걸리지 않은 경우 |
499 |
{ |
500 |
List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업 |
501 |
List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업 |
502 |
List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업 |
503 |
#region 코멘트 보기 |
504 |
if (e.AddedItems.Count() > 0) |
505 |
{ |
506 |
foreach (var item in gridSelectionItem) |
507 |
{ |
508 |
if (item.UserID == App.ViewInfo.UserID) |
509 |
{ |
510 |
var controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList(); |
511 |
if (controls.Count == 0) |
512 |
{ |
513 |
var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList(); |
514 |
foreach (var markup in instance) |
515 |
{ |
516 |
MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", |
517 |
item.MarkupInfoID, markup.ID); |
518 |
} |
519 |
} |
520 |
|
521 |
controls = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList(); |
522 |
foreach (var control in controls) |
523 |
{ |
524 |
Logger.sendCheckLog(String.Format("=={0}", control), 1); |
525 |
control.Visibility = Visibility.Visible; |
526 |
} |
527 |
} |
528 |
else |
529 |
{ |
530 |
var controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList(); |
531 |
if (controls.Count == 0) |
532 |
{ |
533 |
var instance = ViewerDataModel.Instance.MarkupList_Pre.Where(d => d.PageNumber == this.pageNavigator.CurrentPage.PageNumber && d.MarkupInfoID == item.MarkupInfoID).ToList(); |
534 |
foreach (var markup in instance) |
535 |
{ |
536 |
MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", |
537 |
item.MarkupInfoID, markup.ID); |
538 |
} |
539 |
} |
540 |
|
541 |
controls = Common.ViewerDataModel.Instance.MarkupControls.Where(d => d.MarkupInfoID == item.MarkupInfoID).ToList(); |
542 |
foreach (var control in controls) |
543 |
{ |
544 |
control.Visibility = Visibility.Visible; |
545 |
} |
546 |
} |
547 |
} |
548 |
} |
549 |
#endregion |
550 |
#region 코멘트 숨기기 |
551 |
else if (e.RemovedItems.Count > 0) |
552 |
{ |
553 |
var _infoItem = e.RemovedItems.Cast<MarkupInfoItem>().ToList(); |
554 |
|
555 |
(from A in _infoItem |
556 |
from B in Common.ViewerDataModel.Instance.MarkupControls |
557 |
where A.MarkupInfoID == B.MarkupInfoID |
558 |
select B).ToList().ForEach(data => |
559 |
{ |
560 |
data.Visibility = Visibility.Hidden; |
561 |
}); |
562 |
|
563 |
|
564 |
var myComment = _infoItem.Where(d => d.UserID == App.ViewInfo.UserID).FirstOrDefault(); |
565 |
if (myComment != null) |
566 |
{ |
567 |
Common.ViewerDataModel.Instance.MarkupControls_USER.ToList().ForEach(delegate (MarkupToPDF.Common.CommentUserInfo markupitem) |
568 |
{ |
569 |
markupitem.Visibility = Visibility.Hidden; |
570 |
}); |
571 |
} |
572 |
} |
573 |
#endregion |
574 |
} |
575 |
} |
576 |
|
577 |
private void BaseClient_GetDocumentItemInfoCompleted(object sender, GetDocumentItemInfoCompletedEventArgs e) |
578 |
{ |
579 |
Logger.sendResLog("GetDocumentItemInfoCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
580 |
|
581 |
if (e.Result != null) |
582 |
{ |
583 |
_DocItem = e.Result; |
584 |
|
585 |
if (e.Result.DOCUMENT_NO == "" && e.Result.DOCUMENT_NAME == "" && e.Result.GROUP_NO == "0") |
586 |
{ |
587 |
//장원 |
588 |
_ViewInfo.UserID = _ViewInfo.UserID.Replace(@"DAELIM\", ""); |
589 |
} |
590 |
Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1); |
591 |
BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID }); |
592 |
} |
593 |
else |
594 |
{ |
595 |
BaseClient.GetCheckSystemAdminCompleted += (sen, ea) => |
596 |
{ |
597 |
Logger.sendResLog("GetCheckSystemAdminCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1); |
598 |
|
599 |
if (ea.Error == null) |
600 |
{ |
601 |
if (ea.Result) |
602 |
{ |
603 |
this._ViewInfo.isAdmin = true; |
604 |
Logger.sendReqLog("GetDocInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1); |
605 |
BaseClient.GetDocInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID }); |
606 |
} |
607 |
else |
608 |
{ |
609 |
//System.Windows.Forms.MessageBox.Show("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내"); |
610 |
DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내"); |
611 |
//this.ParentOfType<MainPage>().DialogMessage_Alert("해당 프로젝트에 가입되지 않은 유저입니다. 관리자에게 등록신청을 해주세요", "안내"); |
612 |
} |
613 |
|
614 |
} |
615 |
else |
616 |
{ |
617 |
//System.Windows.Browser.HtmlPage.Window.Invoke("close"); |
618 |
} |
619 |
}; |
620 |
Logger.sendReqLog("GetCheckSystemAdminAsync", _ViewInfo.UserID, 1); |
621 |
BaseClient.GetCheckSystemAdminAsync(this._ViewInfo.UserID); |
622 |
} |
623 |
} |
624 |
|
625 |
private void BaseClient_GetSystemDataCompleted(object sender, GetSystemDataCompletedEventArgs e) |
626 |
{ |
627 |
Logger.sendResLog("GetSystemDataCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
628 |
|
629 |
if (e.Error == null && e.Result != null) |
630 |
{ |
631 |
App.SystemInfo = e.Result; |
632 |
|
633 |
//App.urlPort_DB = App.SystemInfo.HostPort; |
634 |
//App.urlHost_DB = App.SystemInfo.HostName; |
635 |
Logger.sendReqLog("GetConversionStateAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID, 1); |
636 |
BaseClient.GetConversionStateAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID }); |
637 |
|
638 |
//if (App.urlHost.Contains("localhost")) |
639 |
//{ |
640 |
// App.urlHost = App.urlHost_DB; |
641 |
//} |
642 |
} |
643 |
} |
644 |
|
645 |
private void BaseClient_GetConversionStateCompleted(object sender, GetConversionStateCompletedEventArgs e) |
646 |
{ |
647 |
|
648 |
Logger.sendResLog("GetConversionStateCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
649 |
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잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다"); |
650 |
if (e.Error == null && e.Result == true) |
651 |
{ |
652 |
Logger.sendReqLog("GetDocumentItemInfoAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + _ViewInfo.UserID, 1); |
653 |
|
654 |
BaseClient.GetDocumentItemInfoAsync(new KCOM_BasicParam { projectNo = _ViewInfo.ProjectNO, documentID = _ViewInfo.DocumentItemID, userID = _ViewInfo.UserID }); |
655 |
|
656 |
if (App.ViewInfo != null && App.ViewInfo.ProjectNO != "") |
657 |
{ |
658 |
Logger.sendReqLog("GetMember", _ViewInfo.ProjectNO + "," + _ViewInfo.UserID, 1); |
659 |
userData = BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID); |
660 |
if (userData != null) |
661 |
{ |
662 |
Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1); |
663 |
BaseClient.GetDeptDataAsync(userData.DEPARTMENT); |
664 |
} |
665 |
else |
666 |
{ |
667 |
userData = new MEMBER(); |
668 |
userData.DEPARTMENT = "ALL"; |
669 |
Logger.sendReqLog("GetDeptDataAsync", userData.DEPARTMENT, 1); |
670 |
BaseClient.GetDeptDataAsync(userData.DEPARTMENT); |
671 |
} |
672 |
} |
673 |
} |
674 |
else |
675 |
{ |
676 |
|
677 |
DialogMessage_Alert(failedmsg, "Warning"); |
678 |
} |
679 |
} |
680 |
|
681 |
|
682 |
|
683 |
|
684 |
public void SetView(ViewInfo info) |
685 |
{ |
686 |
//string docid = info.EnsembleID;//BaseClient.GetDocItemID(info.EnsembleID); |
687 |
this._ViewInfo = info; |
688 |
//if (!string.IsNullOrEmpty(docid)) |
689 |
//{ |
690 |
// this._ViewInfo.DocumentItemID = docid; |
691 |
//} |
692 |
Logger.sendReqLog("GetSystemDataAsync", "", 1); |
693 |
BaseClient.GetSystemDataAsync(); |
694 |
} |
695 |
|
696 |
public void HubSet() |
697 |
{ |
698 |
// 허브 연결 구성 |
699 |
var hubConnection = new HubConnection(CommonLib.Common.GetConfigString("HubAddress", "URL", "", App.isExternal)); |
700 |
IHubProxy MarkusLicenseProxy = hubConnection.CreateHubProxy("MarkusLicenseHub"); |
701 |
|
702 |
|
703 |
// 허브 연결 |
704 |
hubConnection.Start().ContinueWith(task => |
705 |
{ |
706 |
if (task.IsFaulted) |
707 |
{ |
708 |
Console.WriteLine("There was an error opening the connection:{0}", |
709 |
task.Exception.GetBaseException()); |
710 |
//throw task.Exception.GetBaseException(); |
711 |
} |
712 |
else |
713 |
{ |
714 |
Console.WriteLine("Connected :: " + task.Id); |
715 |
} |
716 |
|
717 |
}).Wait(); |
718 |
|
719 |
|
720 |
// [ 프로그램 시작 ] |
721 |
// 클라이언트에서 서버를 호출 ( 접속 시 ) : 라이센스 체크 |
722 |
//( "method name", arg1, arg2 ) |
723 |
//MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", "H2009115", "고동균").ContinueWith(task => |
724 |
//{ |
725 |
// if (task.IsFaulted) |
726 |
// { |
727 |
// Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException()); |
728 |
// } |
729 |
// else |
730 |
// { |
731 |
// Console.WriteLine(task.Result); |
732 |
// } |
733 |
//}); |
734 |
MarkusLicenseProxy.Invoke<string>("ConnectionMarkus", App.ViewInfo.UserID,App.ViewInfo.ProjectNO).ContinueWith(task => |
735 |
{ |
736 |
if (task.IsFaulted) |
737 |
{ |
738 |
Console.WriteLine("ConnectionMarkus :: There was an error calling send: {0}", task.Exception.GetBaseException()); |
739 |
//throw task.Exception.GetBaseException(); |
740 |
} |
741 |
else |
742 |
{ |
743 |
switch (task.Result) |
744 |
{ |
745 |
case "2": |
746 |
{ |
747 |
var result = MessageBox.Show("권한이 없습니다."); |
748 |
if (result == MessageBoxResult.OK) |
749 |
System.Diagnostics.Process.GetCurrentProcess().Kill(); |
750 |
} |
751 |
break; |
752 |
case "404": |
753 |
{ |
754 |
var result = MessageBox.Show("등록된 사용자가 아닙니다."); |
755 |
if(result == MessageBoxResult.OK) |
756 |
System.Diagnostics.Process.GetCurrentProcess().Kill(); |
757 |
} |
758 |
break; |
759 |
} |
760 |
} |
761 |
}); |
762 |
|
763 |
// 서버에서 클라이언트 호출 ( 프로그램 구동여부 ) : 라이센스 체크 후 응답 ( 반환값 : true, false ) |
764 |
//MarkusLicenseProxy.On<bool>("IsConnection", status => |
765 |
//{ |
766 |
|
767 |
// if (status) |
768 |
// { |
769 |
// // 프로그램 시작 |
770 |
// Console.WriteLine("connection status : " + status); |
771 |
// } |
772 |
// else |
773 |
// { |
774 |
// // 프로그램 종료 ( signalr 접속 끊기 ) |
775 |
// hubConnection.Stop(); |
776 |
// } |
777 |
//}); |
778 |
|
779 |
// 공지 메세지 ( 서버에서 클라이언트 호출 ) |
780 |
MarkusLicenseProxy.On<string>("MarkusNotification", msg => |
781 |
Console.WriteLine("Noficiation Message : " + msg) |
782 |
); |
783 |
|
784 |
|
785 |
// 서버 메서드 호출 |
786 |
//MarkusLicenseProxy.Invoke<string>("DoSomething", "I'm doing something!!!").Wait(); |
787 |
|
788 |
//Console.ReadKey(); |
789 |
|
790 |
//hubConnection.Stop(); |
791 |
} |
792 |
|
793 |
public void MarkupUserListDisplay() |
794 |
{ |
795 |
List<MarkupInfoItem> gridItem = gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList(); //전체 마크업 |
796 |
List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업 |
797 |
List<MarkupInfoItem> gridNonSelectionItem = gridItem.Except(gridSelectionItem).ToList(); //선택 되지 않은 마크업 |
798 |
//MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl(); |
799 |
Common.ViewerDataModel.Instance.MarkupControls_USER.Clear(); //전체 제거 |
800 |
Common.ViewerDataModel.Instance.MarkupControls.Clear(); //전체 제거 |
801 |
//foreach (var item in gridSelectionItem) |
802 |
//{ |
803 |
// if (item.UserID == App.ViewInfo.UserID) |
804 |
// { |
805 |
// ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem) |
806 |
// { |
807 |
// layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID); |
808 |
// }); |
809 |
// } |
810 |
// else |
811 |
// { |
812 |
// ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem) |
813 |
// { |
814 |
// layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID); |
815 |
// }); |
816 |
// } |
817 |
//} |
818 |
(from A in gridSelectionItem |
819 |
from B in Common.ViewerDataModel.Instance.MarkupControls_USER |
820 |
where A.MarkupInfoID == B.MarkupInfoID |
821 |
select B).ToList().ForEach(data => |
822 |
{ |
823 |
Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(data); |
824 |
}); |
825 |
(from A in gridSelectionItem |
826 |
from B in Common.ViewerDataModel.Instance.MarkupControls |
827 |
where A.MarkupInfoID == B.MarkupInfoID |
828 |
select B).ToList().ForEach(data => |
829 |
{ |
830 |
Common.ViewerDataModel.Instance.MarkupControls.Remove(data); |
831 |
}); |
832 |
|
833 |
foreach (var item in gridSelectionItem) |
834 |
{ |
835 |
if (item.UserID == App.ViewInfo.UserID) |
836 |
{ |
837 |
ViewerDataModel.Instance.MyMarkupList.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem) |
838 |
{ |
839 |
MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", |
840 |
item.MarkupInfoID, markupitem.ID); |
841 |
}); |
842 |
} |
843 |
else |
844 |
{ |
845 |
ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem) |
846 |
{ |
847 |
MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID); |
848 |
}); |
849 |
} |
850 |
} |
851 |
} |
852 |
} |
853 |
} |