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