Ejemplo n.º 1
0
        public void Cron_Expression_Override_Is_Used_When_Provided()
        {
            var          job = DefaultJob;
            const string cronExpressionOverride = "0 0 17 ? * * *";

            job.Update(null, new DateTime(2022, 5, 5, 17, 0, 0), null, RepeatEndStrategy.NotUsed, RepeatInterval.NotUsed, 0, "test", cronExpressionOverride);

            var cronExpressions = cronExpressionGenerator.Create(job);

            cronExpressions.Count.Should().Be(1);
            cronExpressions[0].Should().Be("0 0 17 ? * * *");
        }
Ejemplo n.º 2
0
        private IReadOnlyList <TriggerBuilder> BuildBaseTriggers(Job job)
        {
            if ((job.RepeatInterval == RepeatInterval.Never || job.RepeatInterval == RepeatInterval.NotUsed) &&
                job.CronExpressionOverride.HasNoValue())
            {
                // Run once
                return(new[]
                {
                    TriggerBuilder.Create()
                    .WithIdentity(job.JobIdentifier, job.SubscriptionName)
                    .WithSimpleSchedule()
                    .StartAt(job.StartAt)
                });
            }

            // Certain scheduling requirements may require multiple cron expressions, which means multiple triggers for a job
            var cronExpressions = cronExpressionGenerator.Create(job);

            return(cronExpressions.Select((cronExpression, idx) => TriggerBuilder.Create()
                                          .WithIdentity($"{job.JobIdentifier}-{idx}", job.SubscriptionName)
                                          .WithCronSchedule(cronExpression)
                                          .StartAt(job.StartAt))
                   .ToList()
                   .AsReadOnly());
        }