/// <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); } }
/// <summary> /// Reads the appointments from the Exchange server. /// </summary> /// <param name="owner">The owner RadScheduler instance.</param> /// <returns></returns> public override IEnumerable<Appointment> GetAppointments(RadScheduler owner) { List<Appointment> appointments = new List<Appointment>(); foreach (Resource resource in owner.Resources) { string sharedCalendarName = this.CalendarNames;// resource.Text; // Identify which folders to search. DistinguishedFolderIdType distinguishedFolderIdType = new DistinguishedFolderIdType(); distinguishedFolderIdType.Id = DistinguishedFolderIdNameType.calendar; EmailAddressType emailAddressType = new EmailAddressType(); emailAddressType.EmailAddress = sharedCalendarName; distinguishedFolderIdType.Mailbox = emailAddressType; List<ItemIdType> itemIds = new List<ItemIdType>(); foreach (CalendarItemType item in FindCalendarItems(new DistinguishedFolderIdType[] { distinguishedFolderIdType })) { if ((item.Start < owner.VisibleRangeEnd && item.End > owner.VisibleRangeStart) || item.CalendarItemType1 == CalendarItemTypeType.RecurringMaster) { itemIds.Add(item.ItemId); } } appointments.AddRange(GetAppointments(owner, sharedCalendarName, itemIds.ToArray())); } return appointments; }