This commit is contained in:
@@ -94,7 +94,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
return Ok(ApiOkResponse.Response(await JobsBiz.GetJobStatusAsync(gid)));
|
return Ok(ApiOkResponse.Response(await JobsBiz.GetJobStatusAsync(gid)));
|
||||||
}
|
}
|
||||||
@@ -112,10 +112,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
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))
|
|
||||||
{
|
//## NOTE: deliberately do *not* check for authorization as this is called by any bulk operation users may submit via extensions
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
//and the user would need the exact Guid to view a job so not likely they will fish for it in a nefarious way
|
||||||
}
|
// if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.ServerJob))
|
||||||
|
// {
|
||||||
|
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
// }
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
@@ -187,7 +190,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bulk DELETE list of object id's specified
|
/// Bulk DELETE list of object id's specified
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataListSelection"></param>
|
/// <param name="dataListSelection"></param>
|
||||||
@@ -203,7 +206,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (dataListSelection.IsEmpty)
|
if (dataListSelection.IsEmpty)
|
||||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
|
||||||
|
|
||||||
|
|
||||||
if (!Authorized.HasDeleteRole(HttpContext.Items, dataListSelection.ObjectType))
|
if (!Authorized.HasDeleteRole(HttpContext.Items, dataListSelection.ObjectType))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ namespace AyaNova.Biz
|
|||||||
await JobsBiz.LogJobAsync(job.GId, $"Bulk job {job.SubType} started...");
|
await JobsBiz.LogJobAsync(job.GId, $"Bulk job {job.SubType} started...");
|
||||||
List<long> idList = new List<long>();
|
List<long> idList = new List<long>();
|
||||||
long ProcessedObjectCount = 0;
|
long ProcessedObjectCount = 0;
|
||||||
|
long FailedObjectCount = 0;
|
||||||
JObject jobData = JObject.Parse(job.JobInfo);
|
JObject jobData = JObject.Parse(job.JobInfo);
|
||||||
if (jobData.ContainsKey("idList"))
|
if (jobData.ContainsKey("idList"))
|
||||||
idList = ((JArray)jobData["idList"]).ToObject<List<long>>();
|
idList = ((JArray)jobData["idList"]).ToObject<List<long>>();
|
||||||
@@ -402,6 +403,7 @@ namespace AyaNova.Biz
|
|||||||
if (!await DeleteAsync(id))
|
if (!await DeleteAsync(id))
|
||||||
{
|
{
|
||||||
await JobsBiz.LogJobAsync(job.GId, $"Error processing item {id}: {GetErrorsAsString()}");
|
await JobsBiz.LogJobAsync(job.GId, $"Error processing item {id}: {GetErrorsAsString()}");
|
||||||
|
FailedObjectCount++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -424,8 +426,9 @@ namespace AyaNova.Biz
|
|||||||
await JobsBiz.LogJobAsync(job.GId, ExceptionUtil.ExtractAllExceptionMessages(ex));
|
await JobsBiz.LogJobAsync(job.GId, ExceptionUtil.ExtractAllExceptionMessages(ex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await JobsBiz.LogJobAsync(job.GId, $"Bulk job {job.SubType} processed {ProcessedObjectCount} of {idList.Count}");
|
|
||||||
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed);
|
await JobsBiz.LogJobAsync(job.GId, $"Bulk job {job.SubType} processed {ProcessedObjectCount} of {idList.Count} with {FailedObjectCount} failures");
|
||||||
|
await JobsBiz.UpdateJobStatusAsync(job.GId, FailedObjectCount == 0 ? JobStatus.Completed : JobStatus.Failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,11 +72,10 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
foreach (OpsJobLog i in l)
|
foreach (OpsJobLog i in l)
|
||||||
{
|
{
|
||||||
|
|
||||||
JobOperationsLogInfoItem o = new JobOperationsLogInfoItem();
|
JobOperationsLogInfoItem o = new JobOperationsLogInfoItem();
|
||||||
|
|
||||||
o.Created = i.Created;
|
o.Created = i.Created;
|
||||||
o.StatusText = i.StatusText;
|
o.StatusText = i.StatusText;
|
||||||
|
o.JobId = jobId;
|
||||||
ret.Add(o);
|
ret.Add(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +128,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
var sleepTime = 30 * 1000;
|
var sleepTime = 30 * 1000;
|
||||||
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running);
|
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running);
|
||||||
await JobsBiz.LogJobAsync(job.GId, $"Test job started, sleeping for {sleepTime/1000} seconds...");
|
await JobsBiz.LogJobAsync(job.GId, $"Test job started, sleeping for {sleepTime / 1000} seconds...");
|
||||||
await Task.Delay(sleepTime);
|
await Task.Delay(sleepTime);
|
||||||
await JobsBiz.LogJobAsync(job.GId, "Test job done sleeping setting status to finished");
|
await JobsBiz.LogJobAsync(job.GId, "Test job done sleeping setting status to finished");
|
||||||
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed);
|
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace AyaNova.Biz
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public enum JobStatus : int
|
public enum JobStatus : int
|
||||||
{
|
{
|
||||||
Absent=0,
|
Absent = 0,
|
||||||
Sleeping = 1,
|
Sleeping = 1,
|
||||||
Running = 2,
|
Running = 2,
|
||||||
Completed = 3,
|
Completed = 3,
|
||||||
|
|||||||
Reference in New Issue
Block a user