Example #1
0
        public static void AddTask <TJob>(IServiceCollectionQuartzConfigurator configurator, IConfigurationSection rootSection)
            where TJob : class, IJob
        {
            var jobProperties = QuartzService.GetJobProperties <TJob>(rootSection);

            if (jobProperties != null)
            {
                configurator.RegisterJob <TJob>(jobProperties);
            }
        }
Example #2
0
        public static IServiceCollectionQuartzConfigurator RegisterJob <TJob>(this IServiceCollectionQuartzConfigurator configurator, CommonSchedulerTaskProperties taskSettings)
            where TJob : class, IJob
        {
            var jobType = typeof(TJob);

            configurator.ScheduleJob <TJob>(
                trigger =>
                trigger.WithIdentity(QuartzService.GetJobTriggerIdentity(jobType))
                .WithDescription(QuartzService.GetJobTriggerDescription(jobType, taskSettings.Schedule))
                .WithCronSchedule(taskSettings.Schedule),
                j =>
            {
                j
                .WithIdentity(jobType.Name)
                .WithDescription(QuartzService.GetJobDescription(jobType, taskSettings.Description));

                if (taskSettings.SpecifiedConditions != null)
                {
                    j.UsingJobData(new JobDataMap(taskSettings.SpecifiedConditions));
                }
            });

            return(configurator);
        }