コード例 #1
0
        /// <summary>
        /// Retrieves a collection of immediately upcoming Doing Business events that are ready for reminder e-mails.
        /// </summary>
        /// <param name="candidateID">The ID of the targeted candidate.</param>
        /// <param name="electionCycle">The election cycle in which to search.</param>
        /// <param name="lastRetrieved">The lower limit date of events that can be retrieved, non-inclusive.</param>
        /// <returns>A collection of immediately upcoming Doing Business events that are ready for reminder e-mails.</returns>
        private IEnumerable <DbrResponseDeadline> GetDoingBusinessEvents(string candidateID, string electionCycle, DateTime lastRetrieved)
        {
            // process events upcoming within [DoingBusinessReminderDays]
            DateTime upperLimit = DateTime.Today.AddDays(Properties.Settings.Default.DoingBusinessReminderDays);
            // last retrieval would have processed all events within [DoingBusinessReminderDays], so we set lower limit one day later to avoid double-sending
            DateTime lowerLimit = lastRetrieved.Date.AddDays(Properties.Settings.Default.DoingBusinessReminderDays + 1);

            // lower limit must not be earlier than tomorrow (future)
            if (lowerLimit <= DateTime.Today)
            {
                lowerLimit = DateTime.Today.AddDays(Properties.Settings.Default.DoingBusinessReminderDays);
            }
            Elections elections = Elections.GetElections(CPProviders.SettingsProvider.MinimumElectionCycle);

            if (elections != null)
            {
                Election election = elections[electionCycle];
                if (election != null)
                {
                    bool isElectionYear = election.Year == DateTime.Now.Year;
                    return(from r in DoingBusinessReviews.GetDoingBusinessReviews(candidateID, electionCycle).ResponseDeadlines
                           where r.StartDate.Date >= lowerLimit && r.StartDate.Date <= upperLimit && isElectionYear ? r.IsElectionYearUpcoming : r.IsUpcoming
                           select r);
                }
            }
            return(null);
        }
コード例 #2
0
 public static AuditReviewTrackingViewModel DoingBusinessReviewsFrom(DoingBusinessReviews source, IDictionary <byte, string> messageIDs)
 {
     return(source == null ? new AuditReviewTrackingViewModel() : new AuditReviewTrackingViewModel
     {
         SentNamePrefix = "Review",
         Reviews = (from r in source.Reviews
                    group r by r.CommitteeID).ToDictionary(g => g.Key, g => g.Select(r => AuditReviewFrom(r, messageIDs.ContainsKey(r.Number) ? messageIDs[r.Number] : null, r.Statement))),
         CommiteeNames = GetNamesFrom(source.Reviews)
     });
 }
コード例 #3
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);
     }
 }