public static void DeleteScheduler(Schedule schedule, bool deleteSeries) { Message message = Message.Parse(schedule, "schedule:delete"); var scheduleContext = new DeleteScheduleContext(schedule, deleteSeries); Dispatcher.Dispatch(message, scheduleContext); }
public static void CreateRecurrence(Event ev, Schedule schedule, Options options) { Message message = Message.Parse(ev, "recurrence:" + schedule.Recurrence.ToString().ToLower()); var context = new EventCommandContext(ev, schedule, options); Dispatcher.Dispatch(message, context); }
public static void UpdateEvent(Event evnt, Schedule schedule, Options options, bool updateSeries) { if (RemoteSettings.Service != null) { RemoteSettings.Service.SaveEventInfo(evnt.ToXml(), schedule == null ? string.Empty : schedule.ToXml(), options.ToXml(), updateSeries, RemoteSettings.ServiceCredentials); CacheManager.ClearAllCaches(); } else { CalendarActions.UpdateEvent(evnt, schedule, options, updateSeries); } }
public static void CreateEvent(Event ev, Schedule schedule, Options options) { if (RemoteSettings.Service != null) { RemoteSettings.Service.CreateEvent(ev.ToXml(), schedule == null ? string.Empty : schedule.ToXml(), options.ToXml(), RemoteSettings.ServiceCredentials); CacheManager.ClearAllCaches(); } else { CalendarActions.CreateEvent(ev, schedule, options); } }
public void CreateEvent(Event eventItem, Schedule schedule, EventList calendar, BranchItem branch) { if (eventItem == null || calendar == null) { return; } calendar.AddEvent(eventItem, branch); if (schedule != null) { if (schedule.IsNew) { schedule.StartDate = eventItem.StartDate; schedule.EndDate = eventItem.EndDate; CreateSchedule(schedule); } switch (schedule.Recurrence) { case Recurrence.Daily: addDaily(Utilities.StringToDate(schedule.StartDate), eventItem, schedule, calendar); break; case Recurrence.Weekly: addWeekly(Utilities.FirstCalendarDay(Utilities.StringToDate(schedule.StartDate)), eventItem, schedule, calendar); break; case Recurrence.Monthly: addMonthly(Utilities.FirstMonthDay(Utilities.StringToDate(schedule.StartDate)), eventItem, schedule, calendar); break; case Recurrence.Yearly: addYearly(Utilities.FirstMonthDay(Utilities.StringToDate(schedule.StartDate)), eventItem, schedule, calendar); break; default: break; } } }
public static void CreateSchedule(Event ev, Schedule schedule, Options options) { Message message = Message.Parse(ev, "schedule:create"); var context = new EventCommandContext(ev, schedule, options); Dispatcher.Dispatch(message, context); }
public static void CreateEvent(Event ev, Schedule schedule, Options options) { CreateEvent(ev, schedule, options, null); }
public static void CreateEvent(Event ev, Schedule schedule, Options options, BranchItem branch) { Message message = Message.Parse(ev, "event:create"); var calendarContext = new EventCommandContext(ev, schedule, options, branch); Dispatcher.Dispatch(message, calendarContext); }
public void CreateEvent(Event ev, Schedule schedule, Options options) { RemoteActionWrapper.CreateEvent(ev, schedule, options); }
public void SaveEventInfo(Event evnt, Schedule schedule, bool updateSeries, Options options) { RemoteActionWrapper.UpdateEvent(evnt, schedule, options, updateSeries); }
public static void UpdateEvent(Event evnt, Schedule schedule, Options options) { UpdateEvent(evnt, schedule, options, false); }
public void UpdateEvent(Event evnt, Schedule schedule, string calendarID, bool updateSeries, BranchItem branchID) { if (evnt == null) { return; } EventList newCal = EventLists[calendarID]; EventList currentCal = GetCalendar(evnt); if (updateSeries == false) { evnt.ScheduleID = string.Empty; evnt.Save(); PublishUtil.Publishing(evnt.GetTargetItem(), true, false); if (newCal != null && currentCal != null && currentCal.ID != newCal.ID) { currentCal.DeleteEvent(evnt); newCal.AddEvent(evnt, branchID); } return; } if (schedule == null || schedule.IsNew || schedule.IsChanged) { DeleteEvent(evnt.ID, true, true); CreateEvent(evnt, schedule, newCal, branchID); return; } if (newCal != null && currentCal != null) { DeleteEvent(evnt.ID, true, true); evnt.StartDate = schedule.StartDate; evnt.EndDate = schedule.EndDate; CreateEvent(evnt, schedule, newCal, branchID); } if (evnt.IsChanged != true) { return; } ItemLink[] links = Globals.LinkDatabase.GetReferences(schedule.GetTargetItem()); foreach (ItemLink link in links) { evnt.SaveToItem(link.GetSourceItem(), true); } }
private static void addMonthly(DateTime start, Event eventItem, Schedule schedule, EventList calendar) { if (eventItem == null || schedule == null || start > Utilities.StringToDate(schedule.EndDate) || schedule.Frequency == 0 || calendar == null) { return; } switch (schedule.Sequence) { case Sequence.First: case Sequence.Second: case Sequence.Third: case Sequence.Fourth: addSequence(start, eventItem, schedule, calendar); break; case Sequence.Last: DateTime tmp = start.AddMonths(1); tmp = tmp.Subtract(TimeSpan.FromDays(1)); while (true) { if (string.Compare(tmp.DayOfWeek.ToString(), schedule.DaysOfWeek.ToString(), true) == 0) { addEvent(eventItem, tmp, calendar, schedule); break; } else { tmp = tmp.Subtract(TimeSpan.FromDays(1)); } } break; default: break; } addMonthly(start.AddMonths(schedule.Frequency), eventItem, schedule, calendar); }
public static void UpdateEvent(Event evnt, Schedule schedule, Options options, bool updateSeries) { var context = new UpdateCommandContext(evnt, schedule, options, updateSeries); Message message = Message.Parse(evnt, "event:update"); Dispatcher.Dispatch(message, context); }
private static void addEvent(Event eventItem, DateTime date, EventList calendar, Schedule schedule) { if (date > Utilities.StringToDate(schedule.EndDate)) { return; } eventItem.StartDate = Utilities.NormalizeDate(date); eventItem.EndDate = Utilities.NormalizeDate(date); eventItem.ScheduleID = schedule.ID; calendar.AddEvent(eventItem, StaticSettings.EventBranch); }
private static void addDaily(DateTime start, Event eventItem, Schedule schedule, EventList calendar) { if (eventItem == null || schedule == null || start > Utilities.StringToDate(schedule.EndDate) || schedule.Frequency == 0 || calendar == null) { return; } eventItem.StartDate = Utilities.NormalizeDate(start); eventItem.EndDate = Utilities.NormalizeDate(start); eventItem.ScheduleID = schedule.ID; calendar.AddEvent(eventItem, StaticSettings.EventBranch); addDaily(start.AddDays(schedule.Frequency), eventItem, schedule, calendar); }
private static void addByDayOfWeek(DateTime start, Event eventItem, Schedule schedule, EventList calendar) { if ((schedule.DaysOfWeek & DaysCollection.Monday) == DaysCollection.Monday) { addEvent(eventItem, start, calendar, schedule); } if ((schedule.DaysOfWeek & DaysCollection.Tuesday) == DaysCollection.Tuesday) { addEvent(eventItem, start.AddDays(1), calendar, schedule); } if ((schedule.DaysOfWeek & DaysCollection.Wednesday) == DaysCollection.Wednesday) { addEvent(eventItem, start.AddDays(2), calendar, schedule); } if ((schedule.DaysOfWeek & DaysCollection.Thursday) == DaysCollection.Thursday) { addEvent(eventItem, start.AddDays(3), calendar, schedule); } if ((schedule.DaysOfWeek & DaysCollection.Friday) == DaysCollection.Friday) { addEvent(eventItem, start.AddDays(4), calendar, schedule); } if ((schedule.DaysOfWeek & DaysCollection.Saturday) == DaysCollection.Saturday) { addEvent(eventItem, start.AddDays(5), calendar, schedule); } if ((schedule.DaysOfWeek & DaysCollection.Sunday) == DaysCollection.Sunday) { addEvent(eventItem, start.AddDays(6), calendar, schedule); } }
public static void DeleteScheduler(Schedule schedule) { DeleteScheduler(schedule, false); }
private static void addYearly(DateTime start, Event eventItem, Schedule schedule, EventList calendar) { if (eventItem == null || schedule == null || start > Utilities.StringToDate(schedule.EndDate) || schedule.Frequency == 0 || calendar == null) { return; } DateTime tmp = new DateTime(start.Year, (int) schedule.Month, schedule.Frequency); if (tmp >= Utilities.StringToDate(schedule.StartDate) && tmp <= Utilities.StringToDate(schedule.EndDate)) { addEvent(eventItem, tmp, calendar, schedule); } addYearly(start.AddYears(1), eventItem, schedule, calendar); }
private static void addSequence(DateTime start, Event eventItem, Schedule schedule, EventList calendar) { DateTime tmp = start; while (true) { if (string.Compare(tmp.DayOfWeek.ToString(), schedule.DaysOfWeek.ToString(), true) == 0) { if (schedule.Sequence != Sequence.None && schedule.Sequence != Sequence.First) { tmp = tmp.AddDays(((int) schedule.Sequence)*7); } if (tmp >= Utilities.StringToDate(schedule.StartDate)) { addEvent(eventItem, tmp, calendar, schedule); } break; } else { tmp = tmp.AddDays(1); } } }
public bool CreateSchedule(Schedule schedule) { if (schedule == null) { return false; } Item root = SiteSettings.SchedulesRoot; if (root == null) { return false; } using (new SecurityDisabler()) { Item newSched = root.Add(SchedulePrefix + root.Children.Count, StaticSettings.ScheduleTemplate); schedule.SaveRecurrence(newSched); schedule.ID = newSched.ID.ToString(); } return true; }
private static void CreateEndUserTrainingEvents(EventListManager eventManager) { DateTime start = FindNextDayOfWeek(DateTime.Today, DeveloperDay); var evt = new Event { Description = string.Empty, StartDate = Utilities.NormalizeDate(start), EndDate = Utilities.NormalizeDate(start.AddMonths(2)), StartTime = "09:00", EndTime = "17:00", Location = EndUserLocationDefault, Title = EndUserDefaultTitle }; var scheduler = new Schedule { DaysOfWeek = (Utils.DaysOfWeek.Monday | Utils.DaysOfWeek.Friday), StartDate = Utilities.NormalizeDate(start), EndDate = Utilities.NormalizeDate(start.AddMonths(2)), Recurrence = Recurrence.Weekly, Frequency = 1 }; var options = new Options { CalendarID = EndUserTrainingList, ControlSettingsPath = DeveloperViewSettings, SiteSettingsPath = DefaultModuleSettings }; CalendarActions.CreateEvent(evt, scheduler, options); }
private static void addWeekly(DateTime start, Event eventItem, Schedule schedule, EventList calendar) { if (eventItem == null || schedule == null || start > Utilities.StringToDate(schedule.EndDate) || schedule.Frequency == 0 || calendar == null) { return; } addByDayOfWeek(start, eventItem, schedule, calendar); start = start.AddDays(schedule.Frequency*7); addWeekly(start, eventItem, schedule, calendar); }