Ejemplo n.º 1
0
        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());
        }