Exemplo n.º 1
0
        public void BuildJob_Throw_Exception_If_Schedule_Is_Missing()
        {
            var message = new ScheduleJobMessage
            {
                JobUid           = "unique id 1234",
                SubscriptionName = "foo",
                Schedule         = null,
            };

            var result = scheduledJobBuilder.BuildJob(message);

            result.Error.Should().Contain("Schedule property is required ");
        }
Exemplo n.º 2
0
        public async Task AddOrUpdateJob(Job job, CancellationToken ct)
        {
            var jobResult = scheduledJobBuilder.BuildJob(job);

            if (jobResult.IsFailure)
            {
                logger.LogError($"{jobResult.Error}. Message: {job}");
                return;
            }

            var triggerResult = scheduledJobBuilder.BuildTriggers(job);

            if (triggerResult.IsFailure)
            {
                logger.LogError($"{triggerResult.Error}. Message: {job}");
                return;
            }

            await RemoveJobIfAlreadyExists(job.JobIdentifier, job.SubscriptionName, ct);

            if (job.IsActive)
            {
                await scheduler.ScheduleJob(jobResult.Value, triggerResult.Value, false, ct);
            }
        }