1 |
b7645ccc
|
taeseongkim
|
using System;
|
2 |
|
|
using System.Collections.Generic;
|
3 |
|
|
using System.Collections.ObjectModel;
|
4 |
|
|
using System.Linq;
|
5 |
|
|
using System.Text;
|
6 |
|
|
using System.Threading.Tasks;
|
7 |
|
|
using System.Windows;
|
8 |
|
|
using KCOM.Common;
|
9 |
|
|
using KCOM.PemssService;
|
10 |
|
|
using Markus.Mvvm.ToolKit;
|
11 |
|
|
using Telerik.Windows.Controls;
|
12 |
|
|
|
13 |
|
|
namespace KCOM.ViewModel
|
14 |
|
|
{
|
15 |
|
|
public class BiddersViewModel : Markus.Mvvm.ToolKit.ViewModelBase
|
16 |
|
|
{
|
17 |
|
|
PemssService.PemssServiceClient pemssServiceClient;
|
18 |
|
|
|
19 |
|
|
private System.Collections.ObjectModel.ObservableCollection<Bidders> biddersList;
|
20 |
|
|
|
21 |
|
|
public ObservableCollection<Bidders> BiddersList
|
22 |
|
|
{
|
23 |
|
|
get
|
24 |
|
|
{
|
25 |
|
|
if (biddersList == null)
|
26 |
|
|
{
|
27 |
|
|
biddersList = new ObservableCollection<Bidders>();
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
return biddersList;
|
31 |
|
|
}
|
32 |
|
|
set
|
33 |
|
|
{
|
34 |
|
|
if (biddersList != value)
|
35 |
|
|
{
|
36 |
|
|
biddersList = value;
|
37 |
|
|
OnPropertyChanged(() => BiddersList);
|
38 |
|
|
}
|
39 |
|
|
}
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
private Bidders selectBidders;
|
43 |
|
|
|
44 |
|
|
public Bidders SelectBidders
|
45 |
|
|
{
|
46 |
|
|
get
|
47 |
|
|
{
|
48 |
|
|
return selectBidders;
|
49 |
|
|
}
|
50 |
|
|
set
|
51 |
|
|
{
|
52 |
|
|
if (selectBidders != value)
|
53 |
|
|
{
|
54 |
|
|
selectBidders = value;
|
55 |
|
|
OnPropertyChanged(() => SelectBidders);
|
56 |
|
|
}
|
57 |
|
|
}
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
private VpCommant selectVPComment;
|
61 |
|
|
|
62 |
|
|
public VpCommant SelectVPComment
|
63 |
|
|
{
|
64 |
|
|
get
|
65 |
|
|
{
|
66 |
|
|
return selectVPComment;
|
67 |
|
|
}
|
68 |
|
|
set
|
69 |
|
|
{
|
70 |
|
|
if (selectVPComment != value)
|
71 |
|
|
{
|
72 |
|
|
selectVPComment = value;
|
73 |
|
|
OnPropertyChanged(() => SelectVPComment);
|
74 |
|
|
}
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
#region UI에 대한 이벤트
|
79 |
|
|
|
80 |
|
|
public AsyncCommand RefreshCommand => new AsyncCommand(()=> OnGetBiddersDataAsync());
|
81 |
|
|
|
82 |
|
|
public RelayCommand AddVPCommentCommand => new RelayCommand(x => OnAddVPCommentCommand(x));
|
83 |
|
|
|
84 |
|
|
public RelayCommand DelVPCommentCommand => new RelayCommand(x => OnDelVPCommentCommand(x));
|
85 |
|
|
|
86 |
|
|
public RelayCommand SelectedVPCommentCommand => new RelayCommand(x => OnSelectedVPCommentCommand(x));
|
87 |
|
|
|
88 |
df2e7646
|
taeseongkim
|
public RelayCommand BiddersSearchCommand => new RelayCommand(x => OnBiddersSearchCommand(x));
|
89 |
|
|
|
90 |
|
|
|
91 |
b7645ccc
|
taeseongkim
|
#endregion
|
92 |
|
|
|
93 |
|
|
#region 초기화 및 종료 이벤트
|
94 |
|
|
|
95 |
|
|
public BiddersViewModel()
|
96 |
|
|
{
|
97 |
b10671a4
|
taeseongkim
|
if (App.IsDesignMode)
|
98 |
|
|
return;
|
99 |
|
|
|
100 |
b7645ccc
|
taeseongkim
|
try
|
101 |
|
|
{
|
102 |
|
|
if (pemssServiceClient == null)
|
103 |
|
|
{
|
104 |
|
|
pemssServiceClient = new PemssServiceClient(App._binding, App._PemssEndPoint);
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
OnGetBiddersDataAsync().ConfigureAwait(false);
|
108 |
|
|
}
|
109 |
|
|
catch (Exception ex)
|
110 |
|
|
{
|
111 |
b10671a4
|
taeseongkim
|
System.Diagnostics.Debug.WriteLine(ex);
|
112 |
b7645ccc
|
taeseongkim
|
}
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
public override void Loaded()
|
116 |
|
|
{
|
117 |
|
|
base.Loaded();
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
public override void Closed()
|
121 |
|
|
{
|
122 |
|
|
base.Closed();
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
#endregion
|
126 |
|
|
|
127 |
|
|
#region Command
|
128 |
|
|
private async Task OnGetBiddersDataAsync(bool IsInit = true)
|
129 |
|
|
{
|
130 |
|
|
var result = await pemssServiceClient.GetBidderstListAsync(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
|
131 |
|
|
|
132 |
|
|
if (IsInit)
|
133 |
|
|
{
|
134 |
|
|
BiddersList.Clear();
|
135 |
|
|
|
136 |
|
|
if (!string.IsNullOrWhiteSpace(App.PEMSSInfo.CommentID))
|
137 |
|
|
{
|
138 |
|
|
Common.ViewerDataModel.Instance.OnLoadPaged += Instance_OnLoadPaged;
|
139 |
|
|
}
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
result.ForEach(newItem =>
|
143 |
|
|
{
|
144 |
|
|
newItem.IsExpanded = true;
|
145 |
|
|
newItem.IsExpandable = true;
|
146 |
|
|
|
147 |
|
|
if (IsInit)
|
148 |
|
|
{
|
149 |
|
|
BiddersList.Add(newItem);
|
150 |
|
|
}
|
151 |
|
|
else
|
152 |
|
|
{
|
153 |
|
|
BiddersList.UpdateWhere(changeitem => CollectionExtensions.ChangeValues(changeitem, newItem), x => x.bdId == newItem.bdId);
|
154 |
|
|
}
|
155 |
|
|
});
|
156 |
|
|
|
157 |
|
|
IsInit = true;
|
158 |
|
|
}
|
159 |
|
|
private void Instance_OnLoadPaged(object sender, EventArgs e)
|
160 |
|
|
{
|
161 |
|
|
var comment = BiddersList.SelectMany(x => x.VpComments).Where(y => y.commentId == App.PEMSSInfo.CommentID);
|
162 |
|
|
|
163 |
|
|
if (comment.Count() > 0)
|
164 |
|
|
{
|
165 |
|
|
GotoMarkup(new[] { App.PEMSSInfo.CommentID });
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
Common.ViewerDataModel.Instance.OnLoadPaged -= Instance_OnLoadPaged;
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
private void OnAddVPCommentCommand(object obj)
|
172 |
|
|
{
|
173 |
|
|
if (obj == null)
|
174 |
|
|
{
|
175 |
|
|
selectedComment = null;
|
176 |
|
|
}
|
177 |
|
|
else
|
178 |
|
|
{
|
179 |
|
|
SelectBidders = (obj as Telerik.Windows.Controls.GridView.GridViewRow).DataContext as Bidders;
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
if (SelectBidders != null && SelectionSet.Instance.SelectedItems?.Count() > 0)
|
183 |
|
|
{
|
184 |
|
|
Views.AddRequirement addRequirement = new Views.AddRequirement();
|
185 |
df2e7646
|
taeseongkim
|
addRequirement.Header = "Bidders 코멘트 연결 추가";
|
186 |
b7645ccc
|
taeseongkim
|
addRequirement.Width = 600;
|
187 |
|
|
addRequirement.Header = 150;
|
188 |
|
|
|
189 |
|
|
addRequirement.Closed += new EventHandler<WindowClosedEventArgs>(OnAddVpCommantWindowClosed);
|
190 |
|
|
addRequirement.ShowDialogCenter();
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
//var parameters = new DialogParameters()
|
194 |
|
|
//{
|
195 |
|
|
// ContentStyle = (Style)App.Current.Resources["AddVpCommantWindowStyle"],
|
196 |
|
|
// Content = "마크업에 대한 코멘트 : ",
|
197 |
|
|
// Closed = new EventHandler<WindowClosedEventArgs>(OnAddVpCommantWindowClosed),
|
198 |
|
|
// Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault()
|
199 |
|
|
//};
|
200 |
|
|
|
201 |
|
|
//RadWindow.Prompt(parameters);
|
202 |
|
|
}
|
203 |
|
|
else
|
204 |
|
|
{
|
205 |
|
|
DialogParameters parameters = null;
|
206 |
|
|
|
207 |
|
|
if (SelectBidders == null)
|
208 |
|
|
{
|
209 |
|
|
parameters = new DialogParameters()
|
210 |
|
|
{
|
211 |
|
|
Content = "추가할 BIdders을 선택해야 합니다.",
|
212 |
|
|
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault()
|
213 |
|
|
};
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
if (SelectionSet.Instance.SelectedItems == null || SelectionSet.Instance.SelectedItems.Count() == 0)
|
217 |
|
|
{
|
218 |
|
|
parameters = new DialogParameters()
|
219 |
|
|
{
|
220 |
|
|
Content = "선택된 마크업이 없습니다.",
|
221 |
|
|
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault()
|
222 |
|
|
};
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
RadWindow.Alert(parameters);
|
226 |
|
|
}
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
private void OnDelVPCommentCommand(object obj)
|
230 |
|
|
{
|
231 |
|
|
if(obj is Telerik.Windows.Controls.GridView.GridViewRow)
|
232 |
|
|
{
|
233 |
|
|
selectedComment = (obj as Telerik.Windows.Controls.GridView.GridViewRow).DataContext as VpCommant;
|
234 |
|
|
|
235 |
|
|
var parameters = new DialogParameters()
|
236 |
|
|
{
|
237 |
|
|
Content = "해당 Comment를 삭제 하시겠습니까?",
|
238 |
|
|
Closed = new EventHandler<WindowClosedEventArgs>(OnDelVPCommentWindowClosed),
|
239 |
|
|
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault(),
|
240 |
|
|
|
241 |
|
|
};
|
242 |
|
|
|
243 |
|
|
RadWindow.Confirm(parameters);
|
244 |
|
|
}
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
private void OnSelectedVPCommentCommand(object obj)
|
248 |
|
|
{
|
249 |
|
|
if (SelectVPComment != null)
|
250 |
|
|
{
|
251 |
|
|
var iditems = SelectVPComment.commentId.Split(',');
|
252 |
|
|
|
253 |
|
|
GotoMarkup(iditems);
|
254 |
|
|
|
255 |
|
|
//selectedComment
|
256 |
|
|
//SelectionSet.Instance.SelectControl = selectedComment;
|
257 |
|
|
|
258 |
|
|
//if (instanceFavoVP.PAGE_NO == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber)
|
259 |
|
|
//{
|
260 |
|
|
// Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("You have selected the current page", "Notice");
|
261 |
|
|
//}
|
262 |
|
|
//else
|
263 |
|
|
//{
|
264 |
|
|
// Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(instanceFavoVP.PAGE_NO);
|
265 |
|
|
//}
|
266 |
|
|
}
|
267 |
|
|
}
|
268 |
df2e7646
|
taeseongkim
|
private void OnBiddersSearchCommand(object obj)
|
269 |
|
|
{
|
270 |
|
|
var searchView = new Views.BiddersSearchView();
|
271 |
|
|
RadWindow window = new RadWindow();
|
272 |
|
|
window.Header = "Bidders 목록";
|
273 |
|
|
window.Content = searchView;
|
274 |
|
|
window.Width = 1268;
|
275 |
|
|
window.Height = 700;
|
276 |
|
|
|
277 |
|
|
window.Closed += (snd, evt) =>
|
278 |
|
|
{
|
279 |
|
|
if (evt.DialogResult == true)
|
280 |
|
|
{
|
281 |
|
|
if (!string.IsNullOrEmpty(evt.PromptResult))
|
282 |
|
|
{
|
283 |
|
|
SelectBidders = BiddersList.Where(x => x.bdId == evt.PromptResult).First();
|
284 |
|
|
}
|
285 |
|
|
}
|
286 |
|
|
};
|
287 |
|
|
|
288 |
|
|
window.ShowDialogCenter();
|
289 |
|
|
}
|
290 |
b7645ccc
|
taeseongkim
|
|
291 |
|
|
private void GotoMarkup(IEnumerable<string> CommentIdList)
|
292 |
|
|
{
|
293 |
|
|
var selectComments = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(x=> CommentIdList.Count(y=> y == x.CommentID) > 0).ToList();
|
294 |
|
|
|
295 |
|
|
if (selectComments.Count() > 0)
|
296 |
|
|
{
|
297 |
|
|
var infoList = Common.ViewerDataModel.Instance.MyMarkupList.Where(f => f.MarkupInfoID == selectComments.First().MarkupInfoID);
|
298 |
|
|
|
299 |
|
|
if (infoList.Count() > 0)
|
300 |
|
|
{
|
301 |
|
|
Common.ViewerDataModel.Instance.PageBalanceNumber = infoList.First().PageNumber;
|
302 |
|
|
selectComments.First().IsSelected = true;
|
303 |
|
|
GotoMarkup(selectComments);
|
304 |
|
|
|
305 |
|
|
selectComments.First().IsSelected =false;
|
306 |
|
|
}
|
307 |
|
|
}
|
308 |
|
|
}
|
309 |
|
|
|
310 |
|
|
private void GotoMarkup(IEnumerable<MarkupToPDF.Common.CommentUserInfo> commentUserInfo)
|
311 |
|
|
{
|
312 |
|
|
if (commentUserInfo?.Count() > 0)
|
313 |
|
|
{
|
314 |
|
|
var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
|
315 |
|
|
|
316 |
|
|
try
|
317 |
|
|
{
|
318 |
|
|
Rect rect = commentUserInfo.First().ItemRect;
|
319 |
|
|
|
320 |
|
|
foreach (var instance in commentUserInfo)
|
321 |
|
|
{
|
322 |
|
|
rect = Rect.Union(rect, instance.ItemRect);
|
323 |
|
|
|
324 |
|
|
}
|
325 |
|
|
|
326 |
|
|
SelectionSet.Instance.SelectItemByRect(rect, main);
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
//var matrix = new System.Windows.Media.Matrix();
|
330 |
|
|
////var CenterPoint = VectorExtentions.Rotate(new Point(centerX, centerY), Common.ViewerDataModel.Instance.Angle,
|
331 |
|
|
//// new Point(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2));
|
332 |
|
|
|
333 |
|
|
////matrix.RotateAt(Common.ViewerDataModel.Instance.Angle, Common.ViewerDataModel.Instance.ImageViewWidth/2, Common.ViewerDataModel.Instance.ImageViewHeight/2);
|
334 |
|
|
|
335 |
|
|
//matrix.Rotate(Common.ViewerDataModel.Instance.Angle);
|
336 |
|
|
////if (Math.Abs(Common.ViewerDataModel.Instance.Angle) == 90)
|
337 |
|
|
////{
|
338 |
|
|
//// matrix.Translate(Common.ViewerDataModel.Instance.ImageViewHeight, Common.ViewerDataModel.Instance.ImageViewWidth);
|
339 |
|
|
////}
|
340 |
|
|
|
341 |
|
|
//rect.Transform(matrix);
|
342 |
|
|
//if (Math.Abs(Common.ViewerDataModel.Instance.Angle) == 90)
|
343 |
|
|
//{
|
344 |
|
|
// var matrix = new System.Windows.Media.Matrix();
|
345 |
|
|
// matrix.RotateAt(Common.ViewerDataModel.Instance.Angle, Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
|
346 |
|
|
// rect.Transform(matrix);
|
347 |
|
|
//}
|
348 |
|
|
|
349 |
|
|
//double centerX = rect.Left + rect.Width / 2;
|
350 |
|
|
//double centerY = rect.Top + rect.Height / 2;
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
|
354 |
|
|
var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle, center);
|
355 |
|
|
rect.Transform(matrix);
|
356 |
|
|
|
357 |
|
|
double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
|
358 |
|
|
double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
|
359 |
|
|
double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
|
360 |
|
|
double positionX = 0;
|
361 |
|
|
double positionY = 0;
|
362 |
|
|
|
363 |
|
|
if (Common.ViewerDataModel.Instance.Angle == 90)
|
364 |
|
|
{
|
365 |
|
|
positionX = Common.ViewerDataModel.Instance.ImageViewHeight - rect.X;
|
366 |
|
|
positionY = Common.ViewerDataModel.Instance.ImageViewWidth - rect.Y;
|
367 |
|
|
}
|
368 |
|
|
|
369 |
|
|
main.zoomAndPanControl.ContentScale = newScale;
|
370 |
|
|
main.zoomAndPanControl.ContentOffsetX = positionX;
|
371 |
|
|
main.zoomAndPanControl.ContentOffsetY = positionY;
|
372 |
|
|
|
373 |
|
|
main.zoomAndPanControl.ZoomTo(rect);
|
374 |
|
|
|
375 |
|
|
|
376 |
|
|
//double centerX = rect.Left + rect.Width / 2;
|
377 |
|
|
//double centerY = rect.Top + rect.Height / 2;
|
378 |
|
|
|
379 |
|
|
//main.zoomAndPanControl.ZoomAboutPoint(main.zoomAndPanControl.ContentScale, new Point(centerX, centerY));
|
380 |
|
|
}
|
381 |
|
|
catch (Exception ex)
|
382 |
|
|
{
|
383 |
|
|
main.DialogMessage_Alert(ex.Message, "Error");
|
384 |
|
|
}
|
385 |
|
|
}
|
386 |
|
|
}
|
387 |
|
|
|
388 |
|
|
private VpCommant selectedComment;
|
389 |
|
|
|
390 |
|
|
private async void OnDelVPCommentWindowClosed(object sender, WindowClosedEventArgs e)
|
391 |
|
|
{
|
392 |
|
|
VpCommant deleteComment = selectedComment;
|
393 |
|
|
selectedComment = null;
|
394 |
|
|
|
395 |
|
|
if (e.DialogResult == true)
|
396 |
|
|
{
|
397 |
|
|
try
|
398 |
|
|
{
|
399 |
|
|
string projectNo = App.ViewInfo.ProjectNO;
|
400 |
|
|
string docId = App.ViewInfo.DocumentItemID;
|
401 |
|
|
string mdId = deleteComment.mdId;
|
402 |
|
|
string userId = deleteComment.createdBy;
|
403 |
|
|
string commentId = deleteComment.commentId;
|
404 |
|
|
|
405 |
|
|
var result = await pemssServiceClient.RemoveRequirementCommentAsync(projectNo, docId, mdId, commentId, userId);
|
406 |
|
|
|
407 |
|
|
}
|
408 |
|
|
catch (Exception)
|
409 |
|
|
{
|
410 |
|
|
//MessageBox.Show("삭제 오류");
|
411 |
|
|
}
|
412 |
|
|
|
413 |
|
|
await OnGetBiddersDataAsync(false);
|
414 |
|
|
}
|
415 |
|
|
}
|
416 |
|
|
|
417 |
|
|
private async void OnAddVpCommantWindowClosed(object sender, WindowClosedEventArgs e)
|
418 |
|
|
{
|
419 |
|
|
if(e.DialogResult == true)
|
420 |
|
|
{
|
421 |
|
|
var addrequirement = sender as Views.AddRequirement;
|
422 |
|
|
|
423 |
|
|
if(string.IsNullOrWhiteSpace(addrequirement.Comment))
|
424 |
|
|
{
|
425 |
|
|
var parameters = new DialogParameters()
|
426 |
|
|
{
|
427 |
|
|
Content = "코멘트가 없습니다.",
|
428 |
|
|
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault()
|
429 |
|
|
};
|
430 |
|
|
|
431 |
|
|
RadWindow.Alert(parameters);
|
432 |
|
|
return;
|
433 |
|
|
}
|
434 |
|
|
|
435 |
|
|
string commentOnMarkup = addrequirement.Comment;
|
436 |
|
|
|
437 |
|
|
string markupId = string.Join(",",SelectionSet.Instance.SelectedItems.Select(f => f.CommentID));
|
438 |
|
|
string projectNo = App.ViewInfo.ProjectNO;
|
439 |
|
|
string docId = App.ViewInfo.DocumentItemID;
|
440 |
|
|
string bdId = SelectBidders.bdId;
|
441 |
|
|
string userId = App.PEMSSInfo.UserID;
|
442 |
|
|
|
443 |
|
|
bool condition = addrequirement.IsContition;
|
444 |
|
|
|
445 |
|
|
var result = await pemssServiceClient.SetRequirementCommentAsync(projectNo,docId, bdId, markupId,commentOnMarkup,condition,userId);
|
446 |
|
|
|
447 |
|
|
await OnGetBiddersDataAsync(false);
|
448 |
|
|
}
|
449 |
|
|
}
|
450 |
|
|
|
451 |
|
|
#endregion Command
|
452 |
|
|
|
453 |
|
|
}
|
454 |
|
|
} |