예제 #1
0
        public static void ReSchedule(string guid)
        {
            var task = JobRepository.GetByGuid(guid);

            JobRepository.SetTaskOneTimeOnly(guid, task.Alias, task.Data);
            JobScheduler.LaunchJob <JobList.CommandJob>(guid);
        }
예제 #2
0
        public static void LaunchJob <T>(string guid) where T : IJob
        {
            var task   = JobRepository.GetByGuid(guid);
            var dbtask = JobBuilder.Create <T>()
                         .WithIdentity(task.Alias, Guid.NewGuid().ToString())
                         .UsingJobData("data", task.Data)
                         .UsingJobData("jobID", task.Guid)
                         .Build();
            ITrigger trigger;

            switch (task.TriggerPeriod)
            {
            case TriggerPeriod.IsOneTimeOnly:
                trigger = DefineOneTimeOnlyTrigger(task.Alias, task.StartTime);
                break;

            case TriggerPeriod.IsCron:
                trigger = DefineCronTrigger(task.Alias, task.StartTime, task.CronExpression);
                break;

            case TriggerPeriod.WithInterval:
                trigger = DefineIntervalTrigger(task.Alias, task.StartTime, task.IntervalType, task.IntervalSpan, task.Count);
                break;

            case TriggerPeriod.Other:
                trigger = DefineDefaultTrigger(task.Alias);
                break;

            default:
                trigger = DefineDefaultTrigger(task.Alias);
                break;
            }
            Scheduler.ScheduleJob(dbtask, trigger);
        }