public static TimerItem New(Identity identity, IWorkflow workflow) { var scheduleId = identity.ScheduleId(); var timerItem = new TimerItem(identity, scheduleId, workflow); timerItem._rescheduleTimer = Reschedule(timerItem, scheduleId, workflow); timerItem.OnStartFailed(e => e.DefaultAction(workflow)); timerItem.OnCancellationFailed(e => e.DefaultAction(workflow)); timerItem.OnFired(e => e.DefaultAction(workflow)); return(timerItem); }
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); }