public static bool HasTrueCondition(SequenceFlow sequenceFlow, IExecutionEntity execution) { string conditionExpression; if (Context.ProcessEngineConfiguration.EnableProcessDefinitionInfoCache) { JToken elementProperties = Context.GetBpmnOverrideElementProperties(sequenceFlow.Id, execution.ProcessDefinitionId); conditionExpression = GetActiveValue(sequenceFlow.ConditionExpression, DynamicBpmnConstants.SEQUENCE_FLOW_CONDITION, elementProperties); } else { conditionExpression = sequenceFlow.ConditionExpression; } if (!string.IsNullOrWhiteSpace(conditionExpression)) { IExpression expression = Context.ProcessEngineConfiguration.ExpressionManager.CreateExpression(conditionExpression); ICondition condition = new UelExpressionCondition(expression); if (condition.Evaluate(sequenceFlow.Id, execution)) { return(true); } return(false); } else { return(true); } }
public SequenceFlow AddSequenceFlow(string id, string target, string source, string processId) { var process = GetProcess(processId); if (process.SequenceFlows.ContainsKey(id)) { throw new DuplicateIdException($"Process already contains id {id}"); } //Check if the element is not stored in the deletion buffer if (_deletedSequenceFlows.TryGetValue(id, out var sequenceFlow)) { _deletedSequenceFlows.Remove(id); } else { sequenceFlow = new SequenceFlow { Id = id, SourceId = source, TargetId = target }; } process.SequenceFlows.Add(id, sequenceFlow); //Add sequence flow references to the source and target elements UpdateIncomingOfElement(sequenceFlow.TargetId, sequenceFlow.Id, true); UpdateOutgoingOfElement(sequenceFlow.SourceId, sequenceFlow.Id, true); Console.WriteLine($"Number of sequence flows: {process.SequenceFlows.Count()}"); return(sequenceFlow); }
/// <summary> /// gets the initial workflow state /// </summary> /// <param name="workflowData">the bpmn workflow</param> /// <returns></returns> public static ServiceState GetInitialWorkflowState(string workflowData) { Definitions workflowModel = null; XmlSerializer serializer = new XmlSerializer(typeof(Definitions)); using (TextReader tr = new StringReader(workflowData)) { workflowModel = (Definitions)serializer.Deserialize(tr); } string nextStepName = string.Empty; SequenceFlow currentSequenceFlow = workflowModel.Process.SequenceFlow.Find(seq => seq.Id == workflowModel.Process.StartEvent.Outgoing); if (currentSequenceFlow != null) { Task nextStepObj = workflowModel.Process.Task.Find(task => task.Id == currentSequenceFlow.TargetRef); if (nextStepObj != null) { nextStepName = nextStepObj.Name; } } JObject stateJson = JObject.FromObject(new { state = nextStepName, }); return(new ServiceState() { State = string.IsNullOrEmpty(nextStepName) ? WorkflowStep.Unknown : (WorkflowStep)Enum.Parse(typeof(WorkflowStep), nextStepName, true), }); }
protected internal virtual void connectTargetWithSequenceFlow(FlowNode target) { CurrentSequenceFlowBuilder.from(element).to(target); SequenceFlow sequenceFlow = CurrentSequenceFlowBuilder.Element; createEdge(sequenceFlow); currentSequenceFlowBuilder = null; }
public void SimpleProcess() { var startNode = new StartNode("1. Submit claim"); var n2 = new Activity("2. Middle"); var endNode = new EndNode("3. Closed"); var t12 = new SequenceFlow(startNode, n2); var t23 = new SequenceFlow(n2, endNode); this.process = new Process(startNode); }
public ServiceState UpdateCurrentState(string org, string service, string developer, int partyId, Guid instanceId) { string workflowFullFilePath = _settings.GetWorkflowPath(org, service, developer) + _settings.WorkflowFileName; string workflowData = System.IO.File.ReadAllText(workflowFullFilePath, Encoding.UTF8); string serviceStatePath = $"{_settings.GetTestdataForPartyPath(org, service, developer)}{partyId}/{instanceId}/{instanceId}.state.json"; string currentStateAsString = System.IO.File.ReadAllText(serviceStatePath, Encoding.UTF8); ServiceState currentState = JsonConvert.DeserializeObject <ServiceState>(currentStateAsString); Definitions workflowModel = null; XmlSerializer serializer = new XmlSerializer(typeof(Definitions)); using (TextReader tr = new StringReader(workflowData)) { workflowModel = (Definitions)serializer.Deserialize(tr); } string nextStepName = string.Empty; Task currentTask = workflowModel.Process.Task.Find(task => task.Name == currentState.State.ToString()); if (currentTask != null) { SequenceFlow currentSequenceFlow = workflowModel.Process.SequenceFlow.Find(seq => seq.SourceRef == currentTask.Id); if (currentSequenceFlow != null) { Task nextStepObj = workflowModel.Process.Task.Find(task => task.Id == currentSequenceFlow.TargetRef); if (nextStepObj != null) { nextStepName = nextStepObj.Name; } else if (workflowModel.Process.EndEvent.Id == currentSequenceFlow.TargetRef) { nextStepName = WorkflowStep.Archived.ToString(); } } } JObject stateJson = JObject.FromObject(new { state = nextStepName, }); if (string.IsNullOrEmpty(nextStepName)) { _logger.LogError("Unable to read workflowfile, unable to find next step name from current step"); } System.IO.File.WriteAllText(serviceStatePath, stateJson.ToString(), Encoding.UTF8); return(new ServiceState() { State = string.IsNullOrEmpty(nextStepName) ? WorkflowStep.Unknown : (WorkflowStep)Enum.Parse(typeof(WorkflowStep), nextStepName, true), }); }
protected internal override void WriteAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) { SequenceFlow sequenceFlow = (SequenceFlow)element; WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF, sequenceFlow.SourceRef, xtw); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF, sequenceFlow.TargetRef, xtw); if (!string.IsNullOrWhiteSpace(sequenceFlow.SkipExpression)) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_SKIP_EXPRESSION, sequenceFlow.SkipExpression, xtw); } }
public static SequenceFlowModel ToModel(this SequenceFlow sequenceFlow) { return(new SequenceFlowModel { ConditionExpression = sequenceFlow.ConditionExpression, Name = sequenceFlow.Name, SourceRef = sequenceFlow.SourceRef, TargetRef = sequenceFlow.TargetRef, EltId = sequenceFlow.Id }); }
public virtual SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) { SequenceFlow sequenceFlow = createElement(process, from.Id + "-" + to.Id, typeof(SequenceFlow)); process.addChildElement(sequenceFlow); sequenceFlow.Source = from; from.Outgoing.Add(sequenceFlow); sequenceFlow.Target = to; to.Incoming.Add(sequenceFlow); return(sequenceFlow); }
public void AddSourceRef(string sourceRef, SequenceFlow sequenceFlow) { List <SequenceFlow> flows = null; if (!this.sourceRefs.TryGetValue(sourceRef, out flows)) { flows = new List <SequenceFlow>(); this.sourceRefs.Add(sourceRef, flows); } flows.Add(sequenceFlow); }
public void AddTargetRef(string targetRef, SequenceFlow sequenceFlow) { List <SequenceFlow> flows = null; if (!this.targetRefs.TryGetValue(targetRef, out flows)) { flows = new List <SequenceFlow>(); this.targetRefs.Add(targetRef, flows); } flows.Add(sequenceFlow); }
protected internal override void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) { SequenceFlow sequenceFlow = (SequenceFlow)element; if (!string.IsNullOrWhiteSpace(sequenceFlow.ConditionExpression)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_FLOW_CONDITION, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteAttribute(BpmnXMLConstants.XSI_PREFIX, BpmnXMLConstants.XSI_NAMESPACE, "type", "bpmn2:tFormalExpression"); xtw.WriteCharacters(sequenceFlow.ConditionExpression); xtw.WriteEndElement(); } }
public virtual void Complete() { FlowNode node = null; SequenceFlow sequenceFlow = null; foreach (var item in this.sourceRefs) { if (this.flowNodeByIds.TryGetValue(item.Key, out node)) { item.Value.SourceRef = node; } } foreach (var item in this.targetRefs) { if (this.flowNodeByIds.TryGetValue(item.Key, out node)) { item.Value.TargetRef = node; } } foreach (var item in this.activityDefaults) { if (this.sequenceFlowByIds.TryGetValue(item.Key, out sequenceFlow)) { item.Value.Default = sequenceFlow; } } foreach (var item in this.gatewayDefaults) { if (this.sequenceFlowByIds.TryGetValue(item.Key, out sequenceFlow)) { item.Value.Default = sequenceFlow; } } foreach (var item in this.incomings) { if (this.sequenceFlowByIds.TryGetValue(item.Key, out sequenceFlow)) { item.Value.Incomings.Add(sequenceFlow); } } foreach (var item in this.outgings) { if (this.sequenceFlowByIds.TryGetValue(item.Key, out sequenceFlow)) { item.Value.Outgoings.Add(sequenceFlow); } } }
public override Task AppendLoad(XElement item, Process target) { // 还需要为默认连线赋值 var @in = item.Attribute("default"); if (@in != null) { Default = target.Where(a => a.Id == @in.Value).FirstOrDefault() as SequenceFlow; } return(base.AppendLoad(item, target)); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { SequenceFlow sequenceFlow = new SequenceFlow(); BpmnXMLUtil.AddXMLLocation(sequenceFlow, xtr); sequenceFlow.SourceRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF); sequenceFlow.TargetRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF); sequenceFlow.Name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME); sequenceFlow.SkipExpression = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_SKIP_EXPRESSION); ParseChildElements(XMLElementName, sequenceFlow, model, xtr); return(sequenceFlow); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void parseModel() public virtual void parseModel() { modelInstance = Bpmn.readModelFromStream(this.GetType().getResourceAsStream(this.GetType().Name + ".xml")); collaboration = modelInstance.getModelElementById(COLLABORATION_ID); participant = modelInstance.getModelElementById(PARTICIPANT_ID + 1); process = modelInstance.getModelElementById(PROCESS_ID + 1); serviceTask = modelInstance.getModelElementById(SERVICE_TASK_ID); exclusiveGateway = modelInstance.getModelElementById(EXCLUSIVE_GATEWAY); startEvent = modelInstance.getModelElementById(START_EVENT_ID + 2); sequenceFlow = modelInstance.getModelElementById(SEQUENCE_FLOW_ID + 3); messageFlow = modelInstance.getModelElementById(MESSAGE_FLOW_ID); dataInputAssociation = modelInstance.getModelElementById(DATA_INPUT_ASSOCIATION_ID); association = modelInstance.getModelElementById(ASSOCIATION_ID); endEvent = modelInstance.getModelElementById(END_EVENT_ID + 2); }
public ProcessModel AddSequenceFlow( string from, string to, params string[] path) { var result = AddSequenceFlow(SequenceFlow.Create(from, to)); from = to; for (var i = 0; i < path.Length; i++) { result = result.AddSequenceFlow(SequenceFlow.Create(from, path[i])); from = path[i]; } return(result); }
public void ImplicitGatewayProcess() { var startNode = new StartNode("0. Start"); var n1 = new Activity("1. Submit claim"); var n2 = new Activity("2. Child A"); var n3 = new Activity("3. Child B"); var endNode = new EndNode("4. Closed"); var ts1 = new SequenceFlow(startNode, n1); var t12 = new SequenceFlow(n1, n2); var t13 = new SequenceFlow(n1, n3); var t2e = new SequenceFlow(n2, endNode); var t3e = new SequenceFlow(n3, endNode); this.process = new Process(startNode); }
private void LeaveDefault(ExecutionContext executionContext) { var node = executionContext.Node; var outgoings = node.Outgoings; if (outgoings.Count == 0) { executionContext.End(); return; } SequenceFlow transition = null; if (outgoings.Count == 1) { transition = outgoings[0]; } else { var evaluator = executionContext.GetEvaluator(); foreach (var outgoing in outgoings) { var condition = outgoing.ConditionExpression; if (condition == null || string.IsNullOrEmpty(condition.Text) || !evaluator.Evaluate <bool>(condition.Text)) { continue; } transition = outgoing; break; } if (transition == null) { transition = this.GetDefaultOutgoing(executionContext); } } if (transition == null) { throw new RuntimeException("没有满足条件的分支可走"); } executionContext.LeaveNode(transition); }
public ServiceState InitializeServiceState(string org, string service, string developer, int partyId, int formId) { string workflowFullFilePath = _settings.GetWorkflowPath(org, service, developer) + _settings.WorkflowFileName; string workflowData = System.IO.File.ReadAllText(workflowFullFilePath, Encoding.UTF8); Definitions workflowModel = null; XmlSerializer serializer = new XmlSerializer(typeof(Definitions)); using (TextReader tr = new StringReader(workflowData)) { workflowModel = (Definitions)serializer.Deserialize(tr); } string nextStepName = string.Empty; SequenceFlow currentSequenceFlow = workflowModel.Process.SequenceFlow.Find(seq => seq.Id == workflowModel.Process.StartEvent.Outgoing); if (currentSequenceFlow != null) { Task nextStepObj = workflowModel.Process.Task.Find(task => task.Id == currentSequenceFlow.TargetRef); if (nextStepObj != null) { nextStepName = nextStepObj.Name; } } JObject stateJson = JObject.FromObject(new { state = nextStepName, }); if (string.IsNullOrEmpty(nextStepName)) { _logger.LogError("Unable to read workflowfile, unable to find next step name from start event"); } string stateFilePath = $"{_settings.GetTestdataForPartyPath(org, service, developer)}{partyId}/{formId}.state.json"; System.IO.File.WriteAllText(stateFilePath, stateJson.ToString(), Encoding.UTF8); return(new ServiceState() { State = string.IsNullOrEmpty(nextStepName) ? WorkflowStep.Unknown : (WorkflowStep)Enum.Parse(typeof(WorkflowStep), nextStepName, true), }); }
public override string[] EvaulateOutgoingPaths(Definition definition, IsFlowValid isFlowValid, ProcessVariablesContainer variables) { string ret = null; foreach (string str in Outgoing) { if ((Default == null ? "" : Default) != str) { SequenceFlow sf = (SequenceFlow)definition.LocateElement(str); if (sf.IsFlowValid(isFlowValid, variables)) { ret = sf.id; break; } } } return(ret == null ? (this.Default == null ? null : new string[] { Default }) : new string[] { ret }); }
public void SplitGwProcess() { var startNode = new StartNode("1. Submit claim"); var xorGw = new ParallelGateway("X. Split"); var n2 = new Activity("2. Child A"); var n3 = new Activity("3. Child B"); var joinGw = new JoinGateway("X. Join"); var endNode = new EndNode("4. Closed"); var t1gw = new SequenceFlow(startNode, xorGw); var tgw2 = new SequenceFlow(xorGw, n2); var tgw3 = new SequenceFlow(xorGw, n3); var t2End = new SequenceFlow(n2, joinGw); var t3End = new SequenceFlow(n3, joinGw); var tJE = new SequenceFlow(joinGw, endNode); this.process = new Process(startNode); }
public void UpdateSequenceFlowSourceAndTarget(SequenceFlow sequenceFlow, string newSource, string newTarget, string processId) { if (sequenceFlow.SourceId != newSource) { //Remove the reference about the sequence flow in the old source UpdateOutgoingOfElement(sequenceFlow.SourceId, sequenceFlow.Id, false); //Add the reference about the sequence flow to the new source UpdateOutgoingOfElement(newSource, sequenceFlow.Id, true); sequenceFlow.SourceId = newSource; } if (sequenceFlow.TargetId != newTarget) { //Remove the reference about the sequence flow in the old target UpdateIncomingOfElement(sequenceFlow.TargetId, sequenceFlow.Id, false); //Add the reference about the sequence flow to the new target UpdateIncomingOfElement(newTarget, sequenceFlow.Id, true); sequenceFlow.TargetId = newTarget; } }
/// <summary> /// Updates the current state for the workflow /// </summary> /// <param name="workflowData">the workflow for the application</param> /// <param name="currentState">the current workflow state</param> /// <returns>the next state in workflow</returns> public static ServiceState UpdateCurrentState(string workflowData, ServiceState currentState) { Definitions workflowModel = null; XmlSerializer serializer = new XmlSerializer(typeof(Definitions)); using (TextReader tr = new StringReader(workflowData)) { workflowModel = (Definitions)serializer.Deserialize(tr); } string nextStepName = string.Empty; Task currentTask = workflowModel.Process.Task.Find(task => task.Name == currentState.State.ToString()); if (currentTask != null) { SequenceFlow currentSequenceFlow = workflowModel.Process.SequenceFlow.Find(seq => seq.SourceRef == currentTask.Id); if (currentSequenceFlow != null) { Task nextStepObj = workflowModel.Process.Task.Find(task => task.Id == currentSequenceFlow.TargetRef); if (nextStepObj != null) { nextStepName = nextStepObj.Name; } else if (workflowModel.Process.EndEvent.Id == currentSequenceFlow.TargetRef) { nextStepName = WorkflowStep.Archived.ToString(); } } } JObject stateJson = JObject.FromObject(new { state = nextStepName, }); return(new ServiceState() { State = string.IsNullOrEmpty(nextStepName) ? WorkflowStep.Unknown : (WorkflowStep)Enum.Parse(typeof(WorkflowStep), nextStepName, true), }); }
/// <summary> /// Identifies the first task in the process. /// </summary> /// <returns>The first task in the process</returns> public string GetStartElementId() { if (definitions.Process.StartEvents.Count != 1) { throw new ProcessException("The number of start events are different from one. Unable to identify the correct start."); } SequenceFlow currentSequenceFlow = definitions.Process.SequenceFlow.Find(seq => seq.Id == definitions.Process.StartEvents[0].Outgoing); if (currentSequenceFlow != null) { ProcessTask nextStepObj = definitions.Process.Tasks.Find(task => task.Id == currentSequenceFlow.TargetRef); if (nextStepObj != null) { return(nextStepObj.Id); } } return(string.Empty); }
public virtual void ValidateExclusiveGateway(Process process, ExclusiveGateway exclusiveGateway, IList <ValidationError> errors) { if (exclusiveGateway.OutgoingFlows.Count == 0) { AddError(errors, ProblemsConstants.EXCLUSIVE_GATEWAY_NO_OUTGOING_SEQ_FLOW, process, exclusiveGateway, ProcessValidatorResource.EXCLUSIVE_GATEWAY_NO_OUTGOING_SEQ_FLOW); } else if (exclusiveGateway.OutgoingFlows.Count == 1) { SequenceFlow sequenceFlow = exclusiveGateway.OutgoingFlows[0]; if (!string.IsNullOrWhiteSpace(sequenceFlow.ConditionExpression)) { AddError(errors, ProblemsConstants.EXCLUSIVE_GATEWAY_CONDITION_NOT_ALLOWED_ON_SINGLE_SEQ_FLOW, process, exclusiveGateway, ProcessValidatorResource.EXCLUSIVE_GATEWAY_CONDITION_NOT_ALLOWED_ON_SINGLE_SEQ_FLOW); } } else { string defaultSequenceFlow = exclusiveGateway.DefaultFlow; IList <SequenceFlow> flowsWithoutCondition = new List <SequenceFlow>(); foreach (SequenceFlow flow in exclusiveGateway.OutgoingFlows) { string condition = flow.ConditionExpression; bool isDefaultFlow = flow.Id is object && flow.Id.Equals(defaultSequenceFlow); bool hasConditon = !string.IsNullOrWhiteSpace(condition); if (!hasConditon && !isDefaultFlow) { flowsWithoutCondition.Add(flow); } if (hasConditon && isDefaultFlow) { AddError(errors, ProblemsConstants.EXCLUSIVE_GATEWAY_CONDITION_ON_DEFAULT_SEQ_FLOW, process, exclusiveGateway, ProcessValidatorResource.EXCLUSIVE_GATEWAY_CONDITION_ON_DEFAULT_SEQ_FLOW); } } if (flowsWithoutCondition.Count > 0) { AddWarning(errors, ProblemsConstants.EXCLUSIVE_GATEWAY_SEQ_FLOW_WITHOUT_CONDITIONS, process, exclusiveGateway, ProcessValidatorResource.EXCLUSIVE_GATEWAY_SEQ_FLOW_WITHOUT_CONDITIONS); } } }
public override string[] EvaulateOutgoingPaths(Definition definition, IsFlowValid isFlowValid, ProcessVariablesContainer variables) { List <string> ret = new List <string>(); foreach (string str in Outgoing) { SequenceFlow sf = (SequenceFlow)definition.LocateElement(str); if (sf.IsFlowValid(isFlowValid, variables)) { ret.Add(sf.id); } } if (ret.Count == 0) { if (Default != null) { ret.Add(Default); } } return(ret.Count == 0 ? null : ret.ToArray()); }
protected internal virtual EventGateway GetPrecedingEventBasedGateway(IExecutionEntity execution) { FlowElement currentFlowElement = execution.CurrentFlowElement; if (currentFlowElement is IntermediateCatchEvent intermediateCatchEvent) { IList <SequenceFlow> incomingSequenceFlow = intermediateCatchEvent.IncomingFlows; // If behind an event based gateway, there is only one incoming sequence flow that originates from said gateway if (incomingSequenceFlow != null && incomingSequenceFlow.Count == 1) { SequenceFlow sequenceFlow = incomingSequenceFlow[0]; FlowElement sourceFlowElement = sequenceFlow.SourceFlowElement; if (sourceFlowElement is EventGateway) { return((EventGateway)sourceFlowElement); } } } return(null); }
public void SplitConditionalProcess() { var startNode = new StartNode("1. Submit claim"); var xorGw = new SplitConditionalGateway<string>("X. Split", (e => transitionState)); var n2 = new Activity("2. Child A"); var n3 = new Activity("3. Child B"); var n4 = new Activity("4. Child C"); var joinGw = new JoinGateway("X. Join"); var endNode = new EndNode("5. Closed"); var t1gw = new SequenceFlow(startNode, xorGw); var tgw2 = new ConditionalFlow<string>(xorGw, n2, "a"); var tgw3 = new ConditionalFlow<string>(xorGw, n3, "a"); var tgw4 = new ConditionalFlow<string>(xorGw, n4, "b"); var t2Join = new SequenceFlow(n2, joinGw); var t3Join = new SequenceFlow(n3, joinGw); var t4Join = new SequenceFlow(n4, joinGw); var tJE = new SequenceFlow(joinGw, endNode); this.process = new Process(startNode); }
/// <summary> /// /// </summary> /// <param name="sequenceFlow"></param> protected internal virtual void ContinueThroughSequenceFlow(SequenceFlow sequenceFlow) { // Execution listener. Sequenceflow only 'take' makes sense ... but we've supported all three since the beginning if (CollectionUtil.IsNotEmpty(sequenceFlow.ExecutionListeners)) { ExecuteExecutionListeners(sequenceFlow, BaseExecutionListenerFields.EVENTNAME_START); ExecuteExecutionListeners(sequenceFlow, BaseExecutionListenerFields.EVENTNAME_TAKE); ExecuteExecutionListeners(sequenceFlow, BaseExecutionListenerFields.EVENTNAME_END); } // Firing event that transition is being taken ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration; if (processEngineConfiguration != null && processEngineConfiguration.EventDispatcher.Enabled) { FlowElement sourceFlowElement = sequenceFlow.SourceFlowElement; FlowElement targetFlowElement = sequenceFlow.TargetFlowElement; IActivitiSequenceFlowTakenEvent asft = ActivitiEventBuilder.CreateSequenceFlowTakenEvent(execution, ActivitiEventType.SEQUENCEFLOW_TAKEN, sequenceFlow.Id, sourceFlowElement?.Id, sourceFlowElement?.Name, sourceFlowElement?.GetType().FullName, sourceFlowElement == null ? null : ((FlowNode)sourceFlowElement).Behavior, targetFlowElement?.Id, targetFlowElement?.Name, targetFlowElement?.GetType().FullName, targetFlowElement == null ? null : ((FlowNode)targetFlowElement).Behavior); processEngineConfiguration.EventDispatcher.DispatchEvent(asft); } { FlowElement targetFlowElement = sequenceFlow.TargetFlowElement; execution.CurrentFlowElement = targetFlowElement; log.LogDebug($"Sequence flow '{sequenceFlow.Id}' encountered. Continuing process by following it using execution {execution.Id}"); Context.Agenda.PlanContinueProcessOperation(execution); } }
private void CombineLinkedMergeNodes() { List <SequenceFlow> sequenceFlows = trail.GetSequenceFlowsBetweenMergeNodes(); Queue <SequenceFlow> seqQueue = new Queue <SequenceFlow>(); sequenceFlows.ForEach(seqQueue.Enqueue); SequenceFlow curr = null; ExclusiveGateway firstEg = null; ExclusiveGateway secondEg = null; while (seqQueue.Count > 0) { curr = seqQueue.Dequeue(); firstEg = trail.GetExclusiveGateWay(curr.sourceRef); secondEg = trail.GetExclusiveGateWay(curr.targetRef); firstEg.incoming.ForEach(x => { secondEg.incoming.Add(x); trail.ChangeTargetRefOnSequenceFlow(x, secondEg.id); }); firstEg.incoming.RemoveAll(x => true); trail.RemoveEventWithSequences(firstEg.id); } }
internal void ProcessSequenceFlow(SequenceFlow flow) { Log.Debug("Processing Sequence Flow {0} in Process Path", new object[] { flow.id }); _addPathEntry(flow.id, flow.sourceRef, flow.targetRef, StepStatuses.Succeeded, DateTime.Now, DateTime.Now); _Complete(flow.id, flow.targetRef); }
public void XorGwProcess() { var startNode = new StartNode("1. Submit claim"); var xorGw = new ExclusiveGateway<string>("X. Decide", (e => transitionState)); var n2 = new Activity("2. Alternative A"); var n3 = new Activity("3. Alternative B"); var n4 = new Activity("D. Default"); var endNode = new EndNode("4. Closed"); var t1gw = new SequenceFlow(startNode, xorGw); var tgw2 = new ConditionalFlow<string>(xorGw, n2, "a"); var tgw3 = new ConditionalFlow<string>(xorGw, n3, "b"); var tgw4 = new DefaultFlow(xorGw, n4); var t2End = new SequenceFlow(n2, endNode); var t3End = new SequenceFlow(n3, endNode); var t4End = new SequenceFlow(n4, endNode); this.process = new Process(startNode); }
public void TimerEventScenario(int s) { var startNode = new StartNode("1. Submit"); var n2 = new TimerNode("2. Wait 2 seconds", new TimeSpan(0, 0, s)); var endNode = new EndNode("3. Closed"); var t12 = new SequenceFlow(startNode, n2); var t23 = new SequenceFlow(n2, endNode); this.process = new Process(startNode); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateValidBpmnDi() public virtual void shouldCreateValidBpmnDi() { modelInstance = Bpmn.createProcess("process").startEvent("start").sequenceFlowId("flow").endEvent("end").done(); process = modelInstance.getModelElementById("process"); startEvent = modelInstance.getModelElementById("start"); sequenceFlow = modelInstance.getModelElementById("flow"); endEvent = modelInstance.getModelElementById("end"); // create bpmn diagram BpmnDiagram bpmnDiagram = modelInstance.newInstance(typeof(BpmnDiagram)); bpmnDiagram.Id = "diagram"; bpmnDiagram.Name = "diagram"; bpmnDiagram.Documentation = "bpmn diagram element"; bpmnDiagram.Resolution = 120.0; modelInstance.Definitions.addChildElement(bpmnDiagram); // create plane for process BpmnPlane processPlane = modelInstance.newInstance(typeof(BpmnPlane)); processPlane.Id = "plane"; processPlane.BpmnElement = process; bpmnDiagram.BpmnPlane = processPlane; // create shape for start event BpmnShape startEventShape = modelInstance.newInstance(typeof(BpmnShape)); startEventShape.Id = "startShape"; startEventShape.BpmnElement = startEvent; processPlane.DiagramElements.Add(startEventShape); // create bounds for start event shape Bounds startEventBounds = modelInstance.newInstance(typeof(Bounds)); startEventBounds.setHeight(36.0); startEventBounds.setWidth(36.0); startEventBounds.setX(632.0); startEventBounds.setY(312.0); startEventShape.Bounds = startEventBounds; // create shape for end event BpmnShape endEventShape = modelInstance.newInstance(typeof(BpmnShape)); endEventShape.Id = "endShape"; endEventShape.BpmnElement = endEvent; processPlane.DiagramElements.Add(endEventShape); // create bounds for end event shape Bounds endEventBounds = modelInstance.newInstance(typeof(Bounds)); endEventBounds.setHeight(36.0); endEventBounds.setWidth(36.0); endEventBounds.setX(718.0); endEventBounds.setY(312.0); endEventShape.Bounds = endEventBounds; // create edge for sequence flow BpmnEdge flowEdge = modelInstance.newInstance(typeof(BpmnEdge)); flowEdge.Id = "flowEdge"; flowEdge.BpmnElement = sequenceFlow; flowEdge.SourceElement = startEventShape; flowEdge.TargetElement = endEventShape; processPlane.DiagramElements.Add(flowEdge); // create waypoints for sequence flow edge Waypoint startWaypoint = modelInstance.newInstance(typeof(Waypoint)); startWaypoint.X = 668.0; startWaypoint.Y = 330.0; flowEdge.Waypoints.add(startWaypoint); Waypoint endWaypoint = modelInstance.newInstance(typeof(Waypoint)); endWaypoint.X = 718.0; endWaypoint.Y = 330.0; flowEdge.Waypoints.add(endWaypoint); }
// private static Logger log = LoggerFactory.getLogger(typeof(ExclusiveGatewayActivityBehavior)); /// <summary> /// The default behaviour of BPMN, taking every outgoing sequence flow (where the condition evaluates to true), is not valid for an exclusive gateway. /// /// Hence, this behaviour is overridden and replaced by the correct behavior: selecting the first sequence flow which condition evaluates to true (or which hasn't got a condition) and leaving the /// activity through that sequence flow. /// /// If no sequence flow is selected (ie all conditions evaluate to false), then the default sequence flow is taken (if defined). /// </summary> public override void Leave(IExecutionEntity execution) { if (log.IsEnabled(LogLevel.Debug)) { log.LogDebug($"Leaving exclusive gateway '{execution.CurrentActivityId}'"); } ExclusiveGateway exclusiveGateway = (ExclusiveGateway)execution.CurrentFlowElement; ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration; if (processEngineConfiguration is object && processEngineConfiguration.EventDispatcher.Enabled) { processEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateActivityEvent(ActivitiEventType.ACTIVITY_COMPLETED, exclusiveGateway.Id, exclusiveGateway.Name, execution.Id, execution.ProcessInstanceId, execution.ProcessDefinitionId, exclusiveGateway)); } SequenceFlow outgoingSequenceFlow = null; SequenceFlow defaultSequenceFlow = null; string defaultSequenceFlowId = exclusiveGateway.DefaultFlow; // Determine sequence flow to take foreach (SequenceFlow sequenceFlow in exclusiveGateway.OutgoingFlows) { string skipExpressionString = sequenceFlow.SkipExpression; if (!SkipExpressionUtil.IsSkipExpressionEnabled(execution, skipExpressionString)) { bool conditionEvaluatesToTrue = ConditionUtil.HasTrueCondition(sequenceFlow, execution); if (conditionEvaluatesToTrue && (defaultSequenceFlowId is null || !defaultSequenceFlowId.Equals(sequenceFlow.Id))) { if (log.IsEnabled(LogLevel.Debug)) { log.LogDebug($"Sequence flow '{sequenceFlow.Id}'selected as outgoing sequence flow."); } outgoingSequenceFlow = sequenceFlow; break; } } else if (SkipExpressionUtil.ShouldSkipFlowElement(Context.CommandContext, execution, skipExpressionString)) { outgoingSequenceFlow = sequenceFlow; break; } // Already store it, if we would need it later. Saves one for loop. if (defaultSequenceFlowId is object && defaultSequenceFlowId.Equals(sequenceFlow.Id)) { defaultSequenceFlow = sequenceFlow; } } // We have to record the end here, or else we're already past it Context.CommandContext.HistoryManager.RecordActivityEnd(execution, null); // Leave the gateway if (outgoingSequenceFlow != null) { execution.CurrentFlowElement = outgoingSequenceFlow; log.LogInformation($"条件表达式:id={outgoingSequenceFlow.Id} expression={outgoingSequenceFlow.ConditionExpression}"); } else { if (defaultSequenceFlow != null) { execution.CurrentFlowElement = defaultSequenceFlow; log.LogInformation($"条件表达式:id={defaultSequenceFlow.Id} expression={defaultSequenceFlow.ConditionExpression}"); } else { // No sequence flow could be found, not even a default one throw new ActivitiException("No outgoing sequence flow of the exclusive gateway '" + exclusiveGateway.Id + "' could be selected for continuing the process"); } } base.Leave(execution); }