Esempio n. 1
0
 private ScheduleTimerDecision(ScheduleId id, TimeSpan timeout, TimerType timerType, long triggerEventId = 0) : base(false)
 {
     _id             = id;
     _timeout        = timeout;
     _timerType      = timerType;
     _triggerEventId = triggerEventId;
 }
Esempio n. 2
0
        /// <summary>
        /// Internal method. Library user should not care about it.
        /// </summary>
        /// <param name="runid"></param>
        /// <param name="initiatedEventId"></param>
        /// <param name="allEvents"></param>
        protected void PopulateProperties(string runid, long initiatedEventId, IEnumerable <HistoryEvent> allEvents)
        {
            RunId             = runid;
            _initiatedEventId = initiatedEventId;
            bool foundEvent = false;

            foreach (var historyEvent in allEvents)
            {
                if (historyEvent.IsChildWorkflowInitiatedEvent(initiatedEventId))
                {
                    var attr = historyEvent.StartChildWorkflowExecutionInitiatedEventAttributes;
                    Input           = attr.Input;
                    WorkflowId      = attr.WorkflowId;
                    ScheduleId      = ScheduleId.Raw(attr.WorkflowId);
                    WorkflowName    = attr.WorkflowType.Name;
                    WorkflowVersion = attr.WorkflowType.Version;
                    PositionalName  = attr.Control.As <ScheduleData>().PN;
                    foundEvent      = true;
                    break;
                }
            }

            if (!foundEvent)
            {
                throw new IncompleteEventGraphException($"Can not find Child Workflow InitiatedEvent for id {initiatedEventId}");
            }
        }
Esempio n. 3
0
 public WorkflowItemSignalledDecision(ScheduleId id, long triggerEventId, string signalName, long signalEventId = 0) : base(false)
 {
     _id             = id;
     _triggerEventId = triggerEventId;
     _signalName     = signalName;
     _signalEventId  = signalEventId;
 }
        public WorkflowItemSignalTimedoutEvent(HistoryEvent historyEvent) : base(historyEvent)
        {
            var attr = historyEvent.MarkerRecordedEventAttributes;

            _details   = attr.Details.As <SignalsTimedoutDetails>();
            ScheduleId = ScheduleId.Raw(_details.ScheduleId);
        }
Esempio n. 5
0
        /// <summary>
        /// For internal use only.
        /// </summary>
        /// <param name="allHistoryEvents"></param>
        /// <param name="startedEventId"></param>
        /// <param name="scheduledEventId"></param>
        protected void PopulateAttributes(IEnumerable <HistoryEvent> allHistoryEvents, long startedEventId, long scheduledEventId)
        {
            bool foundActivityScheduledEvent = false;

            _startedEventId   = startedEventId;
            _scheduledEventId = scheduledEventId;
            foreach (var historyEvent in allHistoryEvents)
            {
                if (historyEvent.IsActivityStartedEvent(startedEventId))
                {
                    WorkerIdentity = historyEvent.ActivityTaskStartedEventAttributes.Identity;
                }
                else if (historyEvent.IsActivityScheduledEvent(scheduledEventId))
                {
                    var attr = historyEvent.ActivityTaskScheduledEventAttributes;
                    _activityName           = attr.ActivityType.Name;
                    _activityVersion        = attr.ActivityType.Version;
                    _activityPositionalName = attr.Control.As <ScheduleData>().PN;
                    ScheduleId = ScheduleId.Raw(attr.ActivityId);
                    Input      = attr.Input;
                    foundActivityScheduledEvent = true;
                }
            }
            if (!foundActivityScheduledEvent)
            {
                throw new IncompleteEventGraphException(string.Format("Can not found activity scheduled event id {0}.", scheduledEventId));
            }
        }
        internal ExternalWorkflowCancellationRequestedEvent(HistoryEvent cancelRequested)
            : base(cancelRequested)
        {
            var attr = cancelRequested.ExternalWorkflowExecutionCancelRequestedEventAttributes;

            ScheduleId = ScheduleId.Raw(attr.WorkflowExecution.WorkflowId);
        }
Esempio n. 7
0
        internal LambdaSchedulingFailedEvent(HistoryEvent failedEvent)
            : base(failedEvent)
        {
            var attr = failedEvent.ScheduleLambdaFunctionFailedEventAttributes;

            ScheduleId = ScheduleId.Raw(attr.Id);
            Cause      = attr.Cause?.Value;
        }
