/// <summary> /// Adds a step to the job and connects it to the last step, if necessary. /// </summary> /// <param name="step"></param> public void AddStep(JobStep step) { if (step is IDataSource source) { source.Output = new OutputPipeline(); } var lastStep = steps.LastOrDefault(); ConnectAndAddStep(step, lastStep); }
private void ConnectAndAddStep(JobStep step, JobStep sourceStep) { if (step is IDataSink) { if (!(sourceStep is IDataSource lastSource)) { throw new InvalidOperationException($"Step {sourceStep.Id} must be a Data Source to be connected to {step.Id}."); } ((IDataSink)step).Input = ((OutputPipeline)lastSource.Output).CreateInputPipeline(); } steps.Add(step); }
/// <summary> /// Add a step to the job and connects it to <paramref name="sourceStepId"/>. /// </summary> /// <param name="step">The step to add.</param> /// <param name="sourceStepId">The Id of the data source step.</param> /// <exception cref="InvalidConfigurationException">sourceStepId doesn't exist.</exception> public void AddStep(JobStep step, string sourceStepId) { if (step is null) { throw new ArgumentNullException(nameof(step)); } var sourceStep = steps.FirstOrDefault(s => s.Id == sourceStepId); if (sourceStep is null) { throw new InvalidConfigurationException($"Data Source step {sourceStepId} doesn't exist."); } if (!(sourceStep is IDataSource)) { throw new InvalidConfigurationException($"Data Source Step {sourceStepId} is not a data source."); } if (!(step is IDataSink)) { throw new InvalidConfigurationException($"Step {step.Id} is not a Data Sink."); } ConnectAndAddStep(step, sourceStep); }