예제 #1
0
        public async Task <JobConfigUpdateResult> StartJobAsync(
            JobConfigUpdateCommand jobConfigUpdateCommand)
        {
            var storage = _componentRegistry.GetRegisteredStorage();

            if (storage == null)
            {
                _logger.TrackError(
                    "StartJob",
                    "No storage component was registered");
                return(JobConfigUpdateResult.Failed("No storage is present. Job can't be done"));
            }


            var job = new Job
            {
                FinishedAt = null,
                JobName    = jobConfigUpdateCommand.JobName,
                JobStatus  = JobStatus.Running,
                JobId      = jobConfigUpdateCommand.JobId,
                Owner      = "admin",
                TopicQuery = jobConfigUpdateCommand.TopicQuery,
                StartedAt  = DateTime.Now,
            };

            var analysers = await PushAnalyserJobConfig(
                storage.AnalysedDataInputChannel,
                jobConfigUpdateCommand);


            var analysersInputs = analysers.Select(r => r.InputChannelName).ToArray();

            await PushNetworkDataAcquisitionJobConfig(
                storage.AcquiredDataInputChannel,
                analysersInputs,
                jobConfigUpdateCommand);

            await _jobStorage.InsertNewJobAsync(job);

            return(JobConfigUpdateResult.Successfull(
                       jobConfigUpdateCommand.JobId,
                       JobStatus.Running));
        }