/// <summary>
    /// Gets the scheduler recurrence day.
    /// </summary>
    /// <param name="byDay">The by day.</param>
    /// <returns></returns>
    private static RecurrenceDay GetSchedulerRecurrenceDay(IList <IWeekDay> byDay)
    {
        RecurrenceDay schedulerRecurrenceDay = RecurrenceDay.None;

        foreach (WeekDay daySpecifier in byDay)
        {
            switch (daySpecifier.DayOfWeek)
            {
            case DayOfWeek.Monday:
                schedulerRecurrenceDay |= RecurrenceDay.Monday;
                break;

            case DayOfWeek.Tuesday:
                schedulerRecurrenceDay |= RecurrenceDay.Tuesday;
                break;

            case DayOfWeek.Wednesday:
                schedulerRecurrenceDay |= RecurrenceDay.Wednesday;
                break;

            case DayOfWeek.Thursday:
                schedulerRecurrenceDay |= RecurrenceDay.Thursday;
                break;

            case DayOfWeek.Friday:
                schedulerRecurrenceDay |= RecurrenceDay.Friday;
                break;

            default:
                break;
            }
        }
        return(schedulerRecurrenceDay);
    }
		public static string ConvertFromRecurrenceDay(RecurrenceDay recurrenceDay, bool useWildcards)
		{
			if (useWildcards)
			{
				if ((recurrenceDay & RecurrenceDay.EveryDay) == RecurrenceDay.EveryDay)
				{
					return "Day";
				}

				if ((recurrenceDay & RecurrenceDay.WeekDays) == RecurrenceDay.WeekDays)
				{
					return "Weekday";
				}

				if ((recurrenceDay & RecurrenceDay.WeekendDays) == RecurrenceDay.WeekendDays)
				{
					return "WeekendDay";
				}
			}

			StringBuilder result = new StringBuilder();

			if ((recurrenceDay & RecurrenceDay.Monday) == RecurrenceDay.Monday)
			{
				result.Append("Monday ");
			}

			if ((recurrenceDay & RecurrenceDay.Tuesday) == RecurrenceDay.Tuesday)
			{
				result.Append("Tuesday ");
			}

			if ((recurrenceDay & RecurrenceDay.Wednesday) == RecurrenceDay.Wednesday)
			{
				result.Append("Wednesday ");
			}

			if ((recurrenceDay & RecurrenceDay.Thursday) == RecurrenceDay.Thursday)
			{
				result.Append("Thursday ");
			}

			if ((recurrenceDay & RecurrenceDay.Friday) == RecurrenceDay.Friday)
			{
				result.Append("Friday ");
			}

			if ((recurrenceDay & RecurrenceDay.Saturday) == RecurrenceDay.Saturday)
			{
				result.Append("Saturday ");
			}

			if ((recurrenceDay & RecurrenceDay.Sunday) == RecurrenceDay.Sunday)
			{
				result.Append("Sunday ");
			}


			return result.ToString().Trim();
		}
        public static string ConvertFromRecurrenceDay(RecurrenceDay recurrenceDay, bool useWildcards)
        {
            if (useWildcards)
            {
                if ((recurrenceDay & RecurrenceDay.EveryDay) == RecurrenceDay.EveryDay)
                {
                    return("Day");
                }

                if ((recurrenceDay & RecurrenceDay.WeekDays) == RecurrenceDay.WeekDays)
                {
                    return("Weekday");
                }

                if ((recurrenceDay & RecurrenceDay.WeekendDays) == RecurrenceDay.WeekendDays)
                {
                    return("WeekendDay");
                }
            }

            StringBuilder result = new StringBuilder();

            if ((recurrenceDay & RecurrenceDay.Monday) == RecurrenceDay.Monday)
            {
                result.Append("Monday ");
            }

            if ((recurrenceDay & RecurrenceDay.Tuesday) == RecurrenceDay.Tuesday)
            {
                result.Append("Tuesday ");
            }

            if ((recurrenceDay & RecurrenceDay.Wednesday) == RecurrenceDay.Wednesday)
            {
                result.Append("Wednesday ");
            }

            if ((recurrenceDay & RecurrenceDay.Thursday) == RecurrenceDay.Thursday)
            {
                result.Append("Thursday ");
            }

            if ((recurrenceDay & RecurrenceDay.Friday) == RecurrenceDay.Friday)
            {
                result.Append("Friday ");
            }

            if ((recurrenceDay & RecurrenceDay.Saturday) == RecurrenceDay.Saturday)
            {
                result.Append("Saturday ");
            }

            if ((recurrenceDay & RecurrenceDay.Sunday) == RecurrenceDay.Sunday)
            {
                result.Append("Sunday ");
            }


            return(result.ToString().Trim());
        }
