API/CodeSamples/HiddenFilters.md
... ...
@@ -0,0 +1,70 @@
1
+#HiddenFilters
2
+
3
+[[_TOC_]]
4
+
5
+##About
6
+
7
+This controls row-level security throughout the tool. This collection is designed to be used in all multi-tenant systems and systems where users are restricted to certain records.
8
+Hidden filters are applied per-report upon execution and are invisible to the user. Users may still add their own filters to reports and will not override the hidden filters applied to them.
9
+
10
+##Global.asax (C♯)
11
+
12
+```csharp
13
+//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig
14
+public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig
15
+{
16
+ // Configure settings
17
+ // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method
18
+ public static void InitializeReporting() {
19
+ //Check to see if we've already initialized.
20
+ if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null)
21
+ return;
22
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE";
23
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE";
24
+ Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig();
25
+ AdHocSettings.HiddenFilters.Add("EmployeeID", new int[5] { 1, 2, 3, 4, 5 });
26
+ HttpContext.Current.Session["ReportingInitialized"] = true;
27
+ }
28
+}
29
+```
30
+
31
+##Global.asax (VB.NET)
32
+
33
+```visualbasic
34
+'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig
35
+Public Class CustomAdHocConfig
36
+ Inherits Izenda.AdHoc.DatabaseAdHocConfig
37
+
38
+ 'Configure settings
39
+ 'Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method
40
+ Shared Sub InitializeReporting()
41
+ 'Check to see if we've already initialized.
42
+ If HttpContext.Current.Session Is Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then
43
+ Return
44
+ 'Initialize System
45
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"
46
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"
47
+ Izenda.AdHoc.AdHocSettings.AdHocConfig = New CustomAdHocConfig()
48
+ AdHocSettings.HiddenFilters.Add("EmployeeID", New Integer(4) { 1, 2, 3, 4, 5 })
49
+ HttpContext.Current.Session("ReportingInitialized") = True
50
+ End Sub
51
+End Class
52
+```
53
+
54
+##Fully qualified filters
55
+
56
+If, for instance, you have two database tables in the same schema with identical names but they do not contain the same data, you can use fully qualified names with the hidden filters list to ensure you only filter the correct one. This can be done by prepending the schema and table name to the column name as in the example below:
57
+
58
+###C♯
59
+
60
+```csharp
61
+AdHocSettings.HiddenFilters.Add("[dbo].[Employees].[EmployeeID]", new int[5] { 1, 2, 3, 4, 5 });
62
+```
63
+
64
+###VB.NET
65
+
66
+```visualbasic
67
+AdHocSettings.HiddenFilters.Add("[dbo].[Employees].[EmployeeID]", New Integer(4) {1, 2, 3, 4, 5})
68
+```
69
+
70
+_**Note:** You will have to add a new filter for each individual table you wish to filter by this methodology._
... ...
\ No newline at end of file