IConnection Methods

The IConnection interface exposes the methods listed in the following table:

Methods

Description

IConnection.Close Method

Closes a current connection with the runtime system.

IConnection.Connect Method

Establishes a connection to the runtime system through a synchronous call that blocks the client application calling it.

IConnection.ConnectAsync Method

Establishes a connection to the runtime system through an asynchronous call that does not block the client application calling it. When the connection is established, a specified callback handler is triggered to process the connection result.

IConnection.GetDataModelObject Method

Retrieves a DataModel object for a particular ispec or class.

IConnection.Load Method

Loads an ispec or a class in the runtime system through a synchronous call.

IConnection.LoadAsync Method

Loads an ispec or a class in the runtime system through an asynchronous call.

IConnection.ProcessColonCommand Method

Sends a colon command to the runtime system through a synchronous call.

IConnection.ProcessColonCommandAsync Method

Sends a colon command to the runtime system through an asynchronous call.

IConnection.Close Method

The Close method closes the current connection with the runtime system.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

void Close()

Using the IConnection Interface for the Close Method

The following code shows an example of using the Close() method to close the connection with the host system:

  // CloseHostSession performs a Close operation on the Connection object
  public void CloseHostSession()
  {   
   // Call the Close method on the Connection object
        ABSConnection.Close();
  }

IConnection.Connect Method

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;
    }

IConnection.ConnectAsync Method

The ConnectAsync method is used to establish a connection to the runtime system through an asynchronous call that does not block the client application calling it. When the connection is established, a specified callback handler is triggered to process the connection result.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

Task<TransmissionObject> ConnectAsync(
 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 system through the Access Layer API. To use the ConnectionDetails class with the ConnectAsync method, an instance of the class must be created and populated with the required information to be used by the ConnectAsync method.

    Refer to the description of the Connect method for more information on the ConnectionDetails class members.

  • attDetail – This argument provides the ATT recording configuration details in an instance of the ATTConnectionDetails class.

    The ATTConnectionDetails class provides properties that are required to record and playback test cases by using ATT.

    Refer to the description of the Connect method for more information on the ATTConnectionDetails class members.

Return Value

This method executes an awaitable task and returns a TransmissionObject instance that specifies the current context of the system.

Using the IConnection Interface for the ConnectAsync Method

The following code shows an example of using the ConnectAsync() method to perform an asynchronous connection to the host system:

// Async Method to establish a host connection.
        public async void EstablishHostSessionAsync()
        {
            // Create a new connection to the AB Suite host system
            // Use the Access Layer API ConnectionFactory to create 
           // an instance of a Connection class
                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                
            };
      // Perform the ConnectAsync call using the defined connection details.
      // No ATT recording is required. Therefore, the second parameter 
      // is set to null.
      // We can await the ConnectAsync Task that lets the calling 
      // thread to continue processing. It returns an instance of the 
      // TransmissionObject. 
TransmissionObject trObj = null;
trObj = await ABSConnection.ConnectAsync(cDetails, null);
ApplicationLogger.LogInfo(() => string.Format("<Test Client>:: After Connect call!!"));
if (trObj != null && (trObj.State == TransmissionReturnCode.Ok || 
trObj.State == TransmissionReturnCode.OkWithSwitch))
 {
     CurrentIspecName = trObj.ObjectClassName;
     CurrentTO = trObj;
 }
     SessionConnected = true;     
}

IConnection.GetDataModelObject Method

The GetDataModelObject method is used to retrieve a new DataModel instance of the specified ispec or class.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

Object GetDataModelObject(
   string className
)

Arguments

  • classname – System.String

    This argument provides an ispec name or a class name of the required DataModel.

Return Value

If this method succeeds, it returns an object for the required DataModel.

Using the IConnection Interface for the GetDataModelObject Method

The following code shows an example of using the GetDataModelObject() method to retrieve an instance of a specified DataModel:

// Create a new connection to the AB Suite host system

// Use the Access Layer API ConnectionFactory to create an instance 
// of a Connection class.

// If the DataModels assembly is referenced by the client project 
// directly (and no composition is required), then you can pass a 
// DataModels IspecFactory instance to the ConnectionFactory 

// Create a call

ABSConnection = ConnectionFactory.Create(new Sample.Custom.DataModels.Core.IspecFactory());
 
