12df60138dcc0294e0696e36c1bf703ac2364f90
Integration/Tutorials/Customizing-Izenda-Settings.md
| ... | ... | @@ -35,19 +35,43 @@ public class CustomAdHocConfig : Izenda.AdHoc.FileSystemAdHocConfig |
| 35 | 35 | { |
| 36 | 36 | //the method to be called by each of your reporting web pages in the OnPreInit() method. This will instantiate Izenda reports throughout your reporting application. |
| 37 | 37 | public static void InitializeReporting() { |
| 38 | - //Check to see if we've already initialized. |
|
| 39 | - if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 40 | - return; |
|
| 38 | + //Check to see if we've already initialized. |
|
| 39 | + if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 40 | + return; |
|
| 41 | + bool isMultiTenant = false; |
|
| 42 | + string role = GetUserRole(); |
|
| 43 | + AdHocSettings.CurrentUserName = (string)HttpContext.Current.Session["UserName"]; //Assumes the authenticated username is stored in a session variable |
|
| 44 | + AdHocSettings.CurrentUserIsAdmin = (bool)HttpContext.Current.Session["IsAdmin"]; //Assumes the authenticated user's admin status is stored in a session variable |
|
| 45 | + AdHocSettings.ShowSettingsButton = AdHocSettings.CurrentUserIsAdmin; |
|
| 46 | + AdHocSettings.ShowModifyButton = AdHocSettings.CurrentUserIsAdmin; |
|
| 47 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig(); |
|
| 48 | + |
|
| 49 | + if (!isMultiTenant) { |
|
| 41 | 50 | AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"; |
| 42 | 51 | //Creates a connection to Microsoft SQL Server |
| 43 | - AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"; |
|
| 44 | - Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig(); |
|
| 52 | + AdHocSettings.SqlServerConnectionString = GetConnectionString(); |
|
| 45 | 53 | //Handle user specific logic |
| 46 | - AdHocSettings.CurrentUserName = (string)HttpContext.Current.Session["UserName"]; //Assumes the authenticated username is stored in a session variable |
|
| 47 | - AdHocSettings.CurrentUserIsAdmin = (bool)HttpContext.Current.Session["IsAdmin"]; //Assumes the authenticated user's admin status is stored in a session variable |
|
| 48 | - AdHocSettings.ShowSettingsButton = AdHocSettings.CurrentUserIsAdmin; |
|
| 54 | + AdHocSettings.CurrentUserIsAdmin = (bool)HttpContext.Current.Session |
|
| 49 | 55 | AdHocSettings.VisibleDataSources = GetUserDataSources(); |
| 50 | - HttpContext.Current.Session["ReportingInitialized"] = true; |
|
| 56 | + } |
|
| 57 | + else { |
|
| 58 | + string company = GetUserCompany(); |
|
| 59 | + //Set connection string per-tenant |
|
| 60 | + AdHocSettings.SqlServerConnectionString = GetConnectionStringByCompany(company); |
|
| 61 | + //Set the stored reports file folder path per-tenant |
|
| 62 | + AdHocSettings.ReportsPath="\\" + company + "\\" + GetUserDepartment(AdHocSettings.CurrentUserName); |
|
| 63 | + //Set table and view access |
|
| 64 | + AdHocSettings.VisibleDataSources = GetTables(role); //get the allowed datasources based on role |
|
| 65 | + //Set all other settings |
|
| 66 | + if (company=="AcmeWidget") |
|
| 67 | + { |
|
| 68 | + AdHocSettings.Formats["Currency"] = "{0:#,###.##}"; |
|
| 69 | + if (GetUserRole()=="PowerUser") { |
|
| 70 | + AdHocSettings.ShowModifyButton=true; |
|
| 71 | + AdHocSettings.AllowDeletingReports=false; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + HttpContext.Current.Session["ReportingInitialized"] = true; |
|
| 51 | 75 | } |
| 52 | 76 | |
| 53 | 77 | // Dynamically modify the report before execution. |