/
ListSAPRoles.aspx.cs
executable file
·330 lines (236 loc) · 9.48 KB
/
ListSAPRoles.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using RBSR_AUFW.DB.ISAProle;
using RBSR_AUFW.DB.ITcodeAssignmentSet;
namespace _6MAR_WebApplication
{
public partial class ListSAProles : AFWACpage
{
int IDsaprole = -1;
public returnGetTcodeAssignmentSet targetEASet;
protected void Page_Load(object sender, EventArgs e)
{
base.Page_Load(sender, e);
Grid1.UpdateCommand += new ComponentArt.Web.UI.Grid.GridItemEventHandler(this.Grid1_UpdateCommand);
Grid1.DeleteCommand += new ComponentArt.Web.UI.Grid.GridItemEventHandler(this.Grid1_DeleteCommand);
Grid1.InsertCommand += new ComponentArt.Web.UI.Grid.GridItemEventHandler(this.Grid1_InsertCommand);
try
{
session.ObtainWorkspaceContext_SAP();
}
catch (Exception ex)
{
if (ex.Message.Contains("more than one workspace"))
{
Response.Redirect("Page_SAP_History.aspx");
return;
}
}
Session["UUIDSAPTASSSET"] = session.idWorkspace_SAP;
CALLBACKselectCurRole.Callback +=
new ComponentArt.Web.UI.CallBack.CallbackEventHandler(this.OnCallback_SelectCurRole);
GRIDroleowners.NeedRebind += new ComponentArt.Web.UI.Grid.NeedRebindEventHandler(this.OnNeedRebind_GRIDroleowners);
PANELcond_Editable.Visible = false;
PANELcond_ReadOnly.Visible = false;
PANELcond_ViewOtherUserWorkspace.Visible = false;
PANELcond_PublishWorkspace.Visible = false;
PANELcond_ViewActiveReadOnly.Visible = false;
PANELcond_ViewHistoricalReadOnly.Visible = false;
int IDeaset = -1;
ITcodeAssignmentSet engineEASET = new ITcodeAssignmentSet(HELPERS.NewOdbcConn());
// STICKINESS: If the URL does not specifically demand a particular
// workspace via query param, then draw it in from the session parameter.
// Only if no session preference for a particular workspace would you then
// default to the current open-for-editing workspace.
if (this.Request.Params["WSID"] == null)
{
// URL does not explicitly request a particular EASet
if (Session["INTcurWS_SAP"].ToString() != "")
{
IDeaset = int.Parse(Session["INTcurWS_SAP"].ToString());
}
} else {
IDeaset = int.Parse(this.Request.Params["WSID"].ToString());
}
if (IDeaset < 0)
{
// LAST RESORT:
IDeaset = session.idWorkspace_SAP;
}
if (IDeaset != session.idWorkspace_SAP) {
// IMPORTANT: we are going back in time and looking at a frozen state.
// This is NOT a workspace!
Session["INTcurWS_SAP"] = IDeaset;
// Get info about this snapshot
targetEASet = engineEASET.GetTcodeAssignmentSet(IDeaset);
if (targetEASet.Status.ToLower() == "active")
{
PANELcond_ViewActiveReadOnly.Visible = true;
}else{
PANELcond_ViewHistoricalReadOnly.Visible = true;
}
}
else
{
Session["INTcurWS_SAP"] = IDeaset;
if (IDeaset >= 0)
{
// THIS IS A WORKSPACE !!
// THIS IS A WORKSPACE !!
// THIS IS A WORKSPACE !!
// It might not belong to "me" but it is definitely a workspace
targetEASet = engineEASET.GetTcodeAssignmentSet(session.idWorkspace_SAP);
if (session.isWorkspaceOwner_SAP) {
SAP_HELPERS.InitChangeMgmtForWS(session.idWorkspace_SAP);
PANELcond_Editable.Visible = true;
}
else{
PANELcond_ViewOtherUserWorkspace.Visible = true;
}
}
else
{
// There IS no workspace!
PANELcond_ReadOnly.Visible = true;
Grid1.Visible = false;
}
}
}
public void OnNeedRebind_GRIDroleowners(object sender, EventArgs oArgs)
{
GRIDroleowners.DataBind();
}
protected void INTERCEPTsqldatasource_roleowners_select(object sender, SqlDataSourceSelectingEventArgs e)
{
e.Command.Parameters[0].Value = this.IDsaprole;
}
public void OnCallback_SelectCurRole
(object sender,
ComponentArt.Web.UI.CallBackEventArgs e)
{
this.IDsaprole = int.Parse(e.Parameter);
this.GRIDroleowners.DataBind();
this.GRIDroleowners.RenderControl(e.Output);
}
public void EVTHNDL_hidfield_curroleid_changed (Object sender, EventArgs e)
{
EventArgs ee = e;
}
private void Grid1_InsertCommand(object sender, ComponentArt.Web.UI.GridItemEventArgs e)
{
UpdateDb(e.Item, "INSERT");
}
private void Grid1_UpdateCommand(object sender, ComponentArt.Web.UI.GridItemEventArgs e)
{
UpdateDb(e.Item, "UPDATE");
}
private void Grid1_DeleteCommand(object sender, ComponentArt.Web.UI.GridItemEventArgs e)
{
UpdateDb(e.Item, "DELETE");
}
/*
* Although most editing occurs in the ashx handler in the guidededitor folder,
* a few edit activities are still being done via events reported directly from
* the grid widget. This handles all such requests.
*/
private void UpdateDb(ComponentArt.Web.UI.GridItem item, string command)
{
ISAProle engine = new ISAProle(HELPERS.NewOdbcConn());
switch (command)
{
case "INSERT":
int newid;
try
{
newid =
engine.NewSAProle(
item["c_u_Name"] as string,
this.session.idSubprocess,
item["c_u_System"] as string,
item["c_u_Platform"] as string
);
}
catch (Exception e)
{
throw new Exception("Failure occurred. That rolename + platform combination is already in use, whether in this or some other subprocess. Refresh your browser to continue working.");
}
engine.SetSAProle
(
newid,
item["c_u_Name"] as string,
item["c_u_Description"] as string,
this.session.idSubprocess,
item["c_u_System"] as string,
item["c_u_Platform"] as string,
item["c_u_RoleActivity"] as string,
item["c_u_RoleType"] as string, ""
);
returnGetSAProle newval = engine.GetSAProle(newid);
SAP_HELPERS.MaintainMatchingBusinessEntitlementForSAPRole(newval, newval);
break;
case "UPDATE":
if ((item["c_id"] as string) == "")
{
UpdateDb(item, "INSERT");
return;
}
try
{
int IDsaprole = int.Parse(item["c_id"] as string);
returnGetSAProle prevvals = engine.GetSAProle(IDsaprole);
engine.SetSAProle
(IDsaprole,
item["c_u_Name"] as string,
item["c_u_Description"] as string,
this.session.idSubprocess,
item["c_u_System"] as string,
item["c_u_Platform"] as string,
item["c_u_RoleActivity"] as string,
item["c_u_RoleType"] as string, ""
);
returnGetSAProle newvals = engine.GetSAProle(IDsaprole);
SAP_HELPERS.MaintainMatchingBusinessEntitlementForSAPRole
(prevvals, newvals);
}
catch (Exception e)
{
if (e.ToString().Contains("duplicate key"))
{
throw new Exception("That SAP role name + platform combination is already registered, either in this subprocess or another subprocess. Please refresh the webpage to restore the grid contents and try again.");
}
else
{
throw e;
}
}
break;
case "DELETE":
int idToKill = int.Parse(item["c_id"] as string);
returnGetSAProle prevvals2 = engine.GetSAProle(idToKill);
// First, try to delete the matching business entitlement, and alert if that fails due to in-use.
SAP_HELPERS.DeleteMatchingBusinessEntitlementForSAPRole(prevvals2);
// If the above line fails, the rest of this method won't be executed anyway.
try
{
engine.DeleteSAProle(idToKill);
}
catch (Exception exc323)
{
throw new Exception("This SAP role cannot be deleted because it has TCode assignments associated with it (possibly in other workspaces). NOTE: its matching business entitlement HAS been deleted! Refresh this webpage to restore the tabular data, and then continue working.");
}
break;
default:
throw new NotImplementedException();
break;
}
}
}
}