// Token: 0x0600121A RID: 4634 RVA: 0x00062608 File Offset: 0x00060808
        private static void PopulateRecurrenceRange(RecurrenceData recurrenceData, RecurrenceRange range)
        {
            EndDateRecurrenceRange  endDateRecurrenceRange  = range as EndDateRecurrenceRange;
            NumberedRecurrenceRange numberedRecurrenceRange = range as NumberedRecurrenceRange;

            if (endDateRecurrenceRange != null)
            {
                recurrenceData.Until = endDateRecurrenceRange.EndDate;
                return;
            }
            if (numberedRecurrenceRange != null)
            {
                recurrenceData.Occurrences = (ushort)numberedRecurrenceRange.NumberOfOccurrences;
            }
        }
        public void SerializeDateValue()
        {
            var now = DateTimeOffset.UtcNow;

            var expectedSerializedString = string.Format("{{\"startDate\":\"{0}\"}}", now.ToString("yyyy-MM-dd"));

            var recurrence = new RecurrenceRange
            {
                StartDate = new Date(now.Year, now.Month, now.Day),
            };

            var serializedString = this.serializer.SerializeObject(recurrence);

            Assert.Equal(expectedSerializedString, serializedString);
        }
示例#3
0
        /// <summary>
        /// Sets the range.
        /// </summary>
        /// <param name="range">The range.</param>
        private void SetRecurrenceRange(RecurrenceRange range)
        {
            this.RepeatIndefinitely.Checked = this.RepeatGivenOccurrences.Checked = this.RepeatUntilGivenDate.Checked = false;
            if (range.MaxOccurrences != int.MaxValue)
            {
                this.RepeatGivenOccurrences.Checked = true;
                this.RangeOccurrencesTextBox.Text   = range.MaxOccurrences.ToString(CultureInfo.InvariantCulture);
            }
            else if (range.RecursUntil != DateTime.MaxValue)
            {
                this.RepeatUntilGivenDate.Checked = true;

                // TODO: only remove a day if it isn't an all day event, if we start to support all day events.  BD
                this.RangeEndDate.SelectedDate = range.RecursUntil.AddDays(-1);
            }
            else
            {
                this.RepeatIndefinitely.Checked = true;
            }
        }
        // Token: 0x060001C6 RID: 454 RVA: 0x00010D1C File Offset: 0x0000EF1C
        public static Recurrence ChangeRecurrenceType(Recurrence recurrence, OwaRecurrenceType newRecurrenceType)
        {
            OwaRecurrenceType owaRecurrenceType = CalendarUtilities.MapRecurrenceType(recurrence);

            if (owaRecurrenceType == newRecurrenceType)
            {
                return(recurrence);
            }
            RecurrencePattern pattern = CalendarUtilities.CreateDefaultRecurrencePattern(newRecurrenceType, recurrence.Range.StartDate);
            RecurrenceRange   range   = CalendarItemData.CloneRecurrenceRange(recurrence.Range);
            Recurrence        result;

            if (recurrence.CreatedExTimeZone != ExTimeZone.UtcTimeZone && recurrence.ReadExTimeZone != ExTimeZone.UtcTimeZone)
            {
                result = new Recurrence(pattern, range, recurrence.CreatedExTimeZone, recurrence.ReadExTimeZone);
            }
            else
            {
                result = new Recurrence(pattern, range);
            }
            return(result);
        }
示例#5
0
        private void ProcessRecurringCalendarItem(Appointment targetAppointment, CalendarItemType calendarItem, RadScheduler owner, ICollection <Appointment> instances)
        {
            targetAppointment.RecurrenceState = RecurrenceState.Master;

            RecurrencePattern pattern = calendarItem.Recurrence.Item.ConvertToRecurrencePattern();

            RecurrenceRange range = calendarItem.Recurrence.Item1.ConvertToRecurrenceRange();

            range.EventDuration = targetAppointment.Duration;
            range.Start         = targetAppointment.Start;

            RecurrenceRule rrule = RecurrenceRule.FromPatternAndRange(pattern, range);

            if (calendarItem.ModifiedOccurrences != null)
            {
                foreach (CalendarItemType modifiedOccurrence in GetModifiedOccurrences(calendarItem))
                {
                    foreach (Appointment aptException in CreateAppointmentsFromCalendarItem(owner, modifiedOccurrence))
                    {
                        aptException.RecurrenceState    = RecurrenceState.Exception;
                        aptException.RecurrenceParentID = calendarItem.ItemId.Id;

                        instances.Add(aptException);
                    }

                    rrule.Exceptions.Add(modifiedOccurrence.OriginalStart);
                }
            }

            if (calendarItem.DeletedOccurrences != null)
            {
                foreach (DeletedOccurrenceInfoType occurenceInfo in calendarItem.DeletedOccurrences)
                {
                    rrule.Exceptions.Add(occurenceInfo.Start);
                }
            }

            targetAppointment.RecurrenceRule = rrule.ToString();
        }
