Esempio n. 1
0
        /// <summary>
        /// <c>Daily</c> recurrence with <c>every weekdays</c> (Monday - Tuesday - Wednesday - Thursday - Friday).
        /// </summary>
        /// <returns></returns>
        public XrmRecurringAppointment Daily()
        {
            SetRecurrence();

            _recurrencePattern = RecurrencePatternType.Daily;
            _isEveryWeekday    = true;
            _dayOfWeeksValue   = (int)DayOfWeek.AllWeekdays;

            return(this);
        }
Esempio n. 2
0
        /// <summary>
        /// <c>Daily</c> recurrence with <c>every X days</c>.
        /// Please note that this includes alldays (weekdays and weekend).
        /// </summary>
        /// <param name="interval"><c>every X days</c> interval value.</param>
        /// <returns></returns>
        public XrmRecurringAppointment Daily(int interval)
        {
            ExceptionThrow.IfEquals(interval, "interval", 0);
            ExceptionThrow.IfNegative(interval, "interval");

            SetRecurrence();

            _recurrencePattern = RecurrencePatternType.Daily;
            _interval          = interval;

            return(this);
        }
Esempio n. 3
0
        /// <summary>
        /// <c>Weekly</c> recurrence.
        /// </summary>
        /// <param name="interval"></param>
        /// <param name="daysOfWeek"></param>
        /// <returns></returns>
        public XrmRecurringAppointment Weekly(int interval, DayOfWeek daysOfWeek)
        {
            ExceptionThrow.IfEquals(interval, "interval", 0);
            ExceptionThrow.IfNegative(interval, "interval");

            SetRecurrence();

            _recurrencePattern = RecurrencePatternType.Weekly;
            _interval          = interval;
            _dayOfWeeksValue   = (int)daysOfWeek;

            return(this);
        }
Esempio n. 4
0
        /// <summary>
        /// <c>Monthly</c> recurrence.
        /// </summary>
        /// <param name="option"></param>
        /// <param name="day"></param>
        /// <param name="interval"></param>
        /// <returns></returns>
        public XrmRecurringAppointment Monthly(MonthlyOption option, DayOfWeek day, int interval)
        {
            ExceptionThrow.IfEquals(interval, "interval", 0);
            ExceptionThrow.IfNegative(interval, "interval");

            SetRecurrence();

            _recurrencePattern = RecurrencePatternType.Monthly;
            _monthlyOption     = option;
            _interval          = interval;
            _dayOfWeeksValue   = (int)day;

            return(this);
        }
Esempio n. 5
0
        /// <summary>
        /// <c>Yearly</c> recurrence with exact date.
        /// </summary>
        /// <param name="month"></param>
        /// <param name="day"></param>
        /// <param name="interval"><c>Recur every X years</c> interval.</param>
        /// <returns></returns>
        public XrmRecurringAppointment Yearly(Month month, int day, int interval)
        {
            ExceptionThrow.IfEquals(day, "day", 0);
            ExceptionThrow.IfNegative(day, "day");

            SetRecurrence();

            _isFirstOption     = true;
            _recurrencePattern = RecurrencePatternType.Yearly;
            _interval          = interval;
            _dayNumber         = day;
            _month             = month;

            return(this);
        }
Esempio n. 6
0
        /// <summary>
        /// <c>Monthly</c> recurrence with exact day.
        /// </summary>
        /// <param name="onDay">Excat day number</param>
        /// <param name="interval"><c>Every X months</c> interval value.</param>
        /// <returns></returns>
        public XrmRecurringAppointment Monthly(int onDay, int interval)
        {
            ExceptionThrow.IfEquals(onDay, "onDay", 0);
            ExceptionThrow.IfNegative(onDay, "onDay");
            ExceptionThrow.IfEquals(interval, "interval", 0);
            ExceptionThrow.IfNegative(interval, "interval");

            SetRecurrence();

            _isFirstOption     = true;
            _recurrencePattern = RecurrencePatternType.Monthly;
            _interval          = interval;
            _dayNumber         = onDay;

            return(this);
        }
