private static IBuildQueueJob CreateNewBuildJob(
            ComponentConfiguration componentConfiguration,
            CancellationTokenSource <CompileCancellationToken> cancellationTokenSource,
            ProgressToken progressToken,
            IJobCollection jobCollection)
        {
            IBuildableComponentSubtype buildableComponentSubtype = (IBuildableComponentSubtype)componentConfiguration.ComponentSubtype;

            string outputFilePath = buildableComponentSubtype.GetOutputTopLevelFilePath(componentConfiguration);

            if (jobCollection.JobInProgress(outputFilePath))
            {
                throw new CommandLineOperationException($"Build at {outputFilePath} is already in progress.");
            }

            BuildId         currentBuildId  = buildableComponentSubtype.CreateBuildId(componentConfiguration);
            BuildQueueJobId buildQueueJobId = BuildQueueJobExtension.CreateBuildQueueJobId(currentBuildId);
            IBuildQueueJob  job             = jobCollection.CreateNewJob(
                buildQueueJobId,
                componentConfiguration.ComponentDefinition.ReferencingEnvoy,
                buildableComponentSubtype.XmlName,
                outputFilePath,
                cancellationTokenSource,
                progressToken);

            return(job);
        }
        public Model Initial()
        {
            _currentCavity     = 95;
            _currentPlate      = null;
            _currentTube       = 15;
            _currentTubeRunner = null;

            _platesCreated      = 0;
            _tubeRunnersCreated = 0;

            _result             = new JobCollection.JobCollection();
            _locationRepository = new LocationRepository();

            foreach (var sample in _jobRequest.Samples)
            {
                AddSample(sample);
            }

            foreach (var reagent in _jobRequest.Assay.Reagents)
            {
                AddReagent(reagent);
            }

            AddSteps(_jobRequest.Samples);

            _resultModel = new Model
            {
                RootElements = { _result },
                ModelUri     = new Uri("temp:result")
            };

            return(_resultModel);
        }
        public static void CalculateActualChanges(IJobCollection jobCollection, string[] changes, out Dictionary <IJob, JobStatus> stateChanges, out Dictionary <ITipLiquidTransfer, JobStatus> tipChanges, out List <string> newSamples)
        {
            stateChanges = new Dictionary <IJob, JobStatus>();
            tipChanges   = new Dictionary <ITipLiquidTransfer, JobStatus>();
            newSamples   = new List <string>();
            foreach (var line in changes)
            {
                if (line.StartsWith("NewSample"))
                {
                    newSamples.Add(line.Substring("NewSample".Length + 1));
                    continue;
                }
                var firstUnderscore = line.IndexOf('_');
                var lastUnderscore  = line.LastIndexOf('_');

                var stepName  = line.Substring(0, firstUnderscore);
                var plateName = line.Substring(firstUnderscore + 1, lastUnderscore - firstUnderscore - 1);
                var state     = line.Substring(lastUnderscore + 1);

                foreach (var job in jobCollection.Jobs.Where(j => j.ProtocolStepName == stepName))
                {
                    switch (job)
                    {
                    case LiquidTransferJob liquidTransfer:
                        if (liquidTransfer.Target.Name == plateName)
                        {
                            var wasSuccess = true;
                            foreach (var tip in liquidTransfer.Tips)
                            {
                                var tipSuccess = state[tip.TargetCavityIndex] == 'S';
                                wasSuccess &= tipSuccess;
                                tipChanges.Add(tip, tipSuccess ? JobStatus.Succeeded : JobStatus.Failed);
                            }
                            stateChanges.Add(liquidTransfer, wasSuccess ? JobStatus.Succeeded : JobStatus.Failed);
                        }
                        break;

                    case IncubateJob incubate:
                        if (incubate.Microplate.Name == plateName)
                        {
                            stateChanges.Add(incubate, state == "S" ? JobStatus.Succeeded : JobStatus.Failed);
                        }
                        break;

                    case WashJob washJob:
                        if (washJob.Microplate.Name == plateName)
                        {
                            stateChanges.Add(washJob, state == "S" ? JobStatus.Succeeded : JobStatus.Failed);
                        }
                        break;
                    }
                }
            }
        }
Example #4
0
 /// <summary>
 /// Constructs an instance of a <see cref="CommandLineBuildJobMonitor"/>. Creates a build job for a component build and
 /// begins monitoring the job collection for child jobs to be added.
 /// </summary>
 /// <param name="componentConfiguration">The <see cref="ComponentConfiguration"/> for the component build being monitored.</param>
 /// <param name="progressToken">Progress token to create the build job with.</param>
 /// <param name="cancellationTokenSource">Cancellation token source to create the build job with.</param>
 public CommandLineBuildJobMonitor(
     ComponentConfiguration componentConfiguration,
     ProgressToken progressToken,
     CancellationTokenSource <CompileCancellationToken> cancellationTokenSource)
 {
     _jobFinishedCompletionSource = new TaskCompletionSource <object>();
     _jobCollection = componentConfiguration.Host.GetSharedExportedValue <IJobCollection>();
     _jobCollection.CollectionChanged += JobCollectionOnCollectionChanged;
     _rootJob = CreateNewBuildJob(componentConfiguration, cancellationTokenSource, progressToken, _jobCollection);
     if (_rootJob == null)
     {
         throw new CommandLineOperationException(LocalizedStrings.BuildComponentTool_FailToStartBuildErrorMessage);
     }
     SubscribeToRootJobFinishedEvent();
 }
 public CollectionOfJobCollections(IJobCollection jobCollection, ITransformationContext context)
     : base(jobCollection.Jobs.GroupBy(j => j.ProtocolStepName).Select(group => new JobsOfProtocolStep(group.Key, group, context)))
 {
     _jobCollection = jobCollection;
 }