示例#1
0
        private static RecurrenceType TaskRecurrencePatternToRecurrenceType(TaskRecurrence taskRecurrence)
        {
            if (taskRecurrence == null)
            {
                return(RecurrenceType.None);
            }
            RecurrencePattern pattern = taskRecurrence.Pattern;

            if (pattern is DailyRegeneratingPattern)
            {
                return(RecurrenceType.DailyRegenerating);
            }
            if (pattern is WeeklyRegeneratingPattern)
            {
                return(RecurrenceType.WeeklyRegenerating);
            }
            if (pattern is MonthlyRegeneratingPattern)
            {
                return(RecurrenceType.MonthlyRegenerating);
            }
            if (pattern is YearlyRegeneratingPattern)
            {
                return(RecurrenceType.YearlyRegenerating);
            }
            if (pattern is DailyRecurrencePattern)
            {
                return(RecurrenceType.Daily);
            }
            if (pattern is WeeklyRecurrencePattern)
            {
                return(RecurrenceType.Weekly);
            }
            if (pattern is MonthlyRecurrencePattern || pattern is MonthlyThRecurrencePattern)
            {
                return(RecurrenceType.Monthly);
            }
            if (pattern is YearlyRecurrencePattern || pattern is YearlyThRecurrencePattern)
            {
                return(RecurrenceType.Yearly);
            }
            return(RecurrenceType.None);
        }
        public override bool Equals(RecurrencePattern value, bool ignoreCalendarTypeAndIsLeapMonth)
        {
            MonthlyRegeneratingPattern monthlyRegeneratingPattern = value as MonthlyRegeneratingPattern;

            return(monthlyRegeneratingPattern != null && (ignoreCalendarTypeAndIsLeapMonth || monthlyRegeneratingPattern.CalendarType == this.CalendarType) && base.Equals(value, ignoreCalendarTypeAndIsLeapMonth));
        }
 public override bool Equals(RecurrencePattern value, bool ignoreCalendarTypeAndIsLeapMonth)
 {
     return(value is DailyRegeneratingPattern && base.Equals(value, ignoreCalendarTypeAndIsLeapMonth));
 }
示例#4
0
		private void SetPatternSpecificProperties(RecurrencePattern pattern)
		{
			if (pattern is DailyRecurrencePattern)
			{
				DailyRecurrencePattern dailyRecurrencePattern = (DailyRecurrencePattern)pattern;
				this.Group = RecurrenceGroup.Daily;
				this.Type = RecurrenceTypeInBlob.Minute;
				this.Period = dailyRecurrencePattern.RecurrenceInterval * 24 * 60;
				return;
			}
			if (pattern is WeeklyRecurrencePattern)
			{
				WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)pattern;
				this.Group = RecurrenceGroup.Weekly;
				this.Type = RecurrenceTypeInBlob.Week;
				this.Period = weeklyRecurrencePattern.RecurrenceInterval;
				this.DayMask = weeklyRecurrencePattern.DaysOfWeek;
				this.FirstDayOfWeek = (int)((WeeklyRecurrencePattern)pattern).FirstDayOfWeek;
				return;
			}
			if (pattern is MonthlyRecurrencePattern)
			{
				MonthlyRecurrencePattern monthlyRecurrencePattern = (MonthlyRecurrencePattern)pattern;
				this.Group = RecurrenceGroup.Monthly;
				this.Type = ((monthlyRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonth : RecurrenceTypeInBlob.Month);
				this.Period = monthlyRecurrencePattern.RecurrenceInterval;
				this.DayOfMonth = monthlyRecurrencePattern.DayOfMonth;
				return;
			}
			if (pattern is YearlyRecurrencePattern)
			{
				YearlyRecurrencePattern yearlyRecurrencePattern = (YearlyRecurrencePattern)pattern;
				this.Group = RecurrenceGroup.Yearly;
				this.Type = ((yearlyRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonth : RecurrenceTypeInBlob.Month);
				this.DayOfMonth = yearlyRecurrencePattern.DayOfMonth;
				this.Period = 12;
				return;
			}
			if (pattern is MonthlyThRecurrencePattern)
			{
				MonthlyThRecurrencePattern monthlyThRecurrencePattern = (MonthlyThRecurrencePattern)pattern;
				this.Group = RecurrenceGroup.Monthly;
				this.Type = ((monthlyThRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonthNth : RecurrenceTypeInBlob.MonthNth);
				this.DayMask = monthlyThRecurrencePattern.DaysOfWeek;
				this.NthOccurrence = monthlyThRecurrencePattern.Order;
				this.Period = monthlyThRecurrencePattern.RecurrenceInterval;
				return;
			}
			if (pattern is YearlyThRecurrencePattern)
			{
				YearlyThRecurrencePattern yearlyThRecurrencePattern = (YearlyThRecurrencePattern)pattern;
				this.Group = RecurrenceGroup.Yearly;
				this.Type = ((yearlyThRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonthNth : RecurrenceTypeInBlob.MonthNth);
				this.DayMask = yearlyThRecurrencePattern.DaysOfWeek;
				this.NthOccurrence = yearlyThRecurrencePattern.Order;
				this.MonthOfYear = yearlyThRecurrencePattern.Month;
				this.Period = 12;
				return;
			}
			if (pattern is DailyRegeneratingPattern)
			{
				DailyRegeneratingPattern dailyRegeneratingPattern = (DailyRegeneratingPattern)pattern;
				this.Type = RecurrenceTypeInBlob.Minute;
				this.Group = RecurrenceGroup.Daily;
				this.Period = dailyRegeneratingPattern.RecurrenceInterval * 24 * 60;
				return;
			}
			if (pattern is WeeklyRegeneratingPattern)
			{
				WeeklyRegeneratingPattern weeklyRegeneratingPattern = (WeeklyRegeneratingPattern)pattern;
				this.Type = RecurrenceTypeInBlob.Minute;
				this.Group = RecurrenceGroup.Weekly;
				this.DayMask = DaysOfWeek.Monday;
				this.Period = weeklyRegeneratingPattern.RecurrenceInterval * 7 * 24 * 60;
				return;
			}
			if (pattern is MonthlyRegeneratingPattern)
			{
				MonthlyRegeneratingPattern monthlyRegeneratingPattern = (MonthlyRegeneratingPattern)pattern;
				this.Type = RecurrenceTypeInBlob.MonthNth;
				this.Group = RecurrenceGroup.Monthly;
				this.DayMask = DaysOfWeek.Monday;
				this.NthOccurrence = (RecurrenceOrderType)0;
				this.Period = monthlyRegeneratingPattern.RecurrenceInterval;
				return;
			}
			if (pattern is YearlyRegeneratingPattern)
			{
				YearlyRegeneratingPattern yearlyRegeneratingPattern = (YearlyRegeneratingPattern)pattern;
				this.Type = RecurrenceTypeInBlob.Month;
				this.Group = RecurrenceGroup.Yearly;
				this.DayOfMonth = 1;
				this.Period = 12 * yearlyRegeneratingPattern.RecurrenceInterval;
			}
		}
示例#5
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);
        }
示例#6
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(RecurrencePattern value, bool ignoreCalendarTypeAndIsLeapMonth)
 {
     return(value is RegeneratingPattern && ((RegeneratingPattern)value).RecurrenceInterval == base.RecurrenceInterval);
 }