Beispiel #1
0
        public async Task <JobConfigUpdateResult> StopJob(Guid jobId)
        {
            try
            {
                var job = await _jobStorage.GetJobAsync(jobId);

                var notification = new DataAcquisitionConfigUpdateNotification
                {
                    JobId   = jobId,
                    Command = JobCommand.Stop
                };

                var components = await _componentRegistry.GetAllComponentsAsync();

                foreach (var item in components)
                {
                    await NotifyComponent(jobId, item.ComponentId, notification);
                }

                job.JobStatus = JobStatus.Stopped;

                await _jobStorage.UpdateJobAsync(job);

                return(JobConfigUpdateResult.Successfull(jobId, job.JobStatus));
            }
            catch (Exception e)
            {
                var message = $"Could not stop the job {jobId}, due to error {e.Message}";

                _logger.TrackError(
                    "StopJob",
                    message,
                    new
                {
                    jobId,
                    exception = e
                });

                throw new InvalidOperationException(message);
            }
        }