コード例 #1
0
        // Updates a business role object and if necessary creates new user objects for role ownership
        private void JQDLGbusroleProperties(System.Collections.Specialized.NameValueCollection pars, HttpResponse httpResponse)
        {
            IBusRole engineBR = new IBusRole(CONNdedicated);
            IBusRole engine   = engineBR;

            int idbusrole;

            if (pars["JQDLGbp_id"].Length == 0)
            {
                // WE ARE CREATING A NEW BUS ROLE, NOT JUST UPDATING EXISTING

                int babyid = -1;

                try
                {
                    babyid =
                        engine.NewBusRole(
                            pars["JQDLGbp_name"],
                            pars["JQDLGbp_descr"], session.idSubprocess);
                }
                catch (Exception eee)
                {
                    throw new Exception("Addition of new role failed: check for name already in use.");
                }
                idbusrole = babyid;
                // Default role type: Functional
                engineBR.SetBusRole(idbusrole, "F");
            }
            else
            {
                returnListBusRole[] chk =
                    engineBR.ListBusRole(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 business role.");
                }

                idbusrole = int.Parse(pars["JQDLGbp_id"]);
            }



            engineBR.SetBusRole(
                idbusrole,
                pars["JQDLGbp_name"],
                pars["JQDLGbp_descr"],
                pars["JQDLGbp_primown_eid"],
                pars["JQDLGbp_secown_eid"],
                pars["JQDLGbp_designdetails"]);
            engineBR.SetBusRole(idbusrole, pars["JQDLGbp_roletype"]);

            httpResponse.Write("OK");
        }
コード例 #2
0
        private void CloneBusRole(int idBusRole, string newBusRoleName, int idWorkspace, HttpResponse response)
        {
            IBusRole       engineBR  = new IBusRole(HELPERS.NewOdbcConn_FORCE());
            IEntAssignment engineEAS = new IEntAssignment(HELPERS.NewOdbcConn_FORCE());

            returnGetBusRole detailsBusRole = engineBR.GetBusRole(idBusRole);

            int idNewBRole;

            try
            {
                idNewBRole = engineBR.NewBusRole(newBusRoleName,
                                                 detailsBusRole.Description, detailsBusRole.SubProcessID);
                // Also copy over the notes and the owner info as well.
                engineBR.SetBusRole
                    (idNewBRole, newBusRoleName, detailsBusRole.Description,
                    detailsBusRole.OwnerPrimaryEID, detailsBusRole.OwnerSecondaryEID, detailsBusRole.DesignDetails);
                engineBR.SetBusRole(idNewBRole, detailsBusRole.RoleType_Abbrev);
            }
            catch (Exception exxx)
            {
                response.Write("ERROR: The given name was found to already be in use.");
                return;
            }

            returnListEntAssignmentByEntAssignmentSet[] ret =
                engineEAS.ListEntAssignmentByEntAssignmentSet(null, " \"BusRole\" = ? AND \"Status\" NOT IN ('X') ",
                                                              new string[] { idBusRole.ToString() }, "", idWorkspace);

            for (int i = 0; i < ret.Length; i++)
            {
                engineEAS.NewEntAssignment
                (
                    idWorkspace, idNewBRole, ret[i].EntitlementID, "N");
            }

            response.Write("The role was successfully cloned.  Number of entitlement assignments: " +
                           ret.Length);
        }
