diff --git a/server/AyaNova/Controllers/JobOperationsController.cs b/server/AyaNova/Controllers/JobOperationsController.cs index 0c0007cd..1d0959d4 100644 --- a/server/AyaNova/Controllers/JobOperationsController.cs +++ b/server/AyaNova/Controllers/JobOperationsController.cs @@ -94,7 +94,7 @@ namespace AyaNova.Api.Controllers // return StatusCode(403, new ApiNotAuthorizedResponse()); // } - if (!ModelState.IsValid) + if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); return Ok(ApiOkResponse.Response(await JobsBiz.GetJobStatusAsync(gid))); } @@ -112,10 +112,13 @@ namespace AyaNova.Api.Controllers 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()); - } + + //## NOTE: deliberately do *not* check for authorization as this is called by any bulk operation users may submit via extensions + //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) { @@ -187,7 +190,7 @@ namespace AyaNova.Api.Controllers // - /// + /// /// Bulk DELETE list of object id's specified /// /// @@ -203,7 +206,7 @@ namespace AyaNova.Api.Controllers if (dataListSelection.IsEmpty) return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required")); - + if (!Authorized.HasDeleteRole(HttpContext.Items, dataListSelection.ObjectType)) return StatusCode(403, new ApiNotAuthorizedResponse()); diff --git a/server/AyaNova/biz/HeadOfficeBiz.cs b/server/AyaNova/biz/HeadOfficeBiz.cs index f3fc345b..20433bf8 100644 --- a/server/AyaNova/biz/HeadOfficeBiz.cs +++ b/server/AyaNova/biz/HeadOfficeBiz.cs @@ -372,6 +372,7 @@ namespace AyaNova.Biz await JobsBiz.LogJobAsync(job.GId, $"Bulk job {job.SubType} started..."); List idList = new List(); long ProcessedObjectCount = 0; + long FailedObjectCount = 0; JObject jobData = JObject.Parse(job.JobInfo); if (jobData.ContainsKey("idList")) idList = ((JArray)jobData["idList"]).ToObject>(); @@ -402,6 +403,7 @@ namespace AyaNova.Biz if (!await DeleteAsync(id)) { await JobsBiz.LogJobAsync(job.GId, $"Error processing item {id}: {GetErrorsAsString()}"); + FailedObjectCount++; } break; default: @@ -424,8 +426,9 @@ namespace AyaNova.Biz 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); } diff --git a/server/AyaNova/biz/JobOperationsBiz.cs b/server/AyaNova/biz/JobOperationsBiz.cs index 23defd2b..b021236a 100644 --- a/server/AyaNova/biz/JobOperationsBiz.cs +++ b/server/AyaNova/biz/JobOperationsBiz.cs @@ -72,11 +72,10 @@ namespace AyaNova.Biz foreach (OpsJobLog i in l) { - JobOperationsLogInfoItem o = new JobOperationsLogInfoItem(); - o.Created = i.Created; o.StatusText = i.StatusText; + o.JobId = jobId; ret.Add(o); } @@ -129,7 +128,7 @@ namespace AyaNova.Biz { var sleepTime = 30 * 1000; 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 JobsBiz.LogJobAsync(job.GId, "Test job done sleeping setting status to finished"); await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed); diff --git a/server/AyaNova/biz/JobStatus.cs b/server/AyaNova/biz/JobStatus.cs index 2b26cd31..68d32bb7 100644 --- a/server/AyaNova/biz/JobStatus.cs +++ b/server/AyaNova/biz/JobStatus.cs @@ -7,7 +7,7 @@ namespace AyaNova.Biz /// public enum JobStatus : int { - Absent=0, + Absent = 0, Sleeping = 1, Running = 2, Completed = 3,