e3f23f2f37c8478147c6b6509240d09061ce6a2f
Guides/Izenda-AdHoc-Driver.md
| ... | ... | @@ -12,18 +12,11 @@ Izenda reports is designed as a modular system to be easily customizable for usa |
| 12 | 12 | ###Customizing the Izenda AdHoc Driver |
| 13 | 13 | |
| 14 | 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 | 15 | |
| 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: |
|
| 16 | +**1.** Create new project with type of Class library in Visual Studio. |
|
| 17 | +**2.** Add Izenda.AdHoc.dll to the References in the project. |
|
| 26 | 18 | |
| 19 | +**3.** Create new class and inherit MSSQLDriver: |
|
| 27 | 20 | ```csharp |
| 28 | 21 | using Izenda.AdHoc.Database; |
| 29 | 22 | namespace CustomDriver |
| ... | ... | @@ -33,10 +26,9 @@ namespace CustomDriver |
| 33 | 26 | } |
| 34 | 27 | } |
| 35 | 28 | ``` |
| 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 | - |
|
| 29 | +**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**: |
|
| 30 | + |
|
| 31 | +**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: |
|
| 40 | 32 | ```csharp |
| 41 | 33 | public override Table[] GetAllTables() |
| 42 | 34 | { |
| ... | ... | @@ -45,30 +37,35 @@ public override Table[] GetAllTables() |
| 45 | 37 | return result; |
| 46 | 38 | } |
| 47 | 39 | ``` |
| 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 | - |
|
| 40 | + |
|
| 41 | +**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: |
|
| 42 | + |
|
| 43 | +```csharp |
|
| 50 | 44 | public override Column[] GetColumns(Table table) |
| 51 | 45 | { |
| 52 | 46 | if (table.Name == "Products") { |
| 53 | 47 | 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); |
|
| 48 | + result[0] = new Column("ProductID", SqlType.UInt32); |
|
| 49 | + result[1] = new Column("ProductName", SqlType.VarChar); |
|
| 50 | + result[2] = new Column("UnitPrice", SqlType.SqlMoney); |
|
| 57 | 51 | } |
| 58 | 52 | else { |
| 59 | 53 | throw new Exception("Unknown DataSource"); |
| 60 | 54 | } |
| 61 | 55 | } |
| 56 | +``` |
|
| 62 | 57 | |
| 63 | 58 | The overridden fields can be seen in the Fields tab on the Report Designer after selecting the DataSource "Products" at the DataSources tab. |
| 64 | 59 | |
| 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. |
|
| 60 | +**5.** Include a reference to your ``CustomDriver`` to your website. To perform this, the following steps should be taken: |
|
| 61 | + |
|
| 62 | +**a)** Compile your ``CustomDriver`` project and copy the assembly to your website's /bin folder, and add the reference just like above. |
|
| 63 | + |
|
| 64 | +**b)** Set ``AdHocContext.Driver = new CustomDriver`` in the ``Session_Start()`` or ``Application_Start()`` method. |
|
| 68 | 65 | |
| 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. |
|
| 66 | +**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 | 67 | |
| 71 | -To override this method, simply add following strings to the MyCustomDriver class: |
|
| 68 | +To override this method, simply add following method to the MyCustomDriver class: |
|
| 72 | 69 | |
| 73 | 70 | ```csharp |
| 74 | 71 | public override DataSet GetDataSet(IDbCommand Command) |