private bool ValidateUMFaxFilter(DefaultFolderContext context, OutlookSearchFolder folder) { SearchFolderCriteria searchFolderCriteria = SearchFolderValidation.TryGetSearchCriteria(folder); if (searchFolderCriteria == null || !UMFaxValidation.GetUMFaxQueryFilter(context).Equals(searchFolderCriteria.SearchQuery)) { folder.ApplyContinuousSearch(UMFaxValidation.CreateUMFaxSearchCriteria(context)); } return(true); }
private bool ValidateUMVoiceMailFilter(DefaultFolderContext context, OutlookSearchFolder folder) { SearchFolderCriteria searchFolderCriteria = SearchFolderValidation.TryGetSearchCriteria(folder); if (searchFolderCriteria == null || !UMVoiceMailValidation.GetUMVoicemailQueryFilter(context).Equals(searchFolderCriteria.SearchQuery)) { folder.ApplyContinuousSearch(UMVoiceMailValidation.CreateUMVoiceMailSearchCriteria(context)); folder.MakeVisibleToOutlook(true); } return(true); }
protected override void SetPropertiesInternal(DefaultFolderContext context, Folder folder) { base.SetPropertiesInternal(context, folder); folder[InternalSchema.OutlookSearchFolderClsId] = UMVoiceMailValidation.UmVoiceMailClsId; folder.ClassName = "IPF.Note.Microsoft.Voicemail"; OutlookSearchFolder outlookSearchFolder = (OutlookSearchFolder)folder; outlookSearchFolder.Save(); outlookSearchFolder.ApplyContinuousSearch(UMVoiceMailValidation.CreateUMVoiceMailSearchCriteria(context)); outlookSearchFolder.Load(null); outlookSearchFolder.MakeVisibleToOutlook(true); }
public static StoreObjectId Recreate(MailboxSession session, Guid searchFolderClsId) { if (session == null) { throw new ArgumentNullException("session"); } if (searchFolderClsId == Guid.Empty) { throw new ArgumentException("Guid is empty", "searchFolderClsId"); } using (Folder folder = Folder.Bind(session, DefaultFolderType.SearchFolders)) { using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.None, null, null, new PropertyDefinition[] { InternalSchema.OutlookSearchFolderClsId })) { for (;;) { object[][] rows = queryResult.GetRows(10000); for (int i = 0; i < rows.Length; i++) { if (rows[i][0] is Guid && ((Guid)rows[i][0]).Equals(searchFolderClsId)) { goto Block_9; } } if (rows.Length <= 0) { goto Block_11; } } Block_9: throw new ObjectExistedException(ServerStrings.ExSearchFolderAlreadyExists(searchFolderClsId)); Block_11 :; } } VersionedId versionedId = OutlookSearchFolder.FindAssociatedMessageId(session, searchFolderClsId); if (versionedId == null) { throw new ObjectNotFoundException(ServerStrings.ExSearchFolderNoAssociatedItem(searchFolderClsId)); } StoreObjectId objectId; using (MessageItem messageItem = MessageItem.Bind(session, versionedId)) { bool deepTraversal; StoreId[] folderScope; Restriction restriction = OutlookSearchFolder.ReadOutlookSearchFolderDefinitionBlob(messageItem, out deepTraversal, out folderScope); QueryFilter searchQuery = FilterRestrictionConverter.CreateFilter(session, session.Mailbox.MapiStore, restriction, true); SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(searchQuery, folderScope); searchFolderCriteria.DeepTraversal = deepTraversal; string valueOrDefault = messageItem.GetValueOrDefault <string>(InternalSchema.DisplayName, string.Empty); using (OutlookSearchFolder outlookSearchFolder = OutlookSearchFolder.Create(session, valueOrDefault)) { outlookSearchFolder[InternalSchema.OutlookSearchFolderClsId] = searchFolderClsId; FolderSaveResult folderSaveResult = outlookSearchFolder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { throw folderSaveResult.ToException(ServerStrings.ExCannotCreateFolder(folderSaveResult)); } outlookSearchFolder.Load(null); outlookSearchFolder.ApplyContinuousSearch(searchFolderCriteria); objectId = outlookSearchFolder.Id.ObjectId; } } return(objectId); }