示例#1
0
        public void Should_Execute_IPlugin()
        {
            IExecutionManager     manager    = new ExecutionManager( new PluginManager() );
            IAllocationDefinition definition = new AllocationDefinition( 2 );
            IExecutionSlot        slot       = new ExecutionSlot(definition);

            definition.Add( DTO.NewPluginInfoTestPlugin );

            manager.PluginManager.Install( definition );
            manager.Add( slot );

            IPlugin completedPlugin = null;
            TestPlugin testPlugin = new TestPlugin(100);

            manager.ExecuteCompleted += delegate(object sender, ObjectEventArgs<IPlugin> eventArgs)
                                            {
                                                completedPlugin = eventArgs.EventObject;
                                            };
            manager.Execute( testPlugin );

            Assert.AreEqual( slot, manager[ definition ] );
            Assert.AreEqual( 1, manager[ definition ].UsedSlots );

            Timing.WaitWhile(() => completedPlugin == null, 1000);

            Assert.AreEqual( testPlugin, completedPlugin );
            Assert.AreEqual( 0, manager[ definition ].UsedSlots );
            Assert.AreEqual( PluginStatus.Executed, testPlugin.Status );
        }
示例#2
0
	// Use this for initialization
	void Awake ()
	{
		Instance = this;

		Debug.Log ("ExecutionManager Awake");
		EventBeginExecution_Sync += BeginExecution;
		currentCommandDict = new Dictionary<ProgramManager, Vector3> ();
		intendedNextPositions = new Dictionary<Vector3, DynamicVoxel> ();
		commandPriority = new Dictionary<Command, int>{
			{Command.WAIT, 0},
			{Command.NONE, 0},
			{Command.SENSE, 0},
			{Command.TURN_R, 0},
			{Command.TURN_L, 0},
			{Command.PUSH, 1},
			{Command.FIRE, 2},
			{Command.FORWARD, 3},
			{Command.BACKWARD, 3},
			{Command.BUILD, 4}


		};
		programManagers_inProgress = new List<ProgramManager> ();//[PlayerManager.Instance.maxPlayers];
		programManagers_finished = new List<ProgramManager> ();
		movingVoxels = new List<Voxel> ();
	}
示例#3
0
        public void Should_Add_ExecutionSlot()
        {
            IExecutionManager     manager    = new ExecutionManager( new PluginManager() );
            IAllocationDefinition definition = new AllocationDefinition( 2 );

            definition.Add( DTO.NewPluginInfoTestPlugin );

            manager.PluginManager.Install( definition );
            manager.Add( new ExecutionSlot( definition ) );

            Assert.AreEqual( 1, manager.Count );
        }
示例#4
0
	public void Init ()
	{
		Instance = this;
	}
示例#5
0
        public void Should_Initialize_IAgent_With_Custom_Execution_And_Plugin_Manager()
        {
            IPluginManager    pluginManager    = new PluginManager();
            IExecutionManager executionManager = new ExecutionManager( pluginManager );
            IAgentEngine      agentEngine      = new AgentEngine( executionManager );

            Assert.IsNotNull( agentEngine.ExecutionManager );
            Assert.IsNotNull( agentEngine.PluginManager );
            Assert.AreEqual( executionManager, agentEngine.ExecutionManager );
            Assert.AreEqual( pluginManager, agentEngine.PluginManager );
        }
示例#6
0
        public void Should_Initialize_ExecutionManager()
        {
            IExecutionManager manager = new ExecutionManager( new PluginManager() );

            Assert.IsNotNull( manager.PluginManager );
        }
示例#7
0
 private void RegisterDebugEventHandler(ExecutionManager in_execution_control)
 {
     in_execution_control.DebuggerBreakEvent += DebuggerBreakEventDelegate;
     m_execution_control = in_execution_control;
     DataContext         = this;
 }
