Ejemplo n.º 1
0
        /// <summary>
        /// Execute a task.
        /// </summary>
        /// <param name="task"></param>
        public void Execute(JobTask task)
        {
            var startTime = DateTime.UtcNow;

            try
            {
                // Log.
                EngineEventSource.Log.Verbose("Executing task '{0}' at {1}.", task.GetType().Name, startTime);

                // Send out event.
                EventContext.TaskRunning(this, task, startTime);

                // Execute the task.
                task.Job = this;
                task.CancellationToken = CancellationToken;
                task.Execute();

                // Calculate duration.
                var duration = DateTime.UtcNow - startTime;

                // Send out event.
                EventContext.TaskComplete(this, task, startTime, duration);

                // Log complete.
                EngineEventSource.Log.Verbose("Executed task '{0}' in {1}.", task.GetType().Name, duration.ToString());
            }
            catch (Exception ex)
            {
                EventContext.TaskFailed(this, task, startTime, ex);

                // Log.
                EngineEventSource.Log.ErrorDetails(ex, "Error executing task '{0}'", task.GetType().Name);

                throw;
            }
        }
 public void TaskFailed(Job job, JobTask task, DateTime startTime, Exception exception)
 {
     
 }
 public void TaskComplete(Job job, JobTask task, DateTime startTime, TimeSpan duration)
 {
     
 }
 public void TaskProgress(Job job, JobTask task, string message, object[] args)
 {
     
 }
 public void TaskRunning(Job job, JobTask task, DateTime startTime)
 {
     
 }