Esempio n. 1
0
 /// <summary>
 /// In the specified directory <paramref name="folder"/> searches for all subdirectories
 /// that match the specified filter <paramref name="filter"/> and returns them to the collection <paramref name="list"/>.
 /// </summary>
 /// <param name="list">Filtered Exchange Server catalog collection.</param>
 /// <param name="folder">The directory from which the recursive search is performed.</param>
 /// <param name="filter">Search filter.</param>
 public static void GetAllFoldersByFilter(this List <Exchange.Folder> list, Exchange.Folder folder, Exchange.SearchFilter filter = null)
 {
     if (folder.ChildFolderCount > 0 && list != null)
     {
         Exchange.FindFoldersResults searchedFolders;
         var folderView = new Exchange.FolderView(folder.ChildFolderCount);
         if (filter != null)
         {
             searchedFolders = folder.FindFolders(filter, folderView);
         }
         else
         {
             searchedFolders = folder.FindFolders(folderView);
         }
         list.AddRange(searchedFolders);
         foreach (Exchange.Folder findFoldersResult in searchedFolders)
         {
             list.GetAllFoldersByFilter(findFoldersResult, filter);
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// In the specified directory <paramref name="folder"/> searches for all subdirectories
 /// that match the specified filter <paramref name="filter"/> with the corresponding class <paramref name="className"/>
 /// and returns them to the collection <paramref name="list"/>.
 /// </summary>
 /// <param name="list">Filtered Exchange Server catalog collection.</param>
 /// <param name="folder">The directory from which the recursive search is performed.</param>
 /// <param name="className">Class name for search.</param>
 /// <param name="filter">Search filter.</param>
 public static void GetAllFoldersByClass(this List <Exchange.Folder> list, Exchange.Folder folder, string className, Exchange.SearchFilter filter)
 {
     if (folder.ChildFolderCount > 0 && list != null)
     {
         Exchange.FindFoldersResults childFolders;
         var folderView = new Exchange.FolderView(folder.ChildFolderCount);
         if (filter == null)
         {
             childFolders = folder.FindFolders(folderView);
         }
         else
         {
             childFolders = folder.FindFolders(filter, folderView);
         }
         foreach (Exchange.Folder childFolder in childFolders)
         {
             if (childFolder.FolderClass == className)
             {
                 list.Add(childFolder);
             }
             list.GetAllFoldersByClass(childFolder, className, filter);
         }
     }
 }
        private TreeViewFolder LoadSubFolders(Folder f, TreeViewFolder subtree, bool addTopFolder)
        {
            var view = new FolderView(100);
            view.Traversal = FolderTraversal.Shallow;
            var findFolderResults = f.FindFolders(view);

            string typeClass = "Contact";

            if ((((CCFolder)Session["folderDetail"])) != null)
            {
                if ((((CCFolder)Session["folderDetail"]).Type) == 1) { typeClass = "Contact"; }
                else { typeClass = "Appointment"; }
            }

            if (addTopFolder)
            {
                var childNode = new TreeViewFolder();
                childNode.Name = f.DisplayName;
                childNode.Id = f.Id.UniqueId;
                var fclass = f.FolderClass;
                if (fclass == null) fclass = "All";
                if (fclass == "IPF.Contact") fclass = "Contact";
                else if (fclass == "IPF.Appointment") fclass = "Appointment";
                else if (fclass == "IPF.Task") fclass = "Task";
                else fclass = "All";
                childNode.FolderClass = fclass;
                subtree.ChildFolders.Add(childNode);
            }
            foreach (var item in findFolderResults.Folders)
            {
                var childNode = new TreeViewFolder();
                childNode.Name = item.DisplayName;
                childNode.Id = item.Id.UniqueId;
                var fclass = item.FolderClass;
                if (fclass == null) fclass = "All";
                if (fclass == "IPF.Contact") fclass = "Contact";
                else if (fclass == "IPF.Appointment") fclass = "Appointment";
                else if (fclass == "IPF.Task") fclass = "Task";
                else fclass = "All";
                childNode.FolderClass = fclass;
                if (item.ChildFolderCount > 0)
                {
                    if (typeClass == fclass)
                    {
                        subtree.ChildFolders.Add(LoadSubFolders(item, childNode, false));
                    }
                    else if (fclass == "All")
                    {
                        subtree.ChildFolders.Add(LoadSubFolders(item, childNode, false));
                    }
                }
                else
                {
                    if (typeClass == fclass)
                    {
                        subtree.ChildFolders.Add(childNode);
                    }
                }
            }
            return subtree;
        }
 private TreeViewFolder LoadSubFolders(Folder f, TreeViewFolder subtree)
 {
     var view = new FolderView(100);
     view.Traversal = FolderTraversal.Shallow;
     var findFolderResults = f.FindFolders(view);
     foreach (var item in findFolderResults.Folders)
     {
         var childNode = new TreeViewFolder();
         childNode.Name = item.DisplayName;
         childNode.Id = item.Id.UniqueId;
         var fclass = item.FolderClass;
         if (fclass == null) fclass = "All";
         if (fclass == "IPF.Contact") fclass = "Contact";
         else if (fclass == "IPF.Appointment") fclass = "Appointment";
         else if (fclass == "IPF.Task") fclass = "Task";
         else fclass = "All";
         childNode.FolderClass = fclass;
         if (item.ChildFolderCount > 0)
         {
             subtree.ChildFolders.Add(LoadSubFolders(item, childNode));
         }
         else
         {
             subtree.ChildFolders.Add(childNode);
         }
     }
     return subtree;
 }