示例#8
0
        public virtual Void execute(CommandContext commandContext)
        {
            ProcessEngineConfigurationImpl configuration = commandContext.ProcessEngineConfiguration;

            // check that the new process definition is just another version of the same
            // process definition that the process instance is using
            ExecutionManager executionManager = commandContext.ExecutionManager;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);
            ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);

            if (processInstance == null)
            {
                throw new ProcessEngineException("No process instance found for id = '" + processInstanceId + "'.");
            }
            else if (!processInstance.ProcessInstanceExecution)
            {
                throw new ProcessEngineException("A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.ProcessInstanceId + "'. " + "Please invoke the " + this.GetType().Name + " with a root execution id.");
            }
            ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.getProcessDefinition();

            DeploymentCache         deploymentCache = configuration.DeploymentCache;
            ProcessDefinitionEntity currentProcessDefinition;

            if (currentProcessDefinitionImpl is ProcessDefinitionEntity)
            {
                currentProcessDefinition = (ProcessDefinitionEntity)currentProcessDefinitionImpl;
            }
            else
            {
                currentProcessDefinition = deploymentCache.findDeployedProcessDefinitionById(currentProcessDefinitionImpl.Id);
            }

            ProcessDefinitionEntity newProcessDefinition = deploymentCache.findDeployedProcessDefinitionByKeyVersionAndTenantId(currentProcessDefinition.Key, processDefinitionVersion, currentProcessDefinition.TenantId);

            validateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);

            HistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, processInstance));
            }

            // switch all sub-executions of the process instance to the new process definition version
            IList <ExecutionEntity> childExecutions = executionManager.findExecutionsByProcessInstanceId(processInstanceId);

            foreach (ExecutionEntity executionEntity in childExecutions)
            {
                validateAndSwitchVersionOfExecution(commandContext, executionEntity, newProcessDefinition);
            }

            // switch all jobs to the new process definition version
            IList <JobEntity>           jobs = commandContext.JobManager.findJobsByProcessInstanceId(processInstanceId);
            IList <JobDefinitionEntity> currentJobDefinitions    = commandContext.JobDefinitionManager.findByProcessDefinitionId(currentProcessDefinition.Id);
            IList <JobDefinitionEntity> newVersionJobDefinitions = commandContext.JobDefinitionManager.findByProcessDefinitionId(newProcessDefinition.Id);

            IDictionary <string, string> jobDefinitionMapping = getJobDefinitionMapping(currentJobDefinitions, newVersionJobDefinitions);

            foreach (JobEntity jobEntity in jobs)
            {
                switchVersionOfJob(jobEntity, newProcessDefinition, jobDefinitionMapping);
            }

            // switch all incidents to the new process definition version
            IList <IncidentEntity> incidents = commandContext.IncidentManager.findIncidentsByProcessInstance(processInstanceId);

            foreach (IncidentEntity incidentEntity in incidents)
            {
                switchVersionOfIncident(commandContext, incidentEntity, newProcessDefinition);
            }

            // add an entry to the op log
            PropertyChange change = new PropertyChange("processDefinitionVersion", currentProcessDefinition.Version, processDefinitionVersion);

            commandContext.OperationLogManager.logProcessInstanceOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE, processInstanceId, null, null, Collections.singletonList(change));

            return(null);
        }