示例#6
0
        public static RecurrenceRangeBaseType CreateFromSchedulerRecurrenceRule(RecurrenceRule schedulerRule, RadScheduler owner)
        {
            RecurrenceRange schedulerRange = schedulerRule.Range;

            DateTime start = schedulerRange.Start;

            //DateTime start = owner.UtcDayStart(schedulerRange.Start);
            if (schedulerRule.Pattern.Frequency == RecurrenceFrequency.Monthly ||
                schedulerRule.Pattern.Frequency == RecurrenceFrequency.Yearly)
            {
                DateTime monthStart = new DateTime(schedulerRange.Start.Year, schedulerRange.Start.Month, 1, 0, 0, 0, DateTimeKind.Utc);
                start = monthStart;
            }

            if (schedulerRange.RecursUntil < DateTime.MaxValue)
            {
                EndDateRecurrenceRangeType range = new EndDateRecurrenceRangeType();
                range.StartDate = start;
                range.EndDate   = schedulerRange.RecursUntil.AddDays(-1);
                return(range);
            }

            if (schedulerRange.MaxOccurrences < int.MaxValue)
            {
                NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
                range.StartDate           = start;
                range.NumberOfOccurrences = schedulerRange.MaxOccurrences;
                return(range);
            }

            NoEndRecurrenceRangeType noEndRange = new NoEndRecurrenceRangeType();

            noEndRange.StartDate = start;

            return(noEndRange);
        }
        public RecurrenceForm(RecurrencePattern pattern, RecurrenceRange range)
        {
            InitializeComponent();
            StringBuilder dow = new StringBuilder();
            int n = dgRecurrencePattern.Rows.Add();
            dgRecurrencePattern.Rows[n].Cells[0].Value = pattern.Type;
            dgRecurrencePattern.Rows[n].Cells[1].Value = pattern.Interval;
            dgRecurrencePattern.Rows[n].Cells[2].Value = pattern.DayOfMonth;
            dgRecurrencePattern.Rows[n].Cells[3].Value = pattern.Month;
            foreach (var item in pattern.DaysOfWeek)
            {
                dow.Append(item + "-");
            }
            dgRecurrencePattern.Rows[n].Cells[4].Value = dow;
            dgRecurrencePattern.Rows[n].Cells[5].Value = pattern.FirstDayOfWeek;
            dgRecurrencePattern.Rows[n].Cells[6].Value = pattern.Index;

            int x = dgRecurrenceRange.Rows.Add();
            dgRecurrenceRange.Rows[n].Cells[0].Value = range.Type;
            dgRecurrenceRange.Rows[n].Cells[1].Value = range.StartDate;
            dgRecurrenceRange.Rows[n].Cells[2].Value = range.EndDate;
            dgRecurrenceRange.Rows[n].Cells[3].Value = range.NumberOfOccurrences;
            dgRecurrenceRange.Rows[n].Cells[4].Value = range.RecurrenceTimeZone;
        }
        public Recurrence Convert(PatternedRecurrence value)
        {
            Recurrence result;

            if (value == null)
            {
                result = null;
            }
            else
            {
                RecurrencePattern recurrencePattern = RecurrenceConverter.PatternConverter.Convert(value.Pattern);
                if (recurrencePattern == null)
                {
                    throw new InvalidRequestException(Strings.ErrorMissingRequiredParameter("Pattern"));
                }
                RecurrenceRange recurrenceRange = RecurrenceConverter.RangeConverter.Convert(value.Range);
                if (recurrenceRange == null)
                {
                    throw new InvalidRequestException(Strings.ErrorMissingRequiredParameter("Range"));
                }
                result = ((this.timeZone == null) ? new Recurrence(recurrencePattern, recurrenceRange) : new Recurrence(recurrencePattern, recurrenceRange, this.timeZone, this.timeZone));
            }
            return(result);
        }
        /// <summary>
        /// create Payload for Meeting Invite to be set to Graph API.
        /// </summary>
        /// <param name="meetingNotificationEntity"> MeetingNotification Entity Object.</param>
        /// <param name="applicationName">Application Name for the Meeting Invite.</param>
        /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
        private async Task <InvitePayload> CreateInvitePayload(MeetingNotificationItemEntity meetingNotificationEntity, string applicationName)
        {
            if (meetingNotificationEntity == null)
            {
                return(null);
            }

            var payload = new InvitePayload();

            var requiredAttendees = meetingNotificationEntity.RequiredAttendees.Split(Common.ApplicationConstants.SplitCharacter, System.StringSplitOptions.RemoveEmptyEntries).Select(e => new Attendee()
            {
                EmailAddress = new EmailAddress()
                {
                    Address = e,
                },
                Type = AttendeeType.Required,
            });
            var optionalAttendees = meetingNotificationEntity.OptionalAttendees?.Split(Common.ApplicationConstants.SplitCharacter, System.StringSplitOptions.RemoveEmptyEntries).Select(e => new Attendee()
            {
                EmailAddress = new EmailAddress()
                {
                    Address = e,
                },
                Type = AttendeeType.Optional,
            });

            payload.Attendees = (optionalAttendees != null ? requiredAttendees.Union(optionalAttendees) : requiredAttendees).ToList();
            payload.Body      = await this.emailManager.GetMeetingInviteBodyAsync(applicationName, meetingNotificationEntity).ConfigureAwait(false);

            payload.End = new InviteDateTime()
            {
                DateTime = meetingNotificationEntity.End.FormatDate(ApplicationConstants.GraphMeetingInviteDateTimeFormatter),
            };
            payload.Importance      = (ImportanceType)Enum.Parse(typeof(ImportanceType), meetingNotificationEntity.Priority.ToString());
            payload.IsCancelled     = meetingNotificationEntity.IsCancel;
            payload.IsOnlineMeeting = meetingNotificationEntity.IsOnlineMeeting;
            payload.IsAllDay        = meetingNotificationEntity.IsAllDayEvent;
            payload.Location        = new Location()
            {
                DisplayName = meetingNotificationEntity.Location,
            };
            payload.Organizer = new Organizer()
            {
                EmailAddress = new EmailAddress()
                {
                    Address = meetingNotificationEntity.From,
                },
            };

            if (meetingNotificationEntity.RecurrencePattern != MeetingRecurrencePattern.None)
            {
                var recurrencePattern = new RecurrencePattern()
                {
                    Type       = (RecurrencePatternType)Enum.Parse(typeof(RecurrencePatternType), meetingNotificationEntity.RecurrencePattern.ToString()),
                    Interval   = meetingNotificationEntity.Interval,
                    DaysOfWeek = meetingNotificationEntity.DaysOfWeek.GetListFromString <Contracts.Models.Graph.Invite.DayOfTheWeek>(','),
                    DayOfMonth = meetingNotificationEntity.DayofMonth,
                    Month      = meetingNotificationEntity.MonthOfYear,
                };
                var recurrenceRangeType = meetingNotificationEntity.EndDate.HasValue ? RecurrenceRangeType.EndDate : meetingNotificationEntity.Ocurrences.HasValue ? RecurrenceRangeType.Numbered : RecurrenceRangeType.NoEnd;
                var recurrenceRange     = new RecurrenceRange()
                {
                    NumberOfOccurences = meetingNotificationEntity.Ocurrences,
                    EndDate            = meetingNotificationEntity.EndDate.HasValue ? meetingNotificationEntity.EndDate?.FormatDate(ApplicationConstants.GraphMeetingInviteRecurrenceRangeDateFormatter) : null,
                    StartDate          = meetingNotificationEntity.Start.FormatDate(ApplicationConstants.GraphMeetingInviteRecurrenceRangeDateFormatter),
                    Type = recurrenceRangeType,
                };
                payload.Recurrence = new Recurrence()
                {
                    Pattern = recurrencePattern,
                    Range   = recurrenceRange,
                };
            }

            payload.ReminderMinutesBeforeStart = Convert.ToInt32(meetingNotificationEntity.ReminderMinutesBeforeStart, CultureInfo.InvariantCulture);
            payload.Start = new InviteDateTime()
            {
                DateTime = meetingNotificationEntity.Start.FormatDate(ApplicationConstants.GraphMeetingInviteDateTimeFormatter),
            };

            payload.Subject        = meetingNotificationEntity.Subject;
            payload.TransactionId  = meetingNotificationEntity.NotificationId;
            payload.HasAttachments = meetingNotificationEntity.Attachments != null && meetingNotificationEntity.Attachments.Any() ? true : false;
            payload.ICallUid       = meetingNotificationEntity.ICalUid;
            payload.ShowAs         = meetingNotificationEntity.ShowAs ?? ApplicationConstants.DefaultInviteStatus;
            return(payload);
        }
		public override RecurrenceRange ConvertToRecurrenceRange()
		{
			RecurrenceRange range = new RecurrenceRange();
			range.Start = StartDate;
			range.RecursUntil = EndDate.Date.AddDays(1);
			return range;
		}
		public override RecurrenceRange ConvertToRecurrenceRange()
		{
			RecurrenceRange range = new RecurrenceRange();
			range.Start = StartDate;
			range.MaxOccurrences = NumberOfOccurrences;
			return range;
		}
		public override RecurrenceRange ConvertToRecurrenceRange()
		{
			RecurrenceRange range = new RecurrenceRange();
			range.Start = StartDate;
			return range;
		}
