Beispiel #1
0
        // Token: 0x06000F5F RID: 3935 RVA: 0x0003BBE0 File Offset: 0x00039DE0
        public static ItemType[] GetItemDataFromSearchFolder(OwaSearchContext searchContext, MailboxSession mailboxSession, out int totalRowCount)
        {
            List <ItemType> list = new List <ItemType>(50);

            totalRowCount = 0;
            StoreId searchFolderId = searchContext.SearchFolderId;

            SortBy[] searchSortBy = searchContext.SearchSortBy;
            using (SearchFolder searchFolder = SearchFolder.Bind(mailboxSession, searchFolderId))
            {
                int rowCount = 25;
                using (QueryResult queryResult = searchFolder.ItemQuery(ItemQueryType.None, null, searchSortBy, SearchFolderItemDataRetriever.itemSearchPropertyDefinitions))
                {
                    bool flag = true;
                    while (flag)
                    {
                        object[][] rows = queryResult.GetRows(rowCount, out flag);
                        if (rows == null || rows.Length == 0)
                        {
                            break;
                        }
                        for (int i = 0; i < rows.Length; i++)
                        {
                            if (totalRowCount < 50)
                            {
                                ItemType itemFromDataRow = SearchFolderItemDataRetriever.GetItemFromDataRow(searchContext, mailboxSession, rows[i], SearchFolderItemDataRetriever.itemSearchPropertyDefinitionsOrderDictionary);
                                list.Add(itemFromDataRow);
                            }
                            totalRowCount++;
                        }
                    }
                }
            }
            return(list.ToArray());
        }
Beispiel #2
0
        // Token: 0x06001359 RID: 4953 RVA: 0x00077AAC File Offset: 0x00075CAC
        private static bool GetSearchFolderData(UserContext userContext, out int searchFolderItemCount, out SearchState searchState, out bool isRemoteSession)
        {
            searchFolderItemCount = -1;
            searchState           = SearchState.None;
            isRemoteSession       = false;
            bool result = false;

            if (userContext.SearchFolderId != null)
            {
                try
                {
                    using (SearchFolder searchFolder = SearchFolder.Bind(userContext.SearchFolderId.GetSession(userContext), userContext.SearchFolderId.StoreObjectId, SearchPerformanceData.searchFolderProperties))
                    {
                        object obj = searchFolder.TryGetProperty(FolderSchema.SearchFolderItemCount);
                        if (obj is int)
                        {
                            searchFolderItemCount = (int)obj;
                        }
                        searchState     = searchFolder.GetSearchCriteria().SearchState;
                        isRemoteSession = searchFolder.Session.IsRemote;
                    }
                    result = true;
                }
                catch (ObjectNotFoundException)
                {
                }
            }
            return(result);
        }
