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; }
private void CSVgenerate_FullDetail(HttpContext context, OdbcDataReader dr, IMVFormula ENGINEmanif, IEntitlement ENGINEwsent, bool BOOLgenerateHeader) { int colnumFormula = -1; if (BOOLgenerateHeader) { for (int i = 0; i < dr.VisibleFieldCount; i++) { switch (dr.GetName(i) as string) { case "Formula": colnumFormula = i; break; /* * case "EntID": * break; */ default: context.Response.Write(CSVquoteize(dr.GetName(i).Replace('_', ' ')) + ","); break; } } context.Response.Write("Privilege String"); context.Response.Write("\n"); } // FOR EACH ROW while (dr.Read()) { try { int IDwsentrow = (int)(dr.GetValue(0)); object RESLT; ComputePrivilegeString(context, ENGINEmanif, ENGINEwsent, IDwsentrow, out RESLT); for (int i = 0; i < dr.VisibleFieldCount; i++) { if (i != 0) { if (i != colnumFormula) { context.Response.Write(CSVquoteize(dr.GetValue(i) as string) + ","); } } } string resultAsStr = RESLT.ToString().Replace(" ", ""); context.Response.Write(CSVquoteize(resultAsStr)); context.Response.Write("\n"); } catch (Exception e) { context.Response.Write(e.ToString() + e.StackTrace.ToString() + "\n"); } } return; }
public void ProcessRequest(HttpContext context) { OdbcConnection conn = HELPERS.NewOdbcConn(); int IDwsentrow = int.Parse(context.Request.Params["IDwsent"]); context.Response.ContentType = "text/plain"; IMVFormula ENGINEmanif = new IMVFormula(conn); IEntitlement ENGINEwsent = new IEntitlement(conn); OBJwsent = ENGINEwsent.GetEntitlement(IDwsentrow); string appname = OBJwsent.Application; returnListMVFormula[] LISTformulas = ENGINEmanif.ListMVFormula(null, "\"KEYapplication\" = ?", new string[] { appname }, ""); // Currently, we only allow one formula per manifest. // Later we might have richer selection process where other fields // get to play a role in which formula is used. if (LISTformulas.Length > 1) { context.Response.Write("Error: more than one manifest formula for this app."); return; } if (LISTformulas.Length < 1) { context.Response.Write("Error: there is no manifest formula for this app."); return; } returnListMVFormula TheFormula = LISTformulas[0]; if (TheFormula.Formula == null) { TheFormula.Formula = ""; } string STRformula = TheFormula.Formula.Trim(); if (STRformula == "") { context.Response.Write("Error: the manifest formula for this application has NOT been specified."); return; } // We have the formula; now we can evaluate. Evaluator ev = new Evaluator(Eval3.eParserSyntax.cSharp, false); ev.AddEnvironmentFunctions(this); ev.AddEnvironmentFunctions(new ManifestFormulaEvaluatorFunctions(OBJwsent)); opCode lCode; try { lCode = ev.Parse(STRformula); } catch (Exception e) { context.Response.Write("The formula [[" + STRformula + "]] for this app [[" + appname + "]] has parse errors: " + e.ToString()); return; } object RESLT; try { RESLT = lCode.value; } catch (Exception e) { context.Response.Write("Interpreting the formula for this app resulted in errors: " + e.ToString()); return; } context.Response.Write(RESLT.ToString().Replace(" ", "")); }