Guides/Izenda-AdHoc-Driver.md
... ...
@@ -182,7 +182,10 @@ Below is a full example of how to set up and configure the Izenda Fusion Driver
182 182
<%@ Import Namespace="System.Configuration" %>
183 183
184 184
<script runat="server">
185
- void Session_Start(object sender, EventArgs e)
185
+[Serializable]
186
+public class CustomAdHocConfig : Izenda.AdHoc.FileSystemAdHocConfig
187
+{
188
+ public static void InitializeReporting()
186 189
{
187 190
// Set license key. Note: "+FUSION" must be in license key
188 191
AdHocSettings.LicenseKey = "LICENSE KEY";
... ...
@@ -192,12 +195,7 @@ Below is a full example of how to set up and configure the Izenda Fusion Driver
192 195
193 196
// Create Fusion driver and set it as default driver for AdHoc
194 197
FusionDriver fusionDriver = new FusionDriver();
195
- AdHocContext.Driver = fusionDriver;
196
-
197
- // Add connection to the local MSSQL database
198
- fusionDriver.AddConnection("SqlNW", FusionConnectionType.MsSql, "server=(local);database=Northwind;Trusted_Connection=True;");
199
- // Add connection to the OData provider which is connected to the Oracle database
200
- fusionDriver.AddConnection("OrclNW", FusionConnectionType.OData, "http://www.providerdomain.com/Oracle/FusionEndpoint.aspx");
198
+ AdHocContext.Driver = fusionDriver;
201 199
202 200
// Add visible data sources
203 201
fusionDriver.VisibleDataSources = new string[] { "Orders", "Customers", "Order Details" };
... ...
@@ -216,14 +214,85 @@ Below is a full example of how to set up and configure the Izenda Fusion Driver
216 214
// Set connection to the database with reports table
217 215
((FusionAdHocConfig)AdHocSettings.AdHocConfig).ReportingConnectionString = "server=(local);database=ReportsDB;Trusted_Connection=True;";
218 216
}
219
-
220
- [Serializable]
221
- public class CustomFusionAdHocConfig : FusionAdHocConfig
217
+}
218
+[Serializable]
219
+public class CustomFusionAdHocConfig : FusionAdHocConfig
220
+{
221
+ public CustomFusionDriver()
222
+ {
223
+ // Add connection to the local MSSQL database
224
+ this.AddConnection("SqlNW", FusionConnectionType.MsSql, "server=(local);database=Northwind;Trusted_Connection=True;");
225
+ // Add connection to the OData provider which is connected to the Oracle database
226
+ this.AddConnection("OrclNW", FusionConnectionType.OData, "http://www.providerdomain.com/Oracle/FusionEndpoint.aspx");
227
+ }
228
+
229
+ public override System.Data.DataSet GetDataSet(System.Data.IDbCommand command, string reportPart)
222 230
{
223
- public override void ConfigureSettings()
224
- {
225
-
226
- }
231
+ // You could use AdHocContext.CurrentReportSet property here to get the executing report
232
+
233
+ // Replace with custom code
234
+ // For ex. add some caching here and then call base method to retrieve data
235
+ return base.GetDataSet(command, reportPart);
227 236
}
237
+}
228 238
</script>
239
+```
240
+
241
+###Overriding CustomFusionDriver Methods
242
+
243
+You could also override other methods to customize getting data. Here are the most commonly used:
244
+
245
+```csharp
246
+// Get array of all available tables from all connections
247
+public override Izenda.AdHoc.Database.Table[] GetAllTables()
248
+{
249
+ return base.GetAllTables();
250
+}
251
+
252
+// Get array of all available tables from all connections
253
+public override StoredProcedure[] GetAllStoredProcedures()
254
+{
255
+ return base.GetAllStoredProcedures();
256
+}
257
+
258
+// Get array of all columns in tables from all connections
259
+public override Column[] GetColumns(Izenda.AdHoc.Database.Table table)
260
+{
261
+ return base.GetColumns(table);
262
+}
263
+
264
+// Get array of all tables constraints from all connections
265
+public override Constraint[] GetConstraints(DatabaseSchema schema)
266
+{
267
+ return base.GetConstraints(schema);
268
+}
269
+
270
+// Add new virtual constraint
271
+public override void AddConstraint(string primaryColumn, string foreignColumn)
272
+{
273
+ base.AddConstraint(primaryColumn, foreignColumn);
274
+}
275
+
276
+// Remove constraint
277
+public override bool RemoveConstraint(string fullyQualifiedPrimaryColumn, string fullyQualifiedForeignColumn)
278
+{
279
+ return base.RemoveConstraint(fullyQualifiedPrimaryColumn, fullyQualifiedForeignColumn);
280
+}
281
+```
282
+
283
+**Note:** The **fusionConnections** property within the **FusionDriver** class is where all connections for the current driver are stored. You can iterate over the collection and ping the database with a small bit of data in order to determine if the connection string you are using is obtaining results properly.
284
+
285
+Here is a sample use of fusionConnections:
286
+
287
+```csharp
288
+public override Column[] GetColumns(Izenda.AdHoc.Database.Table table)
289
+{
290
+ foreach (FusionConnection fusionConnection in this.fusionConnections)
291
+ {
292
+ Column[] columns = fusionConnection.GetColumns(table);
293
+ if (columns.Length > 0)
294
+ return columns;
295
+ }
296
+ return new Column[0];
297
+}
229 298
```
... ...
\ No newline at end of file