Beispiel #3
0
        private SearchFolder GetSearchFolder(MailboxSession session)
        {
            bool          flag          = false;
            StoreObjectId storeObjectId = this.GetCvsFolderIdIfPresent(session);
            SearchFolder  searchFolder  = null;

            try
            {
                if (storeObjectId == null)
                {
                    storeObjectId = session.CreateDefaultFolder(DefaultFolderType.CalendarVersionStore);
                }
                try
                {
                    searchFolder = SearchFolder.Bind(session, storeObjectId);
                }
                catch (ObjectNotFoundException innerException)
                {
                    ExTraceGlobals.DefaultFoldersTracer.TraceError <string, StoreObjectId>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetSearchFolder - No item is found with the CVS search folder ID (Session Display Name: {0}; Folder ID: {1}).", session.DisplayName, storeObjectId);
                    throw new CalendarVersionStoreNotPopulatedException(false, SearchState.None, TimeSpan.Zero, innerException);
                }
                catch (WrongObjectTypeException innerException2)
                {
                    ExTraceGlobals.DefaultFoldersTracer.TraceError <string, StoreObjectId>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetSearchFolder - The CVS search folder ID does not belong to a search folder (Session Display Name: {0}; Folder ID: {1}).", session.DisplayName, storeObjectId);
                    throw new CalendarVersionStoreNotPopulatedException(false, SearchState.None, TimeSpan.Zero, innerException2);
                }
                SearchState folderState;
                if (!this.IsSearchFolderPopulated(searchFolder, out folderState))
                {
                    if (this.Policy.WaitForPopulation)
                    {
                        using (SearchFolderAsyncSearch searchFolderAsyncSearch = new SearchFolderAsyncSearch(session, storeObjectId, null, null))
                        {
                            if (!this.IsSearchFolderPopulated(searchFolder, out folderState) && !searchFolderAsyncSearch.AsyncResult.AsyncWaitHandle.WaitOne(this.Policy.WaitTimeForPopulation))
                            {
                                ExTraceGlobals.DefaultFoldersTracer.TraceDebug <TimeSpan, string>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetSearchFolder - The CVS search folder is not populated, and timeout ({0}) is passed (Session Display Name: {1}).", this.Policy.WaitTimeForPopulation, session.DisplayName);
                                throw new CalendarVersionStoreNotPopulatedException(true, folderState, this.Policy.WaitTimeForPopulation);
                            }
                            goto IL_151;
                        }
                    }
                    ExTraceGlobals.DefaultFoldersTracer.TraceDebug <string>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetSearchFolder - The CVS search folder is not populated, and query policy has no wait time specified (Session Display Name: {0}).", session.DisplayName);
                    throw new CalendarVersionStoreNotPopulatedException(true, folderState, TimeSpan.Zero);
                }
IL_151:
                flag = true;
            }
            finally
            {
                if (!flag && searchFolder != null)
                {
                    searchFolder.Dispose();
                }
            }
            return(searchFolder);
        }
        public static List <object[]> QueryReminders(ExDateTime actualizationTime, UserContext userContext)
        {
            List <object[]> list = new List <object[]>();

            object[][]       array            = null;
            ComparisonFilter comparisonFilter = new ComparisonFilter(ComparisonOperator.LessThan, ItemSchema.ReminderNextTime, actualizationTime.AddHours(24.0));

            if (userContext.IsPushNotificationsEnabled)
            {
                array = userContext.MapiNotificationManager.GetReminderRows(comparisonFilter, 100);
            }
            else
            {
                using (SearchFolder searchFolder = SearchFolder.Bind(userContext.MailboxSession, DefaultFolderType.Reminders))
                {
                    SortBy[] sortColumns = new SortBy[]
                    {
                        new SortBy(ItemSchema.ReminderIsSet, SortOrder.Descending),
                        new SortBy(ItemSchema.ReminderNextTime, SortOrder.Descending)
                    };
                    using (QueryResult queryResult = searchFolder.ItemQuery(ItemQueryType.None, null, sortColumns, RemindersRenderingUtilities.QueryProperties))
                    {
                        queryResult.SeekToCondition(SeekReference.OriginBeginning, comparisonFilter);
                        array = queryResult.GetRows(100);
                    }
                }
            }
            if (array == null)
            {
                return(list);
            }
            for (int i = 0; i < array.Length; i++)
            {
                bool itemProperty = RemindersRenderingUtilities.GetItemProperty <bool>(array[i], ItemSchema.ReminderIsSet, false);
                if (!itemProperty)
                {
                    break;
                }
                list.Add(array[i]);
                if (list.Count == 100)
                {
                    break;
                }
            }
            return(list);
        }
Beispiel #5
0
 private void InitReminderTableSubscription()
 {
     if (this.reminderSub == null)
     {
         using (SearchFolder searchFolder = SearchFolder.Bind(this.mailboxSession, DefaultFolderType.Reminders))
         {
             SortBy[] sortColumns = new SortBy[]
             {
                 new SortBy(ItemSchema.ReminderIsSet, SortOrder.Descending),
                 new SortBy(ItemSchema.ReminderNextTime, SortOrder.Descending)
             };
             this.queryResultReminder = searchFolder.ItemQuery(ItemQueryType.None, null, sortColumns, RemindersRenderingUtilities.QueryProperties);
             this.queryResultReminder.GetRows(1);
             this.reminderSub = Subscription.Create(this.queryResultReminder, new NotificationHandler(this.HandleReminderNotification));
         }
     }
 }
 private void SetUpRemindersSubscription(int currentRetryCount)
 {
     if (!base.UserContext.MailboxSessionLockedByCurrentThread())
     {
         throw new InvalidOperationException("UserContext lock should be acquired before calling this method ReminderNotificationHandler.SetUpRemindersSubscription");
     }
     try
     {
         using (SearchFolder searchFolder = SearchFolder.Bind(base.UserContext.MailboxSession, DefaultFolderType.Reminders))
         {
             base.QueryResult = searchFolder.ItemQuery(ItemQueryType.None, null, ReminderNotificationHandler.sorts, ReminderNotificationHandler.querySubscriptionProperties);
             base.QueryResult.GetRows(1);
             base.Subscription = Subscription.Create(base.QueryResult, new NotificationHandler(base.HandleNotification));
         }
     }
     catch (QueryInProgressException)
     {
         if (currentRetryCount >= 5)
         {
             throw;
         }
         this.SetUpRemindersSubscription(currentRetryCount + 1);
     }
 }
