Пример #1
0
 /// <summary>
 /// Directly posts a payment letter to C-Access as a CMO message.
 /// </summary>
 /// <param name="electionCycle">The election cycle context of the letter to post.</param>
 /// <param name="candidateID">The ID of the candidate receipient of the letter to post.</param>
 /// <param name="run">The payment run number.</param>
 /// <param name="creator">The network username of the user posting the letter.</param>
 /// <param name="title">The letter subject.</param>
 /// <param name="body">The letter body.</param>
 /// <param name="receiptEmail">The e-mail address for the recipient of open receipt e-mails if desired; otherwise, null to decline open receipts for this letter.</param>
 /// <param name="data">The raw binary data contents of the payment letter attachment.</param>
 /// <param name="name">The filename of the payment letter.</param>
 /// <param name="notify">Indicates whether to generate an e-mail notification to the campaign's C-Access accounts upon post.</param>
 /// <returns>The ID of the message if succesfully posted; otherwise, a negative value representing an error code.</returns>
 /// <exception cref="ArgumentNullException">Any parameters are null, except <paramref name="receiptEmail"/>.</exception>
 public int PostPaymentLetter(string electionCycle, string candidateID, byte run, string creator, string title, string body, string receiptEmail, byte[] data, string name, bool notify)
 {
     return(PostPaymentLetter(electionCycle, candidateID, run, creator, title, body, receiptEmail, notify, delegate(CmoMessage message)
     {
         return message != null && CmoAttachment.Add(candidateID, message.ID, data, name) != null;
     }));
 }
Пример #2
0
        /// <summary>
        /// Obtains a <see cref="AddAttachmentEventHandler"/> to handle events for adding attachments to CMO messages.
        /// </summary>
        /// <param name="candidateID">The ID of the candidate whose attachment is being added.</param>
        /// <param name="path">The full UNC file path to the attachment.</param>
        /// <returns>A <see cref="AddAttachmentEventHandler"/> for adding the attachment located at <paramref name="path"/>.</returns>
        /// <exception cref="FileNotFoundException"><paramref name="path"/> is invalid or does not exist.</exception>
        private static Func <CmoMessage, bool> GetAddAttachmentEventHandler(string candidateID, string path)
        {
            if (!File.Exists(path))
            {
                throw new FileNotFoundException(string.Format("Unable to access the specified file from UNC path \"{0}\". Please make sure the path is valid, the file exists, and the service has sufficient permissions to read it.", path), path);
            }
            string name = Path.GetFileName(path);

            return(delegate(CmoMessage message)
            {
                return message != null && CmoAttachment.Add(candidateID, message.ID, File.ReadAllBytes(path), name) != null;
            });
        }