public static void BuildFolderTree(MailboxSession mailboxSession, SyncState syncState) { StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Root); SharingSubscriptionData[] array = null; using (SharingSubscriptionManager sharingSubscriptionManager = new SharingSubscriptionManager(mailboxSession)) { array = sharingSubscriptionManager.GetAll(); } using (Folder folder = Folder.Bind(mailboxSession, defaultFolderId)) { FolderTree folderTree; using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, FolderTree.fetchProperties)) { folderTree = new FolderTree(); object[][] rows; do { rows = queryResult.GetRows(10000); for (int i = 0; i < rows.Length; i++) { MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForNewItem(((VersionedId)rows[i][0]).ObjectId); MailboxSyncItemId mailboxSyncItemId2 = MailboxSyncItemId.CreateForNewItem((StoreObjectId)rows[i][1]); folderTree.AddFolder(mailboxSyncItemId); object obj = rows[i][3]; int num = (obj is PropertyError) ? 0 : ((int)obj); if ((num & 1073741824) != 0) { for (int j = 0; j < array.Length; j++) { if (array[j].LocalFolderId.Equals(mailboxSyncItemId.NativeId)) { folderTree.SetPermissions(mailboxSyncItemId, SyncPermissions.Readonly); folderTree.SetOwner(mailboxSyncItemId, array[j].SharerIdentity); break; } } } if (!defaultFolderId.Equals(mailboxSyncItemId2.NativeId)) { folderTree.AddFolder(mailboxSyncItemId2); folderTree.LinkChildToParent(mailboxSyncItemId2, mailboxSyncItemId); } if ((bool)rows[i][2]) { folderTree.SetHidden(mailboxSyncItemId, true); } } }while (rows.Length != 0); } syncState[CustomStateDatumType.FullFolderTree] = folderTree; syncState[CustomStateDatumType.RecoveryFullFolderTree] = syncState[CustomStateDatumType.FullFolderTree]; } }
private SharingSubscriptionData[] LoadAllSubscriptions() { try { if (this.requesterBudget != null) { this.requesterBudget.CheckOverBudget(); } ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(this.adUser, null); using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(mailboxOwner, CultureInfo.InvariantCulture, "Client=AS")) { if (this.requesterBudget != null) { mailboxSession.AccountingObject = this.requesterBudget; } try { using (SharingSubscriptionManager sharingSubscriptionManager = new SharingSubscriptionManager(mailboxSession)) { return(sharingSubscriptionManager.GetAll()); } } catch (ObjectNotFoundException) { } } } catch (OverBudgetException handledException) { this.HandledException = handledException; } catch (ConnectionFailedPermanentException handledException2) { this.HandledException = handledException2; } catch (ObjectNotFoundException handledException3) { this.HandledException = handledException3; } catch (ConnectionFailedTransientException handledException4) { this.HandledException = handledException4; } catch (AccountDisabledException handledException5) { this.HandledException = handledException5; } catch (VirusScanInProgressException innerException) { LocalizedString localizedString = Strings.descVirusScanInProgress(this.adUser.PrimarySmtpAddress.ToString()); this.HandledException = new LocalizedException(localizedString, innerException); } catch (VirusDetectedException innerException2) { LocalizedString localizedString2 = Strings.descVirusDetected(this.adUser.PrimarySmtpAddress.ToString()); this.HandledException = new LocalizedException(localizedString2, innerException2); } catch (StoragePermanentException handledException6) { this.HandledException = handledException6; } catch (StorageTransientException handledException7) { this.HandledException = handledException7; } return(new SharingSubscriptionData[0]); }