Quick start to EOS .NET programming

This quick start aims to provide a practical introduction to using the EOS .NET API.

Everything you need to program with EOS in .NET is provided by Ecrion.EOS.NET.dll. This .NET assembly provides an easy way to communicate with a remote EOS instance to quickly accomplish common tasks programatically. 

Running a Job in EOS

To run a job, instantiate the service, service client and login, and then call the RunJobAndWait() method on the service instance:

using Ecrion.EOS;

Service svc = new Service();
ServiceClient client = svc.GetServiceClient("http://localhost:8091");
LogIn login = svc.CreateLogin("username", "password", "environment_id");

Dictionary<string, string> parameters = new Dictionary<string, string>;
parameters.Add("myParam1", "myParamValue1");
parameters.Add("myParam2", "myParamValue2");

svc.RunJobAndWait(client, login, "Telephone Invoice", "Main.wkf", parameters, 0); // Set timeout to 0 to wait indefinitely.

To run a job without waiting for it to finish, just change RunJobAndWait to RunJob:

using Ecrion.EOS;

Service svc = new Service();
ServiceClient client = svc.GetServiceClient("http://localhost:8091");
LogIn login = svc.CreateLogin("username", "password", "environment_id");

Dictionary<string, string> parameters = new Dictionary<string, string>;
parameters.Add("myParam1", "myParamValue1");
parameters.Add("myParam2", "myParamValue2");

svc.RunJob(client, login, "Telephone Invoice", "Main.wkf", parameters);

Geting the Job Status

To check on a job that is running, you will need to provide a job ID. The job ID can be retrieved from the return value of the RunJob and RunJobAndWait methods:

using Ecrion.EOS;

Service  svc = new Service();
ServiceClient client = svc.GetServiceClient("http://localhost:8091");
LogIn login = svc.CreateLogin("username", "password", "environment_id");

Dictionary<string, string> parameters = new Dictionary<string, string>;
parameters.Add("myParam1", "myParamValue1");
parameters.Add("myParam2", "myParamValue2");

JobInfo job = svc.RunJob(client, login, "Telephone Invoice", "Maintenance.wkf", parameters);

JobStatus jobStatus = svc.GetJobStatus(client, login, job.JobId);

Asynchronous Calls

We also provide async versions of all the client methods, which make the remote calls themselves asynchronous. These methods are intended for use when you're building an interactive application that needs to be consistently responsive.

For example, if your application has a UI that launches jobs and gets the status periodically, these methods ensure that even if there is high network latency, your application will continue to react normally to user input even while waiting to retrieve a job status.

The async versions of the methods work with the .NET 4.5 async/await framework and have the same name as the sync methods plus the suffix "Async".

Assuming we have the client, service, login and the job ID that we want to check, we can ask asynchronously for the job status like this:

using Ecrion.EOS;

Task<JobStatus> tJobStatus = svc.GetJobStatusAsync(client, login, jobId);

DoIndependentWork();

Console.WriteLine(await tJobStatus);

Using with COM+ Applications

This assembly is also COM Visible so you can use it in scenarios where you have a COM-based application that needs to call EOS remotely.

Below are the steps to register/unregister the EOS .NET assembly for usage in COM-based applications. If you are trying to create COM objects from vbscript please first restart IIS Web Server in order to see the changes.

Register:

1. Install assembly into GAC using gacutil

gacutil /i Ecrion.EOS.NET.dll

2. Register assembly using regasm

regasm Ecrion.EOS.NET.dll

Unregister:

1. Uninstall assemby from the GAC

gacutil /u Ecrion.EOS.NET.dll

2. Unregister assembly using regasm

regasm /u Ecrion.EOS.NET.dll

Have more questions? Submit a request

Comments

Powered by Zendesk