The Connect method is used to establish a connection with the runtime system through a synchronous call that blocks the client application calling it. The ConnectAsync() method can be used if you do not want a blocking call.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
TransmissionObject Connect (ConnectionDetails details, ATTConnectionDetails attDetails)
Arguments
details – This argument provides the connection details in an instance of the ConnectionDetails class.
The ConnectionDetails class defines properties required to establish a connection with the runtime through the Access Layer API. To use the ConnectionDetails class with the Connect method, an instance of the class must be created and populated with the required information to be used by the Connect method.
The ConnectionDetails class exposes the members listed in the following table:
Members of ConnectionDetails Class
Name | Type | Description |
---|---|---|
ConnectToDebbuger | Boolean | Specifies whether the connection is using a debugger session. |
DownLoadCredentials | String | Specifies the user credentials to download dependent assemblies. For example, this might be required if the DownloadURI specifies an FTP server. |
DownLoadFiles | IEnumerable<String> | Specifies a collection of assemblies required for a specific client application. |
DownLoadURI | String | Specifies the location from where the required assemblies can be downloaded. |
FileRepositoryDirectory | String | Specifies the location that can be used for uploading and downloading files, such as images, from or to the client. |
ForceLogin | Boolean | Specifies whether the connection should forcibly override an existing session. |
GateWayAddress | String | Specifies the Gateway address to be used when a WCF Gateway is used for the connection. |
Host | String | Specifies the machine name or the IP address where the runtime system has been deployed. |
IsAnonymous | Boolean | Determines whether the connection uses an anonymous login. |
StationName | String | Specifies the station name to be used for the connection |
System | String | Specifies the name of the runtime system with which a connection must be established. This is the deployed component name in COM+. |
AssemblyLocation | String | This argument provides the root path to the dependent Access Layer API DataModels assembly. The Access Layer API tries to find a subfolder in this path that matches the System name (for example, Sample). It expects to find the DataModels assembly in this subfolder. For example, if the AssemblyLocation is specified as “C:\ABSuite\Models”, and the System name is “Sample”, then the DataModels assembly should exist in the “C:\ABSuite\Models\Sample” directory. |
attDetails – This argument provides the ATT recording configuration details in an instance of the ATTConnectionDetails class.
The ATTConnectionDetails class provides properties required to record and playback test cases by using ATT.
This argument can be set to null when ATT recording is not required.
The ATTConnectionDetails class exposes the members listed in the following table:
Members of ATTConnectionDetails Class
Name | Type | Description |
---|---|---|
Enable | Boolean | Determines whether the ATT recording must be turned on or off. True = On; False = Off. |
FileName | String | Specifies the file name used to store recorded test cases for ATT. |
Mode | ConnectionMode | Specifies the ConnectionMode to record the ATT test cases. The ConnectionMode can be either Connected or Disconnected. |
Port | Port | Specifies the ATT Port number to record the ATT test cases. |
RecordDynamicLists | Boolean | Specifies whether the dynamic list content should be recorded for validation during playback. |
Server | String | Specifies the address of the ATT Service to be used for recording. |
System | String | Specifies the name of the system to which a connection must be established. |
Return Value
If this method succeeds, it returns a TransmissionObject containing a DataModel for the fireup ispec. If the Connect call fails, the TransmissionObject returns null.
Using the IConnection Interface for the Connect Method
The following code shows an example of using the Connect() method to perform a synchronous connection to the host system:
// Method to establish a host connection public void EstablishHostSession() { // Create a new connection to the AB Suite host system // Use the Access Layer API ConnectionFactory to create an // instance of a Connection class IConnection ABSConnection = ConnectionFactory.Create(); // Set up the ConnectionDetails object with the required // entries ConnectionDetails cDetails = new ConnectionDetails() { Host = "localhost", // Host name or IP Address System = "Sample", // Name of the Runtime System IsAnonymous = true, // Set anonymous access if required AssemblyLocation = @"C:\ABSuite\Datamodels" // Sets the location of DataModels Assembly }; bool SessionConnected=false; // Perform the Connect call using the defined connection details. // No ATT recording is required. Therefore, the second parameter is set to null. // The Connect call returns a TransmissionObject that can be used to // verify the success or failure of the call. TransmissionObject trObj = ABSConnection.Connect(cDetails, null); // Check the TransmissionObject if (trObj != null && (trObj.State == TransmissionReturnCode.Ok || trObj.State == TransmissionReturnCode.OkWithSwitch)) { CurrentIspecName = trObj.ObjectClassName; SessionConnected = true; } else SessionConnected = false; }