public void Execute(IJobExecutionContext context) { // Task Status this.ExecutionContext = context; this.Status = context.GetDiscoScheduledTaskStatus(); if (this.Status == null) this.Status = ScheduledTasks.RegisterTask(this); try { if (!this.LogExceptionsOnly) ScheduledTasksLog.LogScheduledTaskExecuted(this.Status.TaskName, this.Status.SessionId); this.Status.Started(); this.ExecuteTask(); } catch (Exception ex) { ScheduledTasksLog.LogScheduledTaskException(this.Status.TaskName, this.Status.SessionId, this.GetType(), ex); this.Status.SetTaskException(ex); } finally { if (!this.Status.FinishedTimestamp.HasValue) // Scheduled Task Didn't Trigger 'Finished' this.Status.Finished(); this.Status.Finally(); var nextTriggerTime = context.NextFireTimeUtc; if (nextTriggerTime.HasValue) { // Continuous Task this.Status.Reset(nextTriggerTime.Value.LocalDateTime); } else { this.UnregisterTask(); } if (!this.LogExceptionsOnly) ScheduledTasksLog.LogScheduledTaskFinished(this.Status.TaskName, this.Status.SessionId); } }