602274c1cd531e3ea528a655aaeb869514a72265
API/CodeSamples/CustomTimePeriods.md
| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | +#CustomTimePeriods |
|
| 2 | + |
|
| 3 | +[[_TOC_]] |
|
| 4 | + |
|
| 5 | +##About |
|
| 6 | + |
|
| 7 | +Used to define custom time periods that will be accessible in the 'In Time Period' filter operator on the Filters tab in the ReportDesigner. These options will be appended to the list of time periods that ship with Izenda AdHoc.<br>*Note: There are several overloads for the [[CustomTimePeriod|/FAQ/Questions/Adding-Custom-Time-Periods]] constructor, so you can define different time periods with various types.* |
|
| 8 | + |
|
| 9 | +##Global.asax (C♯) |
|
| 10 | +```csharp |
|
| 11 | +//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 12 | +public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig |
|
| 13 | +{ |
|
| 14 | + // Configure settings |
|
| 15 | + // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method |
|
| 16 | + public static void InitializeReporting() { |
|
| 17 | + //Check to see if we've already initialized. |
|
| 18 | + if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 19 | + return; |
|
| 20 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"; |
|
| 21 | + //Creates a connection to Microsoft SQL Server |
|
| 22 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"; |
|
| 23 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig(); |
|
| 24 | + AdHocSettings.CustomTimePeriods.Add("Lunar Cycle", new CustomTimePeriod("Lunar Cycle", new TimeSpan(29, 12, 44, 2, 976))); |
|
| 25 | + HttpContext.Current.Session["ReportingInitialized"] = true; |
|
| 26 | + } |
|
| 27 | + public override void ConfigureSettings() { |
|
| 28 | + AdHocSettings.VisibleDataSources = new string[] {"DataSource1", "DataSource2"}; |
|
| 29 | + } |
|
| 30 | +} |
|
| 31 | +``` |
|
| 32 | + |
|
| 33 | +##Global.asax (VB.NET) |
|
| 34 | + |
|
| 35 | +```visualbasic |
|
| 36 | +'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 37 | +Public Class CustomAdHocConfig |
|
| 38 | + Inherits Izenda.AdHoc.DatabaseAdHocConfig |
|
| 39 | + |
|
| 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.CustomTimePeriods.Add("Lunar Cycle", new CustomTimePeriod("Lunar Cycle", new TimeSpan(29, 12, 44, 2, 976))) |
|
| 49 | + HttpContext.Current.Session("ReortingInitialized") = True |
|
| 50 | + End Sub |
|
| 51 | +End Class |
|
| 52 | +``` |
|
| ... | ... | \ No newline at end of file |