private void SAP_deleteSapRole (System.Collections.Specialized.NameValueCollection P, HttpResponse httpResponse) { // SHOULD WE DISALLOW THIS IF THE MIRROR ITEM IS STILL IN USE ON BUSROLE SIDE? ISAProle engine = new ISAProle(CONNdedicated); returnGetSAProle trashee = engine.GetSAProle(int.Parse(P["id"])); // STEP 1: Try to delete its matching mirror image on the business side. // This is a TRUE deletion, not just an "X" status. // But this will THROW AN EXCEPTION if the item is in use in any way, even historically. SAP_HELPERS.DeleteMatchingBusinessEntitlementForSAPRole(trashee); // STEP 1: Rename the subprocess by adding the //DEL_... suffix, and also // move it into the trashcan subprocess. engine.SetSAProle( trashee.ID, trashee.Name + "//DEL_" + trashee.ID.ToString() + "//SUBPR_" + trashee.SubProcessID, trashee.Description, int.Parse(ConfigurationManager.AppSettings["IDsubprocessTrashcan"]), trashee.System, trashee.Platform, trashee.RoleActivity, trashee.RoleType, trashee.Comment); }
/* * 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; } }
// Creates or Updates a business role object. // Alos, if necessary, creates new user objects for role ownership private void JQDLGsaproleProperties (System.Collections.Specialized.NameValueCollection pars, HttpResponse httpResponse) { ISAProle engineBR = new ISAProle(CONNdedicated); ISAProle engine = engineBR; int idsaprole; if (pars["JQDLGbp_id"].Length == 0) { // WE ARE CREATING A NEW ROLE, NOT JUST UPDATING EXISTING int babyid = -1; // Make sure not already existing returnListSAProle[] chk = engineBR.ListSAProle(null, "(\"Name\" = ?) and (\"System\" = ?) and (\"Platform\" = ?)", new string[] { pars["JQDLGbp_name"], pars["JQDLGbp_system"], pars["JQDLGbp_platform"] }, ""); if (chk.Length > 0) { // Already in existence! returnListSAProle details = chk[0]; if (details.SubProcessID == session.idSubprocess) { // And this existing role is even in the same subprocess! throw new Exception("This SAP role already exists and is registered with this very same subprocess."); } else { // Oh, belongs to a different subprocess. IProcess engineProcess = new IProcess(engineBR.DbConnection); ISubProcess engineSubProcess = new ISubProcess(engineBR.DbConnection); returnGetSubProcess theSubProcess = engineSubProcess.GetSubProcess(details.SubProcessID); returnGetProcess theProcess = engineProcess.GetProcess(theSubProcess.ProcessID); throw new Exception ("This SAP role already exists, in a different subprocess: " + theProcess.Name + " / " + theSubProcess.Name); } } try { babyid = engine.NewSAProle( pars["JQDLGbp_name"], session.idSubprocess, pars["JQDLGbp_system"], pars["JQDLGbp_platform"]); } catch (Exception eee) { throw new Exception("Addition of new role failed: check for name already in use."); } idsaprole = babyid; } else { returnListSAProle[] chk = engineBR.ListSAProle(null, "(\"id\" <> ?) AND (\"Name\" = ?)", new string[] { pars["JQDLGbp_id"], pars["JQDLGbp_name"] }, ""); if (chk.Length > 0) { throw new Exception("Name '" + pars["JQDLGbp_name"] + "' is already in use for an existing SAP role."); } idsaprole = int.Parse(pars["JQDLGbp_id"]); } engineBR.SetSAProle( idsaprole, pars["JQDLGbp_name"], pars["JQDLGbp_description"], session.idSubprocess, pars["JQDLGbp_system"], pars["JQDLGbp_platform"], pars["JQDLGbp_roleactivity"], pars["JQDLGbp_roletype"], ""); // ADDED to fix regression, on 09MAR2010: returnGetSAProle saprolePostAction = engine.GetSAProle(idsaprole); SAP_HELPERS.MaintainMatchingBusinessEntitlementForSAPRole(saprolePostAction, saprolePostAction); httpResponse.Write("OK"); }
public static void ImportDataTableAsNewTcodeAssignmentSet( DataTable dt, int IDuser, int IDsubpr, System.Data.Odbc.OdbcConnection conn) { IUser Iuser = new IUser(conn); ISubProcess Isubpr = new ISubProcess(conn); ITcodeAssignmentSet Ieaset = new ITcodeAssignmentSet(conn); ITcodeAssignment Iea = new ITcodeAssignment(conn); ITcodeEntitlement Ientit = new ITcodeEntitlement(conn); ITcodeDictionary Idict = new ITcodeDictionary(conn); ISAProle Isr = new ISAProle(conn); int IDneweas = Ieaset.NewTcodeAssignmentSet (false, DateTime.Now, "Import from CSV", IDsubpr, IDuser); // These Get function are only useful for a read-only view of fields; // not for generating subordinate entities. returnGetTcodeAssignmentSet neweas = Ieaset.GetTcodeAssignmentSet(IDneweas); IEnumerator <System.Data.DataRow> x = (IEnumerator <System.Data.DataRow>)dt.Rows.GetEnumerator(); while (x.MoveNext()) { int IDsaprole; int IDtcode; if (x.Current[0].Equals(System.DBNull.Value)) { // Ignore any line with no value in the first field. // Often the end of the csv file has just lots of blank rows. continue; } // Make sure SAP role object exists; create if not. string saprole = (string)(x.Current["SAProle"]); RBSR_AUFW.DB.ISAProle.returnListSAProle[] xx = Isr.ListSAProle(null, "\"Name\" like ?", new string[] { saprole }, ""); if (xx.Length < 1) { // MUST ADD NEW ONE IDsaprole = Isr.NewSAProle(saprole, IDsubpr); } else { IDsaprole = xx[0].ID; } // Make sure Tcode exists in the Tcode dictionary string tcodeshortname = (string)(x.Current["TCODE Value"]); returnListTcodeDictionary[] xxx = Idict.ListTcodeDictionary (null, "\"TcodeID\" like ?", new string[] { tcodeshortname }, ""); if (xxx.Length < 1) { // MUST ADD NEW ONE IDtcode = Idict.NewTcodeDictionary(tcodeshortname, x.Current["TCODE Description"] as string); } else { IDtcode = xxx[0].ID; } int IDnewent = Ientit.NewTcodeEntitlement( x.Current["Standard Activity"] as string, x.Current["Type"] as string, x.Current["System"] as string, x.Current["Platform"] as string, IDtcode); Ientit.SetTcodeEntitlement(IDnewent, x.Current["Standard Activity"] as string, x.Current["Type"] as string, x.Current["System"] as string, x.Current["Platform"] as string, x.Current["AuthObj Name"] as string, x.Current["AuthObj Description"] as string, x.Current["Field-Level Security Value Description"] as string, x.Current["Field-Level Security Value"] as string, x.Current["Additional Comments"] as string, IDtcode); int IDnewentass = Iea.NewTcodeAssignment(IDneweas, IDsaprole, IDnewent); } }