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 |
|
|
if (pemssServiceClient == null)
|
93 |
|
|
{
|
94 |
6f67c93d
|
taeseongkim
|
pemssServiceClient = new PemssServiceClient(App._binding,App._PemssEndPoint);
|
95 |
fad4d1c0
|
taeseongkim
|
}
|
96 |
|
|
|
97 |
|
|
OnGetRequirementDataAsync().ConfigureAwait(false);
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
public override void Loaded()
|
101 |
|
|
{
|
102 |
|
|
base.Loaded();
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
public override void Closed()
|
106 |
|
|
{
|
107 |
|
|
base.Closed();
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
#endregion
|
111 |
|
|
|
112 |
|
|
#region Command
|
113 |
|
|
private async Task OnGetRequirementDataAsync()
|
114 |
|
|
{
|
115 |
|
|
var result = await pemssServiceClient.GetrequirementListAsync(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
|
116 |
|
|
|
117 |
|
|
requirementList.Clear();
|
118 |
|
|
result.ForEach(x =>
|
119 |
|
|
{
|
120 |
|
|
x.IsExpanded = true;
|
121 |
|
|
x.IsExpandable = false;
|
122 |
|
|
RequirementList.Add(x);
|
123 |
|
|
});
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
|
127 |
84190963
|
taeseongkim
|
private void OnAddVPCommentCommand(object obj)
|
128 |
fad4d1c0
|
taeseongkim
|
{
|
129 |
84190963
|
taeseongkim
|
if (obj == null)
|
130 |
|
|
{
|
131 |
|
|
selectedComment = null;
|
132 |
|
|
}
|
133 |
|
|
else
|
134 |
|
|
{
|
135 |
|
|
SelectRequirement = (obj as Telerik.Windows.Controls.GridView.GridViewRow).DataContext as Requirement;
|
136 |
|
|
}
|
137 |
|
|
|
138 |
fad4d1c0
|
taeseongkim
|
if (SelectRequirement != null && SelectionSet.Instance.SelectedItems?.Count() > 0)
|
139 |
|
|
{
|
140 |
84190963
|
taeseongkim
|
Views.AddRequirement addRequirement = new Views.AddRequirement();
|
141 |
|
|
addRequirement.Header = "정합성 코멘트 연결 추가";
|
142 |
|
|
addRequirement.Width = 600;
|
143 |
|
|
addRequirement.Header = 150;
|
144 |
|
|
|
145 |
|
|
addRequirement.Closed += new EventHandler<WindowClosedEventArgs>(OnAddVpCommantWindowClosed);
|
146 |
|
|
addRequirement.ShowDialogCenter();
|
147 |
|
|
|
148 |
fad4d1c0
|
taeseongkim
|
|
149 |
84190963
|
taeseongkim
|
//var parameters = new DialogParameters()
|
150 |
|
|
//{
|
151 |
|
|
// ContentStyle = (Style)App.Current.Resources["AddVpCommantWindowStyle"],
|
152 |
|
|
// Content = "마크업에 대한 코멘트 : ",
|
153 |
|
|
// Closed = new EventHandler<WindowClosedEventArgs>(OnAddVpCommantWindowClosed),
|
154 |
|
|
// Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault()
|
155 |
|
|
//};
|
156 |
|
|
|
157 |
|
|
//RadWindow.Prompt(parameters);
|
158 |
fad4d1c0
|
taeseongkim
|
}
|
159 |
|
|
else
|
160 |
|
|
{
|
161 |
|
|
DialogParameters parameters = null;
|
162 |
|
|
|
163 |
|
|
if (SelectRequirement == null)
|
164 |
|
|
{
|
165 |
|
|
parameters = new DialogParameters()
|
166 |
|
|
{
|
167 |
|
|
Content = "추가할 정합성을 선택해야 합니다.",
|
168 |
|
|
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault()
|
169 |
|
|
};
|
170 |
|
|
}
|
171 |
|
|
|
172 |
84190963
|
taeseongkim
|
if (SelectionSet.Instance.SelectedItems == null || SelectionSet.Instance.SelectedItems.Count() == 0)
|
173 |
fad4d1c0
|
taeseongkim
|
{
|
174 |
|
|
parameters = new DialogParameters()
|
175 |
|
|
{
|
176 |
|
|
Content = "선택된 마크업이 없습니다.",
|
177 |
|
|
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault()
|
178 |
|
|
};
|
179 |
|
|
}
|
180 |
|
|
|
181 |
|
|
RadWindow.Alert(parameters);
|
182 |
|
|
}
|
183 |
|
|
}
|
184 |
|
|
|
185 |
84190963
|
taeseongkim
|
private void OnDelVPCommentCommand(object obj)
|
186 |
|
|
{
|
187 |
|
|
if(obj is Telerik.Windows.Controls.GridView.GridViewRow)
|
188 |
|
|
{
|
189 |
|
|
selectedComment = (obj as Telerik.Windows.Controls.GridView.GridViewRow).DataContext as VpCommant;
|
190 |
|
|
|
191 |
|
|
var parameters = new DialogParameters()
|
192 |
|
|
{
|
193 |
|
|
Content = "해당 Comment를 삭제 하시겠습니까?",
|
194 |
|
|
Closed = new EventHandler<WindowClosedEventArgs>(OnDelVPCommentWindowClosed),
|
195 |
|
|
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault(),
|
196 |
|
|
|
197 |
|
|
};
|
198 |
|
|
|
199 |
|
|
RadWindow.Confirm(parameters);
|
200 |
|
|
}
|
201 |
|
|
}
|
202 |
|
|
|
203 |
|
|
private void OnSelectedVPCommentCommand(object obj)
|
204 |
|
|
{
|
205 |
|
|
if (SelectVPComment != null)
|
206 |
|
|
{
|
207 |
|
|
var iditems = SelectVPComment.commentId.Split(',');
|
208 |
|
|
|
209 |
|
|
var selectComments = Common.ViewerDataModel.Instance.MarkupControls_USER.Where(x=>iditems.Count(y=> y == x.CommentID) > 0).ToList();
|
210 |
|
|
|
211 |
c47493ca
|
taeseongkim
|
if (selectComments.Count() > 0)
|
212 |
84190963
|
taeseongkim
|
{
|
213 |
c47493ca
|
taeseongkim
|
var infoList = Common.ViewerDataModel.Instance.MyMarkupList.Where(f => f.MarkupInfoID == selectComments.First().MarkupInfoID);
|
214 |
84190963
|
taeseongkim
|
|
215 |
c47493ca
|
taeseongkim
|
if (infoList.Count() > 0)
|
216 |
|
|
{
|
217 |
|
|
Common.ViewerDataModel.Instance.PageBalanceNumber = infoList.First().PageNumber;
|
218 |
|
|
selectComments.First().IsSelected = true;
|
219 |
|
|
GotoMarkup(selectComments);
|
220 |
|
|
|
221 |
|
|
}
|
222 |
84190963
|
taeseongkim
|
}
|
223 |
|
|
|
224 |
|
|
//selectedComment
|
225 |
|
|
//SelectionSet.Instance.SelectControl = selectedComment;
|
226 |
|
|
|
227 |
|
|
//if (instanceFavoVP.PAGE_NO == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber)
|
228 |
|
|
//{
|
229 |
|
|
// Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("You have selected the current page", "Notice");
|
230 |
|
|
//}
|
231 |
|
|
//else
|
232 |
|
|
//{
|
233 |
|
|
// Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(instanceFavoVP.PAGE_NO);
|
234 |
|
|
//}
|
235 |
|
|
}
|
236 |
|
|
}
|
237 |
|
|
|
238 |
c47493ca
|
taeseongkim
|
private void GotoMarkup(IEnumerable<MarkupToPDF.Common.CommentUserInfo> commentUserInfo)
|
239 |
|
|
{
|
240 |
|
|
if (commentUserInfo?.Count() > 0)
|
241 |
|
|
{
|
242 |
|
|
var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
|
243 |
|
|
|
244 |
|
|
try
|
245 |
|
|
{
|
246 |
|
|
foreach (var instance in commentUserInfo)
|
247 |
|
|
{
|
248 |
|
|
SelectionSet.Instance.SelectItemByRect(instance.ItemRect, main);
|
249 |
|
|
main.zoomAndPanControl.ZoomTo(instance.ItemRect);
|
250 |
|
|
}
|
251 |
|
|
}
|
252 |
|
|
catch (Exception ex)
|
253 |
|
|
{
|
254 |
|
|
main.DialogMessage_Alert(ex.Message, "Error");
|
255 |
|
|
}
|
256 |
|
|
}
|
257 |
|
|
}
|
258 |
|
|
|
259 |
84190963
|
taeseongkim
|
private void OnVpCommentSelectCommand(object x)
|
260 |
|
|
{
|
261 |
|
|
throw new NotImplementedException();
|
262 |
|
|
}
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
private VpCommant selectedComment;
|
266 |
|
|
|
267 |
|
|
private async void OnDelVPCommentWindowClosed(object sender, WindowClosedEventArgs e)
|
268 |
|
|
{
|
269 |
|
|
VpCommant deleteComment = selectedComment;
|
270 |
|
|
selectedComment = null;
|
271 |
|
|
|
272 |
|
|
if (e.DialogResult == true)
|
273 |
|
|
{
|
274 |
|
|
try
|
275 |
|
|
{
|
276 |
|
|
string projectNo = App.ViewInfo.ProjectNO;
|
277 |
|
|
string docId = App.ViewInfo.DocumentItemID;
|
278 |
|
|
string mdId = deleteComment.mdId;
|
279 |
|
|
string userId = deleteComment.createdBy;
|
280 |
|
|
string commentId = deleteComment.commentId;
|
281 |
|
|
|
282 |
|
|
var result = await pemssServiceClient.RemoveRequirementCommentAsync(projectNo, docId, mdId, commentId, userId);
|
283 |
|
|
|
284 |
|
|
}
|
285 |
|
|
catch (Exception)
|
286 |
|
|
{
|
287 |
c47493ca
|
taeseongkim
|
//MessageBox.Show("삭제 오류");
|
288 |
84190963
|
taeseongkim
|
}
|
289 |
|
|
|
290 |
|
|
await OnGetRequirementDataAsync();
|
291 |
|
|
}
|
292 |
|
|
}
|
293 |
|
|
|
294 |
fad4d1c0
|
taeseongkim
|
private async void OnAddVpCommantWindowClosed(object sender, WindowClosedEventArgs e)
|
295 |
|
|
{
|
296 |
|
|
if(e.DialogResult == true)
|
297 |
|
|
{
|
298 |
84190963
|
taeseongkim
|
var addrequirement = sender as Views.AddRequirement;
|
299 |
|
|
|
300 |
|
|
if(string.IsNullOrWhiteSpace(addrequirement.Comment))
|
301 |
fad4d1c0
|
taeseongkim
|
{
|
302 |
|
|
var parameters = new DialogParameters()
|
303 |
|
|
{
|
304 |
|
|
Content = "코멘트가 없습니다.",
|
305 |
|
|
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault()
|
306 |
|
|
};
|
307 |
|
|
|
308 |
|
|
RadWindow.Alert(parameters);
|
309 |
|
|
return;
|
310 |
|
|
}
|
311 |
|
|
|
312 |
84190963
|
taeseongkim
|
string commentOnMarkup = addrequirement.Comment;
|
313 |
fad4d1c0
|
taeseongkim
|
|
314 |
84190963
|
taeseongkim
|
string markupId = string.Join(",",SelectionSet.Instance.SelectedItems.Select(f => f.CommentID));
|
315 |
fad4d1c0
|
taeseongkim
|
string projectNo = App.ViewInfo.ProjectNO;
|
316 |
|
|
string docId = App.ViewInfo.DocumentItemID;
|
317 |
|
|
string mdId = SelectRequirement.mdId;
|
318 |
3a4649f8
|
taeseongkim
|
string userId = App.PEMSSInfo.UserID;
|
319 |
fad4d1c0
|
taeseongkim
|
|
320 |
84190963
|
taeseongkim
|
bool condition = addrequirement.IsContition;
|
321 |
fad4d1c0
|
taeseongkim
|
|
322 |
|
|
var result = await pemssServiceClient.SetRequirementCommentAsync(projectNo,docId,mdId,markupId,commentOnMarkup,condition,userId);
|
323 |
84190963
|
taeseongkim
|
|
324 |
|
|
await OnGetRequirementDataAsync();
|
325 |
fad4d1c0
|
taeseongkim
|
}
|
326 |
|
|
}
|
327 |
|
|
|
328 |
|
|
#endregion Command
|
329 |
|
|
|
330 |
|
|
}
|
331 |
|
|
} |