Esempio n. 7
0
        async void OnRecurrenceTypeClicked(Object sender, EventArgs args)
        {
            var recurrenceType = await DisplayActionSheet(SampleStrings.RecurrenceTypeChoiceText, null, null, SampleStrings.DailyText, SampleStrings.WeeklyText, SampleStrings.MonthlyText);

            if (recurrenceType == SampleStrings.DailyText)
            {
                UpdateRecurrencePatternType = RecurrencePatternType.Daily;
                DailylLabel.Text            = SampleStrings.EveryWeekdayText;
                DailylLabel.IsVisible       = true;
                WeeklyStack.IsVisible       = false;
                MonthlyStack.IsVisible      = false;
            }
            else if (recurrenceType == SampleStrings.WeeklyText)
            {
                UpdateRecurrencePatternType = RecurrencePatternType.Weekly;
                DaysOfWeekButton.Text       = SampleStrings.SelectButtonText;
                EveryWeekLabel.Text         = SampleStrings.EveryText + " ";
                WeeklyLabel.Text            = SampleStrings.WeeklyLabelText + " ";
                WeeklyDayOfWeek.Text        = SampleStrings.SelectDayText;
                WeeklyStack.IsVisible       = true;
                DailylLabel.IsVisible       = false;
                MonthlyStack.IsVisible      = false;
            }
            else if (recurrenceType == SampleStrings.MonthlyText)
            {
                UpdateRecurrencePatternType = RecurrencePatternType.AbsoluteMonthly;
                MonthlyStack.IsVisible      = true;
                MonthDayLabel.Text          = SampleStrings.DayText + " ";
                OfEveryLabel.Text           = SampleStrings.OfEveryText + " ";
                MonthSingPluralLabel.Text   = SampleStrings.MonthlyLabelText;
                DailylLabel.IsVisible       = false;
                WeeklyStack.IsVisible       = false;
            }
            else
            {
                UpdateRecurrencePatternType = RecurrencePatternType.AbsoluteYearly;
                DailylLabel.IsVisible       = false;
                WeeklyStack.IsVisible       = false;
                MonthlyStack.IsVisible      = false;
            }
        }
