This commit is contained in:
@@ -80,11 +80,11 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// Get Operations log for a job
|
/// Get Operations log for a job
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gid"></param>
|
/// <param name="gid"></param>
|
||||||
/// <returns>A tag</returns>
|
/// <returns>A single job's log</returns>
|
||||||
[HttpGet("logs/{gid}")]
|
[HttpGet("logs/{gid}")]
|
||||||
public async Task<IActionResult> GetLogs([FromRoute] Guid gid)
|
public async Task<IActionResult> GetLogs([FromRoute] Guid gid)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.ServerJob))
|
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.ServerJob))
|
||||||
@@ -105,6 +105,34 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Operations log for all jobs
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
/// <returns>Log for all jobs in system</returns>
|
||||||
|
[HttpGet("logs/all-jobs")]
|
||||||
|
public async Task<IActionResult> GetAllLogs()
|
||||||
|
{
|
||||||
|
if (serverState.IsClosed)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
|
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.ServerJob))
|
||||||
|
{
|
||||||
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
{
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Instantiate the business object handler
|
||||||
|
JobOperationsBiz biz = new JobOperationsBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
|
||||||
|
List<JobOperationsLogInfoItem> l = await biz.GetAllJobsLogsListAsync();
|
||||||
|
return Ok(ApiOkResponse.Response(l));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,27 @@ namespace AyaNova.Biz
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get list of logs for job
|
||||||
|
internal async Task<List<JobOperationsLogInfoItem>> GetAllJobsLogsListAsync()
|
||||||
|
{
|
||||||
|
List<JobOperationsLogInfoItem> ret = new List<JobOperationsLogInfoItem>();
|
||||||
|
|
||||||
|
var l = await ct.OpsJobLog
|
||||||
|
.OrderByDescending(z => z.Created)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (OpsJobLog i in l)
|
||||||
|
{
|
||||||
|
|
||||||
|
JobOperationsLogInfoItem o = new JobOperationsLogInfoItem();
|
||||||
|
o.Created = i.Created;
|
||||||
|
o.StatusText = i.StatusText;
|
||||||
|
ret.Add(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion controller routes
|
#endregion controller routes
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ namespace AyaNova.Biz
|
|||||||
var JobDescription = $"{job.Name} {job.JobType.ToString()}";
|
var JobDescription = $"{job.Name} {job.JobType.ToString()}";
|
||||||
if (job.SubType != JobSubType.NotSet)
|
if (job.SubType != JobSubType.NotSet)
|
||||||
JobDescription += $":{job.SubType}";
|
JobDescription += $":{job.SubType}";
|
||||||
|
await LogJobAsync(job.GId, $"Process job \"{JobDescription}\"", ct);
|
||||||
log.LogDebug($"ProcessJobAsync -> Processing job {JobDescription}");
|
log.LogDebug($"ProcessJobAsync -> Processing job {JobDescription}");
|
||||||
IJobObject o = null;
|
IJobObject o = null;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using AyaNova.Biz;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace AyaNova.Models
|
namespace AyaNova.Models
|
||||||
|
|||||||
Reference in New Issue
Block a user