private static SearchFolder CreateAndUpdateFilteredViewSearchFolder(MailboxSession mailboxSession, OwaSearchContext searchContext, StoreId searchFoldersRootId, SearchFolderCriteria searchFolderCriteria) { ExTraceGlobals.StorageTracer.TraceDebug <string, string>(0L, "[OwaFilterState::CreateAndUpdateFilteredViewSearchFolder] Create filtered view search folder for view filter: {0} search folder identity: {1} ", searchContext.ViewFilter.ToString(), searchContext.ClientSearchFolderIdentity); SearchFolder searchFolder = SearchFolder.Create(mailboxSession, searchFoldersRootId, searchContext.ClientSearchFolderIdentity, CreateMode.OpenIfExists); OwaFilterState.UpdateFilteredViewSearchFolder(mailboxSession, searchFolder, searchContext); searchContext.SearchFolderId = searchFolder.StoreObjectId; searchContext.IsSearchFailed = !OwaFilterState.ApplyOwaContinuousSearch(searchFolder, searchFolderCriteria, mailboxSession, searchContext); if (searchContext.IsSearchFailed) { ExTraceGlobals.StorageTracer.TraceError(0L, "[OwaFilterState::CreateAndUpdateFilteredViewSearchFolder] deleting searchContext.SearchFolderId: " + searchContext.SearchFolderId); searchContext.ViewFilterActions |= ViewFilterActions.DeleteInvalidSearchFolder; mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[] { searchContext.SearchFolderId }); searchFolder.Dispose(); searchFolder = null; } else if (OwaFilterState.LinkViewFolder(mailboxSession, searchContext.FolderIdToSearch, searchFolder, searchContext.ViewFilter)) { searchContext.ViewFilterActions |= ViewFilterActions.LinkToSourceFolderSucceeded; } return(searchFolder); }
protected override void SetPropertiesInternal(DefaultFolderContext context, Folder folder) { base.SetPropertiesInternal(context, folder); folder.Save(); SearchFolder searchFolder = (SearchFolder)folder; StoreObjectId[] folderScope; if (MailboxSession.DefaultFoldersToForceInit != null && MailboxSession.DefaultFoldersToForceInit.Contains(DefaultFolderType.MyContacts)) { folderScope = this.contactsSearchFolderCriteria.GetExistingDefaultFolderScope(context); } else { folderScope = this.contactsSearchFolderCriteria.GetDefaultFolderScope(context.Session, true); } SearchFolderCriteria searchFolderCriteria = ContactsSearchFolderCriteria.CreateSearchCriteria(folderScope); ContactsSearchFolderCriteria.ApplyContinuousSearchFolderCriteria(XSOFactory.Default, context.Session, searchFolder, searchFolderCriteria); bool flag = context.Session.MailboxOwner.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox || !context.Session.ClientInfoString.Contains("Client=WebServices;Action=ConfigureGroupMailbox"); MyContactsFolderValidation.Tracer.TraceDebug <string, RecipientTypeDetails, bool>((long)context.Session.GetHashCode(), "SearchFolder criteria applied. ClientInfoString={0}, RecipientTypeDetails={1}, ShouldWaitForNotification={2}", context.Session.ClientInfoString, context.Session.MailboxOwner.RecipientTypeDetails, flag); if (flag) { ContactsSearchFolderCriteria.WaitForSearchFolderPopulation(XSOFactory.Default, context.Session, searchFolder); } folder.Load(null); }
internal override bool EnsureIsValid(DefaultFolderContext context, Folder folder) { FromFavoriteSendersFolderValidation.Tracer.TraceFunction((long)this.GetHashCode(), "Entering FromFavoriteSendersFolderValidation.EnsureIsValid"); if (!base.EnsureIsValid(context, folder)) { FromFavoriteSendersFolderValidation.Tracer.TraceFunction((long)this.GetHashCode(), "Exiting FromFavoriteSendersFolderValidation.EnsureIsValid: folder failed base class validation."); return(false); } SearchFolder searchFolder = folder as SearchFolder; if (searchFolder == null) { FromFavoriteSendersFolderValidation.Tracer.TraceFunction((long)this.GetHashCode(), "Exiting FromFavoriteSendersFolderValidation.Validate: not a SearchFolder instance."); return(false); } SearchFolderCriteria searchFolderCriteria = SearchFolderValidation.TryGetSearchCriteria(searchFolder); SearchFolderCriteria searchCriteria = FromFavoriteSendersFolderValidation.GetSearchCriteria(context); if (searchFolderCriteria == null || !SearchFolderValidation.MatchSearchFolderCriteria(searchFolderCriteria, searchCriteria) || searchFolderCriteria.DeepTraversal != searchCriteria.DeepTraversal) { FromFavoriteSendersFolderValidation.Tracer.TraceDebug((long)this.GetHashCode(), "Current criteria are NOT initialized or don't match desired criteria. Updating."); searchFolder.ApplyContinuousSearch(searchCriteria); } FromFavoriteSendersFolderValidation.Tracer.TraceFunction((long)this.GetHashCode(), "Exiting FromFavoriteSendersFolderValidation.EnsureIsValid. Validation is done."); return(true); }
public static SearchFolder Bind(MailboxSession session, DefaultFolderType defaultFolderType, ICollection <PropertyDefinition> propsToReturn) { EnumValidator.ThrowIfInvalid <DefaultFolderType>(defaultFolderType, "defaultFolderType"); DefaultFolder defaultFolder = session.InternalGetDefaultFolder(defaultFolderType); if (defaultFolder.StoreObjectType != StoreObjectType.OutlookSearchFolder && defaultFolder.StoreObjectType != StoreObjectType.SearchFolder) { throw new ArgumentOutOfRangeException("defaultFolderType"); } StoreObjectId folderId = session.SafeGetDefaultFolderId(defaultFolderType); ObjectNotFoundException ex = null; for (int i = 0; i < 2; i++) { try { return(SearchFolder.Bind(session, folderId, propsToReturn)); } catch (ObjectNotFoundException ex2) { ex = ex2; ExTraceGlobals.StorageTracer.Information <DefaultFolderType>(0L, "SearchFolder::Bind(defaultFolderType): attempting to recreate {0}.", defaultFolderType); if (!session.TryFixDefaultFolderId(defaultFolderType, out folderId)) { throw; } } } throw ex; }
protected override void SetPropertiesInternal(DefaultFolderContext context, Folder folder) { base.SetPropertiesInternal(context, folder); SearchFolderCriteria searchFolderCriteria = null; SearchFolder searchFolder = (SearchFolder)folder; searchFolder[InternalSchema.ContainerClass] = "IPF.Task"; int num = 786432; searchFolder[InternalSchema.ExtendedFolderToDoVersion] = num; searchFolder.Save(); searchFolder.Load(null); try { searchFolderCriteria = searchFolder.GetSearchCriteria(); } catch (ObjectNotInitializedException arg) { ExTraceGlobals.DefaultFoldersTracer.TraceDebug <string, ObjectNotInitializedException>((long)this.GetHashCode(), "ToDoSearchValidation::SetPropertiesInternal. Failed to get search criteria on the folder with name {0} due to {1}. It can be normal though for a search folder without search criteria applied yet.", searchFolder.DisplayName, arg); } if (searchFolderCriteria == null || !ToDoSearchValidation.MatchedToDoSearchCriteriaApproxly(searchFolderCriteria)) { ExTraceGlobals.DefaultFoldersTracer.TraceDebug <string, SearchFolderCriteria, SearchFolderCriteria>((long)this.GetHashCode(), "ToDoSearchValidation::SetPropertiesInternal. Apply ToDo search criteria on the folder. DisplayName = {0}, currentCriteria = {1}, newCriteria = {2}.", searchFolder.DisplayName, searchFolderCriteria, ToDoSearchValidation.GetToDoSearchCriteria(context)); searchFolder.ApplyContinuousSearch(ToDoSearchValidation.GetToDoSearchCriteria(context)); } }
protected override void SetPropertiesInternal(DefaultFolderContext context, Folder folder) { base.SetPropertiesInternal(context, folder); folder.Save(); SearchFolder searchFolder = (SearchFolder)folder; searchFolder.ApplyContinuousSearch(this.CreateSearchCriteria(context)); folder.Load(null); }
protected override void SetPropertiesInternal(DefaultFolderContext context, Folder folder) { base.SetPropertiesInternal(context, folder); SearchFolder searchFolder = (SearchFolder)folder; searchFolder.Save(); searchFolder.ApplyContinuousSearch(CalendarVersionStoreValidation.CreateCalendarVersionSearchCriteria(context)); searchFolder.Load(); }
public SearchFolderCriteria GetSearchCriteria() { this.CheckDisposed("GetSearchCriteria"); if (SearchFolder.TestInjectCriteriaFailure != null) { SearchFolder.TestInjectCriteriaFailure(); } return(base.CoreFolder.GetSearchCriteria(true)); }
protected override void SetPropertiesInternal(DefaultFolderContext context, Folder folder) { base.SetPropertiesInternal(context, folder); SearchFolder searchFolder = (SearchFolder)folder; searchFolder.Save(); searchFolder.Load(null); AllItemsFolderHelper.InitializeTransportIndexes(folder); AllItemsFolderValidation.TryApplyContinuousSearch(searchFolder, AllItemsFolderValidation.CreateSearchCriteria(context)); }
protected override void SetPropertiesInternal(DefaultFolderContext context, Folder folder) { FromFavoriteSendersFolderValidation.Tracer.TraceFunction((long)this.GetHashCode(), "FromFavoriteSendersFolderValidation.SetPropertiesInternal"); base.SetPropertiesInternal(context, folder); folder.Save(); SearchFolder searchFolder = (SearchFolder)folder; searchFolder.ApplyContinuousSearch(FromFavoriteSendersFolderValidation.GetSearchCriteria(context)); folder.Load(null); FromFavoriteSendersFolderValidation.Tracer.TraceFunction((long)this.GetHashCode(), "Exiting FromFavoriteSendersFolderValidation.SetPropertiesInternal. Initialization is done."); }
private static bool VerifyAndFixSearchFolder(DefaultFolderContext context, SearchFolder folder) { SearchFolderCriteria searchFolderCriteria = SearchFolderValidation.TryGetSearchCriteria(folder); SearchFolderCriteria searchFolderCriteria2 = AllItemsFolderValidation.CreateSearchCriteria(context); if (searchFolderCriteria == null || !SearchFolderValidation.MatchSearchFolderCriteria(searchFolderCriteria, searchFolderCriteria2)) { AllItemsFolderValidation.TryApplyContinuousSearch(folder, searchFolderCriteria2); } return(true); }
private static bool ApplyOwaContinuousSearch(SearchFolder searchFolder, SearchFolderCriteria searchCriteria, MailboxSession mailboxSession, OwaSearchContext searchContext) { ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "[OwaFilterState::ApplyOwaContinuousSearch] Start for search folder: {0}", searchContext.ClientSearchFolderIdentity); StoreObjectId storeObjectId = searchFolder.StoreObjectId; bool flag = false; try { IAsyncResult asyncResult = searchFolder.BeginApplyContinuousSearch(searchCriteria, null, null); flag = asyncResult.AsyncWaitHandle.WaitOne(searchContext.SearchTimeoutInMilliseconds); if (flag) { searchFolder.EndApplyContinuousSearch(asyncResult); searchContext.ViewFilterActions |= ViewFilterActions.SearchCriteriaApplied; ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "[OwaFilterState::ApplyOwaContinuousSearch] Search completed for search folder: {0}", searchContext.ClientSearchFolderIdentity); } else { flag = true; searchContext.ViewFilterActions |= ViewFilterActions.PopulateSearchFolderTimedOut; ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "[OwaFilterState::ApplyOwaContinuousSearch] Search timed out for search folder: {0}", searchContext.ClientSearchFolderIdentity); } } catch (QueryInProgressException ex) { searchContext.ViewFilterActions |= ViewFilterActions.QueryInProgressException; string message = string.Format("[OwaFilterState::ApplyOwaContinuousSearch] Population of dynamic search folder: {0} failed due to QueryInProgressException: {1}. ViewFilterActions: {2}", searchContext.ClientSearchFolderIdentity, ex.ToString(), (int)searchContext.ViewFilterActions); ExTraceGlobals.StorageTracer.TraceError(0L, message); flag = OwaFilterState.EnsureSearchIsCompleted(searchFolder, mailboxSession, searchContext); } catch (CorruptDataException ex2) { searchContext.ViewFilterActions |= ViewFilterActions.CorruptDataException; string text = string.Format("[OwaFilterState::ApplyOwaContinuousSearch] Population of dynamic search folder: {0} failed due to CorruptDataException: {1}. ViewFilterActions = {2}.", searchContext.ClientSearchFolderIdentity, ex2.ToString(), (int)searchContext.ViewFilterActions); ExTraceGlobals.StorageTracer.TraceError(0L, text); OwaFilterState.SendWatsonWithoutDump(ex2, text); } catch (ObjectNotFoundException ex3) { searchContext.ViewFilterActions |= ViewFilterActions.ObjectNotFoundException; string message2 = string.Format("[OwaFilterState::ApplyOwaContinuousSearch] Population of dynamic search folder: {0} failed due to ObjectNotFoundException: {1}. ViewFilterActions = {2}.", searchContext.ClientSearchFolderIdentity, ex3.ToString(), (int)searchContext.ViewFilterActions); ExTraceGlobals.StorageTracer.TraceError(0L, message2); } catch (Exception ex4) { searchContext.ViewFilterActions |= ViewFilterActions.Exception; string text2 = string.Format("[OwaFilterState::ApplyOwaContinuousSearch] Population of dynamic search folder: {0} failed due to Exception: {1}. ViewFilterActions = {2}.", searchContext.ClientSearchFolderIdentity, ex4.ToString(), (int)searchContext.ViewFilterActions); ExTraceGlobals.StorageTracer.TraceError(0L, text2); OwaFilterState.SendWatsonWithoutDump(ex4, text2); } return(flag); }
private HashSet <StoreObjectId> GetLocalItemIds(StoreObjectId localFolderId) { HashSet <StoreObjectId> hashSet = new HashSet <StoreObjectId>(); foreach (IConversationTreeNode conversationTreeNode in this.ConversationTree) { foreach (StoreObjectId storeObjectId in conversationTreeNode.ToListStoreObjectId()) { StoreObjectId valueOrDefault = conversationTreeNode.GetValueOrDefault <StoreObjectId>(storeObjectId, StoreObjectSchema.ParentItemId, null); if (localFolderId == null || localFolderId.CompareTo(valueOrDefault) == 0) { hashSet.Add(storeObjectId); } } } if (hashSet.Count == 0 && localFolderId != null) { using (Folder folder = Folder.Bind(this.session, localFolderId)) { SearchFolder searchFolder = folder as SearchFolder; if (searchFolder != null) { using (QueryResult queryResult = searchFolder.ConversationItemQuery(null, new SortBy[] { new SortBy(ConversationItemSchema.ConversationId, SortOrder.Ascending) }, new PropertyDefinition[] { ConversationItemSchema.ConversationItemIds })) { if (queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ConversationItemSchema.ConversationId, this.ConversationId))) { IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(1); if (propertyBags.Length > 0) { StoreObjectId[] array = propertyBags[0].TryGetProperty(ConversationItemSchema.ConversationItemIds) as StoreObjectId[]; if (array != null) { foreach (StoreObjectId item in array) { hashSet.Add(item); } } } } } } } } return(hashSet); }
public static bool LinkViewFolder(MailboxSession session, StoreId folderId, SearchFolder viewFolder, OwaViewFilter filter) { bool flag = false; Exception ex = null; if (OwaFilterState.FilterToLinkPropertyDefinitionsMap.ContainsKey(filter)) { try { using (Folder folder = Folder.Bind(session, folderId)) { bool flag2 = true; StoreId linkedFolderIdForFilteredView = OwaFilterState.GetLinkedFolderIdForFilteredView(session, folderId, filter); if (linkedFolderIdForFilteredView != null && viewFolder.StoreObjectId.Equals(linkedFolderIdForFilteredView)) { flag2 = false; flag = true; } if (flag2) { folder.SafeSetProperty(OwaFilterState.FilterToLinkPropertyDefinitionsMap[filter], viewFolder.Id.ObjectId.ProviderLevelItemId); FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult == OperationResult.Succeeded) { ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "[OwaFilterState::LinkViewFolder] Search Folder Name = {0} linked to physical folder", viewFolder.DisplayName); flag = true; } else { ex = folderSaveResult.Exception; } } } } catch (ObjectNotFoundException ex2) { ex = ex2; } if (!flag) { string arg = (ex != null) ? ex.ToString() : "[OwaFilterState::LinkViewFolder] FolderSaveResult.OperationResult != OperationResult.Succeeded"; string message = string.Format("Linking the view folder ({0}) failed. Details= {1}", viewFolder.DisplayName, arg); ExTraceGlobals.StorageTracer.TraceError(0L, message); } } else { ExTraceGlobals.StorageTracer.TraceDebug <OwaViewFilter>(0L, "[OwaFilterState::LinkViewFolder] The specified OwaViewFilter {0} is not supported for linking to the source folder.", filter); } return(flag); }
public static G RunQueryOnAllItemsFolder <G>(MailboxSession session, AllItemsFolderHelper.SupportedSortBy supportedSortBy, AllItemsFolderHelper.DoQueryProcessing <G> queryProcessor, ICollection <PropertyDefinition> properties, ItemQueryType itemQueryType) { AllItemsFolderHelper.CheckAndCreateDefaultFolders(session); G result; using (SearchFolder searchFolder = SearchFolder.Bind(session, DefaultFolderType.AllItems)) { using (QueryResult queryResult = searchFolder.ItemQuery(itemQueryType, null, AllItemsFolderHelper.sortOrderMap[supportedSortBy], properties)) { result = queryProcessor(queryResult); } } return(result); }
private static void TryApplyContinuousSearch(SearchFolder folder, SearchFolderCriteria criteria) { try { folder.ApplyContinuousSearch(criteria); } catch (QueryInProgressException) { SearchFolderCriteria searchFolderCriteria = SearchFolderValidation.TryGetSearchCriteria(folder); if (searchFolderCriteria == null || !SearchFolderValidation.MatchSearchFolderCriteria(criteria, searchFolderCriteria)) { throw; } } }
public static OwaFilterState GetOwaFilterStateForExistingFolder(MailboxSession mailboxSession, StoreId searchFolderId) { ExTraceGlobals.StorageTracer.TraceDebug <StoreId>(0L, "[OwaFilterState::GetOwaFilterStateForExistingFolder] Get the filter state for the specified folder id: {0}", searchFolderId); OwaFilterState result = null; OwaSearchContext searchContext = new OwaSearchContext(); using (SearchFolder searchFolder = OwaFilterState.BindExistingFilteredViewSearchFolder(searchFolderId, mailboxSession, searchContext)) { if (searchFolder != null) { result = OwaFilterState.ParseFromPropertyValue(OwaFilterState.GetFolderProperty <object>(searchFolder, OwaFilteredViewProperties.FilteredViewLabel, null)); } } return(result); }
internal static SearchFolderCriteria TryGetSearchCriteria(SearchFolder folder) { SearchFolderCriteria result = null; try { result = folder.GetSearchCriteria(); } catch (ObjectNotInitializedException) { } catch (CorruptDataException) { } return(result); }
private static SearchFolder BindExistingFilteredViewSearchFolder(StoreId searchFolderId, MailboxSession mailboxSession, OwaSearchContext searchContext) { SearchFolder result = null; try { result = SearchFolder.Bind(mailboxSession, searchFolderId, OwaFilterState.FolderQueryProperties); } catch (ObjectNotFoundException) { searchContext.ViewFilterActions |= ViewFilterActions.ObjectNotFoundException; string message = string.Format("[OwaFilterState::BindExistingFilteredViewSearchFolder] Attempt to bind to search folder failed {0}. ViewFilterActions: {1}", searchFolderId.ToString(), (int)searchContext.ViewFilterActions); ExTraceGlobals.StorageTracer.TraceDebug(0L, message); } return(result); }
internal override bool EnsureIsValid(DefaultFolderContext context, Folder folder) { if (!base.EnsureIsValid(context, folder) || !(folder is SearchFolder)) { return(false); } SearchFolder searchFolder = (SearchFolder)folder; SearchFolderCriteria searchFolderCriteria = CalendarVersionStoreValidation.CreateCalendarVersionSearchCriteria(context); SearchFolderCriteria searchCriteria = searchFolder.GetSearchCriteria(); if (!SearchFolderValidation.MatchSearchFolderCriteria(searchCriteria, searchFolderCriteria)) { searchFolder.ApplyContinuousSearch(searchFolderCriteria); } return(true); }
internal override bool EnsureIsValid(DefaultFolderContext context, Folder folder) { if (!base.EnsureIsValid(context, folder)) { return(false); } SearchFolder searchFolder = folder as SearchFolder; if (searchFolder == null) { return(false); } if (SearchFolderValidation.TryGetSearchCriteria(searchFolder) == null) { this.SetPropertiesInternal(context, folder); } return(true); }
private static SearchFolder BindAndUpdateExistingFilteredViewSearchFolder(MailboxSession mailboxSession, OwaSearchContext searchContext) { SearchFolder searchFolder = OwaFilterState.BindExistingFilteredViewSearchFolder(searchContext.SearchFolderId, mailboxSession, searchContext); if (searchFolder != null) { string folderProperty = OwaFilterState.GetFolderProperty <string>(searchFolder, FolderSchema.DisplayName, string.Empty); ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "[OwaFilterState::BindAndUpdateExistingFilteredViewSearchFolder] Re-using existing filtered view search folder: {0}", folderProperty); searchContext.IsSearchFailed = !OwaFilterState.EnsureSearchIsCompleted(searchFolder, mailboxSession, searchContext); if (!searchContext.IsSearchFailed) { searchFolder[OwaFilteredViewProperties.FilteredViewAccessTime] = ExDateTime.Now; searchFolder.Save(); searchFolder.Load(); if ((searchContext.ViewFilterActions & ViewFilterActions.BindToExisting) == ViewFilterActions.None && OwaFilterState.LinkViewFolder(mailboxSession, searchContext.FolderIdToSearch, searchFolder, searchContext.ViewFilter)) { searchContext.ViewFilterActions |= ViewFilterActions.LinkToSourceFolderSucceeded; } } } return(searchFolder); }
private Folder CreateNewFolder(DefaultFolderContext context, string displayName, StoreObjectId parentFolderObjectId) { Folder result; if (this.storeObjectType == StoreObjectType.Folder || this.storeObjectType == StoreObjectType.ContactsFolder) { result = Folder.Create(context.Session, parentFolderObjectId, this.storeObjectType, displayName, CreateMode.CreateNew); } else if (this.storeObjectType == StoreObjectType.OutlookSearchFolder) { result = OutlookSearchFolder.Create(context.Session, displayName); } else { if (this.storeObjectType != StoreObjectType.SearchFolder) { throw new NotSupportedException(string.Format("The type of folder cannot be created. type = {0}.", this.storeObjectType)); } result = SearchFolder.Create(context.Session, parentFolderObjectId, displayName, CreateMode.CreateNew); } return(result); }
private void PreprocessSearch(SearchFolderCriteria searchFolderCriteria, SearchFolder.SearchType searchType, out SetSearchCriteriaFlags searchCriteriaFlags) { if (searchFolderCriteria == null) { throw new ArgumentNullException("searchFolderCriteria"); } if (this.IsDirty) { throw new InvalidOperationException(ServerStrings.ExMustSaveFolderToApplySearch); } this.DisposeCurrentSearch(); SetSearchCriteriaFlags setSearchCriteriaFlags = SetSearchCriteriaFlags.None; if (searchFolderCriteria.StatisticsOnly) { setSearchCriteriaFlags |= SetSearchCriteriaFlags.StatisticsOnly; } if (searchFolderCriteria.EstimateCountOnly) { setSearchCriteriaFlags |= SetSearchCriteriaFlags.EstimateCountOnly; } searchCriteriaFlags = SearchFolder.CalculateSearchCriteriaFlags(searchFolderCriteria.DeepTraversal, searchFolderCriteria.UseCiForComplexQueries, setSearchCriteriaFlags, searchFolderCriteria.FailNonContentIndexedSearch, searchType); }
public static SearchFolder Bind(MailboxSession session, DefaultFolderType defaultFolderType) { return(SearchFolder.Bind(session, defaultFolderType, null)); }
public new static SearchFolder Bind(StoreSession session, StoreId folderId, params PropertyDefinition[] propsToReturn) { return(SearchFolder.Bind(session, folderId, (ICollection <PropertyDefinition>)propsToReturn)); }
public new static SearchFolder Bind(StoreSession session, StoreId folderId) { return(SearchFolder.Bind(session, folderId, null)); }
private static void UpdateFilteredViewSearchFolder(MailboxSession mailboxSession, SearchFolder searchFolder, OwaSearchContext searchContext) { ExTraceGlobals.StorageTracer.TraceDebug <string, OwaViewFilter>(0L, "[OwaFilterState::UpdateFilteredViewSearchFolder] updating search folder: {0} for filter: {1}", searchContext.ClientSearchFolderIdentity, searchContext.ViewFilter); searchFolder[FolderSchema.SearchFolderAllowAgeout] = true; searchFolder[OwaFilteredViewProperties.FilteredViewLabel] = OwaFilterState.GetPropertyValueToSave(mailboxSession, searchContext.FolderIdToSearch, searchContext.ViewFilter, searchContext.FromFilter); searchFolder[OwaFilteredViewProperties.FilteredViewAccessTime] = ExDateTime.Now; int folderProperty = OwaFilterState.GetFolderProperty <int>(searchFolder, FolderSchema.ExtendedFolderFlags, 0); searchFolder[FolderSchema.ExtendedFolderFlags] = (folderProperty | 4194304); searchFolder.Save(); searchFolder.Load(); }
public static SearchFolder CreateOrOpenOwaFilteredViewSearchFolder(MailboxSession mailboxSession, OwaSearchContext searchContext, StoreId searchFoldersRootId, SearchFolderCriteria searchFolderCriteria, bool flushStaleFolders = true) { ExTraceGlobals.StorageTracer.TraceDebug <OwaViewFilter>(0L, "[OwaFilterState::CreateOrOpenOwaFilteredViewSearchFolder] Create or open the specified filtered view: {0}", searchContext.ViewFilter); SearchFolder searchFolder = null; bool flag = true; searchContext.ViewFilterActions = ViewFilterActions.None; try { searchContext.ClientSearchFolderIdentity = OwaFilterState.GetOwaFilteredViewSearchFolderName(mailboxSession, searchContext); if (searchContext.SearchFolderId == null && OwaFilterState.FilterToLinkPropertyDefinitionsMap.ContainsKey(searchContext.ViewFilter)) { StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); if (defaultFolderId.Equals(searchContext.FolderIdToSearch)) { searchContext.SearchFolderId = OwaFilterState.GetLinkedFolderIdForFilteredView(mailboxSession, searchContext.FolderIdToSearch, searchContext.ViewFilter); } } if (searchContext.SearchFolderId != null) { searchContext.ViewFilterActions |= ViewFilterActions.BindToExisting; searchFolder = OwaFilterState.BindAndUpdateExistingFilteredViewSearchFolder(mailboxSession, searchContext); } if (searchFolder == null) { searchContext.ViewFilterActions |= ViewFilterActions.FindExisting; searchFolder = OwaFilterState.GetFilteredView(mailboxSession, searchContext, searchFoldersRootId, flushStaleFolders); } if (searchContext.IsSearchFailed && searchFolder != null) { ExTraceGlobals.StorageTracer.TraceError <string, StoreId>(0L, "[OwaFilterState::CreateOrOpenOwaFilteredViewSearchFolder] deleting search folder: {0} using searchContext.SearchFolderId: {1}", searchContext.ClientSearchFolderIdentity, searchContext.SearchFolderId); searchContext.ViewFilterActions |= ViewFilterActions.DeleteInvalidSearchFolder; mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[] { searchContext.SearchFolderId }); searchContext.SearchFolderId = null; searchContext.IsSearchFailed = false; searchFolder.Dispose(); searchFolder = null; } if (searchFolder == null) { searchContext.ViewFilterActions |= ViewFilterActions.CreateFilter; searchFolder = OwaFilterState.CreateAndUpdateFilteredViewSearchFolder(mailboxSession, searchContext, searchFoldersRootId, searchFolderCriteria); } ExTraceGlobals.StorageTracer.TraceDebug(0L, string.Format("{0}_{1}", searchContext.ClientSearchFolderIdentity, (int)searchContext.ViewFilterActions)); flag = false; } finally { if (flag) { ExTraceGlobals.StorageTracer.TraceError(0L, "[OwaFilterState::CreateOrOpenOwaFilteredViewSearchFolder] Creating/Opening of dynamic search folder failed. Setting search folder to null and disposing it"); if (searchFolder != null) { searchFolder.Dispose(); searchFolder = null; } } } return(searchFolder); }
private static bool EnsureSearchIsCompleted(SearchFolder searchFolder, MailboxSession mailboxSession, OwaSearchContext searchContext) { ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "[OwaFilterState::EnsureSearchIsCompleted] Start. search folder: {0}", searchContext.ClientSearchFolderIdentity); Subscription subscription = null; bool searchCompleted = false; SearchState searchState = SearchState.Error; bool result; try { SearchFolderCriteria searchCriteria = searchFolder.GetSearchCriteria(); if (searchCriteria != null) { searchState = searchCriteria.SearchState; } if ((searchState & SearchState.Rebuild) == SearchState.Rebuild) { ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "[OwaFilterState::EnsureSearchIsCompleted] SearchState.Rebuild == true. search folder: {0}", searchContext.ClientSearchFolderIdentity); ManualResetEvent completedEvent = new ManualResetEvent(false); subscription = Subscription.Create(mailboxSession, delegate(Notification notification) { if ((notification.Type & NotificationType.SearchComplete) == NotificationType.SearchComplete) { searchCompleted = true; completedEvent.Set(); } }, NotificationType.SearchComplete, searchFolder.StoreObjectId); completedEvent.WaitOne(searchContext.SearchTimeoutInMilliseconds); if (!searchCompleted) { searchCompleted = true; searchContext.ViewFilterActions |= ViewFilterActions.PopulateSearchFolderTimedOut; ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "[OwaFilterState::EnsureSearchIsCompleted] Search timed out for search folder: {0}", searchContext.ClientSearchFolderIdentity); } } else { ExTraceGlobals.StorageTracer.TraceDebug <SearchState, string, string>(0L, "[OwaFilterState::EnsureSearchIsCompleted] SearchFolder not rebuilding. searchState: {0}. searchCriteria: {1} for search folder: {2}", searchState, searchCriteria.ToString(), searchContext.ClientSearchFolderIdentity); searchCompleted = ((searchState & SearchState.Error) != SearchState.Error); } ExTraceGlobals.StorageTracer.TraceDebug <bool, string>(0L, "[OwaFilterState::EnsureSearchIsCompleted] Is searchCompleted is: {0} for search folder: {1}", searchCompleted, searchContext.ClientSearchFolderIdentity); searchContext.ViewFilterActions |= ViewFilterActions.SearchCompleted; result = searchCompleted; } catch (ObjectNotInitializedException) { searchContext.ViewFilterActions |= ViewFilterActions.ObjectNotInitializedException; string message = string.Format("[OwaFilterState::EnsureSearchIsCompleted] ObjectNotInitializedException thrown, searchCompleted is false for search folder: {0}. ViewFilterActions: {1}", searchContext.ClientSearchFolderIdentity, (int)searchContext.ViewFilterActions); ExTraceGlobals.StorageTracer.TraceError(0L, message); result = false; } catch (CorruptDataException ex) { searchContext.ViewFilterActions |= ViewFilterActions.CorruptDataException; string text = string.Format("[OwaFilterState::EnsureSearchIsCompleted] CorruptDataException thrown, searchCompleted is false for search folder: {0}. Exception: {1}. ViewFilterActions: {2}", searchContext.ClientSearchFolderIdentity, ex.ToString(), (int)searchContext.ViewFilterActions); ExTraceGlobals.StorageTracer.TraceError(0L, text); OwaFilterState.SendWatsonWithoutDump(ex, text); result = false; } finally { if (subscription != null) { subscription.Dispose(); subscription = null; } } return(result); }