Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventReminderMessage"/> class.
        /// </summary>
        /// <param name="candidateID">The ID of the campaign candidate.</param>
        /// <param name="electionCycle">The election cycle during which the event occurs.</param>
        /// <param name="item">The upcoming event.</param>
        /// <exception cref="ArgumentNullException"><paramref name="item"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="item"/> is not a supported event type. Supported events include Doing Business review responses only.</exception>
        public EventReminderMessage(string candidateID, string electionCycle, CPCalendarItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item", "The calendar item must not be null.");
            }
            _candidateID     = candidateID;
            _mail            = new CPMailMessage();
            _mail.IsBodyHtml = true;
            Settings settings = Properties.Settings.Default;
            string   siteUrl  = CPProviders.SettingsProvider.ApplicationUrl;

            _mail.Sender = new MailAddress(string.IsNullOrEmpty(settings.SenderEmail) ? _mail.Sender.Address : settings.SenderEmail, settings.SenderDisplayName);

            // set up message subject and body based on event type
            if (item is DbrResponseDeadline)
            {
                DbrResponseDeadline deadline = item as DbrResponseDeadline;
                _mail.Subject = settings.DoingBusinessSubject;
                StringBuilder body = new StringBuilder();
                body.AppendFormat(settings.BodyTemplateHeader, siteUrl);
                body.AppendFormat(settings.DoingBusinessBodyTemplate, deadline.Date.Subtract(DateTime.Today).Days, electionCycle, deadline.ReviewSentDate);
                body.Append(settings.BodyTemplateFooter);
                _mail.Body = body.ToString();
            }
            else
            {
                throw new ArgumentException("item", Resources.UnsupportedExceptionText);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Retrieves a collection of all completed Doing Business reviews on record for the specified candidate and election cycle.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate whose Doing Business reviews are to be retrieved.</param>
 /// <param name="electionCycle">The election cycle in which to search.</param>
 /// <returns>A collection of all completed Doing Business reviews for the specified candidate and election cycle.</returns>
 public DoingBusinessReviews GetDoingBusinessReviews(string candidateID, string electionCycle)
 {
     using (DoingBusinessReviewTds ds = new DoingBusinessReviewTds())
     {
         using (DoingBusinessReviewsTableAdapter ta = new DoingBusinessReviewsTableAdapter())
         {
             ta.Fill(ds.DoingBusinessReviews, candidateID, electionCycle);
         }
         Election             election = GetElections(CPProviders.SettingsProvider.MinimumElectionCycle)[electionCycle];
         DoingBusinessReviews dbr      = new DoingBusinessReviews();
         if (election == null)
         {
             return(dbr);
         }
         var s = this.GetStatements(electionCycle);
         foreach (DoingBusinessReviewTds.DoingBusinessReviewsRow row in ds.DoingBusinessReviews.Rows)
         {
             byte number = row.StatementNumber;
             if (!object.Equals(s, null) && s.ContainsKey(number))
             {
                 DoingBusinessReview review = new DoingBusinessReview(row.ElectionCycle.Trim(), ParseCommitteeID(row.CommitteeID), s[number])
                 {
                     StartDate     = row.IsStartDateNull() ? DateTime.MinValue : row.StartDate,
                     EndDate       = row.IsCompletionDateNull() ? DateTime.MinValue : row.CompletionDate,
                     CommitteeName = row.CommitteeName.Trim(),
                     LastUpdated   = row.LastUpdated,
                     SentDate      = row.IsSentDateNull() ? null : row.SentDate as DateTime?
                 };
                 // response due if due date is after letter sent date
                 if (!row.IsResponseDueDateNull() && review.SentDate.HasValue && (review.SentDate.Value < row.ResponseDueDate))
                 {
                     DbrResponseDeadline deadline = new DbrResponseDeadline(row.ResponseDueDate.Date, review);
                     if (!row.IsResponseReceivedDateNull())
                     {
                         deadline.ResponseReceivedDate = row.ResponseReceivedDate;
                     }
                     review.ResponseDeadline = deadline;
                     dbr.ResponseDeadlines.Add(deadline);
                 }
                 dbr.Reviews.Add(review);
             }
         }
         return(dbr);
     }
 }