예제 #1
0
        internal IFolder NewFolder(string name, IFolder parent)
        {
            lock (_lockObj)
            {
                string fullPath = parent != null?String.Format("{0}/{1}", parent.FullPath, name) : name;

                IFolder existingFolder = FolderExists(fullPath);
                if (existingFolder != null)
                {
                    return(existingFolder);
                }

                Mailbox.FolderDataTable folderTable = FolderTable;
                Mailbox.FolderRow       row         = folderTable.NewFolderRow();

                row.Name     = name;
                row.ParentID = parent != null ? parent.ID : -1;
                row.FullPath = fullPath;
                row.Exists   = 0;
                row.Recent   = 0;

                folderTable.Rows.Add(row);
                folderTable.AcceptChanges();

                return(new Folder(_client, row.ID));
            }
        }
예제 #2
0
        /// <summary>
        /// Retreives a folder from the mailbox with the specified ID
        /// </summary>
        /// <param name="id">ID of folder to find</param>
        /// <returns>IFolder object, or null if ID not found</returns>
        public IFolder GetFolderByID(int id)
        {
            Mailbox.FolderDataTable folderTable =
                _client.DataManager.FolderTable;

            Mailbox.FolderRow[] rows = (Mailbox.FolderRow[])folderTable.Select(String.Format("ID = {0}", id));
            if (rows.Length == 1)
            {
                return(new Folder(_client, rows[0].ID));
            }

            throw new ArgumentOutOfRangeException(String.Format("No folder with ID {0} found.", id));
        }
예제 #3
0
        /// <summary>
        /// Returns an array of all the folders in the mailbox.
        /// </summary>
        /// <returns></returns>
        public IFolder[] GetAllFolders()
        {
            Mailbox.FolderDataTable folderTable =
                _client.DataManager.FolderTable;
            List <IFolder> _folderList = new List <IFolder>();

            foreach (Mailbox.FolderRow row in folderTable.Rows)
            {
                IFolder f = new Folder(_client, row.ID);
                _folderList.Add(f);
            }

            return(_folderList.ToArray());
        }
예제 #4
0
        /// <summary>
        /// Returns the list of folders that have their parent sent to the ID of rootFolder
        /// </summary>
        /// <param name="rootFolder"></param>
        /// <returns></returns>
        public IFolder[] GetChildFolders(IFolder rootFolder)
        {
            int rootID = rootFolder == null ? -1 : rootFolder.ID;

            Mailbox.FolderDataTable folderTable = _client.DataManager.FolderTable;
            List <IFolder>          folders     = new List <IFolder>();

            foreach (Mailbox.FolderRow row in folderTable.Select(String.Format("ParentID = {0}", rootID)))
            {
                folders.Add(new Folder(_client, row.ID));
            }

            return(folders.ToArray());
        }
예제 #5
0
        /// <summary>
        /// Get a list of all of the specified folders child folders
        /// </summary>
        /// <param name="parentFolder">The folder of which to get the children</param>
        /// <returns>Array of child folders</returns>
        public IFolder[] GetSubFolders(IFolder parentFolder)
        {
            if (parentFolder == null)
            {
                return(GetAllFolders());
            }

            Mailbox.FolderDataTable folderTable = _client.DataManager.FolderTable;
            List <IFolder>          folders     = new List <IFolder>();

            foreach (Mailbox.FolderRow row in folderTable.Select(String.Format("ParentID = {0}", parentFolder.ID)))
            {
                folders.Add(new Folder(_client, row.ID));
            }

            return(folders.ToArray());
        }
예제 #6
0
        /// <summary>
        /// Searches the Folder table for a folder that has the specified fullpath
        /// </summary>
        /// <param name="fullpath">The full path to search for</param>
        /// <param name="foundFolder">An IFolder object for the folder that was found</param>
        /// <returns>The ID of the folder that was found</returns>
        private int FindFolder(string fullpath, out IFolder foundFolder)
        {
            foundFolder = null;

            Mailbox.FolderDataTable folderTable = _client.DataManager.FolderTable;
            if (folderTable.Rows.Count == 0)
            {
                return(-1);
            }

            foreach (Mailbox.FolderRow row in folderTable.Rows)
            {
                if (!row.FullPath.Equals(fullpath))
                {
                    continue;
                }
                foundFolder = new Folder(_client, row.ID);
                return(row.ID);
            }

            return(-1);
        }