public IActionResult CancelExecution(Guid id) { var resource = ResourceDataService.Get(id); if (resource == null || resource.SubscriberId != User.Claims.First(claim => claim.Type == JwtClaimTypes.Subject).Value) { return(NotFound(ResourceNotFound(id.ToString()))); } if (resource.Status == Status.Enqueued || resource.Status == Status.InProgress) { //if(resource.InnerJobId != null) // BackgroundJob.Delete(resource.InnerJobId); //BackgroundJob.Delete(resource.JobId); ExecutionLogger.SetExecutionId(id); ExecutionLogger.Error("Execution canceled by the user."); resource.Status = Status.Canceled; resource.FinishTime = DateTime.Now; resource.CancelJob = true; ResourceDataService.Update(resource); ResourceDataService.SaveChanges(); } return(NoContent()); }
public IActionResult CreateResource([FromBody] DiscreteLogarithmCreateDto createDto) { var result = base.CreateResource <DiscreteLogarithmCreateDto, DiscreteLogarithmGetDto>(createDto); if (CreatedResource == null) { return(result); } if (User.Identity.IsAuthenticated) { CreatedResource.SubscriberId = User.Claims.First(claim => claim.Type == JwtClaimTypes.Subject).Value; } CreatedResource.JobId = CreatedResource.StartJobService(); ResourceDataService.Update(CreatedResource); ResourceDataService.SaveChanges(); ExecutionLogger.SetExecutionId(CreatedResource.Id); ExecutionLogger.Info("Enqueued for execution."); return(result); }