private IJobQueueOutputMessage ProcessResult(IScheduledJob job, DateTimeOffset scheduledTime, IQueueOutputMessage result)
{
//no errors, so just return
if (!result.HasError) return new JobQueueOutputMessage(result, JobQueuedStatus.Success);
//this is not an error for the job already existing in the queue
if (!JobAlreadyExistsError(result.SendingException))
return new JobQueueOutputMessage(result, JobQueuedStatus.Failed);
var status = DoesJobExist(job.Name, scheduledTime);
switch (status)
{
case QueueStatuses.Processing:
return new JobQueueOutputMessage(result, JobQueuedStatus.AlreadyQueuedProcessing);
case QueueStatuses.Waiting:
return new JobQueueOutputMessage(result, JobQueuedStatus.AlreadyQueuedWaiting);
case QueueStatuses.Processed:
return new JobQueueOutputMessage(result, JobQueuedStatus.AlreadyProcessed);
case QueueStatuses.Error:
DeleteJob(job.Name);
return null;
default:
return null; //try to re-queue once; if this is second try and this happens agian, an error will be returned
}
}