/// <summary>
        /// Creates a search folder that finds items in the Inbox that contain the word "extended" in the subject line.
        /// </summary>
        /// <param name="service">An ExchangeService object with credentials and the EWS URL.</param>
        private static void CreateASearchFolder(ExchangeService service)
        {
            // Create a new search folder.
            SearchFolder searchFolder = new SearchFolder(service);

            // Use the following search filter to get all mail in the Inbox with the word "extended" in the subject line.
            SearchFilter.ContainsSubstring searchCriteria = new SearchFilter.ContainsSubstring(ItemSchema.Subject, "extended");

            searchFolder.SearchParameters.RootFolderIds.Add(WellKnownFolderName.Inbox);
            searchFolder.SearchParameters.Traversal    = SearchFolderTraversal.Shallow;
            searchFolder.SearchParameters.SearchFilter = searchCriteria;
            searchFolder.DisplayName = "Extended";

            try
            {
                // This call results in a CreateFolder operation call to EWS. The search folder should be added
                // to the WellKnownFolderName.SearchFolders folder so that it is visible to clients like Outlook.
                searchFolder.Save(WellKnownFolderName.SearchFolders);
                Console.WriteLine("Added: {0}", searchFolder.DisplayName);
            }
            catch (ServiceResponseException e)
            {
                if (e.Response.ErrorCode == ServiceError.ErrorFolderExists)
                {
                    Console.WriteLine("Rename your search folder or delete the existing search folder of the same name.");
                }
                else
                {
                    Console.WriteLine("Error - " + e.Message);
                }
            }
        }
Exemple #2
0
 // Token: 0x0600228C RID: 8844 RVA: 0x000C5B13 File Offset: 0x000C3D13
 public void UpgradeFilter(SearchFolder folder, PropertyDefinition[] propertiesToLoad)
 {
     if (this.IsCurrentVersion)
     {
         throw new OwaInvalidOperationException("Can't upgrade a filter in current version");
     }
     this.version = 3;
     folder[ViewStateProperties.FilteredViewLabel] = this.GetPropertyValueToSave();
     folder.Save();
     folder.Load(FolderList.FolderTreeQueryProperties);
 }
Exemple #3
0
        private void PopulateDynamicSearchFolder(SearchFolder searchFolder, SearchFolderCriteria searchCriteria)
        {
            IAsyncResult asyncResult = searchFolder.BeginApplyContinuousSearch(searchCriteria, null, null);
            bool         flag        = asyncResult.AsyncWaitHandle.WaitOne(SearchFolderManager.MaximumSearchTime, false);

            if (flag)
            {
                searchFolder.EndApplyContinuousSearch(asyncResult);
            }
            else
            {
                SearchFolderManager.Tracer.TraceDebug <SearchFolderManager>((long)this.GetHashCode(), "{0}: ELC Non Archive Tag search timed out.", this);
            }
            searchFolder.Save();
            searchFolder.Load();
        }
Exemple #4
0
        // Token: 0x0600228D RID: 8845 RVA: 0x000C5B54 File Offset: 0x000C3D54
        public void ApplyFilter(SearchFolder folder, PropertyDefinition[] propertiesToLoad)
        {
            if (!this.IsCurrentVersion)
            {
                throw new OwaInvalidOperationException("Can't apply a filter in different version");
            }
            int num = 0;
            SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(this.GetQueryFilter(), new StoreId[]
            {
                this.SourceFolderId.StoreObjectId
            });

            searchFolderCriteria.DeepTraversal = false;
            SearchPerformanceData searchPerformanceData = new SearchPerformanceData();
            string text = this.ToDescription();

            searchPerformanceData.StartSearch(string.IsNullOrEmpty(text) ? "No Search String" : text);
            IAsyncResult asyncResult = folder.BeginApplyContinuousSearch(searchFolderCriteria, null, null);
            Stopwatch    watch       = Utilities.StartWatch();
            bool         flag        = asyncResult.AsyncWaitHandle.WaitOne(5000, false);

            searchPerformanceData.Complete(!flag, true);
            if (flag)
            {
                folder.EndApplyContinuousSearch(asyncResult);
            }
            else
            {
                ExTraceGlobals.MailTracer.TraceDebug((long)this.GetHashCode(), "FolderVirtualListViewEventHandler.GetFilteredView. Search for filtered view timed out.");
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.SearchesTimedOut.Increment();
                }
            }
            OwaContext.Current.SearchPerformanceData = searchPerformanceData;
            Utilities.StopWatch(watch, "FolderVirtualListViewEventHandler.GetFilteredView (Wait for filter to complete)");
            object obj = folder.TryGetProperty(FolderSchema.ExtendedFolderFlags);

            if (!(obj is PropertyError))
            {
                num = (int)obj;
            }
            folder[FolderSchema.ExtendedFolderFlags] = (num | 4194304);
            folder.Save();
            folder.Load(propertiesToLoad);
        }