Esempio n. 4
0
        private MonthlyRecurrenceRule(int dayOfMonth, int interval, int dayOrdinal, RecurrenceDay daysOfWeekMask, RecurrenceRange range)
        {
            rulePattern.Frequency      = RecurrenceFrequency.Monthly;
            rulePattern.Interval       = interval;
            rulePattern.DaysOfWeekMask = daysOfWeekMask;
            rulePattern.DayOfMonth     = dayOfMonth;
            rulePattern.DayOrdinal     = dayOrdinal;
            rulePattern.Month          = RecurrenceMonth.None;

            ruleRange = range;
        }
Esempio n. 5
0
        /// <summary>
        ///     Initializes a new instance of <see cref="WeeklyRecurrenceRule"/> with the
        ///     specified interval, days of week bit mask and <see cref="RecurrenceRange"/>.
        /// </summary>
        /// <param name="interval">The number of weeks between the occurrences.</param>
        /// <param name="daysOfWeekMask">A bit mask that specifies the week days on which the event recurs.</param>
        /// <param name="range">
        ///     The <see cref="RecurrenceRange"/> instance that specifies the range of this rule.
        /// </param>
        public WeeklyRecurrenceRule(int interval, RecurrenceDay daysOfWeekMask, RecurrenceRange range)
        {
            rulePattern.Frequency      = RecurrenceFrequency.Weekly;
            rulePattern.Interval       = interval;
            rulePattern.DaysOfWeekMask = daysOfWeekMask;
            rulePattern.DayOfMonth     = 0;
            rulePattern.DayOrdinal     = 0;
            rulePattern.Month          = RecurrenceMonth.None;

            ruleRange = range;
        }
Esempio n. 6
0
        /// <summary>
        /// Adds the day to list.
        /// </summary>
        /// <param name="daysOfWeekMask">The days of week mask.</param>
        /// <param name="daysOfWeek">The days of week.</param>
        /// <param name="recurrenceDay">The recurrence day.</param>
        /// <param name="dayOfWeek">The day of week.</param>
        private static void AddDayToList(RecurrenceDay daysOfWeekMask, StringBuilder daysOfWeek, RecurrenceDay recurrenceDay, DayOfWeek dayOfWeek)
        {
            if ((daysOfWeekMask & recurrenceDay) != 0)
            {
                if (daysOfWeek.Length > 0)
                {
                    daysOfWeek.Append(", ");
                }

                daysOfWeek.Append(CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(dayOfWeek));
            }
        }
        public static RecurrenceDay ConvertToRecurrenceDay(string daysOfWeek)
        {
            RecurrenceDay finalMask = RecurrenceDay.None;

            foreach (string day in daysOfWeek.Split(' '))
            {
                switch (day)
                {
                case "Monday":
                    finalMask |= RecurrenceDay.Monday;
                    break;

                case "Tuesday":
                    finalMask |= RecurrenceDay.Tuesday;
                    break;

                case "Wednesday":
                    finalMask |= RecurrenceDay.Wednesday;
                    break;

                case "Thursday":
                    finalMask |= RecurrenceDay.Thursday;
                    break;

                case "Friday":
                    finalMask |= RecurrenceDay.Friday;
                    break;

                case "Saturday":
                    finalMask |= RecurrenceDay.Saturday;
                    break;

                case "Sunday":
                    finalMask |= RecurrenceDay.Sunday;
                    break;

                case "WeekendDay":
                    finalMask |= RecurrenceDay.WeekendDays;
                    break;

                case "Weekday":
                    finalMask |= RecurrenceDay.WeekDays;
                    break;

                case "Day":
                    finalMask |= RecurrenceDay.EveryDay;
                    break;
                }
            }
            return(finalMask);
        }
