public string rowsOwnersApprovers() { StringBuilder BUFFER = new StringBuilder(); IBusRoleOwner engine = new IBusRoleOwner(HELPERS.NewOdbcConn()); IUser DBuser = new IUser(HELPERS.NewOdbcConn()); returnListBusRoleOwnerByBusRole[] listowners = engine.ListBusRoleOwnerByBusRole(null, idBR); foreach (returnListBusRoleOwnerByBusRole cur in listowners) { returnListUser[] theUser = DBuser.ListUser(null, "\"EID\" LIKE ?", new string[] { cur.EID }, ""); BUFFER.Append("<tr><td>" + cur.RankFriendly + "</td>"); BUFFER.Append(" <td>"); if (theUser.Length == 1) { BUFFER.Append(theUser[0].NameFirst + " " + theUser[0].NameSurname); } BUFFER.Append("</td>\n"); BUFFER.Append("<td>" + cur.EID + "</td>"); BUFFER.Append("</tr>\n"); } return(BUFFER.ToString()); }
private void JQDLGeditRoleOwner (System.Collections.Specialized.NameValueCollection pars, HttpResponse httpResponse) { IBusRoleOwner engine = new IBusRoleOwner(CONNdedicated); int idBusRoleBeingEdited = int.Parse(pars["JQDLGbp_id"]); string EID = pars["eid"].Trim(); string strIdCurEdit = pars["idcuredit"]; int idCurEdit; if (strIdCurEdit == "ADD") { idCurEdit = engine.NewBusRoleOwner (EID, pars["geo"], pars["rank"], idBusRoleBeingEdited); } else { idCurEdit = int.Parse(strIdCurEdit); } if (pars["deleteme"] == "true") { // DELETION OF THIS ROW IS REQUESTED. engine.DeleteBusRoleOwner(idCurEdit); } else { engine.SetBusRoleOwner (idCurEdit, EID, pars["geo"], pars["rank"], idBusRoleBeingEdited); } CreateOrUpdateUserName(EID, pars["NAMEsur"], pars["NAMEfirst"], true); }
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; }
/* 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); }
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; } } } }
ONCLICK_BulkUploadPersonnel(object sender, EventArgs e) { Dictionary <string, bool> DOESEXISTbyEid = new Dictionary <string, bool>(); Dictionary <string, int> DICTbusrole = new Dictionary <string, int>(); IBusRoleOwner ENGINEbrown = new IBusRoleOwner(HELPERS.NewOdbcConn()); IBusRole ENGINEbr = new IBusRole(HELPERS.NewOdbcConn()); if (this.FileUpload_PersonnelMappings.HasFile) { string pathTempFolder = System.IO.Path.GetTempPath(); string pathTempFile = System.IO.Path.GetTempFileName(); FileUpload_PersonnelMappings.SaveAs(pathTempFile); DataTable dt = HELPERS.LoadCsv(pathTempFolder, System.IO.Path.GetFileName(pathTempFile)); if (dt != null) { if (dt.Columns.Count < 3) { throw new Exception("The uploaded CSV file does not have at least 3 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 rank = x.Current[1].ToString().Trim(); string eid = x.Current[2].ToString().Trim().ToUpper(); switch (rank) { case "Primary Owner": rank = "OWNprim"; break; case "Delegate Owner": rank = "OWNdele"; break; case "Primary Approver": rank = "appr"; break; case "Delegate Approver": rank = "delegate"; break; default: RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": line ignored due to unknown rank name: " + rank); continue; } if (recordseq == 1) { // Upon seeing at least one row in the CSV, erase the entire personnel mapping table! HELPERS.DestroyAllBusroleToPersonnelMappings(); } if (DOESEXISTbyEid.ContainsKey(eid) == false) { HELPERS.FindUser(HELPERS.NewOdbcConn(), eid, eid, true); DOESEXISTbyEid.Add(eid, true); } int IDrole = -1; if (DICTbusrole.ContainsKey(rolename)) { IDrole = DICTbusrole[rolename]; } else { try { IDrole = HELPERS.FindBusRoleByName(rolename); DICTbusrole.Add(rolename, IDrole); } catch (Exception) { } } if (IDrole < 0) { RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": line ignored due to unknown role: " + rolename); continue; } try { ENGINEbrown.NewBusRoleOwner(eid, "", rank, IDrole); okCount++; } catch (Exception ee) { RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": " + ee.Message); } } RETmsgs.Enqueue("------------------"); RETmsgs.Enqueue("Number of records processed 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; } } } }