Beispiel #7
0
        // Token: 0x06000ABD RID: 2749 RVA: 0x00046480 File Offset: 0x00044680
        private void SendMwiMessage(MailboxInfo mailbox, MailboxSession itemStore)
        {
            StoreObjectId umsearchFolderId = MwiAssistant.GetUMSearchFolderId(itemStore);

            if (umsearchFolderId == null)
            {
                ExTraceGlobals.MWITracer.TraceWarning <MailboxInfo>((long)this.GetHashCode(), "MwiAssistant.SendMwiMessage(): Skipping event. Could not get Voice Mail search folder for {0}.", mailbox);
                return;
            }
            using (SearchFolder searchFolder = SearchFolder.Bind(itemStore, umsearchFolderId, new PropertyDefinition[]
            {
                FolderSchema.ItemCount,
                FolderSchema.UnreadCount
            }))
            {
                int itemCount = searchFolder.ItemCount;
                int num       = (int)searchFolder[FolderSchema.UnreadCount];
                ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo, int, int>((long)this.GetHashCode(), "MwiAssistant.SendMwiMessage(): Sending MWI for user {0}, itemCount={1}, unreadCount={2}", mailbox, itemCount, num);
                IADSystemConfigurationLookup iadsystemConfigurationLookup = ADSystemConfigurationLookupFactory.CreateFromOrganizationId(mailbox.OrganizationId);
                Guid       externalDirectoryOrganizationId = iadsystemConfigurationLookup.GetExternalDirectoryOrganizationId();
                MwiMessage message = new MwiMessage(mailbox.Guid, mailbox.DialPlanGuid, mailbox.DisplayName, mailbox.UMExtension, num, itemCount, MwiAssistant.MessageExpirationTime, mailbox.EventTimeUtc, externalDirectoryOrganizationId);
                this.loadBalancer.SendMessage(message);
            }
        }
