/// <summary> /// Store the given <see cref="T:Quartz.ICalendar"/>. /// </summary> /// <param name="name">The name.</param><param name="calendar">The <see cref="T:Quartz.ICalendar"/> to be stored.</param><param name="replaceExisting">If <see langword="true"/>, any <see cref="T:Quartz.ICalendar"/> existing /// in the <see cref="T:Quartz.Spi.IJobStore"/> with the same name and group /// should be over-written.</param><param name="updateTriggers">If <see langword="true"/>, any <see cref="T:Quartz.ITrigger"/>s existing /// in the <see cref="T:Quartz.Spi.IJobStore"/> that reference an existing /// Calendar with the same name with have their next fire time /// re-computed with the new <see cref="T:Quartz.ICalendar"/>.</param><throws>ObjectAlreadyExistsException </throws> public override void StoreCalendar(string name, ICalendar calendar, bool replaceExisting, bool updateTriggers) { string calendarHashKey = RedisJobStoreSchema.CalendarHashKey(name); if (replaceExisting == false && Db.KeyExists(calendarHashKey)) { throw new ObjectAlreadyExistsException(string.Format("Calendar with key {0} already exists", calendarHashKey)); } Db.HashSet(calendarHashKey, ConvertToHashEntries(calendar)); Db.SetAdd(RedisJobStoreSchema.CalendarsSetKey(), calendarHashKey); if (updateTriggers) { var calendarTriggersSetkey = RedisJobStoreSchema.CalendarTriggersSetKey(name); var triggerHashKeys = Db.SetMembers(calendarTriggersSetkey); foreach (var triggerHashKey in triggerHashKeys) { var trigger = RetrieveTrigger(RedisJobStoreSchema.TriggerKey(triggerHashKey)); trigger.UpdateWithNewCalendar(calendar, TimeSpan.FromSeconds(MisfireThreshold)); StoreTrigger(trigger, true); } } }
/// <summary> /// Remove (delete) the <see cref="T:Quartz.ICalendar"/> with the /// given name. /// </summary> /// <remarks> /// If removal of the <see cref="T:Quartz.ICalendar"/> would result in /// <see cref="T:Quartz.ITrigger"/>s pointing to non-existent calendars, then a /// <see cref="T:Quartz.JobPersistenceException"/> will be thrown. /// </remarks> /// <param name="calendarName">The name of the <see cref="T:Quartz.ICalendar"/> to be removed.</param> /// <returns> /// <see langword="true"/> if a <see cref="T:Quartz.ICalendar"/> with the given name /// was found and removed from the store. /// </returns> public override bool RemoveCalendar(string calendarName) { var calendarTriggersSetKey = RedisJobStoreSchema.CalendarTriggersSetKey(calendarName); if (Db.SetLength(calendarTriggersSetKey) > 0) { throw new JobPersistenceException(string.Format("There are triggers are using calendar {0}", calendarName)); } var calendarHashKey = RedisJobStoreSchema.CalendarHashKey(calendarName); return(Db.KeyDelete(calendarHashKey) && Db.SetRemove(RedisJobStoreSchema.CalendarsSetKey(), calendarHashKey)); }