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