// Create an instance of a required DataModel by using the 
// GetDataModelObject() method
Sample.Custom.DataModels.Models.MENUModel menuModel= (Sample.Custom.DataModels.Models.MENUModel) 
ABSConnection.GetDataModelObject("MENU");

IConnection.Load Method

The Load method is used to load a specified ispec or class in the runtime system for a session. This is a synchronous call. The calling process is blocked until the method completes.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

TransmissionObject Load(
   string name,
   bool withSwitch = true
)

Arguments

  • name – System.String

    This argument provides the name of the ispec or the class to be loaded.

  • withSwitch – System.Boolean

    This argument is optional. It determines whether a TransmissionObjectChanged event is raised. By default, this is set to true.

Return Value

If this method succeeds, it returns a TransmissionObject containing the DataModel to load the specified class.

Using the IConnection Interface for the Load Method

The following code shows an example of using the Load() method to load the MENU ispec into the current context:

// Call the Connection Load method with a given ispec name 
   TransmissionObject trObj = ABSConnection.Load("MENU");

// Check the returned TransmissionObject 
   if (trObj != null && (trObj.State == TransmissionReturnCode.Ok || 
trObj.State == TransmissionReturnCode.OkWithSwitch))
            {
                CurrentIspecName = trObj.ObjectClassName;
                CurrentTO = trObj;
            }

IConnection.LoadAsync Method

The LoadAsync method is an asynchronous call that loads a specified ispec or class in the runtime system for a session. The calling process is not blocked during the execution of the method. A specified callback method receives a new TransmissionObject when the call completes.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

Task<TransmissionObject> LoadAsync(
	 string name,
   bool withSwitch = true
)

Arguments

  • name – System.String

    This argument provides the name of the ispec or class to be loaded.

  • withSwitch – System.Boolean

    This argument is optional. It determines whether a TransmissionObjectChanged event is raised. By default, this is set to true.

Return Value

If this method succeeds, a TransmissionObject can be retrieved containing the specified DataModel that was loaded.

Using the IConnection Interface for the LoadAsync Method

The following code shows an example of using the LoadAsync() method to load a specified ispec into the current application context:

// Load a specified ispec into the current context using the LoadAsync call on the Connection object
        public async void LoadIspecAsync(string ispecName)
        {
       // Call LoadAsync with the ispecName parameter.

       // The LoadIspecComplete() method is executed when the 
       // Load request to the host system is complete
            TransmissionObject trObj = await ABSConnection.LoadAsync(ispecName,LoadIspecComplete);

            if (trObj != null && (trObj.State == TransmissionReturnCode.Ok || 
trObj.State == TransmissionReturnCode.OkWithSwitch))
            {
                CurrentIspecName = trObj.ObjectClassName;
                CurrentTO = trObj;
            }

        }

IConnection.ProcessColonCommand Method

The ProcessColonCommand method is used to send a colon command to the runtime system through a synchronous call.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

void ProcessColonCommand(
   string cmd
)

Arguments

  • cmd – System.String

    This argument provides the colon command to be executed by the runtime system.

Using the IConnection Interface for the ProcessColonCommand Method

The following code shows an example of using the interface for the ProcessColonCommand() method:

// Format the required command string 
string cmd = "HEL"
// Send the command to the host system
ABSConnection.ProcessColonCommand(cmd);

After the command is sent, responses from the host application are collected in the MessageQueue property of the MessagesHandler, which is an instance of the IUnsolicitedMessages interface. See IUnsolicitedMessages Interface for more information.

IConnection.ProcessColonCommandAsync Method

The ProcessColonCommandAsync method is used to send a colon command to the runtime system through an asynchronous call.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

Task ProcessColonCommandAsync(
   string cmd
)

Arguments

  • cmd – System.String

    This argument provides the colon command to be executed by the runtime system.

Using the IConnection Interface for the ProcessColonCommandAsync Method

The following code shows an example of using the interface for the ProcessColonCommandAsync() method:

// Format the required command string 
string cmd = “HEL”
// Send the command to the host system
Var task = ABSConnection.ProcessColonCommandAsync(cmd);
// Wait for the execution of the command. This does not mean
// wait for completion of the execution to the command (like running 
// a report), but ‘wait’ means to wait for the command to be sent to 
// the system for execution.
task.Wait();