Guides/Izenda-AdHoc-Driver.md
... ...
@@ -115,20 +115,26 @@ AdHocContext.Driver = fusionDriver;
115 115
116 116
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.
117 117
118
-#####a) Adding a connection to the local MSSQL database.
118
+#####a) Adding a direct and indirect database connection using the Fusion Driver:
119 119
120
-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:
120
+You can use the standard SqlServerConnectionString to connect to your database directly and also use the FusionDriver's capabilities to connect to an indirect database connection (like OData) at the same time:
121 121
122 122
```csharp
123
-fusionDriver.AddConnection("SqlNW", FusionConnectionType.MsSql, "server=(local);database=Northwind;Trusted_Connection=True;");
123
+AdHocSettings.SqlServerConnectionString = "my_direct_connection_string";
124
+Izenda.Fusion.FusionDriver.AddODataConnection("OD", @"http://url_to_odata_connector.com/provider_endpoint.aspx");
124 125
```
125 126
126
-#####b) Adding a connection to the OData provider.
127
+#####b) Adding multiple indirect data connections.
127 128
128
-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:
129
+You can use the FusionDriver to add multiple indirect database connections to your Driver's context:
129 130
130 131
```csharp
131
-fusionDriver.AddConnection("OrclNW", FusionConnectionType.OData, "http://www.providerdomain.com/provider_endpoint.aspx");
132
+//only for direct connections
133
+//AdHocSettings.SqlServerConnectionString = "my_direct_connection_string";
134
+Izenda.Fusion.FusionDriver fd = new Izenda.Fusion.FusionDriver();
135
+fd.AddConnection("OD", Izenda.Fusion.FusionConnectionType.OData, @"http://url_to_odata_connector.com/provider_endpoint.aspx");
136
+fd.AddConnection("OD2", Izenda.Fusion.FusionConnectionType.OData, @"http://url_to_odata_2_connector.com/provider_endpoint.aspx");
137
+AdHocSettings.AdHocContext.Driver = fd;
132 138
```
133 139
134 140
####3. Set up additional settings
... ...
@@ -140,24 +146,34 @@ The Izenda Fusion Driver has several additional settings:
140 146
This is setup the same way as for a single connection. Only data sources with the specified names will be available:
141 147
142 148
```csharp
143
-fusionDriver.VisibleDataSources = new string[] { "Orders", "Customers", "Order Details" };
149
+AdHocSettings.VisibleDataSources = new string[] { "Orders", "Customers", "Order Details" };
144 150
```
145 151
146 152
#####b) Constraints
147 153
148
-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:
154
+This is setup the same as for single connection except that you are able to specify separate constraints for each connection by using connection aliases. Note that you can use wildcard characters to set up constraints:
155
+
156
+**Example 1:** Static context
157
+
158
+```csharp
159
+Izenda.Fusion.FusionDriver.AddConstraintSimple("OD/Order.Id", "OD/*.OrderID");
160
+Izenda.Fusion.FusionDriver.RemoveConstraintSimple("OD2/Account.Id", "OD2/User.AccountID");
161
+```
162
+
163
+**Example 2:** reference context
149 164
150 165
```csharp
151
-fusionDriver.AddConstraint("SqlNW/Order.Id", "SqlNW/*.OrderID");
152
-fusionDriver.RemoveConstraint("OrclNW/Account.Id", "OrclNW/User.AccountID");
166
+Izenda.Fusion.FusionDriver fd = new FusionDriver();
167
+fd.AddConstraint("OD/Order.Id", "OD/*.OrderID");
168
+fd.AddConstraint("OD2/Account.Id", "OD2/User.AccountID");
153 169
```
154 170
155
-#####c) ReportingConnectionString
171
+#####c) Saving Reports with Fusion
156 172
157
-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).
173
+If you are using DatabaseAdHocConfig and reports are stored in the database, you need to explicitly specify the connection you will use for saving reports. The following example sets up the connection string to the database that contains the reports table. If you store reports in the file system then skip this step(use FileSystemAdHocConfig if you do this).
158 174
159 175
```csharp
160
-((FusionAdHocConfig)AdHocSettings.AdHocConfig).ReportingConnectionString = "server=(local);database=Reports;Trusted_Connection=True;";
176
+((DatabaseAdHocConfig)AdHocSettings.AdHocConfig).SavedReportsDriver = new MSSQLDriver("your_mssql_direct_database_connection_string");
161 177
```
162 178
163 179
#####d) Set up cache
... ...
@@ -174,6 +190,10 @@ You can configure the cache yourself by using the following properties and metho
174 190
175 191
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:
176 192
193
+####SQL/Oracle/MySql data connection
194
+
195
+The following example describes the process for initializing a FusionDriver connection when you have direct access to a SQL/Oracle/MySQL database where you want to store your reports. This database **does not** have to be the same database you obtain your schema from. Your CustomAdHocConfig class can inherit from either [[DatabaseAdHocConfig|http://wiki.izenda.us/FAQ/Storing-Reports#Database-Mode]] or [[FileSystemAdHocConfig|http://wiki.izenda.us/FAQ/Storing-Reports#File-System-Mode]] in this case:
196
+
177 197
```csharp
178 198
<%@ Application Language="C#" %>
179 199
<%@ Import Namespace="System.Data"%>
... ...
@@ -183,7 +203,8 @@ Below is a full example of how to set up and configure the Izenda Fusion Driver
183 203
184 204
<script runat="server">
185 205
[Serializable]
186
-public class CustomAdHocConfig : Izenda.AdHoc.FileSystemAdHocConfig
206
+//If SavedReportsDriver is set, you can use DatabaseAdHocConfig or FileSystemAdHocConfig
207
+public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig //Izenda.AdHoc.FileSystemAdHocConfig
187 208
{
188 209
public static void InitializeReporting()
189 210
{
... ...
@@ -191,32 +212,93 @@ public class CustomAdHocConfig : Izenda.AdHoc.FileSystemAdHocConfig
191 212
AdHocSettings.LicenseKey = "LICENSE KEY";
192 213
193 214
// Set config. Note: config class must derive from FusionAdHocConfig or FileSystemAdHocConfig
194
- AdHocSettings.AdHocConfig = new CustomFusionAdHocConfig();
215
+ AdHocSettings.AdHocConfig = new CustomAdHocConfig();
195 216
196 217
// Create Fusion driver and set it as default driver for AdHoc
197
- FusionDriver fusionDriver = new FusionDriver();
198
- AdHocContext.Driver = fusionDriver;
218
+ Izenda.Fusion.FusionDriver fusionDriver = new Izenda.Fusion.FusionDriver();
199 219
200
- // Add visible data sources
201
- fusionDriver.VisibleDataSources = new string[] { "Orders", "Customers", "Order Details" };
220
+ //Initialize the connections on the driver
221
+ fusionDriver.AddConnection("SqlNW", Izenda.Fusion.FusionConnectionType.MsSql, @"http://url_to_odata_connector.com/provider_endpoint.aspx");
222
+ fusionDriver.AddConnection("OrclNW", Izenda.Fusion.FusionConnectionType.Oracle, @"http://url_to_odata_connector.com/provider_endpoint.aspx");
202 223
203 224
// Configure constraints for connections
204 225
fusionDriver.AddConstraint("SqlNW/Order.Id", "SqlNW/*.OrderID");
205
- fusionDriver.RemoveConstraint("OrclNW/Account.Id", "OrclNW/User.AccountID");
226
+ fusionDriver.AddConstraint("OrclNW/Account.Id", "OrclNW/User.AccountID");
206 227
228
+ //set the Driver object
229
+ AdHocContext.Driver = fusionDriver;
230
+
207 231
// Clear cache
208
- fusionDriver.DataCacheExpiration = DateTime.Now;
232
+ AdHocSettings.DataCacheExpiration = DateTime.Now;
209 233
210
- // Add some reports to the cache
211
- fusionDriver.CacheReport("Financial reports\Sales");
212
- fusionDriver.CacheReport("Common reports\Employees");
234
+ // Cache reports for less database load
235
+ AdHocSettings.CacheReports = true;
213 236
214 237
// Set connection to the database with reports table
215
- ((FusionAdHocConfig)AdHocSettings.AdHocConfig).ReportingConnectionString = "server=(local);database=ReportsDB;Trusted_Connection=True;";
238
+ ((DatabaseAdHocConfig)AdHocSettings.AdHocConfig).SavedReportsDriver = new MSSQLDriver("your_mssql_direct_database_connection_string");
239
+
240
+ // Add visible data sources
241
+ AdHocSettings.VisibleDataSources = new string[] { "Orders", "Customers", "Order Details" };
242
+ }
243
+}
244
+</script>
245
+```
246
+
247
+####OData connection
248
+
249
+The following example describes the process for initializing a FusionDriver connection when you have indirect data connections, such as OData:
250
+
251
+```csharp
252
+<%@ Application Language="C#" %>
253
+<%@ Import Namespace="System.Data"%>
254
+<%@ Import Namespace="Izenda.AdHoc.Database"%>
255
+<%@ Import Namespace="Izenda.AdHoc" %>
256
+<%@ Import Namespace="System.Configuration" %>
257
+<%@ Import Namespace="Izenda.Fusion" %>
258
+
259
+<script runat="server">
260
+[Serializable]
261
+public class CustomAdHocConfig : Izenda.AdHoc.FileSystemAdHocConfig
262
+{
263
+ public static void InitializeReporting()
264
+ {
265
+ // Set license key. Note: "+FUSION" must be in license key
266
+ AdHocSettings.LicenseKey = "LICENSE KEY";
267
+
268
+ // Set config. Note: config class must derive from FusionAdHocConfig or FileSystemAdHocConfig
269
+ AdHocSettings.AdHocConfig = new CustomFusionAdHocConfig();
270
+
271
+ // Add visible data sources
272
+ AdHocSettings.VisibleDataSources = new string[] { "Orders", "Customers", "Order Details" };
273
+
274
+ //Add connections to the driver (static context)
275
+ FusionDriver.AddODataConnection("OD", FusionConnectionType.OData, @"http://your_odata_schema_url");
276
+ FusionDriver.AddODataConnection("OD2", FusionConnectionType.OData, @"http://your_odata2_schema_url");
277
+
278
+ // Configure constraints for connections
279
+ FusionDriver.AddConstraintSimple("OD/Order.Id", "OD/*.OrderID");
280
+ FusionDriver.AddConstraintSimple("OD2/Account.Id", "OD2/User.AccountID");
281
+
282
+ // Clear cache
283
+ AdHocSettings.DataCacheExpiration = DateTime.Now;
284
+
285
+ // Add some reports to the cache
286
+ AdHocContext.CacheReports = true;
287
+
288
+ // Set connection to the database with the reports table. You CANNOT use an OData connection as your SavedReportsDriver connection string
289
+ ((FusionAdHocConfig)AdHocSettings.AdHocConfig).SavedReportsDriver = new MSSQLDriver("server=(local);database=ReportsDB;Trusted_Connection=True;");
216 290
}
217 291
}
292
+</script>
293
+```
294
+
295
+##CustomFusionDriver
296
+
297
+You can implement your own FusionDriver class to enable more control over features and settings. Below is an example of an overridden FusionDriver:
298
+
299
+```csharp
218 300
[Serializable]
219
-public class CustomFusionAdHocConfig : FusionAdHocConfig
301
+public class CustomFusionDriver : Izenda.Fusion.FusionDriver
220 302
{
221 303
public CustomFusionDriver()
222 304
{
... ...
@@ -235,7 +317,6 @@ public class CustomFusionAdHocConfig : FusionAdHocConfig
235 317
return base.GetDataSet(command, reportPart);
236 318
}
237 319
}
238
-</script>
239 320
```
240 321
241 322
###Overriding CustomFusionDriver Methods
... ...
@@ -280,19 +361,20 @@ public override bool RemoveConstraint(string fullyQualifiedPrimaryColumn, string
280 361
}
281 362
```
282 363
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.
364
+**Note:** The **GetAllConnections** method 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 365
285
-Here is a sample use of fusionConnections:
366
+Here is a code sample for using the **GetColumns** method to iterate through GetAllConnections:
286 367
287 368
```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];
369
+public override Column[] GetColumns(Izenda.AdHoc.Database.Table table) {
370
+ //return base.GetColumns(table);
371
+ Column[] cols = null;
372
+
373
+ foreach (Izenda.Fusion.FusionConnection fc in this.GetAllConnections()) {
374
+ cols = fc.GetColumns(table);
375
+ if (cols.Length > 0)
376
+ break;
377
+ }
378
+ return cols;
297 379
}
298 380
```
... ...
\ No newline at end of file