public RecurringJobWrapper Create(Type enqueuerType) { try { var wrapperType = RecurringJobWrapper.CreateType(enqueuerType); return((RecurringJobWrapper)_lifetimeScope.Resolve(wrapperType)); } catch (Exception e) { throw new SchedulerException("Problem instantiating class: " + e.Message, e); } }
public static void AddRecurringJob(this IScheduler scheduler, Type jobType, JobKey jobKey, string triggerTime) { if (!typeof(IRecurringJobBase).IsAssignableFrom(jobType)) { throw new ArgumentException("Wrong type of recurrent task enqueuer. It should be assignable from IRecurringJobBase"); } var wrapperType = RecurringJobWrapper.CreateType(jobType); var trigger = TriggerBuilder.Create().WithIdentity(jobKey.Name + "trigger").WithCronSchedule(triggerTime).ForJob(jobKey).Build(); var job = JobBuilder.Create(wrapperType).WithIdentity(jobKey).Build(); scheduler.ScheduleJob(job, trigger); }