예제 #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;
        }
예제 #2
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);
            });
        }