示例#1
0
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            EventGateway gateway = new EventGateway();

            BpmnXMLUtil.AddXMLLocation(gateway, xtr);
            ParseChildElements(XMLElementName, gateway, model, xtr);
            return(gateway);
        }
        static void Main(string[] args)
        {
            //create the gateway
            EventGateway gateway = new EventGateway();

            //listen on .net events using the gateway
            gateway.OnEvent += new EventGateway.DotNetEventHandler(gateway_OnEvent);
        }
示例#3
0
        public override BaseElement Clone()
        {
            EventGateway clone = new EventGateway
            {
                Values = this
            };

            return(clone);
        }
        /// <summary>
        /// Specific leave method for intermediate events: does a normal leave(), except
        /// when behind an event based gateway. In that case, the other events are cancelled
        /// (we're only supporting the exclusive event based gateway type currently).
        /// and the process instance is continued through the triggered event.
        /// </summary>
        public virtual void LeaveIntermediateCatchEvent(IExecutionEntity execution)
        {
            EventGateway eventGateway = GetPrecedingEventBasedGateway(execution);

            if (eventGateway != null)
            {
                DeleteOtherEventsRelatedToEventBasedGateway(execution, eventGateway);
            }

            Leave(execution); // Normal leave
        }
示例#5
0
 public EventController(EventGateway eventGateway)
 {
     _eventGateway = eventGateway;
 }
 public virtual EventBasedGatewayActivityBehavior CreateEventBasedGatewayActivityBehavior(EventGateway eventGateway)
 {
     return(new EventBasedGatewayActivityBehavior());
 }
        protected internal virtual void DeleteOtherEventsRelatedToEventBasedGateway(IExecutionEntity execution, EventGateway eventGateway)
        {
            // To clean up the other events behind the event based gateway, we must gather the
            // activity ids of said events and check the _sibling_ executions of the incoming execution.
            // Note that it can happen that there are multiple such execution in those activity ids,
            // (for example a parallel gw going twice to the event based gateway, kinda silly, but valid)
            // so we only take _one_ result of such a query for deletion.

            // Gather all activity ids for the events after the event based gateway that need to be destroyed
            IList <SequenceFlow> outgoingSequenceFlows = eventGateway.OutgoingFlows;
            ISet <string>        eventActivityIds      = new HashSet <string>();//outgoingSequenceFlows.Count - 1); // -1, the event being triggered does not need to be deleted

            foreach (SequenceFlow outgoingSequenceFlow in outgoingSequenceFlows)
            {
                if (outgoingSequenceFlow.TargetFlowElement != null && !outgoingSequenceFlow.TargetFlowElement.Id.Equals(execution.CurrentActivityId))
                {
                    eventActivityIds.Add(outgoingSequenceFlow.TargetFlowElement.Id);
                }
            }

            ICommandContext         commandContext         = Context.CommandContext;
            IExecutionEntityManager executionEntityManager = commandContext.ExecutionEntityManager;

            // Find the executions
            IList <IExecutionEntity> executionEntities = executionEntityManager.FindExecutionsByParentExecutionAndActivityIds(execution.ParentId, eventActivityIds);

            // Execute the cancel behaviour of the IntermediateCatchEvent
            foreach (IExecutionEntity executionEntity in executionEntities)
            {
                if (eventActivityIds.Contains(executionEntity.ActivityId) && execution.CurrentFlowElement is IntermediateCatchEvent)
                {
                    IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent)execution.CurrentFlowElement;
                    if (intermediateCatchEvent.Behavior is IntermediateCatchEventActivityBehavior)
                    {
                        ((IntermediateCatchEventActivityBehavior)intermediateCatchEvent.Behavior).EventCancelledByEventGateway(executionEntity);
                        eventActivityIds.Remove(executionEntity.ActivityId); // We only need to delete ONE execution at the event.
                    }
                }
            }
        }