This commit is contained in:
@@ -73,6 +73,16 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request the cancellation of a job, not all jobs honour this
|
||||
/// </summary>
|
||||
/// <param name="jobId"></param>
|
||||
internal static async Task RequestCancelAsync(Guid jobId)
|
||||
{
|
||||
await UpdateJobStatusAsync(jobId, JobStatus.CancelRequested);
|
||||
await LogJobAsync(jobId, "LT:Cancel");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Remove the job and it's logs
|
||||
@@ -152,6 +162,37 @@ namespace AyaNova.Biz
|
||||
return o.JobStatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update the progress of a job
|
||||
/// </summary>
|
||||
/// <param name="jobId"></param>
|
||||
/// <param name="progress"></param>
|
||||
internal static async Task UpdateJobProgressAsync(Guid jobId, string progress)
|
||||
{
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
var oFromDb = await ct.OpsJob.SingleOrDefaultAsync(z => z.GId == jobId);
|
||||
if (oFromDb == null) return;
|
||||
oFromDb.Progress = progress;
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the progress and status of a job
|
||||
/// </summary>
|
||||
/// <param name="jobId"></param>
|
||||
internal static async Task<JobProgress> GetJobProgressAsync(Guid jobId)
|
||||
{
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
var o = await ct.OpsJob.AsNoTracking().SingleOrDefaultAsync(z => z.GId == jobId);
|
||||
if (o == null) return new JobProgress() { JobStatus = JobStatus.Absent, Progress = string.Empty };
|
||||
return new JobProgress() { JobStatus = o.JobStatus, Progress = o.Progress };
|
||||
}
|
||||
}
|
||||
#endregion Job ops
|
||||
|
||||
#region PROCESSOR
|
||||
|
||||
Reference in New Issue
Block a user