示例#13
0
        public static void Populate(RecurrenceData recurrenceData, StoreObject item)
        {
            CalendarItem calendarItem = item as CalendarItem;
            Task         task         = item as Task;
            Recurrence   recurrence;

            if (calendarItem != null)
            {
                recurrence = calendarItem.Recurrence;
            }
            else
            {
                if (task == null)
                {
                    throw new UnexpectedTypeException("Task", item);
                }
                recurrence = task.Recurrence;
            }
            if (recurrence == null)
            {
                throw new ArgumentNullException("recurrence");
            }
            if (recurrenceData == null)
            {
                throw new ArgumentNullException("recurrenceData");
            }
            RecurrencePattern          pattern = recurrence.Pattern;
            RecurrenceRange            range   = recurrence.Range;
            DailyRecurrencePattern     dailyRecurrencePattern;
            WeeklyRecurrencePattern    weeklyRecurrencePattern;
            MonthlyRecurrencePattern   monthlyRecurrencePattern;
            YearlyRecurrencePattern    yearlyRecurrencePattern;
            MonthlyThRecurrencePattern monthlyThRecurrencePattern;
            YearlyThRecurrencePattern  yearlyThRecurrencePattern;
            DailyRegeneratingPattern   dailyRegeneratingPattern;
            WeeklyRegeneratingPattern  weeklyRegeneratingPattern;
            MonthlyRegeneratingPattern monthlyRegeneratingPattern;

            if ((dailyRecurrencePattern = (pattern as DailyRecurrencePattern)) != null)
            {
                recurrenceData.Type       = RecurrenceData.RecurrenceType.Daily;
                recurrenceData.Regenerate = false;
                recurrenceData.Interval   = (ushort)dailyRecurrencePattern.RecurrenceInterval;
            }
            else if ((weeklyRecurrencePattern = (pattern as WeeklyRecurrencePattern)) != null)
            {
                recurrenceData.Type       = RecurrenceData.RecurrenceType.Weekly;
                recurrenceData.Regenerate = false;
                recurrenceData.Interval   = (ushort)weeklyRecurrencePattern.RecurrenceInterval;
                recurrenceData.DayOfWeek  = (byte)weeklyRecurrencePattern.DaysOfWeek;
                if (recurrenceData.ProtocolVersion >= 141)
                {
                    recurrenceData.FirstDayOfWeek = weeklyRecurrencePattern.FirstDayOfWeek;
                }
            }
            else if ((monthlyRecurrencePattern = (pattern as MonthlyRecurrencePattern)) != null)
            {
                recurrenceData.Type       = RecurrenceData.RecurrenceType.Monthly;
                recurrenceData.Regenerate = false;
                recurrenceData.Interval   = (ushort)monthlyRecurrencePattern.RecurrenceInterval;
                recurrenceData.DayOfMonth = (byte)monthlyRecurrencePattern.DayOfMonth;
                if (recurrenceData.ProtocolVersion >= 140)
                {
                    recurrenceData.CalendarType = monthlyRecurrencePattern.CalendarType;
                }
            }
            else if ((yearlyRecurrencePattern = (pattern as YearlyRecurrencePattern)) != null)
            {
                recurrenceData.Type        = RecurrenceData.RecurrenceType.Yearly;
                recurrenceData.Regenerate  = false;
                recurrenceData.Interval    = 1;
                recurrenceData.DayOfMonth  = (byte)yearlyRecurrencePattern.DayOfMonth;
                recurrenceData.MonthOfYear = (byte)yearlyRecurrencePattern.Month;
                if (recurrenceData.ProtocolVersion >= 140)
                {
                    recurrenceData.CalendarType = yearlyRecurrencePattern.CalendarType;
                    recurrenceData.IsLeapMonth  = yearlyRecurrencePattern.IsLeapMonth;
                }
            }
            else if ((monthlyThRecurrencePattern = (pattern as MonthlyThRecurrencePattern)) != null)
            {
                recurrenceData.Type        = RecurrenceData.RecurrenceType.MonthlyTh;
                recurrenceData.Regenerate  = false;
                recurrenceData.Interval    = (ushort)monthlyThRecurrencePattern.RecurrenceInterval;
                recurrenceData.WeekOfMonth = (byte)((monthlyThRecurrencePattern.Order == RecurrenceOrderType.Last) ? ((RecurrenceOrderType)5) : monthlyThRecurrencePattern.Order);
                recurrenceData.DayOfWeek   = (byte)monthlyThRecurrencePattern.DaysOfWeek;
                if (recurrenceData.ProtocolVersion >= 140)
                {
                    recurrenceData.CalendarType = monthlyThRecurrencePattern.CalendarType;
                }
            }
            else if ((yearlyThRecurrencePattern = (pattern as YearlyThRecurrencePattern)) != null)
            {
                recurrenceData.Type        = RecurrenceData.RecurrenceType.YearlyTh;
                recurrenceData.Regenerate  = false;
                recurrenceData.Interval    = 1;
                recurrenceData.WeekOfMonth = (byte)((yearlyThRecurrencePattern.Order == RecurrenceOrderType.Last) ? ((RecurrenceOrderType)5) : yearlyThRecurrencePattern.Order);
                recurrenceData.DayOfWeek   = (byte)yearlyThRecurrencePattern.DaysOfWeek;
                recurrenceData.MonthOfYear = (byte)yearlyThRecurrencePattern.Month;
                if (recurrenceData.ProtocolVersion >= 140)
                {
                    recurrenceData.CalendarType = yearlyThRecurrencePattern.CalendarType;
                    recurrenceData.IsLeapMonth  = yearlyThRecurrencePattern.IsLeapMonth;
                }
            }
            else if ((dailyRegeneratingPattern = (pattern as DailyRegeneratingPattern)) != null)
            {
                recurrenceData.Type       = RecurrenceData.RecurrenceType.Daily;
                recurrenceData.Regenerate = true;
                recurrenceData.Interval   = (ushort)dailyRegeneratingPattern.RecurrenceInterval;
            }
            else if ((weeklyRegeneratingPattern = (pattern as WeeklyRegeneratingPattern)) != null)
            {
                recurrenceData.Type       = RecurrenceData.RecurrenceType.Weekly;
                recurrenceData.Regenerate = true;
                recurrenceData.Interval   = (ushort)weeklyRegeneratingPattern.RecurrenceInterval;
            }
            else if ((monthlyRegeneratingPattern = (pattern as MonthlyRegeneratingPattern)) != null)
            {
                recurrenceData.Type       = RecurrenceData.RecurrenceType.Monthly;
                recurrenceData.Regenerate = true;
                recurrenceData.Interval   = (ushort)monthlyRegeneratingPattern.RecurrenceInterval;
                if (recurrenceData.ProtocolVersion >= 140)
                {
                    recurrenceData.CalendarType = monthlyRegeneratingPattern.CalendarType;
                }
            }
            else
            {
                YearlyRegeneratingPattern yearlyRegeneratingPattern;
                if ((yearlyRegeneratingPattern = (pattern as YearlyRegeneratingPattern)) == null)
                {
                    throw new ConversionException("Unexpected Recurrence Pattern");
                }
                recurrenceData.Type       = RecurrenceData.RecurrenceType.Yearly;
                recurrenceData.Regenerate = true;
                recurrenceData.Interval   = (ushort)yearlyRegeneratingPattern.RecurrenceInterval;
                if (recurrenceData.ProtocolVersion >= 140)
                {
                    recurrenceData.CalendarType = yearlyRegeneratingPattern.CalendarType;
                    recurrenceData.IsLeapMonth  = false;
                }
            }
            if (task != null)
            {
                object obj = task.TryGetProperty(TaskSchema.IsOneOff);
                if (obj != null && obj is bool)
                {
                    recurrenceData.DeadOccur = (bool)obj;
                }
                else
                {
                    recurrenceData.DeadOccur = false;
                }
                recurrenceData.Start = range.StartDate;
            }
            EndDateRecurrenceRange endDateRecurrenceRange;

            if ((endDateRecurrenceRange = (range as EndDateRecurrenceRange)) == null)
            {
                NumberedRecurrenceRange numberedRecurrenceRange;
                if ((numberedRecurrenceRange = (range as NumberedRecurrenceRange)) != null)
                {
                    recurrenceData.Occurrences = (ushort)numberedRecurrenceRange.NumberOfOccurrences;
                }
                return;
            }
            if (calendarItem != null)
            {
                ExDateTime exDateTime = endDateRecurrenceRange.EndDate;
                exDateTime += calendarItem.Recurrence.StartOffset;
                ExDateTime until = ExTimeZone.UtcTimeZone.ConvertDateTime(exDateTime);
                recurrenceData.Until = until;
                return;
            }
            recurrenceData.Until = endDateRecurrenceRange.EndDate;
        }