Esempio n. 8
0
        /// <summary>
        /// Gets a comma-delimited list of the days of week from the given <paramref name="daysOfWeekMask"/> with localized day names.
        /// </summary>
        /// <param name="daysOfWeekMask">The days of week mask.</param>
        /// <returns>A list of the days of week from the given <paramref name="daysOfWeekMask"/> with localized day names</returns>
        private static string GetDaysOfWeekList(RecurrenceDay daysOfWeekMask)
        {
            var daysOfWeek = new StringBuilder();

            AddDayToList(daysOfWeekMask, daysOfWeek, RecurrenceDay.Sunday, DayOfWeek.Sunday);
            AddDayToList(daysOfWeekMask, daysOfWeek, RecurrenceDay.Monday, DayOfWeek.Monday);
            AddDayToList(daysOfWeekMask, daysOfWeek, RecurrenceDay.Tuesday, DayOfWeek.Tuesday);
            AddDayToList(daysOfWeekMask, daysOfWeek, RecurrenceDay.Wednesday, DayOfWeek.Wednesday);
            AddDayToList(daysOfWeekMask, daysOfWeek, RecurrenceDay.Thursday, DayOfWeek.Thursday);
            AddDayToList(daysOfWeekMask, daysOfWeek, RecurrenceDay.Friday, DayOfWeek.Friday);
            AddDayToList(daysOfWeekMask, daysOfWeek, RecurrenceDay.Saturday, DayOfWeek.Saturday);

            return(daysOfWeek.ToString());
        }
Esempio n. 9
0
        /// <summary>
        /// Gets the localized resource for the day of week.
        /// Uses <see cref="DateTimeFormatInfo.GetDayName"/> if it's a day of the week, otherwise uses localization for composite values.
        /// </summary>
        /// <param name="daysOfWeekMask">The days of week mask.</param>
        /// <param name="resourceFile">The resource file to use to find get localized text.</param>
        /// <returns>
        /// A human-readable, localized representation of the given <paramref name="daysOfWeekMask"/>
        /// </returns>
        private static string GetLocalizedDayOfWeek(RecurrenceDay daysOfWeekMask, string resourceFile)
        {
            DayOfWeek dayOfWeek;

            switch (daysOfWeekMask)
            {
            case RecurrenceDay.Sunday:
                dayOfWeek = DayOfWeek.Sunday;
                break;

            case RecurrenceDay.Monday:
                dayOfWeek = DayOfWeek.Monday;
                break;

            case RecurrenceDay.Tuesday:
                dayOfWeek = DayOfWeek.Tuesday;
                break;

            case RecurrenceDay.Wednesday:
                dayOfWeek = DayOfWeek.Wednesday;
                break;

            case RecurrenceDay.Thursday:
                dayOfWeek = DayOfWeek.Thursday;
                break;

            case RecurrenceDay.Friday:
                dayOfWeek = DayOfWeek.Friday;
                break;

            case RecurrenceDay.Saturday:
                dayOfWeek = DayOfWeek.Saturday;
                break;

            // If it's not a day of the week, it should be a named composite value, like EveryDay, WeekDays, etc.
            default:
                return(Localization.GetString(daysOfWeekMask.ToString(), resourceFile));
            }

            return(CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(dayOfWeek));
        }
