/// <summary> /// Evaluates this event to determine the dates and times for which the event occurs. /// This method only evaluates events which occur between <paramref name="FromDate"/> /// and <paramref name="ToDate"/>; therefore, if you require a list of events which /// occur outside of this range, you must specify a <paramref name="FromDate"/> and /// <paramref name="ToDate"/> which encapsulate the date(s) of interest. /// <note type="caution"> /// For events with very complex recurrence rules, this method may be a bottleneck /// during processing time, especially when this method in called for a large number /// of events, in sequence, or for a very large time span. /// </summary> /// <param name="FromDate">The beginning date of the range to evaluate.</param> /// <param name="ToDate">The end date of the range to evaluate.</param> /// <returns></returns> public override ArrayList Evaluate(Date_Time FromDate, Date_Time ToDate) { // Add the event itself, before recurrence rules are evaluated DateTimes.Add(DTStart.Copy()); Periods.Add(new Period(DTStart, Duration)); // Evaluate recurrences normally base.Evaluate(FromDate, ToDate); // Remove DateTimes that already have a Period for (int i = DateTimes.Count - 1; i >= 0; i--) { foreach (Period p in Periods) { if (p.StartTime == DateTimes[i]) { DateTimes.RemoveAt(i); } } } // Convert each calculated Date_Time into a Period. foreach (Date_Time dt in DateTimes) { Period p = new Period(dt, Duration); if (!Periods.Contains(p)) { Periods.Add(p); } } Periods.Sort(); return(Periods); }
/// <summary> /// Evaluates this item to determine the dates and times for which it occurs/recurs. /// This method only evaluates items which occur/recur between <paramref name="FromDate"/> /// and <paramref name="ToDate"/>; therefore, if you require a list of items which /// occur outside of this range, you must specify a <paramref name="FromDate"/> and /// <paramref name="ToDate"/> which encapsulate the date(s) of interest. /// <note type="caution"> /// For events with very complex recurrence rules, this method may be a bottleneck /// during processing time, especially when this method is called for a large number /// of items, in sequence, or for a very large time span. /// </note> /// </summary> /// <param name="FromDate">The beginning date of the range to evaluate.</param> /// <param name="ToDate">The end date of the range to evaluate.</param> /// <returns> /// An <see cref="ArrayList"/> containing a <see cref="Date_Time"/> object for /// each date/time this item occurs/recurs. /// </returns> virtual public List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate) { // Evaluate extra time periods, without re-evaluating ones that were already evaluated if ((EvalStart == null && EvalEnd == null) || (ToDate == EvalStart) || (FromDate == EvalEnd)) { EvaluateRRule(FromDate, ToDate); EvaluateRDate(FromDate, ToDate); EvaluateExRule(FromDate, ToDate); EvaluateExDate(FromDate, ToDate); if (EvalStart == null || EvalStart > FromDate) { EvalStart = FromDate.Copy(); } if (EvalEnd == null || EvalEnd < ToDate) { EvalEnd = ToDate.Copy(); } } if (EvalStart != null && FromDate < EvalStart) { Evaluate(FromDate, EvalStart); } if (EvalEnd != null && ToDate > EvalEnd) { Evaluate(EvalEnd, ToDate); } Periods.Sort(); // Ensure the Kind of time is consistent with DTStart foreach (Period p in Periods) { if (p.StartTime.Kind != DTStart.Kind) { p.StartTime.Value = new DateTime(p.StartTime.Year, p.StartTime.Month, p.StartTime.Day, p.StartTime.Hour, p.StartTime.Minute, p.StartTime.Second, DTStart.Kind); } } // Evaluate all Alarms for this component. foreach (Alarm alarm in Alarms) { alarm.Evaluate(this); } return(Periods); }
/// <summary> /// Evaluates this item to determine the dates and times for which it occurs/recurs. /// This method only evaluates items which occur/recur between <paramref name="FromDate"/> /// and <paramref name="ToDate"/>; therefore, if you require a list of items which /// occur outside of this range, you must specify a <paramref name="FromDate"/> and /// <paramref name="ToDate"/> which encapsulate the date(s) of interest. /// <note type="caution"> /// For events with very complex recurrence rules, this method may be a bottleneck /// during processing time, especially when this method is called for a large number /// of items, in sequence, or for a very large time span. /// </note> /// </summary> /// <param name="FromDate">The beginning date of the range to evaluate.</param> /// <param name="ToDate">The end date of the range to evaluate.</param> /// <returns> /// A <see cref="List<Period>"/> containing a <see cref="Period"/> object for /// each date/time this item occurs/recurs. /// </returns> virtual internal List <Period> Evaluate(iCalDateTime FromDate, iCalDateTime ToDate) { // Evaluate extra time periods, without re-evaluating ones that were already evaluated if ((EvalStart == null && EvalEnd == null) || (ToDate == EvalStart) || (FromDate == EvalEnd)) { EvaluateRRule(FromDate, ToDate); EvaluateRDate(FromDate, ToDate); EvaluateExRule(FromDate, ToDate); EvaluateExDate(FromDate, ToDate); if (EvalStart == null || EvalStart > FromDate) { EvalStart = FromDate.Copy(); } if (EvalEnd == null || EvalEnd < ToDate) { EvalEnd = ToDate.Copy(); } } if (EvalStart != null && FromDate < EvalStart) { Evaluate(FromDate, EvalStart); } if (EvalEnd != null && ToDate > EvalEnd) { Evaluate(EvalEnd, ToDate); } Periods.Sort(); foreach (Period p in Periods) { // Ensure the Kind of time is consistent with DTStart p.StartTime.IsUniversalTime = DTStart.IsUniversalTime; } return(Periods); }
/// <summary> /// Evaluates this item to determine the dates and times for which it occurs/recurs. /// This method only evaluates items which occur/recur between <paramref name="FromDate"/> /// and <paramref name="ToDate"/>; therefore, if you require a list of items which /// occur outside of this range, you must specify a <paramref name="FromDate"/> and /// <paramref name="ToDate"/> which encapsulate the date(s) of interest. /// <note type="caution"> /// For events with very complex recurrence rules, this method may be a bottleneck /// during processing time, especially when this method is called for a large number /// of items, in sequence, or for a very large time span. /// </note> /// </summary> /// <param name="FromDate">The beginning date of the range to evaluate.</param> /// <param name="ToDate">The end date of the range to evaluate.</param> /// <returns> /// An <see cref="ArrayList"/> containing a <see cref="Date_Time"/> object for /// each date/time this item occurs/recurs. /// </returns> virtual public List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate) { // Evaluate extra time periods, without re-evaluating ones that were already evaluated if ((EvalStart == null && EvalEnd == null) || (ToDate == EvalStart) || (FromDate == EvalEnd)) { EvaluateRRule(FromDate, ToDate); EvaluateRDate(FromDate, ToDate); EvaluateExRule(FromDate, ToDate); EvaluateExDate(FromDate, ToDate); if (EvalStart == null || EvalStart > FromDate) { EvalStart = FromDate.Copy(); } if (EvalEnd == null || EvalEnd < ToDate) { EvalEnd = ToDate.Copy(); } } if (EvalStart != null && FromDate < EvalStart) { Evaluate(FromDate, EvalStart); } if (EvalEnd != null && ToDate > EvalEnd) { Evaluate(EvalEnd, ToDate); } Periods.Sort(); // Evaluate all Alarms for this component. foreach (Alarm alarm in Alarms) { alarm.Evaluate(this); } return(Periods); }