3da5651f79939e093c4d68ce3929a17c3236b7b7
Guides/Izenda-AdHoc-Driver.md
| ... | ... | @@ -1,18 +1,97 @@ |
| 1 | -#Izenda Fusion Driver |
|
| 1 | +#Izenda AdHoc Driver |
|
| 2 | 2 | |
| 3 | 3 | [[_TOC_]] |
| 4 | 4 | |
| 5 | -##How the Izenda Fusion Driver works |
|
| 5 | +##The AdHoc Driver class |
|
| 6 | + |
|
| 7 | +Izenda reports is designed as a modular system to be easily customizable for usage with any datasources. The ``AdHocContext`` class has a **Driver** property containing an instance of the ``Izenda.AdHoc.Database.Driver`` abstract class, which provides datasource metadata for Izenda AdHoc. All datasource drivers in Izenda AdHoc use this as their base class and layer functionality on top of it. |
|
| 8 | + |
|
| 9 | + |
|
| 10 | +**Figure 1:** The standard Izenda Driver model. Datasources are separate and the driver handles the heavy lifting of interacting with the datasources. |
|
| 11 | + |
|
| 12 | +###Customizing the Izenda AdHoc Driver |
|
| 13 | + |
|
| 14 | +The ``Izenda.AdHoc.Database.MSSQLDriver`` class implements complete functionality for using MSSQL server as your datasource and also allows you to create inheritors. So the easiest way to create a custom driver working with MSSQL server is to inherit ``Izenda.AdHoc.Database.MSSQLDriver`` and override the functionality you need to work differently. Below are complete instructions detailing how to perform this: |
|
| 15 | + |
|
| 16 | +1. Create new project with type of Class library in Visual Studio. |
|
| 17 | + |
|
| 18 | +**Figure 2:** |
|
| 19 | + |
|
| 20 | +2. Add Izenda.AdHoc.dll to the References in the project. |
|
| 21 | + |
|
| 22 | + |
|
| 23 | +**Figure 3:** |
|
| 24 | + |
|
| 25 | +3. Create new class and inherit MSSQLDriver: |
|
| 26 | + |
|
| 27 | +```csharp |
|
| 28 | +using Izenda.AdHoc.Database; |
|
| 29 | +namespace CustomDriver |
|
| 30 | +{ |
|
| 31 | + public class MyCustomDriver : MSSQLDriver |
|
| 32 | + { |
|
| 33 | + } |
|
| 34 | +} |
|
| 35 | +``` |
|
| 36 | +4. Now any metadata drilling functionality can be altered. Here we will implement overriding of two most important methods, assuming that we have a single custom source of data. For our example, we will assume the table **Products** exists with three fields: **Id**, **Name**, and **Price**: |
|
| 37 | + |
|
| 38 | +a. ``GetAllTables()`` returns an array of ``Izenda.AdHoc.Database.Table`` which will be available in the DataSources tab in the ReportDesigner as a list of datasources. Here is a short example of overriding this method: |
|
| 39 | + |
|
| 40 | +```csharp |
|
| 41 | +public override Table[] GetAllTables() |
|
| 42 | +{ |
|
| 43 | + Table[] result = new Table[1]; |
|
| 44 | + result[0] = new Table("Products"); |
|
| 45 | + return result; |
|
| 46 | +} |
|
| 47 | +``` |
|
| 48 | +b. GetColumns returns an array of Izenda.AdHoc.Database.Column for the given table. This array is used as fields list at several tabs in the ReportDesigner. Again, short example of overriding this method: |
|
| 49 | + |
|
| 50 | +public override Column[] GetColumns(Table table) |
|
| 51 | +{ |
|
| 52 | + if (table.Name == "Products") { |
|
| 53 | + Column[] result = new Column[3]; |
|
| 54 | + result[0] = new Column("Id", SqlType.UInt32); |
|
| 55 | + result[1] = new Column("Name", SqlType.VarChar); |
|
| 56 | + result[2] = new Column("Price", SqlType.Float); |
|
| 57 | + } |
|
| 58 | + else { |
|
| 59 | + throw new Exception("Unknown DataSource"); |
|
| 60 | + } |
|
| 61 | +} |
|
| 62 | + |
|
| 63 | +The overridden fields can be seen in the Fields tab on the Report Designer after selecting the DataSource "Products" at the DataSources tab. |
|
| 64 | + |
|
| 65 | +5. Include a reference to your ``CustomDriver`` to your website. To perform this, the following steps should be taken: |
|
| 66 | + a. Compile your ``CustomDriver`` project and copy the assembly to your website's /bin folder, and add the reference just like above. |
|
| 67 | + b. Set ``AdHocContext.Driver = new CustomDriver`` in the ``Session_Start()`` or ``Application_Start()`` method. |
|
| 68 | + |
|
| 69 | +6. You must also override some other methods like ``GetDataSet()``. This method accepts a ``System.Data.IDBCommand`` parameter, and returns the corresponding DataSet. Overriding this method allows you to pre-process the dataset before returning it. You may use ``AdHocContext.CurrentReportSet`` to get additional details of the report. For integrations that will not utilize SQL queries in the command object, ``Izenda.AdHoc.AdHocContext.CurrentReportSet`` may be used to get the report state. |
|
| 70 | + |
|
| 71 | +To override this method, simply add following strings to the MyCustomDriver class: |
|
| 72 | + |
|
| 73 | +```csharp |
|
| 74 | +public override DataSet GetDataSet(IDbCommand Command) |
|
| 75 | +{ |
|
| 76 | +DataSet result; |
|
| 77 | + result = base.GetDataSet(command); //If you want the driver to obtain DataSet and process it before returning |
|
| 78 | + |
|
| 79 | + //result = new DataSet(); //If you want to implement your own method for obtaining a DataSet. |
|
| 80 | + |
|
| 81 | + //more processing.... |
|
| 82 | + return result; |
|
| 83 | +} |
|
| 84 | + |
|
| 85 | +You can also see more coding examples in our [[Knowledge Base|http://izenda.com/Site/KB/CodeSamples/79]]. |
|
| 86 | + |
|
| 87 | +##Izenda Fusion Driver |
|
| 6 | 88 | |
| 7 | 89 | The Izenda Fusion Driver composes data sources from several connections (data providers) into a single data source. This is very similar to how [[SSAS|http://technet.microsoft.com/en-us/library/ms175609(v=sql.90).aspx]] works, but using Fusion you can aggregate data not only from MSSQL databases but from very different data sources. For example, you can get data from the [[OData|Guides/OData]] data provider (i.e. without a direct connection to the database). All you need to do is set up the data sources' connections and you will be able to work with aggregated data as a single data source. |
| 8 | 90 | |
| 9 | 91 |  |
| 10 | -**Figure 1:** Schematics of how the Fusion Driver interacts with different datasources |
|
| 11 | - |
|
| 12 | - |
|
| 13 | -**Figure 2:** The driver works directly with your datasources and provides Izenda AdHoc with complete information about tables, fields of tables, data types, etc. |
|
| 92 | +**Figure :** Schematics of how the Fusion Driver interacts with different datasources. Instead of working with individual datasources, it aggregates the datasources into one. |
|
| 14 | 93 | |
| 15 | -##Configuring the Izenda Fusion Driver |
|
| 94 | +###Configuring the Izenda Fusion Driver |
|
| 16 | 95 | |
| 17 | 96 | Configuring the Izenda Fusion Driver is almost the same as configuring the Izenda Driver with single connection. The main differences are: |
| 18 | 97 | |
| ... | ... | @@ -22,7 +101,7 @@ Configuring the Izenda Fusion Driver is almost the same as configuring the Izend |
| 22 | 101 | |
| 23 | 102 | Configuring the Izenda Fusion Driver consists of several steps: |
| 24 | 103 | |
| 25 | -###1. Create the Fusion Driver |
|
| 104 | +####1. Create the Fusion Driver |
|
| 26 | 105 | |
| 27 | 106 | At first you should create FusionDriver object and set up it as default driver for the Izenda AdHoc. Here is example how to do it in C#: |
| 28 | 107 | |
| ... | ... | @@ -31,11 +110,11 @@ FusionDriver fusionDriver = new FusionDriver(); |
| 31 | 110 | AdHocContext.Driver = fusionDriver; |
| 32 | 111 | ``` |
| 33 | 112 | |
| 34 | -###2. Add connections to the driver |
|
| 113 | +####2. Add connections to the driver |
|
| 35 | 114 | |
| 36 | 115 | Now you can add connections to the data sources end points. The end point could be a direct connection to the MSSQL database or it can be an OData connection to the MSSQL or Oracle database. |
| 37 | 116 | |
| 38 | -####a) Adding a connection to the local MSSQL database. |
|
| 117 | +#####a) Adding a connection to the local MSSQL database. |
|
| 39 | 118 | |
| 40 | 119 | You should specify the connection nickname in first parameter, the connection type of MSSQL in the second parameter, and the connection string in the last parameter: |
| 41 | 120 | |
| ... | ... | @@ -43,7 +122,7 @@ You should specify the connection nickname in first parameter, the connection ty |
| 43 | 122 | fusionDriver.AddConnection("SqlNW", FusionConnectionType.MsSql, "server=(local);database=Northwind;Trusted_Connection=True;"); |
| 44 | 123 | ``` |
| 45 | 124 | |
| 46 | -####b) Adding a connection to the OData provider. |
|
| 125 | +#####b) Adding a connection to the OData provider. |
|
| 47 | 126 | |
| 48 | 127 | You should specify the connection nickname in first parameter, the connection type of OData in the second parameter, and the link to the OData end point in the last parameter: |
| 49 | 128 | |
| ... | ... | @@ -51,11 +130,11 @@ You should specify the connection nickname in first parameter, the connection ty |
| 51 | 130 | fusionDriver.AddConnection("OrclNW", FusionConnectionType.OData, "http://www.providerdomain.com/provider_endpoint.aspx"); |
| 52 | 131 | ``` |
| 53 | 132 | |
| 54 | -###3. Set up additional settings |
|
| 133 | +####3. Set up additional settings |
|
| 55 | 134 | |
| 56 | 135 | The Izenda Fusion Driver has several additional settings: |
| 57 | 136 | |
| 58 | -####a) VisibleDataSources |
|
| 137 | +#####a) VisibleDataSources |
|
| 59 | 138 | |
| 60 | 139 | This is setup the same way as for a single connection. Only data sources with the specified names will be available: |
| 61 | 140 | |
| ... | ... | @@ -63,7 +142,7 @@ This is setup the same way as for a single connection. Only data sources with th |
| 63 | 142 | fusionDriver.VisibleDataSources = new string[] { "Orders", "Customers", "Order Details" }; |
| 64 | 143 | ``` |
| 65 | 144 | |
| 66 | -####b) Constraints |
|
| 145 | +#####b) Constraints |
|
| 67 | 146 | |
| 68 | 147 | This is setup the same as for single connection except that you are able to specify separate constraints for each connection by using connection nicknames. Note that you can use wildcard characters to set up constraints: |
| 69 | 148 | |
| ... | ... | @@ -72,7 +151,7 @@ fusionDriver.AddConstraint("SqlNW/Order.Id", "SqlNW/*.OrderID"); |
| 72 | 151 | fusionDriver.RemoveConstraint("OrclNW/Account.Id", "OrclNW/User.AccountID"); |
| 73 | 152 | ``` |
| 74 | 153 | |
| 75 | -####c) ReportingConnectionString |
|
| 154 | +#####c) ReportingConnectionString |
|
| 76 | 155 | |
| 77 | 156 | If reports are stored in the database you should specify connection string to that database. Note that in addition to this, you should also use FusionAdHocConfig instead of DatabaseAdHocConfig. The following example sets up the connection string to the database using the reports table. If you store reports in the file system then skip this step(use FileSystemAdHocConfig if you do this). |
| 78 | 157 | |
| ... | ... | @@ -80,7 +159,7 @@ If reports are stored in the database you should specify connection string to th |
| 80 | 159 | ((FusionAdHocConfig)AdHocSettings.AdHocConfig).ReportingConnectionString = "server=(local);database=Reports;Trusted_Connection=True;"; |
| 81 | 160 | ``` |
| 82 | 161 | |
| 83 | -####d) Set up cache |
|
| 162 | +#####d) Set up cache |
|
| 84 | 163 | |
| 85 | 164 | Getting data from several data source providers may take a lot of time and resources when many connections are added. This will result in a slow connection to the providers due to large amount of data being transferred, etc. That’s why the cache is enabled by default for the Izenda Fusion Driver. By default, cache expiration time is set to 12PM on Saturday. This means that every Saturday, the cache will be cleared and all data will be requested from the providers during the next session. |
| 86 | 165 | |
| ... | ... | @@ -90,7 +169,7 @@ You can configure the cache yourself by using the following properties and metho |
| 90 | 169 | * **CacheAllReports method:** Adds all available reports to the cache: ``fusionDriver.CacheAllReports();`` |
| 91 | 170 | * **CacheReport method:** Adds a single report with the specified name to the cache: ``fusionDriver.CacheReport(string reportFullName);`` |
| 92 | 171 | |
| 93 | -##Sample use |
|
| 172 | +###Sample use |
|
| 94 | 173 | |
| 95 | 174 | Below is a full example of how to set up and configure the Izenda Fusion Driver with several connections and reports stored in your database: |
| 96 | 175 | |
| ... | ... | @@ -146,14 +225,4 @@ Below is a full example of how to set up and configure the Izenda Fusion Driver |
| 146 | 225 | } |
| 147 | 226 | } |
| 148 | 227 | </script> |
| 149 | -``` |
|
| 150 | - |
|
| 151 | -##Customizing the Izenda Fusion driver |
|
| 152 | - |
|
| 153 | -Izenda reports is designed as a modular system to be easily customizable for usage with any datasources. The ``AdHocContext`` class has a **Driver** property containing an instance of ``Izenda.AdHoc.Database.Driver`` abstract class, which provides datasource metadata for Izenda AdHoc. |
|
| 154 | - |
|
| 155 | -The ``Izenda.AdHoc.Database.MSSQLDriver`` class implements complete functionality for using MSSQL server as your datasource and also allows you to create inheritors. So the easiest way to create a custom driver working with MSSQL server is to inherit ``Izenda.AdHoc.Database.MSSQLDriver`` and override the functionality you need to work differently. Below is complete instruction on performing this. |
|
| 156 | - |
|
| 157 | -1. Create new project with type of Class library in Visual Studio (Figure 2). |
|
| 158 | - |
|
| 159 | -2. |
|
| 228 | +``` |
|
| ... | ... | \ No newline at end of file |