コード例 #3
0
        ONCLICK_BulkUploadNewBusRoles(object sender, EventArgs e)
        {
            IBusRoleOwner ENGINEbrown = new IBusRoleOwner(HELPERS.NewOdbcConn());
            IBusRole      ENGINEbr    = new IBusRole(HELPERS.NewOdbcConn());


            if (this.FileUpload_AddRoles.HasFile)
            {
                string pathTempFolder = System.IO.Path.GetTempPath();
                string pathTempFile   = System.IO.Path.GetTempFileName();
                FileUpload_AddRoles.SaveAs(pathTempFile);
                DataTable dt = HELPERS.LoadCsv(pathTempFolder,
                                               System.IO.Path.GetFileName(pathTempFile));
                if (dt != null)
                {
                    if (dt.Columns.Count < 2)
                    {
                        throw new Exception("The uploaded CSV file must have at least the name and description columns.  (It can optionally also have the two approver/owner columns.)");
                    }


                    Queue RETmsgs = new Queue();

                    IEnumerator <System.Data.DataRow> x =
                        (IEnumerator <System.Data.DataRow>)dt.Rows.GetEnumerator();

                    int recordseq = 0;
                    int okCount   = 0;
                    while (x.MoveNext())
                    {
                        recordseq++;

                        string rolename        = x.Current[0].ToString().Trim();
                        string description     = x.Current[1].ToString().Trim();
                        string roletype        = x.Current[2].ToString().Trim();
                        string primaryApprover = x.Current[3].ToString().Trim().ToUpper();
                        string primaryOwner    = x.Current[4].ToString().Trim().ToUpper();


                        int IDrole = -1;
                        try
                        {
                            IDrole = HELPERS.FindBusRoleByName(rolename);
                        }
                        catch (Exception)
                        {
                            /* The exception is what we WANT!  If this does not throw an exception, this row must be ignored! */
                        }


                        bool doRoleCreation = true;

                        if (IDrole >= 0)
                        {
                            // This role name is already in use somewhere in the system (not nec this subpr).
                            RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": Role already exists, so the only action will be updating of owner/approver info.  Role name: " + rolename);
                            doRoleCreation = false;
                        }

                        int newID = (doRoleCreation ? -1 : IDrole);
                        if (doRoleCreation)
                        {
                            switch (roletype)
                            {
                            case "A":
                                break;

                            case "F":
                                break;

                            case "E":
                                break;

                            default:
                                RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": line ignored due to unknown role-type code: " + roletype);
                                continue;
                            }

                            try
                            {
                                newID = ENGINEbr.NewBusRole(rolename, description, session.idSubprocess);
                                ENGINEbr.SetBusRole(newID, roletype);
                                okCount++;
                            }
                            catch (Exception ee)
                            {
                                RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": " + ee.Message);
                            }
                        }

                        if (newID >= 0)
                        {
                            // New code added Thanksgiving 2012: supporting approver/owner
                            if (primaryOwner.Length > 2)
                            {
                                string __eid        = primaryOwner;
                                string __rank       = "OWNprim";
                                string __rankPretty = "Primary Owner";
                                try
                                {
                                    HELPERS.FindUser(HELPERS.NewOdbcConn(), __eid, __eid, false);
                                    returnListBusRoleOwnerByBusRole[] theList = ENGINEbrown.ListBusRoleOwnerByBusRole(null, newID);
                                    if (theList.Length < 1)
                                    {
                                        ENGINEbrown.NewBusRoleOwner(__eid, "", __rank, newID);
                                    }
                                    else
                                    {
                                        foreach (returnListBusRoleOwnerByBusRole roleowner in theList)
                                        {
                                            if (roleowner.Rank == __rank)
                                            {
                                                ENGINEbrown.DeleteBusRoleOwner(roleowner.ID);
                                            }
                                        }
                                    }
                                }
                                catch (Exception ee)
                                {
                                    RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": ignoring setting of " + __rankPretty + " due to unknown employee ID: " + __eid);
                                }
                            }


                            if (primaryApprover.Length > 2)
                            {
                                string __eid        = primaryApprover;
                                string __rank       = "appr";
                                string __rankPretty = "Primary Approver";
                                try
                                {
                                    HELPERS.FindUser(HELPERS.NewOdbcConn(), __eid, __eid, false);
                                    returnListBusRoleOwnerByBusRole[] theList = ENGINEbrown.ListBusRoleOwnerByBusRole(null, newID);
                                    if (theList.Length < 1)
                                    {
                                        ENGINEbrown.NewBusRoleOwner(__eid, "", __rank, newID);
                                    }
                                    else
                                    {
                                        foreach (returnListBusRoleOwnerByBusRole roleowner in theList)
                                        {
                                            if (roleowner.Rank == __rank)
                                            {
                                                ENGINEbrown.DeleteBusRoleOwner(roleowner.ID);
                                            }
                                        }
                                    }
                                }
                                catch (Exception ee)
                                {
                                    RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": ignoring setting of " + __rankPretty + " due to unknown employee ID: " + __eid);
                                }
                            }
                        }
                    }

                    // -----------------------------------------------

                    RETmsgs.Enqueue("------------------");
                    RETmsgs.Enqueue("Number of NEW business roles created successfully: " + okCount.ToString());
                    if (RETmsgs.Count > 0)
                    {
                        string strMsgs = "";
                        foreach (object objMsg in RETmsgs.ToArray())
                        {
                            strMsgs += "\n" + objMsg.ToString();
                        }
                        TXTimportEngineMessages.Text  = strMsgs;
                        DIVimportFeeback.Visible      = true;
                        PANELcond_AbortUpload.Visible = false;
                        PANELcond_AllowUpload.Visible = false;
                    }
                }
            }
        }
