Exemple #1
0
        /// <summary>
        /// SetNewByDayAppStartTime
        /// </summary>
        /// <param name="app"></param>
        /// <param name="dayOfWeek"></param>
        /// <param name="byDay"></param>
        private void SetNewByDayAppStartTime(
            Appointment app, DayOfWeek dayOfWeek, int byDay)
        {
            DateTime date = app.StartTime.AddDays(-app.StartTime.Day + 1);

            if (byDay >= 0)
            {
                while (date.DayOfWeek != dayOfWeek)
                    date = date.AddDays(1);

                if (byDay > 0)
                    date = date.AddDays((byDay - 1) * 7);
            }
            else
            {
                date = date.AddMonths(1).AddDays(-1);

                while (date.DayOfWeek != dayOfWeek)
                    date = date.AddDays(-1);
            }

            if (app.StartTime != date)
                app.MoveTo(date);
        }
Exemple #2
0
        private void AddYearlyByMonthDay(CalendarModel model,
            Appointment app, int byMonth, int byMonthDay, VEventData evData)
        {
            AppointmentRecurrence recur = new AppointmentRecurrence();

            recur.RecurrenceType = eRecurrencePatternType.Yearly;

            recur.Yearly.RepeatOnMonth = byMonth;
            recur.Yearly.RepeatOnRelativeDayInMonth = eRelativeDayInMonth.None;
            recur.Yearly.RepeatOnDayOfMonth = byMonthDay;

            if (app.Recurrence != null)
            {
                app = app.Copy();

                evData.UidApps.Add(app);
            }

            model.Appointments.Add(app);

            int day = DateTime.DaysInMonth(app.StartTime.Year, byMonth);

            if (day < byMonthDay)
                byMonthDay = day;

            DateTime startTime = new DateTime(app.StartTime.Year,
                byMonth, byMonthDay, app.StartTime.Hour, app.StartTime.Minute, 0);

            if (startTime < app.StartTime)
                recur.SkippedRecurrences.Add(startTime);

            if (app.StartTime != startTime)
                app.MoveTo(startTime);

            ProcessRecurrenceRange(app, recur, evData);

            app.Recurrence = recur;
        }