Esempio n. 8
0
 public WorkflowItemSignalsTimedoutDecision(ScheduleId scheduleId, long signalTriggerEventId, string[] timedoutSignals, long timeoutTriggerId)
     : base(false, false)
 {
     _scheduleId           = scheduleId;
     _signalTriggerEventId = signalTriggerEventId;
     _timedoutSignals      = timedoutSignals;
     _timeoutTriggerId     = timeoutTriggerId;
 }
Esempio n. 9
0
 public WaitForSignalsEvent(HistoryEvent @event, IEnumerable <HistoryEvent> allEvents)
     : base(@event)
 {
     _data        = @event.MarkerRecordedEventAttributes.Details.As <WaitForSignalData>();
     ScheduleId   = ScheduleId.Raw(_data.ScheduleId);
     _signalState = new WaitingForSignalState(this);
     PopulateResumedSignals(allEvents);
 }
Esempio n. 10
0
        private bool _invokedTimerCancelAction = false;// to avoid recursion.

        private TimerItem(Identity identity, ScheduleId defaultScheduleId, IWorkflow workflow)
            : base(identity, workflow)
        {
            _defaultScheduleId = defaultScheduleId;
            _canSchedule       = t => true;
            _falseAction       = _ => IsStartupItem() ? WorkflowAction.Empty : new TriggerActions(this).FirstJoint();
            _timerCancelAction = _ => WorkflowAction.Empty;
            _fireAfterFunc     = _ => _fireAfter;
        }
Esempio n. 11
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);
        }
 internal WorkflowItemWaitAction(WorkflowItemEvent itemEvent, SignalWaitType waitType, params string[] signalNames)
 {
     _scheduleId            = itemEvent.ScheduleId;
     _waitingEventTimeStamp = itemEvent.Timestamp;
     _data = new WaitForSignalData
     {
         ScheduleId                 = itemEvent.ScheduleId,
         TriggerEventId             = itemEvent.EventId,
         WaitType                   = waitType,
         SignalNames                = signalNames,
         NextAction                 = SignalNextAction.Continue,
         TriggerEventCompletionDate = itemEvent.Timestamp
     };
 }
Esempio n. 13
0
 protected void PopulateProperties(long scheduledEventId, IEnumerable <HistoryEvent> eventGraph)
 {
     _scheduledEventId = scheduledEventId;
     foreach (var historyEvent in eventGraph)
     {
         if (historyEvent.IsLambdaScheduledEvent(scheduledEventId))
         {
             var attr = historyEvent.LambdaFunctionScheduledEventAttributes;
             Input           = attr.Input;
             _name           = attr.Name;
             _positionalName = attr.Control.As <ScheduleData>().PN;
             ScheduleId      = ScheduleId.Raw(historyEvent.LambdaFunctionScheduledEventAttributes.Id);
             if (!string.IsNullOrEmpty(attr.StartToCloseTimeout))
             {
                 Timeout = TimeSpan.FromSeconds(Double.Parse(attr.StartToCloseTimeout));
             }
             break;
         }
     }
     if (ScheduleId == null)
     {
         throw new IncompleteEventGraphException($"Can not find lambda scheduled event for id {scheduledEventId}.");
     }
 }
Esempio n. 14
0
        protected void PopulateProperties(long timerStartedEventId, IEnumerable <HistoryEvent> allHistoryEvents)
        {
            bool foundTimerStartedEvent = false;

            _timerStartedEventId = timerStartedEventId;
            foreach (var historyEvent in allHistoryEvents)
            {
                if (historyEvent.IsTimerStartedEvent(timerStartedEventId))
                {
                    _timeout   = TimeSpan.FromSeconds(int.Parse(historyEvent.TimerStartedEventAttributes.StartToFireTimeout));
                    ScheduleId = ScheduleId.Raw(historyEvent.TimerStartedEventAttributes.TimerId);
                    var timerScheduleData = historyEvent.TimerStartedEventAttributes.Control.As <TimerScheduleData>();
                    TimerType              = timerScheduleData.TimerType;
                    _timerName             = timerScheduleData.TimerName;
                    SignalTriggerEventId   = timerScheduleData.SignalTriggerEventId;
                    foundTimerStartedEvent = true;
                    break;
                }
            }
            if (!foundTimerStartedEvent)
            {
                throw new IncompleteEventGraphException(string.Format("Can not find the timer started event id {0}", timerStartedEventId));
            }
        }
