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);
        }
        protected void ONCLICK_BulkRemove(object sender, EventArgs e)
        {
            if (this.FileUpload_BulkRemove.HasFile)
            {
                string pathTempFolder = System.IO.Path.GetTempPath();
                string pathTempFile   = System.IO.Path.GetTempFileName();
                FileUpload_BulkRemove.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 has more than two columns.");
                    }


                    Queue RETmsgs = new Queue();

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

                    int recordseq = 0;
                    int okCount   = 0;

                    IBusRole       ENGINEbusrole = new IBusRole(HELPERS.NewOdbcConn());
                    IEntitlement   ENGINE        = new IEntitlement(HELPERS.NewOdbcConn());
                    IEntAssignment IEA           = new IEntAssignment(HELPERS.NewOdbcConn());


                    while (x.MoveNext())
                    {
                        recordseq++;

                        string rolename   = x.Current[0].ToString();
                        string privstring = x.Current[1].ToString();

                        try
                        {
                            HELPERS.RemoveEntitlementFromRole(rolename, privstring, ENGINEbusrole, ENGINE, IEA);
                            okCount++;
                        }
                        catch (Exception ee)
                        {
                            RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": " + ee.Message);
                        }
                    }
                    RETmsgs.Enqueue("------------------");
                    RETmsgs.Enqueue("Number of records processed without message: " + 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;
                    }
                }
            }
        }
Exemple #3
0
        public void OnItemCheckChanged(object sender, GridItemCheckChangedEventArgs oArgs)
        {
            IEntAssignment ENGINEentass = new IEntAssignment(HELPERS.NewOdbcConn());

            int IDentitlement = int.Parse(oArgs.Item["c_id"].ToString());

            string editstatusEAss = "-";
            int    idEntAss       = -1;

            if (oArgs.Item["TEassEditStatus"] != null)
            {
                if (oArgs.Item["TEassEditStatus"].ToString() != "")
                {
                    editstatusEAss = oArgs.Item["TEassEditStatus"].ToString();
                    idEntAss       = int.Parse(oArgs.Item["TEassRowId"].ToString());
                }
            }


            if (oArgs.Checked)
            {
                if (idEntAss >= 0)
                {
                    returnGetEntAssignment curval = ENGINEentass.GetEntAssignment(idEntAss);
                    ENGINEentass.SetEntAssignment(idEntAss, curval.EntAssignmentSetID, curval.BusRoleID, curval.EntitlementID,
                                                  "A");/*ACTIVE*/
                }
                else
                {
                    // Create a EAss
                    int baby = ENGINEentass.NewEntAssignment(session.idWorkspace, IDrole, IDentitlement, "N");
                    MAPentIdToBabyEAssId.Add(IDentitlement, baby);
                }
            }
            else
            {
                if (idEntAss < 0)
                {
                    if (MAPentIdToBabyEAssId.ContainsKey(IDentitlement))
                    {
                        idEntAss       = MAPentIdToBabyEAssId[IDentitlement];
                        editstatusEAss = "N";
                        MAPentIdToBabyEAssId.Remove(IDentitlement);
                    }
                }
                if (editstatusEAss == "N")
                {
                    try
                    {
                        ENGINEentass.DeleteEntAssignment(idEntAss);
                    }
                    catch (Exception eee)
                    {
                        // Exceptions will occur here naturally, if during a session where row R was
                        // initially unchecked, someone checked it, and then unchecked it back to its
                        // original unchecked state, and then hits submit.
                        ENGINEentass.DeleteEntAssignment(
                            MAPentIdToBabyEAssId[IDentitlement]);
                        MAPentIdToBabyEAssId.Remove(IDentitlement);
                    }
                }
                else
                {
                    returnGetEntAssignment curval = ENGINEentass.GetEntAssignment(idEntAss);
                    ENGINEentass.SetEntAssignment(idEntAss, curval.EntAssignmentSetID, curval.BusRoleID, curval.EntitlementID,
                                                  "X");
                }
            }
        }
Exemple #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;
            }
        }
Exemple #5
0
        /* Warning: this is still singleton-based */

        /* This just takes whatever is the active EAS for the given subprocess,
         * but probably should receive the EAS ID as input.
         */
        public static void WorkspaceCreate(OdbcConnection conn, int IDsubprocess, string commentary)
        {
            IEditingWorkspace Iws = new IEditingWorkspace(conn);

            // BUG: hardwired user ID!
            int IDnewWS = Iws.NewEditingWorkspace(commentary, DateTime.Now, IDsubprocess, 1);


            // Still singleton!!
            EmptyTable(conn, "t_r_BusRoleWorkspaceEntitlement");
            EmptyTable(conn, "WorkspaceEntitlement");


            IWorkspaceEntitlement Iwserows = new IWorkspaceEntitlement(conn);
            IEntAssignmentSet     Ieas     = new IEntAssignmentSet(conn);
            IEntitlement          Ient     = new IEntitlement(conn);

            /* See above comment: this hardwared active=true logic is not good */
            returnListEntAssignmentSetBySubProcess[] _IDeas =
                Ieas.ListEntAssignmentSetBySubProcess(null, "\"BOOLisActive\" = 1", new string[] { }, "", IDsubprocess);
            int IDeas = _IDeas[0].ID;


            /* Find the list of EAssignments to bring over to the Workspace */
            IEntAssignment Iea = new IEntAssignment(conn);

            returnListEntAssignmentByEntAssignmentSet[] _IDea =
                Iea.ListEntAssignmentByEntAssignmentSet(null, "", new string[] {}, "", IDeas);
            int numToConvert = _IDea.Length;

            Hashtable dictEntVectorClones = new Hashtable();

            foreach (returnListEntAssignmentByEntAssignmentSet i in _IDea)
            {
                int IDentitlementVector = i.EntitlementID;
                int IDbusrole           = i.BusRoleID;
                int IDcloneEntVector    = -88;

                if (dictEntVectorClones.ContainsKey(IDentitlementVector))
                {
                    // The entitlement vector was already cloned in the workspace.
                    IDcloneEntVector =
                        (int)dictEntVectorClones[IDentitlementVector];
                }
                else
                {
                    // MUST CLONE THE VECTOR
                    returnGetEntitlement theE = Ient.GetEntitlement(IDentitlementVector);

                    IDcloneEntVector =
                        Iwserows.NewWorkspaceEntitlement
                            (theE.StandardActivity,
                            theE.RoleType,
                            theE.System,
                            theE.Platform,
                            theE.EntitlementName,
                            theE.EntitlementValue,
                            IDnewWS);

                    dictEntVectorClones.Add(IDentitlementVector, IDcloneEntVector);
                }

                // We have the bus.role ID and we now have the ID of the
                // WorkspaceEntitlement object.
                // We now create the tie that binds them.
                RecordLinkFromBusRoleToWSEntitVector
                    (conn, IDbusrole, IDcloneEntVector, IDnewWS);
            }
        }