Exemple #5
0
        public static SearchFolder CreateSearchFolderIfNeeded(ExchangeService exchService, Mailbox mailbox)
        {
            // Check if it exists already
            var          searchFoldersId     = new FolderId(WellKnownFolderName.SearchFolders, mailbox);
            var          searchFoldersFolder = Folder.Bind(exchService, searchFoldersId);
            var          searchFoldersView   = new FolderView(2);
            var          searchFoldersFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, SearchFolderName);
            var          searchFolderResults = searchFoldersFolder.FindFolders(searchFoldersFilter, searchFoldersView);
            SearchFolder mySearchFolder      = null;

            if (searchFolderResults.Folders.Count > 1)
            {
                Console.WriteLine("The expected folder name is ambiguous. How did we end up with multiple folders?");
                Console.WriteLine("Dunno, but I'm going to delete all but the first.");
                for (var x = 1; x < searchFolderResults.Folders.Count; x++)
                {
                    searchFolderResults.Folders[x].Delete(DeleteMode.HardDelete);
                }
            }

            if (searchFolderResults.Folders.Count > 0)
            {
                Console.WriteLine("Found existing search folder.");
                mySearchFolder = searchFolderResults.Folders[0] as SearchFolder;
                if (mySearchFolder == null)
                {
                    Console.WriteLine("Somehow this folder isn't a search folder. Deleting it.");
                    searchFolderResults.Folders[0].Delete(DeleteMode.HardDelete);
                }
            }

            if (mySearchFolder == null)
            {
                Console.WriteLine("Creating a new search folder.");
                mySearchFolder             = new SearchFolder(exchService);
                mySearchFolder.DisplayName = SearchFolderName;
                mySearchFolder.SearchParameters.SearchFilter =
                    new SearchFilter.Exists(MyNamedProp);
                var inboxId = new FolderId(WellKnownFolderName.Inbox, mailbox);
                mySearchFolder.SearchParameters.RootFolderIds.Add(inboxId);
                mySearchFolder.SearchParameters.Traversal = SearchFolderTraversal.Shallow;
                mySearchFolder.Save(searchFoldersId);
            }

            return(mySearchFolder);
        }
Exemple #6
0
            public IAsyncResult BeginAuditLogQuery(QueryFilter queryFilter, int maximumResultsCount)
            {
                if (this.pendingAsyncResult != null)
                {
                    throw new InvalidOperationException("Asynchronous query is already pending.");
                }
                StoreId      storeId = null;
                IAsyncResult result;

                using (DisposeGuard disposeGuard = default(DisposeGuard))
                {
                    Folder disposable;
                    if (queryFilter != null)
                    {
                        SearchFolder searchFolder = SearchFolder.Create(this.auditLog.Session, this.auditLog.Session.GetDefaultFolderId(DefaultFolderType.SearchFolders), "SearchAuditMailboxFolder" + Guid.NewGuid().ToString(), CreateMode.OpenIfExists);
                        disposeGuard.Add <SearchFolder>(searchFolder);
                        searchFolder.Save();
                        searchFolder.Load();
                        storeId = searchFolder.Id;
                        result  = searchFolder.BeginApplyOneTimeSearch(new SearchFolderCriteria(queryFilter, new StoreId[]
                        {
                            this.auditLog.LogFolderId
                        })
                        {
                            DeepTraversal               = false,
                            UseCiForComplexQueries      = true,
                            FailNonContentIndexedSearch = true,
                            MaximumResultsCount         = new int?(maximumResultsCount)
                        }, null, null);
                        disposable = searchFolder;
                    }
                    else
                    {
                        disposable = Folder.Bind(this.auditLog.Session, this.auditLog.LogFolderId);
                        disposeGuard.Add <Folder>(disposable);
                        result = new CompletedAsyncResult();
                    }
                    disposeGuard.Success();
                    this.pendingAsyncResult = result;
                    this.folder             = disposable;
                    this.folderIdToDelete   = storeId;
                }
                return(result);
            }
Exemple #7
0
        private void PopulateSearchFolder(SearchFolder searchFolder, QueryFilter queryFilter)
        {
            IAsyncResult asyncResult = searchFolder.BeginApplyOneTimeSearch(new SearchFolderCriteria(queryFilter, new StoreId[]
            {
                this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Root)
            })
            {
                DeepTraversal = true
            }, null, null);
            bool flag = asyncResult.AsyncWaitHandle.WaitOne(SearchFolderManager.MaximumSearchTime, false);

            if (flag)
            {
                searchFolder.EndApplyOneTimeSearch(asyncResult);
            }
            else
            {
                SearchFolderManager.Tracer.TraceDebug <SearchFolderManager>((long)this.GetHashCode(), "{0}: ELC Auto Tag search timed out.", this);
            }
            searchFolder.Save();
            searchFolder.Load();
        }
