Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
/*
 * 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;
            }
        }
Ejemplo n.º 3
0
        // 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");
        }