b4a86f32ab404886d98ba6db9209d36d96527e0f
FAQ/Questions/Applying-Security.md
| ... | ... | @@ -84,4 +84,48 @@ public override void PreExecuteReportSet(Izenda.AdHoc.ReportSet reportSet) |
| 84 | 84 | f.Value = GetCurrentUserTerritory(); |
| 85 | 85 | reportSet.Filters.AddHidden(f); |
| 86 | 86 | } |
| 87 | +``` |
|
| 88 | + |
|
| 89 | +##Field Value Concealing |
|
| 90 | + |
|
| 91 | +Field value concealing allows you to return all data in a data set but hide the data with a string you provide. By using this method, you can modify the conditions in which the override occurs using any data that the global.asax has access to (for example tenant ID, user ID, parsed cookie/user data). |
|
| 92 | + |
|
| 93 | +Insert the following code block inside the CustomAdhocConfig class in the global.asax after the InitializeReporting() function. |
|
| 94 | +In order to adjust what column to block out with "- -" and the conditions in which it happens, alter the "if" blocks within the public object Format() block. |
|
| 95 | + |
|
| 96 | +In this example, any value of freight that is below 50 will be replaced with "--". |
|
| 97 | + |
|
| 98 | +```csharp |
|
| 99 | + |
|
| 100 | +public class ConcealingFormatter : IFormatter |
|
| 101 | +{ |
|
| 102 | +public Type GetOutputDataType(System.Data.DataTable table, int columnNumber, ReportOutputOptions reportOutputOptions, Field field) |
|
| 103 | +{ |
|
| 104 | +return typeof(string); |
|
| 105 | +} |
|
| 106 | + |
|
| 107 | +public object Format(System.Data.DataTable table, int rowNumber, int columnNumber, Field field, System.Data.DataTable originalTable, Field nameField) |
|
| 108 | +{ |
|
| 109 | +object value = table.Rows[rowNumber][columnNumber]; |
|
| 110 | +float val; |
|
| 111 | +if (field.DbColumn.Name == "Freight" && value != null && value != DBNull.Value && float.TryParse(value.ToString().Trim(new char[] {'(', ')', '$'}), out val)) { |
|
| 112 | + |
|
| 113 | +//any kind of conditions can be checked here - username, field name, table name, column name, currentreportset properties, particular field value, etc |
|
| 114 | +if (val < 50) |
|
| 115 | +value = "--"; |
|
| 116 | +} |
|
| 117 | +return value; |
|
| 118 | +} |
|
| 119 | +} |
|
| 120 | + |
|
| 121 | +public override void PreExecuteReportSet(ReportSet reportSet) |
|
| 122 | +{ |
|
| 123 | +reportSet.CustomFormatter = new ConcealingFormatter(); |
|
| 124 | +} |
|
| 125 | + |
|
| 126 | +public override void PostExecuteReportSet(ReportSet reportSet) |
|
| 127 | +{ |
|
| 128 | +reportSet.CustomFormatter = null; |
|
| 129 | +} |
|
| 130 | + |
|
| 87 | 131 | ``` |
| ... | ... | \ No newline at end of file |