Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <summary>
        /// Inserts the specified appointment.
        /// </summary>
        /// <param name="owner">The owner RadScheduler instance.</param>
        /// <param name="appointmentToInsert">The appointment to insert.</param>
        public override void Insert(RadScheduler owner, Appointment appointmentToInsert)
        {
            CreateRecurrenceExceptionContext createExceptionContext = owner.ProviderContext as CreateRecurrenceExceptionContext;

            if (createExceptionContext != null)
            {
                Debug.Assert(appointmentToInsert.RecurrenceState == RecurrenceState.Exception);
                InsertRecurrenceException(owner, appointmentToInsert, createExceptionContext.RecurrenceExceptionDate);
                return;
            }


            CalendarItemType calendarItem = CreateCalendarItem(owner, appointmentToInsert);

            CreateItemType createItemRequest = new CreateItemType();

            DistinguishedFolderIdType destFolder = new DistinguishedFolderIdType();

            destFolder.Id = DistinguishedFolderIdNameType.calendar;

            EmailAddressType emailAddressType = new EmailAddressType();

            emailAddressType.EmailAddress = this.CalendarNames;

            destFolder.Mailbox = emailAddressType;

            createItemRequest.SavedItemFolderId      = new TargetFolderIdType();
            createItemRequest.SavedItemFolderId.Item = destFolder;


            createItemRequest.SendMeetingInvitations          = CalendarItemCreateOrDeleteOperationType.SendToNone;
            createItemRequest.SendMeetingInvitationsSpecified = true;
            createItemRequest.Items       = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new CalendarItemType[] { calendarItem };

            CreateItemResponseType response        = Service.CreateItem(createItemRequest);
            ResponseMessageType    responseMessage = response.ResponseMessages.Items[0];

            if (responseMessage.ResponseCode != ResponseCodeType.NoError)
            {
                throw new Exception("CreateItem failed with response code " + responseMessage.ResponseCode);
            }
        }