The Access Layer API contains a number of interfaces and classes that are required to interact with the runtime system. The main components are as follows:
IConnection interface – This interface provide methods and properties for establishing and maintaining a connection to the runtime system. The Connection class implements this interface.
IRtConnection interface – This interface provides methods and properties for exchanging data with the runtime system.
The DataHandler property of the IConnection interface is an instance of IRtConnection and provides a mechanism to exchange data between the client and the host application.
TransmissionObject – This object is used when sending and receiving data to or from the runtime system. It contains the current DataModel object being used for data exchange, information on the status of the transaction, and any error conditions.
DataModels – The DataModel defines an ispec or a class that was modeled in AB Suite Developer and generated for Access Layer API usage.
The basic flow of operations when developing a client application is as follows:
Instantiate a Connection object by using the static ConnectionFactory class.
This returns an instance of a Connection object when calling the Create() method.
Create a new ConnectionDetails object and set its properties with information about how to connect to the host application.
Perform a Connect() call on the Connection object by passing in the ConnectionDetails.
The Connect() method returns a TransmissionObject from which you can determine the status of the connection and the current DataModel (if the system returns a fireup ispec).
Populate the DataModel with new information by setting its properties.
Use the DataHandler object to send the DataModel details to the runtime system, with either the Transmit() or TransmitAsync() method.
The Transmit() or TransmitAsync() method returns an updated Transmission object that indicates the resulting state of the transaction and provides an updated DataModel, which might be for the same ispec or a new ispec.
Repeat steps 5 through 6 to perform additional transactions with the runtime system.
Close the connection by using the Connection object, Close() method.
The following code shows an example of these operations:
// Create a new connection to the AB Suite host system // Use the Access Layer API ConnectionFactory to create an instance of a Connection Interface class ABSConnection = ConnectionFactory.Create(new Sample.Custom.DataModels.Core.IspecFactory()); // Set up the ConnectionDetails object with information from Web.config ConnectionDetails cDetails = new ConnectionDetails() { Host = "localhost", IsAnonymous = true, System = "Sample, ForceLogin = true, AssemblyLocation = @"C:\ABSuite\Datamodels", LogFolder=@"C:\Temp", LogLevel="DEBUG" }; TransmissionObject trObj = ABSConnection.Connect(cDetails, null); if (trObj != null && (trObj.State == TransmissionReturnCode.Ok || trObj.State == TransmissionReturnCode.OkWithSwitch)) { SessionConnected = true; CurrentIspecName = trObj.ObjectClassName; } else SessionConnected = false; // Create an instance of a PRODModel class. PRODModel pModel = (PRODModel) ABSConnection.DataHandler.GetDataModelObject("PROD"); // Populate the PRODModel pModel._UserMAINT = "FIR"; // Transmit the PRODModel to the host system TransmissionObject tObject = ABSConnection.DataHandler.Transmit(pModel); // Check the return state and whether the current context is for the PROD ispec if (tObject.State == TransmissionReturnCode.Ok) { // Check the DataModel type in the returned TransmissionObject, // by using the ObjectClassName as the name of the Ispec. If it // is a type of PRODModel, extract the data. if (ABSConnection.DataHandler.GetDataModelType(tObject.ObjectClassName) == typeof(PRODModel)) { // Extract the Data from the PRDOModel object returned by the Connector. pModel = (PRODModel)tObject.Datamodel; string Name = pModel.NAM; string ID = pModel.PRODUCT; decimal price = pModel.SELLPRICE; Int32 reOrderLevel = pModel.REORDLEV; } } // Close the connection ABSConnection.Close();
See Access Layer API Interfaces for a detailed description of each interface, its properties, and events.