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 two or three properties need to be set:

 

Visual Basic

In Visual Basic Script the code to connect to an Application Server is:

Dim ResCode

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

LIONapp.IPAddress = "MyServer"
LIONapp.PortNo = <AppServer PortNo>

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

 

And for an Application Manager:

Dim ResCode

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

LIONapp.IPAddress = "MyServer"
LIONapp.UseAppManager = True
LIONapp.PortNo = <AppManager PortNo>

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 the code to connect to an Application Server is:

# 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 = <AppServer PortNo>

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

 

And for an Application Manager:

# Import the COMModule
Add-Type -Path 'D:\Amt\AmtLionDoc\AMTTools\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 = <AppManager PortNo>

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

 

C# (.NET)

In C# the example code is for a WPF program named AmtLionComm_Test, with a Button to connect to the Application Server and a TextBox 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 = <AppServer PortNo>;
      // LionComAMT.UseAppManager = true;

      if (LionComAMT.OpenSession() == ResponseCode.Ok) {
        edtStatus.Text = "Connected";
      } else {
        edtStatus.Text = "Unable to connect";
      }

    }
  }
}

 

For connecting to an Application Manager uncomment the code lion with LionComAMT.UseAppManager = true; and replace the <AppServer PortNo> by the <AppManager PortNo>.