The IConnection interface exposes the properties listed in the following table:
Properties | Description |
---|---|
Gets an object to handle the exchange of data with the runtime system. This object implements the IRtConnection interface, which exposes methods and properties used for handling the data exchanged between the client and the host applications. | |
Gets a value indicating whether the connection is busy at the moment. | |
Gets a value indicating whether the connection is established. | |
Returns the logger object to the client. The client can then use this object to log information in the same log file as the Access Layer API. | |
Gets an IUnsolicitedMessages instance to handle the unsolicited messages. | |
Returns an integer value that contains the session id of the connection. | |
Holds the current status information of the connection sent by the runtime system. |
The DataHandler property gets an object to handle the exchange of data with the runtime system by using the IRtConnection interface.
Refer to the IRtConnection interface for more information on the methods and properties supported by DataHandler property.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
IRtConnection DataHandler { get; }
Using the IConnection Interface for the DataHandler Property
The following code shows an example of using the DataHandler property to transmit the data from a specific DataModel to the host application:
// Get an instance of the PROD DataModel PRODModel pModel = (PRODModel) ABSConnection.GetDataModelObject("PROD"); // Set the required attributes pModel._UserMAINT = "FIR"; // Perform the Transmit request to the host application. // The AccessLayer API returns a Transmission object containing // the data for the returned Ispec response from the host. TransmissionObject trObj = ABSConnection.DataHandler.Transmit(pModel);
The IsBusy property gets a value indicating whether the connection is busy at the moment.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
bool IsBusy { get; }
Using the IConnection Interface for the IsBusy Property
The following code shows an example of using the IsBusy property:
// Call the ConnectAsync method // Specify the ConnectionComplete method as the callback ABSConnection.ConnectAsync(cDetails, null, ConnectionComplete); // Check if the Connection object is busy and log a message if (ABSConnection.IsBusy) ApplicationLogger.LogDebug(() => string.Format("Connection object is processing a request."));
The IsConnected property gets a value indicating whether the connection is established with the runtime. This property returns true if the connection is established with the runtime system. It returns false if the connection is not established with the runtime.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
bool IsConnected { get; }
Using the IConnection Interface for the IsConnected Property
The following code is an example of using the IsConnected property:
// Callback method to handle the result of the Connect processing void ConnectionComplete(TransmissionObject trObj) { // Check if the session is connected successfully if (ABSConnection.IsConnected) { SessionConnected = true; } else SessionConnected = false; }
The Logger property returns the Logger object to the client.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
ILogger Logger { get; }
Using the IConnection Interface for the Logger Property
The following code is an example of using the Logger property:
// Create a new connection to the AB Suite host system // Use the Access Layer API ConnectionFactory to create an instance of a Connection class // The log settings (level and logPath) can be initialized in the Create method ABSConnection = ConnectionFactory.Create(new Sample.Custom.DataModels.Core.IspecFactory(), level: "DEBUG", logPath: @"C:\Temp\MVC"); // Obtain the Logger object from the Connection ApplicationLogger = ABSConnection.Logger; // Log a message ApplicationLogger.LogInfo(() => string.Format("My Log Message."));
The MessageHandler property gets an object that implements the IUnsolicitedMessages interface to handle unsolicited messages sent from the runtime system.
See IUnsolicitedMessages Interface for more information on the methods and properties supported by the MessageHandler property.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
bool MessageHandler { get; }
Using the IConnection Interface for the MessageHandler Property
The following code is an example of using the MessageHandler property to register an event that notifies the application when an unsolicited message has arrived. The MessagesHandler object contains a MessageQueue where Unsolicited messages are queued for processing and the application is informed of a CollectionChanged event when a new message arrives. The QueueUpdate() method is then called to process the message. The CommandResponsesBuilder builds up a list of unsolicited messages in a string that can be displayed in the client application.
// Use a string builder to store responses from the host application CommandResponesBuilder = new StringBuilder(); // Register for the CollectionChanged event on the MessageQueue property // The QueueUpdate handler processes the responses when they are received. ABSConnection.MessagesHandler.MessageQueue.CollectionChanged += (o, e) => { this.QueueUpdate(e, ABSConnection.MessagesHandler.MessageQueue, this.CommandResponesBuilder); };
The SessionId property returns an integer value that contains the session id of the connection.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
int SessionId { get; }
Using the IConnection Interface for the SessionId Property
The following code is an example of using the SessionId property:
MyLogger.Log(“Session Id “ + myConnection.SessionId)
The Status property holds the current status information of the connection sent by the runtime system.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
string Status { get; }
Using the IConnection Interface for the Status Property
The following code is an example of using the Status property:
// Callback method to handle the result of the Connect processing void ConnectionComplete(TransmissionObject trObj) { // Check if the session is connected successfully if (ABSConnection.IsConnected) { SessionConnected = true; // Get the current Status information returned from the application String StatusMsg = ABSConnection.Status; } else SessionConnected = false; }