public Form1() { mInitializing = true; ev = new Evaluator(Eval3.eParserSyntax.cSharp, false); ev.AddEnvironmentFunctions(this); ev.AddEnvironmentFunctions(new EvalFunctions()); // This call is required by the Windows Form Designer. A = new Eval3.EvalVariable(0.0, typeof(double)); B = new Eval3.EvalVariable(0.0, typeof(double)); C = new Eval3.EvalVariable(0.0, typeof(double)); // This call is required by the Windows Form Designer. InitializeComponent(); A.Value = (double)updownA.Value; B.Value = (double)updownB.Value; C.Value = (double)updownC.Value; // Add any initialization after the InitializeComponent() call mInitializing = false; btnEvaluate_Click(null, null); btnEvaluate2_Click(null, null); btnEvaluate3_Click(null, null); }
public Form1() { mInitializing = true; ev = new Evaluator(Eval3.eParserSyntax.cSharp,false); ev.AddEnvironmentFunctions(this); ev.AddEnvironmentFunctions(new EvalFunctions()); // This call is required by the Windows Form Designer. A = new Eval3.EvalVariable(0.0, typeof(double)); B = new Eval3.EvalVariable(0.0, typeof(double)); C = new Eval3.EvalVariable(0.0, typeof(double)); // This call is required by the Windows Form Designer. InitializeComponent(); A.Value = (double)updownA.Value; B.Value = (double)updownB.Value; C.Value = (double)updownC.Value; // Add any initialization after the InitializeComponent() call mInitializing = false; btnEvaluate_Click(null, null); btnEvaluate2_Click(null, null); btnEvaluate3_Click(null, null); }
private Workbook XLSXgenerate (HttpContext context, OdbcDataReader dr, IMVFormula ENGINEmanif, IEntitlement ENGINEwsent, bool singlesheet, int idWS, string strRoleList) { Workbook book = new Workbook(); Worksheet sheet = null; Worksheet sheetRoleMetadata = null; Worksheet sheetEASetMetadata = null; int IDsubprocess = -1; int colnumFormula = -1; int colnumStatus = -1; int colnumBusRole = -1; int colnumIdSubprocess = -1; string currolename = null; WorksheetRow row; sheetEASetMetadata = book.Worksheets.Add("Context"); // Create an annotation row with info about the snapshot context. RoleMetadata mdat = this.GenerateRoleMetadata(null, idWS); bool boolMetadataHasBeenEmitted = false; sheetRoleMetadata = book.Worksheets.Add("Role Metadata"); if (singlesheet) { sheet = book.Worksheets.Add("Technical Framework"); row = sheet.Table.Rows.Add(); for (int i = 0; i < dr.VisibleFieldCount; i++) { switch (dr.GetName(i) as string) { case "Formula": colnumFormula = i; break; case "Mod": colnumStatus = i; row.Cells.Add(dr.GetName(i)); break; /* * case "EntID": * break; */ case "BusRole": colnumBusRole = i; row.Cells.Add(dr.GetName(i)); break; case "IDSubProcess": colnumIdSubprocess = i; break; default: row.Cells.Add(dr.GetName(i)); break; } } row.Cells.Add("Manifest"); row.Cells.Add("AutoCorrectedNulls"); } if (colnumBusRole < 0) { // We haven't even gone through the SQL result's columns to determine // key column numbers yet! Special case donehere. for (int i = 0; i < dr.VisibleFieldCount; i++) { switch (dr.GetName(i) as string) { case "Formula": colnumFormula = i; break; case "Mod": colnumStatus = i; break; /* * case "EntID": * break; * */ case "Business_Role_Name": colnumBusRole = i; break; case "IDSubProcess": colnumIdSubprocess = i; break; default: break; } } } // FOR EACH ROW while (dr.Read()) { try { if (!boolMetadataHasBeenEmitted) { EmitMetadata(sheetEASetMetadata, ref mdat, dr, colnumFormula); boolMetadataHasBeenEmitted = true; } string newrolename = dr.GetValue(colnumBusRole) as string; IDsubprocess = (int)dr.GetValue(colnumIdSubprocess); if (singlesheet) { bool isBabySheet = false; if (currolename == null) { currolename = newrolename; isBabySheet = true; } else if (currolename != newrolename) { currolename = newrolename; isBabySheet = true; } if (isBabySheet) { WorksheetRow row2 = null; if (sheetRoleMetadata.Table.Rows.Count < 3) { row2 = sheetRoleMetadata.Table.Rows.Add(); row2.Cells.Add("ROLE OWNERS/APPROVERS"); row2 = sheetRoleMetadata.Table.Rows.Add(); row2 = sheetRoleMetadata.Table.Rows.Add(); row2.Cells.Add("Role Name"); row2.Cells.Add("Type"); row2.Cells.Add("EID"); row2.Cells.Add("Name"); row2.Cells.Add("Geography"); } mdat = this.GenerateRoleMetadata(newrolename, idWS); foreach (RoleMetadataOwner x in mdat.ROLEownersident) { row2 = sheetRoleMetadata.Table.Rows.Add(); row2.Cells.Add(newrolename); row2.Cells.Add(x.rank); row2.Cells.Add(x.EID); row2.Cells.Add(x.name); row2.Cells.Add(x.geography); } } // GenMetadataSpreadsheetRow(sheetRoleMetadata, "--------", "-----------------------"); } if (!singlesheet) { bool isBabySheet = false; //Note: Excel cannot handle worksheet names longer than 31 chars string truncsheetname = newrolename; if (truncsheetname.Length > 31) { truncsheetname = truncsheetname.Substring(truncsheetname.Length - 31); } if (currolename == null) { sheet = book.Worksheets.Add(truncsheetname); currolename = newrolename; isBabySheet = true; } else if (currolename != newrolename) { sheet = book.Worksheets.Add(truncsheetname); isBabySheet = true; } if (isBabySheet) { // Create an annotation row with info about the snapshot context. mdat = this.GenerateRoleMetadata(newrolename, idWS); GenMetadataSpreadsheetRow(sheet, "Role name:", mdat.rolename); if (mdat.ROLEownersident.Count == 0) { GenMetadataSpreadsheetRow(sheet, "Role owners:", "NOT YET ENTERED"); } else { foreach (object x in mdat.ROLEownersident) { GenMetadataSpreadsheetRow(sheet, "Principal: ", x.ToString()); } } GenMetadataSpreadsheetRow(sheet, "----------", "---------------------"); /* * * row = sheet.Table.Rows.Add(); * row.Cells.Add(annotation); */ currolename = newrolename; row = sheet.Table.Rows.Add(); for (int i = 0; i < dr.VisibleFieldCount; i++) { switch (dr.GetName(i) as string) { case "Formula": colnumFormula = i; break; case "Mod": colnumStatus = i; row.Cells.Add(dr.GetName(i)); break; /* * case "EntID": * break; * */ case "BusRole": colnumBusRole = i; row.Cells.Add(dr.GetName(i)); break; case "IDSubProcess": colnumIdSubprocess = i; break; default: row.Cells.Add(dr.GetName(i)); break; } } row.Cells.Add("Manifest"); } } row = sheet.Table.Rows.Add(); int IDwsentrow = (int)(dr.GetValue(0)); returnGetEntitlement OBJwsent = ENGINEwsent.GetEntitlement(IDwsentrow); string appname = OBJwsent.Application; returnListMVFormula[] LISTformulas = ENGINEmanif.ListMVFormula(null, "\"KEYapplication\" = ?", new string[] { appname }, ""); string STRformula = ""; try { returnListMVFormula TheFormula = LISTformulas[0]; if (TheFormula.Formula == null) { TheFormula.Formula = ""; } STRformula = HttpUtility.HtmlDecode(TheFormula.Formula.Trim()); } catch (Exception eee) { } if (STRformula == "") { STRformula = "\"TBD - " + appname + "\""; //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; bool doMakeNullRepair2ndTry = false; try { lCode = ev.Parse(STRformula); } catch (Exception e) { row.Cells.Add("The formula for " + appname + " has parse errors: " + e.ToString()); return(book); } object RESLT = null; try { RESLT = lCode.value; } catch (NullReferenceException enull) { //row.Cells.Add("Interpreting the formula for this application resulted in an error because of references to one or more fields that are NULL in value."); //RESLT = "[ERROR: reference to one or more fields with null values]"; //row = sheet.Table.Rows.Add(); doMakeNullRepair2ndTry = true; } catch (Exception e) { row.Cells.Add("Interpreting the formula for this application resulted in this exception: " + e.ToString()); RESLT = "[ERROR: see line above for details]"; row = sheet.Table.Rows.Add(); } if (doMakeNullRepair2ndTry) { int repairCount = 0; // NULLs caused failures in the 1st try. // We will thus now repair all nulls and try again. // If succeeds, we will generate a useable row but the final column // will alert the users to the fact that autorepair was performed. TurnNullsToEmptyStrings(ref OBJwsent, ref repairCount); if (repairCount == 0) { throw new Exception("ASSERTION FAILURE: null fields expected but not found"); } opCode lCode2; ev = new Evaluator(Eval3.eParserSyntax.cSharp, false); ev.AddEnvironmentFunctions(this); ev.AddEnvironmentFunctions(new ManifestFormulaEvaluatorFunctions(OBJwsent)); lCode2 = ev.Parse(STRformula); try { RESLT = lCode2.value; } catch (Exception e) { row.Cells.Add("2nd try: Interpreting the formula for this application resulted in this exception: " + e.ToString()); RESLT = "[ERROR: see line above for details]"; row = sheet.Table.Rows.Add(); } } // NOW READY TO EMIT THE COLUMNS for (int i = 0; i < dr.VisibleFieldCount; i++) { if (i != -342350) /*used to be != 0 */ { if ((i != colnumFormula) && (i != colnumIdSubprocess)) { if (i == colnumStatus) { string statSemantics = "ERR"; switch (dr.GetValue(i) as string) { case "N": statSemantics = "New"; break; case "P": statSemantics = "New"; break; case "X": statSemantics = "Deleted"; break; case "A": statSemantics = ""; break; } row.Cells.Add(statSemantics); } else { row.Cells.Add(dr.GetValue(i).ToString()); } } } } row.Cells.Add(RESLT as string); row.Cells.Add(doMakeNullRepair2ndTry ? "Y" : ""); } catch (Exception e) { row = sheet.Table.Rows.Add(); row.Cells.Add(e.ToString() + e.StackTrace.ToString()); } } EmitRoleMetadata_AdditionalRoles (sheetRoleMetadata, strRoleList, idWS, IDsubprocess); EmitRoleMetadata_FuncAppEntsByRole (sheetRoleMetadata, strRoleList, idWS, IDsubprocess); EmitRoleMetadata_SubProcessActivities (sheetRoleMetadata, strRoleList, idWS, IDsubprocess); return(book); }
private void ComputePrivilegeString(HttpContext context, IMVFormula ENGINEmanif, IEntitlement ENGINEwsent, int IDwsentrow, out object RESLT) { RESLT = ""; returnGetEntitlement OBJwsent = ENGINEwsent.GetEntitlement(IDwsentrow); int repaircount = 0; TurnNullsToEmptyStrings(ref OBJwsent, ref repaircount); string appname = OBJwsent.Application; returnListMVFormula[] LISTformulas = ENGINEmanif.ListMVFormula(null, "\"KEYapplication\" = ?", new string[] { appname }, ""); string STRformula = ""; try { returnListMVFormula TheFormula = LISTformulas[0]; if (TheFormula.Formula == null) { TheFormula.Formula = ""; } STRformula = HttpUtility.HtmlDecode(TheFormula.Formula.Trim()); } catch (Exception eee) { } if (STRformula == "") { STRformula = "\"TBD - " + appname + "\""; //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; } try { RESLT = lCode.value; } catch (Exception e) { RESLT = "NULL"; //context.Response.Write("Interpreting the formula for this app resulted in errors: " + e.ToString()); //return; } return; }
private void btnEvaluate2_Click(object sender, System.EventArgs e) { opCode lCodeR = null; opCode lCodeG = null; opCode lCodeB = null; try { ev.AddEnvironmentFunctions(this); ev.AddEnvironmentFunctions(new EvalFunctions()); lCodeR = ev.Parse(tbExpressionRed.Text); lCodeG = ev.Parse(tbExpressionGreen.Text); lCodeB = ev.Parse(tbExpressionBlue.Text); } catch (Exception ex) { Label1.Text = ex.Message; return; } try { Timer t = new Timer(); Bitmap bm = (Bitmap)PictureBox1.Image; if ((bm == null)) { bm = new Bitmap(256, 256); PictureBox1.Image = bm; } double mult = (2 * (Math.PI / 256)); double r = 0; double g = 0; double b = 0; for (int Xi = 0; (Xi <= 255); Xi++) { X = ((Xi - 128) * mult); for (int Yi = 0; (Yi <= 255); Yi++) { Y = ((Yi - 128) * mult); try { r = (double)lCodeR.value; g = (double)lCodeG.value; b = (double)lCodeB.value; if (((r < 0) || double.IsNaN(r))) { r = 0; } else if ((r > 1)) { r = 1; } if (((g < 0) || double.IsNaN(g))) { g = 0; } else if ((g > 1)) { g = 1; } if (((b < 0) || double.IsNaN(b))) { b = 0; } else if ((b > 1)) { b = 1; } } catch { // ignore (same as previous pixel) } bm.SetPixel(Xi, Yi, Color.FromArgb((int)(r * 255), (int)(g * 255), (int)(b * 255))); } if ((Xi & 7) == 7) { PictureBox1.Refresh(); } } Label1.Text = ("196,608 evaluations run in " + (t.ms() + " ms")); } catch (Exception ex) { Label1.Text = ex.Message; } }
public void ProcessRequest(HttpContext context) { if (context.Session["AFWACSESSION"] == null) { throw new Exception("Must be in a legal R-AF session"); } session = context.Session["AFWACSESSION"] as AFWACsession; string mode = context.Request.Params["mode"]; // mode=dumpraf // mode=compare string requestorUserEID = context.Request.Params["usereid"]; string requestorUserName = context.Request.Params["username"]; string pathIdmInput = context.Request.Params["pathidminput"]; bool boolReportInternalIdmRoles = bool.Parse(context.Request.Params["showinternal"]); bool boolSaveToHistory = bool.Parse(context.Request.Params["save"]); bool boolDoCompare = (mode == "compare"); bool boolCaseSens = false; string CSVlistOfInterestingRoles = "-3"; string CSVlistOfInterestingSubprocesses = "-3"; // // New format for the CSVlist: // Still comma-separated. // But now each item is either: // an integer // "SP/###" where ### is the ID number for a subprocess // Our goal is to split this into two CSV lists: // list of interesting roles // list of interesting subprocesses (meaning all its roles are interesting) // So here we must tokenize the incoming role list. StringTok.StringTokenizer TK = new StringTok.StringTokenizer(context.Request.Params["roles"], ","); string curnode; while (TK.HasMoreTokens()) { curnode = TK.NextToken(); if (curnode.StartsWith("SP/")) { curnode = curnode.Substring(3); CSVlistOfInterestingSubprocesses += ("," + curnode); } else { CSVlistOfInterestingRoles += ("," + curnode); } } int errcountEntitlements = 0; int errcountRoleMetadata = 0; DataTable dt_idmdump = null; if (boolDoCompare) { string pathTempFolder = Path.GetDirectoryName(pathIdmInput); string pathTempFile = Path.GetFileName(pathIdmInput); // Load the IDM-dump CSV file. // Load the IDM-dump CSV file. // Load the IDM-dump CSV file. // Load the IDM-dump CSV file. // Load the IDM-dump CSV file. dt_idmdump = HELPERS.LoadCsv(pathTempFolder, System.IO.Path.GetFileName(pathTempFile)); } OdbcCommand cmd = new OdbcCommand(); cmd.Connection = HELPERS.NewOdbcConn(); Workbook book = null; WorksheetRow row; Worksheet sheetMetadata = null; Worksheet sheetDeltas = null; Worksheet sheetErrors = null; if (boolSaveToHistory) { ENGINEreport = new IReconcReport(HELPERS.NewOdbcConn()); IDreport = ENGINEreport.NewReconcReport(DateTime.Now, session.idUser); ENGINEreport.SetReconcReport (IDreport, DateTime.Now, "Comparison via upload of file " + pathIdmInput, session.idUser, "IDM"); ENGINEreportDiffItem = new IReconcDiffItem(HELPERS.NewOdbcConn()); } else { book = new Workbook(); context.Response.ContentType = "application/vnd.xls"; context.Response.AddHeader("Content-Disposition", "filename=RAFidmReconcile.xls;attachment"); sheetMetadata = book.Worksheets.Add("Metadata"); sheetErrors = book.Worksheets.Add("Errors"); row = sheetMetadata.Table.Rows.Add(); row.Cells.Add("Run Date:"); row.Cells.Add(DateTime.Now.ToUniversalTime().ToLongDateString() + " UTC"); row = sheetMetadata.Table.Rows.Add(); row.Cells.Add("Run Time:"); row.Cells.Add(DateTime.Now.ToUniversalTime().ToLongTimeString() + " UTC"); // row = sheetMetadata.Table.Rows.Add(); // row.Cells.Add("User EID:"); // row.Cells.Add(requestorUserEID); row = sheetMetadata.Table.Rows.Add(); row.Cells.Add("User Name:"); row.Cells.Add(requestorUserName); row = sheetMetadata.Table.Rows.Add(); row.Cells.Add("Include list of IDM ELE_INT_ and INT_ roles"); row.Cells.Add(boolReportInternalIdmRoles.ToString()); row = sheetMetadata.Table.Rows.Add(); row = sheetMetadata.Table.Rows.Add(); row.Cells.Add("STATISTICS"); sheetDeltas = book.Worksheets.Add("Reconciliation"); row = RecordDelta(sheetDeltas, "Role Name", "Difference", "Action", "Difference Type", ""); } OdbcConnection conn2 = HELPERS.NewOdbcConn_FORCE(); IEntitlement ENGINEwsent = new IEntitlement(conn2); string SQLsubpr = @" SELECT c_r_SubProcess, c_u_Name FROM t_RBSR_AUFW_u_BusRole;"; cmd.CommandText = SQLsubpr; OdbcDataReader drSubpr = cmd.ExecuteReader(); Dictionary <string, string> MAPbrolenamesToSubprids = new Dictionary <string, string>(); while (drSubpr.Read()) { int IDsubprid = (int)(drSubpr.GetValue(0)); string brolename = drSubpr.GetValue(1).ToString(); if (!MAPbrolenamesToSubprids.ContainsKey(brolename)) { MAPbrolenamesToSubprids.Add(brolename, IDsubprid.ToString()); // + " = " + STRsubpr); } } drSubpr.Close(); string extraconds = " AND (TEASS.c_u_Status NOT IN ('X')) "; // Perform a massive SQL select to obtain all active entitlements in R-AF string SQL = @" SELECT TENT.c_id as EntID, BROL.c_u_Name as BusRole, RTRIM(LTRIM(BROL.c_u_Description)) as BusRoleDescr, MVF.c_u_Formula as Formula, MVF.c_u_KEYapplication as Appl, OWNERS.c_u_EID as EIDprimaryApprover, SUBPR.c_u_Name as SubprocessName, BROL.c_r_SubProcess as SubprocessID FROM t_RBSR_AUFW_u_EntAssignment TEASS LEFT OUTER JOIN t_RBSR_AUFW_u_Entitlement TENT ON TEASS.c_r_Entitlement = TENT.c_id LEFT OUTER JOIN t_RBSR_AUFW_u_BusRole BROL ON BROL.c_id = TEASS.c_r_BusRole LEFT OUTER JOIN t_RBSR_AUFW_u_MVFormula MVF ON MVF.c_u_KEYapplication = TENT.c_u_Application LEFT OUTER JOIN t_RBSR_AUFW_u_EntAssignmentSet TEASET ON TEASET.c_id = TEASS.c_r_EntAssignmentSet LEFT OUTER JOIN t_RBSR_AUFW_u_SubProcess SUBPR ON TEASET.c_r_SubProcess = SUBPR.c_id LEFT OUTER JOIN t_RBSR_AUFW_u_BusRoleOwner OWNERS ON ( (OWNERS.c_r_BusRole = BROL.c_id) AND (OWNERS.c_u_Rank='appr') ) WHERE (TEASET.c_u_Status = 'ACTIVE') AND (SUBPR.c_r_Process NOT IN (7)) AND ( (BROL.c_id IN (" + CSVlistOfInterestingRoles + ")) OR " + "(BROL.c_r_SubProcess IN (" + CSVlistOfInterestingSubprocesses + ")) ) " + extraconds + " ORDER BY TEASS.c_r_BusRole;"; cmd.CommandText = SQL; OdbcDataReader dr = cmd.ExecuteReader(); Dictionary <string, string> DICTactiveEnts = new Dictionary <string, string>(); // These map role names to role descriptions Dictionary <string, string> DICTactiveBroles = new Dictionary <string, string>(); Dictionary <string, string> DICTidmBroles = new Dictionary <string, string>(); // Key = rolename + EID of primary approver // Value = 1 Dictionary <string, string> DICTroleApprover = new Dictionary <string, string>(); Queue <string> QUEUEmsgsWarning = new Queue <string>(); // WE ARE NOW READING THE DATA COMING FROM R-AF VIA SQL QUERY // WE ARE NOW READING THE DATA COMING FROM R-AF VIA SQL QUERY // WE ARE NOW READING THE DATA COMING FROM R-AF VIA SQL QUERY // WE ARE NOW READING THE DATA COMING FROM R-AF VIA SQL QUERY // WE ARE NOW READING THE DATA COMING FROM R-AF VIA SQL QUERY while (dr.Read()) { int IDwsentrow = (int)(dr.GetValue(0)); string brolename = dr.GetValue(1).ToString(); string broledescr = dr.GetValue(2).ToString(); string STRformula = dr.GetValue(3).ToString(); string STRapp = dr.GetValue(4).ToString(); string STRapproverEID = dr.GetValue(5).ToString(); string STRsubpr = dr.GetValue(6).ToString(); int IDsubpr = (int)(dr.GetValue(7)); if (!DICTactiveBroles.ContainsKey(brolename)) { DICTactiveBroles.Add(brolename, broledescr); } /* * if (!MAPbrolenamesToSubprids.ContainsKey(brolename)) * { * MAPbrolenamesToSubprids.Add(brolename, IDsubpr.ToString() + " = " + STRsubpr); * } */ if (STRapproverEID.Length > 1) { try { DICTroleApprover.Add( brolename + (char)1 + STRapproverEID, "1"); } catch (Exception) { } } returnGetEntitlement OBJwsent = ENGINEwsent.GetEntitlement(IDwsentrow); // SKLAR NOTE: the returnGetEntitlement struct has every column/field already segregated int repaircount = 0; TurnNullsToEmptyStrings(ref OBJwsent, ref repaircount); if (STRformula == "") { STRformula = "\"TBD - " + dr.GetValue(4).ToString() + "\""; } else { STRformula = HttpUtility.HtmlDecode(STRformula.Trim()); } // 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) { if (book != null) { sheetMetadata.Table.Rows.Add().Cells.Add("The formula [[" + STRformula + "]] for this app [[" + STRapp + "]] has parse errors: " + e.ToString()); } else { context.Response.Write("The formula [[" + STRformula + "]] for this app [[" + STRapp + "]] has parse errors: " + e.ToString()); } continue; } string RESLT; try { RESLT = lCode.value.ToString(); } catch (Exception e) { RESLT = "NULL"; //context.Response.Write("Interpreting the formula for this app resulted in errors: " + e.ToString()); //return; } string RESLTforCompare = RESLT; if (!boolCaseSens) { RESLTforCompare = RESLT.ToLower().Replace(" ", ""); } if (!boolDoCompare) { context.Response.Write(CSVquoteize(brolename)); context.Response.Write(","); context.Response.Write(CSVquoteize(broledescr)); context.Response.Write(","); context.Response.Write(CSVquoteize(RESLTforCompare)); context.Response.Write("\n"); } else { // Enter the role name and the privilegestring into a dictionary try { DICTactiveEnts.Add(brolename + (char)1 + RESLTforCompare, RESLT); } catch (Exception eduringprivadd) { // This situation occurs when two or more distinct entitlements in RAF // generate the very same priv string (because they differ in a field that // "does not count" towards generation of the priv string. QUEUEmsgsWarning.Enqueue ("Role " + brolename + ": privilege was registered redundantly: " + RESLTforCompare); } } } // Now comes the comparison. if (boolDoCompare) { Queue <string> QUEUE_idmRowsLackingActiveMatch = new Queue <string>(); // HERE WE ARE ACTUALLY LOOKING AT THE DATA COMING IN FROM THE IDM DUMP FILE // HERE WE ARE ACTUALLY LOOKING AT THE DATA COMING IN FROM THE IDM DUMP FILE // HERE WE ARE ACTUALLY LOOKING AT THE DATA COMING IN FROM THE IDM DUMP FILE // HERE WE ARE ACTUALLY LOOKING AT THE DATA COMING IN FROM THE IDM DUMP FILE // HERE WE ARE ACTUALLY LOOKING AT THE DATA COMING IN FROM THE IDM DUMP FILE // HERE WE ARE ACTUALLY LOOKING AT THE DATA COMING IN FROM THE IDM DUMP FILE // HERE WE ARE ACTUALLY LOOKING AT THE DATA COMING IN FROM THE IDM DUMP FILE // HERE WE ARE ACTUALLY LOOKING AT THE DATA COMING IN FROM THE IDM DUMP FILE foreach (DataRow idmrow in dt_idmdump.Rows) { string idmrsrcRolename = idmrow[0].ToString().Trim(); string idmrsrcValue = idmrow[1].ToString().Trim(); string idmrsrcObjType = idmrow[2].ToString().Trim(); switch (idmrsrcObjType) { case "PrimaryApprover": case "RoleApprover": string target = idmrsrcRolename + (char)1 + idmrsrcValue; if (DICTroleApprover.ContainsKey(target)) { // Was also found in RAF, so nothing to report. DICTroleApprover.Remove(target); } else { // Was not found in RAF, so report a need for removal RecordDelta(sheetDeltas, idmrsrcRolename, idmrsrcValue, "Remove", "PrimaryApprover", null); } break; case "RoleDescription": if (!DICTidmBroles.ContainsKey(idmrsrcRolename)) { DICTidmBroles.Add(idmrsrcRolename, idmrsrcValue); } break; case "Entitlement": string idmrsrcPrivForCompare = idmrsrcValue; if (!boolCaseSens) { idmrsrcPrivForCompare = idmrsrcValue.ToLower().Replace(" ", ""); } string idmrsrcKey = idmrsrcRolename + (char)1 + idmrsrcPrivForCompare; if (DICTactiveEnts.ContainsKey(idmrsrcKey)) { DICTactiveEnts.Remove(idmrsrcKey); } else { QUEUE_idmRowsLackingActiveMatch.Enqueue(idmrsrcKey); /* * int idxSep = idmrsrcKey.IndexOf((char)1); * string reportRolename = idmrsrcKey.Substring(0,idxSep); * string reportPriv = idmrsrcKey.Substring(idxSep+1); * */ if (!boolReportInternalIdmRoles) { if (idmrsrcRolename.StartsWith("ELE_INT_") || idmrsrcRolename.StartsWith("INT_")) { continue; } } try { RecordDelta(sheetDeltas, idmrsrcRolename, idmrsrcValue, "Remove", "Entitlement", MAPbrolenamesToSubprids[idmrsrcRolename]); } catch (Exception) { RecordDelta(sheetDeltas, idmrsrcRolename, idmrsrcValue, "Remove", "Entitlement", "Note: this role is not known to the RAF system at all."); } errcountEntitlements++; } break; } } foreach (string keytoadd in DICTactiveEnts.Keys) { int idxSep = keytoadd.IndexOf((char)1); string reportRolename = keytoadd.Substring(0, idxSep); string reportPriv = DICTactiveEnts[keytoadd]; if (!boolReportInternalIdmRoles) { if (reportRolename.StartsWith("ELE_INT_") || reportRolename.StartsWith("INT_")) { continue; } } RecordDelta(sheetDeltas, reportRolename, reportPriv, "Add", "Entitlement", null); errcountEntitlements++; } foreach (string keytoadd in DICTroleApprover.Keys) { int idxSep = keytoadd.IndexOf((char)1); string reportRolename = keytoadd.Substring(0, idxSep); string reportEID = keytoadd.Substring(idxSep + 1); if (!boolReportInternalIdmRoles) { if (reportRolename.StartsWith("ELE_INT_") || reportRolename.StartsWith("INT_")) { continue; } } RecordDelta(sheetDeltas, reportRolename, reportEID, "Add", "PrimaryApprover", null); } // Roles as a whole foreach (string rolePresentInRAF in DICTactiveBroles.Keys) { if (DICTidmBroles.ContainsKey(rolePresentInRAF)) { // This role is present in both RAF and IDM. // But perhaps differs in description? if (DICTactiveBroles[rolePresentInRAF] != DICTidmBroles[rolePresentInRAF]) { // 1. Do a remove RecordDelta(sheetDeltas, rolePresentInRAF, DICTidmBroles[rolePresentInRAF], "Remove", "RoleDescription", ""); // 2. Do an add RecordDelta(sheetDeltas, rolePresentInRAF, DICTactiveBroles[rolePresentInRAF], "Add", "RoleDescription", ""); errcountRoleMetadata++; } //Record having seen this. DICTidmBroles.Remove(rolePresentInRAF); } else { RecordDelta(sheetDeltas, rolePresentInRAF, DICTactiveBroles[rolePresentInRAF], "Add", "Role", null); errcountRoleMetadata++; } } foreach (string rolePresentInIDM in DICTidmBroles.Keys) { if (!boolReportInternalIdmRoles) { if (rolePresentInIDM.StartsWith("ELE_INT_") || rolePresentInIDM.StartsWith("INT_")) { continue; } } RecordDelta(sheetDeltas, rolePresentInIDM, rolePresentInIDM, "Remove", "Role", null); errcountRoleMetadata++; } if (book != null) { row = sheetMetadata.Table.Rows.Add(); row.Cells.Add(" - Entitlement deltas:"); row.Cells.Add(errcountEntitlements.ToString()); row = sheetMetadata.Table.Rows.Add(); row.Cells.Add(" - Role deltas:"); row.Cells.Add(errcountRoleMetadata.ToString()); if (QUEUEmsgsWarning.Count > 0) { row = sheetMetadata.Table.Rows.Add(); row.Cells.Add(" - Warning messages regarding RAF-side data:"); while (QUEUEmsgsWarning.Count > 0) { string msg = QUEUEmsgsWarning.Dequeue(); row = sheetMetadata.Table.Rows.Add(); row.Cells.Add(""); row.Cells.Add(msg); } } book.Save(context.Response.OutputStream); } else { context.Response.Redirect("../Page_Reconc_History.aspx"); } } }
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(" ", "")); }