Customize CRON input help text for Quartz provider
This commit is contained in:
parent
1e04e0eaa5
commit
3c8d343165
|
|
@ -31,7 +31,7 @@ namespace Elsa.Activities.Temporal
|
|||
_crontabParser = crontabParser;
|
||||
}
|
||||
|
||||
[ActivityProperty(Hint = "Specify a CRON expression. See https://crontab.guru/ for help.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
|
||||
[ActivityProperty(Hint = "Specify a CRON expression.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
|
||||
public string CronExpression { get; set; } = "* * * * *";
|
||||
|
||||
public Instant? ExecuteAt
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using Elsa.Activities.Temporal.Common.Options;
|
||||
using Elsa.Activities.Temporal.Common.Services;
|
||||
using Elsa.Activities.Temporal.Quartz.Handlers;
|
||||
using Elsa.Activities.Temporal.Quartz.Jobs;
|
||||
using Elsa.Activities.Temporal.Quartz.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -29,7 +30,8 @@ namespace Elsa
|
|||
timersOptions.Services
|
||||
.AddSingleton<IWorkflowScheduler, QuartzWorkflowScheduler>()
|
||||
.AddSingleton<ICrontabParser, QuartzCrontabParser>()
|
||||
.AddTransient<RunQuartzWorkflowJob>();
|
||||
.AddTransient<RunQuartzWorkflowJob>()
|
||||
.AddNotificationHandlers(typeof(ConfigureCronProperty));
|
||||
|
||||
if (registerQuartz)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Events;
|
||||
using MediatR;
|
||||
|
||||
namespace Elsa.Activities.Temporal.Quartz.Handlers
|
||||
{
|
||||
public class ConfigureCronProperty : INotificationHandler<DescribingActivityType>
|
||||
{
|
||||
public Task Handle(DescribingActivityType notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var activityType = notification.ActivityType;
|
||||
|
||||
if (activityType.Type != typeof(Cron))
|
||||
return Task.CompletedTask;
|
||||
|
||||
var cronExpressionProperty = notification.ActivityDescriptor.Properties.First(x => x.Name == nameof(Cron.CronExpression));
|
||||
cronExpressionProperty.DefaultValue = "0 * 0 ? * * *";
|
||||
cronExpressionProperty.Hint = "Specify a Quartz CRON expression. Go to https://www.freeformatter.com/cron-expression-generator-quartz.html to generate valid Quartz cron expressions.";
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue