Ejemplo n.º 1
0
        private void SaveProject()
        {
            // Store current package if in design-mode
            var packageOverview = this.mainWindowContent.Content as Screens.PackageOverview;

            if (packageOverview != null)
            {
                packageOverview.SaveDiagram();
            }

            Type[] extraTypes = applicationInitializer.ModuleLoader.GetModuleTypeList();

            // Save the connections to disk
            ObservableCollection <ConnectionConfigurationBase> connections = this.CurrentProject.Connections;
            string serializedConnections = ConfigurationSerializer.SerializeObject(connections, extraTypes);

            ConfigurationFileHandler.SaveStringToFile(this.CurrentProject.ProjectName + "Connections.xml",
                                                      this.CurrentProject.ProjectFolder,
                                                      serializedConnections);

            // Save the project to disk
            this.CurrentProject.Connections = null;
            string serializedProject = ConfigurationSerializer.SerializeObject(this.CurrentProject, extraTypes);

            ConfigurationFileHandler.SaveStringToFile(this.CurrentProject.ProjectName + ".xml",
                                                      this.CurrentProject.ProjectFolder,
                                                      serializedProject);

            this.CurrentProject.Connections = connections;
        }
Ejemplo n.º 2
0
        public void Add(string file)
        {
            // Limit number of recent files to 5
            if (RecentFiles.Count > 4)
            {
                RecentFiles.RemoveAt(0);
            }

            var newFile = new RecentFile()
            {
                FileName     = Path.GetFileName(file),
                FullFilePath = file
            };

            var recentFile = RecentFiles.FirstOrDefault(t => t.FullFilePath == newFile.FullFilePath);

            if (recentFile != null)
            {
                RecentFiles.Remove(recentFile);
            }

            RecentFiles.Add(newFile);

            var serializedRecentFiles = ConfigurationSerializer.SerializeObject(RecentFiles, new Type [] {});

            ApplicationLocalStorageHelper.WriteToFile(RECENTFILESSTORENAME, serializedRecentFiles);
        }
Ejemplo n.º 3
0
        public static ConfigurationWindowSettings Get(DesignerItem designerItem, StepConfigurationBase configuration, ModuleLoader moduleLoader, List <IDatastore> dataStores, IEnumerable <ConnectionConfigurationBase> connections)
        {
            var module = Activator.CreateInstance(designerItem.ModuleDescription.ModuleType) as IModule;

            ConfigurationWindowSettings configurationWindowSettings = new ConfigurationWindowSettings()
            {
                title                 = designerItem.ItemLabel,
                titleImage            = IntegrationTool.SDK.Diagram.IconLoader.GetFromAssembly(designerItem.ModuleDescription.ModuleType.Assembly, "Icon.xml"),
                connections           = connections.Where(t => t.ModuleDescription.Attributes.ConnectionType == designerItem.ModuleDescription.Attributes.ConnectionType),
                moduleDescription     = designerItem.ModuleDescription,
                configuration         = configuration,
                originalConfiguration = ConfigurationSerializer.SerializeObject(configuration, moduleLoader.GetModuleTypeList()),
            };

            if (!dataStores.Any())
            {
                throw new InfoException("No incoming data available. Please connect a datasource first!");
            }

            if (module is IDataMerge)
            {
                if (dataStores.Count != 2)
                {
                    throw new InfoException("Make sure to connect exactly two incoming datasources!");
                }
                configurationWindowSettings.configurationControl = ((IDataMerge)module).RenderConfigurationWindow(configuration, dataStores[0], dataStores[1]);
            }
            else
            {
                configurationWindowSettings.configurationControl = ((IModule)module).RenderConfigurationWindow(configuration, dataStores.First());
                configurationWindowSettings.datastore            = dataStores.First();
            }

            return(configurationWindowSettings);
        }
Ejemplo n.º 4
0
        private void lbConnections_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ConnectionConfigurationBase connectionConfiguration = ((ListBox)sender).SelectedItem as ConnectionConfigurationBase;

            if (connectionConfiguration != null)
            {
                string        orginalConnectionConfiguration = ConfigurationSerializer.SerializeObject(connectionConfiguration, this.moduleLoader.GetModuleTypeList());
                NewConnection newConnection = new NewConnection(this.moduleLoader.Modules, connectionConfiguration, orginalConnectionConfiguration);
                ShowNewConnectionWindow(newConnection);
            }
        }
Ejemplo n.º 5
0
        public void ConfigurationSerialization()
        {
            string  projectName = "Serialization    Project";
            Project project     = new Project()
            {
                ProjectName   = "Serialiazation    Project",
                ProjectFolder = @"C:\temp"
            };

            string  projectString       = ConfigurationSerializer.SerializeObject(project, new Type [] {});
            Project deserializedProject = (Project)ConfigurationSerializer.DeserializeObject(projectString, typeof(Project), new Type[] { });

            StringAssert.Equals(deserializedProject.ProjectName, projectName);
        }