示例#14
0
        private void dgEvents_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                // get the selected items Id
                string mId = dgEvents.Rows[e.RowIndex].Cells[0].Value.ToString();

                // open the associated form based on the selected column
                if (e.ColumnIndex == (int)columns.Body)
                {
                    List <ItemBody> tItemBody = null;

                    foreach (KeyValuePair <string, List <ItemBody> > pair in dItemBody)
                    {
                        if (pair.Key == mId)
                        {
                            tItemBody = pair.Value;
                        }
                    }

                    ItemBodyForm mItemBody = new ItemBodyForm(mId, tItemBody);
                    mItemBody.Owner = this;
                    mItemBody.ShowDialog(this);
                }
                // open the associated form based on the selected column
                if (e.ColumnIndex == (int)columns.Attendees)
                {
                    List <Attendee> tAttendees = null;

                    foreach (KeyValuePair <string, List <Attendee> > pair in dAttendees)
                    {
                        if (pair.Key == mId)
                        {
                            tAttendees = pair.Value;
                        }
                    }

                    AttendeeForm mAttendees = new AttendeeForm(mId, tAttendees);
                    mAttendees.Owner = this;
                    mAttendees.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.Categories)
                {
                    List <string> lCategories = null;
                    foreach (KeyValuePair <string, List <string> > pair in dCategories)
                    {
                        if (pair.Key == mId)
                        {
                            lCategories = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lCategories);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.Recurrence)
                {
                    RecurrencePattern tPattern = null;
                    RecurrenceRange   tRange   = null;
                    foreach (KeyValuePair <string, RecurrencePattern> pair in dRecurrencePattern)
                    {
                        if (pair.Key == mId)
                        {
                            tPattern = pair.Value;
                        }
                    }

                    foreach (KeyValuePair <string, RecurrenceRange> pair in dRecurrenceRange)
                    {
                        if (pair.Key == mId)
                        {
                            tRange = pair.Value;
                        }
                    }

                    RecurrenceForm mRecurrence = new RecurrenceForm(tPattern, tRange);
                    mRecurrence.Owner = this;
                    mRecurrence.ShowDialog(this);
                }

                if (e.ColumnIndex == (int)columns.Attachments)
                {
                    if (dFileAttachments.Count > 0 || dItemAttachments.Count > 0)
                    {
                        List <FileAttachment>      tFileAttachments = null;
                        List <ItemAttachment>      tItemAttachments = null;
                        List <ReferenceAttachment> tRefAttachments  = null;

                        foreach (KeyValuePair <string, List <FileAttachment> > pair in dFileAttachments)
                        {
                            if (pair.Key == mId)
                            {
                                tFileAttachments = pair.Value;
                            }
                        }

                        foreach (KeyValuePair <string, List <ItemAttachment> > pair in dItemAttachments)
                        {
                            if (pair.Key == mId)
                            {
                                tItemAttachments = pair.Value;
                            }
                        }

                        foreach (KeyValuePair <string, List <ReferenceAttachment> > pair in dReferenceAttachments)
                        {
                            if (pair.Key == mId)
                            {
                                tRefAttachments = pair.Value;
                            }
                        }

                        AttachmentsForm mAttachment = new AttachmentsForm(mId, tFileAttachments, tItemAttachments, tRefAttachments, ref applogger);
                        mAttachment.Owner = this;
                        mAttachment.ShowDialog(this);
                    }
                }
            }
            catch (NullReferenceException nre)
            {
                applogger.Log("Double-click Error:");
                applogger.Log(nre.Message);
            }
            catch (Exception ex)
            {
                applogger.Log("Double-click Error:");
                applogger.Log(ex.Message);
            }
        }
