Exemplo n.º 1
0
        public async Task StartAsync(CancellationToken cancellationToken, bool captureContext = false)
        {
            Scheduler = await _schedulerFactory.GetScheduler(cancellationToken).ConfigureAwait(captureContext);

            Scheduler.JobFactory = _jobFactory;

            foreach (Job job in await _jobEntitiesRepository.ReadAsync(cancellationToken, captureContext))
            {
                _jobIndex.TryGetValue(Guid.Parse(job.JobId), out ISchedulerJobDefinition schedulerJobDefinition);

                if (schedulerJobDefinition is null)
                {
                    LogService.Error?.Write($"Job with id {job.JobId} could not be founded, skipping...");

                    continue;
                }

                IJobDetail jobDetail  = CreateJob(schedulerJobDefinition.JobType);
                ITrigger   jobTrigger = CreateTrigger(schedulerJobDefinition, job);

                await Scheduler.ScheduleJob(jobDetail, jobTrigger, cancellationToken).ConfigureAwait(captureContext);
            }

            await Scheduler.Start(cancellationToken).ConfigureAwait(captureContext);
        }
 public async Task <IActionResult> List()
 => ToJsonResult(await _jobEntitiesRepository.ReadAsync(CancellationToken.None));