Exemplo n.º 1
0
        private IJobDetail CreateJob(JobSchedule schedule)
        {
            var dic = new Dictionary <string, JobSchedule>();

            dic.Add("data", schedule);

            return(JobBuilder
                   .Create(typeof(HelloWorldJob))
                   .WithIdentity(schedule.JobName, schedule.JobGroup)
                   .WithDescription(schedule.JobDescription)
                   .UsingJobData(new JobDataMap(dic))
                   .Build());
        }
Exemplo n.º 2
0
        private IReadOnlyCollection <ITrigger> CreateTrigger(JobSchedule schedule)
        {
            List <ITrigger> triggers = new List <ITrigger>();

            var crons = schedule.CronExpression.Split(',');

            for (int i = 0; i < crons.Length; i++)
            {
                var Builder = TriggerBuilder
                              .Create()
                              .WithIdentity($"{schedule.JobName}.trigger{i+1}")
                              .WithCronSchedule(crons[i])
                              .WithDescription(crons[i])
                              .Build();
                triggers.Add(Builder);
            }

            return(triggers);
        }