예제 #1
0
        public static CalendarGroupEntry BindFromCalendarFolder(MailboxSession session, StoreObjectId calendarFolderObjectId)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(calendarFolderObjectId, "calendarFolderObjectId");
            if (calendarFolderObjectId.ObjectType != StoreObjectType.CalendarFolder && calendarFolderObjectId.ObjectType != StoreObjectType.Folder)
            {
                throw new ArgumentException("StoreObject is not a calendar folder.", "calendarFolderObjectId");
            }
            VersionedId groupEntryIdFromFolderId = CalendarGroupEntry.GetGroupEntryIdFromFolderId(session, calendarFolderObjectId);

            if (groupEntryIdFromFolderId == null)
            {
                if (calendarFolderObjectId.Equals(session.GetDefaultFolderId(DefaultFolderType.Calendar)))
                {
                    using (CalendarGroup calendarGroup = CalendarGroup.Bind(session, FolderTreeData.MyFoldersClassId))
                    {
                        ReadOnlyCollection <CalendarGroupEntryInfo> childCalendars = calendarGroup.GetChildCalendars();
                        foreach (CalendarGroupEntryInfo calendarGroupEntryInfo in childCalendars)
                        {
                            LocalCalendarGroupEntryInfo localCalendarGroupEntryInfo = calendarGroupEntryInfo as LocalCalendarGroupEntryInfo;
                            if (localCalendarGroupEntryInfo != null && calendarFolderObjectId.Equals(localCalendarGroupEntryInfo.CalendarId))
                            {
                                return(CalendarGroupEntry.Bind(session, calendarGroupEntryInfo.Id, null));
                            }
                        }
                    }
                }
                throw new ObjectNotFoundException(ServerStrings.ExItemNotFound);
            }
            return(CalendarGroupEntry.Bind(session, groupEntryIdFromFolderId, null));
        }
예제 #2
0
        public ICalendarGroupEntry BindToCalendarGroupEntry(IMailboxSession session, StoreId id)
        {
            StoreObjectId storeObjectId = StoreId.GetStoreObjectId(id);

            if (!storeObjectId.IsFolderId)
            {
                return(CalendarGroupEntry.Bind((MailboxSession)session, id, null));
            }
            return(CalendarGroupEntry.BindFromCalendarFolder((MailboxSession)session, storeObjectId));
        }