Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public static StoreObjectId GetLinkedFolderIdForFilteredView(MailboxSession session, StoreId sourceFolderId, OwaViewFilter viewFilter)
        {
            StoreObjectId result = null;

            try
            {
                using (Folder folder = Folder.Bind(session, sourceFolderId))
                {
                    byte[] folderProperty = OwaFilterState.GetFolderProperty <byte[]>(folder, OwaFilterState.FilterToLinkPropertyDefinitionsMap[viewFilter], null);
                    if (folderProperty != null)
                    {
                        result = StoreObjectId.FromProviderSpecificId(folderProperty, StoreObjectType.Folder);
                    }
                }
            }
            catch (CorruptDataException arg)
            {
                ExTraceGlobals.StorageTracer.TraceError <OwaViewFilter, CorruptDataException>(0L, "[OwaFilterState::GetLinkedFolderIdForFilteredView] Caught a CorruptDataException for OwaViewFilter {0}: {1}", viewFilter, arg);
            }
            return(result);
        }
Exemplo n.º 4
0
        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);
        }