示例#9
0
        static void Main(string[] args)
        {
            //SetProcessDPIAware();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //exception handler
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            //get app settings
            var appSettings = new ApplicationSettings();

            appSettings = appSettings.GetOrCreateApplicationSettings();

            //create native chrome manifest file
            var manifestSettingsManger = new ManifestSettingsManager();

            manifestSettingsManger.Save();

            //if the exe was passed a filename argument then run the script
            if (args.Length > 0)
            {
                string configPath = args[0];

                if (!File.Exists(configPath))
                {
                    using (EventLog eventLog = new EventLog("Application"))
                    {
                        eventLog.Source = "Application";
                        eventLog.WriteEntry($"An attempt was made to run an OpenBots project from '{new DirectoryInfo(configPath).Parent}'" +
                                            "but the 'project.obconfig' file was not found. Please verify that the file exists at the path indicated.",
                                            EventLogEntryType.Error, 101, 1);
                    }

                    Application.Exit();
                    return;
                }

                //initialize Logger
                string engineLoggerFilePath = Path.Combine(Folders.GetFolder(FolderType.LogFolder), "OpenBots Engine Logs.txt");
                Logger engineLogger         = new LoggingMethods().CreateFileLogger(engineLoggerFilePath, Serilog.RollingInterval.Day);

                ProjectType projectType = Project.OpenProject(configPath).ProjectType;
                switch (projectType)
                {
                case ProjectType.OpenBots:
                    Application.Run(new frmScriptEngine(configPath, engineLogger));
                    break;

                case ProjectType.Python:
                case ProjectType.TagUI:
                case ProjectType.CSScript:
                case ProjectType.PowerShell:
                    ExecutionManager.RunTextEditorProject(configPath, Project.OpenProject(configPath).ProjectArguments).Wait();
                    break;
                }
            }
            else if (appSettings.ClientSettings.StartupMode == "Builder Mode" && appSettings.ClientSettings.IsRestarting)
            {
                Application.DoEvents();
                Application.Run(new frmScriptBuilder(appSettings.ClientSettings.RecentProjects[0]));
            }
            else if (appSettings.ClientSettings.StartupMode == "Builder Mode")
            {
                SplashForm = new frmSplash();
                SplashForm.Show();

                Application.DoEvents();
                Application.Run(new frmScriptBuilder(null));
            }
            else
            {
                SplashForm = new frmSplash();
                SplashForm.Show();

                Application.DoEvents();
                Application.Run(new frmAttendedMode());
            }
        }
示例#10
0
 /// <summary>
 /// Runs the <see cref="DatabaseExecutor"/> directly.
 /// </summary>
 /// <param name="command">The <see cref="DatabaseExecutorCommand"/>.</param>
 /// <param name="connectionString">The database connection string.</param>
 /// <param name="assemblies">The <see cref="Assembly"/> array whose embedded resources will be probed.</param>
 /// <param name="codeGenArgs">The <see cref="DatabaseExecutorCommand.CodeGen"/> arguments.</param>
 /// <returns>The return code; zero equals success.</returns>
 public static int Run(DatabaseExecutorCommand command, string connectionString, Assembly[] assemblies, CodeGenExecutorArgs codeGenArgs = null)
 {
     return(HandleRunResult(ExecutionManager.Create(() => new DatabaseExecutor(command, connectionString, assemblies, codeGenArgs)).Run()));
 }
