USoft Custom Data Provider |
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:
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. |