Example #1
0
        /// <summary>
        /// Directly posts a tolling 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="eventNumber">The tolling event number.</param>
        /// <param name="source">The tolling event source code.</param>
        /// <param name="eventCode">The tolling event code.</param>
        /// <param name="type">The type of letter to post.</param>
        /// <param name="isSecondRequest">Whether or not the letter is a second request.</param>
        /// <param name="isRepost">Whether or not the letter is a repost.</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.</param>
        /// <param name="path">The full UNC file path to the tolling letter attachment.</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>
        /// <remarks>If <paramref name="receiptEmail"/> is null, whitespace, or empty, the default e-mail address for the user specified by <paramref name="creator"/> will be retrieved from the network and used instead.</remarks>
        public int PostTollingLetter(string electionCycle, string candidateID, int eventNumber, string source, string eventCode, string type, bool isSecondRequest, bool isRepost, string creator, string title, string body, string receiptEmail, string path, bool notify)
        {
            TollingLetter letter = CPProviders.DataProvider.GetTollingLetter(source, eventCode, type);

            if (letter == null)
            {
                return(Convert.ToInt32(CmoServiceError.UnsupportedTollingLetter));
            }
            return(PostLetter(electionCycle, candidateID, creator, title, body, receiptEmail, letter.GetCmoCategoryID(), notify, addAttachment : GetAddAttachmentEventHandler(candidateID, path), addPostElection : GetAddPostElectionEventHandler(isSecondRequest, isRepost), addTolling : delegate(CmoMessage message)
            {
                if (message == null || letter == null)
                {
                    return false;
                }
                message.TollingLetter = letter;
                message.TollingEventNumber = eventNumber;
                return message.Update();
            }));
        }