protected internal virtual void ValidateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinitionEntity newProcessDefinition) { // check that the new process definition version contains the current activity if (execution.Activity != null) { string activityId = execution.Activity.Id; IPvmActivity newActivity = newProcessDefinition.FindActivity(activityId); if (newActivity == null) { throw new ProcessEngineException("The new process definition " + "(key = '" + newProcessDefinition.Key + "') " + "does not contain the current activity " + "(id = '" + activityId + "') " + "of the process instance " + "(id = '" + _processInstanceId + "')."); } // clear cached activity so that outgoing transitions are refreshed execution.Activity = (newActivity); } // switch the process instance to the new process definition version execution.SetProcessDefinition(newProcessDefinition); // and change possible existing tasks (as the process definition id is stored there too) IList <TaskEntity> tasks = commandContext.TaskManager.FindTasksByExecutionId(execution.Id); foreach (TaskEntity taskEntity in tasks) { taskEntity.ProcessDefinitionId = newProcessDefinition.Id; } }
protected internal virtual void HandleStartEvent(EventSubscriptionEntity eventSubscription, object payload, CommandContext commandContext) { var processDefinitionId = eventSubscription.Configuration; EnsureUtil.EnsureNotNull( "Configuration of signal start event subscription '" + eventSubscription.Id + "' contains no process definition id.", processDefinitionId); DeploymentCache deploymentCache = Context.ProcessEngineConfiguration.DeploymentCache; ProcessDefinitionEntity processDefinition = deploymentCache.FindDeployedProcessDefinitionById(processDefinitionId); if (processDefinition == null || processDefinition.Suspended) { // ignore event subscription Log.DebugIgnoringEventSubscription(eventSubscription, processDefinitionId); } else { ActivityImpl signalStartEvent = (ActivityImpl)processDefinition.FindActivity(eventSubscription.ActivityId); IPvmProcessInstance processInstance = processDefinition.CreateProcessInstanceForInitial(signalStartEvent); processInstance.Start(); } }
[Deployment]//表达式解析相关 public virtual void TestParseNamespaceInConditionExpressionType() { ICommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired; ProcessDefinitionEntity processDefinitionEntity = commandExecutor.Execute <ProcessDefinitionEntity>(new CommandAnonymousInnerClass2(this)); // Test that the process definition has been deployed Assert.NotNull(processDefinitionEntity); IPvmActivity activity = processDefinitionEntity.FindActivity("ExclusiveGateway_1"); Assert.NotNull(activity); // Test that the conditions has been resolved foreach (IPvmTransition transition in activity.OutgoingTransitions) { if (transition.Destination.Id.Equals("Task_2")) { Assert.AreEqual("#{approved}", transition.GetProperty("conditionText")); //Assert.True(transition.GetProperty("conditionText").Equals("#{approved}")); } else if (transition.Destination.Id.Equals("Task_3")) { Assert.True(transition.GetProperty("conditionText").Equals("#{!approved}")); } else { Assert.Fail("Something went wrong"); } } }
protected internal virtual ActivityImpl FindActivityInDeployedProcessDefinition(string activityId) { IProcessDefinition processDefinition = repositoryService.CreateProcessDefinitionQuery().First(); Assert.NotNull(processDefinition); ProcessDefinitionEntity cachedProcessDefinition = processEngineConfiguration.DeploymentCache.ProcessDefinitionCache.Get(processDefinition.Id); return(cachedProcessDefinition.FindActivity(activityId) as ActivityImpl); }
protected internal virtual ActivityImpl FindActivity(IProcessInstance pi, string activityId) { ProcessInstanceWithVariablesImpl entity = (ProcessInstanceWithVariablesImpl)pi; ProcessDefinitionEntity processDefEntity = (entity.ExecutionEntity as ExecutionEntity).ProcessDefinition as ProcessDefinitionEntity; Assert.NotNull(processDefEntity); ActivityImpl activity = processDefEntity.FindActivity(activityId) as ActivityImpl; Assert.NotNull(activity); return(activity); }
protected internal virtual ActivityImpl GetCurrentActivity(CommandContext commandContext, JobEntity job) { var type = job.JobHandlerType; ActivityImpl activity = null; if (SupportedTypes.Contains(type))// SUPPORTED_TYPES.Contains(type)) { DeploymentCache deploymentCache = Context.ProcessEngineConfiguration.DeploymentCache; ProcessDefinitionEntity processDefinitionEntity = deploymentCache.FindDeployedProcessDefinitionById(job.ProcessDefinitionId); activity = (ActivityImpl)processDefinitionEntity.FindActivity(job.ActivityId); } return(activity); }