public static StoreObjectId Query(Folder parentFolder, string childFolderName)
        {
            StoreObjectId objectId;

            using (QueryResult queryResult = QueryChildFolderByName.CreateQueryResult(parentFolder))
            {
                VersionedId versionedId;
                for (;;)
                {
                    object[][] rows = queryResult.GetRows(100);
                    if (rows == null || rows.Length == 0)
                    {
                        break;
                    }
                    foreach (object[] array2 in rows)
                    {
                        string text = array2[0] as string;
                        versionedId = (array2[1] as VersionedId);
                        if (text != null && versionedId != null && StringComparer.InvariantCultureIgnoreCase.Equals(text, childFolderName))
                        {
                            goto Block_5;
                        }
                    }
                }
                return(null);

Block_5:
                objectId = versionedId.ObjectId;
            }
            return(objectId);
        }
Beispiel #2
0
        private static StoreObjectId GetFreeBusyFolderIdInternal(PublicFolderSession session, string legacyDN, FreeBusyFolderDisposition disposition)
        {
            string freeBusyFolderName = FreeBusyFolder.GetFreeBusyFolderName(legacyDN);

            if (freeBusyFolderName == null)
            {
                FreeBusyFolder.Tracer.TraceError <string>(0L, "Unable to get free/busy folder for mailbox with legacy DN '{0}' because cannot obtain folder name from legacy DN", legacyDN);
                return(null);
            }
            StoreObjectId freeBusyRootFolderId = FreeBusyFolder.GetFreeBusyRootFolderId(session);

            if (freeBusyRootFolderId == null)
            {
                return(null);
            }
            StoreObjectId result;

            try
            {
                StoreObjectId storeObjectId = null;
                using (Folder folder = Folder.Bind(session, freeBusyRootFolderId))
                {
                    storeObjectId = QueryChildFolderByName.Query(folder, freeBusyFolderName);
                }
                if (storeObjectId == null && disposition == FreeBusyFolderDisposition.CreateIfNeeded)
                {
                    storeObjectId = FreeBusyFolder.CreateFreeBusyFolder(session, freeBusyRootFolderId, freeBusyFolderName);
                }
                result = storeObjectId;
            }
            catch (StoragePermanentException arg)
            {
                FreeBusyFolder.Tracer.TraceDebug <StoragePermanentException>(0L, "Failed to get free/busy folder due exception: {0}", arg);
                result = null;
            }
            return(result);
        }
Beispiel #3
0
        internal static StoreObjectId GetFreeBusyRootFolderId(PublicFolderSession session)
        {
            StoreObjectId result;

            try
            {
                StoreObjectId storeObjectId = null;
                using (Folder folder = Folder.Bind(session, session.GetNonIpmSubtreeFolderId()))
                {
                    storeObjectId = QueryChildFolderByName.Query(folder, "SCHEDULE+ FREE BUSY");
                }
                if (storeObjectId == null)
                {
                    FreeBusyFolder.Tracer.TraceError <string>(0L, "Unable to find folder '{0}' in public folders", "SCHEDULE+ FREE BUSY");
                }
                result = storeObjectId;
            }
            catch (StoragePermanentException arg)
            {
                FreeBusyFolder.Tracer.TraceError <string, StoragePermanentException>(0L, "Failed to get folder '{0}' due exception: {1}", "SCHEDULE+ FREE BUSY", arg);
                result = null;
            }
            return(result);
        }