コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectingIdType"></param>
        /// <param name="roomAddress"></param>
        /// <param name="itemId"></param>
        /// <param name="filterPropertySet"></param>
        /// <returns></returns>
        public AppointmentObjectId GetAppointment(ConnectingIdType connectingIdType, string roomAddress, ItemId itemId, IList <PropertyDefinitionBase> filterPropertySet)
        {
            SetImpersonation(connectingIdType, roomAddress);
            var appointmentTime = Appointment.Bind(ExchangeService, itemId, new PropertySet(filterPropertySet));

            PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties)
            {
                CleanGlobalObjectId
            };

            appointmentTime.Load(psPropSet);
            appointmentTime.TryGetProperty(CleanGlobalObjectId, out object CalIdVal);


            var objectId = new AppointmentObjectId()
            {
                Id             = itemId,
                Item           = appointmentTime,
                Base64UniqueId = Convert.ToBase64String((Byte[])CalIdVal),
                ICalUid        = appointmentTime.ICalUid,
                Organizer      = appointmentTime.Organizer
            };


            return(objectId);
        }
コード例 #2
0
        public AppointmentObjectId GetParentAppointment(AppointmentObjectId dependentAppointment, IList <PropertyDefinitionBase> filterPropertySet)
        {
            IList <PropertyDefinitionBase> findPropertyCollection = new List <PropertyDefinitionBase>()
            {
                ItemSchema.DateTimeReceived,
                ItemSchema.Subject,
                AppointmentSchema.Start,
                AppointmentSchema.End,
                AppointmentSchema.IsAllDayEvent,
                AppointmentSchema.IsRecurring,
                AppointmentSchema.IsCancelled,
                AppointmentSchema.TimeZone
            };

            var icalId    = dependentAppointment.ICalUid;
            var mailboxId = dependentAppointment.Organizer.Address;


            var objectId = new AppointmentObjectId()
            {
                ICalUid   = dependentAppointment.ICalUid,
                Organizer = dependentAppointment.Organizer
            };

            try
            {
                // Initialize the calendar folder via Impersonation
                SetImpersonation(ConnectingIdType.SmtpAddress, mailboxId);

                CalendarFolder AtndCalendar   = CalendarFolder.Bind(ExchangeService, new FolderId(WellKnownFolderName.Calendar, mailboxId), new PropertySet());
                SearchFilter   sfSearchFilter = new SearchFilter.IsEqualTo(CleanGlobalObjectId, dependentAppointment.Base64UniqueId);
                ItemView       ivItemView     = new ItemView(5)
                {
                    PropertySet = new PropertySet(BasePropertySet.IdOnly, findPropertyCollection)
                };
                FindItemsResults <Item> fiResults = AtndCalendar.FindItems(sfSearchFilter, ivItemView);
                if (fiResults.Items.Count > 0)
                {
                    var objectItem           = fiResults.Items.FirstOrDefault();
                    var ownerAppointmentTime = (Appointment)Item.Bind(ExchangeService, objectItem.Id, new PropertySet(filterPropertySet));

                    Trace.WriteLine($"The first {fiResults.Items.Count()} appointments on your calendar from {ownerAppointmentTime.Start.ToShortDateString()} to {ownerAppointmentTime.End.ToShortDateString()}");


                    objectId.Item = ownerAppointmentTime;
                    objectId.Id   = ownerAppointmentTime.Id;
                    var props = ownerAppointmentTime.ExtendedProperties.Where(p => (p.PropertyDefinition.PropertySet == DefaultExtendedPropertySet.Meeting));
                    if (props.Any())
                    {
                        objectId.ReferenceId = (string)props.First(p => p.PropertyDefinition.Name == EWSConstants.RefIdPropertyName).Value;
                        objectId.MeetingKey  = (int)props.First(p => p.PropertyDefinition.Name == EWSConstants.MeetingKeyPropertyName).Value;
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine($"Error retreiving calendar {mailboxId} msg:{ex.Message}");
            }

            return(objectId);
        }