Exemple #1
0
        public async Task <IHttpActionResult> CancelJob([FromBody] JobCancellationRequest request)
        {
            if (request == null)
            {
                return(BadRequest("null request encountered"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var currentUser = new ReferenceUser(this.User.Identity.GetUserId(), this.User.Identity.GetUserName())
            {
                Name = this.User.Identity.GetUserFullName()
            };

            var job = await repository.GetJob(request.JobId);

            var result = await repository.CancelJob(job, request.Reason);

            Task.Factory.StartNew(() =>
            {
                var activity = new JobActivity(job, JobActivityOperationNames.Cancel, currentUser);
                activitySubject.OnNext(activity);
            });
            return(Ok(result));
        }
Exemple #2
0
 public void Cancel(IJobRepository jobRepository,Event dblogEvent)
 {
     jobRepository.CancelJob(this, dblogEvent.Monitor == Event.Monitors.CancelOnBulking ? CobCancelCode : F21CancelCode);
     dblogEvent.EventActions.Add(new EventAction()
     {
         Action = EventAction.Actions.JobCancel,
         ActedOnDeliveryGroupId = deliverygroup_id,
         JobId = job_id
     });
 }
Exemple #3
0
        public bool PatchJob(Guid jobCorrelationId, Command command)
        {
            if (jobCorrelationId == Guid.Empty)
            {
                throw new ArgumentOutOfRangeException(nameof(jobCorrelationId), "Specified jobCorrelationId is invalid");
            }

            bool res;

            switch (command)
            {
            case Command.Pause:
                res = _repository.PauseJob(jobCorrelationId);
                break;

            case Command.Resume:
                res = _repository.ResumeJob(jobCorrelationId);
                break;

            case Command.Cancel:
                res = _repository.CancelJob(jobCorrelationId);
                break;

            case Command.Unknown:
            default:
                throw new ArgumentOutOfRangeException(nameof(command), $"unsupported {command}", nameof(command));
            }
            if (res)
            {
                _logging.Info($"Recived valid {command} order for job {jobCorrelationId}.");
            }
            else
            {
                _logging.Warn($"Recived invalid {command} order for job {jobCorrelationId}.");
            }
            return(res);
        }