Beispiel #8
0
        // Token: 0x06000942 RID: 2370 RVA: 0x000424EC File Offset: 0x000406EC
        public Folder Execute(UserContext userContext, Folder folder, SearchScope searchScope, string searchString, bool newSearch, bool asyncSearch)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }
            MailboxSession   mailboxSession   = (MailboxSession)folder.Session;
            QueryFilter      queryFilter      = SearchFilterGenerator.Execute(searchString, mailboxSession.Mailbox.IsContentIndexingEnabled, userContext.UserCulture, new PolicyTagMailboxProvider(userContext.MailboxSession), folder, searchScope, this.advancedQueryFilter);
            string           text             = (queryFilter == null) ? string.Empty : queryFilter.ToString();
            OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromStoreObject(folder);
            SearchFolder     searchFolder     = null;
            bool             flag             = false;
            Folder           result;

            try
            {
                if (userContext.SearchFolderId != null)
                {
                    if (!newSearch && userContext.LastSearchFolderId.Equals(owaStoreObjectId) && userContext.LastSearchQueryFilter.CompareTo(text) == 0 && userContext.LastSearchScope == searchScope)
                    {
                        try
                        {
                            searchFolder = SearchFolder.Bind(userContext.SearchFolderId.GetSession(userContext), userContext.SearchFolderId.StoreObjectId, FolderSearch.PrefetchProperties);
                        }
                        catch (ObjectNotFoundException)
                        {
                        }
                        if (searchFolder != null)
                        {
                            if (asyncSearch)
                            {
                                SearchPerformanceData searchPerformanceData = userContext.MapiNotificationManager.GetSearchPerformanceData(mailboxSession);
                                if (searchPerformanceData != null)
                                {
                                    searchPerformanceData.RefreshStart();
                                }
                                OwaContext.Current.SearchPerformanceData = searchPerformanceData;
                            }
                            flag = true;
                            return(searchFolder);
                        }
                    }
                    if (userContext.IsPushNotificationsEnabled)
                    {
                        userContext.MapiNotificationManager.CancelSearchNotifications(mailboxSession);
                        userContext.MapiNotificationManager.AddSearchFolderDeleteList(mailboxSession, userContext.SearchFolderId.StoreObjectId);
                    }
                    else
                    {
                        mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                        {
                            userContext.SearchFolderId.StoreObjectId
                        });
                    }
                    userContext.SearchFolderId = null;
                }
                using (Folder folder2 = Folder.Bind(mailboxSession, userContext.GetSearchFoldersId(mailboxSession).StoreObjectId))
                {
                    searchFolder = SearchFolder.Create(mailboxSession, folder2.Id.ObjectId, "OWA Search " + userContext.Key.UserContextId + " " + DateTime.UtcNow.ToString("o"), CreateMode.CreateNew);
                }
                searchFolder.Save();
                searchFolder.Load(FolderSearch.PrefetchProperties);
                userContext.SearchFolderId        = OwaStoreObjectId.CreateFromStoreObject(searchFolder);
                userContext.LastSearchFolderId    = owaStoreObjectId;
                userContext.LastSearchQueryFilter = text;
                userContext.LastSearchScope       = searchScope;
                if (queryFilter == null)
                {
                    flag   = true;
                    result = searchFolder;
                }
                else
                {
                    bool      flag2 = FolderSearch.FailNonContentIndexedSearch(folder, queryFilter);
                    bool      flag3;
                    StoreId[] folderScope;
                    if (searchScope == SearchScope.SelectedFolder || !mailboxSession.Mailbox.IsContentIndexingEnabled)
                    {
                        flag3       = false;
                        folderScope = new StoreId[]
                        {
                            folder.Id.ObjectId
                        };
                    }
                    else if (searchScope == SearchScope.SelectedAndSubfolders)
                    {
                        flag3       = true;
                        folderScope = new StoreId[]
                        {
                            folder.Id.ObjectId
                        };
                    }
                    else
                    {
                        if (searchScope != SearchScope.AllFoldersAndItems && searchScope != SearchScope.AllItemsInModule)
                        {
                            throw new ArgumentOutOfRangeException();
                        }
                        flag3       = true;
                        folderScope = new StoreId[]
                        {
                            userContext.GetRootFolderId(mailboxSession)
                        };
                    }
                    if (searchScope != SearchScope.SelectedFolder)
                    {
                        if (!folder.Id.ObjectId.Equals(userContext.JunkEmailFolderId))
                        {
                            QueryFilter queryFilter2 = new ComparisonFilter(ComparisonOperator.NotEqual, StoreObjectSchema.ParentItemId, userContext.JunkEmailFolderId);
                            queryFilter = new AndFilter(new QueryFilter[]
                            {
                                queryFilter,
                                queryFilter2
                            });
                        }
                        StoreObjectId storeObjectId = userContext.GetDeletedItemsFolderId((MailboxSession)folder.Session).StoreObjectId;
                        if (!folder.Id.ObjectId.Equals(storeObjectId))
                        {
                            QueryFilter queryFilter3 = new ComparisonFilter(ComparisonOperator.NotEqual, StoreObjectSchema.ParentItemId, storeObjectId);
                            queryFilter = new AndFilter(new QueryFilter[]
                            {
                                queryFilter,
                                queryFilter3
                            });
                        }
                    }
                    ExTraceGlobals.MailDataTracer.TraceDebug((long)this.GetHashCode(), "Search\nFilter: {0}\nDeep Traversal: {1}\nFolder: {2}\nContent Indexing Enabled: {3}", new object[]
                    {
                        queryFilter,
                        flag3,
                        folder.Id,
                        mailboxSession.Mailbox.IsContentIndexingEnabled ? "Yes" : "No"
                    });
                    SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(queryFilter, folderScope);
                    searchFolderCriteria.DeepTraversal               = flag3;
                    searchFolderCriteria.MaximumResultsCount         = new int?(1000);
                    searchFolderCriteria.FailNonContentIndexedSearch = flag2;
                    SearchPerformanceData searchPerformanceData;
                    if (!userContext.IsPushNotificationsEnabled || !asyncSearch)
                    {
                        searchPerformanceData = new SearchPerformanceData();
                        searchPerformanceData.StartSearch(searchString);
                        IAsyncResult asyncResult = searchFolder.BeginApplyOneTimeSearch(searchFolderCriteria, null, null);
                        Stopwatch    stopwatch   = Utilities.StartWatch();
                        bool         flag4       = asyncResult.AsyncWaitHandle.WaitOne(30000, false);
                        searchPerformanceData.Complete(!flag4, true);
                        if (flag4)
                        {
                            searchFolder.EndApplyOneTimeSearch(asyncResult);
                        }
                        else
                        {
                            ExTraceGlobals.MailTracer.TraceDebug((long)this.GetHashCode(), "FolderSearch.Execute. Search timed out.");
                            if (Globals.ArePerfCountersEnabled)
                            {
                                OwaSingleCounters.SearchesTimedOut.Increment();
                            }
                        }
                        Utilities.StopWatch(stopwatch, "FolderSearch.Execute (Wait for search to complete)");
                        if (Globals.ArePerfCountersEnabled)
                        {
                            PerformanceCounterManager.UpdateSearchTimePerformanceCounter(stopwatch.ElapsedMilliseconds);
                            OwaSingleCounters.TotalSearches.Increment();
                        }
                        searchFolder.Save();
                        searchFolder.Load(FolderSearch.PrefetchProperties);
                    }
                    else
                    {
                        userContext.MapiNotificationManager.InitSearchNotifications(mailboxSession, userContext.SearchFolderId.StoreObjectId, searchFolder, searchFolderCriteria, searchString);
                        searchPerformanceData = userContext.MapiNotificationManager.GetSearchPerformanceData(mailboxSession);
                    }
                    if (!flag2)
                    {
                        searchPerformanceData.SlowSearchEnabled();
                    }
                    OwaContext.Current.SearchPerformanceData = searchPerformanceData;
                    flag   = true;
                    result = searchFolder;
                }
            }
            finally
            {
                if (!flag && searchFolder != null)
                {
                    searchFolder.Dispose();
                }
            }
            return(result);
        }
