Example #1
0
 /// <summary>
 /// Attempts to display a CMO message in a new <see cref="CmoMessageForm"/>.
 /// </summary>
 /// <param name="uniqueId">The unique identifer of the CMO message to display.</param>
 private void ShowMessage(string uniqueId)
 {
     this.Cursor = Cursors.WaitCursor;
     new MethodInvoker(() =>
     {
         CmoMessage message = CmoMessage.GetMessage(uniqueId);
         this.BeginInvoke(new MethodInvoker(() =>
         {
             try
             {
                 if (message == null)
                 {
                     MessageBox.Show(this, string.Format("Unable to retrieve campaign message with ID \"{0}\". Please check the message ID and retry your request.", uniqueId), "Message Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     CmoMessageForm form = new CmoMessageForm();
                     form.SetMessage(message);
                     form.ShowAsMdiSiblingOf(this);
                 }
             }
             finally
             {
                 this.Cursor = Cursors.Default;
             }
         }));
     }).BeginInvoke(null, null);
 }
Example #2
0
        public ActionResult Attachment(string messageid, string id)
        {
            // check for valid, opened message
            var message = CmoMessage.GetMessage(messageid);

            if (message == null)
            {
                return(HttpNotFound());
            }
            if (!message.IsOpened)
            {
                return(RedirectToAction(ActionName_Details, new { id = messageid }));
            }

            // find attachment and download
            var attachment = CmoAttachment.GetAttachment(string.Join("-", messageid, id));

            if (attachment == null)
            {
                return(HttpNotFound());
            }
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", attachment.FileName));
            return(new FilePathResult("~/App_Data/SampleAttachment.pdf", "application/octet-stream")
            {
                FileDownloadName = attachment.FileName
            });
        }
Example #3
0
        private bool UpdateMessage(string id, string updateAction)
        {
            var msg = CmoMessage.GetMessage(id);

            if (msg != null)
            {
                CmoMessage.MessageAction action = null;
                switch (updateAction)
                {
                case ActionName_Archive:
                    action = msg.Archive;
                    break;

                case ActionName_Unarchive:
                    action = msg.Unarchive;
                    break;

                case ActionName_Flag:
                    action = msg.SetFlag;
                    break;

                case ActionName_ClearFlag:
                    action = msg.ClearFlag;
                    break;
                }
                return(action != null && action((User.Identity.Name)));
            }
            return(false);
        }
Example #4
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="IHttpHandler"/> interface.
        /// </summary>
        /// <param name="context">An <see cref="HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        public void ProcessRequest(HttpContext context)
        {
            context.CheckPitStops();
            // process query string for attachment
            string id = context.Request.Path;

            if (id.EndsWith("/"))
            {
                context.Server.RedirectPageNotFound();
            }
            if (id.Contains("/"))
            {
                id = id.Substring(id.LastIndexOf('/') + 1);
            }
            if (id.Contains("."))
            {
                id = id.Substring(0, id.IndexOf('.'));
            }
            CmoAttachment attachment = CmoAttachment.GetAttachment(id);

            if (attachment == null || !attachment.CandidateID.Equals(CPSecurity.Provider.GetCid(context.User.Identity.Name), StringComparison.InvariantCultureIgnoreCase))
            {
                context.Server.RedirectPageNotFound();
            }
            CmoMessage owner = CmoMessage.GetMessage(attachment.CandidateID, attachment.MessageID);

            if ((owner == null) || !owner.IsOpened)
            {
                // if owner message is not posted, open the message first
                context.Response.Redirect(string.Format("/Messages/View.aspx?id={0}", owner.UniqueID));
            }
            else
            {
                context.Response.Clear();
                context.Response.Expires     = 0;
                context.Response.ContentType = context.Response.GetContentType(attachment.FileName);
                // BUGFIX #49 - content-disposition filename need to be surrounded by quotes
                context.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", attachment.FileName));
                context.Response.AddHeader("Content-Length", new FileInfo(attachment.Path).Length.ToString());
                // BUGFIX #32 - KB823409: Response.WriteFile cannot download a large file so read/write file in chunks
                context.Response.TransmitFile(attachment.Path);
            }
            context.ApplicationInstance.CompleteRequest();
        }
Example #5
0
 private void printToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ListView.SelectedListViewItemCollection selection = this.ResultsListView.SelectedItems;
     if (!this.ConfirmMultipleAction("Printing", selection.Count))
     {
         return;
     }
     foreach (ListViewItem item in selection)
     {
         CmoMessage message = CmoMessage.GetMessage(item.Name);
         if (message != null)
         {
             using (CmoMessageForm form = new CmoMessageForm())
             {
                 form.Message = message;
                 form.PrintMessage(false);
             }
         }
     }
 }
Example #6
0
        /// <summary>
        /// Handles the event that occurs when an action button that affects selected messages is clicked.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="CommandEventArgs"/> object that contains the event data.</param>
        protected void MultipleMessageAction(object sender, CommandEventArgs e)
        {
            string selectionRaw = Request.Form[CmoMailboxMessageList.MessageCheckboxName];

            // check for selected messages
            if (string.IsNullOrEmpty(selectionRaw))
            {
                this.PageError = NoSelectionText;
            }
            else
            {
                string[] selection = selectionRaw.Split(MessageIdDelimiters, StringSplitOptions.RemoveEmptyEntries);
                if (selection.Count() == 0)
                {
                    this.PageError = NoSelectionText;
                }
                else
                {
                    // determine action
                    string action = null;
                    switch (e.CommandName)
                    {
                    case Messages.ArchiveCommandName:
                        action = "archived";
                        break;

                    case Messages.UnarchiveCommandName:
                        action = "unarchived";
                        break;

                    case Messages.FlagCommandName:
                        action = "flagged";
                        break;

                    case Messages.ClearFlagCommandName:
                        action = "unflagged";
                        break;

                    default:
                        this.PageError = "You have requested an unsupported action. Please try again.";
                        break;
                    }
                    if (!string.IsNullOrEmpty(action))
                    {
                        // iterate through messages and monitor failures
                        bool error        = false;
                        uint successCount = 0;
                        foreach (string messageId in selection)
                        {
                            CmoMessage m = CmoMessage.GetMessage(messageId);
                            if (m == null)
                            {
                                error = true;
                            }
                            else
                            {
                                CmoMessage.MessageAction ma = Messages.GetAction(e.CommandName, m);
                                if (ma != null)
                                {
                                    if (ma(this.DataSource.Username))
                                    {
                                        successCount++;
                                    }
                                    else
                                    {
                                        error = true;
                                    }
                                }
                            }
                        }
                        this.PageResult = string.Format("{0} message{1} {2} successfully{3}.", successCount, successCount == 1 ? string.Empty : "s", action, error ? ", with exceptions" : string.Empty);
                    }
                }
            }
            this.DataBind();
        }