Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MessageBL bl       = new MessageBL();
        var       Messages = bl.GetAllMessages(User.Identity.Name);
        var       messages = Messages.Where(m => m.Folder != "Sent Items" && m.Folder != "Drafts").Select(m => new {
            From    = m.From,
            Subject = m.Subject,
            Date    = m.Date.ToShortDateString()
        });

        MailReportViewer.Report = new MailReport(messages);
    }
Beispiel #2
0
    List <Message> SelectMessages()
    {
        MessageBL BL       = new MessageBL();
        var       Messages = BL.GetAllMessages(User.Identity.Name);
        var       result   = Messages.AsQueryable();

        if (MailTree.SelectedNode.Text == "Inbox")
        {
            result = result.Where(m => m.Folder != "Sent Items" && m.Folder != "Drafts");
        }
        else
        {
            result = result.Where(m => m.Folder == MailTree.SelectedNode.Text);
        }
        return(result.ToList());
    }
Beispiel #3
0
    protected void MailPreviewPanel_Callback(object sender, CallbackEventArgsBase e)
    {
        int id;
        var text = string.Format(NotFoundMessageFormat, e.Parameter);

        if (int.TryParse(e.Parameter, out id))
        {
            MessageBL bl       = new MessageBL();
            var       Messages = bl.GetAllMessages(User.Identity.Name);
            var       message  = Messages.FirstOrDefault(m => m.ID == id);
            if (message != null)
            {
                bl.MarkMessagesAs(true, new int[] { id });
                var subject = message.Subject;
                if (message.IsReply)
                {
                    subject = "Re: " + subject;
                }
                text = string.Format(PreviewMessageFormat, subject, message.From, message.To, message.Date, message.Text);
            }
        }
        MailPreviewPanel.Controls.Add(new LiteralControl(text));
    }
Beispiel #4
0
    protected void MailGrid_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        Session["CurrentReplyEmailID"] = null;
        var args = e.Parameters.Split('|');

        if (args[0] == "MailForm" && args[1] == "Reply" && args.Length == 3)
        {
            int id;
            if (!int.TryParse(args[2], out id))
            {
                return;
            }
            MessageBL bl       = new MessageBL();
            var       Messages = bl.GetAllMessages(User.Identity.Name);
            var       message  = Messages.FirstOrDefault(m => m.ID == id);
            if (message == null)
            {
                return;
            }
            var result = new Dictionary <string, string>();

            Session["CurrentReplyEmailID"] = id;
            result["To"] = message.To;

            var subject = message.Subject;
            if (!subject.StartsWith("Re: "))
            {
                subject = "Re: " + subject;
            }
            result["Subject"] = subject;

            result["Text"] = FormatMessageCore(message, ReplyMessageFormat);
            e.Result       = result;
        }
        if (args[0] == "MailForm" && args.Length == 3 && args[1] == "EditDraft")
        {
            int id;
            if (!int.TryParse(args[2], out id))
            {
                return;
            }
            MessageBL bl       = new MessageBL();
            var       Messages = bl.GetAllMessages(User.Identity.Name);
            var       message  = Messages.FirstOrDefault(m => m.ID == id);
            if (message == null)
            {
                return;
            }
            var result = new Dictionary <string, string>();
            result["To"]      = message.To;
            result["Subject"] = message.Subject;
            result["Text"]    = message.Text;
            e.Result          = result;
        }
        if (args[0] == "MarkAs" && args.Length > 2)
        {
            var   read = args[1] == "Read";
            int[] keys = null;
            if (!TryParseKeyValues(args.Skip(2), out keys))
            {
                return;
            }
            MessageBL bl = new MessageBL();
            bl.MarkMessagesAs(read, keys);
        }
    }