Beispiel #9
0
        public void Remove()
        {
            base.ThrowIfCannotActAsOwner();
            StoreObjectId nodeId = (StoreObjectId)base.GetParameter("srcNId");
            NavigationNodeGroupSection navigationNodeGroupSection = (NavigationNodeGroupSection)base.GetParameter("GS");
            NavigationNodeCollection   navigationNodeCollection   = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, navigationNodeGroupSection);
            List <OwaStoreObjectId>    list           = new List <OwaStoreObjectId>();
            NavigationNode             navigationNode = navigationNodeCollection.FindNavigationNodeByNodeId(nodeId);

            if (navigationNode == null)
            {
                base.RenderPartialFailure(-289549140, OwaEventHandlerErrorCode.NotSet);
            }
            else
            {
                OperationResult operationResult = (OperationResult)0;
                if (navigationNodeGroupSection != NavigationNodeGroupSection.First)
                {
                    List <NavigationNodeFolder> list2 = new List <NavigationNodeFolder>();
                    if (navigationNode is NavigationNodeFolder)
                    {
                        list2.Add(navigationNode as NavigationNodeFolder);
                    }
                    else if (navigationNode is NavigationNodeGroup)
                    {
                        NavigationNodeGroup navigationNodeGroup = navigationNode as NavigationNodeGroup;
                        foreach (NavigationNodeFolder item in navigationNodeGroup.Children)
                        {
                            list2.Add(item);
                        }
                    }
                    foreach (NavigationNodeFolder navigationNodeFolder in list2)
                    {
                        if (navigationNodeFolder.IsValid)
                        {
                            OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromNavigationNodeFolder(base.UserContext, navigationNodeFolder);
                            MailboxSession   mailboxSession   = owaStoreObjectId.IsArchive ? ((MailboxSession)owaStoreObjectId.GetSession(base.UserContext)) : base.UserContext.MailboxSession;
                            if (navigationNodeFolder.IsFolderInSpecificMailboxSession(mailboxSession))
                            {
                                if (Utilities.IsSpecialFolderForSession(mailboxSession, navigationNodeFolder.FolderId))
                                {
                                    throw new OwaEventHandlerException("Cannot delete default folders.", LocalizedStrings.GetNonEncoded(-1164567320), true);
                                }
                                if (operationResult == (OperationResult)0)
                                {
                                    operationResult = OperationResult.Succeeded;
                                }
                                AggregateOperationResult aggregateOperationResult = mailboxSession.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                                {
                                    navigationNodeFolder.FolderId
                                });
                                if (aggregateOperationResult.OperationResult == OperationResult.Succeeded)
                                {
                                    list.Add(OwaStoreObjectId.CreateFromNavigationNodeFolder(base.UserContext, navigationNodeFolder));
                                }
                                else
                                {
                                    operationResult = OperationResult.PartiallySucceeded;
                                }
                            }
                        }
                    }
                    if (operationResult != (OperationResult)0 && list.Count == 0)
                    {
                        operationResult = OperationResult.Failed;
                    }
                    if (operationResult == OperationResult.Failed)
                    {
                        base.RenderPartialFailure(1041829989, OwaEventHandlerErrorCode.NotSet);
                    }
                    else if (operationResult == OperationResult.PartiallySucceeded)
                    {
                        base.RenderPartialFailure(995407892, OwaEventHandlerErrorCode.NotSet);
                    }
                }
                else
                {
                    NavigationNodeFolder navigationNodeFolder2 = navigationNode as NavigationNodeFolder;
                    if (navigationNodeFolder2 != null && navigationNodeFolder2.IsFilteredView)
                    {
                        OwaStoreObjectId owaStoreObjectId2 = OwaStoreObjectId.CreateFromNavigationNodeFolder(base.UserContext, navigationNodeFolder2);
                        using (SearchFolder searchFolder = SearchFolder.Bind(owaStoreObjectId2.GetSession(base.UserContext), owaStoreObjectId2.StoreObjectId, FolderList.FolderTreeQueryProperties))
                        {
                            searchFolder[FolderSchema.SearchFolderAllowAgeout] = true;
                            searchFolder.DisplayName = Utilities.GetRandomNameForTempFilteredView(base.UserContext);
                            searchFolder.Save();
                        }
                    }
                }
                if (operationResult == (OperationResult)0 || operationResult == OperationResult.Succeeded)
                {
                    if (navigationNodeCollection.RemoveFolderOrGroupByNodeId(nodeId) != null)
                    {
                        navigationNodeCollection.Save(base.UserContext.MailboxSession);
                    }
                }
                else if (operationResult == OperationResult.PartiallySucceeded)
                {
                    foreach (OwaStoreObjectId owaStoreObjectId3 in list)
                    {
                        navigationNodeCollection.RemoveFolderByLegacyDNandId(owaStoreObjectId3.MailboxOwnerLegacyDN ?? base.UserContext.MailboxOwnerLegacyDN, owaStoreObjectId3.StoreObjectId);
                    }
                    navigationNodeCollection.Save(base.UserContext.MailboxSession);
                }
            }
            NavigationTreeDirtyFlag navigationTreeDirtyFlag = NavigationTreeDirtyFlag.None;

            if (navigationNodeGroupSection == NavigationNodeGroupSection.First)
            {
                navigationTreeDirtyFlag = NavigationTreeDirtyFlag.Favorites;
            }
            else
            {
                if (list.Count > 0)
                {
                    List <FolderTreeNode> list3 = FolderTreeNode.CreateDeletedNodesWithDirtyCheck(base.UserContext, list, out navigationTreeDirtyFlag);
                    this.Writer.Write("<div id=tn>");
                    foreach (FolderTreeNode folderTreeNode in list3)
                    {
                        folderTreeNode.RenderUndecoratedNode(this.Writer);
                    }
                    this.Writer.Write("</div>");
                }
                switch (navigationNodeGroupSection)
                {
                case NavigationNodeGroupSection.Calendar:
                    navigationTreeDirtyFlag |= NavigationTreeDirtyFlag.Calendar;
                    break;

                case NavigationNodeGroupSection.Contacts:
                    navigationTreeDirtyFlag |= NavigationTreeDirtyFlag.Contact;
                    break;

                case NavigationNodeGroupSection.Tasks:
                    navigationTreeDirtyFlag |= NavigationTreeDirtyFlag.Task;
                    break;
                }
            }
            RenderingUtilities.RenderNavigationTreeDirtyFlag(this.Writer, base.UserContext, navigationTreeDirtyFlag, (NavigationModule[])base.GetParameter("cms"));
        }
