Rename TimerEvent to Timer
This commit is contained in:
parent
bd4dd6a849
commit
6c8cc5efd0
|
|
@ -10,13 +10,13 @@ using NodaTime;
|
|||
namespace Elsa.Activities.Timers
|
||||
{
|
||||
[Trigger(Category = "Timers", Description = "Triggers at a specified interval.")]
|
||||
public class TimerEvent : Activity
|
||||
public class Timer : Activity
|
||||
{
|
||||
private readonly IWorkflowInstanceManager _workflowInstanceManager;
|
||||
private readonly IWorkflowScheduler _workflowScheduler;
|
||||
private readonly IClock _clock;
|
||||
|
||||
public TimerEvent(IWorkflowInstanceManager workflowInstanceManager, IWorkflowScheduler workflowScheduler, IClock clock)
|
||||
public Timer(IWorkflowInstanceManager workflowInstanceManager, IWorkflowScheduler workflowScheduler, IClock clock)
|
||||
{
|
||||
_workflowInstanceManager = workflowInstanceManager;
|
||||
_workflowScheduler = workflowScheduler;
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using NodaTime;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace Elsa.Activities.Timers
|
||||
{
|
||||
public static class TimerBuilderExtensions
|
||||
{
|
||||
public static IActivityBuilder Timer(this IBuilder builder,
|
||||
Action<ISetupActivity<Timer>>? setup = default) => builder.Then(setup);
|
||||
|
||||
public static IActivityBuilder
|
||||
Timer(this IBuilder builder, Func<ActivityExecutionContext, Duration> value) =>
|
||||
builder.Timer(setup => setup.Set(x => x.Timeout, value));
|
||||
|
||||
public static IActivityBuilder Timer(this IBuilder builder, Func<Duration> value) =>
|
||||
builder.Timer(setup => setup.Set(x => x.Timeout, value));
|
||||
|
||||
public static IActivityBuilder Timer(this IBuilder builder, Duration value) =>
|
||||
builder.Timer(setup => setup.Set(x => x.Timeout, value));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
using System;
|
||||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using NodaTime;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace Elsa.Activities.Timers
|
||||
{
|
||||
public static class TimerEventBuilderExtensions
|
||||
{
|
||||
public static IActivityBuilder TimerEvent(this IBuilder builder,
|
||||
Action<ISetupActivity<TimerEvent>>? setup = default) => builder.Then(setup);
|
||||
|
||||
public static IActivityBuilder
|
||||
TimerEvent(this IBuilder builder, Func<ActivityExecutionContext, Duration> value) =>
|
||||
builder.TimerEvent(setup => setup.Set(x => x.Timeout, value));
|
||||
|
||||
public static IActivityBuilder TimerEvent(this IBuilder builder, Func<Duration> value) =>
|
||||
builder.TimerEvent(setup => setup.Set(x => x.Timeout, value));
|
||||
|
||||
public static IActivityBuilder TimerEvent(this IBuilder builder, Duration value) =>
|
||||
builder.TimerEvent(setup => setup.Set(x => x.Timeout, value));
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
.AddTransient<RunWorkflowJob>()
|
||||
.AddHostedService<StartJobs>()
|
||||
.AddActivity<CronEvent>()
|
||||
.AddActivity<TimerEvent>()
|
||||
.AddActivity<Timer>()
|
||||
.AddActivity<StartAt>()
|
||||
.AddTriggerProvider<TimerEventTriggerProvider>()
|
||||
.AddTriggerProvider<CronEventTriggerProvider>()
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ namespace Elsa.Activities.Timers.HostedServices
|
|||
// Schedule workflow blueprints that start with a timer event.
|
||||
var timerWorkflows =
|
||||
from workflow in workflows
|
||||
from activity in workflow.GetStartActivities<TimerEvent>()
|
||||
from activity in workflow.GetStartActivities<Timer>()
|
||||
select (workflow, activity);
|
||||
|
||||
var now = _clock.GetCurrentInstant();
|
||||
|
|
@ -91,7 +91,7 @@ namespace Elsa.Activities.Timers.HostedServices
|
|||
var workflow = timerWorkflow.workflow;
|
||||
var activity = timerWorkflow.activity;
|
||||
var workflowWrapper = await _workflowBlueprintReflector.ReflectAsync(serviceScope, workflow, cancellationToken);
|
||||
var timerEventWrapper = workflowWrapper.GetActivity<TimerEvent>(activity.Id);
|
||||
var timerEventWrapper = workflowWrapper.GetActivity<Timer>(activity.Id);
|
||||
var timeOut = await timerEventWrapper.GetPropertyValueAsync(x => x.Timeout, cancellationToken);
|
||||
var startAt = now.Plus(timeOut);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ namespace Elsa.Activities.Timers.Triggers
|
|||
public Instant ExecuteAt { get; set; }
|
||||
}
|
||||
|
||||
public class TimerEventTriggerProvider : TriggerProvider<TimerEventTrigger, TimerEvent>
|
||||
public class TimerEventTriggerProvider : TriggerProvider<TimerEventTrigger, Timer>
|
||||
{
|
||||
public override ITrigger GetTrigger(TriggerProviderContext<TimerEvent> context)
|
||||
public override ITrigger GetTrigger(TriggerProviderContext<Timer> context)
|
||||
{
|
||||
var executeAt = context.Activity.GetState(x => x.ExecuteAt);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Elsa.Samples.ForkJoinTimerAndSignalHttp.Workflows
|
|||
{
|
||||
fork
|
||||
.When("Timer")
|
||||
.TimerEvent(_timeOut)
|
||||
.Timer(_timeOut)
|
||||
.SetVariable("CompletedVia", "Timer")
|
||||
.Then("Join");
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using NodaTime;
|
|||
namespace Elsa.Samples.Interrupts.Activities
|
||||
{
|
||||
[Activity]
|
||||
public class Sleep : TimerEvent
|
||||
public class Sleep : Timer
|
||||
{
|
||||
public Sleep(IWorkflowInstanceManager workflowInstanceManager, IWorkflowScheduler workflowScheduler, IClock clock) : base(workflowInstanceManager, workflowScheduler, clock)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Elsa.Samples.AzureServiceBusWorker.Workflows
|
|||
public void Build(IWorkflowBuilder workflow)
|
||||
{
|
||||
workflow
|
||||
.TimerEvent(Duration.FromSeconds(5))
|
||||
.Timer(Duration.FromSeconds(5))
|
||||
.WriteLine("Sending a random greeting to the \"greetings\" queue.")
|
||||
.SendMessage("greetings", GetRandomGreeting);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Elsa.Samples.CustomAttributesChildWorker.Workflows
|
|||
public void Build(IWorkflowBuilder workflow)
|
||||
{
|
||||
workflow
|
||||
.TimerEvent(Duration.FromSeconds(5))
|
||||
.Timer(Duration.FromSeconds(5))
|
||||
.SetVariable("CustomerId", SelectRandomCustomerId)
|
||||
.WriteLine(context => $"Creating a new order for customer {context.GetVariable<string>("CustomerId")}.")
|
||||
.Then<SendRebusMessage>(message => message.Set(x => x.Message, context => new OrderReceived { CustomerId = context.GetVariable<string>("CustomerId") }));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Elsa.Samples.DistributedLock
|
|||
{
|
||||
workflow
|
||||
.WithPersistenceBehavior(WorkflowPersistenceBehavior.ActivityExecuted)
|
||||
.TimerEvent(Duration.FromSeconds(1))
|
||||
.Timer(Duration.FromSeconds(1))
|
||||
.WriteLine("Hello World")
|
||||
.WriteLine(() => $"Timer event at {DateTime.Now}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Elsa.Samples.MultiTenantChildWorker.Workflows
|
|||
public void Build(IWorkflowBuilder workflow)
|
||||
{
|
||||
workflow
|
||||
.TimerEvent(Duration.FromSeconds(5))
|
||||
.Timer(Duration.FromSeconds(5))
|
||||
.SetVariable("CustomerId", SelectRandomCustomerId)
|
||||
.WriteLine(context => $"Creating a new order for customer {context.GetVariable<string>("CustomerId")}.")
|
||||
.Then<SendRebusMessage>(message => message.Set(x => x.Message, context => new OrderReceived { CustomerId = context.GetVariable<string>("CustomerId") }));
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Elsa.Samples.RebusWorker.Workflows
|
|||
public void Build(IWorkflowBuilder workflow)
|
||||
{
|
||||
workflow
|
||||
.TimerEvent(Duration.FromSeconds(5))
|
||||
.Timer(Duration.FromSeconds(5))
|
||||
.WriteLine("Sending a random greeting to the \"greetings\" queue.")
|
||||
.Then<SendRebusMessage>(sendMessage => sendMessage.Set(x => x.Message, GetRandomGreeting));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ namespace Elsa.Samples.Timers
|
|||
{
|
||||
workflow
|
||||
.AsSingleton()
|
||||
.TimerEvent(Duration.FromSeconds(2))
|
||||
.Timer(Duration.FromSeconds(2))
|
||||
.WriteLine(context => $"{context.WorkflowExecutionContext.WorkflowInstance.WorkflowInstanceId} triggered by timer at {_clock.GetCurrentInstant()}.")
|
||||
.TimerEvent(Duration.FromSeconds(2))
|
||||
.Timer(Duration.FromSeconds(2))
|
||||
.WriteLine(context => $"{context.WorkflowExecutionContext.WorkflowInstance.WorkflowInstanceId} resumed by timer at {_clock.GetCurrentInstant()}.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Elsa.Samples.WhileLoopWorker.Workflows
|
|||
@while
|
||||
.WriteLine("Ringgggg ringgg.")
|
||||
.WriteLine(() => $"Call status: {_phoneCallService.CallStatus}")
|
||||
.TimerEvent(Duration.FromSeconds(5))
|
||||
.Timer(Duration.FromSeconds(5))
|
||||
.Then(() => _phoneCallService.Progress());
|
||||
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue