Beispiel #1
0
        private void AddPipelineComponent(IPipelineComponent toRealize, DataFlowComponentVisualisation.Role role)
        {
            Exception exConstruction;

            //create the pipeline realization (might fail
            var value = _pipelineFactory.TryCreateComponent(toRealize, out exConstruction);

            if (role != DataFlowComponentVisualisation.Role.Source)
            {
                AddDividerIfReorderingAvailable();
            }

            //create the visualization
            var component = new PipelineComponentVisualisation(toRealize, role, value, exConstruction, component_shouldAllowDrop);

            component.DragDrop += component_DragDrop;
            flpPipelineDiagram.Controls.Add(component);//add the component

            //try to initialize the realization (we do this after creating visualization so that when the events come in we can record where on UI the consumption events happen and also because later on it might be that initialization takes ages and we want to use a Thread)
            if (value != null)
            {
                try
                {
                    if (!_useCase.IsDesignTime)
                    {
                        _useCase.GetContext().PreInitializeGeneric(new ThrowImmediatelyDataLoadEventListener(), value, _useCase.GetInitializationObjects().ToArray());
                        component.Check();
                    }

                    component.CheckMandatoryProperties();
                }
                catch (Exception exInit)
                {
                    //initialization failed
                    component.ExInitialization = exInit;
                }
            }

            component.AllowDrag = AllowReOrdering;

            if (AllowSelection)
            {
                component.AllowSelection     = true;
                component.ComponentSelected += component_Selected;
            }


            //PipelineComponents can never be locked because they are user setup things
            component.IsLocked = false;
        }
Beispiel #2
0
        private void RefreshPipelineList()
        {
            var before = ddPipelines.SelectedItem as Pipeline;

            ddPipelines.Items.Clear();

            var context = _useCase.GetContext();

            //add pipelines
            var allPipelines = _repository.GetAllObjects <Pipeline>();

            ddPipelines.Items.AddRange(context == null || cbOnlyShowCompatiblePipelines.Checked == false
                ? allPipelines.ToArray()                              //no context/show incompatible enabled so add all pipelines
                : allPipelines.Where(context.IsAllowable).ToArray()); //only compatible components

            ddPipelines.Items.Add("<<None>>");

            //reselect if it is still there
            if (before != null)
            {
                var toReselect = ddPipelines.Items.OfType <Pipeline>().SingleOrDefault(p => p.ID == before.ID);

                //if we can reselect the users previously selected one
                if (toReselect != null)
                {
                    ddPipelines.SelectedItem = toReselect;
                    return;
                }
            }

            //if there is only one pipeline select it
            ddPipelines.SelectedItem = ddPipelines.Items.OfType <Pipeline>().Count() == 1
                ? (object)ddPipelines.Items.OfType <Pipeline>().Single()
                : "<<None>>";
        }
Beispiel #3
0
        public AdvertisedPipelineComponentTypeUnderContext(Type componentType, IPipelineUseCase useCase)
        {
            _componentType = componentType;

            _role = PipelineComponent.GetRoleFor(componentType);

            var context = useCase.GetContext();

            _allowableUnderContext = context.IsAllowable(componentType, out _allowableReason);

            Type[] initializationTypes;

            var initializationObjects = useCase.GetInitializationObjects();

            //it is permitted to specify only Types as initialization objects if it is design time and the user hasn't picked any objects to execute the use case under
            if (useCase.IsDesignTime && initializationObjects.All(t => t is Type))
            {
                initializationTypes = initializationObjects.Cast <Type>().ToArray();
            }
            else
            {
                initializationTypes = useCase.GetInitializationObjects().Select(o => o.GetType()).ToArray();
            }

            foreach (var requiredInputType in context.GetIPipelineRequirementsForType(componentType))
            {
                //if there are no initialization objects that are instances of an IPipelineRequirement<T> then we cannot satisfy the components pipeline requirements (e.g. a component  DelimitedFlatFileDataFlowSource requires a FlatFileToLoad but pipeline is trying to load from a database reference)
                if (!initializationTypes.Any(available => requiredInputType == available || requiredInputType.IsAssignableFrom(available)))
                {
                    unmetRequirements.Add(requiredInputType);
                }
            }
        }
