Autobahn DX .NET API

The Autobahn DX .NET API allows a .NET application to execute a selected job definition.

A sample Visual Studio project is provided in the <Autobahn DX installation folder>\code examples\AutobahnAPIExample folder.

API Example (Local Job)

/// \<summary\>

/// Call Autobahn and run specified JobID

/// \</summary\>

/// \<param name="jobID"\>The Autobahn JobID\</param\>

/// \<param name="configFile"\>Full file path to the Autobahn config file\</param\>

/// \<param name="timeOut"\>Time out in ms. Default is zero which is no time out\</param\>

/// \<returns\>Exit Code - zero is success\</returns\>

public int Call(int jobID, string configFile, int timeOut = 0)

{

int exitCode;

Job job = null;

try

{

// Create new Job instance for the supplied JobID and the Autobahn config file

job = new Job(jobID, configFile);

// Start the job

job.Start();

// If a time out value is supplied, wait until time out complete

if (timeOut \> 0)

{

job.WaitForExit(timeOut);

}

else

{

string started = job.JobFinished();

job.WaitForExit();

Console.WriteLine("Job execution finished:" + job.JobFinished());

Console.WriteLine("Exit code is:" + job.Jobstatus());

}

// Job status analysis

if (job.Jobstatus().ToUpper().Equals("ERROR"))

{

exitCode = -1;

}

else if (job.Jobstatus().ToUpper().Equals("STOPPED"))

{

if (job.JobFinished().ToUpper().Equals("TRUE"))

{

exitCode = 0;

}

else

{

exitCode = -1;

}

}

else

{

exitCode = -2;

}

}

catch (Exception ex)

{

exitCode = -1;

Console.WriteLine(ex.Message);

}

finally

{

if (job != null)

{

job.Dispose();

}

}

return exitCode;

}

API details

Constructors

public Job(int jobid)

Create a Job object using an existing jobid.

public Job(string jobdeffile)

Create a Job object using a temporary job definition file.

public Job(int jobid, string config)

Create a Job object using an existing jobid and config file with the configuration of the remote machine

public Job(string jobdeffile, string config)

Create a Job object using a temporary job definition file and config file with the configuration of the remote machine

Methods

public Start()

Starts the Job.

public void WaitForExit(int ms)

Waits for the job to exit, for up to ms milliseconds. The job is stopped if it has not completed.

public void WaitForExit()

Waits indefinitely for the job to complete.

public virtual void Dispose()

Disposes of the resources associated with the Job.

Public string Jobstatus()

Returns the status of the job which may be either Stopped or Error. This should be checked in conjunction with the value of JobFinished() to determine whether the job completed before being stopped.

Public string JobFinished()

Indicates whether the job has completed (return value True) or has been stopped (return value False) as a result of timeout being exceeded.

Public void ClearError(string JobStatusPath)

When a job is error, ClearError(string jobStatusPath) will clear the error job and set the job status to stopped.

Public string GetLastRunDate()

Returns the last Date and Time the job executed.

Public List<DocumentResults> GetDocumentsStatus()

Returns a list of files processed and their status.