示例#1
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");
        }
示例#2
0
        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);
            }
        }