示例#11
0
        /// <summary>
        /// Execute the database upgrade.
        /// </summary>
        protected override Task OnRunAsync(ExecutorRunArgs args)
        {
            var ls = new LoggerSink();

            if (_command.HasFlag(DatabaseExecutorCommand.Drop))
            {
                Logger.Default.Info(string.Empty);
                Logger.Default.Info(new string('-', 80));
                Logger.Default.Info("DB DROP: Checking database existence and dropping where found...");
                TimeExecution(() => { DropDatabase.For.SqlDatabase(_connectionString, ls); return(true); });
            }

            if (_command.HasFlag(DatabaseExecutorCommand.Create))
            {
                Logger.Default.Info(string.Empty);
                Logger.Default.Info(new string('-', 80));
                Logger.Default.Info("DB CREATE: Checking database existence and creating where not found...");
                TimeExecution(() => { EnsureDatabase.For.SqlDatabase(_connectionString, ls); return(true); });
            }

            if (_command.HasFlag(DatabaseExecutorCommand.Migrate))
            {
                Logger.Default.Info(string.Empty);
                Logger.Default.Info(new string('-', 80));
                Logger.Default.Info("DB MIGRATE: Migrating the database...");
                Logger.Default.Info($"Probing for embedded resources: {(String.Join(", ", GetNamespacesWithSuffix($"{MigrationsNamespace}.*.sql")))}");

                DatabaseUpgradeResult result = null;
                TimeExecution(() =>
                {
                    result = DeployChanges.To
                             .SqlDatabase(_connectionString)
                             .WithScriptsEmbeddedInAssemblies(_assemblies, x => ScriptsNamespaceFilter(x))
                             .WithTransactionPerScript()
                             .LogTo(ls)
                             .Build()
                             .PerformUpgrade();

                    return(result.Successful);
                });

                if (!result.Successful)
                {
                    Logger.Default.Exception(result.Error);
                    return(Task.CompletedTask);
                }
            }

            if (_command.HasFlag(DatabaseExecutorCommand.CodeGen))
            {
                Logger.Default.Info(string.Empty);
                Logger.Default.Info(new string('-', 80));
                Logger.Default.Info("DB CODEGEN: Code-gen database objects...");
                CodeGenConsole.LogCodeGenExecutionArgs(_codeGenArgs);

                if (!TimeExecution(() =>
                {
                    var em = ExecutionManager.Create(() => new CodeGenExecutor(_codeGenArgs)).Run();
                    return(em.StopExecutor?.Exception == null);
                }))
                {
                    return(Task.CompletedTask);
                }
            }

            if (_command.HasFlag(DatabaseExecutorCommand.Schema))
            {
                Logger.Default.Info(string.Empty);
                Logger.Default.Info(new string('-', 80));
                Logger.Default.Info("DB OBJECTS: Drops and creates the database objects...");

                if (!TimeExecution(() => DropAndCreateAllObjects(new string[] { "dbo", "Ref" })))
                {
                    return(Task.CompletedTask);
                }
            }

            if (_command.HasFlag(DatabaseExecutorCommand.Reset))
            {
                Logger.Default.Info(string.Empty);
                Logger.Default.Info(new string('-', 80));
                Logger.Default.Info("DB OBJECTS: Drops and creates the database objects...");

                if (!TimeExecution(() => DeleteAllAndResetIdent()))
                {
                    return(Task.CompletedTask);
                }
            }

            if (_command.HasFlag(DatabaseExecutorCommand.Data))
            {
                Logger.Default.Info(string.Empty);
                Logger.Default.Info(new string('-', 80));
                Logger.Default.Info("DB DATA: Insert or merge the embedded YAML data...");

                if (!TimeExecution(() => InsertOrMergeYamlData()))
                {
                    return(Task.CompletedTask);
                }
            }

            if (_command.HasFlag(DatabaseExecutorCommand.ScriptNew))
            {
                Logger.Default.Info(string.Empty);
                Logger.Default.Info(new string('-', 80));
                Logger.Default.Info("DB SCRIPTNEW: Creating a new SQL script from embedded template...");

                if (!TimeExecution(() => CreateScriptNew()))
                {
                    return(Task.CompletedTask);
                }
            }

            ReturnCode = 0;
            return(Task.CompletedTask);
        }
示例#12
0
 /// <summary>
 /// Runs the <see cref="DatabaseExecutor"/> directly.
 /// </summary>
 /// <param name="command">The <see cref="DatabaseExecutorCommand"/>.</param>
 /// <param name="connectionString">The database connection string.</param>
 /// <param name="assemblies">The <see cref="Assembly"/> array whose embedded resources will be probed.</param>
 /// <returns>The return code; zero equals success.</returns>
 public static int Run(DatabaseExecutorCommand command, string connectionString, params Assembly[] assemblies)
 {
     return(HandleRunResult(ExecutionManager.Create(() => new DatabaseExecutor(command, connectionString, assemblies, null)).Run()));
 }
示例#13
0
        public void TestInit()
        {
            this.executionManager = new ExecutionManager();

            TestPluginCache.Instance = null;
        }