示例#15
0
        async void OnSaveClicked(Object sender, EventArgs args)
        {
            var  newRecurrence = new PatternedRecurrence();
            Date startDate;
            Date endDate;

            var recurrenceRange   = new RecurrenceRange();
            var recurrencePattern = new RecurrencePattern();
            var daysOfWeek        = new List <Microsoft.Graph.DayOfWeek>();

            if (UpdateRecurrencePatternType == RecurrencePatternType.Daily)
            {
                daysOfWeek.Add(Microsoft.Graph.DayOfWeek.Monday);
                daysOfWeek.Add(Microsoft.Graph.DayOfWeek.Tuesday);
                daysOfWeek.Add(Microsoft.Graph.DayOfWeek.Wednesday);
                daysOfWeek.Add(Microsoft.Graph.DayOfWeek.Thursday);
                daysOfWeek.Add(Microsoft.Graph.DayOfWeek.Friday);
                recurrencePattern.Type           = RecurrencePatternType.Daily;
                recurrencePattern.FirstDayOfWeek = Microsoft.Graph.DayOfWeek.Monday;
                recurrencePattern.DaysOfWeek     = daysOfWeek;
                recurrencePattern.Interval       = 1;
            }
            else if (UpdateRecurrencePatternType == RecurrencePatternType.Weekly)
            {
                daysOfWeek.Add(StringToDayOfWeek[WeeklyDayOfWeek.Text]);
                recurrencePattern.Type       = RecurrencePatternType.Weekly;
                recurrencePattern.DaysOfWeek = daysOfWeek;
                recurrencePattern.Interval   = Convert.ToInt32(NumberOfWeeksEditor.Text);
            }
            else if (UpdateRecurrencePatternType == RecurrencePatternType.AbsoluteMonthly)
            {
                recurrencePattern.Type       = RecurrencePatternType.AbsoluteMonthly;
                recurrencePattern.DayOfMonth = Convert.ToInt32(MonthDayNumberLabel.Text);
                recurrencePattern.Interval   = Convert.ToInt32(MonthIntervalLabel.Text);
            }


            if (String.IsNullOrEmpty(EndAfterOccurrencesEntry.Text))
            {
                recurrenceRange.Type = RecurrenceRangeType.EndDate;
                startDate            = new Date(StartOnDatePicker.Date.Year, StartOnDatePicker.Date.Month, StartOnDatePicker.Date.Day);
                endDate = new Date(EndOnDatePicker.Date.Year, EndOnDatePicker.Date.Month, EndOnDatePicker.Date.Day);
                recurrenceRange.StartDate = startDate;
                recurrenceRange.EndDate   = endDate;
            }
            else
            {
                startDate = new Date(ThisMeetingDate.Date.Year, ThisMeetingDate.Date.Month, ThisMeetingDate.Date.Day);
                recurrenceRange.StartDate           = startDate;
                recurrenceRange.Type                = RecurrenceRangeType.Numbered;
                recurrenceRange.NumberOfOccurrences = Convert.ToInt32(EndAfterOccurrencesEntry.Text);
            }

            newRecurrence.Pattern = recurrencePattern;
            newRecurrence.Range   = recurrenceRange;

            var eventUpdated = await CalendarHelper.UpdateEventRecurrenceAsync(ThisMeeting.Id, newRecurrence);

            if (eventUpdated)
            {
                await Navigation.PopAsync();
            }
            else
            {
                await DisplayAlert(SampleStrings.ErrorText, SampleStrings.CreateMeetingFailed, SampleStrings.OKButtonText);
            }
        }
    /// <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);
    }
        /// <summary>
        /// Gets the recurrence range for this control.
        /// </summary>
        /// <param name="startDate">The start date of the event in question.</param>
        /// <param name="endDate">The end date of the event in question.</param>
        /// <returns>The recurrence range for the event in question</returns>
        private RecurrenceRange GetRange(DateTime startDate, DateTime endDate)
        {
            var range = new RecurrenceRange
                {
                    Start = startDate,
                    EventDuration = endDate - startDate,
                    MaxOccurrences = 0,
                    RecursUntil = DateTime.MaxValue,
                };

            if (this.Visible)
            {
                if (this.RepeatGivenOccurrences.Checked)
                {
                    range.MaxOccurrences = this.RangeOccurrences.Value;
                }
                else if (this.RepeatUntilGivenDate.Checked && this.RangeEndDate.SelectedDate.HasValue)
                {
                    range.RecursUntil = this.RangeEndDate.SelectedDate.Value;

                    ////if (!_allDayEvent.Checked)
                    {
                        range.RecursUntil = range.RecursUntil.AddDays(1);
                    }
                }
            }

            return range;
        }
