private void UpdateCalendarItem(ItemChangeType[] changes) { UpdateItemType updateItemRequest = new UpdateItemType(); updateItemRequest.ConflictResolution = ConflictResolutionType.AlwaysOverwrite; updateItemRequest.ItemChanges = changes; updateItemRequest.SendMeetingInvitationsOrCancellations = CalendarItemUpdateOperationType.SendToNone; updateItemRequest.SendMeetingInvitationsOrCancellationsSpecified = true; UpdateItemResponseType response = Service.UpdateItem(updateItemRequest); ResponseMessageType responseMessage = response.ResponseMessages.Items[0]; if (responseMessage.ResponseCode != ResponseCodeType.NoError) { throw new Exception("UpdateItem failed with response code " + responseMessage.ResponseCode); } }
private void InsertRecurrenceException(RadScheduler owner, Appointment appointmentToInsert, DateTime exceptionDate) { Appointment master = owner.Appointments.FindByID(appointmentToInsert.RecurrenceParentID); int occurrenceIndex = GetOccurrenceIndex(exceptionDate, master); CalendarItemType occurrenceItem = GetOccurrenceItem(master, occurrenceIndex); occurrenceItem.MeetingTimeZone = GetTimeZone(appointmentToInsert.Owner.TimeZoneOffset); // Update the occurrence ItemChangeType itemUpdates = GetAppointmentChanges(appointmentToInsert) ; itemUpdates.Item = occurrenceItem.ItemId; ItemChangeType[] changes = new ItemChangeType[] { itemUpdates }; UpdateCalendarItem(changes); }
protected virtual ItemChangeType GetAppointmentChanges(Appointment apt) { ItemChangeType itemUpdates = new ItemChangeType(); ItemIdType itemId = new ItemIdType(); itemId.Id = apt.Attributes[ExchangeIdAttribute]; itemId.ChangeKey = apt.Attributes[ExchangeChangeKeyAttribute]; itemUpdates.Item = itemId; List<ItemChangeDescriptionType> updates = new List<ItemChangeDescriptionType>(); updates.Add(GetSubjectUpdate(apt)); updates.Add(GetStartUpdate(apt)); updates.Add(GetEndUpdate(apt)); if (apt.RecurrenceRule != string.Empty) { updates.Add(GetRecurrenceUpdate(apt)); } itemUpdates.Updates = updates.ToArray(); return itemUpdates; }
private void RemoveRecurrenceExceptions(Appointment appointmentToUpdate) { ItemChangeType itemUpdates = new ItemChangeType(); ItemIdType itemId = new ItemIdType(); itemId.Id = appointmentToUpdate.Attributes[ExchangeIdAttribute]; itemId.ChangeKey = appointmentToUpdate.Attributes[ExchangeChangeKeyAttribute]; itemUpdates.Item = itemId; PathToUnindexedFieldType deletedOccurrencesPath = new PathToUnindexedFieldType(); deletedOccurrencesPath.FieldURI = UnindexedFieldURIType.calendarRecurrence; DeleteItemFieldType deletedOccurrencesUpdate = new DeleteItemFieldType(); deletedOccurrencesUpdate.Item = deletedOccurrencesPath; // To reset the deleted and modified occurrences we must // remove the recurrence rule and then immediately restore it itemUpdates.Updates = new ItemChangeDescriptionType[] { deletedOccurrencesUpdate, GetRecurrenceUpdate(appointmentToUpdate) }; UpdateCalendarItem(new ItemChangeType[] { itemUpdates }); }
/// <summary> /// Updates the specified appointment. /// </summary> /// <param name="owner">The owner RadScheduler instance.</param> /// <param name="appointmentToUpdate">The appointment to update.</param> public override void Update(RadScheduler owner, Appointment appointmentToUpdate) { if (owner.ProviderContext is RemoveRecurrenceExceptionsContext) { RemoveRecurrenceExceptions(appointmentToUpdate); return; } if (owner.ProviderContext is UpdateAppointmentContext) { // When removing recurrences through the UI, // one Update operation is used to both update the appointment // and remove the recurrence exceptions. RecurrenceRule updatedRule; RecurrenceRule.TryParse(appointmentToUpdate.RecurrenceRule, out updatedRule); if (updatedRule != null && updatedRule.Exceptions.Count == 0) { RemoveRecurrenceExceptions(appointmentToUpdate); } } CreateRecurrenceExceptionContext createExceptionContext = owner.ProviderContext as CreateRecurrenceExceptionContext; if (createExceptionContext == null) { // We are not creating a recurrence exceptions - synchronize deleted occurrences. SynchronizeDeletedOccurrences(appointmentToUpdate); } ItemChangeType[] changes = new ItemChangeType[] { GetAppointmentChanges(appointmentToUpdate) }; UpdateCalendarItem(changes); }