Ejemplo n.º 6
0
        void MyDesigner_OnCopyCurrentSelection(object sender, EventArgs e)
        {
            this.StepCopy      = new StepCopy();
            this.StepCopy.Type = ((DesignerCanvas)sender).DesignerCanvasType;
            List <ConfigurationBase> configurationsToCopy = new List <ConfigurationBase>();
            List <SerializedDiagram> diagramsToCopy       = new List <SerializedDiagram>();

            DesignerCanvas designerCanvas = sender as DesignerCanvas;

            foreach (DesignerItem designerItem in designerCanvas.SelectionService.CurrentSelection.OfType <DesignerItem>())
            {
                // Copy sub-configurations (diagram and configurations)
                var subDiagram = this.Package.SubDiagrams.Where(t => t.ParentItemId == designerItem.ID).FirstOrDefault();
                if (subDiagram != null)
                {
                    diagramsToCopy.Add(subDiagram);
                    List <DesignerItem> subdiagramDesignerItems = DesignerCanvas.LoadDiagramDesignerItems(subDiagram.Diagram, this.moduleLoader.Modules);
                    foreach (DesignerItem subdiagramDesignerItem in subdiagramDesignerItems)
                    {
                        var subconfiguration = this.Package.Configurations.Where(t => t.ConfigurationId == subdiagramDesignerItem.ID).FirstOrDefault();
                        if (subconfiguration != null)
                        {
                            configurationsToCopy.Add(subconfiguration);
                        }
                    }
                }

                // Copy main configuration
                var configuration = this.Package.Configurations.Where(t => t.ConfigurationId == designerItem.ID).FirstOrDefault();
                if (configuration != null)
                {
                    configurationsToCopy.Add(configuration);
                }
            }

            this.StepCopy.Configurations = ConfigurationSerializer.SerializeObject(configurationsToCopy, moduleLoader.GetModuleTypeList());
            this.StepCopy.Diagrams       = ConfigurationSerializer.SerializeObject(diagramsToCopy, moduleLoader.GetModuleTypeList());
        }
Ejemplo n.º 7
0
        private async Task RunInternal(IProgress <ProgressReport> progress)
        {
            this.progress = progress;

            await Task.Run(() =>
            {
                ItemWorker[] startDesignerItems = GetStartDesignerItems();
                ItemWorker[] endDesignerItems   = GetEndDesignerItems();

                // Start starteritems
                foreach (ItemWorker item in startDesignerItems)
                {
                    ExecuteDesignerItem(item);
                }

                while (true)
                {
                    // Continously check if all items finished already
                    List <ItemWorker> unfinishedItemWorkers = itemWorkers.Where(t => t.DesignerItem.State != ItemState.Stopped && t.DesignerItem.State != ItemState.Error && t.DesignerItem.State != ItemState.NotExecuted).ToList();
                    if (unfinishedItemWorkers.Count == 0)
                    {
                        if (RunCompleted != null)
                        {
                            RunCompleted(this, new EventArgs());
                        }
                        break;
                    }

                    // Check if a new item can be started
                    List <ItemWorker> finishedItems = itemWorkers.Where(t => t.DesignerItem.State == ItemState.Stopped || t.DesignerItem.State == ItemState.Error || t.DesignerItem.State == ItemState.NotExecuted).ToList();
                    foreach (ItemWorker itemWorker in unfinishedItemWorkers.Where(t => t.DesignerItem.State == ItemState.Initialized))
                    {
                        // Initialize
                        bool newItemCanBeStarted = true;

                        // If not all incoming connections to the item are from finished items, the item may not be started
                        IEnumerable <ConnectionBase> incomingConnections = FlowHelper.GetIncomingConnections(itemWorker.DesignerItem.ID, connectionList);
                        foreach (ConnectionBase connection in incomingConnections)
                        {
                            if (finishedItems.Where(t => t.DesignerItem.ID == connection.SourceID).Count() == 0)
                            {
                                newItemCanBeStarted = false;
                            }
                        }

                        if (newItemCanBeStarted == true)
                        {
                            // Check if all incoming connection allow an execution
                            bool allowExecution_PreviousErrorTest = FlowHelper.AllowExecution_OnPreviousErrorTest(itemWorker, this.itemWorkers, this.connectionList);
                            bool allowExecution_PreviousItemNotSuccessfulOnErrorlineTest = FlowHelper.AllowExecution_PreviousStepNotSuccessfulOnErrorlineTest(itemWorker, this.itemWorkers, this.connectionList);
                            bool allowExecution_activeItem = itemWorker.Configuration.Status == StepExecutionStatus.Active;

                            if (allowExecution_PreviousErrorTest && allowExecution_PreviousItemNotSuccessfulOnErrorlineTest && allowExecution_activeItem)
                            {
                                ExecuteDesignerItem(itemWorker);
                            }
                            else
                            {
                                DoNotExecuteDesignerItem(itemWorker);
                            }
                        }
                    }

                    System.Threading.Thread.Sleep(200);
                }

                this.runLog.EndTime = DateTime.Now;

                string serializedRunLog = ConfigurationSerializer.SerializeObject(runLog, new Type [] {});
                ConfigurationFileHandler.SaveStringToFile("runLog.xml", this.runLog.RunLogPath, serializedRunLog);
            });
        }