| | | 1 | | using System.Runtime.CompilerServices; |
| | | 2 | | using Elsa.Expressions.Models; |
| | | 3 | | using Elsa.Extensions; |
| | | 4 | | using Elsa.Workflows.Attributes; |
| | | 5 | | using Elsa.Workflows.Models; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Scheduling.Activities; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Represents a timer to periodically trigger the workflow. |
| | | 11 | | /// </summary> |
| | | 12 | | [Activity("Elsa", "Scheduling", "Trigger workflow execution at a specific interval.")] |
| | | 13 | | public class Timer : TimerBase |
| | | 14 | | { |
| | | 15 | | /// <inheritdoc /> |
| | 31 | 16 | | public Timer([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) |
| | | 17 | | { |
| | 31 | 18 | | } |
| | | 19 | | |
| | | 20 | | /// <inheritdoc /> |
| | 26 | 21 | | public Timer(TimeSpan interval, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this( |
| | | 22 | | { |
| | 26 | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <inheritdoc /> |
| | 26 | 26 | | public Timer(Input<TimeSpan> interval, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) |
| | | 27 | | { |
| | 26 | 28 | | Interval = interval; |
| | 26 | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// The interval at which the timer should execute. |
| | | 33 | | /// </summary> |
| | | 34 | | [Input(Description = "The interval at which the timer should execute.", DefaultValue = "00:01:00")] |
| | 142 | 35 | | public Input<TimeSpan> Interval { get; set; } = new(TimeSpan.FromMinutes(1)); |
| | | 36 | | |
| | | 37 | | protected override TimeSpan GetInterval(ExpressionExecutionContext context) |
| | | 38 | | { |
| | 11 | 39 | | return Interval.Get(context); |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Creates a new <see cref="Timer"/> activity set to trigger at the specified interval. |
| | | 44 | | /// </summary> |
| | 22 | 45 | | public static Timer FromTimeSpan(TimeSpan value, [CallerFilePath] string? source = null, [CallerLineNumber] int? lin |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Creates a new <see cref="Timer"/> activity set to trigger at the specified interval in seconds. |
| | | 49 | | /// </summary> |
| | 20 | 50 | | public static Timer FromSeconds(double value, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = |
| | | 51 | | } |