markus / KCOM / ViewModel / RequirementViewModel.cs @ fe5ec96f
이력 | 보기 | 이력해설 | 다운로드 (11.4 KB)
1 | fad4d1c0 | 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 RequirementViewModel : Markus.Mvvm.ToolKit.ViewModelBase |
||
16 | { |
||
17 | PemssService.PemssServiceClient pemssServiceClient; |
||
18 | |||
19 | private System.Collections.ObjectModel.ObservableCollection<Requirement> requirementList; |
||
20 | |||
21 | public ObservableCollection<Requirement> RequirementList |
||
22 | { |
||
23 | get |
||
24 | { |
||
25 | if (requirementList == null) |
||
26 | { |
||
27 | requirementList = new ObservableCollection<Requirement>(); |
||
28 | } |
||
29 | |||
30 | return requirementList; |
||
31 | } |
||
32 | set |
||
33 | { |
||
34 | if (requirementList != value) |
||
35 | { |
||
36 | requirementList = value; |
||
37 | OnPropertyChanged(() => RequirementList); |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | |||
42 | private Requirement selectRequirement; |
||
43 | |||
44 | public Requirement SelectRequirement |
||
45 | { |
||
46 | get |
||
47 | { |
||
48 | return selectRequirement; |
||
49 | } |
||
50 | set |
||
51 | { |
||
52 | if (selectRequirement != value) |
||
53 | { |
||
54 | selectRequirement = value; |
||
55 | OnPropertyChanged(() => SelectRequirement); |
||
56 | } |
||
57 | } |
||
58 | } |
||
59 | |||
60 | 84190963 | taeseongkim | 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 | fad4d1c0 | taeseongkim | |
79 | public AsyncCommand RefreshCommand => new AsyncCommand(()=> OnGetRequirementDataAsync()); |
||
80 | |||
81 | 84190963 | taeseongkim | public RelayCommand AddVPCommentCommand => new RelayCommand(x => OnAddVPCommentCommand(x)); |
82 | |||
83 | public RelayCommand DelVPCommentCommand => new RelayCommand(x => OnDelVPCommentCommand(x)); |
||
84 | |||
85 | public RelayCommand SelectedVPCommentCommand => new RelayCommand(x => OnSelectedVPCommentCommand(x)); |
||
86 | fad4d1c0 | taeseongkim | |
87 | |||
88 | #region 초기화 및 종료 이벤트 |
||
89 | |||
90 | public RequirementViewModel() |
||
91 | { |
||
92 | fe5ec96f | taeseongkim | try |
93 | fad4d1c0 | taeseongkim | { |
94 | fe5ec96f | taeseongkim | if (pemssServiceClient == null) |
95 | { |
||
96 | pemssServiceClient = new PemssServiceClient(App._binding, App._PemssEndPoint); |
||
97 | } |
||
98 | |||
99 | OnGetRequirementDataAsync().ConfigureAwait(false); |
||
100 | fad4d1c0 | taeseongkim | } |
101 | fe5ec96f | taeseongkim | catch (Exception EX) |
102 | { |
||
103 | fad4d1c0 | taeseongkim | |
104 | fe5ec96f | taeseongkim | throw; |
105 | } |
||
106 | fad4d1c0 | taeseongkim | } |
107 | |||
108 | public override void Loaded() |
||
109 | { |
||
110 | base.Loaded(); |
||
111 | } |
||
112 | |||
113 | public override void Closed() |
||
114 | { |
||
115 | base.Closed(); |
||
116 | } |
||
117 | |||
118 | #endregion |
||
119 | |||
120 | #region Command |
||
121 | private async Task OnGetRequirementDataAsync() |
||
122 | { |
||
123 | var result = await pemssServiceClient.GetrequirementListAsync(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
||
124 | |||
125 | requirementList.Clear(); |
||
126 | result.ForEach(x => |
||
127 | { |
||
128 | x.IsExpanded = true; |
||
129 | x.IsExpandable = false; |
||
130 | RequirementList.Add(x); |
||
131 | }); |
||
132 | } |
||
133 | |||
134 | |||
135 | 84190963 | taeseongkim | private void OnAddVPCommentCommand(object obj) |
136 | fad4d1c0 | taeseongkim | { |
137 | 84190963 | taeseongkim | if (obj == null) |
138 | { |
||
139 | selectedComment = null; |
||
140 | } |
||
141 | else |
||
142 | { |
||
143 | SelectRequirement = (obj as Telerik.Windows.Controls.GridView.GridViewRow).DataContext as Requirement; |
||
144 | } |
||
145 | |||
146 | fad4d1c0 | taeseongkim | if (SelectRequirement != null && SelectionSet.Instance.SelectedItems?.Count() > 0) |
147 | { |
||
148 | 84190963 | taeseongkim | Views.AddRequirement addRequirement = new Views.AddRequirement(); |
149 | addRequirement.Header = "정합성 코멘트 연결 추가"; |
||
150 | addRequirement.Width = 600; |
||
151 | addRequirement.Header = 150; |
||
152 | |||
153 | addRequirement.Closed += new EventHandler<WindowClosedEventArgs>(OnAddVpCommantWindowClosed); |
||
154 | addRequirement.ShowDialogCenter(); |
||
155 | |||
156 | fad4d1c0 | taeseongkim | |
157 | 84190963 | taeseongkim | //var parameters = new DialogParameters() |
158 | //{ |
||
159 | // ContentStyle = (Style)App.Current.Resources["AddVpCommantWindowStyle"], |
||
160 | // Content = "마크업에 대한 코멘트 : ", |
||
161 | // Closed = new EventHandler<WindowClosedEventArgs>(OnAddVpCommantWindowClosed), |
||
162 | // Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault() |
||
163 | //}; |
||
164 | |||
165 | //RadWindow.Prompt(parameters); |
||
166 | fad4d1c0 | taeseongkim | } |
167 | else |
||
168 | { |
||
169 | DialogParameters parameters = null; |
||
170 | |||
171 | if (SelectRequirement == null) |
||
172 | { |
||
173 | parameters = new DialogParameters() |
||
174 | { |
||
175 | Content = "추가할 정합성을 선택해야 합니다.", |
||
176 | Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault() |
||
177 | }; |
||
178 | } |
||
179 | |||
180 | 84190963 | taeseongkim | if (SelectionSet.Instance.SelectedItems == null || SelectionSet.Instance.SelectedItems.Count() == 0) |
181 | fad4d1c0 | taeseongkim | { |
182 | parameters = new DialogParameters() |
||
183 | { |
||
184 | Content = "선택된 마크업이 없습니다.", |
||
185 | Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault() |
||
186 | }; |
||
187 | } |
||
188 | |||
189 | RadWindow.Alert(parameters); |
||
190 | } |
||
191 | } |
||
192 | |||
193 | 84190963 | taeseongkim | private void OnDelVPCommentCommand(object obj) |
194 | { |
||
195 | if(obj is Telerik.Windows.Controls.GridView.GridViewRow) |
||
196 | { |
||
197 | selectedComment = (obj as Telerik.Windows.Controls.GridView.GridViewRow).DataContext as VpCommant; |
||
198 | |||
199 | var parameters = new DialogParameters() |
||
200 | { |
||
201 | Content = "해당 Comment를 삭제 하시겠습니까?", |
||
202 | Closed = new EventHandler<WindowClosedEventArgs>(OnDelVPCommentWindowClosed), |
||
203 | Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault(), |
||
204 | |||
205 | }; |
||
206 | |||
207 | RadWindow.Confirm(parameters); |
||
208 | } |
||
209 | } |
||
210 | |||
211 | private void OnSelectedVPCommentCommand(object obj) |
||
212 | { |
||
213 | if (SelectVPComment != null) |
||
214 | { |
||
215 | var iditems = SelectVPComment.commentId.Split(','); |
||
216 | |||
217 | var selectComments = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(x=>iditems.Count(y=> y == x.CommentID) > 0).ToList(); |
||
218 | |||
219 | c47493ca | taeseongkim | if (selectComments.Count() > 0) |
220 | 84190963 | taeseongkim | { |
221 | c47493ca | taeseongkim | var infoList = Common.ViewerDataModel.Instance.MyMarkupList.Where(f => f.MarkupInfoID == selectComments.First().MarkupInfoID); |
222 | 84190963 | taeseongkim | |
223 | c47493ca | taeseongkim | if (infoList.Count() > 0) |
224 | { |
||
225 | Common.ViewerDataModel.Instance.PageBalanceNumber = infoList.First().PageNumber; |
||
226 | selectComments.First().IsSelected = true; |
||
227 | GotoMarkup(selectComments); |
||
228 | |||
229 | } |
||
230 | 84190963 | taeseongkim | } |
231 | |||
232 | //selectedComment |
||
233 | //SelectionSet.Instance.SelectControl = selectedComment; |
||
234 | |||
235 | //if (instanceFavoVP.PAGE_NO == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) |
||
236 | //{ |
||
237 | // Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("You have selected the current page", "Notice"); |
||
238 | //} |
||
239 | //else |
||
240 | //{ |
||
241 | // Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(instanceFavoVP.PAGE_NO); |
||
242 | //} |
||
243 | } |
||
244 | } |
||
245 | |||
246 | c47493ca | taeseongkim | private void GotoMarkup(IEnumerable<MarkupToPDF.Common.CommentUserInfo> commentUserInfo) |
247 | { |
||
248 | if (commentUserInfo?.Count() > 0) |
||
249 | { |
||
250 | var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu; |
||
251 | |||
252 | try |
||
253 | { |
||
254 | 709b3fb7 | taeseongkim | Rect rect = commentUserInfo.First().ItemRect; |
255 | |||
256 | c47493ca | taeseongkim | foreach (var instance in commentUserInfo) |
257 | { |
||
258 | 709b3fb7 | taeseongkim | rect = Rect.Union(rect,instance.ItemRect); |
259 | |||
260 | c47493ca | taeseongkim | } |
261 | 709b3fb7 | taeseongkim | |
262 | SelectionSet.Instance.SelectItemByRect(rect, main); |
||
263 | //rect.Scale(4, 4); |
||
264 | |||
265 | main.zoomAndPanControl.ZoomTo(rect); |
||
266 | // main.zoomAndPanControl.ZoomAboutPoint(main.zoomAndPanControl.ContentScale - 0.2, contentZoomCenter); |
||
267 | c47493ca | taeseongkim | } |
268 | catch (Exception ex) |
||
269 | { |
||
270 | main.DialogMessage_Alert(ex.Message, "Error"); |
||
271 | } |
||
272 | } |
||
273 | } |
||
274 | |||
275 | 84190963 | taeseongkim | private void OnVpCommentSelectCommand(object x) |
276 | { |
||
277 | throw new NotImplementedException(); |
||
278 | } |
||
279 | |||
280 | |||
281 | private VpCommant selectedComment; |
||
282 | |||
283 | private async void OnDelVPCommentWindowClosed(object sender, WindowClosedEventArgs e) |
||
284 | { |
||
285 | VpCommant deleteComment = selectedComment; |
||
286 | selectedComment = null; |
||
287 | |||
288 | if (e.DialogResult == true) |
||
289 | { |
||
290 | try |
||
291 | { |
||
292 | string projectNo = App.ViewInfo.ProjectNO; |
||
293 | string docId = App.ViewInfo.DocumentItemID; |
||
294 | string mdId = deleteComment.mdId; |
||
295 | string userId = deleteComment.createdBy; |
||
296 | string commentId = deleteComment.commentId; |
||
297 | |||
298 | var result = await pemssServiceClient.RemoveRequirementCommentAsync(projectNo, docId, mdId, commentId, userId); |
||
299 | |||
300 | } |
||
301 | catch (Exception) |
||
302 | { |
||
303 | c47493ca | taeseongkim | //MessageBox.Show("삭제 오류"); |
304 | 84190963 | taeseongkim | } |
305 | |||
306 | await OnGetRequirementDataAsync(); |
||
307 | } |
||
308 | } |
||
309 | |||
310 | fad4d1c0 | taeseongkim | private async void OnAddVpCommantWindowClosed(object sender, WindowClosedEventArgs e) |
311 | { |
||
312 | if(e.DialogResult == true) |
||
313 | { |
||
314 | 84190963 | taeseongkim | var addrequirement = sender as Views.AddRequirement; |
315 | |||
316 | if(string.IsNullOrWhiteSpace(addrequirement.Comment)) |
||
317 | fad4d1c0 | taeseongkim | { |
318 | var parameters = new DialogParameters() |
||
319 | { |
||
320 | Content = "코멘트가 없습니다.", |
||
321 | Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault() |
||
322 | }; |
||
323 | |||
324 | RadWindow.Alert(parameters); |
||
325 | return; |
||
326 | } |
||
327 | |||
328 | 84190963 | taeseongkim | string commentOnMarkup = addrequirement.Comment; |
329 | fad4d1c0 | taeseongkim | |
330 | 84190963 | taeseongkim | string markupId = string.Join(",",SelectionSet.Instance.SelectedItems.Select(f => f.CommentID)); |
331 | fad4d1c0 | taeseongkim | string projectNo = App.ViewInfo.ProjectNO; |
332 | string docId = App.ViewInfo.DocumentItemID; |
||
333 | string mdId = SelectRequirement.mdId; |
||
334 | 3a4649f8 | taeseongkim | string userId = App.PEMSSInfo.UserID; |
335 | fad4d1c0 | taeseongkim | |
336 | 84190963 | taeseongkim | bool condition = addrequirement.IsContition; |
337 | fad4d1c0 | taeseongkim | |
338 | var result = await pemssServiceClient.SetRequirementCommentAsync(projectNo,docId,mdId,markupId,commentOnMarkup,condition,userId); |
||
339 | 84190963 | taeseongkim | |
340 | await OnGetRequirementDataAsync(); |
||
341 | fad4d1c0 | taeseongkim | } |
342 | } |
||
343 | |||
344 | #endregion Command |
||
345 | |||
346 | } |
||
347 | } |