Esempio n. 1
0
        internal static RestartWorkflowAction RestartWorkflow(IWorkflowHistoryEvents workflowHistoryEvents)
        {
            var workflowStartedEvent  = workflowHistoryEvents.WorkflowStartedEvent();
            var restartWorkflowAction = new RestartWorkflowAction()
            {
                Input    = workflowStartedEvent.Input,
                TaskList = workflowStartedEvent.TaskList,
                ExecutionStartToCloseTimeout = workflowStartedEvent.ExecutionStartToCloseTimeout,
                TaskPriority            = workflowStartedEvent.TaskPriority,
                TaskStartToCloseTimeout = workflowStartedEvent.TaskStartToCloseTimeout,
                ChildPolicy             = workflowStartedEvent.ChildPolicy,
            };

            workflowStartedEvent.TagList.ToList().ForEach(tag => restartWorkflowAction.AddTag(tag));
            return(restartWorkflowAction);
        }
        private WorkflowDecision WaitForSignalTimerDecision(IWorkflowHistoryEvents historyEvents)
        {
            if (_timerWait == null)
            {
                return(WorkflowDecision.Empty);
            }

            var delay = historyEvents.ServerTimeUtc - _waitingEventTimeStamp;

            if (delay > _timerWait.Value)
            {
                return(ScheduleTimerDecision.SignalTimer(_scheduleId, _data.TriggerEventId, TimeSpan.Zero));
            }
            var timeout = _timerWait.Value - delay;

            return(ScheduleTimerDecision.SignalTimer(_scheduleId, _data.TriggerEventId, timeout));
        }
Esempio n. 3
0
        internal IEnumerable <WorkflowDecision> Decisions(IWorkflowHistoryEvents historyEvents)
        {
            _generatedActions = new WorkflowActions();
            _executingEvents  = new Stack <WorkflowEvent>();
            IWorkflow workflow  = this;
            var       decisions = new List <WorkflowDecision>();

            try
            {
                _currentWorkflowHistoryEvents = historyEvents;
                BeforeExecution();
                foreach (var workflowEvent in historyEvents.NewEvents())
                {
                    workflow.PushNewExecutingEvent(workflowEvent);

                    try
                    {
                        var action = workflowEvent.Interpret(this) ?? WorkflowAction.Empty;
                        _generatedActions.Add(action);
                        decisions.AddRange(action.Decisions(this));
                    }
                    finally
                    {
                        workflow.PopExecutingEvent();
                    }
                }

                return(decisions.Distinct().CompatibleDecisions(this).Where(d => d != WorkflowDecision.Empty).ToArray());
            }
            finally
            {
                //Following line may not be required because clean up has handled before it comes here.
                _allWorkflowItems.ResetContinueItems();

                AfterExecution();
                _executingEvents = new Stack <WorkflowEvent>();
                _currentWorkflowHistoryEvents = null;
            }
        }
Esempio n. 4
0
 internal void FinishExecution()
 {
     _currentWorkflowHistoryEvents = null;
 }
Esempio n. 5
0
 internal WorkflowEventsExecution NewExecutionFor(IWorkflowHistoryEvents workflowHistoryEvents)
 {
     _currentWorkflowHistoryEvents = workflowHistoryEvents;
     return(new WorkflowEventsExecution(this, workflowHistoryEvents));
 }
 public WorkflowEventsExecution(Workflow workflow, IWorkflowHistoryEvents workflowHistoryEvents)
 {
     _workflow = workflow;
     _workflowHistoryEvents = workflowHistoryEvents;
 }