API/CodeSamples/LicenseKey.md
... ...
@@ -6,81 +6,41 @@ This setting is required to run Izenda and must be entered as one of the very fi
6 6
7 7
##Global.asax (C♯)
8 8
```c#
9
-<%@ Application Language="C#" %>
10
-<%@ Import Namespace="Izenda.AdHoc" %>
11 9
12
-<script runat="server">
13
-
14
- void Session_Start(object sender, EventArgs e)
15
- {
16
- AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE";
17
- Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig();
18
- }
19
-
20
- public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig
21
- {
22
- // Configure settings
23
- // Add Custom Setting below license key and connection string setting
24
- public override void ConfigureSettings()
25
- {
26
- AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE";
27
- //AdHocSettings.VisibleTables = new string[] { "VIEW1", "TABLE2" };
28
- AdHocSettings.LicenseKey = "INSERT LICENSE KEY HERE";
29
-
30
- }
31
-
32
- // Control what reports are visible for the current user
33
- public override Izenda.AdHoc.ReportInfo[] ListReports()
34
- {
35
- return base.ListReports();
36
- }
37
-
38
- // Customize a report on the fly prior to execution on a per user basis
39
- public override void PreExecuteReportSet(Izenda.AdHoc.ReportSet reportSet)
40
- {
41
-
42
- }
43
-
44
- }
45
-</script>
10
+//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig
11
+public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig
12
+{
13
+ // Configure settings
14
+ // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method
15
+public static void InitializeReporting() {
16
+ //Check to see if we've already initialized.
17
+ if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null)
18
+ return;
19
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE";
20
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE";
21
+ Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig();
22
+ HttpContext.Current.Session["ReportingInitialized"] = true;
23
+}
24
+}
46 25
```
47 26
48 27
##Global.asax (VB.NET)
49 28
50 29
```visualbasic
51
-<%@ Application Language="VB" %>
52
-<%@ Import Namespace="Izenda.AdHoc" %>
53 30
54
-<script runat="server">
31
+'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig
32
+Public Class CustomAdHocConfig
33
+Inherits Izenda.AdHoc.DatabaseAdHocConfig
55 34
56
- Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
35
+ Shared Sub InitializeReporting()
36
+ 'Check to see if we've already initialized
37
+ If HttpContext.Current.Session = Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then
38
+ Return
39
+ 'Initialize System
57 40
AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"
58 41
Izenda.AdHoc.AdHocSettings.AdHocConfig = New CustomAdHocConfig()
42
+ HttpContext.Current.Session("ReortingInitialized") = True
59 43
End Sub
60
-
61
- Public Class CustomAdHocConfig
62
- Inherits Izenda.AdHoc.DatabaseAdHocConfig
63
-
64
- ' Configure settings
65
- ' Add Custom Setting below license key and connection string setting
66
- Public Overrides Sub ConfigureSettings()
67
- AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"
68
- 'AdHocSettings.VisibleTables = New String() { "VIEW1", "TABLE2" }
69
- AdHocSettings.LicenseKey = "INSERT LICENSE KEY HERE"
70
-
71
- End Sub
72
-
73
- ' Control what reports are visible for the current user
74
- Public Overrides Function ListReports() As Izenda.AdHoc.ReportInfo()
75
- Return MyBase.ListReports
76
- End Function
77
-
78
- ' Customize a report on the fly prior to execution on a per user basis
79
- Public Overrides Sub PreExecuteReportSet(ByVal reportSet As Izenda.AdHoc.ReportSet)
80
-
81
- End Sub
82
-
83
- End Class
84 44
85
-</script>
45
+End Class
86 46
```
... ...
\ No newline at end of file