示例#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 CSVgenerate_IDMreconciliation_3column
            (HttpContext context, OdbcDataReader dr, IMVFormula ENGINEmanif, IEntitlement ENGINEwsent,
            bool BOOLgenerateHeader)
        {
            int colnumFormula   = -1;
            int colnumRolename  = -1;
            int colnumRoledescr = -1;

            OdbcConnection tempconn    = HELPERS.NewOdbcConn_FORCE();
            IBusRole       engineBR    = new IBusRole(tempconn);
            IBusRoleOwner  engineBRole = new IBusRoleOwner(tempconn);

            Dictionary <string, bool> DICTboolHaveSeenThisRole = new Dictionary <string, bool>();

            for (int i = 0; i < dr.VisibleFieldCount; i++)
            {
                switch (dr.GetName(i) as string)
                {
                case "Formula":
                    colnumFormula = i;
                    break;

                case "Business_Role_Name":
                    colnumRolename = i;
                    break;

                case "Business_Role_Description":
                    colnumRoledescr = i;
                    break;
                }
            }

            if (BOOLgenerateHeader)
            {
                context.Response.Write("RoleName,Entitlement,ComparisonObject\n");
            }


            // FOR EACH ROW

            while (dr.Read())
            {
                try
                {
                    int IDwsentrow = (int)(dr.GetValue(0));

                    object RESLT;
                    ComputePrivilegeString(context, ENGINEmanif, ENGINEwsent, IDwsentrow, out RESLT);
                    string resultAsStr = RESLT.ToString().Replace(" ", "");

                    // If the first time we are seeing this role, emit its description text.
                    if (!DICTboolHaveSeenThisRole.ContainsKey(dr.GetValue(colnumRolename) as string))
                    {
                        string rolename = dr.GetValue(colnumRolename) as string;
                        context.Response.Write(CSVquoteize(rolename) + ",");
                        context.Response.Write(CSVquoteize(dr.GetValue(colnumRoledescr) as string) + ",");
                        context.Response.Write("RoleDescription");
                        context.Response.Write("\n");
                        DICTboolHaveSeenThisRole[rolename] = true;
                        returnListBusRole[] retFindBRole
                            = engineBR.ListBusRole(null, "\"Name\" = ?", new string[] { rolename }, "");
                        int roleID = retFindBRole[0].ID;
                        returnListBusRoleOwnerByBusRole[] roleowners
                            = engineBRole.ListBusRoleOwnerByBusRole(null, roleID);
                        foreach (returnListBusRoleOwnerByBusRole roleowner in roleowners)
                        {
                            context.Response.Write(CSVquoteize(rolename) + ",");
                            context.Response.Write(roleowner.EID + ",");
                            context.Response.Write(roleowner.RankFriendly.Replace(" ", ""));
                            context.Response.Write("\n");
                        }
                    }

                    context.Response.Write(CSVquoteize(dr.GetValue(colnumRolename) as string) + ",");

                    context.Response.Write(CSVquoteize(resultAsStr.Replace(" ", "")) + ",");
                    context.Response.Write("Entitlement");
                    context.Response.Write("\n");
                }

                catch (Exception e)
                {
                    context.Response.Write(e.ToString() + e.StackTrace.ToString() + "\n");
                }
            }

            return;
        }
示例#3
0
        /* Passing rolename as null is OK: generates just metadata about the entset context */
        private RoleMetadata GenerateRoleMetadata(string rolename, int wsID)
        {
            OdbcConnection tempconn = HELPERS.NewOdbcConn();

            RoleMetadata newbee = new RoleMetadata();

            IEntAssignmentSet engineEASet = new IEntAssignmentSet(tempconn);

            returnGetEntAssignmentSet eas = engineEASet.GetEntAssignmentSet(wsID);

            newbee.WSid         = wsID;
            newbee.WSstatus     = eas.Status;
            newbee.WSownerident =
                UserIdentificationString(eas.UserID, tempconn);
            newbee.WSdateOfImport =
                (eas.Status == "WORKSPACE") ? eas.DATETIMEbirth.ToString() :
                eas.DATETIMElock.ToString();


            newbee.ROLEownersident = new Queue <RoleMetadataOwner>();

            if (rolename != null)
            {
                int roleID;


                IBusRole            engineBR = new IBusRole(tempconn);
                returnListBusRole[] retFindBRole
                    = engineBR.ListBusRole(null, "\"Name\" = ?", new string[] { rolename }, "");

                if (retFindBRole.Length < 1)
                {
                    // If we get here, it's probably the case that rolename ends in "//DEL",
                    // i.e. representing a deleted role.
                    // throw new Exception("Rolename " + rolename + " not found");
                    roleID = -1;
                    // By setting roleID to this, we ensure that the list of role owners
                    // (computed by the logic immediately below)
                    // will just create an empty list.
                }
                else
                {
                    roleID = retFindBRole[0].ID;
                }

                newbee.rolename = rolename;

                IBusRoleOwner engineBRole = new IBusRoleOwner(tempconn);
                returnListBusRoleOwnerByBusRole[] roleowners
                    = engineBRole.ListBusRoleOwnerByBusRole(null, roleID);

                if (roleowners.Length < 1)
                {
                    RoleMetadataOwner baby = new RoleMetadataOwner();
                    baby.EID       = "";
                    baby.geography = "";
                    baby.rank      = "";
                    baby.name      = "";
                    newbee.ROLEownersident.Enqueue(baby);
                }
                else
                {
                    foreach (returnListBusRoleOwnerByBusRole roleowner in roleowners)
                    {
                        RoleMetadataOwner baby = new RoleMetadataOwner();
                        baby.EID       = roleowner.EID;
                        baby.geography = roleowner.Geography;
                        baby.rank      = roleowner.RankFriendly;
                        baby.name      = UserFriendlyName(roleowner.EID, tempconn);
                        newbee.ROLEownersident.Enqueue(baby);
                    }
                }
            }

            return(newbee);
        }
示例#4
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);
                }
            }
        }