示例#18
0
        private void dgEvents_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                // get the selected items Id
                string mId = dgEvents.Rows[e.RowIndex].Cells[0].Value.ToString();

                // open the associated form based on the selected column
                if (e.ColumnIndex == 6)
                {
                    List <ItemBody> tItemBody = null;

                    foreach (KeyValuePair <string, List <ItemBody> > pair in dItemBody)
                    {
                        if (pair.Key == mId)
                        {
                            tItemBody = pair.Value;
                        }
                    }

                    // check for empty list and bail the event if we are
                    if (tItemBody == null)
                    {
                        return;
                    }

                    Forms.ItemBodyForm mItemBody = new Forms.ItemBodyForm(mId, tItemBody);
                    mItemBody.Owner = this;
                    mItemBody.ShowDialog(this);
                }
                // open the associated form based on the selected column
                if (e.ColumnIndex == 3)
                {
                    List <Attendee> tAttendees = null;

                    foreach (KeyValuePair <string, List <Attendee> > pair in dAttendees)
                    {
                        if (pair.Key == mId)
                        {
                            tAttendees = pair.Value;
                        }
                    }

                    // check for empty list and bail the event if we are
                    if (tAttendees == null)
                    {
                        return;
                    }

                    Forms.AttendeeForm mAttendees = new Forms.AttendeeForm(mId, tAttendees);
                    mAttendees.Owner = this;
                    mAttendees.ShowDialog(this);
                }
                if (e.ColumnIndex == 9)
                {
                    List <string> lCategories = null;
                    foreach (KeyValuePair <string, List <string> > pair in dCategories)
                    {
                        if (pair.Key == mId)
                        {
                            lCategories = pair.Value;
                        }
                    }

                    // check for empty list and bail the event if we are
                    if (lCategories == null)
                    {
                        return;
                    }

                    Forms.CategoriesForm mCategories = new Forms.CategoriesForm(lCategories);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
                if (e.ColumnIndex == 24)
                {
                    RecurrencePattern tPattern = null;
                    RecurrenceRange   tRange   = null;
                    foreach (KeyValuePair <string, RecurrencePattern> pair in dRecurrencePattern)
                    {
                        if (pair.Key == mId)
                        {
                            tPattern = pair.Value;
                        }
                    }

                    foreach (KeyValuePair <string, RecurrenceRange> pair in dRecurrenceRange)
                    {
                        if (pair.Key == mId)
                        {
                            tRange = pair.Value;
                        }
                    }

                    // check for empty list and bail the event if we are
                    if (tPattern == null && tRange == null)
                    {
                        return;
                    }

                    Forms.RecurrenceForm mRecurrence = new Forms.RecurrenceForm(tPattern, tRange);
                    mRecurrence.Owner = this;
                    mRecurrence.ShowDialog(this);
                }

                if (e.ColumnIndex == 5)
                {
                    List <FileAttachment> tFileAttachments = null;
                    List <ItemAttachment> tItemAttachments = null;

                    foreach (KeyValuePair <string, List <FileAttachment> > pair in dFileAttachments)
                    {
                        if (pair.Key == mId)
                        {
                            tFileAttachments = pair.Value;
                        }
                    }

                    foreach (KeyValuePair <string, List <ItemAttachment> > pair in dItemAttachments)
                    {
                        if (pair.Key == mId)
                        {
                            tItemAttachments = pair.Value;
                        }
                    }

                    // check for empty list and bail the event if we are
                    if (tFileAttachments == null && tItemAttachments == null)
                    {
                        return;
                    }
                    Forms.AttachmentsForm mAttachment = new Forms.AttachmentsForm(mId, tFileAttachments, tItemAttachments);
                    mAttachment.Owner = this;
                    mAttachment.ShowDialog(this);
                }
            }
            catch (Exception ex)
            {
                toolStripStatus.Text = ex.Message;
            }
        }
 /// <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;
 }
        /// <summary>
        /// Sets the range.
        /// </summary>
        /// <param name="range">The range.</param>
        private void SetRecurrenceRange(RecurrenceRange range)
        {
            this.RepeatIndefinitely.Checked = this.RepeatGivenOccurrences.Checked = this.RepeatUntilGivenDate.Checked = false;
            if (range.MaxOccurrences != int.MaxValue)
            {
                this.RepeatGivenOccurrences.Checked = true;
                this.RangeOccurrencesTextBox.Text = range.MaxOccurrences.ToString(CultureInfo.InvariantCulture);
            }
            else if (range.RecursUntil != DateTime.MaxValue)
            {
                this.RepeatUntilGivenDate.Checked = true;

                // TODO: only remove a day if it isn't an all day event, if we start to support all day events.  BD
                this.RangeEndDate.SelectedDate = range.RecursUntil.AddDays(-1);
            }
            else
            {
                this.RepeatIndefinitely.Checked = true;
            }
        }
