Multi-Step Scheduled Batch Framework
This is a simple library, designed only for the .NET Framework, which allows the rapid creation of multi-step batch programs with scheduling included.
Through a simple configuration file (json for now, soon also through SQL database!) It is possible to configure the steps of the batch. The creation of a step occurs by extending the base class BatchStep and configuring the namespace relating to it in the json file. The activation and execution of the step takes place at runtime.
Before doing anything else you need to configure the environment.
At the moment it is possible to configure the batch through a configuration file “Config.json” which can be located in any folder.
class Program
{
static void Main(string[] args)
{
var batch = new Batch();
batch.Init("Config/Config.json");
Console.Read();
}
}
By instantiating the Batch class, you can call the Init method with the “ConfigPath” parameter which indicates the path where the configuration file is located.
{
"Name":"Batch",
"StepList": [
{
"ID": 0,
"Name": "Step 1",
"Description": "batch step 1",
"Active": true,
"ClassName": "test.hctab.sh.Step1",
"Scheduling": [
{
"DaysOfWeek": "sun,mon,tue",
"hhmmFrom": "15:30:00",
"hhmmTo": "23:00:00"
},
{
"DaysOfWeek": "sun,mon,tue",
"hhmmFrom": "23:00:00",
"hhmmTo": "24:00:00"
}
],
"isSchedulerActive": true,
"RunOrder": 1
},
{
"ID": 1,
"Name": "Load Files",
"Description": "Load files from fb",
"Active": true,
"ClassName": "test.hctab.sh.LoadFiles",
"Scheduling": [
{
"DaysOfWeek": "sun,mon,tue",
"hhmmFrom": "15:30:00",
"hhmmTo": "23:00:00"
}
],
"isSchedulerActive": true,
"RunOrder": 2
}
]
}
This is the configuration file also used in the Test project, test.hctab.sh.
using core.hctab.sh.Batch;
using core.hctab.sh.Interfaces;
using System;
using System.Collections.Generic;
namespace test.hctab.sh
{
class Step1 : BatchStep, IBatchStep
{
public override bool IsApplicable()
{
return true;
}
public override void ReadData()
{
}
public override void SaveData()
{
}
public override void Verify()
{
}
}
}
For any more information check the Test project!