AMT Help Files

Connecting to an Application

When the Amt COM Module has been loaded into memory and the appropriate object created, a connection to an application has to be established before any Forms can be accessed. This is done by opening a session to the appropriate Application service or Application Manager service.

Before the connection can be made, you must set two or three properties:

Visual Basic

In VBScript, use the following code to connect to an Application Server:

Dim ResCode
Set LIONapp = CreateObject("Asysco.Amt.LionClient.ComModule.AmtLionComConnection")

LIONapp.IPAddress = "MyServer"
LIONapp.PortNo = 1234 ' Replace with the Application Server port number

ResCode = LIONapp.OpenSession()
If ResCode = 1 Then
  WScript.echo("Connected")
Else
  WScript.echo("Not Connected")
  WScript.echo("Result code is: " & ResCode)
End If

For an Application Manager:

Dim ResCode
Set LIONapp = CreateObject("Asysco.Amt.LionClient.ComModule.AmtLionComConnection")

LIONapp.IPAddress = "MyServer"
LIONapp.UseAppManager = True
LIONapp.PortNo = 1234 ' Replace with the Application Manager port number

ResCode = LIONapp.OpenSession()
If ResCode = 1 Then
  WScript.echo("Connected")
Else
  WScript.echo("Not Connected")
  WScript.echo("Result code is: " & ResCode)
End If

PowerShell

In PowerShell, use the following code to connect to an Application Server:

# Import the COMModule
Add-Type -Path '<Path to COMModule>\Asysco.Amt.LionCommodule.dll'

# Create an AmtComConnection object
$LionApp = New-Object Asysco.Amt.LionClient.ComModule.AmtLionComConnection

# The URL to connect to
$LionApp.IPAddress = 'MyServer'
$LionApp.PortNo = 1234 # Replace with the Application Server port number

# Try to connect
if ($LionApp.OpenSession() -eq 1) {
  Write-Host 'Connected'
} else {
  Write-Host 'Connection Failed!!!!!'
}

For an Application Manager:

# Import the COMModule
Add-Type -Path '<Path to COMModule>\Asysco.Amt.LionCommodule.dll'

# Create an AmtComConnection object
$LionApp = New-Object Asysco.Amt.LionClient.ComModule.AmtLionComConnection

# The URL to connect to
$LionApp.IPAddress = 'MyServer'
$LionApp.UseAppManager = $true
$LionApp.PortNo = 1234 # Replace with the Application Manager port number

# Try to connect
if ($LionApp.OpenSession() -eq 1) {
  Write-Host 'Connected'
} else {
  Write-Host 'Connection Failed!!!!!'
}

C# (.NET)

In C#, the following example is for a WPF program named AmtLionComm_Test, with a button to connect to the Application Server and a text box to display the result.

using System;
using System.Windows;
using Asysco.Amt.COMModule;
using Asysco.Amt.LionClient.ComModule;

namespace AmtLionComm_Test {
  /// <summary>
  /// Interaction logic for MainWindow.xaml
  /// </summary>
  public partial class MainWindow :Window {
    private AmtLionComConnection lionComAMT = new AmtLionComConnection();
    
    public AmtLionComConnection LionComAMT {
      get { return lionComAMT; }
      set { lionComAMT = value; }
    }
    
    public MainWindow () {
      InitializeComponent();
    }
    
    private void btnConnect_Click (Object sender, RoutedEventArgs e) {
      // The address and port number for the Application Server or Application Manager.
      LionComAMT.IPAddress = "MyServer";
      LionComAMT.PortNo = 1234; // Replace with the Application Server port number.
      // LionComAMT.UseAppManager = true;
      
      if (LionComAMT.OpenSession() == ResponseCode.Ok) {
        edtStatus.Text = "Connected";
      } else {
        edtStatus.Text = "Unable to connect";
      }
    }
  }
}

To connect to an Application Manager, uncomment the code line LionComAMT.UseAppManager = true; and replace the Application Server port number with the <AppManager PortNo>.

Contents