예제 #1
0
        private bool CreateRange(Recurrence icalRecurrence, ExDateTime start, out RecurrenceRange range)
        {
            range = null;
            ExDateTime exDateTime = (ExDateTime)icalRecurrence.UntilDateTime;

            if (exDateTime == ExDateTime.MinValue)
            {
                exDateTime = (ExDateTime)icalRecurrence.UntilDate;
            }
            if (exDateTime != ExDateTime.MinValue)
            {
                if (!(exDateTime > start))
                {
                    range = null;
                    ExTraceGlobals.ICalTracer.TraceError <string>((long)this.GetHashCode(), "VEvent::CreateRange. Invalid until date in recurrence range. UID:'{0}'.", this.Uid);
                    base.Context.AddError(ServerStrings.InvalidICalElement("RRULE.InvalidRecurrenceUntil"));
                    return(false);
                }
                range = new EndDateRecurrenceRange(start, start.TimeZone.ConvertDateTime(exDateTime));
            }
            else if (icalRecurrence.Count > 0)
            {
                if (!NumberedRecurrenceRange.IsValidNumberedRecurrenceRange(icalRecurrence.Count))
                {
                    range = null;
                    ExTraceGlobals.ICalTracer.TraceError <string>((long)this.GetHashCode(), "VItemBase::CreateRange. Invalid number of occurrences in recurrence range. UID:'{0}'.", this.Uid);
                    base.Context.AddError(ServerStrings.InvalidICalElement("RRULE.InvalidRecurrenceCount"));
                    return(false);
                }
                range = new NumberedRecurrenceRange(start, icalRecurrence.Count);
            }
            else
            {
                range = new NoEndRecurrenceRange(start);
            }
            return(true);
        }
예제 #2
0
 public virtual bool Equals(RecurrenceRange value)
 {
     return(value != null && value.StartDate == this.startDate);
 }
예제 #3
0
        protected Recurrence ICalRecurrenceFromXsoRecurrence(Recurrence xsoRecurrence)
        {
            Recurrence        recurrence = new Recurrence();
            RecurrencePattern pattern    = xsoRecurrence.Pattern;
            RecurrenceRange   range      = xsoRecurrence.Range;

            if (pattern is DailyRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Daily;
            }
            else if (pattern is WeeklyRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Weekly;
                WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)pattern;
                recurrence.ByDayList     = VItemBase.ByDayListFromDaysOfWeek(weeklyRecurrencePattern.DaysOfWeek);
                recurrence.WorkWeekStart = weeklyRecurrencePattern.FirstDayOfWeek;
            }
            else if (pattern is MonthlyRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Monthly;
                MonthlyRecurrencePattern monthlyRecurrencePattern = (MonthlyRecurrencePattern)pattern;
                recurrence.ByMonthDay = new int[]
                {
                    monthlyRecurrencePattern.DayOfMonth
                };
            }
            else if (pattern is MonthlyThRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Monthly;
                MonthlyThRecurrencePattern monthlyThRecurrencePattern = (MonthlyThRecurrencePattern)pattern;
                recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(monthlyThRecurrencePattern.DaysOfWeek);
                int order = (int)monthlyThRecurrencePattern.Order;
                if (recurrence.ByDayList.Length == 1)
                {
                    recurrence.ByDayList[0].OccurrenceNumber = order;
                }
                else
                {
                    recurrence.BySetPosition = new int[]
                    {
                        order
                    };
                }
            }
            else if (pattern is YearlyRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Yearly;
                YearlyRecurrencePattern yearlyRecurrencePattern = (YearlyRecurrencePattern)pattern;
                recurrence.ByMonth = new int[]
                {
                    yearlyRecurrencePattern.Month
                };
                recurrence.ByMonthDay = new int[]
                {
                    yearlyRecurrencePattern.DayOfMonth
                };
            }
            else if (pattern is YearlyThRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Yearly;
                YearlyThRecurrencePattern yearlyThRecurrencePattern = (YearlyThRecurrencePattern)pattern;
                recurrence.ByMonth = new int[]
                {
                    yearlyThRecurrencePattern.Month
                };
                recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(yearlyThRecurrencePattern.DaysOfWeek);
                int order2 = (int)yearlyThRecurrencePattern.Order;
                if (recurrence.ByDayList.Length == 1)
                {
                    recurrence.ByDayList[0].OccurrenceNumber = order2;
                }
                else
                {
                    recurrence.BySetPosition = new int[]
                    {
                        order2
                    };
                }
            }
            IntervalRecurrencePattern intervalRecurrencePattern = pattern as IntervalRecurrencePattern;

            if (intervalRecurrencePattern != null)
            {
                recurrence.Interval = intervalRecurrencePattern.RecurrenceInterval;
            }
            else
            {
                recurrence.Interval = 1;
            }
            if (range is EndDateRecurrenceRange)
            {
                EndDateRecurrenceRange endDateRecurrenceRange = (EndDateRecurrenceRange)range;
                recurrence.UntilDateTime = (DateTime)(endDateRecurrenceRange.EndDate + xsoRecurrence.StartOffset).ToUtc();
            }
            else if (range is NumberedRecurrenceRange)
            {
                NumberedRecurrenceRange numberedRecurrenceRange = (NumberedRecurrenceRange)range;
                recurrence.Count = numberedRecurrenceRange.NumberOfOccurrences;
            }
            return(recurrence);
        }
예제 #4
0
 internal TaskRecurrence(RecurrencePattern pattern, RecurrenceRange range, TimeSpan startOffset, TimeSpan endOffset, ExTimeZone timezone, ExTimeZone readTimeZone, ExDateTime?endDateOverride) : base(pattern, range, startOffset, endOffset, timezone, readTimeZone, endDateOverride)
 {
     base.Pattern.RecurrenceObjectType = RecurrenceObjectType.TaskRecurrence;
 }
 public override bool Equals(RecurrenceRange value)
 {
     return(value is NoEndRecurrenceRange && base.Equals(value));
 }