72d6ddf8c41199d1e8470e2690249058c2e4c63e
FAQ/Questions/MultipleConstraints.md
| ... | ... | @@ -1,88 +1,56 @@ |
| 1 | -#ConnectionStringRW |
|
| 1 | +#Multi Constraints |
|
| 2 | 2 | [[_TOC_]] |
| 3 | 3 | |
| 4 | 4 | |
| 5 | -##About |
|
| 5 | +##Question |
|
| 6 | 6 | |
| 7 | -ConnectionStringRW is one of the Izenda Driver's properties, which enables users to have Read-Write access permission to Database. |
|
| 8 | -Below is a sample global.asax using the ConnectionStringRW setting. The code block will appear within <script runat="server"> </script> tags within global.asax |
|
| 7 | +Is there a way to pre-build a string or object and store it at the application level? to let each session copy it and change the connection string. It is not optimal to have to call the AddConstraint() method so many times every time a user wants to connect to a database |
|
| 9 | 8 | |
| 10 | -##Global.asax (C♯) |
|
| 11 | -```csharp |
|
| 12 | - |
|
| 13 | - public class CustomAdHocConfig : FileSystemAdHocConfig { |
|
| 14 | - public static void InitializeReporting() { |
|
| 15 | - //Check to see if we've already initialized. |
|
| 16 | - if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 17 | - return; |
|
| 18 | - //Initialize System |
|
| 19 | - AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"; |
|
| 20 | - AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"; |
|
| 21 | - AdHocContext.Driver.ConnectionStringRW = "INSERT_CONNECTION_STRING_HERE"; // ConnectionStringRW was used |
|
| 22 | - ... |
|
| 23 | - } |
|
| 24 | -} |
|
| 25 | -``` |
|
| 26 | - |
|
| 27 | -##Global.asax (VB.NET) |
|
| 28 | - |
|
| 29 | -```visualbasic |
|
| 30 | - |
|
| 31 | -'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 32 | -Public Class CustomAdHocConfig |
|
| 33 | - Inherits Izenda.AdHoc.DatabaseAdHocConfig |
|
| 34 | 9 | |
| 35 | - Shared Sub InitializeReporting() |
|
| 36 | - 'Check to see if we've already initialized |
|
| 37 | - If HttpContext.Current.Session Is Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then |
|
| 38 | - Return |
|
| 39 | - 'Initialize System |
|
| 40 | - AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE" |
|
| 41 | - AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE" |
|
| 42 | - AdHocContext.Driver.ConnectionStringRW = "INSERT_CONNECTION_STRING_HERE" |
|
| 10 | +##Answer |
|
| 43 | 11 | |
| 44 | 12 | |
| 45 | - End Sub |
|
| 13 | +Multiple constraints can be stored in application as below. |
|
| 46 | 14 | |
| 47 | -End Class |
|
| 48 | -``` |
|
| 49 | - |
|
| 50 | -Though ConnectionStringRW doesn't require Fusion, if you want to use Fusion together with ConnectionStringRW, read-only connection strings should be used everywhere in Fusion/DB initialization, and assign read/write connection string here: |
|
| 51 | 15 | |
| 52 | -```csharp |
|
| 53 | -FusionDriver fd = new FusionDriver(); |
|
| 54 | - fd.AddConnection("_alias_", FusionConnectionType.MsSql, "_read_only_connection_string_"); |
|
| 55 | - AdHocContext.Driver = fd; |
|
| 56 | - AdHocSettings.AdHocConfig = new CustomAdHocConfig(); |
|
| 57 | - ((DatabaseAdHocConfig) AdHocSettings.AdHocConfig).SavedReportsDriver = new MSSQLDriver("_read_only_connection_string_"); |
|
| 58 | - ((DatabaseAdHocConfig) AdHocSettings.AdHocConfig).SavedReportsDriver.ConnectionStringRW = "_read/write_connection_string_"; |
|
| 59 | -``` |
|
| 60 | 16 | |
| 61 | -##How ConnectionStringRW works |
|
| 17 | +1) Before adding constraints, put this line of code: |
|
| 62 | 18 | |
| 63 | -1) If ConnectionStringRW is not assigned, Izenda uses Driver.ConnectionString for all operations against DB |
|
| 19 | + Izenda.AdHoc.Database.Driver driver = AdHocContext.Driver; |
|
| 64 | 20 | |
| 65 | -2) If ConnectionStringRW is also assigned, then Izenda will |
|
| 21 | +and change all their "AdHocContext.Driver.AddConstraint(...)" lines to "driver.AddConstraint(...)" |
|
| 66 | 22 | |
| 67 | - ---a) Use Driver.ConnectionString for Read-Only operations against DB, thus Driver.ConnectionString can have ReadOnly access to the DB |
|
| 23 | +2) Add following line of code right before adding first custom constraint: |
|
| 68 | 24 | |
| 69 | - ---b) Use Driver.ConnectionStringRW for Read-Write operations. At this moment this includes only following: |
|
| 25 | + AdHocContext.Driver.BeginAddingMultipleConstraints(); |
|
| 70 | 26 | |
| 71 | - - Create Reports table if it doesn't exist |
|
| 27 | +3) Add following line of code right after adding last custom constraint: |
|
| 72 | 28 | |
| 73 | - - Create/Update/Delete Thumbnails in Reports table in Database mode |
|
| 29 | + AdHocContext.Driver.EndAddingMultipleConstraints(); |
|
| 74 | 30 | |
| 75 | - - Create/Update/Delete Forms in Reports table in Database mode |
|
| 31 | +##Global.asax (C♯) |
|
| 32 | +```csharp |
|
| 76 | 33 | |
| 77 | - - Create/Save/Delete ReportSets in Reports table in Database mode |
|
| 34 | + public class CustomAdHocConfig : FileSystemAdHocConfig { |
|
| 35 | + public static void InitializeReporting() { |
|
| 36 | + //Check to see if we've already initialized. |
|
| 37 | + if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 38 | + return; |
|
| 78 | 39 | |
| 40 | + Izenda.AdHoc.Database.Driver driver = AdHocContext.Driver; //before adding any constraints, put this line |
|
| 79 | 41 | |
| 80 | -[Here](http://www.screencast.com/users/IzendaReports/folders/Temporary/media/9a2e633c-bbc7-4c47-9425-8df36d36e368) is the video explaining how to create ReadOnly connection string in MSSQL |
|
| 42 | + AdHocContext.Driver.BeginAddingMultipleConstraints(); // add as many constraints as you want between begin and end |
|
| 43 | + |
|
| 44 | + driver.AddConstraint("[dbo].[Orders].[CustomerID]", "[dbo].[Invoices].[CustomerID]"); |
|
| 45 | + |
|
| 46 | + driver.AddConstraint("[dbo].[Orders].[OrderID]", "[dbo].[Invoices].[OrderID]"); |
|
| 47 | + |
|
| 48 | + AdHocContext.Driver.EndAddingMultipleConstraints(); |
|
| 49 | + ... |
|
| 50 | + } |
|
| 51 | +} |
|
| 52 | +``` |
|
| 81 | 53 | |
| 82 | -[Here](http://www.screencast.com/users/IzendaReports/folders/Temporary/media/a04a117c-89d1-40f3-8053-55d0d7586d1a) is video demonstrating how installation works when Driver.ConnectionStringRW is assigned for read-write operations, and Driver.ConnectionString has ReadOnly access: |
|
| 83 | 54 | |
| 84 | -##Usage |
|
| 85 | -ConnectionStringRW can be used always. General case is just safety improvement - if user specifies ConnectionStringRW, and uses read-only DB account for usual Driver.ConnectionString - he can be 100% sure that users will not be able to modify anything in DB by any means - like using SQL injections. Just because everything which user can input - goes to DB via read-only connection string. |
|
| 86 | 55 | |
| 87 | -## |
|
| 88 | 56 |