using System; using System.Collections.Generic; using Elsa.Attributes; using Elsa.Contracts; using Elsa.Models; namespace Elsa.Modules.Scheduling.Triggers; /// /// Represents a timer to periodically trigger the workflow. /// public class Timer : EventGenerator { [Input] public Input Interval { get; set; } = default!; protected override IEnumerable GetTriggerData(TriggerIndexingContext context) { var interval = context.ExpressionExecutionContext.Get(Interval); var clock = context.ExpressionExecutionContext.GetRequiredService(); var executeAt = clock.UtcNow.Add(interval); yield return new TimerPayload(executeAt, interval); } } public record TimerPayload(DateTimeOffset StartAt, TimeSpan Interval);