Example #1
0
        public override IEnumerable <WorkflowItemEvent> AllEvents(bool includeRescheduleTimerEvents = false)
        {
            var childWorkflowItems = WorkflowHistoryEvents.AllChildWorkflowEvents(this);
            var timerEvents        = Enumerable.Empty <WorkflowItemEvent>();

            if (includeRescheduleTimerEvents)
            {
                timerEvents = WorkflowHistoryEvents.AllTimerEvents(RescheduleTimer, true);
            }
            return(childWorkflowItems.Concat(timerEvents).OrderByDescending(i => i, WorkflowEvent.IdComparer));
        }
Example #2
0
        private async Task ExecuteTasks(WorkflowHost workflowHost, CancellationToken cancellationToken)
        {
            var workflowType  = _decisionTask.WorkflowType;
            var workflow      = workflowHost.Workflow(workflowType.Name, workflowType.Version);
            var historyEvents = new WorkflowHistoryEvents(this);

            var decisions = Perform(() => workflow.Decisions(historyEvents));
            await workflowHost.SendDecisionsAsync(_decisionTask.TaskToken, decisions);

            RaisePostExecutionEvents(decisions, workflow);
        }
Example #3
0
 private void InitializeDefault(IWorkflow workflow)
 {
     _input                  = (item) => WorkflowHistoryEvents.WorkflowStartedEvent().Input;
     _timeout                = item => null;
     _completedAction        = e => e.DefaultAction(workflow);
     _failedAction           = e => e.DefaultAction(workflow);
     _timedoutAction         = e => e.DefaultAction(workflow);
     _schedulingFailedAction = e => e.DefaultAction(workflow);
     _startFailedAction      = e => e.DefaultAction(workflow);
     _onFalseTrigger         = _ => IsStartupItem() ? WorkflowAction.Empty : new TriggerActions(this).FirstJoint();
 }
Example #4
0
        public override IEnumerable <WorkflowDecision> CancelDecisions()
        {
            var lastEvent        = LastEvent(true);
            var latestTimerEvent = WorkflowHistoryEvents.LastTimerEvent(RescheduleTimer, true);

            if (latestTimerEvent != null && lastEvent == latestTimerEvent)
            {
                return(RescheduleTimer.CancelDecisions());
            }

            return(new[] { new CancelRequestWorkflowDecision(ScheduleId, (lastEvent as ChildWorkflowEvent)?.RunId), });
        }
Example #5
0
        public override WorkflowDecision GetCancelDecision()
        {
            var lastEvent        = LastEvent;
            var latestTimerEvent = WorkflowHistoryEvents.LastTimerEventFor(_rescheduleTimer);

            if (latestTimerEvent != null && lastEvent == latestTimerEvent)
            {
                return(_rescheduleTimer.GetCancelDecision());
            }

            return(new CancelActivityDecision(Identity));
        }
Example #6
0
        public override IEnumerable <WorkflowDecision> CancelDecisions()
        {
            var lastEvent        = LastEvent(true);
            var latestTimerEvent = WorkflowHistoryEvents.LastTimerEvent(RescheduleTimer, true);

            if (latestTimerEvent != null && lastEvent == latestTimerEvent)
            {
                return(RescheduleTimer.CancelDecisions());
            }

            return(new [] { new CancelActivityDecision(ScheduleId) });
        }
Example #7
0
        private async Task ExecuteTasks(WorkflowHost workflowHost, CancellationToken cancellationToken)
        {
            var workflowType  = _decisionTask.WorkflowType;
            var workflow      = workflowHost.FindBy(workflowType.Name, workflowType.Version);
            var historyEvents = new WorkflowHistoryEvents(_decisionTask.Events,
                                                          _decisionTask.PreviousStartedEventId + 1, _decisionTask.StartedEventId);

            using (var execution = workflow.NewExecutionFor(historyEvents))
            {
                var decisions = Perform(execution);
                await workflowHost.SendDecisionsAsync(_decisionTask.TaskToken, decisions);

                RaisePostExecutionEvents(decisions, workflow);
            }
        }
Example #8
0
        public override WorkflowItemEvent LastEvent(bool includeRescheduleTimerEvents = false)
        {
            var lastEvent = WorkflowHistoryEvents.LastChildWorkflowEvent(this);
            WorkflowItemEvent timerEvent = null;

            if (includeRescheduleTimerEvents)
            {
                timerEvent = WorkflowHistoryEvents.LastTimerEvent(RescheduleTimer, true);
            }

            if (lastEvent > timerEvent)
            {
                return(lastEvent);
            }
            return(timerEvent);
        }
Example #9
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 = _ => IsStartupItem() ? WorkflowAction.Empty : new TriggerActions(this).FirstJoint();
     _priorityFunc  = a => null;
     _timeoutsFunc  = a => new ActivityTimeouts();
 }
Example #10
0
        public override WorkflowItemEvent LastEvent(bool includeRescheduleTimerEvents = false)
        {
            var latestActivityEvent            = WorkflowHistoryEvents.LastActivityEvent(this);
            WorkflowItemEvent latestTimerEvent = null;

            if (includeRescheduleTimerEvents)
            {
                latestTimerEvent = WorkflowHistoryEvents.LastTimerEvent(RescheduleTimer, true);
            }

            if (latestActivityEvent > latestTimerEvent)
            {
                return(latestActivityEvent);
            }

            return(latestTimerEvent);
        }
Example #11
0
 public override IEnumerable <WorkflowItemEvent> AllEvents(bool includeRescheduleTimerEvents = false)
 => WorkflowHistoryEvents.AllTimerEvents(this, includeRescheduleTimerEvents);
Example #12
0
 public override WorkflowItemEvent LastEvent(bool includeRescheduleTimerEvents = false)
 => WorkflowHistoryEvents.LastTimerEvent(this, includeRescheduleTimerEvents);