Esempio n. 10
0
        public static DayOfWeekType ConvertFromRecurrenceDay(RecurrenceDay recurrenceDay)
        {
            switch (recurrenceDay)
            {
            case RecurrenceDay.Monday:
                return(DayOfWeekType.Monday);

            case RecurrenceDay.Tuesday:
                return(DayOfWeekType.Tuesday);

            case RecurrenceDay.Wednesday:
                return(DayOfWeekType.Wednesday);

            case RecurrenceDay.Thursday:
                return(DayOfWeekType.Thursday);

            case RecurrenceDay.Friday:
                return(DayOfWeekType.Friday);

            case RecurrenceDay.Saturday:
                return(DayOfWeekType.Saturday);

            case RecurrenceDay.Sunday:
                return(DayOfWeekType.Sunday);

            case RecurrenceDay.EveryDay:
                return(DayOfWeekType.Day);

            case RecurrenceDay.WeekDays:
                return(DayOfWeekType.Weekday);

            case RecurrenceDay.WeekendDays:
                return(DayOfWeekType.WeekendDay);
            }

            return(DayOfWeekType.Day);
        }
		public static DayOfWeekType ConvertFromRecurrenceDay(RecurrenceDay recurrenceDay)
		{
			switch (recurrenceDay)
			{
				case RecurrenceDay.Monday:
					return DayOfWeekType.Monday;

				case RecurrenceDay.Tuesday:
					return DayOfWeekType.Tuesday;

				case RecurrenceDay.Wednesday:
					return DayOfWeekType.Wednesday;

				case RecurrenceDay.Thursday:
					return DayOfWeekType.Thursday;

				case RecurrenceDay.Friday:
					return DayOfWeekType.Friday;

				case RecurrenceDay.Saturday:
					return DayOfWeekType.Saturday;

				case RecurrenceDay.Sunday:
					return DayOfWeekType.Sunday;

				case RecurrenceDay.EveryDay:
					return DayOfWeekType.Day;

				case RecurrenceDay.WeekDays:
					return DayOfWeekType.Weekday;

				case RecurrenceDay.WeekendDays:
					return DayOfWeekType.WeekendDay;
			}

			return DayOfWeekType.Day;
		}
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MonthlyRecurrenceRule"/> class.
 /// </summary>
 /// <example>
 ///     <code lang="CS">
 /// using System;
 /// using Micajah.Common.Bll.RecurringSchedule;
 ///
 /// namespace RecurrenceExamples
 /// {
 ///     class MonthlyRecurrenceRuleExample2
 ///     {
 ///         static void Main()
 ///         {
 ///             // Creates a sample appointment that starts at 6/1/2007 3:30 PM (local time) and lasts half an hour.
 ///             Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("6/1/2007 3:30 PM"),
 ///                 Convert.ToDateTime("6/1/2007 4:00 PM"), "Sample appointment");
 ///
 ///             // Creates a recurrence range, that specifies a limit of 10 occurrences for the appointment.
 ///             RecurrenceRange range = new RecurrenceRange();
 ///             range.Start = recurringAppointment.Start;
 ///             range.EventDuration = recurringAppointment.End - recurringAppointment.Start;
 ///             range.MaxOccurrences = 5;
 ///
 ///             // Creates a recurrence rule to repeat the appointment on the last monday of every two months.
 ///             MonthlyRecurrenceRule rrule = new MonthlyRecurrenceRule(-1, RecurrenceDay.Monday, 2, range);
 ///
 ///             Console.WriteLine("Appointment occurrs at the following times: ");
 ///             int ix = 0;
 ///             foreach (DateTime occurrence in rrule.Occurrences)
 ///             {
 ///                 ix = ix + 1;
 ///                 Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime());
 ///             }
 ///         }
 ///     }
 /// }
 ///
 /// /*
 /// This example produces the following results:
 ///
 /// Appointment occurrs at the following times:
 ///  1: 6/25/2007 3:30:00 PM
 ///  2: 8/27/2007 3:30:00 PM
 ///  3: 10/29/2007 2:30:00 PM
 ///  4: 12/31/2007 2:30:00 PM
 ///  5: 2/25/2008 2:30:00 PM
 /// */
 ///     </code>
 ///     <code lang="VB">
 /// Imports System
 /// Imports Micajah.Common.Bll.RecurringSchedule
 ///
 /// Namespace RecurrenceExamples
 ///     Class MonthlyRecurrenceRuleExample2
 ///         Shared Sub Main()
 ///             ' Creates a sample appointment that starts at 6/1/2007 3:30 PM (local time) and lasts half an hour.
 ///             Dim recurringAppointment As New Appointment("1", Convert.ToDateTime("6/1/2007 3:30 PM"), Convert.ToDateTime("6/1/2007 4:00 PM"), "Sample appointment")
 ///
 ///             ' Creates a recurrence range, that specifies a limit of 10 occurrences for the appointment.
 ///             Dim range As New RecurrenceRange()
 ///             range.Start = recurringAppointment.Start
 ///             range.EventDuration = recurringAppointment.[End] - recurringAppointment.Start
 ///             range.MaxOccurrences = 5
 ///
 ///             ' Creates a recurrence rule to repeat the appointment on the last monday of every two months.
 ///             Dim rrule As New MonthlyRecurrenceRule(-1, RecurrenceDay.Monday, 2, range)
 ///
 ///             Console.WriteLine("Appointment occurrs at the following times: ")
 ///             Dim ix As Integer = 0
 ///             For Each occurrence As DateTime In rrule.Occurrences
 ///                 ix = ix + 1
 ///                 Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime())
 ///             Next
 ///         End Sub
 ///     End Class
 /// End Namespace
 ///
 /// '
 /// 'This example produces the following results:
 /// '
 /// 'Appointment occurrs at the following times:
 /// ' 1: 6/25/2007 3:30:00 PM
 /// ' 2: 8/27/2007 3:30:00 PM
 /// ' 3: 10/29/2007 2:30:00 PM
 /// ' 4: 12/31/2007 2:30:00 PM
 /// ' 5: 2/25/2008 2:30:00 PM
 /// '
 ///     </code>
 /// </example>
 /// <param name="dayOrdinal">The day ordinal modifier. See <see cref="RecurrencePattern.DayOrdinal"/> for additional information.</param>
 /// <param name="daysOfWeekMask">A bit mask that specifies the week days on which the event recurs.</param>
 /// <param name="interval">The interval (in months) between the occurrences.</param>
 /// <param name="range">The <see cref="RecurrenceRange"/> instance that specifies the range of this rule.</param>
 public MonthlyRecurrenceRule(int dayOrdinal, RecurrenceDay daysOfWeekMask, int interval, RecurrenceRange range)
     : this(0, interval, dayOrdinal, daysOfWeekMask, range)
 {
 }
