I\'d like to maintain a history of jobs that were scheduled by a Quartz scheduler containing the following properties: \'start time\', \'end time\', \'success\', \'error\'.
If you're happy to just update the database at the end, you can get the job name and run time from the IJobExecutionContext
:
public void JobWasExecuted(JobExecutionContext context,
JobExecutionException jobException)
{
var sql = @"INSERT INTO MyJobAuditHistory
(JobKey, RunTime, Status, Exception) VALUES (?, ?, ?, ?)";
// create command etc.
command.Parameters.Add(context.JobDetail.Key.ToString());
command.Parameters.Add(context.JobRunTime);
command.Parameters.Add(jobException == null ? "Success" : "Fail");
command.Parameters.Add(jobException == null ? null : jobException.Message);
}