示例#21
0
        /// <summary>
        /// Sets recurrent events
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public async Task SetRecurrentAsync(string subject, string startDate, string endDate, string startTime, string endTime)
        {
            // Sets the event to happen every week
            RecurrencePattern pattern = new RecurrencePattern
            {
                Type     = RecurrencePatternType.Weekly,
                Interval = 1
            };

            /**
             * Sets the days of the week the event occurs.
             *
             * For this sample it occurs every Monday
             ***/
            List <Microsoft.Graph.DayOfWeek> daysOfWeek = new List <Microsoft.Graph.DayOfWeek>();

            daysOfWeek.Add(Microsoft.Graph.DayOfWeek.Monday);
            pattern.DaysOfWeek = daysOfWeek;

            /**
             * Sets the duration of time the event will keep recurring.
             *
             * In this case the event runs from Nov 6th to Nov 26th 2018.
             **/
            int startDay   = int.Parse(startDate.Substring(0, 2));
            int startMonth = int.Parse(startDate.Substring(3, 2));
            int startYear  = int.Parse(startDate.Substring(6, 4));

            int endDay   = int.Parse(endDate.Substring(0, 2));
            int endMonth = int.Parse(endDate.Substring(3, 2));
            int endYear  = int.Parse(endDate.Substring(6, 4));

            RecurrenceRange range = new RecurrenceRange
            {
                Type      = RecurrenceRangeType.EndDate,
                StartDate = new Date(startYear, startMonth, startDay),
                EndDate   = new Date(endYear, endMonth, endDay)
            };

            /**
             * This brings together the recurrence pattern and the range to define the
             * PatternedRecurrence property.
             **/
            PatternedRecurrence recurrence = new PatternedRecurrence
            {
                Pattern = pattern,
                Range   = range
            };

            DateTime dateTime = DateTime.Today;
            // set the start and end time for the event
            DateTimeTimeZone start = new DateTimeTimeZone
            {
                TimeZone = "Pacific Standard Time",
                DateTime = $"{startYear}-{startMonth}-{startDay}T{startTime}:00:00"
            };

            DateTimeTimeZone end = new DateTimeTimeZone
            {
                TimeZone = "Pacific Standard Time",
                DateTime = $"{startYear}-{startMonth}-{startDay}T{startTime}:00:00"
            };

            Event eventObj = new Event
            {
                Recurrence = recurrence,
                Subject    = subject,
            };

            try
            {
                var recurrentEvent = await graphClient
                                     .Me
                                     .Events
                                     .Request()
                                     .AddAsync(eventObj);

                Console.WriteLine($"Created {recurrentEvent.Subject}," +
                                  $" happens every week on Monday from {startTime}:00 to {endTime}:00");
            }
            catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }
        }