Esempio n. 13
0
        private YearlyRecurrenceRule(RecurrenceMonth month, int dayOfMonth, int dayOrdinal, RecurrenceDay daysOfWeekMask, RecurrenceRange range)
        {
            rulePattern.Frequency      = RecurrenceFrequency.Yearly;
            rulePattern.Interval       = 1;
            rulePattern.DaysOfWeekMask = daysOfWeekMask;
            rulePattern.DayOfMonth     = dayOfMonth;
            rulePattern.DayOrdinal     = dayOrdinal;
            rulePattern.Month          = month;

            ruleRange = range;
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="YearlyRecurrenceRule"/> class.
 /// </summary>
 /// <example>
 ///     <code lang="CS">
 /// using System;
 /// using Micajah.Common.Bll.RecurringSchedule;
 ///
 /// namespace RecurrenceExamples
 /// {
 ///     class YearlyRecurrenceRuleExample2
 ///     {
 ///         static void Main()
 ///         {
 ///             // Creates a sample appointment that starts at 4/1/2007 10:00 AM (local time) and lasts half an hour.
 ///             Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("4/1/2007 10:00 AM"),
 ///                 Convert.ToDateTime("4/1/2007 10:30 AM"), "Sample appointment");
 ///
 ///             // Creates a recurrence range, that specifies a limit of 10 occurrences for the appointment.
 ///             RecurrenceRange range = new RecurrenceRange();
 ///             range.Start = recurringAppointment.Start;
 ///             range.EventDuration = recurringAppointment.End - recurringAppointment.Start;
 ///             range.MaxOccurrences = 5;
 ///
 ///             // Creates a recurrence rule to repeat the appointment on the second monday of April each year.
 ///             YearlyRecurrenceRule rrule = new YearlyRecurrenceRule(2, RecurrenceMonth.April, RecurrenceDay.Monday, range);
 ///
 ///             Console.WriteLine("Appointment occurrs at the following times: ");
 ///             int ix = 0;
 ///             foreach (DateTime occurrence in rrule.Occurrences)
 ///             {
 ///                 ix = ix + 1;
 ///                 Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime());
 ///             }
 ///         }
 ///     }
 /// }
 ///
 /// /*
 /// This example produces the following results:
 ///
 /// Appointment occurrs at the following times:
 ///  1: 4/9/2007 10:00:00 AM
 ///  2: 4/14/2008 10:00:00 AM
 ///  3: 4/13/2009 10:00:00 AM
 ///  4: 4/12/2010 10:00:00 AM
 ///  5: 4/11/2011 10:00:00 AM
 /// */
 ///     </code>
 ///     <code lang="VB">
 /// Imports System
 /// Imports Micajah.Common.Bll.RecurringSchedule
 ///
 /// Namespace RecurrenceExamples
 ///     Class YearlyRecurrenceRuleExample2
 ///         Shared Sub Main()
 ///             ' Creates a sample appointment that starts at 4/1/2007 10:00 AM (local time) and lasts half an hour.
 ///             Dim recurringAppointment As New Appointment("1", Convert.ToDateTime("4/1/2007 10:00 AM"), Convert.ToDateTime("4/1/2007 10:30 AM"), "Sample appointment")
 ///
 ///             ' Creates a recurrence range, that specifies a limit of 10 occurrences for the appointment.
 ///             Dim range As New RecurrenceRange()
 ///             range.Start = recurringAppointment.Start
 ///             range.EventDuration = recurringAppointment.[End] - recurringAppointment.Start
 ///             range.MaxOccurrences = 5
 ///
 ///             ' Creates a recurrence rule to repeat the appointment on the second monday of April each year.
 ///             Dim rrule As New YearlyRecurrenceRule(2, RecurrenceMonth.April, RecurrenceDay.Monday, range)
 ///
 ///             Console.WriteLine("Appointment occurrs at the following times: ")
 ///             Dim ix As Integer = 0
 ///             For Each occurrence As DateTime In rrule.Occurrences
 ///                 ix = ix + 1
 ///                 Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime())
 ///             Next
 ///         End Sub
 ///     End Class
 /// End Namespace
 ///
 /// '
 /// 'This example produces the following results:
 /// '
 /// 'Appointment occurrs at the following times:
 /// ' 1: 4/9/2007 10:00:00 AM
 /// ' 2: 4/14/2008 10:00:00 AM
 /// ' 3: 4/13/2009 10:00:00 AM
 /// ' 4: 4/12/2010 10:00:00 AM
 /// ' 5: 4/11/2011 10:00:00 AM
 /// '
 ///     </code>
 /// </example>
 /// <param name="dayOrdinal">The day ordinal modifier. See <see cref="RecurrencePattern.DayOrdinal"/> for additional information.</param>
 /// <param name="month">The month in which the event recurs.</param>
 /// <param name="daysOfWeekMask">A bit mask that specifies the week days on which the event recurs.</param>
 /// <param name="range">The <see cref="RecurrenceRange"/> instance that specifies the range of this rule.</param>
 public YearlyRecurrenceRule(int dayOrdinal, RecurrenceMonth month, RecurrenceDay daysOfWeekMask, RecurrenceRange range)
     : this(month, -1, dayOrdinal, daysOfWeekMask, range)
 {
 }
    /// <summary>
    /// Creates a Recurrence Rule in RadScheduler-friendly format from the RRule of the specified Recurring component.
    /// </summary>
    /// <param name="startDate">The Start Date of the Recurring component.</param>
    /// <param name="endDate">The End Date of the Recurring component.</param>
    /// <param name="recurringComponent">The Recurring component.</param>
    /// <returns>A <see cref="string"/> representation of the RRule in RadScheduler-friendly format.</returns>
    private static string GetSchedulerRecurrenceRule(DateTime startDate, DateTime endDate, RecurringComponent recurringComponent)
    {
        string recurrenceRuleString = String.Empty;

        if ((recurringComponent.RecurrenceRules != null) &&
            (recurringComponent.RecurrenceRules[0] != null))
        {
            RecurrenceRange schedulerRange = new RecurrenceRange();
            schedulerRange.Start         = startDate;
            schedulerRange.EventDuration = endDate - startDate;
            DDay.iCal.RecurrencePattern iCalPattern = (DDay.iCal.RecurrencePattern)recurringComponent.RecurrenceRules[0];
            if (iCalPattern.Count > 0)
            {
                schedulerRange.MaxOccurrences = iCalPattern.Count;
            }
            else if ((iCalPattern.Until != null))//&&   (iCalPattern.IsValidDate(iCalPattern.Until))
            {
                schedulerRange.RecursUntil = iCalPattern.Until.ToLocalTime();
            }
            RecurrenceRule schedulerRRule         = null;
            int            iCallPatternInterval   = iCalPattern.Interval;
            RecurrenceDay  schedulerRecurrenceDay = GetSchedulerRecurrenceDay(iCalPattern.ByDay);
            switch (iCalPattern.Frequency)
            {
            case FrequencyType.Hourly:
                schedulerRRule =
                    new HourlyRecurrenceRule(iCallPatternInterval, schedulerRange);
                break;

            case FrequencyType.Daily:
                if (schedulerRecurrenceDay == RecurrenceDay.None)
                {
                    schedulerRRule =
                        new DailyRecurrenceRule(iCallPatternInterval, schedulerRange);
                }
                else
                {
                    schedulerRRule =
                        new DailyRecurrenceRule(schedulerRecurrenceDay, schedulerRange);
                }
                break;

            case FrequencyType.Weekly:
                if (schedulerRecurrenceDay == RecurrenceDay.None)
                {
                    schedulerRRule =
                        new WeeklyRecurrenceRule(
                            iCallPatternInterval,
                            (RecurrenceDay)startDate.DayOfWeek,
                            schedulerRange,
                            iCalPattern.FirstDayOfWeek);
                }
                else
                {
                    schedulerRRule =
                        new WeeklyRecurrenceRule(
                            iCallPatternInterval,
                            schedulerRecurrenceDay,
                            schedulerRange,
                            iCalPattern.FirstDayOfWeek);
                }
                break;

            case FrequencyType.Monthly:
                if (iCalPattern.ByMonthDay.Count > 0)
                {
                    schedulerRRule = new MonthlyRecurrenceRule(
                        iCalPattern.ByMonthDay[0],
                        iCallPatternInterval,
                        schedulerRange);
                }
                else if (iCalPattern.BySetPosition.Count > 0)
                {
                    schedulerRRule = new MonthlyRecurrenceRule(
                        iCalPattern.BySetPosition[0],
                        schedulerRecurrenceDay,
                        iCallPatternInterval,
                        schedulerRange);
                }
                else
                {
                    schedulerRRule = new MonthlyRecurrenceRule(
                        startDate.Day,
                        iCallPatternInterval,
                        schedulerRange);
                }
                break;

            case FrequencyType.Yearly:
                if (iCalPattern.ByMonth.Count > 0)
                {
                    if (iCalPattern.ByMonthDay.Count > 0)
                    {
                        schedulerRRule = new YearlyRecurrenceRule(
                            (RecurrenceMonth)iCalPattern.ByMonth[0],
                            iCalPattern.ByMonthDay[0],
                            schedulerRange);
                    }
                    else if (iCalPattern.BySetPosition.Count > 0)
                    {
                        schedulerRRule = new YearlyRecurrenceRule(
                            iCalPattern.BySetPosition[0],
                            (RecurrenceMonth)iCalPattern.ByMonth[0],
                            schedulerRecurrenceDay,
                            schedulerRange);
                    }
                    else
                    {
                        schedulerRRule = new YearlyRecurrenceRule(
                            (RecurrenceMonth)iCalPattern.ByMonth[0],
                            startDate.Day,
                            schedulerRange);
                    }
                }
                else
                {
                    schedulerRRule = new YearlyRecurrenceRule(
                        (RecurrenceMonth)startDate.Month,
                        startDate.Day,
                        schedulerRange);
                }
                break;

            default:
                break;
            }
            if (schedulerRRule != null)
            {
                AddRecurrenceExceptions(schedulerRRule, recurringComponent);
                recurrenceRuleString = schedulerRRule.ToString();
            }
        }
        return(recurrenceRuleString);
    }
Esempio n. 16
0
 /// <summary>
 ///     Initializes a new instance of <see cref="WeeklyRecurrenceRule"/> with the
 ///     specified interval, days of week bit mask and <see cref="RecurrenceRange"/>.
 /// </summary>
 /// <param name="interval">The number of weeks between the occurrences.</param>
 /// <param name="daysOfWeekMask">A bit mask that specifies the week days on which the event recurs.</param>
 /// <param name="range">
 ///     The <see cref="RecurrenceRange"/> instance that specifies the range of this rule.
 /// </param>
 /// <param name="firstDayOfWeek">
 ///		The first day of week to use for calculations.
 /// </param>
 public WeeklyRecurrenceRule(int interval, RecurrenceDay daysOfWeekMask, RecurrenceRange range, DayOfWeek firstDayOfWeek)
     : this(interval, daysOfWeekMask, range)
 {
     Pattern.FirstDayOfWeek = firstDayOfWeek;
 }
Esempio n. 17
0
 /// <example>
 ///     <code lang="CS">
 /// using System;
 /// using Micajah.Common.Bll.RecurringSchedule;
 ///
 /// namespace RecurrenceExamples
 /// {
 ///     class DailyRecurrenceRuleExample2
 ///     {
 ///         static void Main()
 ///         {
 ///             // Creates a sample appointment that starts at 6/1/2007 3:30 PM (local time) and lasts half an hour.
 ///             Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("6/1/2007 3:30 PM"),
 ///                 Convert.ToDateTime("6/1/2007 4:00 PM"), "Sample appointment");
 ///
 ///             // Creates a recurrence range, that specifies a limit of 10 occurrences for the appointment.
 ///             RecurrenceRange range = new RecurrenceRange();
 ///             range.Start = recurringAppointment.Start;
 ///             range.EventDuration = recurringAppointment.End - recurringAppointment.Start;
 ///             range.MaxOccurrences = 10;
 ///
 ///             // Creates a recurrence rule to repeat the appointment every week day.
 ///             DailyRecurrenceRule rrule = new DailyRecurrenceRule(RecurrenceDay.WeekDays, range);
 ///
 ///             Console.WriteLine("Appointment occurrs at the following times: ");
 ///             int ix = 0;
 ///             foreach (DateTime occurrence in rrule.Occurrences)
 ///             {
 ///                 ix = ix + 1;
 ///                 Console.WriteLine("{0,2}: {1} ({2})", ix, occurrence.ToLocalTime(), occurrence.DayOfWeek);
 ///             }
 ///         }
 ///     }
 /// }
 ///
 /// /*
 /// This example produces the following results:
 ///
 /// Appointment occurrs at the following times:
 ///  1: 6/1/2007 3:30:00 PM (Friday)
 ///  2: 6/4/2007 3:30:00 PM (Monday)
 ///  3: 6/5/2007 3:30:00 PM (Tuesday)
 ///  4: 6/6/2007 3:30:00 PM (Wednesday)
 ///  5: 6/7/2007 3:30:00 PM (Thursday)
 ///  6: 6/8/2007 3:30:00 PM (Friday)
 ///  7: 6/11/2007 3:30:00 PM (Monday)
 ///  8: 6/12/2007 3:30:00 PM (Tuesday)
 ///  9: 6/13/2007 3:30:00 PM (Wednesday)
 /// 10: 6/14/2007 3:30:00 PM (Thursday)
 /// */
 ///     </code>
 ///     <code lang="VB">
 /// Imports System
 /// Imports Micajah.Common.Bll.RecurringSchedule
 ///
 /// Namespace RecurrenceExamples
 ///     Class DailyRecurrenceRuleExample2
 ///         Shared Sub Main()
 ///             ' Creates a sample appointment that starts at 6/1/2007 3:30 PM (local time) and lasts half an hour.
 ///             Dim recurringAppointment As New Appointment("1", Convert.ToDateTime("6/1/2007 3:30 PM"), Convert.ToDateTime("6/1/2007 4:00 PM"), "Sample appointment")
 ///
 ///             ' Creates a recurrence range, that specifies a limit of 10 occurrences for the appointment.
 ///             Dim range As New RecurrenceRange()
 ///             range.Start = recurringAppointment.Start
 ///             range.EventDuration = recurringAppointment.[End] - recurringAppointment.Start
 ///             range.MaxOccurrences = 10
 ///
 ///             ' Creates a recurrence rule to repeat the appointment every week day.
 ///             Dim rrule As New DailyRecurrenceRule(RecurrenceDay.WeekDays, range)
 ///
 ///             Console.WriteLine("Appointment occurrs at the following times: ")
 ///             Dim ix As Integer = 0
 ///             For Each occurrence As DateTime In rrule.Occurrences
 ///                 ix = ix + 1
 ///                 Console.WriteLine("{0,2}: {1} ({2})", ix, occurrence.ToLocalTime(), occurrence.DayOfWeek)
 ///             Next
 ///         End Sub
 ///     End Class
 /// End Namespace
 ///
 /// '
 /// 'This example produces the following results:
 /// '
 /// 'Appointment occurrs at the following times:
 /// ' 1: 6/1/2007 3:30:00 PM (Friday)
 /// ' 2: 6/4/2007 3:30:00 PM (Monday)
 /// ' 3: 6/5/2007 3:30:00 PM (Tuesday)
 /// ' 4: 6/6/2007 3:30:00 PM (Wednesday)
 /// ' 5: 6/7/2007 3:30:00 PM (Thursday)
 /// ' 6: 6/8/2007 3:30:00 PM (Friday)
 /// ' 7: 6/11/2007 3:30:00 PM (Monday)
 /// ' 8: 6/12/2007 3:30:00 PM (Tuesday)
 /// ' 9: 6/13/2007 3:30:00 PM (Wednesday)
 /// '10: 6/14/2007 3:30:00 PM (Thursday)
 /// '
 ///     </code>
 /// </example>
 /// <summary>
 ///     Initializes a new instance of <see cref="DailyRecurrenceRule"/> with the
 ///     specified days of week bit mask and <see cref="RecurrenceRange"/>.
 /// </summary>
 /// <param name="daysOfWeekMask">A bit mask that specifies the week days on which the event recurs.</param>
 /// <param name="range">
 ///     The <see cref="RecurrenceRange"/> instance that specifies the range of this
 ///     recurrence rule.
 /// </param>
 public DailyRecurrenceRule(RecurrenceDay daysOfWeekMask, RecurrenceRange range)
     : this(1, daysOfWeekMask, range)
 {
 }