Beispiel #1
0
        public static ITrigger CreateTrigger(Repeat repeatType, string description = "")
        {
            var cronExpression = CronJob.GetCronExpression(repeatType, default);
            var triggerKey     = TriggerPrefixName + repeatType;
            var trigger        = TriggerBuilder.Create()
                                 .WithIdentity(triggerKey)
                                 .WithCronSchedule(cronExpression)
                                 .WithDescription(description)
                                 .StartNow()
                                 .Build();

            return(trigger);
        }
Beispiel #2
0
        public static string GetCronExpression(Repeat repeatType, DateTime startDate)
        {
            switch (repeatType)
            {
            case Repeat.EveryWeek: return(CronJob.GetEveryWeekCron(startDate));

            case Repeat.EveryMonth: return(CronJob.GetEveryMonthCron(startDate));

            case Repeat.Every6Month: return(CronJob.GetEvery6MonthCron(startDate));

            case Repeat.EveryYear: return(CronJob.GetEveryYearCron(startDate));

            case Repeat.EveryMinute: return(CronJob.GetEveryMinuteCron());
            }
            return(null);
        }
Beispiel #3
0
        public static ITrigger CreateTriggerForExistedJob(DateTime startDate, Repeat repeatType, string description = "")
        {
            if (repeatType == Repeat.Once)
            {
                return(CreateTriggerForExistedJob(startDate, description));
            }
            var cronExpression   = CronJob.GetCronExpression(repeatType, startDate);
            var triggerKey       = TriggerPrefixName + startDate;
            var triggersGroupKey = TriggersPrefixName + repeatType;
            var jobKey           = QuartzJob.GetJobKey(repeatType);

            return(TriggerBuilder.Create()
                   .WithIdentity(triggerKey, triggersGroupKey)
                   .WithCronSchedule(cronExpression)
                   .WithDescription(description)
                   .ForJob(jobKey)
                   .Build());
        }
Beispiel #4
0
        public static ITrigger CreateTrigger(DateTime startDate, Repeat repeatType, string description)
        {
            ITrigger trigger;

            if (repeatType == Repeat.Once)
            {
                trigger = CreateTrigger(startDate, description);
            }
            else
            {
                var cronExpression = CronJob.GetCronExpression(repeatType, startDate);
                var triggerKey     = TriggerPrefixName + startDate;
                var groupKey       = TriggersPrefixName + repeatType;
                trigger = TriggerBuilder.Create()
                          .WithIdentity(triggerKey, groupKey)
                          .WithCronSchedule(cronExpression)
                          .WithDescription(description)
                          .Build();
            }
            return(trigger);
        }