Deploy SAMPLE to your machine.
To create an instance of the segment, you need to know the type name to create. You can find this from Component Services. Under COM+ Applications, find the application representing your system, and expand it to get to the component, which is named something like “<Segment name>.1” for example, “SAMPLE.1”. Open the Properties and see the type name in the Description field on the General Tab, which is “<segment name>COMManager”.
Create a new C# Windows Console Application in Microsoft Visual Studio.
Add references to the various assemblies and components that you need when calling your application. As a minimum, you need to add:
Interop.GenericClassX64 (from <AB Suite Installation folder>\bin64 folder)
Interop.NGLINCX64 (from <AB Suite Installation folder>\bin64 folder)
Interop.MSXML (from <AB Suite Installation folder>\bin64 folder)
System.EnterpriseServices (.NET assembly)
Unisys.AgileBusiness.RuntimeFramework (from <AB Suite Installation folder>\bin64 folder)
<Segment>.dll, for example, SAMPLE.dll (from your deployed application folder)
<Segment>COMManager.dll, for example, SAMPLECOMManager.dll (from your deployed application folder)
Add the following code to the Class to set and retrieve data into the Sample application.
using System;
namespace SampleCaller
{
class Class1
{
/// The main entry point for the application.
[STAThread]
static void Main(string[] args)
// Define the Sample object
// This requires a reference to the Sample
// application
Type tp = Type.GetTypeFromProgID("Sample.1");
System.Object aSysInfoObject = Activator.CreateInstance(tp);
NGLINC.ISegmentCycle sample =
(NGLINC.ISegmentCycle)aSysInfoObject
// Establish a session
int sessId = sample.Connect(null, false, false,
"MyMachine");
// Declare GenericClass objects and call
// CreateInstance():
// Here we are adding a Sales Rep to SAMPLE
GenericClass.IIspecCycle inParams = new
GenericClass.GenericClassClass();
GenericClass.IIspecCycle outParams = new
GenericClass.GenericClassClass();
inParams = (GenericClass.IIspecCycle)
sample.CreateInstance(sessId, "SREP");
// Set values in ispec fields and process the
// transaction:
inParams.SetValue("_UserMaint", "ADD");
inParams.SetValue( "AREA", "Asia");
inParams.SetValue( "NAM", "John Smith");
inParams.SetValue( "SALESREP", "1");
// retrieve output in the output object from the
// ProcessMsg call
outParams = (GenericClass.IIspecCycle)
sample.ProcessMsg(sessId, inParams);
// Use the output object as the next input
object
// to ensure transaction_id is correct
inParams = outParams;
// Process another transaction to retrieve the
// Sales Rep just entered
inParams.SetValue("_UserMAINT","INQ");
inParams.SetValue("SALESREP","1");
outParams = (GenericClass.IIspecCycle)
sample.ProcessMsg(sessId, inParams);
System.Console.WriteLine(outParams.GetValue("NAM"));
// Disconnect your open session
sample.Disconnect(sessId);
// Call administration methods
NGLINC.IAdmin mySysAdmin = sample.Admin;
Array arrReports =
mySysAdmin.ListRunningReports();
for (int i = 0; i < arrReports.Length;
i++)
{
if (null != arrReports.GetValue(i))
{
string strValue =
arrReports.GetValue(i).ToString().Trim();
System.Console.WriteLine(strValue);
}
}
// Stop the system
MySysAdmin.StopSystem();
}
}
}Run the application. The SalesRep account relating to John Smith should appear on the command line.
Note: You need to manually delete this account before running this example again.