Пример #1
0
        internal IMessage[] GetMessagesByFolder(IFolder folder, MessageListDirection direction)
        {
            lock (_lockObj)
            {
                List <IMessage>      msgs = new List <IMessage>();
                Mailbox.MessageRow[] rows = (Mailbox.MessageRow[])MessageTable.Select("FolderID = " + folder.ID);
                foreach (Mailbox.MessageRow row in rows)
                {
                    msgs.Add(new Message(_client, row.ID));
                }

                if (direction == MessageListDirection.Descending)
                {
                    msgs.Reverse();
                }

                return(msgs.ToArray());
            }
        }
Пример #2
0
 /// <summary>
 /// Get a list of messages based on the specified folder and in the specified direction
 /// </summary>
 /// <param name="folder"></param>
 /// <param name="direction"></param>
 /// <returns></returns>
 public IMessage[] GetMessagesByFolder(IFolder folder, MessageListDirection direction)
 {
     return _client.DataManager.GetMessagesByFolder(folder, direction);
 }
        public override CommandResult Execute()
        {
            CommandResult result = new CommandResult(Command, Args);

            /*
             * Here is where things get interesting. In order to make this command work as efficiently
             * as possible the best route to take is to download and display the header data for messages
             * 20 or so at a time. After each group the user can choose to get the next group, go back to
             * the previous group, view details of a specific message, or cancel.
             *
             * Possible arguments
             *
             * -s <num>     message number to start with
             * -e <num>     message number to end with
             *
             * */
            if (Shell.CurrentFolder == null)
            {
                return(CommandResult.CreateError(Command, Args, "This folder does not contain any message data."));
            }
            Shell.Client.Aggregator.ClearLogs();
            Arguments processedArgs = new Arguments(Args);

            // first we have to get all the UIDs for the messages in the current folder
            bool messageListComplete = false;

            Shell.Client.RequestManager.SubmitRequest(
                new MessageListRequest(Shell.CurrentFolder, delegate
            {
                messageListComplete = true;
            }), false);
            while (!messageListComplete)
            {
            }
            MessageListDirection direction = MessageListDirection.Descending;

            if (Args.Length > 0)
            {
                if (Args[0].Equals("desc"))
                {
                    direction = MessageListDirection.Descending;
                }
                else if (Args[0].Equals("asc"))
                {
                    direction = MessageListDirection.Ascending;
                }
            }

            IMessage[] msgList = Shell.Client.MailboxManager.GetMessagesByFolder(Shell.CurrentFolder, direction);

            if (msgList.Length == 0)
            {
                result.SuccessMessage = "This folder does not contain any messages.";
                return(result);
            }

            bool view;
            bool del;
            int  uid;

            DoMessageGroups(msgList, out view, out del, out uid);

            if (view)
            {
                ColorConsole.WriteLine("\nViewing message {0}\n", uid);
            }

            if (del)
            {
                DeleteMessage(uid);
            }

            return(result);
        }
Пример #4
0
 /// <summary>
 /// Get a list of messages based on the specified folder and in the specified direction
 /// </summary>
 /// <param name="folder"></param>
 /// <param name="direction"></param>
 /// <returns></returns>
 public IMessage[] GetMessagesByFolder(IFolder folder, MessageListDirection direction)
 {
     return(_client.DataManager.GetMessagesByFolder(folder, direction));
 }