public DateTime? NextExecution(IJobState state, ISchedulerContext context) { if (state.Status != JobStatus.Pending) { return null; // Have no clue } return context.GetCurrentTime().Date.Add(_dayTime); }
public void Run() { if (_status != JobStatus.Scheduled) { // Do nothing. Work is already started. return; } _status = JobStatus.Running; _lastStartTime = _context.GetCurrentTime(); _definition.Factory().ContinueWith(t => { _status = JobStatus.Pending; _lastCompleteTime = _context.GetCurrentTime(); var run = new JobRun { Started = _lastStartTime.Value, Completed = _lastCompleteTime.Value }; if (t.Status == TaskStatus.Faulted) { var ex = t.Exception.Flatten().GetBaseException(); run.Result = JobRunResult.Failure; run.ResultMessage = ex.ToString(); // We need to log this out. //_trace.Value.Error("Command " + cmdKey + " failed to execute.\r\n" + ex.Message, new { Exception = ex, Command = cmd }); } else if (t.Status == TaskStatus.RanToCompletion) { run.Result = JobRunResult.Success; } _previousRuns.Add(run); var newWorkState = new WorkState(_lastCompleteTime.Value); _context.State.Store(_definition.JobKey, newWorkState); }); }
public JobItem(ISchedulerContext context, JobDefinition definition, WorkState presavedState = null) { _context = context; _definition = definition; _created = _context.GetCurrentTime(); if (presavedState != null) { _lastCompleteTime = presavedState.LastCompleteTime; } UpdateState(); }
public DateTime?NextExecution(IJobState state, ISchedulerContext context) { if (state.Status != JobStatus.Pending) { return(null); // Have no clue } if (state.LastComplete != null) { return(state.LastComplete.Value.Date.AddDays(1).Add(_dayTime)); } return(context.GetCurrentTime().Date.Add(_dayTime)); }
public DateTime? NextExecution(IJobState state, ISchedulerContext context) { if (state.Status != JobStatus.Pending) { return null; // Have no clue } if (state.LastComplete != null) { return state.LastComplete.Value.Date.AddDays(1).Add(_dayTime); } return context.GetCurrentTime().Date.Add(_dayTime); }