Beispiel #4
0
        public PipelineWorkAreaUI(IActivateItems activator, IPipeline pipeline, IPipelineUseCase useCase, ICatalogueRepository catalogueRepository)
        {
            _activator           = activator;
            _pipeline            = pipeline;
            _useCase             = useCase;
            _catalogueRepository = catalogueRepository;

            InitializeComponent();

            olvComponents.BuildGroups(olvRole, SortOrder.Ascending);
            olvComponents.AlwaysGroupByColumn = olvRole;
            olvComponents.FullRowSelect       = true;

            _pipelineDiagram = new PipelineDiagramUI();
            _pipelineDiagram.AllowSelection            = true;
            _pipelineDiagram.AllowReOrdering           = true;
            _pipelineDiagram.SelectedComponentChanged += _pipelineDiagram_SelectedComponentChanged;
            _pipelineDiagram.Dock = DockStyle.Fill;
            diagramPanel.Controls.Add(_pipelineDiagram);

            _arumentsCollection1      = new ArgumentCollectionUI();
            _arumentsCollection1.Dock = DockStyle.Fill;
            gbArguments.Controls.Add(_arumentsCollection1);

            olvComponents.RowFormatter += RowFormatter;
            var context = _useCase.GetContext();

            try
            {
                //middle and destination components
                var allComponentTypes = _catalogueRepository.MEF.GetGenericTypes(typeof(IDataFlowComponent <>), context.GetFlowType());

                //source components (list of all types with MEF exports of )
                var allSourceTypes = _catalogueRepository.MEF.GetGenericTypes(typeof(IDataFlowSource <>), context.GetFlowType());

                _allComponents = new List <AdvertisedPipelineComponentTypeUnderContext>();

                _allComponents.AddRange(allComponentTypes.Select(t => new AdvertisedPipelineComponentTypeUnderContext(t, _useCase)).ToArray());
                _allComponents.AddRange(allSourceTypes.Select(t => new AdvertisedPipelineComponentTypeUnderContext(t, useCase)).ToArray());

                RefreshComponentList();
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show("Failed to get list of supported MEF components that could be added to the pipeline ", exception);
            }

            gbArguments.Enabled = false;

            RDMPCollectionCommonFunctionality.SetupColumnTracking(olvComponents, olvCompatible, new Guid("1b8737cb-75d6-401b-b8a2-441e3e4322ac"));
            RDMPCollectionCommonFunctionality.SetupColumnTracking(olvComponents, olvNamespace, new Guid("35c0497e-3c04-46be-a6d6-eb02111aadb3"));
            RDMPCollectionCommonFunctionality.SetupColumnTracking(olvComponents, olvRole, new Guid("fb1205f3-049e-4fe3-89c5-d07b55fa2e17"));
            RDMPCollectionCommonFunctionality.SetupColumnTracking(olvComponents, olvName, new Guid("b7e797e8-ef6a-45d9-b51d-c2f12dbacead"));
        }
        /// <summary>
        /// Creates a new factory which can translate <see cref="IPipeline"/> blueprints into runnable <see cref="IDataFlowPipelineEngine"/> instances.
        /// </summary>
        /// <param name="useCase">The use case which describes which <see cref="IPipeline"/> are compatible, which objects are available for hydration/preinitialization etc</param>
        /// <param name="mefPlugins">Class for generating Types by name, use <see cref="ICatalogueRepository.MEF"/> to get this </param>
        public DataFlowPipelineEngineFactory(IPipelineUseCase useCase, MEF mefPlugins)
        {
            _mefPlugins = mefPlugins;
            _context    = useCase.GetContext();
            _useCase    = useCase;
            _flowType   = _context.GetFlowType();

            _constructor = new ObjectConstructor();

            _engineType = typeof(DataFlowPipelineEngine <>).MakeGenericType(_flowType);
        }
        public ConfigureAndExecutePipelineUI(IPipelineUseCase useCase, IActivateItems activator)
        {
            _useCase = useCase;

            InitializeComponent();

            //designer mode
            if (useCase == null && activator == null)
            {
                return;
            }

            SetItemActivator(activator);
            progressUI1.ApplyTheme(activator.Theme);

            pipelineDiagram1 = new PipelineDiagramUI();

            pipelineDiagram1.Dock = DockStyle.Fill;
            panel_pipelineDiagram1.Controls.Add(pipelineDiagram1);

            fork = new ForkDataLoadEventListener(progressUI1);

            var context = useCase.GetContext();

            if (context.GetFlowType() != typeof(DataTable))
            {
                throw new NotSupportedException("Only DataTable flow contexts can be used with this class");
            }

            foreach (var o in useCase.GetInitializationObjects())
            {
                var de = o as DatabaseEntity;
                if (o is DatabaseEntity)
                {
                    CommonFunctionality.Add(new ExecuteCommandShow(activator, de, 0, true));
                }
                else
                {
                    CommonFunctionality.Add(o.ToString());
                }

                _initializationObjects.Add(o);
            }

            SetPipelineOptions(activator.RepositoryLocator.CatalogueRepository);

            lblTask.Text = "Task: " + UsefulStuff.PascalCaseStringToHumanReadable(useCase.GetType().Name);
        }
