/// <summary> /// Sets the job's schedule /// </summary> public IJobSchedule SetJobSchedule(IJob job, DayOfWeek[] daysOfWeek, DateTime scheduleTime) { var jobInfo = this.m_jobs.FirstOrDefault(o => o.Job.Id == job.Id); if (jobInfo == null) { throw new KeyNotFoundException($"Job {job.Id} not registered"); } this.m_tracer.TraceInfo("Set job {0} schedule to {1} @ {2}", job, daysOfWeek, scheduleTime); this.m_jobScheduleManager.Clear(job); var retVal = new JobItemSchedule() { Type = JobScheduleType.Scheduled, RepeatOn = daysOfWeek, StartDate = scheduleTime }; this.m_jobScheduleManager.Add(job, retVal); return(retVal); }
/// <summary> /// Set the job to repeat on an interval /// </summary> /// <param name="job">The job to set repeat schedule for</param> /// <param name="interval">The interval to set</param> /// <returns>The created schedule</returns> public IJobSchedule SetJobSchedule(IJob job, TimeSpan interval) { var jobInfo = this.m_jobs.FirstOrDefault(o => o.Job.Id == job.Id); if (jobInfo == null) { throw new KeyNotFoundException($"Job {job.Id} not registered"); } this.m_tracer.TraceInfo("Set job {0} schedule to repeat {1} ", job, interval); this.m_jobScheduleManager.Clear(job); var retVal = new JobItemSchedule() { Type = JobScheduleType.Interval, Interval = (int)interval.TotalSeconds, IntervalSpecified = true, }; this.m_jobScheduleManager.Add(job, retVal); return(retVal); }