private static T GetAnnotation <T>(IProcessEngine processEngine, Type testClass, string methodName, Type annotationClass) where T : Attribute { MethodInfo method = null; var annotation = default(T); try { method = GetMethod(testClass, methodName); annotation = (T)method.GetCustomAttribute(annotationClass); } catch (System.Exception ex) { // - ignore if we cannot access the method // - just try again with the class // => can for example be the case for parameterized tests where methodName does not correspond to the actual method name // (note that method-level annotations still work in this // scenario due to Description#getAnnotation in annotationRequiredHistoryLevelCheck) } // if not found on method, try on class level if (annotation == null) { annotation = (T)testClass.GetCustomAttribute(annotationClass); } return(annotation); }
public virtual void testFallbackSerializerDoesNotOverrideRegularSerializer() { // given // that the process engine is configured with a serializer for a certain format // and a fallback serializer factory for the same format ProcessEngineConfigurationImpl engineConfiguration = (new StandaloneInMemProcessEngineConfiguration()).SetJdbcUrl("jdbc:h2:mem:camunda-forceclose").SetProcessEngineName("engine-forceclose") as ProcessEngineConfigurationImpl; // Todo: ProcessEngineConfigurationImpl.CustomPreVariableSerializers //engineConfiguration.CustomPreVariableSerializers = new (new ExampleConstantSerializer()); engineConfiguration.FallbackSerializerFactory = new ExampleSerializerFactory(); processEngine = engineConfiguration.BuildProcessEngine(); deployOneTaskProcess(processEngine); // Todo: ExampleSerializer // when setting a variable that no regular serializer can handle //IObjectValue objectValue = Engine.Variable.Variables.ObjectValue("foo").SerializationDataFormat(ExampleSerializer.FORMAT).Create(); //IProcessInstance pi = processEngine.RuntimeService.StartProcessInstanceByKey("oneTaskProcess", Engine.Variable.Variables.CreateVariables().PutValueTyped("var", objectValue)); //IObjectValue fetchedValue = processEngine.RuntimeService.GetVariableTyped<IObjectValue>(pi.Id, "var", true); // then the fallback serializer is used //Assert.NotNull(fetchedValue); // Todo: ExampleSerializer //Assert.AreEqual(ExampleSerializer.FORMAT, fetchedValue.SerializationDataFormat); //Assert.AreEqual(ExampleConstantSerializer.DESERIALIZED_VALUE, fetchedValue.Value); }
public virtual void testBuiltinFunctionMapperRegistration() { // given a process engine configuration with a custom function mapper ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.CreateStandaloneInMemProcessEngineConfiguration().SetJdbcUrl("jdbc:h2:mem:camunda" + this.GetType().Name); CustomExpressionManager customExpressionManager = new CustomExpressionManager(); Assert.True(customExpressionManager.FunctionMappers.Count == 0); config.ExpressionManager = customExpressionManager; // when the engine is initialized engine = config.BuildProcessEngine(); // then two default function mappers should be registered Assert.AreSame(customExpressionManager, config.ExpressionManager); Assert.AreEqual(2, customExpressionManager.FunctionMappers.Count); bool commandContextMapperFound = false; bool dateTimeMapperFound = false; foreach (FunctionMapper functionMapper in customExpressionManager.FunctionMappers) { if (functionMapper is CommandContextFunctionMapper) { commandContextMapperFound = true; } if (functionMapper is DateTimeFunctionMapper) { dateTimeMapperFound = true; } } Assert.True(commandContextMapperFound && dateTimeMapperFound); }
/// <summary> /// /// </summary> public ProcessEngineWrapper(ProcessInstanceConverter processInstanceConverter, PageableProcessInstanceRepositoryService pageableProcessInstanceService, TaskConverter taskConverter, PageableTaskRepositoryService pageableTaskService, MessageProducerActivitiEventListener listener, SecurityPoliciesApplicationService securityService, AuthenticationWrapper authenticationWrapper, IApplicationEventPublisher eventPublisher, IProcessEngine processEngine, HistoricInstanceConverter historicInstanceConverter, ILoggerFactory loggerFactory) { this.processEngine = processEngine; this.processInstanceConverter = processInstanceConverter; this.runtimeService = processEngine.RuntimeService; this.pageableProcessInstanceService = pageableProcessInstanceService; this.taskService = processEngine.TaskService; this.taskConverter = taskConverter; this.pageableTaskService = pageableTaskService; this.historyService = processEngine.HistoryService; #warning 暂时不处理事件侦听 //this.runtimeService.addEventListener(listener); this.securityService = securityService; this.repositoryService = processEngine.RepositoryService; this.authenticationWrapper = authenticationWrapper; this.eventPublisher = eventPublisher; this.historicInstanceConverter = historicInstanceConverter; logger = loggerFactory.CreateLogger <ProcessEngineWrapper>(); }
public void 创建自启动任务([FromServices] IProcessEngine processEngine) { ProcessEngineConfigurationImpl configuration = processEngine.ProcessEngineConfiguration as ProcessEngineConfigurationImpl; // 时间计算 DateTime now = DateTime.Now; // delay为相较当前时间,延时的时间变量 DateTime target = now.AddMinutes(1); // 时间事件声明 //ITimerJobEntity timer = new TimerJobEntityImpl() //{ // Id = configuration.IdGenerator.NextId, // Duedate = target, // Exclusive = true, // JobHandlerConfiguration = "Process_eJKiMV6cs",// 这里存入需要启动的流程key // JobHandlerType = TimerStartEventJobHandler.TYPE //}; //configuration.CommandContextFactory.createCommandContext() //ITimerJobEntity timer = configuration.TimerJobDataManager.create(); //timer.Id = configuration.IdGenerator.NextId; //timer.Duedate = target; //timer.Exclusive = true; //timer.JobHandlerConfiguration = "Process_eJKiMV6cs";// 这里存入需要启动的流程key //timer.JobHandlerType = TimerStartEventJobHandler.TYPE; //configuration.JobManager.scheduleTimerJob(timer); IJobEntity timer = configuration.CommandExecutor.Execute <IJobEntity>(new CreateTimerStartJobCmd("Process_b55g1NTCp", DateTime.Now.AddMinutes(1), "Task_1gfchcb")); //processEngine.RepositoryService. // 保存作业事件 //Context.CommandContext.JobEntityManager.insert(timer); }
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void startEngines() public virtual void StartEngines() { Engine1 = CreateProcessEngine("engine1"); Engine2 = CreateProcessEngine("engine2"); StartProcessInstanceOnEngineDelegate.Engines["engine1"] = Engine1; StartProcessInstanceOnEngineDelegate.Engines["engine2"] = Engine2; }
public override IProcessEngine buildProcessEngine() { // Disable schema creation/validation by setting it to null. // We'll do it manually, see buildProcessEngine() method (hence why it's copied first) string originalDatabaseSchemaUpdate = this.databaseSchemaUpdate; this.databaseSchemaUpdate = null; // Also, we shouldn't start the async executor until *after* the schema's have been created bool originalIsAutoActivateAsyncExecutor = this.asyncExecutorActivate; this.asyncExecutorActivate = false; IProcessEngine processEngine = base.buildProcessEngine(); // Reset to original values this.databaseSchemaUpdate = originalDatabaseSchemaUpdate; this.asyncExecutorActivate = originalIsAutoActivateAsyncExecutor; // Create tenant schema foreach (string tenantId in tenantInfoHolder.AllTenants) { createTenantSchema(tenantId); } // Start async executor if (asyncExecutor != null && originalIsAutoActivateAsyncExecutor) { asyncExecutor.start(); } booted = true; return(processEngine); }
public void ExecuteProcessElement(Guid procElUId) { UserConnection userConnection = UserConnection; IProcessEngine processEngine = userConnection.ProcessEngine; processEngine.ExecuteProcessElementByUId(procElUId); }
private IProcessEngineInfo InitProcessEngineFromResource() { IProcessEngineInfo processEngineInfo = null; string processEngineName = null; try { log.LogInformation("initializing process engine"); IProcessEngine processEngine = BuildProcessEngine(); processEngineName = processEngine.Name; log.LogInformation($"initialised process engine {processEngineName}"); processEngineInfo = new ProcessEngineInfoImpl(processEngineName, null); processEngines.AddOrUpdate(processEngineName, processEngine, (name, engine) => engine); processEngineInfosByName[processEngineName] = processEngineInfo; } catch (Exception e) { log.LogError(e, $"Exception while initializing process engine: {e.Message}"); processEngineInfo = new ProcessEngineInfoImpl(null, GetExceptionString(e)); throw e; } processEngineInfos.Add(processEngineInfo); return(processEngineInfo); }
public static void AnnotationDeploymentTearDown(IProcessEngine processEngine, string deploymentId, Type testClass, string methodName) { Debug.WriteLine("annotation Deployment deletes deployment for {0}.{1}", ClassNameUtil.GetClassNameWithoutPackage(testClass), methodName); DeleteDeployment(processEngine, deploymentId); }
public virtual IContext Create(IProcessEngine engine) { var context = this.HttpContextAccessor.HttpContext; var db = context.RequestServices.GetService <BpmDbContext>(); return(new Context(engine, new DbSession(db))); }
/// <summary> /// closes all process engines. This method should be called when the server shuts down. /// </summary> public void Destroy() { lock (syncRoot) { if (Initialized) { IDictionary <string, IProcessEngine> engines = new Dictionary <string, IProcessEngine>(processEngines); processEngines = new ConcurrentDictionary <string, IProcessEngine>(); foreach (string processEngineName in engines.Keys) { IProcessEngine processEngine = engines[processEngineName]; try { processEngine.Close(); } catch (Exception e) { log.LogError(e, $"exception while closing {(processEngineName is null ? "the default process engine" : "process engine " + processEngineName)}"); } } processEngineInfosByName.Clear(); processEngineInfosByResourceUrl.Clear(); processEngineInfos.Clear(); Initialized = false; } } }
protected internal void Finished() { DeleteHistoryCleanupJob(); _processEngine.Close(); ProcessEngines.Unregister(_processEngine); _processEngine = null; }
public virtual void shouldInitTaskPermission() { IProcessEngine engine = null; try { // if //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final TestProcessEngineCfg testProcessEngineCfg = new TestProcessEngineCfg(); TestProcessEngineCfg testProcessEngineCfg = new TestProcessEngineCfg(); engine = testProcessEngineCfg.SetProcessEngineName("DefaultTaskPermissionsCfgTest-engine") .SetJdbcUrl(string.Format("jdbc:h2:mem:{0}", "DefaultTaskPermissionsCfgTest-engine-db")) //.SetMetricsEnabled(false) .SetJobExecutorActivate(false).BuildProcessEngine(); // then Assert.True(testProcessEngineCfg.initMethodCalled); } finally { if (engine != null) { engine.Close(); } } }
public override void PostProcessEngineBuild(IProcessEngine processEngine) { foreach (var plugin in plugins) { plugin.PostProcessEngineBuild(processEngine); } }
public static void DeleteDeployment(IProcessEngine processEngine, string deploymentId) { if (!ReferenceEquals(deploymentId, null)) { processEngine.RepositoryService.DeleteDeployment(deploymentId, true); } }
/// <inheritdoc /> protected override bool InternalExecute(ProcessExecutingContext context) { bool isRedo = (Status == ProcessStatus.Error && CurrentActivityId == Guid.Empty && !ProcessUserTaskUtilities.GetIsActivityCreated(UserConnection, UId)); bool isRunning = !CurrentActivityId.Equals(Guid.Empty) && !IsActivityCompleted; if (!isRunning || isRedo) { var editMode = (RecordEditMode)Enum.ToObject(typeof(RecordEditMode), EditMode); bool isActivityEntitySchema = GetIsActivityEntitySchema(); Entity activity = null; IProcessEngine processEngine = UserConnection.ProcessEngine; if (isActivityEntitySchema) { if (editMode == RecordEditMode.New) { activity = CreateActivity(); RecordId = CurrentActivityId; } else { CurrentActivityId = RecordId; } } else { Entity accompaningActivity = CreateAccompaningActivity(); CoreEntitySchema activityEntitySchema = GetActivityEntitySchema(); Guid resultColumnUId = activityEntitySchema.Columns.GetByName("Status").UId; processEngine.AddProcessListener(accompaningActivity, UId, GetConditionData(resultColumnUId, accompaningActivity)); if (editMode == RecordEditMode.New) { RecordId = Guid.NewGuid(); } } string serializedFilters = IsMatchConditions && DataSourceFilters.IsNotNullOrEmpty() ? ConvertToProcessDataSourceFilters(ObjectSchemaId, DataSourceFilters) : null; if (activity == null) { if (editMode != RecordEditMode.New) { processEngine.AddProcessListener(RecordId, ObjectSchemaId, UId, serializedFilters); } else { processEngine.AddProcessListener(RecordId, ObjectSchemaId, UId, null, null, EntityChangeType.Inserted); } } else { processEngine.AddProcessListener(activity, UId, serializedFilters); } } InteractWithUser(context, isRunning, ShowExecutionPage); return(false); }
/// <summary> /// Gets the bytes from a string using the provided process engine's default charset /// </summary> /// <param name="string"> the string to get the bytes form </param> /// <param name="processEngine"> the process engine to use </param> /// <returns> the byte array </returns> public static byte[] ToByteArray(string @string, IProcessEngine processEngine) { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)((ProcessEngineImpl)processEngine).ProcessEngineConfiguration; Encoding charset = processEngineConfiguration.DefaultCharset; return(@string.GetBytes(charset)); }
/// <inheritdoc /> public TaskVariableControllerImpl(ProcessEngineWrapper processEngine, IProcessEngine engine, TaskVariableResourceAssembler variableResourceBuilder) { this.processEngine = processEngine; this.taskService = engine.TaskService; this.variableResourceBuilder = variableResourceBuilder; }
public virtual void tearDown() { if (engine != null) { engine.Close(); engine = null; } }
public void RunDcmProcess(Guid dcmSchemaUId, Guid entityRecordId) { DcmSchemaManager dcmSchemaManager = UserConnection.DcmSchemaManager; DcmSchema dcmSchema = dcmSchemaManager.GetInstanceByUId(dcmSchemaUId); IProcessEngine processEngine = UserConnection.ProcessEngine; processEngine.RunDcmProcess(entityRecordId, dcmSchema); }
/// <summary> /// converts a byte array into a string using the provided process engine's default charset as /// returned by <seealso cref="ProcessEngineConfigurationImpl#getDefaultCharset()"/> /// </summary> /// <param name="bytes"> the byte array </param> /// <param name="processEngine"> the process engine </param> /// <returns> a string representing the bytes </returns> public static string FromBytes(byte[] bytes, IProcessEngine processEngine) { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)((ProcessEngineImpl)processEngine).ProcessEngineConfiguration; Encoding charset = processEngineConfiguration.DefaultCharset; return(ESS.FW.Bpm.Engine.Common.StringHelperClass.NewString(bytes, charset.EncodingName)); }
public WorkflowDebuggerEventListenerProvider(IProcessEngine processEngine, IHubContext <WorkflowDebuggerHub> hubContext) { this.hubContext = hubContext; this.processEngine = processEngine; this.processEngineConfiguration = processEngine.ProcessEngineConfiguration as ProcessEngineConfigurationImpl; }
private static bool HistoryLevelCheck(IProcessEngine processEngine, RequiredHistoryLevelAttribute annotation) { var processEngineConfiguration = (ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration; var requiredHistoryLevel = GetHistoryLevelForName(processEngineConfiguration.HistoryLevels, annotation.value); var currentHistoryLevel = processEngineConfiguration.HistoryLevel; return(currentHistoryLevel.Id >= requiredHistoryLevel.Id); }
public static ExecutionTree ForExecution(string executionId, IProcessEngine processEngine) { ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration; ICommandExecutor commandExecutor = configuration.CommandExecutorTxRequired; ExecutionTree executionTree = commandExecutor.Execute(new CommandAnonymousInnerClass(executionId)); return(executionTree); }
//public virtual string handleAppException(ActivitiForbiddenException ex) //{ // return ex.Message; //} //public virtual string handleAppException(ActivitiObjectNotFoundException ex) //{ // return ex.Message; //} /// <inheritdoc /> public ProcessInstanceVariableControllerImpl(IProcessEngine engine, ProcessInstanceVariableResourceAssembler variableResourceBuilder, SecurityPoliciesApplicationService securityPoliciesApplicationService, ProcessEngineWrapper processEngine) { this.runtimeService = engine.RuntimeService; this.variableResourceBuilder = variableResourceBuilder; this.securityPoliciesApplicationService = securityPoliciesApplicationService; this.processEngine = processEngine; }
protected internal virtual void closeDownProcessEngine() { CloseDownProcessEngine(); if (OtherProcessEngine != null) { OtherProcessEngine.Close(); ProcessEngines.Unregister(OtherProcessEngine); OtherProcessEngine = null; } }
public virtual IContext Create(IProcessEngine engine) { DbContextOptionsBuilder builder = new DbContextOptionsBuilder(); optionsBuilderAction.Invoke(builder); var session = new DbSession(new BpmDbContext(builder.Options)); return(new Context(engine, session)); }
public override void PostProcessEngineBuild(IProcessEngine processEngine) { if (!AuthorizationEnabled) { return; } var authorizationService = processEngine.AuthorizationService; if (!ReferenceEquals(administratorGroupName, null) && (administratorGroupName.Length > 0)) { // create ADMIN authorizations on all built-in resources for configured group //foreach (Resource resource in Resources.values()) //{ // if ( // authorizationService.createAuthorizationQuery() // .groupIdIn(administratorGroupName) // .resourceType(resource) // .resourceId(ANY) // .count() == 0) // { // AuthorizationEntity adminGroupAuth = new AuthorizationEntity(AUTH_TYPE_GRANT); // adminGroupAuth.GroupId = administratorGroupName; // adminGroupAuth.setResource(resource); // adminGroupAuth.ResourceId = ANY; // adminGroupAuth.addPermission(ALL); // authorizationService.saveAuthorization(adminGroupAuth); // LOG.grantGroupPermissions(administratorGroupName, resource.resourceName()); // } //} } if (!ReferenceEquals(administratorUserName, null) && (administratorUserName.Length > 0)) { // create ADMIN authorizations on all built-in resources for configured user //foreach (Resource resource in Resources.values()) //{ // if ( // authorizationService.createAuthorizationQuery() // .userIdIn(administratorUserName) // .resourceType(resource) // .resourceId(ANY) // .count() == 0) // { // AuthorizationEntity adminUserAuth = new AuthorizationEntity(AUTH_TYPE_GRANT); // adminUserAuth.UserId = administratorUserName; // adminUserAuth.setResource(resource); // adminUserAuth.ResourceId = ANY; // adminUserAuth.addPermission(ALL); // authorizationService.saveAuthorization(adminUserAuth); // LOG.grantUserPermissions(administratorUserName, resource.resourceName()); // } //} } }
/// <summary> /// </summary> /// <returns></returns> public static FW.Common.Configurations.Configuration UseBpm( this FW.Common.Configurations.Configuration configuration) { IProcessEngine processEngine = Engine.ProcessEngineConfiguration.CreateStandaloneInMemProcessEngineConfiguration().BuildProcessEngine(); ObjectContainer.Current.RegisterInstance <IProcessEngine, IProcessEngine>(processEngine); ObjectContainer.Current.RegisterGeneric(typeof(IRepository <,>), typeof(AbstractManagerNet <>), LifeStyle.Transient); return(configuration); }