Click or drag to resize

Getting Started with the .NET Interface

The xTend Framework includes helper assemblies that simplify the overall development process. These assemblies may be referenced by your own .NET application, windows service, etc. They provide easy-to-use classes that handle all the work of making service calls to the xTend API server. These assemblies also provide a comprehensive library of data classes representing the data model of the xTend Framework.

Adding References and Dependencies to your Project

To get started, add the following assembly references to your .NET project / solution:

(Also be sure to redistribute these assemblies with your custom xTend application)

FactoryLogix.xTend.API.dll

(Service Classes)

FactoryLogix.xTend.DataObjects.dll

(Data Model)

In addition, the following dependent assembly must be redistributed with your application. During developement, this assembly must be copied to your project's output folder in order for your xTend custom application to operate properly.

DO NOT add this assembly as a reference in your .NET project / solution. Instead, add it to your project as a simple "Content" file, and set the "Copy To Output" property in Visual Studio to "Copy Always" or "Copy if Newer".

Aegis.Utilities.dll

Additional Dependency Required by xTend API Assemblies

Firewall Settings and Network Setup

The xTend .NET interface communicates with your FactoryLogix xTend API Server using Microsoft's Windows Communication Foundation (WCF). WCF's NET.TCP binding is utilized for its superior speed and effeciency. For this binding to operate correctly, you must allow inbound traffic to the xTend server on the ports listed below. Any firewalls installed on the xTend server itself, or between your xTend application and the xTend server must be configured to allow this traffic:

NET.TCP Protocol

TCP Port 808

xTend API Server Discovery

UDP Port 3702

Connecting to the xTend API Server

The first step in using the xTend API is establishing a connection to the xTend API server. To accomplish this, instantiate an instance of the FactoryLogix.xTend.CoreConnectionServices class, and use the Connect method.

using FactoryLogix.xTend.Core;
using FactoryLogix.xTend.DataObjects;

string serverName = "MyServer";
ConnectionServices conn = new ConnectionServices();
Guid sessionId = Guid.Empty;

try
{
     string defaultDBConnectionName = conn.GetDefaultDatabaseConnection(serverName);
     sessionId = conn.Connect(serverName, "xTendUser", "[my password]", defaultDBConnectionName);
}
catch (xTendExceptionBase ex)
{
     Debug.WriteLine("An error has occurred while establishing a connection:  {0} - {1}", 
                     ex.GetType().Name, ex.Message);
}

The sessionId returned by the Connect method should be retained. This 128-bit unique identifier is your login token, and will passed as the first parameter of all subsequent API calls. For convenience, the sessionId is automatically stored for you in the Session.SessionId static property.

If you do not know the name of your FactoryLogix xTend API server, it can be discovered using the DiscoverServers method, as shown here:

using FactoryLogix.xTend.Core;
using FactoryLogix.xTend.DataObjects;

ConnectionServices conn = new ConnectionServices();
Guid sessionId = Guid.Empty;

try
{
     List<string> servers = conn.DiscoverServers();
     if (servers.Count > 0)
     {
         string serverName = servers[0];
         string defaultDBConnectionName = conn.GetDefaultDatabaseConnection(serverName);
         sessionId = conn.Connect(serverName, "xTendUser", "[my password]", defaultDBConnectionName);
     }
}
catch (xTendException ex)
{
     Debug.WriteLine("An error has occurred while establishing a connection:  {0} - {1}", 
                     ex.GetType().Name, ex.Message);
}
Disconnecting from the xTend API Server

Once your application is done using the API, it should disconnect from the server using the Disconnect method. Disconnecting ensures that any metered licenses that are being consumed by your API session are released and returned to the license pool. It also allows the xTend API server to cleanup information related to your session.

ConnectionServices conn = new ConnectionServices();
conn.Disconnect(Session.SessionId);