public IEnumerable <WorkflowItemEvent> AllTimerEvents(TimerItem timerItem, bool includeRescheduleTimerEvents)
        {
            var allEvents = new List <WorkflowItemEvent>();

            foreach (var historyEvent in AllEventsInDescOrderOfEventId)
            {
                var workflowItemEvent = historyEvent.TimerEvent(_workflowTask.AllEvents);
                if (workflowItemEvent == null)
                {
                    continue;
                }
                if (workflowItemEvent.IsFor(timerItem) && !workflowItemEvent.InChainOf(allEvents))
                {
                    if (IsSignalTimerEvent(workflowItemEvent))
                    {
                        continue;
                    }

                    if (IsRescheduleTimerEvent(workflowItemEvent))
                    {
                        if (includeRescheduleTimerEvents)
                        {
                            allEvents.Add(workflowItemEvent);
                            yield return(workflowItemEvent);
                        }
                        continue;
                    }
                    allEvents.Add(workflowItemEvent);
                    yield return(workflowItemEvent);
                }
            }
        }
Exemple #2
0
        public static TimerItem New(Identity identity, IWorkflow workflow)
        {
            var timerItem = new TimerItem(identity, workflow);

            timerItem._rescheduleTimer = Reschedule(timerItem, identity, workflow);
            timerItem.OnStartFailure(e => e.DefaultAction(workflow));
            timerItem.OnCancelled(e => e.DefaultAction(workflow));
            timerItem.OnFailedCancellation(e => e.DefaultAction(workflow));
            timerItem.OnFired(e => e.DefaultAction(workflow));
            return(timerItem);
        }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
0
        /// <summary>
        /// Schedule the timer.
        /// </summary>
        /// <param name="name">Any user defined name to assign to this timer.</param>
        /// <returns></returns>
        protected IFluentTimerItem ScheduleTimer(string name)
        {
            Ensure.NotNullAndEmpty(name, "name");

            var timerItem = TimerItem.New(Identity.Timer(name), this);

            if (!_allWorkflowItems.Add(timerItem))
            {
                throw new DuplicateItemException(string.Format(Resources.Duplicate_timer, name));
            }

            return(timerItem);
        }
        public WorkflowItemEvent LastTimerEventFor(TimerItem timerItem)
        {
            WorkflowItemEvent result = null;

            if (_cachedTimerEvents.TryGetValue(timerItem, out result))
            {
                return(result);
            }

            result = AllTimerEventsFor(timerItem).FirstOrDefault();
            _cachedTimerEvents.Add(timerItem, result);
            return(result);
        }
Exemple #7
0
 internal ActivityItem(Identity identity, IWorkflow workflow)
     : base(identity, workflow)
 {
     _onCompletionAction         = c => c.DefaultAction(workflow);
     _onFailedAction             = c => c.DefaultAction(workflow);
     _onTimedoutAction           = t => t.DefaultAction(workflow);
     _onCancelledAction          = c => c.DefaultAction(workflow);
     _onCancellationFailedAction = c => c.DefaultAction(workflow);
     _onFailedSchedulingAction   = c => c.DefaultAction(workflow);
     _inputFunc       = a => WorkflowHistoryEvents.WorkflowStartedEvent().Input;
     _taskListFunc    = a => null;
     _whenFunc        = a => true;
     _onFalseAction   = a => new TriggerActions(this).FirstJoint();
     _priorityFunc    = a => null;
     _timeoutsFunc    = a => new ActivityTimeouts();
     _rescheduleTimer = TimerItem.Reschedule(this, identity, workflow);
 }
        public IEnumerable <WorkflowItemEvent> AllTimerEventsFor(TimerItem timerItem)
        {
            var allEvents = new List <WorkflowItemEvent>();

            foreach (var historyEvent in _allHistoryEvents)
            {
                var workflowItemEvent = historyEvent.CreateTimerEventFor(_allHistoryEvents);
                if (workflowItemEvent == null)
                {
                    continue;
                }
                if (workflowItemEvent.IsFor(timerItem) && !workflowItemEvent.InChainOf(allEvents))
                {
                    allEvents.Add(workflowItemEvent);
                    yield return(workflowItemEvent);
                }
            }
        }
 public WorkflowItemEvent LastTimerEvent(TimerItem timerItem, bool includeRescheduleTimerEvents)
 {
     return(AllTimerEvents(timerItem, includeRescheduleTimerEvents).FirstOrDefault(e => !LastEventFilters.Timer.Contains(e)));
 }