コード例 #4
0
        private void UpdateDb(ComponentArt.Web.UI.GridItem item, string command)
        {
            IBusRole       engine   = new IBusRole(HELPERS.NewOdbcConn());
            IEntAssignment engineEA = new IEntAssignment(HELPERS.NewOdbcConn());



            switch (command)
            {
            case "INSERT":
                ValidateAbbrev(item["c_u_Abbrev"] as string, -1);
                item["c_id"] =
                    engine.NewBusRole(
                        item["c_u_Name"] as string,
                        item["c_u_Description"] as string,
                        this.session.idSubprocess);
                engine.SetBusRole
                (
                    (int)(item["c_id"]),
                    item["c_u_Name"] as string,
                    item["c_u_Description"] as string,
                    this.session.idSubprocess,
                    item["c_u_Abbrev"] as string, null, null, null);
                break;

            case "UPDATE":
                ValidateAbbrev(item["c_u_Abbrev"] as string,
                               int.Parse(item["c_id"] as string));
                engine.SetBusRole
                    (int.Parse(item["c_id"] as string),
                    item["c_u_Name"] as string,
                    item["c_u_Description"] as string,
                    this.session.idSubprocess,
                    item["c_u_Abbrev"] as string);
                break;

            case "DELETE":
                int IDbusrole = int.Parse(item["c_id"] as string);

                // 1. Delete any EntAssignments involving this business role...
                // ... in this workspace... ...that have status "X".
                returnListEntAssignmentByBusRole[] ret = engineEA.ListEntAssignmentByBusRole
                                                             (null, "", new string[] {}, "", IDbusrole);
                int refsStillPresent = 0;
                for (int i = 0; i < ret.Length; i++)
                {
                    if (ret[i].Status == "X")
                    {
                        engineEA.DeleteEntAssignment(ret[i].ID);
                    }
                    else
                    {
                        refsStillPresent++;
                    }
                }

                // 2. Check to see if there are any more references to this bus role
                if (refsStillPresent > 0)
                {
                    throw new Exception
                              ("This business role cannot be deleted at this time, because there is/are still " + refsStillPresent + " reference(s) to this business role, in other workspaces or historical snapshots.");
                }

                // 3. Delete the business role itself.
                engine.DeleteBusRole(IDbusrole);
                break;
            }
        }
