Example #1
0
 internal JumpWorkflowAction(WorkflowItem triggerItem, WorkflowItem jumpToItem)
 {
     _triggerItem     = triggerItem;
     _jumpToItem      = jumpToItem;
     _scheduleAction  = ScheduleWorkflowItemAction.ScheduleByIgnoringWhen(jumpToItem);
     _triggeredAction = Default();
 }
 internal override WorkflowAction TriggeredAction(WorkflowItem item)
 {
     if (item.IsWaitingForAnySignal())
     {
         return(this);
     }
     return(item.SignalResumedAction());
 }
 public override WorkflowAction NextAction(WorkflowItem workflowItem)
 {
     if (_data.NextAction == SignalNextAction.Continue)
     {
         return(WorkflowAction.ContinueWorkflow(workflowItem));
     }
     return(WorkflowAction.Schedule(workflowItem));
 }
Example #4
0
        private void ValidateJump(WorkflowItem jumpedItem)
        {
            var triggeringItemBranches = _triggeringItem.ParentBranches().Concat(_triggeringItem.ChildBranches());

            if (!triggeringItemBranches.Any(b => b.Has(jumpedItem)))
            {
                throw new OutOfBranchJumpException(string.Format(Resources.Invalid_jump, jumpedItem, _triggeringItem));
            }
        }
Example #5
0
        public WorkflowItem FindFirstJointItem(WorkflowItem beforeItem)
        {
            if (Has(beforeItem))
            {
                return(_workflowItems.TakeWhile(i => !i.Equals(beforeItem))
                       .FirstOrDefault(i => i.Parents().Count() > 1));
            }

            return(null);
        }
Example #6
0
        public static TimerItem Reschedule(WorkflowItem ownerItem, ScheduleId scheduleId, IWorkflow workflow)
        {
            var identity  = Identity.New(scheduleId.Name, scheduleId.Version, scheduleId.PositionalName);
            var timerItem = new TimerItem(identity, scheduleId, workflow);

            timerItem._rescheduleTimer = timerItem;
            timerItem.OnStartFailed(e => WorkflowAction.FailWorkflow("RESCHEDULE_TIMER_START_FAILED", e.Cause));
            timerItem.OnCancellationFailed(e => WorkflowAction.FailWorkflow("RESCHEDULE_TIMER_CANCELLATION_FAILED", e.Cause));
            timerItem.OnFired(e => WorkflowAction.Schedule(ownerItem));
            return(timerItem);
        }
Example #7
0
        public static TimerItem Reschedule(WorkflowItem ownerItem, Identity identity, IWorkflow workflow)
        {
            var timerItem = new TimerItem(identity, workflow);

            timerItem._rescheduleTimer = timerItem;
            timerItem.OnStartFailure(e => WorkflowAction.FailWorkflow("RESCHEDULE_TIMER_START_FAILED", e.Cause));
            timerItem.OnCancelled(e => WorkflowAction.CancelWorkflow("RESCHEDULE_TIMER_CANCELLED"));
            timerItem.OnFailedCancellation(e => WorkflowAction.FailWorkflow("RESCHEDULE_TIMER_CANCELLATION_FAILED", e.Cause));
            timerItem.OnFired(e => WorkflowAction.Schedule(ownerItem));
            return(timerItem);
        }
