Ejemplo n.º 1
0
        public WorkflowAction Resume(WorkflowSignaledEvent signal)
        {
            Ensure.NotNull(signal, nameof(signal));
            var waitEvent = WaitForSignalsEvent(signal.SignalName);

            if (waitEvent == null)
            {
                throw new SignalResumeException($"Workflow item {Identity} is not waiting for signal {signal.SignalName}");
            }
            WorkflowDecision decision = null;

            if (waitEvent.HasTimedout(signal))
            {
                decision = waitEvent.RecordTimedout(signal);
            }
            else
            {
                decision = waitEvent.RecordSignal(signal);
            }

            var recordedAction = WorkflowAction.Custom(decision);

            if (waitEvent.IsExpectingSignals)
            {
                return(recordedAction);
            }

            return(waitEvent.NextAction(this) + recordedAction);
        }
Ejemplo n.º 2
0
        private WorkflowAction ResetAction(TimeSpan?timeout = null)
        {
            if (!IsActive)
            {
                throw new InvalidOperationException(
                          $"Can not reset the timer {this}. It should be already active for it be reset.");
            }
            var lastTimerEvent = (TimerEvent)LastEvent(true);
            var rescheduleId   = RescheduleId(lastTimerEvent.Id);

            return(WorkflowAction.Custom(new CancelTimerDecision(lastTimerEvent.Id),
                                         ScheduleTimerDecision.WorkflowItem(rescheduleId, timeout ?? lastTimerEvent.Timeout)));
        }
Ejemplo n.º 3
0
        public virtual WorkflowAction Fired(TimerFiredEvent timerFiredEvent)
        {
            if (timerFiredEvent.TimerType == TimerType.Reschedule)
            {
                ITimer timer = RescheduleTimer;
                return(timer.Fired(timerFiredEvent));
            }
            if (timerFiredEvent.TimerType == TimerType.SignalTimer)
            {
                var waitForSignalEvent = WaitForSignalsEvent(timerFiredEvent.SignalTriggerEventId);
                if (!waitForSignalEvent.IsExpectingSignals)
                {
                    return(WorkflowAction.Empty);
                }

                var signalTimedoutDecision = waitForSignalEvent.RecordTimedout(timerFiredEvent);
                return(WorkflowAction.Custom(signalTimedoutDecision) + WorkflowAction.ContinueWorkflow(this));
            }
            throw new InvalidOperationException("Timer fired should be called only for Reschedule and SignalTimer.");
        }