コード例 #5
0
        /*
         * The version 2 coalesces vectors that are identical
         * except for the business role.  Right now it uses a simplistic
         * algorithm that includes the commentary column (not a good thing)
         * and that doesn't look for variations that would be considered
         * not important (whitespaces?).
         */
        public static void ImportDataTableAsNewEntAssignmentSet_v2(
            DataTable dt, int IDuser, int IDsubpr, System.Data.Odbc.OdbcConnection conn)
        {
            IUser             Iuser  = new IUser(conn);
            ISubProcess       Isubpr = new ISubProcess(conn);
            IEntAssignmentSet Ieaset = new IEntAssignmentSet(conn);
            IEntAssignment    Iea    = new IEntAssignment(conn);
            IEntitlement      Ientit = new IEntitlement(conn);
            IBusRole          Ibr    = new IBusRole(conn);

            int IDneweas =
                Ieaset.NewEntAssignmentSet(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.
            returnGetEntAssignmentSet neweas = Ieaset.GetEntAssignmentSet(IDneweas);

            IEnumerator <System.Data.DataRow> x =
                (IEnumerator <System.Data.DataRow>)dt.Rows.GetEnumerator();


            Hashtable signatures = new Hashtable();

            while (x.MoveNext())
            {
                int IDbusrole;

                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 business role object exists; create if not.
                string busrole         = (string)(x.Current["BusRole"]);
                returnListBusRole[] xx = Ibr.ListBusRole(null, "\"Name\" like ?",
                                                         new string[] { busrole }, "");
                if (xx.Length < 1)
                {
                    // MUST ADD NEW ONE
                    IDbusrole =
                        Ibr.NewBusRole(busrole, x.Current["Business Role Description"] as string, IDsubpr);
                }
                else
                {
                    IDbusrole = xx[0].ID;
                }


                /* Create a "signature" for this entitlement vector so we can
                 * register it and also see if it's been seen before.
                 */
                string thisSignature =
                    x.Current["Standard Activity"] as string + "/\\" +
                    x.Current["Type"] as string + "/\\" +
                    x.Current["System"] as string + "/\\" +
                    x.Current["Platform"] as string + "/\\" +
                    x.Current["Entitlement Description"] as string + "/\\" +
                    x.Current["Entitlement Value"] as string + "/\\" +
                    "" + "/\\" +
                    x.Current["Authorization Object"] as string + "/\\" +
                    x.Current["Field-Level Security Name"] as string + "/\\" +
                    x.Current["Field-Level Security Value"] as string + "/\\" +
                    x.Current["4th Level Security Name"] as string + "/\\" +
                    x.Current["4th Level Security Value"] as string;

                if (signatures.ContainsKey(thisSignature))
                {
                    // Already seen before, so just add this bus.role
                    // to the list of busroles tied to this.
                    int IDnewent = (int)signatures[thisSignature];

                    int IDnewentass = Iea.NewEntAssignment
                                          (IDneweas, IDbusrole, IDnewent);
                }
                else
                {
                    int IDnewent = Ientit.NewEntitlement(
                        x.Current["Standard Activity"] as string,
                        x.Current["Type"] as string,
                        x.Current["System"] as string,
                        x.Current["Platform"] as string,
                        x.Current["Entitlement Description"] as string,
                        x.Current["Entitlement Value"] as string);

                    Ientit.SetEntitlement(IDnewent,
                                          x.Current["Standard Activity"] as string,
                                          x.Current["Type"] as string,
                                          x.Current["System"] as string,
                                          x.Current["Platform"] as string,
                                          x.Current["Entitlement Description"] as string,
                                          x.Current["Entitlement Value"] as string,
                                          "",
                                          x.Current["Authorization Object"] as string,
                                          x.Current["Field-Level Security Name"] as string,
                                          x.Current["Field-Level Security Value"] as string,
                                          x.Current["4th Level Security Name"] as string,
                                          x.Current["4th Level Security Value"] as string,
                                          x.Current["Additional Comments"] as string,
                                          x.Current["Manifest Value"] as string);

                    int IDnewentass = Iea.NewEntAssignment
                                          (IDneweas, IDbusrole, IDnewent);

                    signatures.Add(thisSignature, IDnewent);
                }
            }
        }
コード例 #6
0
        private void UpdateDb(ComponentArt.Web.UI.GridItem item, string command)
        {
            IBusRole       engine   = new IBusRole(HELPERS.NewOdbcConn());
            IEntAssignment engineEA = new IEntAssignment(HELPERS.NewOdbcConn());



            switch (command)
            {
            case "INSERT":
                ValidateAbbrev(item["c_u_Abbrev"] as string, -1);
                try
                {
                    item["c_id"] =
                        engine.NewBusRole(
                            item["c_u_Name"] as string,
                            item["c_u_Description"] as string,
                            this.session.idSubprocess);
                }
                catch (Exception eee)
                {
                    throw new Exception("Addition of new role failed: check for name already in use.");
                }

                engine.SetBusRole
                (
                    (int)(item["c_id"]),
                    item["c_u_Name"] as string,
                    item["c_u_Description"] as string,
                    this.session.idSubprocess,
                    item["c_u_Abbrev"] as string, null, null, null);
                break;

            case "UPDATE":
                ValidateAbbrev(item["c_u_Abbrev"] as string,
                               int.Parse(item["c_id"] as string));
                engine.SetBusRole
                    (int.Parse(item["c_id"] as string),
                    item["c_u_Name"] as string,
                    item["c_u_Description"] as string,
                    this.session.idSubprocess,
                    item["c_u_Abbrev"] as string);
                break;

            case "DELETE":
                int IDbusrole = int.Parse(item["c_id"] as string);


                // Deleting a role is forbidden only if *this* workspace
                // still has non-"X" entitlement assignments to it.
                //
                // 1. Count the number of non-X entass in this workspace.
                returnListEntAssignmentByBusRole[] ret = engineEA.ListEntAssignmentByBusRole
                                                             (null, " (\"status\" <> ?) AND (\"entassignmentset\" = ?) ", new string[] { "X", this.session.idWorkspace.ToString() }, "", IDbusrole);
                int refsStillPresent = ret.Length;


                // 2. Check to see if there are any more references to this bus role
                if (refsStillPresent > 0)
                {
                    throw new Exception
                              ("This business role cannot be deleted at this time, because there is/are still " + refsStillPresent + " reference(s) to this business role, in other workspaces or historical snapshots.");
                }

                // 3. Delete the business role, but hiding it away in the special
                // "trashcan" subprocess.
                engine.MoveBusRoleToTrashcan(IDbusrole,
                                             int.Parse(ConfigurationManager.AppSettings["IDsubprocessTrashcan"]));

                break;
            }
        }