private async Task PushNetworkDataAcquisitionJobConfig( string storageChannelName, IEnumerable <string> selectedAnalysersChannels, JobConfigUpdateCommand jobConfigUpdateCommand) { var outputChannels = selectedAnalysersChannels .Concat(new[] { storageChannelName, }) .ToArray(); foreach (var dataAcquirer in jobConfigUpdateCommand.DataAcquirers) { var attributes = jobConfigUpdateCommand .Attributes.GetValue(dataAcquirer)?.ToObject <JObject>() ?? new JObject(); try { var topicQuery = new JProperty("TopicQuery", jobConfigUpdateCommand.TopicQuery); attributes.Add(topicQuery); var languageProperty = new JProperty("Language", jobConfigUpdateCommand.Language); attributes.Add(languageProperty); } catch (Exception e) { _logger.TrackError( "PushNetworkJobConfig", "Error while adding attributes", new { jobId = jobConfigUpdateCommand.JobId, exception = e }); throw; } var notification = new DataAcquisitionConfigUpdateNotification { JobId = jobConfigUpdateCommand.JobId, Attributes = attributes, OutputMessageBrokerChannels = outputChannels, Command = JobCommand.Start }; await NotifyComponent( jobConfigUpdateCommand.JobId, dataAcquirer, notification); var componentConfig = new JobComponentConfig { ComponentId = dataAcquirer, Attributes = attributes, JobId = jobConfigUpdateCommand.JobId, OutputMessageBrokerChannels = notification.OutputMessageBrokerChannels }; await _componentRegistry.InsertJobComponentConfigAsync(componentConfig); } }
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); } }