Esempio n. 15
0
 internal TimerCancellationFailedEvent(HistoryEvent timerCancellationFailedEvent)
     : base(timerCancellationFailedEvent)
 {
     _eventAttributes = timerCancellationFailedEvent.CancelTimerFailedEventAttributes;
     ScheduleId       = ScheduleId.Raw(_eventAttributes.TimerId);
 }
Esempio n. 16
0
 public WaitForSignalsDecision(WaitForSignalData data) : base(false)
 {
     _data = data;
     _id   = ScheduleId.Raw(data.ScheduleId);
 }
Esempio n. 17
0
 internal ActivityCancellationFailedEvent(HistoryEvent activityCancellationFailedEvent)
     : base(activityCancellationFailedEvent)
 {
     _eventAttributes = activityCancellationFailedEvent.RequestCancelActivityTaskFailedEventAttributes;
     ScheduleId       = ScheduleId.Raw(_eventAttributes.ActivityId);
 }
Esempio n. 18
0
 public static ScheduleTimerDecision SignalTimer(ScheduleId scheduleId, long triggerEventId, TimeSpan timeout)
 => new ScheduleTimerDecision(scheduleId, timeout, TimerType.SignalTimer, triggerEventId);
Esempio n. 19
0
 public WorkflowItemSignalledEvent(HistoryEvent @event)
     : base(@event)
 {
     _data      = @event.MarkerRecordedEventAttributes.Details.As <WorkflowItemSignalledData>();
     ScheduleId = ScheduleId.Raw(_data.ScheduleId);
 }
 internal ScheduleLambdaDecision(ScheduleId id, object input, TimeSpan?timeout = null) : base(canCloseWorkflow: false, proposal: false)
 {
     _id      = id;
     _input   = input;
     _timeout = timeout;
 }
Esempio n. 21
0
 internal TimerStartFailedEvent(HistoryEvent startTimerFailedEvent)
     : base(startTimerFailedEvent)
 {
     _startTimerFailedAttributes = startTimerFailedEvent.StartTimerFailedEventAttributes;
     ScheduleId = ScheduleId.Raw(_startTimerFailedAttributes.TimerId);
 }
 internal ActivitySchedulingFailedEvent(HistoryEvent schedulingFailedEvent)
     : base(schedulingFailedEvent)
 {
     _eventAttributes = schedulingFailedEvent.ScheduleActivityTaskFailedEventAttributes;
     ScheduleId       = ScheduleId.Raw(_eventAttributes.ActivityId);
 }
Esempio n. 23
0
 public WorkflowDecision RecordSignal(WorkflowSignaledEvent signal)
 {
     _signalState.RecordSignal(signal.SignalName);
     SignalReceived?.Invoke(this, signal.SignalName);
     return(new WorkflowItemSignalledDecision(ScheduleId.Raw(_data.ScheduleId), _data.TriggerEventId, signal.SignalName, signal.EventId));
 }
Esempio n. 24
0
 public CancelTimerDecision(ScheduleId id) : base(false)
 {
     _id = id;
 }
Esempio n. 25
0
 internal ActivityCancelRequestedEvent(HistoryEvent activityCancelRequestedEvent)
     : base(activityCancelRequestedEvent)
 {
     ScheduleId = ScheduleId.Raw(activityCancelRequestedEvent.ActivityTaskCancelRequestedEventAttributes.ActivityId);
 }
Esempio n. 26
0
 public static ScheduleTimerDecision RescheduleTimer(ScheduleId scheduleId, TimeSpan timeout)
 => new ScheduleTimerDecision(scheduleId, timeout, TimerType.Reschedule);
 public CancelActivityDecision(ScheduleId id) : base(false)
 {
     _id = id;
 }
Esempio n. 28
0
 public static ScheduleTimerDecision WorkflowItem(ScheduleId scheduleId, TimeSpan timeout)
 => new ScheduleTimerDecision(scheduleId, timeout, TimerType.WorkflowItem);
 public ScheduleChildWorkflowDecision(ScheduleId id, object input) : base(false)
 {
     _id    = id;
     _input = input;
 }
Esempio n. 30
0
 public virtual bool Has(ScheduleId id) => ScheduleId == id;