public void SetScheduledTaskLastRunStatistics(long scheduledTaskId, ScheduledTaskRunStatistics lastRunStatistics) { using (WebHawkDataProvider data = new WebHawkDataProvider(ConnectionString)) { data.SetScheduledTaskLastRunStatistics(scheduledTaskId, lastRunStatistics); } }
public override void JobWasExecuted(Quartz.IJobExecutionContext context, Quartz.JobExecutionException jobException) { base.JobWasExecuted(context, jobException); long scheduledTaskId = (long)context.MergedJobDataMap["scheduledTaskId"]; ScheduledTaskRunStatistics lastRunStatistics = new ScheduledTaskRunStatistics(); lastRunStatistics.StartTimeUtc = context.FireTimeUtc.HasValue ? context.FireTimeUtc.Value.DateTime : new DateTime?(); lastRunStatistics.EndTimeUtc = context.FireTimeUtc.HasValue ? context.FireTimeUtc.Value.Add(context.JobRunTime).DateTime : new DateTime?(); if (jobException != null) { lastRunStatistics.Status = ScheduledTaskStatus.Failed; lastRunStatistics.Error = jobException.Message; } else { ExecuteSequenceJobResult result = (ExecuteSequenceJobResult)context.Result; lastRunStatistics.Status = result.RunStatus; lastRunStatistics.Error = result.RunError; } string connectionString = (string)context.MergedJobDataMap["connectionString"]; SchedulingController controller = new SchedulingController(connectionString); controller.SetScheduledTaskLastRunStatistics(scheduledTaskId, lastRunStatistics); zOnTaskComplete(new TaskEventArgs(scheduledTaskId)); m_IsJobRunning = false; }
private ScheduledTaskRunStatistics zMapToScheduledTaskRunStatistics(dataAccess.DataReaderHelper reader) { ScheduledTaskRunStatistics scheduledTaskRunStatistics = new ScheduledTaskRunStatistics(); scheduledTaskRunStatistics.StartTimeUtc = reader.GetNullableDateTime("LastRunStartTimeUtc"); scheduledTaskRunStatistics.EndTimeUtc = reader.GetNullableDateTime("LastRunEndTimeUtc"); scheduledTaskRunStatistics.Status = !reader.IsDBNull("LastRunStatusId") ? (ScheduledTaskStatus)reader.GetInt64("LastRunStatusId") : new ScheduledTaskStatus?(); scheduledTaskRunStatistics.Error = reader.GetNullableString("LastRunError"); return(scheduledTaskRunStatistics); }
private ScheduledTask zMapToScheduledTask(dataAccess.DataReaderHelper reader) { ScheduledTaskRunStatistics lastRunStatistics = zMapToScheduledTaskRunStatistics(reader); ScheduledTask scheduledTask = new ScheduledTask(lastRunStatistics); scheduledTask.ScheduledTaskId = reader.GetInt64("ScheduledTaskId"); scheduledTask.TaskName = reader.GetString("TaskName"); scheduledTask.RunSchedule = Converter.FromBinary <Schedule>(reader.GetFieldValue <byte[]>("Schedule")); string runDurationLimit = reader.GetNullableString("RunDurationLimit"); scheduledTask.RunDurationLimit = runDurationLimit != null?TimeSpan.Parse(runDurationLimit) : new TimeSpan?(); scheduledTask.Enabled = reader.GetBoolean("Enabled"); scheduledTask.IsDeleted = reader.GetBoolean("ScheduledTaskIsDeleted"); scheduledTask.NextScheduledRunTimeUtc = reader.GetNullableDateTime("NextScheduledRunTimeUtc"); if (!reader.IsDBNull("SequenceId")) { scheduledTask.TaskSequence = zMapToSequence(reader); } return(scheduledTask); }
public override void JobToBeExecuted(Quartz.IJobExecutionContext context) { base.JobToBeExecuted(context); m_IsJobRunning = true; long scheduledTaskId = (long)context.MergedJobDataMap["scheduledTaskId"]; ScheduledTaskRunStatistics lastRunStatistics = new ScheduledTaskRunStatistics(); lastRunStatistics.StartTimeUtc = context.FireTimeUtc.HasValue ? context.FireTimeUtc.Value.DateTime : new DateTime?(); lastRunStatistics.EndTimeUtc = null; lastRunStatistics.Status = ScheduledTaskStatus.Running; lastRunStatistics.Error = null; DateTime?nextScheduledRunTimeUtc = context.NextFireTimeUtc.HasValue ? context.NextFireTimeUtc.Value.DateTime : new DateTime?(); string connectionString = (string)context.MergedJobDataMap["connectionString"]; SchedulingController controller = new SchedulingController(connectionString); controller.SetScheduledTaskLastRunStatistics(scheduledTaskId, lastRunStatistics); controller.SetScheduledTaskNextScheduledRunTime(scheduledTaskId, nextScheduledRunTimeUtc); zOnTaskStart(new TaskEventArgs(scheduledTaskId)); }
private List <DbParameter> zMapFromScheduledTaskRunStatistics(dataAccess.ParameterBuilder paramBuilder, long scheduledTaskId, ScheduledTaskRunStatistics scheduledTaskRunStatistics) { List <DbParameter> parameters = new List <DbParameter>(); parameters.Add(paramBuilder.CreateParameter("@scheduledTaskId", scheduledTaskId)); parameters.Add(paramBuilder.CreateParameter("@lastRunStartTimeUtc", scheduledTaskRunStatistics.StartTimeUtc)); parameters.Add(paramBuilder.CreateParameter("@lastRunEndTimeUtc", scheduledTaskRunStatistics.EndTimeUtc)); parameters.Add(paramBuilder.CreateParameter("@lastRunStatusId", scheduledTaskRunStatistics.Status.HasValue ? (long)scheduledTaskRunStatistics.Status.Value : new long?())); parameters.Add(paramBuilder.CreateParameter("@lastRunError", scheduledTaskRunStatistics.Error)); return(parameters); }
public void SetScheduledTaskLastRunStatistics(long scheduledTaskId, ScheduledTaskRunStatistics lastRunStatistics) { m_DataAccess.ExecuteNonQuery(dataAccess.CommandType.StoredProcedure, "usp_Sched_SetScheduledTaskRunStatistics", paramBuilder => zMapFromScheduledTaskRunStatistics(paramBuilder, scheduledTaskId, lastRunStatistics)); }