示例#1
0
        private IDataFlowPipelineEngine CreateAndInitializePipeline()
        {
            progressUI1.Clear();

            IDataFlowPipelineEngine pipeline = null;

            try
            {
                pipeline = PipelineFactory.Create(_pipelineSelectionUI.Pipeline, fork);
            }
            catch (Exception exception)
            {
                fork.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Could not instantiate pipeline", exception));
                return(null);
            }


            try
            {
                pipeline.Initialize(_initializationObjects.ToArray());
            }
            catch (Exception exception)
            {
                fork.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Failed to Initialize pipeline", exception));
                return(null);
            }

            return(pipeline);
        }
        /// <summary>
        /// Attempts to create an instance of <see cref="IDataFlowPipelineEngine"/> described by the blueprint <paramref name="pipeline"/>.  Components are then checked if they
        /// support <see cref="ICheckable"/> using the <paramref name="checkNotifier"/> to record the results.
        /// </summary>
        /// <param name="pipeline">The blueprint to attempt to generate</param>
        /// <param name="checkNotifier">The event notifier to record how it went</param>
        /// <param name="initizationObjects">The objects available for fulfilling IPipelineRequirements</param>
        public void Check(IPipeline pipeline, ICheckNotifier checkNotifier, object[] initizationObjects)
        {
            //Try to construct the pipeline into an in memory Engine based on the in Catalogue blueprint (Pipeline)
            IDataFlowPipelineEngine dataFlowPipelineEngine = null;

            try
            {
                dataFlowPipelineEngine = Create(pipeline, new FromCheckNotifierToDataLoadEventListener(checkNotifier));
                checkNotifier.OnCheckPerformed(new CheckEventArgs("Pipeline successfully constructed in memory", CheckResult.Success));
            }
            catch (Exception exception)
            {
                checkNotifier.OnCheckPerformed(
                    new CheckEventArgs("Failed to construct pipeline, see Exception for details", CheckResult.Fail,
                                       exception));
            }

            if (initizationObjects == null)
            {
                checkNotifier.OnCheckPerformed(new CheckEventArgs("initizationObjects parameter has not been set (this is a programmer error most likely ask your developer to fix it - this parameter should be empty not null)",
                                                                  CheckResult.Fail));
                return;
            }

            //Initialize each component with the initialization objects so that they can check themselves (note that this should be preview data, hopefully the components don't run off and start nuking stuff just because they got their GO objects)
            if (dataFlowPipelineEngine != null)
            {
                try
                {
                    dataFlowPipelineEngine.Initialize(initizationObjects);
                    checkNotifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Pipeline sucesfully initialized with " +
                            initizationObjects.Length + " initialization objects",
                            CheckResult.Success));
                }
                catch (Exception exception)
                {
                    checkNotifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Pipeline initialization failed, there were " + initizationObjects.Length +
                            " objects for use in initialization (" +
                            string.Join(",", initizationObjects.Select(o => o.ToString())) + ")", CheckResult.Fail,
                            exception));
                }

                checkNotifier.OnCheckPerformed(new CheckEventArgs("About to check engine/components", CheckResult.Success));
                dataFlowPipelineEngine.Check(checkNotifier);
            }
        }
示例#3
0
        public void SetTo(IPipeline pipeline, IPipelineUseCase useCase)
        {
            _useCase = useCase;

            _pipeline = pipeline;
            if (_pipeline != null)
            {
                _pipeline.ClearAllInjections();
            }

            //clear the diagram
            flpPipelineDiagram.Controls.Clear();

            pipelineSmiley.Reset();

            try
            {
                //if there is a pipeline
                if (_pipeline != null)
                {
                    try
                    {
                        _pipelineFactory = new DataFlowPipelineEngineFactory(_useCase, _pipeline);

                        //create it
                        IDataFlowPipelineEngine pipelineInstance = _pipelineFactory.Create(pipeline, new ThrowImmediatelyDataLoadEventListener());

                        //initialize it (unless it is design time)
                        if (!_useCase.IsDesignTime)
                        {
                            pipelineInstance.Initialize(_useCase.GetInitializationObjects().ToArray());
                        }
                    }
                    catch (Exception ex)
                    {
                        pipelineSmiley.Fatal(ex);
                    }

                    //There is a pipeline set but we might have been unable to fully realize it so setup stuff based on PipelineComponents

                    //was there an explicit instance?
                    if (_useCase.ExplicitSource != null)
                    {
                        AddExplicit(_useCase.ExplicitSource);//if so add it
                    }
                    else
                    //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken?
                    if (pipeline.SourcePipelineComponent_ID != null)
                    {
                        AddPipelineComponent((int)pipeline.SourcePipelineComponent_ID, DataFlowComponentVisualisation.Role.Source, pipeline.Repository);    //add the possibly broken PipelineComponent to the diagram
                    }
                    else
                    {
                        AddBlankComponent(DataFlowComponentVisualisation.Role.Source);    //the user hasn't put one in yet
                    }
                    foreach (var middleComponent in pipeline.PipelineComponents.Where(c => c.ID != pipeline.SourcePipelineComponent_ID && c.ID != pipeline.DestinationPipelineComponent_ID).OrderBy(comp => comp.Order))
                    {
                        AddPipelineComponent(middleComponent, DataFlowComponentVisualisation.Role.Middle);//add the possibly broken PipelineComponent to the diagram
                    }
                    //was there an explicit instance?
                    if (_useCase.ExplicitDestination != null)
                    {
                        AddDividerIfReorderingAvailable();
                        AddExplicit(_useCase.ExplicitDestination);//if so add it
                    }
                    else
                    //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken?
                    if (pipeline.DestinationPipelineComponent_ID != null)
                    {
                        AddPipelineComponent((int)pipeline.DestinationPipelineComponent_ID, DataFlowComponentVisualisation.Role.Destination, pipeline.Repository);    //add the possibly broken PipelineComponent to the diagram
                    }
                    else
                    {
                        AddDividerIfReorderingAvailable();
                        AddBlankComponent(DataFlowComponentVisualisation.Role.Destination);    //the user hasn't put one in yet
                    }


                    return;
                }


                //Fallback
                //user has not picked a pipeline yet, show him the shell (factory)
                //factory has no source, add empty source
                if (_useCase.ExplicitSource == null)
                {
                    AddBlankComponent(DataFlowComponentVisualisation.Role.Source);
                }
                else
                {
                    AddExplicit(_useCase.ExplicitSource);
                }


                //factory has no source, add empty source
                if (_useCase.ExplicitDestination == null)
                {
                    AddBlankComponent(DataFlowComponentVisualisation.Role.Destination);
                }
                else
                {
                    AddExplicit(_useCase.ExplicitDestination);
                }
            }
            finally
            {
                Invalidate();
            }
        }