Esempio n. 8
0
        public static string ConvertPatternToString(RecurrencePatternType source)
        {
            string day = "";

            foreach (var token in Enum.GetValues(typeof(RecurrencePatternType)))
            {
                RecurrencePatternType value = source & (RecurrencePatternType)token;
                switch (value)
                {
                case RecurrencePatternType.Daily:
                    return("DAILY");

                case RecurrencePatternType.Monthly:
                    return("MONTHLY");

                case RecurrencePatternType.Weekly:
                    return("WEEKLY");

                case RecurrencePatternType.Yearly:
                    return("YEARLY");
                }
            }
            return(day);
        }
        private void Parse(byte[] buffer)
        {
            if (buffer.Length < 22)
            {
                return;
            }

            short frequencyValue = BitConverter.ToInt16(buffer, 4);

            this.frequency = EnumUtil.ParseRecurrencePatternFrequency(frequencyValue);

            short typeValue = BitConverter.ToInt16(buffer, 6);

            this.type = EnumUtil.ParseRecurrencePatternType(typeValue);

            short calendarTypeValue = BitConverter.ToInt16(buffer, 8);

            this.calendarType = EnumUtil.ParseCalendarType(calendarTypeValue);

            short firstDateTimeValue = BitConverter.ToInt16(buffer, 10);

            period = BitConverter.ToInt16(buffer, 14);

            int nextPosition = 22;

            if (this.type == RecurrencePatternType.Day)
            {
                //skip
            }
            else if (this.type == RecurrencePatternType.Week)
            {
                int dayOfWeekValue = BitConverter.ToInt32(buffer, nextPosition);
                nextPosition += 4;

                IList <Independentsoft.Msg.DayOfWeek> list = new List <Independentsoft.Msg.DayOfWeek>();

                if ((dayOfWeekValue & 0x00000001) == 0x00000001)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Sunday);
                }

                if ((dayOfWeekValue & 0x00000002) == 0x00000002)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Monday);
                }

                if ((dayOfWeekValue & 0x00000004) == 0x00000004)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Tuesday);
                }

                if ((dayOfWeekValue & 0x00000008) == 0x00000008)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Wednesday);
                }

                if ((dayOfWeekValue & 0x00000010) == 0x00000010)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Thursday);
                }

                if ((dayOfWeekValue & 0x00000020) == 0x00000020)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Friday);
                }

                if ((dayOfWeekValue & 0x00000040) == 0x00000040)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Saturday);
                }

                dayOfWeek = new DayOfWeek[list.Count];

                for (int i = 0; i < list.Count; i++)
                {
                    dayOfWeek[i] = (Independentsoft.Msg.DayOfWeek)list[i];
                }
            }
            else if (this.type == RecurrencePatternType.Month || this.type == RecurrencePatternType.HijriMonth)
            {
                dayOfMonth    = BitConverter.ToInt32(buffer, nextPosition);
                nextPosition += 4;
            }
            else if (this.type == RecurrencePatternType.MonthEnd || this.type == RecurrencePatternType.HijriMonthEnd || this.type == RecurrencePatternType.MonthNth || this.type == RecurrencePatternType.HijriMonthNth)
            {
                if (buffer.Length < 50)
                {
                    return;
                }

                int dayOfWeekValue = BitConverter.ToInt32(buffer, nextPosition);
                nextPosition += 4;

                int dayOfWeekIndexValue = BitConverter.ToInt32(buffer, nextPosition);
                nextPosition += 4;

                IList <Independentsoft.Msg.DayOfWeek> list = new List <Independentsoft.Msg.DayOfWeek>();

                if ((dayOfWeekValue & 0x00000001) == 0x00000001)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Sunday);
                }

                if ((dayOfWeekValue & 0x00000002) == 0x00000002)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Monday);
                }

                if ((dayOfWeekValue & 0x00000004) == 0x00000004)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Tuesday);
                }

                if ((dayOfWeekValue & 0x00000008) == 0x00000008)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Wednesday);
                }

                if ((dayOfWeekValue & 0x00000010) == 0x00000010)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Thursday);
                }

                if ((dayOfWeekValue & 0x00000020) == 0x00000020)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Friday);
                }

                if ((dayOfWeekValue & 0x00000040) == 0x00000040)
                {
                    list.Add(Independentsoft.Msg.DayOfWeek.Saturday);
                }

                dayOfWeek = new DayOfWeek[list.Count];

                for (int i = 0; i < list.Count; i++)
                {
                    dayOfWeek[i] = (Independentsoft.Msg.DayOfWeek)list[i];
                }

                if (dayOfWeekIndexValue == 0x00000001)
                {
                    dayOfWeekIndex = DayOfWeekIndex.First;
                }
                else if (dayOfWeekIndexValue == 0x00000002)
                {
                    dayOfWeekIndex = DayOfWeekIndex.Second;
                }
                else if (dayOfWeekIndexValue == 0x00000003)
                {
                    dayOfWeekIndex = DayOfWeekIndex.Third;
                }
                else if (dayOfWeekIndexValue == 0x00000004)
                {
                    dayOfWeekIndex = DayOfWeekIndex.Fourth;
                }
                else if (dayOfWeekIndexValue == 0x00000005)
                {
                    dayOfWeekIndex = DayOfWeekIndex.Last;
                }
            }

            int endTypeValue = BitConverter.ToInt32(buffer, nextPosition);

            nextPosition += 4;

            this.endType = EnumUtil.ParseRecurrenceEndType(endTypeValue);

            occurenceCount = BitConverter.ToInt32(buffer, nextPosition);
            nextPosition  += 4;

            int firstDayOfWeekValue = BitConverter.ToInt32(buffer, nextPosition);

            nextPosition += 4;

            this.firstDayOfWeek = EnumUtil.ParseDayOfWeek(firstDayOfWeekValue);

            deletedInstanceCount = BitConverter.ToInt32(buffer, nextPosition);
            nextPosition        += 4;

            if (deletedInstanceCount > 0)
            {
                deletedInstanceDates = new DateTime[deletedInstanceCount];

                for (int i = 0; i < deletedInstanceCount; i++)
                {
                    if (buffer.Length < nextPosition + 4)
                    {
                        return;
                    }

                    int minutes = BitConverter.ToInt32(buffer, nextPosition);
                    nextPosition += 4;

                    deletedInstanceDates[i] = Util.GetDateTime(minutes);
                }
            }

            modifiedInstanceCount = BitConverter.ToInt32(buffer, nextPosition);
            nextPosition         += 4;

            if (modifiedInstanceCount > 0)
            {
                modifiedInstanceDates = new DateTime[modifiedInstanceCount];

                for (int i = 0; i < modifiedInstanceCount; i++)
                {
                    if (buffer.Length < nextPosition + 4)
                    {
                        return;
                    }

                    int minutes = BitConverter.ToInt32(buffer, nextPosition);
                    nextPosition += 4;

                    modifiedInstanceDates[i] = Util.GetDateTime(minutes);
                }
            }

            if (buffer.Length < nextPosition + 4)
            {
                return;
            }

            int startDateMinutes = BitConverter.ToInt32(buffer, nextPosition);

            nextPosition += 4;

            this.startDate = Util.GetDateTime(startDateMinutes);

            int endDateMinutes = BitConverter.ToInt32(buffer, nextPosition);

            this.endDate = Util.GetDateTime(endDateMinutes);
        }
