API
Ianus can be embedded and invoked by a .NET application. You need to add an assembly reference to the visual studio project for the Ianus assembly (HPE.Ianus.DLL
) and then make use of the Ianus classes to run Ianus jobs.
The usage is pretty simple and requires a few steps:
- Create an instance of the Ianus environment using the class
HPE.Ianus.Environment
- Create an instance of the job(s) you want to execute, using the class
HPE.Ianus.Job
- Run the jobs or execute one or more specific steps
- Verify the result of the job or of one or more specific steps
Creating the Environment instance
The environment instance is loaded from an existing Environment configuration that can be stored in an external XML file or in a XML resource file include in the generated assembly.
HPE.Ianus.Environment env = new HPE.Ianus.Environment(new FileInfo(@"C:\IANUS\Env.xml"));
HPE.Ianus.Environment env = new HPE.Ianus.Environment(Assembly.GetExecutingAssembly(),
"Ianus_Unit_Test.EmbeddedEnv.xml");
Creating the Job instance
Like the environment, jobs can be loaded from job files stored either on regular files or embedded resources.
Job job01 = new Job(env, new FileInfo(@"C:\IANUS\ZZFILE_EXTERNAL_MATCH.xml"));
Job job02 = new Job(env, Assembly.GetExecutingAssembly(), "Ianus_Unit_Test.EmbeddedConfig.xml");
Running the Job
You can either run the whole job or just selected steps. To run the entire job all you need to do is to invoke the Run
method.
To run specific steps, you need to use the following sequence of operations:
- Invoke the
Start
method - Invoke the
Execute
method for every step you want to process - Invoke the
End
method
Job job01 = new Job(env, new FileInfo(@"C:\IANUS\ZZFILE_EXTERNAL_MATCH.xml"));
job01.Run();
Job job02 = new Job(env, Assembly.GetExecutingAssembly(),
"Ianus_Unit_Test.EmbeddedConfig.xml");
job.Start();
job.Execute("TBLCMP01"); // executing step named TBLCMP01
job.Execute("TBLCMPAA"); // executing step named TBLCMPAA
job.End();
Checking the job and steps status code
Once the job has been executed, the Status Code of the job can be controlled using the property Status
.
To check the status of selected tasks, the Job
object exposes the Tasks
collection that can be used to access the desired task. The task status code is provided by the property Status
.
Job job = new Job(env, Assembly.GetExecutingAssembly(), "Ianus_Unit_Test.EmbeddedConfig.xml");
job.Run()
Assert.AreEqual(Ianus.Job.JobStatus.Success, job.Status);
Job job = new Job(env, Assembly.GetExecutingAssembly(), "Ianus_Unit_Test.EmbeddedConfig.xml");
job.Run();
Assert.AreEqual(Ianus.Task.TaskStatus.Success, job.Tasks["LOGERR"].Status);
Assert.AreEqual(Ianus.Task.TaskStatus.Success, job.Tasks["LOGWARN"].Status);
Assert.AreEqual(Ianus.Task.TaskStatus.Success, job.Tasks["LOGINFO"].Status);