Beispiel #10
0
        public void Execute()
        {
            Folder folder = null;

            try
            {
                folder = Folder.Bind(this.mailboxSession, this.mailboxSession.GetDefaultFolderId(DefaultFolderType.SearchFolders));
                string text = "EAS Search Device:" + this.context.Request.DeviceIdentity.DeviceId;
                bool   flag = !this.forceResetSearchCriteria;
                AirSyncDiagnostics.TraceDebug <bool>(ExTraceGlobals.AlgorithmTracer, this, "reuseExistingSearchFolderCriteria = !this.forceResetSearchCriteria, therefore reuseExistingSearchFolderCriteria = {0}", flag);
                if (this.queryFilter != null)
                {
                    StoreObjectId storeObjectId = null;
                    using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.None, null, MailboxSearchProvider.displayNameSortBy, new PropertyDefinition[]
                    {
                        FolderSchema.Id,
                        StoreObjectSchema.DisplayName
                    }))
                    {
                        QueryFilter seekFilter = new ComparisonFilter(ComparisonOperator.Equal, StoreObjectSchema.DisplayName, text);
                        if (queryResult.SeekToCondition(SeekReference.OriginBeginning, seekFilter))
                        {
                            object[][] rows = queryResult.GetRows(1);
                            storeObjectId = ((VersionedId)rows[0][0]).ObjectId;
                        }
                    }
                    SearchFolderCriteria searchFolderCriteria = null;
                    if (storeObjectId != null)
                    {
                        this.searchFolder = SearchFolder.Bind(this.mailboxSession, storeObjectId, new PropertyDefinition[]
                        {
                            MailboxSearchProvider.SearchFolderTextDescription,
                            FolderSchema.ItemCount,
                            FolderSchema.UnreadCount,
                            FolderSchema.SearchFolderItemCount
                        });
                        try
                        {
                            searchFolderCriteria = this.searchFolder.GetSearchCriteria();
                            AirSyncDiagnostics.TraceDebug <SearchFolderCriteria>(ExTraceGlobals.AlgorithmTracer, this, "Existing search folder has search criteria {0}", searchFolderCriteria);
                        }
                        catch (StoragePermanentException)
                        {
                            flag = false;
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "GetSearchCriteria() threw StoragePermanentException due to a pre-existing restriction on the search folder.  This condition is expected and handled.");
                        }
                        catch (ArgumentException)
                        {
                            flag = false;
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "GetSearchCriteria() threw ArgumentException due to a pre-existing restriction on the search folder.  This condition is expected and handled.");
                        }
                        catch (ObjectNotInitializedException)
                        {
                            flag = false;
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "Search folder has null search criteria, reuseExistingSearchFolderCriteria = false;");
                        }
                        if (flag)
                        {
                            if (searchFolderCriteria.FolderScope == null || searchFolderCriteria.FolderScope.Length != this.folderScope.Length)
                            {
                                if (searchFolderCriteria.FolderScope == null)
                                {
                                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "searchCriteria.FolderScope is null.");
                                }
                                else
                                {
                                    AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.AlgorithmTracer, this, "searchCriteria.FolderScope is not null and searchCriteria.FolderScope.Length is {0}", searchFolderCriteria.FolderScope.Length);
                                }
                                flag = false;
                                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "therefore reuseExistingSearchFolderCriteria = false");
                            }
                            else
                            {
                                for (int i = 0; i < this.folderScope.Length; i++)
                                {
                                    bool flag2 = false;
                                    for (int j = 0; j < searchFolderCriteria.FolderScope.Length; j++)
                                    {
                                        if (searchFolderCriteria.FolderScope[j].Equals(this.folderScope[i]))
                                        {
                                            flag2 = true;
                                            break;
                                        }
                                    }
                                    if (!flag2)
                                    {
                                        flag = false;
                                        AirSyncDiagnostics.TraceDebug <StoreId>(ExTraceGlobals.AlgorithmTracer, this, "foundIt == false for this.folderScope[idx1] == {0}, therefore reuseExistingSearchFolderCriteria = false", this.folderScope[i]);
                                        break;
                                    }
                                    AirSyncDiagnostics.TraceDebug <StoreId, bool>(ExTraceGlobals.AlgorithmTracer, this, "foundIt == true for this.folderScope[idx1] == {0}, therefore reuseExistingSearchFolderCriteria stays at value: {1}", this.folderScope[i], flag);
                                }
                            }
                        }
                        if (flag)
                        {
                            string text2 = this.searchFolder.TryGetProperty(MailboxSearchProvider.SearchFolderTextDescription) as string;
                            if (searchFolderCriteria.SearchQuery == null)
                            {
                                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "searchCriteria.SearchQuery == null, therefore reuseExistingSearchFolderCriteria = false");
                                flag = false;
                            }
                            else if (text2 != this.queryFilter.ToString())
                            {
                                AirSyncDiagnostics.TraceDebug <string, QueryFilter>(ExTraceGlobals.AlgorithmTracer, this, "oldSearchFilter == {0}, and this.queryFilter.ToString() == {1}, therefore reuseExistingSearchFolderCriteria = false", text2, this.queryFilter);
                                flag = false;
                            }
                            else if (searchFolderCriteria.DeepTraversal != this.deepTraversal)
                            {
                                AirSyncDiagnostics.TraceDebug <bool, bool>(ExTraceGlobals.AlgorithmTracer, this, "searchCriteria.DeepTraversal == {0}, and this.deepTraversal == {1}, therefore reuseExistingSearchFolderCriteria = false", searchFolderCriteria.DeepTraversal, this.deepTraversal);
                                flag = false;
                            }
                        }
                    }
                    else
                    {
                        this.searchFolder = SearchFolder.Create(this.mailboxSession, folder.Id.ObjectId, text, CreateMode.OpenIfExists);
                        AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.AlgorithmTracer, this, "Created a new search folder with display name: {0}", text);
                        this.searchFolder.Save();
                        this.searchFolder.Load(new PropertyDefinition[]
                        {
                            FolderSchema.ItemCount,
                            FolderSchema.UnreadCount,
                            FolderSchema.SearchFolderItemCount
                        });
                        flag = false;
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "Search folder was just recreated, therefore reuseExistingSearchFolderCriteria = false");
                    }
                    if (!flag)
                    {
                        searchFolderCriteria = new SearchFolderCriteria(this.queryFilter, this.folderScope);
                        searchFolderCriteria.DeepTraversal       = this.deepTraversal;
                        searchFolderCriteria.MaximumResultsCount = new int?(GlobalSettings.MaxMailboxSearchResults);
                        AirSyncDiagnostics.TraceDebug <QueryFilter, int, bool>(ExTraceGlobals.AlgorithmTracer, this, "Created search criteria on search folder with queryFilter=={0}, folderScope.Length=={1}, deepTraversal=={2}", this.queryFilter, this.folderScope.Length, this.deepTraversal);
                        Stopwatch    stopwatch           = Stopwatch.StartNew();
                        IAsyncResult asyncResult         = this.searchFolder.BeginApplyOneTimeSearch(searchFolderCriteria, null, null);
                        int          millisecondsTimeout = this.mailboxSession.Mailbox.IsContentIndexingEnabled ? this.maximumSearchTime : this.maximumSearchTimeNoContentIndexing;
                        bool         flag3 = asyncResult.AsyncWaitHandle.WaitOne(millisecondsTimeout, false);
                        stopwatch.Stop();
                        Command.CurrentCommand.Context.ProtocolLogger.SetValue(ProtocolLoggerData.SearchQueryTime, (int)stopwatch.ElapsedMilliseconds);
                        if (!flag3)
                        {
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "MailboxSearchProvider.Execute. Search timed out.");
                            throw new SearchTimeOutException();
                        }
                        this.searchFolder[MailboxSearchProvider.SearchFolderTextDescription] = ((this.queryFilter == null) ? "null" : this.queryFilter.ToString());
                        this.searchFolder.EndApplyOneTimeSearch(asyncResult);
                        this.searchFolder.Save();
                        this.searchFolder.Load(new PropertyDefinition[]
                        {
                            FolderSchema.ItemCount,
                            FolderSchema.UnreadCount,
                            FolderSchema.SearchFolderItemCount
                        });
                    }
                }
            }
            catch (SearchTimeOutException)
            {
                throw;
            }
            catch (Exception innerException)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, innerException, false)
                      {
                          ErrorStringForProtocolLogger = "GeneralMbxSearchError"
                      };
            }
            finally
            {
                if (this.folderIdMappingSyncState != null)
                {
                    this.folderIdMappingSyncState.Dispose();
                }
                this.folderIdMappingSyncState = null;
                if (folder != null)
                {
                    folder.Dispose();
                }
                folder = null;
            }
        }
        // Token: 0x0600095D RID: 2397 RVA: 0x0003ED90 File Offset: 0x0003CF90
        public static IList <CalendarInfo> Load(ExDateTime creationRequestTime, ExTimeZone timeZoneAdjustment, MailboxSession session, StoreObjectId calFldrId, StorageWorkingHours workingHours, ExDateTime actualizationTime, ExDateTime endTime)
        {
            StoreObjectId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Reminders);

            if (defaultFolderId == null)
            {
                ExTraceGlobals.AssistantTracer.TraceDebug <IExchangePrincipal, string>((long)typeof(ReminderLoader).GetHashCode(), "cannot open reminder folder for user {0}, Time {1}", session.MailboxOwner, ExDateTime.GetNow(timeZoneAdjustment).ToLongTimeString());
                return(new CalendarInfo[0]);
            }
            List <CalendarInfo> list          = new List <CalendarInfo>();
            StoreObjectId       storeObjectId = calFldrId;

            if (calFldrId.IsFolderId && StoreObjectType.Folder != calFldrId.ObjectType)
            {
                storeObjectId = calFldrId.Clone();
                storeObjectId.UpdateItemType(StoreObjectType.Folder);
            }
            QueryFilter queryFilter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ItemSchema.ReminderNextTime, actualizationTime),
                new ComparisonFilter(ComparisonOperator.LessThan, ItemSchema.ReminderNextTime, endTime),
                new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.ReminderIsSet, true),
                new ComparisonFilter(ComparisonOperator.Equal, StoreObjectSchema.ParentItemId, storeObjectId)
            });

            SortBy[] sortColumns = new SortBy[]
            {
                new SortBy(ItemSchema.ReminderNextTime, SortOrder.Ascending)
            };
            new Interval <ExDateTime>(actualizationTime, false, endTime, true);
            using (SearchFolder searchFolder = SearchFolder.Bind(session, defaultFolderId))
            {
                using (QueryResult queryResult = searchFolder.ItemQuery(ItemQueryType.None, queryFilter, sortColumns, CalendarInfo.InterestedProperties))
                {
                    ExDateTime exDateTime = ExDateTime.MinValue;
                    foreach (object[] propVals in queryResult.GetRows(100))
                    {
                        CalendarInfo calendarInfo = CalendarInfo.FromInterestedProperties(creationRequestTime, timeZoneAdjustment, session, true, propVals);
                        if (CalendarItemType.RecurringMaster == calendarInfo.CalendarItemType)
                        {
                            using (CalendarItem calendarItem = CalendarItem.Bind(session, calendarInfo.CalendarItemIdentity))
                            {
                                using (CalendarItemOccurrence calendarItemOccurrence = (CalendarItemOccurrence)calendarItem.Reminder.GetPertinentItem(actualizationTime))
                                {
                                    if (calendarItemOccurrence != null)
                                    {
                                        calendarInfo = CalendarInfo.FromCalendarItemBase(creationRequestTime, timeZoneAdjustment, calendarItemOccurrence);
                                    }
                                }
                            }
                        }
                        if (!(calendarInfo.ReminderTime < actualizationTime) && calendarInfo.IsInteresting(CalendarNotificationType.Reminder) && (workingHours == null || Utils.InWorkingHours(calendarInfo.StartTime, calendarInfo.EndTime, workingHours)))
                        {
                            if (ExDateTime.MinValue == exDateTime)
                            {
                                exDateTime = calendarInfo.ReminderTime;
                            }
                            else if (calendarInfo.ReminderTime > exDateTime)
                            {
                                break;
                            }
                            list.Add(calendarInfo);
                        }
                    }
                }
            }
            return(list.AsReadOnly());
        }