Esempio n. 10
0
 /// <summary>
 ///
 /// </summary>
 public XrmRecurringAppointment()
 {
     _isInit            = true;
     _recurrencePattern = RecurrencePatternType.Daily;
 }
Esempio n. 11
0
        public static Microsoft.Exchange.Connections.Eas.Model.Request.Calendar.Recurrence GetRecurrenceData(PatternedRecurrence recurrence)
        {
            if (recurrence == null)
            {
                return(null);
            }
            Microsoft.Exchange.Connections.Eas.Model.Request.Calendar.Recurrence recurrence2 = new Microsoft.Exchange.Connections.Eas.Model.Request.Calendar.Recurrence();
            recurrence2.Interval = new ushort?((ushort)recurrence.Pattern.Interval);
            RecurrencePatternType type = recurrence.Pattern.Type;

            switch (type)
            {
            case RecurrencePatternType.Daily:
            {
                DailyRecurrencePattern dailyRecurrencePattern = (DailyRecurrencePattern)recurrence.Pattern;
                recurrence2.Type = 0;
                break;
            }

            case RecurrencePatternType.Weekly:
            {
                WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)recurrence.Pattern;
                recurrence2.Type      = 1;
                recurrence2.DayOfWeek = new ushort?(SyncCalendarUtils.GetDayOfWeekValue(weeklyRecurrencePattern.DaysOfWeek));
                break;
            }

            case RecurrencePatternType.AbsoluteMonthly:
            {
                AbsoluteMonthlyRecurrencePattern absoluteMonthlyRecurrencePattern = (AbsoluteMonthlyRecurrencePattern)recurrence.Pattern;
                recurrence2.Type       = 2;
                recurrence2.DayOfMonth = new byte?((byte)absoluteMonthlyRecurrencePattern.DayOfMonth);
                break;
            }

            case RecurrencePatternType.RelativeMonthly:
            {
                RelativeMonthlyRecurrencePattern relativeMonthlyRecurrencePattern = (RelativeMonthlyRecurrencePattern)recurrence.Pattern;
                recurrence2.Type        = 3;
                recurrence2.DayOfWeek   = new ushort?(SyncCalendarUtils.GetDayOfWeekValue(relativeMonthlyRecurrencePattern.DaysOfWeek));
                recurrence2.WeekOfMonth = new byte?((byte)relativeMonthlyRecurrencePattern.Index);
                break;
            }

            case RecurrencePatternType.AbsoluteYearly:
            {
                AbsoluteYearlyRecurrencePattern absoluteYearlyRecurrencePattern = (AbsoluteYearlyRecurrencePattern)recurrence.Pattern;
                recurrence2.Type        = 5;
                recurrence2.DayOfMonth  = new byte?((byte)absoluteYearlyRecurrencePattern.DayOfMonth);
                recurrence2.MonthOfYear = new byte?((byte)absoluteYearlyRecurrencePattern.Month);
                break;
            }

            case RecurrencePatternType.RelativeYearly:
            {
                RelativeYearlyRecurrencePattern relativeYearlyRecurrencePattern = (RelativeYearlyRecurrencePattern)recurrence.Pattern;
                recurrence2.Type        = 6;
                recurrence2.DayOfWeek   = new ushort?(SyncCalendarUtils.GetDayOfWeekValue(relativeYearlyRecurrencePattern.DaysOfWeek));
                recurrence2.WeekOfMonth = new byte?((byte)relativeYearlyRecurrencePattern.Index);
                recurrence2.MonthOfYear = new byte?((byte)relativeYearlyRecurrencePattern.Month);
                break;
            }

            default:
                throw new EasSyncFailedPermanentException("Invalid recurrence type: " + type);
            }
            RecurrenceRangeType type2 = recurrence.Range.Type;

            switch (type2)
            {
            case RecurrenceRangeType.EndDate:
            {
                EndDateRecurrenceRange endDateRecurrenceRange = (EndDateRecurrenceRange)recurrence.Range;
                recurrence2.Until = SyncCalendarUtils.ToStringDateTime(endDateRecurrenceRange.EndDate);
                break;
            }

            case RecurrenceRangeType.NoEnd:
                break;

            case RecurrenceRangeType.Numbered:
            {
                NumberedRecurrenceRange numberedRecurrenceRange = (NumberedRecurrenceRange)recurrence.Range;
                recurrence2.Occurrences = new ushort?((ushort)numberedRecurrenceRange.NumberOfOccurrences);
                break;
            }

            default:
                throw new EasSyncFailedPermanentException("Invalid recurrence range type: {0}" + type2);
            }
            return(recurrence2);
        }