Exemple #8
0
        private SearchFolder CreateSearchFolder(string searchFolderName)
        {
            bool         flag         = false;
            SearchFolder searchFolder = null;
            SearchFolder result;

            try
            {
                searchFolder = SearchFolder.Create(this.mailboxSession, this.mailboxSession.GetDefaultFolderId(DefaultFolderType.SearchFolders), searchFolderName, CreateMode.OpenIfExists);
                searchFolder.Save();
                searchFolder.Load();
                SearchFolderManager.Tracer.TraceDebug <SearchFolderManager>((long)this.GetHashCode(), "{0}: Created or opened archive search folder.", this);
                flag   = true;
                result = searchFolder;
            }
            finally
            {
                if (!flag && searchFolder != null)
                {
                    searchFolder.Dispose();
                }
            }
            return(result);
        }
Exemple #9
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);
        }
Exemple #10
0
        // Token: 0x060005CD RID: 1485 RVA: 0x0002BC64 File Offset: 0x00029E64
        private StoreId SubmitSearch(QueryFilter searchCriteriaFilter)
        {
            StoreId        result         = null;
            MailboxSession mailboxSession = base.MailboxDataForTags.MailboxSession;

            if (searchCriteriaFilter != null)
            {
                if (!mailboxSession.Mailbox.IsContentIndexingEnabled)
                {
                    DiscoveryHoldEnforcer.Tracer.TraceError <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0}: CI search failed on the mailbox {1}. CI is not enabled on the mailbox database", this, mailboxSession.ToString());
                    throw new DiscoveryHoldSearchException(Strings.ErrorDiscoveryHoldsCIIndexDisabledOnDatabase(searchCriteriaFilter.ToString(), mailboxSession.ToString()));
                }
                DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0} : Creating search folder for hold queries for mailbox {1}", this, mailboxSession.ToString());
                using (SearchFolder searchFolder = SearchFolder.Create(mailboxSession, this.discoveryHoldsFolderId, DiscoveryHoldEnforcer.SearchDiscoveryHoldsFolderName, CreateMode.OpenIfExists))
                {
                    searchFolder.Save();
                    searchFolder.Load();
                    result = searchFolder.Id;
                    QueryFilter          searchQuery          = new CountFilter(10000U, searchCriteriaFilter);
                    SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(searchQuery, new StoreId[]
                    {
                        this.discoveryHoldsFolderId
                    });
                    searchFolderCriteria.DeepTraversal               = true;
                    searchFolderCriteria.UseCiForComplexQueries      = true;
                    searchFolderCriteria.FailNonContentIndexedSearch = true;
                    int  num  = 0;
                    bool flag = true;
                    while (flag)
                    {
                        DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string, int>((long)this.GetHashCode(), "{0} : Begin search folder execution for mailbox {1}. Attempt#: {2}", this, mailboxSession.ToString(), num);
                        IAsyncResult asyncResult = searchFolder.BeginApplyOneTimeSearch(searchFolderCriteria, null, null);
                        bool         flag2       = asyncResult.AsyncWaitHandle.WaitOne(60000, false);
                        if (flag2)
                        {
                            DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0} : Search folder execution completed for mailbox {1}", this, mailboxSession.ToString());
                            searchFolder.EndApplyOneTimeSearch(asyncResult);
                            SearchFolderCriteria searchCriteria = searchFolder.GetSearchCriteria();
                            if ((searchCriteria.SearchState & SearchState.FailNonContentIndexedSearch) == SearchState.FailNonContentIndexedSearch && (searchCriteria.SearchState & SearchState.Failed) == SearchState.Failed)
                            {
                                DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0} :  Discovery Hold search failed because CI is not running, search query was not served by CI for mailbox {1}", this, mailboxSession.ToString());
                                throw new DiscoveryHoldSearchException(Strings.ErrorDiscoveryHoldsCIIndexNotRunning(searchCriteriaFilter.ToString(), mailboxSession.ToString()));
                            }
                            flag = false;
                        }
                        else
                        {
                            DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0} :  Discovery Hold Search folder execution has timed out for mailbox {1}", this, mailboxSession.ToString());
                            if (num >= 3)
                            {
                                DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string, int>((long)this.GetHashCode(), "{0} :  Discovery Hold Search folder execution has timed out for mailbox {1} and exceeded max retry count {2}. Give up.", this, mailboxSession.ToString(), 3);
                                throw new DiscoveryHoldSearchException(Strings.ErrorDiscoverySearchTimeout(60.ToString(), searchCriteriaFilter.ToString(), mailboxSession.ToString()));
                            }
                            flag = true;
                            num++;
                        }
                    }
                    searchFolder.Save();
                    searchFolder.Load();
                }
            }
            return(result);
        }
Exemple #11
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"));
        }