Exemple #1
0
        public async Task Start(CancellationToken cancellationToken = default)
        {
            if (quartzScheduler == null)
            {
                var initialized = await InitialiseScheduler(cancellationToken);

                if (!initialized)
                {
                    logger.LogError("Failed to initialize scheduler.");
                    return;
                }
            }

            var jobKeys = await quartzScheduler.GetJobKeys(GroupMatcher <JobKey> .AnyGroup());

            int allJobs = jobKeys.Count;

            var triggers = await quartzScheduler.GetTriggerKeys(GroupMatcher <TriggerKey> .AnyGroup());

            int activeJobs = triggers.Count;

            logger.LogInformation($"Configuration loaded, {allJobs} jobs found, {activeJobs} active.");

            await quartzScheduler.Start(cancellationToken);

            if (activeJobs == 0)
            {
                logger.LogWarning("Scheduler will be started, but has no active jobs!");
            }
            else
            {
                logger.LogInformation("Scheduler started.");
            }

            if (allJobs > 0)
            {
                logger.LogInformation(await GetJobsQuickInfo());
            }
        }