Example #8
0
        public bool AreAllParentBranchesInactive(WorkflowItem exceptBranchOf)
        {
            var parentBranches = ParentBranches().Where(p => !p.Has(exceptBranchOf)).ToArray();

            foreach (var parentBranch in parentBranches)
            {
                if (parentBranch.IsActive(parentBranches))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #9
0
        public static IEnumerable <WorkflowBranch> ParentBranches(WorkflowItem startItem)
        {
            var allBranches = new List <WorkflowBranch>();

            var parentBranch = new WorkflowBranch(startItem);

            if (parentBranch.Parents().Any())
            {
                foreach (var parent in parentBranch.Parents())
                {
                    allBranches.Add(parentBranch.Add(parent));
                }
            }
            else
            {
                allBranches.Add(parentBranch);
            }

            return(allBranches);
        }
Example #10
0
        public static IEnumerable <WorkflowBranch> ChildBranches(WorkflowItem startItem)
        {
            var allBranches = new List <WorkflowBranch>();

            var childBranch = new WorkflowBranch(startItem);

            if (childBranch.Childs().Any())
            {
                foreach (var child in childBranch.Childs())
                {
                    allBranches.Add(childBranch.Add(child));
                }
            }
            else
            {
                allBranches.Add(childBranch);
            }

            return(allBranches);
        }
Example #11
0
 IEnumerable <WorkflowItem> IWorkflow.GetChildernOf(WorkflowItem workflowItem)
 {
     return(_allWorkflowItems.ChilderenOf(workflowItem));
 }
Example #12
0
        internal bool IsExceeded(WorkflowItem workflowItem)
        {
            var allEvents = workflowItem.AllEventsOf(workflowItem.LastEvent.GetType());

            return(allEvents.Count() > _count);
        }
Example #13
0
 internal static JumpWorkflowAction JumpTo(WorkflowItem triggerItem, WorkflowItem jumpItem)
 {
     return(new JumpWorkflowAction(triggerItem, jumpItem));
 }
Example #14
0
 internal static ScheduleWorkflowItemAction Schedule(WorkflowItem workflowItem)
 {
     return(ScheduleWorkflowItemAction.ScheduleByConsideringWhen(workflowItem));
 }
Example #15
0
 internal virtual WorkflowAction WithTriggeredItem(WorkflowItem item) => this;
Example #16
0
 internal virtual WorkflowAction TriggeredAction(WorkflowItem item) => this;
Example #17
0
 internal static WorkflowAction Cancel(WorkflowItem workflowItem)
 {
     return(new WorkflowAction(workflowItem.CancelDecisions()));
 }
Example #18
0
 internal static JumpWorkflowAction JumpTo(WorkflowItem workflowItem)
 {
     return(new JumpWorkflowAction(workflowItem));
 }
Example #19
0
 public ContinueWorkflowAction(WorkflowItem completedWorkflowItem)
 {
     _completedWorkflowItem = completedWorkflowItem;
 }
Example #20
0
 internal JumpWorkflowAction(WorkflowItem jumpToItem)
 {
     _scheduleAction = new ScheduleWorkflowItemAction(jumpToItem);
 }
Example #21
0
 internal override WorkflowAction TriggeredAction(WorkflowItem item)
 {
     return(_left.TriggeredAction(item) + _right.TriggeredAction(item));
 }
Example #22
0
 public void SetJumpedItem(WorkflowItem jumpedItem)
 {
     ValidateJump(jumpedItem);
     _findFirstJointItem = b => b.FindFirstJointItem(jumpedItem);
 }
Example #23
0
 public TriggerWorkflowAction(WorkflowItem triggeringItem)
 {
     _triggeringItem = triggeringItem;
 }
Example #24
0
 internal override WorkflowAction WithTriggeredItem(WorkflowItem item)
 {
     return(_left.WithTriggeredItem(item) + _right.WithTriggeredItem(item));
 }
Example #25
0
 internal static JumpActions FromWorkflowItem(WorkflowItems workflowItems, WorkflowItem workflowItem)
 {
     return(new JumpActions(workflowItems, jumpItem => new TriggerActions(workflowItem).FirstJoint(jumpItem)));
 }
Example #26
0
 internal static IgnoreWorkflowAction Ignore(WorkflowItem triggerItem) => new IgnoreWorkflowAction(triggerItem);
 internal IgnoreWorkflowAction(WorkflowItem triggeringItem)
 {
     _triggeringItem   = triggeringItem;
     _keepBranchActive = triggeringItem != null;
 }
Example #28
0
 internal override WorkflowAction WithTriggeredItem(WorkflowItem item)
 {
     _triggerItem = item;
     _triggeredAction.WithTriggeredItem(_triggerItem);
     return(this);
 }
 internal override bool IsFor(WorkflowItem workflowItem)
 {
     return(workflowItem.Has(_id));
 }
Example #30
0
 internal static WorkflowAction ContinueWorkflow(WorkflowItem workflowItem)
 {
     return(new ContinueWorkflowAction(workflowItem));
 }