Beispiel #7
0
        public PipelineWorkAreaUI(IActivateItems activator, IPipeline pipeline, IPipelineUseCase useCase, ICatalogueRepository catalogueRepository)
        {
            _activator           = activator;
            _pipeline            = pipeline;
            _useCase             = useCase;
            _catalogueRepository = catalogueRepository;

            InitializeComponent();

            olvComponents.BuildGroups(olvRole, SortOrder.Ascending);
            olvComponents.AlwaysGroupByColumn = olvRole;

            _pipelineDiagram = new PipelineDiagramUI();
            _pipelineDiagram.AllowSelection            = true;
            _pipelineDiagram.AllowReOrdering           = true;
            _pipelineDiagram.SelectedComponentChanged += _pipelineDiagram_SelectedComponentChanged;
            _pipelineDiagram.Dock = DockStyle.Fill;
            diagramPanel.Controls.Add(_pipelineDiagram);

            _arumentsCollection1      = new ArgumentCollectionUI();
            _arumentsCollection1.Dock = DockStyle.Fill;
            gbArguments.Controls.Add(_arumentsCollection1);

            olvComponents.RowFormatter += RowFormatter;
            var context = _useCase.GetContext();

            try
            {
                //middle and destination components
                var allComponentTypes = _catalogueRepository.MEF.GetGenericTypes(typeof(IDataFlowComponent <>), context.GetFlowType());

                //source components (list of all types with MEF exports of )
                var allSourceTypes = _catalogueRepository.MEF.GetGenericTypes(typeof(IDataFlowSource <>), context.GetFlowType());

                olvComponents.AddObjects(allComponentTypes.Select(t => new AdvertisedPipelineComponentTypeUnderContext(t, _useCase)).ToArray());
                olvComponents.AddObjects(allSourceTypes.Select(t => new AdvertisedPipelineComponentTypeUnderContext(t, useCase)).ToArray());
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show("Failed to get list of supported MEF components that could be added to the pipeline ", exception);
            }

            gbArguments.Enabled = false;
        }
        /// <summary>
        /// Refresh the list of pipeline components
        /// </summary>
        private void RefreshPipelineList()
        {
            var before = ddPipelines.SelectedItem as Pipeline;

            ddPipelines.Items.Clear();

            var context = _useCase.GetContext();

            //add pipelines sorted alphabetically
            var allPipelines = _repository.GetAllObjects <Pipeline>().OrderBy(p => p.Name).ToArray();

            ddPipelines.Items.Add("<<None>>");

            ddPipelines.Items.AddRange(allPipelines.Where(_useCase.IsAllowable).ToArray());
            ddPipelines.Items.Add(ShowAll);

            if (showAll)
            {
                ddPipelines.Items.AddRange(allPipelines.Where(o => !_useCase.IsAllowable(o)).ToArray());
            }

            //reselect if it is still there
            if (before != null)
            {
                var toReselect = ddPipelines.Items.OfType <Pipeline>().SingleOrDefault(p => p.ID == before.ID);

                //if we can reselect the users previously selected one
                if (toReselect != null)
                {
                    ddPipelines.SelectedItem = toReselect;
                    return;
                }
            }

            //if there is only one pipeline select it
            ddPipelines.SelectedItem = ddPipelines.Items.OfType <Pipeline>().Count() == 1
                ? (object)ddPipelines.Items.OfType <Pipeline>().Single()
                : "<<None>>";
        }
