Пример #1
0
        private static void ScheduleJob <TJob>(this IServiceCollection services, string cronExpression) where TJob : class, IJob
        {
            services.AddSingleton <TJob>();

            var jobSchedule = new JobSchedule(typeof(TJob), cronExpression);

            services.AddSingleton(jobSchedule);
        }
Пример #2
0
 private static ITrigger CreateTrigger(JobSchedule schedule)
 {
     return(TriggerBuilder
            .Create()
            .WithIdentity($"{schedule.JobType.FullName}.trigger")
            .WithCronSchedule(schedule.CronExpression)
            .WithDescription(schedule.CronExpression)
            .Build());
 }
Пример #3
0
        private static IJobDetail CreateJob(JobSchedule schedule)
        {
            var jobType = schedule.JobType;

            return(JobBuilder
                   .Create(jobType)
                   .WithIdentity(jobType.FullName)
                   .WithDescription(jobType.Name)
                   .Build());
        }