Exemple #6
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);
                }
            }
        }
Exemple #7
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;
            }
        }
        /* This is called when the user submits the page's changes.
         * It is called once for each checkbox change being submitted.
         * If necessary, a workspace is launched for the relevant subprocess.
         * If the subprocess already contains a workspace but it's owned
         * by some other user, the change is not made and the user
         * is alerted, but the process of executing the set of changes is
         * not aborted.
         *
         * mimic this to create the automatic workspace creation:
         * AutoRemoveEntitlementStatus in GuidedEditor/...
         */

        public void OnAfterCallback(object sender, EventArgs oArgs)
        {
            if (this.boolMustAbort)
            {
                Grid1.CallbackParameter = "OPERATION ABORTED:\n" + messages;
                return;
            }


            Dictionary <int, HELPERS.infoEASet> readyToUseWorkspaces = new Dictionary <int, HELPERS.infoEASet>();
            Dictionary <int, HELPERS.infoEASet> lockedWorkspaces     = new Dictionary <int, HELPERS.infoEASet>();

            if (messages.Length > 0)
            {
                messages += "\n-------------------------\n\n";
            }

            HELPERS.AutoGenWorkspacesInBulk
                (session.idUser, ref messages, MAPsubprToEASet, readyToUseWorkspaces, lockedWorkspaces,
                "facilitate bulk role assignment/unassignment for a particular entitlement");

            // If any problem occurred at all, we abort!
            if (lockedWorkspaces.Count > 0)
            {
                Grid1.CallbackParameter = messages;
                return;
            }


            // We now proceed with the actual edits.
            IEntAssignment ENGINEentass = new IEntAssignment(HELPERS.NewOdbcConn());

            while (QUEUEidsBusrolesToREMOVE.Count > 0)
            {
                int idBusrole = QUEUEidsBusrolesToREMOVE.Dequeue();
                int idSubpr   = MAPbroleToSubproc[idBusrole];
                messages += "Detaching from this role: " + MAPbroleIdToName[idBusrole] + "\n";
                HELPERS.infoEASet wstouse = readyToUseWorkspaces[idSubpr];

                returnListEntAssignmentByEntAssignmentSet[] theEAss =
                    ENGINEentass.ListEntAssignmentByEntAssignmentSet
                        (null, "\"BusRole\" = ? AND \"Entitlement\" = ? ", new string[] { idBusrole.ToString(), IDentitlement.ToString() }, "", wstouse.idEntAssSet);

                ENGINEentass.SetEntAssignment
                    (theEAss[0].ID, theEAss[0].EntAssignmentSetID, theEAss[0].BusRoleID,
                    theEAss[0].EntitlementID, "X");
            }
            while (QUEUEidsBusrolesToADD.Count > 0)
            {
                int idBusrole = QUEUEidsBusrolesToADD.Dequeue();
                int idSubpr   = MAPbroleToSubproc[idBusrole];
                messages += "Attaching to this role: " + MAPbroleIdToName[idBusrole] + "\n";
                HELPERS.infoEASet wstouse = readyToUseWorkspaces[idSubpr];

                returnListEntAssignmentByEntAssignmentSet[] theEAss =
                    ENGINEentass.ListEntAssignmentByEntAssignmentSet
                        (null, "\"BusRole\" = ? AND \"Entitlement\" = ? ", new string[] { idBusrole.ToString(), IDentitlement.ToString() }, "", wstouse.idEntAssSet);

                if (theEAss.GetLength(0) > 1)
                {
                    throw new Exception("Workspace " + wstouse.idEntAssSet + " contains multiple entitlement assignment records for business role " + idBusrole);
                }
                else if (theEAss.GetLength(0) == 1)
                {
                    switch (theEAss[0].Status)
                    {
                    case "A":
                        messages += "Nothing to do. Workspace already has this match in place.\n";
                        break;

                    case "N":
                        messages += "Nothing to do. Workspace already has this match in place.\n";
                        break;

                    case "X":
                        ENGINEentass.SetEntAssignment
                            (theEAss[0].ID, theEAss[0].EntAssignmentSetID, theEAss[0].BusRoleID,
                            theEAss[0].EntitlementID, "N");
                        break;
                    }
                }
                else
                {
                    int baby = ENGINEentass.NewEntAssignment
                                   (wstouse.idEntAssSet, idBusrole, IDentitlement, "N");
                }
            }



            if (messages.Length == 0)
            {
                messages = "NO MESSAGES TO REPORT.";
            }
            Grid1.CallbackParameter = messages;
        }