Beispiel #9
0
 protected override IDataFlowPipelineContext GenerateContextImpl()
 {
     return(_useCase.GetContext());
 }
Beispiel #10
0
        public override void Execute()
        {
            base.Execute();
            var add   = _toAdd;
            var order = _order;

            // if command doesn't know which to add, ask user
            if (add == null)
            {
                var         mef     = BasicActivator.RepositoryLocator.CatalogueRepository.MEF;
                var         context = _useCaseIfAny?.GetContext();
                List <Type> offer   = new List <Type>();

                TypeFilter filter = (t, o) => t.IsGenericType &&
                                    (t.GetGenericTypeDefinition() == typeof(IDataFlowComponent <>) ||
                                     t.GetGenericTypeDefinition() == typeof(IDataFlowSource <>));

                //get any source and flow components compatible with any context
                offer.AddRange(
                    mef.GetAllTypes()
                    .Where(t => !t.IsInterface && !t.IsAbstract)
                    .Where(t => t.FindInterfaces(filter, null).Any())
                    .Where(t => context == null || context.IsAllowable(t))
                    );

                if (!BasicActivator.SelectObject("Add", offer.ToArray(), out add))
                {
                    return;
                }
            }

            // Only proceed if we have a component type to add to the pipe
            if (add == null)
            {
                return;
            }

            // check if it is a source or destination (or if both are false it is a middle component)
            TypeFilter sourceFilter = (t, o) =>
                                      t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IDataFlowSource <>);
            TypeFilter destFilter = (t, o) =>
                                    t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IDataFlowDestination <>);

            var isSource = add.FindInterfaces(sourceFilter, null).Any();
            var isDest   = add.FindInterfaces(destFilter, null).Any();

            if (isSource)
            {
                order = int.MinValue;
                if (_pipeline.SourcePipelineComponent_ID.HasValue)
                {
                    throw new Exception($"Pipeline '{_pipeline}' already has a source");
                }
            }

            if (isDest)
            {
                order = int.MaxValue;
                if (_pipeline.DestinationPipelineComponent_ID.HasValue)
                {
                    throw new Exception($"Pipeline '{_pipeline}' already has a destination");
                }
            }

            // if we don't know the order yet and it's important
            if (!order.HasValue && !isDest && !isSource)
            {
                if (BasicActivator.SelectValueType("Order", typeof(int), 0, out object chosen))
                {
                    order = (int)chosen;
                }
                else
                {
                    return;
                }
            }

            var newComponent = new PipelineComponent(BasicActivator.RepositoryLocator.CatalogueRepository, _pipeline,
                                                     add, order ?? 0);

            newComponent.CreateArgumentsForClassIfNotExists(add);

            if (isSource)
            {
                _pipeline.SourcePipelineComponent_ID = newComponent.ID;
                _pipeline.SaveToDatabase();
            }

            if (isDest)
            {
                _pipeline.DestinationPipelineComponent_ID = newComponent.ID;
                _pipeline.SaveToDatabase();
            }

            Publish(newComponent);
            Emphasise(newComponent);
        }