Ejemplo n.º 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());
            }
        }
Ejemplo n.º 2
0
        public int Count()
        {
            if (_scheduler == null)
            {
                return(0);
            }

            var keys = _scheduler.GetJobKeys(GroupMatcher <JobKey> .GroupEquals("Group1"));

            if (keys == null)
            {
                return(0);
            }

            return(keys
                   .ConfigureAwait(true)
                   .GetAwaiter()
                   .GetResult()
                   .Count);
        }