This commit is contained in:
@@ -74,6 +74,28 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get current job status for a job
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gid"></param>
|
||||||
|
/// <returns>A single job's current status</returns>
|
||||||
|
[HttpGet("status/{gid}")]
|
||||||
|
public async Task<IActionResult> GetJobStatus([FromRoute] Guid gid)
|
||||||
|
{
|
||||||
|
if (serverState.IsClosed)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
|
//This is called by the UI to monitor any operation that triggers a job so it really should be available to any logged in user
|
||||||
|
// if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.ServerJob))
|
||||||
|
// {
|
||||||
|
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
return Ok(ApiOkResponse.Response(await JobsBiz.GetJobStatusAsync(gid)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace AyaNova.Biz
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public enum JobStatus : int
|
public enum JobStatus : int
|
||||||
{
|
{
|
||||||
|
Absent=0,
|
||||||
Sleeping = 1,
|
Sleeping = 1,
|
||||||
Running = 2,
|
Running = 2,
|
||||||
Completed = 3,
|
Completed = 3,
|
||||||
|
|||||||
@@ -138,6 +138,20 @@ namespace AyaNova.Biz
|
|||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the status of a job
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jobId"></param>
|
||||||
|
internal static async Task<JobStatus> GetJobStatusAsync(Guid jobId)
|
||||||
|
{
|
||||||
|
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||||
|
{
|
||||||
|
var o = await ct.OpsJob.AsNoTracking().SingleOrDefaultAsync(z => z.GId == jobId);
|
||||||
|
if (o == null) return JobStatus.Absent;
|
||||||
|
return o.JobStatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion Job ops
|
#endregion Job ops
|
||||||
|
|
||||||
#region PROCESSOR
|
#region PROCESSOR
|
||||||
|
|||||||
Reference in New Issue
Block a user