protected internal virtual string ParseActivityType(FlowElement element) { string elementType = element.GetType().Name; elementType = elementType.Substring(0, 1).ToLower() + elementType.Substring(1); return(elementType); }
void AddFlowControls() { foreach (Activity a in mBusinessFlow.Activities) { foreach (Act act in a.Acts) { foreach (FlowControl FC in act.FlowControls) { FlowElement FlowControlFE = new FlowElement(FlowElement.eElementType.FlowControl, act.Description + Environment.NewLine + FC.Condition + "?", 200, 300); //TODO: fix me cause problem when status = 0 !!!!!!!!!!!!!!!! // FlowControlFE.BindStatusLabel(FC, FlowControl.Fields.Status); mFlowDiagram.AddFlowElem(FlowControlFE); // Create Line connector to the activity this FC is in FlowLink FL2 = new FlowLink(GetFlowElemOfActivity(a), FlowControlFE); FL2.LinkStyle = FlowLink.eLinkStyle.Line; FL2.SourcePosition = FlowLink.eFlowElementPosition.Right; FL2.DestinationPosition = FlowLink.eFlowElementPosition.Left; mFlowDiagram.AddConnector(FL2); //TODO: update the FlowControlFE to be on same y of the Activity and x + 150 if (FC.FlowControlAction == eFlowControlAction.GoToActivity) { // Add Link from FC to target Activity if condition met FlowElement TargetActivityFE = (from x in mFlowDiagram.GetAllFlowElem() where x.Object is Activity && ((Activity)x.Object).Guid == FC.GetGuidFromValue() select x).FirstOrDefault(); FlowLink FL3 = new FlowLink(FlowControlFE, TargetActivityFE); FL3.LinkStyle = FlowLink.eLinkStyle.DottedArrow; FL3.SourcePosition = FlowLink.eFlowElementPosition.Top; // TODO: find best connector - if we go up or down FL3.DestinationPosition = FlowLink.eFlowElementPosition.Right; // TODO: find best connector- if we go up or down mFlowDiagram.AddConnector(FL3); } if (FC.FlowControlAction == eFlowControlAction.StopBusinessFlow || FC.FlowControlAction == eFlowControlAction.StopRun) { FlowLink FL3 = new FlowLink(FlowControlFE, EndFlowElement); FL3.LinkStyle = FlowLink.eLinkStyle.DottedArrow; FL3.SourcePosition = FlowLink.eFlowElementPosition.Top; // TODO: find best connector FL3.DestinationPosition = FlowLink.eFlowElementPosition.Right; // TODO: find best connector mFlowDiagram.AddConnector(FL3); } //TODO: handle all other FC actions //if (FC.FlowControlAction == eFlowControlAction.SetVariableValue ) //{ // FlowLink FL3 = new FlowLink(FlowControlFE, EndFlowElement); // FL3.LinkStyle = FlowLink.eLinkStyle.DottedArrow; // FL3.SourcePosition = FlowLink.eFlowElementPosition.Top; // TODO: find best connector // FL3.DestinationPosition = FlowLink.eFlowElementPosition.Right; // TODO: find best connector // mFlowDiagram.AddConnector(FL3); //} } } } }
/// <summary> /// /// </summary> /// <param name="currentFlowElement"></param> protected internal virtual void CleanupExecutions(FlowElement currentFlowElement) { if (!(execution.ParentId is null) && execution.IsScope) { // If the execution is a scope (and not a process instance), the scope must first be // destroyed before we can continue and follow the sequence flow Context.Agenda.PlanDestroyScopeOperation(execution); }
public TransactionDependentExecutionListenerExecutionScope(string processInstanceId, string executionId, FlowElement flowElement, IDictionary <string, object> executionVariables, IDictionary <string, object> customPropertiesMap) { this.processInstanceId = processInstanceId; this.executionId = executionId; this.flowElement = flowElement; this.executionVariables = executionVariables; this.customPropertiesMap = customPropertiesMap; }
public ExportForm(FlowElement flowElement) { InitializeComponent(); this.m_Layer = StorageAccess.ToRuntime((flowElement as AlgorithmFlowElement).Layer); this.m_Bitmap = new Bitmap(1024 + 32, 1024 + 256); this.c_RenderBox.Image = this.m_Bitmap; this.c_Timer.Start(); }
public static IList <FieldExtension> GetFlowElementFields(IExecutionEntity execution) { FlowElement flowElement = GetFlowElement(execution); if (flowElement is TaskWithFieldExtensions) { return(((TaskWithFieldExtensions)flowElement).FieldExtensions); } return(new List <FieldExtension>()); }
// Transaction Dependent execution listener public virtual void Notify(string processInstanceId, string executionId, FlowElement flowElement, IDictionary <string, object> executionVariables, IDictionary <string, object> customPropertiesMap) { if (transactionDependentExecutionListenerInstance == null) { transactionDependentExecutionListenerInstance = TransactionDependentExecutionListenerInstance; } // Note that we can't wrap it in the delegate interceptor like usual here due to being executed when the context is already removed. transactionDependentExecutionListenerInstance.Notify(processInstanceId, executionId, flowElement, executionVariables, customPropertiesMap); }
public AnalyseForm(FlowElement flowElement) { InitializeComponent(); this.m_Layer = StorageAccess.ToRuntime((flowElement as AlgorithmFlowElement).Layer); this.c_AnalysisAddOptionsMenu.Items.AddRange(( from assembly in AppDomain.CurrentDomain.GetAssemblies() from type in assembly.GetTypes() where typeof(AnalysisEngine).IsAssignableFrom(type) && !type.IsGenericType && !type.IsAbstract select new TypeWrapper(type)).ToArray()); }
/// <summary> /// Returns the current <seealso cref="FlowElement"/> where the <seealso cref="IDelegateExecution"/> is currently at. /// </summary> public static FlowElement GetFlowElement(IExecutionEntity execution) { BpmnModel bpmnModel = GetBpmnModel(execution); FlowElement flowElement = bpmnModel.GetFlowElement(execution.CurrentActivityId); if (flowElement == null) { throw new ActivitiException("Could not find a FlowElement for activityId " + execution.CurrentActivityId); } return(flowElement); }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <SequenceFlow> sequenceFlows = process.FindFlowElementsOfType <SequenceFlow>(); foreach (SequenceFlow sequenceFlow in sequenceFlows) { string sourceRef = sequenceFlow.SourceRef; string targetRef = sequenceFlow.TargetRef; if (string.IsNullOrWhiteSpace(sourceRef)) { AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_SRC); } if (string.IsNullOrWhiteSpace(targetRef)) { AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_TARGET); } // Implicit check: sequence flow cannot cross (sub) process // boundaries, hence we check the parent and not the process // (could be subprocess for example) FlowElement source = process.GetFlowElement(sourceRef, true); FlowElement target = process.GetFlowElement(targetRef, true); // Src and target validation if (source == null) { AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_SRC); } if (target == null) { AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_TARGET); } if (source != null && target != null) { IFlowElementsContainer sourceContainer = process.GetFlowElementsContainer(source.Id); IFlowElementsContainer targetContainer = process.GetFlowElementsContainer(target.Id); if (sourceContainer == null) { AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_SRC); } if (targetContainer == null) { AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_TARGET); } if (sourceContainer != null && targetContainer != null && !sourceContainer.Equals(targetContainer)) { AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_TARGET); } } } }
private void CreateBFFlowDiagram() { mFlowDiagram = new FlowDiagramPage(); double x = 50; double y = 50; // Show start elem StartFlowElement = new FlowElement(FlowElement.eElementType.Start, "Start", x, y); x += StartFlowElement.Width + 50; mFlowDiagram.AddFlowElem(StartFlowElement); y += 100; FlowElement LastActivity = StartFlowElement; foreach (Activity activity in mBusinessFlow.Activities) { FlowElement ActivityFE = new FlowElement(FlowElement.eElementType.Activity, activity, nameof(Activity.ActivityName), x, y); y += ActivityFE.Height + 50; //TODO: fixme to see image //ActivityFE.SetImage(activity.Image); ActivityFE.Object = activity; // keep ref to the Activity for later use ActivityFE.BindStatusLabel(activity, nameof(Activity.Status)); mFlowDiagram.AddFlowElem(ActivityFE); //Add connector to last activity FlowLink FL = new FlowLink(LastActivity, ActivityFE); FL.LinkStyle = FlowLink.eLinkStyle.Arrow; FL.SourcePosition = FlowLink.eFlowElementPosition.bottom; FL.DestinationPosition = FlowLink.eFlowElementPosition.Top; mFlowDiagram.AddConnector(FL); LastActivity = ActivityFE; } // Add 'End' Flow elem x += LastActivity.Width + 50; EndFlowElement = new FlowElement(FlowElement.eElementType.End, "End", x, y); mFlowDiagram.AddFlowElem(EndFlowElement); // connect last Activity to 'End' Flow Elem FlowLink FLEnd = new FlowLink(LastActivity, EndFlowElement); FLEnd.LinkStyle = FlowLink.eLinkStyle.Arrow; FLEnd.SourcePosition = FlowLink.eFlowElementPosition.bottom; FLEnd.DestinationPosition = FlowLink.eFlowElementPosition.Top; mFlowDiagram.AddConnector(FLEnd); AddFlowControls(); MainFrame.Content = mFlowDiagram; }
public virtual void ExecuteTaskListeners(ITaskEntity taskEntity, string eventType) { if (taskEntity.ProcessDefinitionId is object) { Process process = ProcessDefinitionUtil.GetProcess(taskEntity.ProcessDefinitionId); FlowElement flowElement = process.GetFlowElement(taskEntity.TaskDefinitionKey, true); if (flowElement is UserTask userTask) { ExecuteTaskListeners(userTask, taskEntity, eventType); } } }
public TraceForm(FlowElement flowElement) { InitializeComponent(); this.m_Layer = StorageAccess.ToRuntime((flowElement as AlgorithmFlowElement).Layer); this.c_FormZoomSize.Items.Add(new ZoomLevel { Level = 1 }); this.c_FormZoomSize.Items.Add(new ZoomLevel { Level = 2 }); this.c_FormZoomSize.SelectedIndex = 0; }
private void c_DeleteSelectedMenuItem_Click(object sender, EventArgs e) { if (this.c_FlowInterfaceControl.SelectedElement == null) { return; } FlowElement fe = this.c_FlowInterfaceControl.SelectedElement; this.c_FlowInterfaceControl.SelectedElement = null; this.c_FlowInterfaceControl.Elements.Remove(fe); this.c_FlowInterfaceControl.Invalidate(); }
private IList <BpmnModel> ParseSubModels(FlowElement subElement, IDictionary <string, GraphicInfo> locations, IDictionary <string, IList <GraphicInfo> > flowLocations, IDictionary <string, GraphicInfo> labelLocations) { IList <BpmnModel> subModels = new List <BpmnModel>(); BpmnModel subModel = new BpmnModel(); // find nested subprocess models ICollection <FlowElement> subFlowElements = ((SubProcess)subElement).FlowElements; // set main process in submodel to subprocess Process newMainProcess = new Process { Id = subElement.Id }; newMainProcess.FlowElements.ToList().AddRange(subFlowElements); newMainProcess.Artifacts.ToList().AddRange(((SubProcess)subElement).Artifacts); subModel.AddProcess(newMainProcess); foreach (FlowElement element in subFlowElements) { string elementId = element.Id; if (element is SubProcess) { ((List <BpmnModel>)subModels).AddRange(ParseSubModels(element, locations, flowLocations, labelLocations)); } if (element is SequenceFlow && null != flowLocations[elementId]) { // must be an edge subModel.FlowLocationMap[elementId] = flowLocations[elementId]; } else { // do not include data objects because they do not have a corresponding shape in the BPMNDI data if (!(element is DataObject) && null != locations[elementId]) { // must be a shape subModel.LocationMap[elementId] = locations[elementId]; } } // also check for any labels if (null != labelLocations[elementId]) { subModel.LabelLocationMap[elementId] = labelLocations[elementId]; } } subModels.Add(subModel); return(subModels); }
protected internal virtual SubProcess GetSubProcessFromExecution(IExecutionEntity execution) { FlowElement flowElement = execution.CurrentFlowElement; SubProcess subProcess; if (flowElement is SubProcess) { subProcess = (SubProcess)flowElement; } else { throw new ActivitiException("Programmatic error: sub process behaviour can only be applied" + " to a SubProcess instance, but got an instance of " + flowElement); } return(subProcess); }
protected internal virtual string GetPrecedingEventBasedGateway(BpmnParse bpmnParse, IntermediateCatchEvent @event) { string eventBasedGatewayId = null; foreach (SequenceFlow sequenceFlow in @event.IncomingFlows) { FlowElement sourceElement = bpmnParse.BpmnModel.GetFlowElement(sequenceFlow.SourceRef); if (sourceElement is EventGateway) { eventBasedGatewayId = sourceElement.Id; break; } } return(eventBasedGatewayId); }
public virtual void Add(FlowElement flowElement) { //flowElement.Container = this.Container; //this.Container.FlowElements.Add(flowElement); if (flowElement is SequenceFlow) { this.sequenceFlowByIds.Add(flowElement.Id, flowElement as SequenceFlow); } else if (flowElement is FlowNode) { this.flowNodeByIds.Add(flowElement.Id, flowElement as FlowNode); } }
public virtual void Execute(IJobEntity job, string configuration, IExecutionEntity execution, ICommandContext commandContext) { IProcessDefinitionEntity processDefinitionEntity = ProcessDefinitionUtil.GetProcessDefinitionFromDatabase(job.ProcessDefinitionId); // From DB -> need to get latest suspended state if (processDefinitionEntity == null) { throw new ActivitiException("Could not find process definition needed for timer start event"); } try { if (!processDefinitionEntity.Suspended) { if (commandContext.EventDispatcher.Enabled) { commandContext.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.TIMER_FIRED, job)); } // Find initial flow element matching the signal start event Process process = ProcessDefinitionUtil.GetProcess(job.ProcessDefinitionId); string activityId = GetActivityIdFromConfiguration(configuration); if (string.IsNullOrWhiteSpace(activityId) == false) { FlowElement flowElement = process.GetFlowElement(activityId, true); if (flowElement == null) { throw new ActivitiException("Could not find matching FlowElement for activityId " + activityId); } ProcessInstanceHelper processInstanceHelper = commandContext.ProcessEngineConfiguration.ProcessInstanceHelper; processInstanceHelper.CreateAndStartProcessInstanceWithInitialFlowElement(processDefinitionEntity, null, null, flowElement, process, null, null, true); } else { (new StartProcessInstanceCmd(processDefinitionEntity.Key, null, null, null, job.TenantId)).Execute(commandContext); } } else { log.LogDebug($"ignoring timer of suspended process definition {processDefinitionEntity.Name}"); } } catch (Exception e) { log.LogError($"exception during timer execution: {e.Message}"); throw new ActivitiException("exception during timer execution: " + e.Message, e); } }
/// <summary> /// Helper method to match the activityId of an execution with a FlowElement of the process definition referenced by the execution. /// </summary> protected internal virtual FlowElement GetCurrentFlowElement(IExecutionEntity execution) { if (execution.CurrentFlowElement != null) { return(execution.CurrentFlowElement); } else if (execution.CurrentActivityId is object) { string processDefinitionId = execution.ProcessDefinitionId; Process process = ProcessDefinitionUtil.GetProcess(processDefinitionId); string activityId = execution.CurrentActivityId; FlowElement currentFlowElement = process.GetFlowElement(activityId, true); return(currentFlowElement); } return(null); }
/// <summary> /// To be used in an <seealso cref="ActivityBehavior"/> or <seealso cref="ICSharpDelegate"/>: leaves /// the current activity via one specific sequenceflow. /// </summary> public static void LeaveDelegate(IExecutionEntity delegateExecution, string sequenceFlowId) { string processDefinitionId = delegateExecution.ProcessDefinitionId; Process process = ProcessDefinitionUtil.GetProcess(processDefinitionId); FlowElement flowElement = process.FindFlowElement(sequenceFlowId); if (flowElement is SequenceFlow) { delegateExecution.CurrentFlowElement = flowElement; Context.Agenda.PlanTakeOutgoingSequenceFlowsOperation(delegateExecution, false); } else { throw new ActivitiException(sequenceFlowId + " does not match a sequence flow"); } }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <EventGateway> eventGateways = process.FindFlowElementsOfType <EventGateway>(); foreach (EventGateway eventGateway in eventGateways) { foreach (SequenceFlow sequenceFlow in eventGateway.OutgoingFlows) { FlowElement flowElement = process.GetFlowElement(sequenceFlow.TargetRef, true); if (flowElement != null && !(flowElement is IntermediateCatchEvent)) { AddError(errors, ProblemsConstants.EVENT_GATEWAY_ONLY_CONNECTED_TO_INTERMEDIATE_EVENTS, process, eventGateway, ProcessValidatorResource.EVENT_GATEWAY_ONLY_CONNECTED_TO_INTERMEDIATE_EVENTS); } } } }
public virtual void Notify(string processInstanceId, string executionId, FlowElement flowElement, IDictionary <string, object> executionVariables, IDictionary <string, object> customPropertiesMap) { throw new System.NotImplementedException(); //NoExecutionVariableScope scope = new NoExecutionVariableScope(); //object @delegate = expression.getValue(scope); //if (@delegate is ITransactionDependentExecutionListener) //{ // ((ITransactionDependentExecutionListener) @delegate).notify(processInstanceId, executionId, flowElement, executionVariables, customPropertiesMap); //} //else //{ // throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + typeof(ITransactionDependentExecutionListener)); //} }
public virtual void HandleEvent(IEventSubscriptionEntity eventSubscription, object payload, ICommandContext commandContext) { string configuration = eventSubscription.Configuration; if (configuration is null) { throw new ActivitiException("Compensating execution not set for compensate event subscription with id " + eventSubscription.Id); } IExecutionEntity compensatingExecution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(configuration); string processDefinitionId = compensatingExecution.ProcessDefinitionId; Process process = ProcessDefinitionUtil.GetProcess(processDefinitionId); if (process == null) { throw new ActivitiException("Cannot start process instance. Process model (id = " + processDefinitionId + ") could not be found"); } FlowElement flowElement = process.GetFlowElement(eventSubscription.ActivityId, true); if (flowElement is SubProcess && !((SubProcess)flowElement).ForCompensation) { // descend into scope: compensatingExecution.IsScope = true; IList <ICompensateEventSubscriptionEntity> eventsForThisScope = commandContext.EventSubscriptionEntityManager.FindCompensateEventSubscriptionsByExecutionId(compensatingExecution.Id); ScopeUtil.ThrowCompensationEvent(eventsForThisScope, compensatingExecution, false); } else { try { if (commandContext.ProcessEngineConfiguration.EventDispatcher.Enabled) { commandContext.ProcessEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateActivityEvent(ActivitiEventType.ACTIVITY_COMPENSATE, flowElement.Id, flowElement.Name, compensatingExecution.Id, compensatingExecution.ProcessInstanceId, compensatingExecution.ProcessDefinitionId, flowElement)); } compensatingExecution.CurrentFlowElement = flowElement; Context.Agenda.PlanContinueProcessInCompensation(compensatingExecution); } catch (Exception e) { throw new ActivitiException("Error while handling compensation event " + eventSubscription, e); } } }
public override void Leave(IExecutionEntity execution, object signalData) { FlowElement currentFlowElement = execution.CurrentFlowElement; ICollection <BoundaryEvent> boundaryEvents = FindBoundaryEventsForFlowNode(execution.ProcessDefinitionId, currentFlowElement); if (CollectionUtil.IsNotEmpty(boundaryEvents)) { ExecuteCompensateBoundaryEvents(boundaryEvents, execution); } if (!HasLoopCharacteristics()) { base.Leave(execution, signalData); } else if (HasMultiInstanceCharacteristics()) { multiInstanceActivityBehavior.Leave(execution, signalData); } }
public override void HandleEvent(IEventSubscriptionEntity eventSubscription, object payload, ICommandContext commandContext) { if (eventSubscription.ExecutionId is object) { base.HandleEvent(eventSubscription, payload, commandContext); } else if (eventSubscription.ProcessDefinitionId is object) { // Find initial flow element matching the signal start event string processDefinitionId = eventSubscription.ProcessDefinitionId; IProcessDefinition processDefinition = ProcessDefinitionUtil.GetProcessDefinition(processDefinitionId); if (processDefinition == null) { throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", typeof(IProcessDefinition)); } if (processDefinition.Suspended) { throw new ActivitiException("Could not handle signal: process definition with id: " + processDefinitionId + " is suspended"); } Process process = ProcessDefinitionUtil.GetProcess(processDefinitionId); FlowElement flowElement = process.GetFlowElement(eventSubscription.ActivityId, true); if (flowElement == null) { throw new ActivitiException("Could not find matching FlowElement for activityId " + eventSubscription.ActivityId); } // Start process instance via that flow element IDictionary <string, object> variables = null; if (payload is System.Collections.IDictionary) { variables = (IDictionary <string, object>)payload; } ProcessInstanceHelper processInstanceHelper = commandContext.ProcessEngineConfiguration.ProcessInstanceHelper; processInstanceHelper.CreateAndStartProcessInstanceWithInitialFlowElement(processDefinition, null, null, flowElement, process, variables, null, true); } else { throw new ActivitiException("Invalid signal handling: no execution nor process definition set"); } }
/// <summary> /// Verifies if the element with the given source identifier can reach the element with the target identifier through following sequence flow. /// </summary> public static bool IsReachable(string processDefinitionId, string sourceElementId, string targetElementId) { // Fetch source and target elements Process process = ProcessDefinitionUtil.GetProcess(processDefinitionId); FlowElement sourceFlowElement = process.GetFlowElement(sourceElementId, true); FlowNode sourceElement = null; if (sourceFlowElement is FlowNode) { sourceElement = (FlowNode)sourceFlowElement; } else if (sourceFlowElement is SequenceFlow) { sourceElement = (FlowNode)((SequenceFlow)sourceFlowElement).TargetFlowElement; } FlowElement targetFlowElement = process.GetFlowElement(targetElementId, true); FlowNode targetElement = null; if (targetFlowElement is FlowNode) { targetElement = (FlowNode)targetFlowElement; } else if (targetFlowElement is SequenceFlow) { targetElement = (FlowNode)((SequenceFlow)targetFlowElement).TargetFlowElement; } if (sourceElement == null) { throw new ActivitiException("Invalid sourceElementId '" + sourceElementId + "': no element found for this id n process definition '" + processDefinitionId + "'"); } if (targetElement == null) { throw new ActivitiException("Invalid targetElementId '" + targetElementId + "': no element found for this id n process definition '" + processDefinitionId + "'"); } ISet <string> visitedElements = new HashSet <string>(); return(IsReachable(process, sourceElement, targetElement, visitedElements)); }
/// <summary> /// /// </summary> protected override void RunOperation() { try { FlowElement currentFlowElement = GetCurrentFlowElement(execution); if (currentFlowElement is FlowNode) { ContinueThroughMultiInstanceFlowNode((FlowNode)currentFlowElement); } else { throw new Exception("Programmatic error: no valid multi instance flow node, type: " + currentFlowElement + ". Halting."); } } catch (Exception ex) { logger.LogError(ex, ex.Message); throw; } }
public virtual IProcessInstance CreateAndStartProcessInstanceByMessage(IProcessDefinition processDefinition, string messageName, IDictionary <string, object> variables, IDictionary <string, object> transientVariables) { _ = Context.CommandContext; // Do not start process a process instance if the process definition is suspended if (ProcessDefinitionUtil.IsProcessDefinitionSuspended(processDefinition.Id)) { throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.Name + " (id = " + processDefinition.Id + ") is suspended"); } // Get model from cache Process process = ProcessDefinitionUtil.GetProcess(processDefinition.Id); if (process == null) { throw new ActivitiException("Cannot start process instance. Process model " + processDefinition.Name + " (id = " + processDefinition.Id + ") could not be found"); } FlowElement initialFlowElement = null; foreach (FlowElement flowElement in process.FlowElements) { if (flowElement is StartEvent startEvent) { if (CollectionUtil.IsNotEmpty(startEvent.EventDefinitions) && startEvent.EventDefinitions[0] is MessageEventDefinition) { MessageEventDefinition messageEventDefinition = (MessageEventDefinition)startEvent.EventDefinitions[0]; if (messageEventDefinition.MessageRef.Equals(messageName)) { initialFlowElement = flowElement; break; } } } } if (initialFlowElement == null) { throw new ActivitiException("No message start event found for process definition " + processDefinition.Id + " and message name " + messageName); } return(CreateAndStartProcessInstanceWithInitialFlowElement(processDefinition, null, null, initialFlowElement, process, variables, transientVariables, true)); }
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 static void SetProcess(FlowElement element, Process newProcess) { DslModeling::DomainRoleInfo.SetLinkedElement(element, FlowElementDomainRoleId, newProcess); }
/// <summary> /// This method deserializes all child model elements. /// </summary> /// <remarks> /// The caller will position the reader at the open tag of the first child XML element to deserialized. /// This method will read as many child elements as it can. It returns under three circumstances: /// 1) When an unknown child XML element is encountered. In this case, this method will position the reader at the /// open tag of the unknown element. This implies the if the first child XML element is unknown, this method /// should return immediately and do nothing. /// 2) When all child XML elemnets are read. In this case, the reader will be positioned at the end tag of the parent element. /// 3) EOF. /// </remarks> /// <param name="serializationContext">Serialization context.</param> /// <param name="reader">XmlReader to read serialized data from.</param> /// <param name="element">In-memory FlowElement instance that will get the deserialized data.</param> private static void ReadChildElements(DslModeling::SerializationContext serializationContext, FlowElement element, global::System.Xml.XmlReader reader) { while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { switch (reader.LocalName) { case "targetFlowElements": // Relationship "FlowElementBlocks" if (reader.IsEmptyElement) { // No instance of this relationship, just skip DslModeling::SerializationUtilities.Skip(reader); } else { DslModeling::SerializationUtilities.SkipToFirstChild(reader); // Skip the open tag of <targetFlowElements> ReadFlowElementBlocksInstances(serializationContext, element, reader); DslModeling::SerializationUtilities.Skip(reader); // Skip the close tag of </targetFlowElements> } break; case "targetContinuationFlowElements": // Relationship "FlowElementContinuations" if (reader.IsEmptyElement) { // No instance of this relationship, just skip DslModeling::SerializationUtilities.Skip(reader); } else { DslModeling::SerializationUtilities.SkipToFirstChild(reader); // Skip the open tag of <targetContinuationFlowElements> ReadFlowElementContinuationsInstances(serializationContext, element, reader); DslModeling::SerializationUtilities.Skip(reader); // Skip the close tag of </targetContinuationFlowElements> } break; default: return; // Don't know this element. } } }
private static void ReadFlowElementContinuationsInstances(DslModeling::SerializationContext serializationContext, FlowElement element, global::System.Xml.XmlReader reader) { while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { DslModeling::DomainClassXmlSerializer newFlowElementMonikerOfFlowElementContinuationsSerializer = serializationContext.Directory.GetSerializer(FlowElement.DomainClassId); global::System.Diagnostics.Debug.Assert(newFlowElementMonikerOfFlowElementContinuationsSerializer != null, "Cannot find serializer for FlowElement!"); DslModeling::Moniker newFlowElementMonikerOfFlowElementContinuations = newFlowElementMonikerOfFlowElementContinuationsSerializer.TryCreateMonikerInstance(serializationContext, reader, element, FlowElementContinuations.DomainClassId, element.Partition); if (newFlowElementMonikerOfFlowElementContinuations != null) { new FlowElementContinuations(element.Partition, new DslModeling::RoleAssignment(FlowElementContinuations.SourceFlowElementDomainRoleId, element), new DslModeling::RoleAssignment(FlowElementContinuations.TargetFlowElementDomainRoleId, newFlowElementMonikerOfFlowElementContinuations)); DslModeling::SerializationUtilities.Skip(reader); // Moniker contains no child XML elements, so just skip. } else { global::System.Type typeofFlowElementContinuations = typeof(FlowElementContinuations); DslModeling::DomainRelationshipXmlSerializer newFlowElementContinuationsSerializer = serializationContext.Directory.GetSerializer(FlowElementContinuations.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer; global::System.Diagnostics.Debug.Assert(newFlowElementContinuationsSerializer != null, "Cannot find serializer for FlowElementContinuations!"); FlowElementContinuations newFlowElementContinuations = newFlowElementContinuationsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as FlowElementContinuations; if (newFlowElementContinuations != null) { if (newFlowElementContinuations.GetType() == typeofFlowElementContinuations) { // The relationship should be serialized in short-form. AsyncDslSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(FlowElementContinuations)); } DslModeling::DomainRoleInfo.SetRolePlayer (newFlowElementContinuations, FlowElementContinuations.SourceFlowElementDomainRoleId, element); DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newFlowElementContinuations.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newFlowElementContinuations.GetDomainClass().Name + "!"); targetSerializer.Read(serializationContext, newFlowElementContinuations, reader); } else { // Unknown element, skip DslModeling::SerializationUtilities.Skip(reader); } } } }
private static void WriteChildElements(DslModeling::SerializationContext serializationContext, FlowElement element, global::System.Xml.XmlWriter writer) { // FlowElementBlocks global::System.Collections.ObjectModel.ReadOnlyCollection<FlowElementBlocks> allFlowElementBlocksInstances = FlowElementBlocks.GetLinksToTargetFlowElements(element); if (!serializationContext.Result.Failed && allFlowElementBlocksInstances.Count > 0) { DslModeling::DomainRelationshipXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(FlowElementBlocks.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer; global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for FlowElementBlocks!"); writer.WriteStartElement("targetFlowElements"); global::System.Type typeofFlowElementBlocks = typeof(FlowElementBlocks); foreach (FlowElementBlocks eachFlowElementBlocksInstance in allFlowElementBlocksInstances) { if (serializationContext.Result.Failed) break; if (eachFlowElementBlocksInstance.GetType() != typeofFlowElementBlocks) { // Derived relationships will be serialized in full-form. DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachFlowElementBlocksInstance.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachFlowElementBlocksInstance.GetDomainClass().Name + "!"); derivedRelSerializer.Write(serializationContext, eachFlowElementBlocksInstance, writer); } else { // No need to serialize the relationship itself, just serialize the role-player directly. DslModeling::ModelElement targetElement = eachFlowElementBlocksInstance.TargetFlowElement; DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer(targetElement.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(targetSerializer != null, "Cannot find serializer for " + targetElement.GetDomainClass().Name + "!"); targetSerializer.WriteMoniker(serializationContext, targetElement, writer, element, relSerializer); } } writer.WriteEndElement(); } // FlowElementContinuations global::System.Collections.ObjectModel.ReadOnlyCollection<FlowElementContinuations> allFlowElementContinuationsInstances = FlowElementContinuations.GetLinksToTargetContinuationFlowElements(element); if (!serializationContext.Result.Failed && allFlowElementContinuationsInstances.Count > 0) { DslModeling::DomainRelationshipXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(FlowElementContinuations.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer; global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for FlowElementContinuations!"); writer.WriteStartElement("targetContinuationFlowElements"); global::System.Type typeofFlowElementContinuations = typeof(FlowElementContinuations); foreach (FlowElementContinuations eachFlowElementContinuationsInstance in allFlowElementContinuationsInstances) { if (serializationContext.Result.Failed) break; if (eachFlowElementContinuationsInstance.GetType() != typeofFlowElementContinuations) { // Derived relationships will be serialized in full-form. DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachFlowElementContinuationsInstance.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachFlowElementContinuationsInstance.GetDomainClass().Name + "!"); derivedRelSerializer.Write(serializationContext, eachFlowElementContinuationsInstance, writer); } else { // No need to serialize the relationship itself, just serialize the role-player directly. DslModeling::ModelElement targetElement = eachFlowElementContinuationsInstance.TargetFlowElement; DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer(targetElement.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(targetSerializer != null, "Cannot find serializer for " + targetElement.GetDomainClass().Name + "!"); targetSerializer.WriteMoniker(serializationContext, targetElement, writer, element, relSerializer); } } writer.WriteEndElement(); } }
public static DslModeling::LinkedElementCollection<FlowElement> GetSourceContinuationFlowElements(FlowElement element) { return GetRoleCollection<DslModeling::LinkedElementCollection<FlowElement>, FlowElement>(element, TargetFlowElementDomainRoleId); }
public static DslModeling::LinkedElementCollection<FlowElement> GetTargetContinuationFlowElements(FlowElement element) { return new DslModeling::LinkedElementCollection<FlowElement>(element, SourceFlowElementDomainRoleId); }
/// <summary> /// Constructor /// Creates a ProcessHasFlowElements link in the same Partition as the given Process /// </summary> /// <param name="source">Process to use as the source of the relationship.</param> /// <param name="target">FlowElement to use as the target of the relationship.</param> public ProcessHasFlowElements(Process source, FlowElement target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ProcessHasFlowElements.ProcessDomainRoleId, source), new DslModeling::RoleAssignment(ProcessHasFlowElements.FlowElementDomainRoleId, target)}, null) { }
/// <summary> /// Constructor /// Creates a FlowElementBlocks link in the same Partition as the given FlowElement /// </summary> /// <param name="source">FlowElement to use as the source of the relationship.</param> /// <param name="target">FlowElement to use as the target of the relationship.</param> public FlowElementBlocks(FlowElement source, FlowElement target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(FlowElementBlocks.SourceFlowElementDomainRoleId, source), new DslModeling::RoleAssignment(FlowElementBlocks.TargetFlowElementDomainRoleId, target)}, null) { }
public static Process GetProcess(FlowElement element) { return DslModeling::DomainRoleInfo.GetLinkedElement(element, FlowElementDomainRoleId) as Process; }