public static void SyncEvents(Event pattern, IEnumerable<Event> events, EventList list, EventListManager manager) { Message message = Message.Parse(pattern, "event:sync"); var deleteContext = new SyncEventContext(pattern, events, list, manager); Dispatcher.Dispatch(message, deleteContext); }
protected virtual void RenderEventSection(HtmlTextWriter writer, Event ev, EventList evList, DateTime date, string eventAttributes, string dotAttributes, string cssClassReadOnly, string cssClassCanWrite, bool isUseBackgroundColor) { string title = (ev.Title == string.Empty) ? ev.Name : ev.Title; string cssStyle = ((!ReadOnly && !ev.ReadOnly) || isUseBackgroundColor) ? buildRuntimeStyle(evList.TextColor, evList.BackgroundColor) : ""; writer.Write( string.Format( "<div id='{0}' {1} eventID='{0}' align='left' startTime='{2}' endTime='{3}' readonly='{4}' link='{5}' {6} class='{7}' startHour='{8}' isrecur='{9}'>", ev.ID, cssStyle, ev.StartTime, ev.EndTime, ReadOnly ? true : ev.ReadOnly, (LinkBehaviour == LinkBehaviour.Redirect) ? ev.Path : String.Empty, eventAttributes, (ReadOnly || ev.ReadOnly) ? cssClassReadOnly : cssClassCanWrite, date.Hour, ev.IsRecurrentEvent ? "1" : "0")); RenderDataBeforeEvent(writer, ev); RenderEvent(writer, dotAttributes, ev, title, evList.EventEditIcon); RenderDataAfterEvent(writer, ev); writer.Write("</div>"); }
protected virtual int RenderEvents(HtmlTextWriter writer, DateTime date, string eventAttributes, string dotAttributes, int threshold, string cssClassReadOnly, string cssClassCanWrite, bool isUseBackgroundColor) { int counter = 0; foreach (Event ev in EventListMgr.GetSortedEvents(date, threshold, new ComparerEventsByStartTime())) { if (ev.IsVisible) { if (threshold != 0 && counter == threshold) { ++counter; break; } EventList evList = new EventList(Utilities.GetCalendarByEvent(ev.GetItem())); RenderEventSection(writer, ev, evList, date, eventAttributes, dotAttributes, cssClassReadOnly, cssClassCanWrite, isUseBackgroundColor); counter++; } } return counter; }
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); } } }
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); }
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); }
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 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; } } }