markus / KCOM / ViewModel / RequirementViewModel.cs @ 3a4649f8
이력 | 보기 | 이력해설 | 다운로드 (5.41 KB)
1 |
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 |
|
61 |
public AsyncCommand RefreshCommand => new AsyncCommand(()=> OnGetRequirementDataAsync()); |
62 |
|
63 |
public RelayCommand AddVPCommentCommand => new RelayCommand(x => OnAddVPCommentCommand()); |
64 |
|
65 |
|
66 |
#region 초기화 및 종료 이벤트 |
67 |
|
68 |
public RequirementViewModel() |
69 |
{ |
70 |
if (pemssServiceClient == null) |
71 |
{ |
72 |
pemssServiceClient = new PemssServiceClient(); |
73 |
} |
74 |
|
75 |
OnGetRequirementDataAsync().ConfigureAwait(false); |
76 |
} |
77 |
|
78 |
public override void Loaded() |
79 |
{ |
80 |
base.Loaded(); |
81 |
} |
82 |
|
83 |
public override void Closed() |
84 |
{ |
85 |
base.Closed(); |
86 |
} |
87 |
|
88 |
#endregion |
89 |
|
90 |
#region Command |
91 |
private async Task OnGetRequirementDataAsync() |
92 |
{ |
93 |
var result = await pemssServiceClient.GetrequirementListAsync(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
94 |
|
95 |
requirementList.Clear(); |
96 |
result.ForEach(x => |
97 |
{ |
98 |
x.IsExpanded = true; |
99 |
x.IsExpandable = false; |
100 |
RequirementList.Add(x); |
101 |
}); |
102 |
} |
103 |
|
104 |
|
105 |
private void OnAddVPCommentCommand() |
106 |
{ |
107 |
if (SelectRequirement != null && SelectionSet.Instance.SelectedItems?.Count() > 0) |
108 |
{ |
109 |
var parameters = new DialogParameters() |
110 |
{ |
111 |
ContentStyle = (Style)App.Current.Resources["AddVpCommantWindowStyle"], |
112 |
Content = "마크업에 대한 코멘트 : ", |
113 |
Closed = new EventHandler<WindowClosedEventArgs>(OnAddVpCommantWindowClosed), |
114 |
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault() |
115 |
}; |
116 |
|
117 |
RadWindow.Prompt(parameters); |
118 |
} |
119 |
else |
120 |
{ |
121 |
DialogParameters parameters = null; |
122 |
|
123 |
if (SelectRequirement == null) |
124 |
{ |
125 |
parameters = new DialogParameters() |
126 |
{ |
127 |
Content = "추가할 정합성을 선택해야 합니다.", |
128 |
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault() |
129 |
}; |
130 |
} |
131 |
|
132 |
if (SelectionSet.Instance.SelectedItems?.Count() > 0) |
133 |
{ |
134 |
parameters = new DialogParameters() |
135 |
{ |
136 |
Content = "선택된 마크업이 없습니다.", |
137 |
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault() |
138 |
}; |
139 |
} |
140 |
|
141 |
RadWindow.Alert(parameters); |
142 |
} |
143 |
} |
144 |
|
145 |
private async void OnAddVpCommantWindowClosed(object sender, WindowClosedEventArgs e) |
146 |
{ |
147 |
if(e.DialogResult == true) |
148 |
{ |
149 |
if(string.IsNullOrWhiteSpace(e.PromptResult)) |
150 |
{ |
151 |
var parameters = new DialogParameters() |
152 |
{ |
153 |
Content = "코멘트가 없습니다.", |
154 |
Owner = App.Current.Windows.Cast<System.Windows.Window>().FirstOrDefault() |
155 |
}; |
156 |
|
157 |
RadWindow.Alert(parameters); |
158 |
return; |
159 |
} |
160 |
|
161 |
string commentOnMarkup = e.PromptResult?.ToString(); |
162 |
|
163 |
string markupId = string.Join(",",SelectionSet.Instance.SelectedItems.Select(f => f.MarkupInfoID)); |
164 |
string projectNo = App.ViewInfo.ProjectNO; |
165 |
string docId = App.ViewInfo.DocumentItemID; |
166 |
string mdId = SelectRequirement.mdId; |
167 |
string userId = App.PEMSSInfo.UserID; |
168 |
|
169 |
bool condition = true; |
170 |
|
171 |
var result = await pemssServiceClient.SetRequirementCommentAsync(projectNo,docId,mdId,markupId,commentOnMarkup,condition,userId); |
172 |
} |
173 |
} |
174 |
|
175 |
#endregion Command |
176 |
|
177 |
} |
178 |
} |