USoft Custom Data Provider

Previous Next

See Also

A data provider in the .NET framework serves as a bridge between an application and a data source. A data provider is used to retrieve and/or manipulate data from a data source.

USoft has provided a read-only custom .NET data provider, REDataProvider.dll, that will reconnect back to the same Rules Engine and retrieve data. This USoft custom data provider is a standard data provider so it can be used in the same way as any other ADO.NET data provider.

REDataProvider.dll details:

· Namespace: USoftDataProvider

 

· Assembly: REDataProvider.dll

 

· Classes are listed in the following table:

USoftConnection

Represents a connection to a running Rules Engine. Inherits from DbConnection

USoftCommand

Represents a SQL statement to execute against a running Rules Engine. Inherits from DbCommand

USoftDataReader

Provides a way of reading a forward-only stream of rows from a running Rules Engine. Inherits from DbDataReader

USoftParameter

Represents a parameter to a USoftCommand. Inherits from IDataParameter

USoftParameterCollection

Represents a collection of parameters associated with a USoftCommand. Inherits from ArrayList, IDataParameterCollection.

USoftTransaction

Not supported

USoftDataAdapter

Not supported

 

To connect back to the Rules Engine you need to derive your class from a predefined RulesEngine class. In order to acquire a connection to the Rules Engine you need to call a predefined getConnection() function. This function returns a USoftConnection object, and from then on you can work with the connection object in the standard ADO.Net manner.

Example:

using System;

using System.Data;

using UsoftDataProvider;

 

class RulesEngineSQL

{

public static string sql = "SELECT p.email_address FROM person p, participant pt WHERE p.person_id = pt.person_id and pt.res_id = ?";

}

 

class DBExample : RulesEngine

{

public void InformParticipans(int reservation_id, string message)

{

USoftConnection conn = getConnection();

conn.Open();

USoftCommand cmd = (USoftCommand)conn.CreateCommand();

cmd.CommandText = RulesEngineSQL.sql;

USoftParameter p = new USoftParameter("reservation_id", DbType.Int32);

p.Value = reservation_id;

cmd.Parameters.Add(p);

IDataReader reader = cmd.ExecuteReader();

while (reader.Read())

{

String email = reader.GetString(0) ;

//send an email to participant

}

reader.Close();

conn.Close();

}

}

For more information on .NET data sources refer to http://msdn.microsoft.com.

NOTE:

To take advantage of planned future developments related to cross referencing of SQL within C# code, we advise you to declare all your SQL statements as static attributes in the RulesEngineSQL class.