Exemplo n.º 1
0
 /// <summary>
 /// Gets the unique message ID for a specific payment letter's corresponding CMO message.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate context.</param>
 /// <param name="paymentRun">The payment run number.</param>
 /// <returns>The unique ID of the CMO message for the specified payment run if found; otherwise, null.</returns>
 public string GetPaymentMessageID(string candidateID, byte paymentRun)
 {
     using (Data.CmoEntities context = new Data.CmoEntities())
     {
         var message = context.CmoMessages.OrderByDescending(m => m.PostDate).FirstOrDefault(m => m.CandidateId == candidateID && m.PostDate.HasValue && m.CmoAuditReview.ReviewNumber == paymentRun);
         return(message == null ? null : CmoMessage.ToUniqueID(message.CandidateId, message.MessageId));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Gets a collection of IDs for all post election audit reports for a specific candidate and election cycle.
 /// </summary>
 /// <param name="candidateID">The CFIS ID of the reviewed candidate.</param>
 /// <param name="electionCycle">The election cycle of the reviews.</param>
 /// <returns>A collection of unique IDs for all post election audit report CMO messages found.</returns>
 public Dictionary <AuditReportType, string> GetAuditReportMessageIDs(string candidateID, string electionCycle)
 {
     using (Data.CmoEntities context = new Data.CmoEntities())
     {
         var categories = new List <byte> {
             CmoCategory.IdrCategoryID, CmoCategory.IdrInadequateCategoryID, CmoCategory.IdrAdditionalInadequateCategoryID, CmoCategory.DarCategoryID, CmoCategory.DarInadequateCategoryID, CmoCategory.DarAdditionalInadequateCategoryID, CmoCategory.FarCategoryID
         };
         var messages = from m in context.CmoMessages
                        join c in context.CmoCategories
                        on m.CmoCategory.CategoryId equals c.CategoryId
                        where m.CandidateId == candidateID && m.ElectionCycle == electionCycle && m.PostDate.HasValue && categories.Contains(m.CmoCategory.CategoryId)
                        group m by m.CmoCategory.CategoryId into mgroup
                        select new { CategoryID = mgroup.Key, MessageID = mgroup.Max(m => m.MessageId) };
         return((from m in messages.AsEnumerable().Select(m => new { AuditReportType = CmoCategory.ToAuditReportType(m.CategoryID), m.MessageID })
                 where m.AuditReportType.HasValue
                 select m).ToDictionary(m => m.AuditReportType.Value, m => CmoMessage.ToUniqueID(candidateID, m.MessageID)));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets a collection of IDs for all post election audit tolling messages for a specific candidate and election cycle.
 /// </summary>
 /// <param name="candidateID">The CFIS ID of the reviewed candidate.</param>
 /// <param name="electionCycle">The election cycle of the reviews.</param>
 /// <param name="far">true to specify Final Audit Report tolling; otherwise, false to specify Draft Audit Report tolling.</param>
 /// <returns>A collection of unique IDs for all tolling event CMO messages found, indexed by tolling event ID.</returns>
 public Dictionary <int, string> GetTollingMessageIDs(string candidateID, string electionCycle, bool far)
 {
     using (Data.CmoEntities context = new Data.CmoEntities())
     {
         var letters = GetTollingLetters();
         Dictionary <int, string> ids = new Dictionary <int, string>();
         foreach (var evt in context.CmoGetCandidateTollingEvents(candidateID, electionCycle, far))
         {
             ids[letters.Any(l => l.ID == evt.LetterId && l.IsInadequate) ? -evt.EventNumber : evt.EventNumber] = CmoMessage.ToUniqueID(candidateID, evt.MessageId);
         }
         return(ids);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets a collection of IDs for all audit review messages for a specific candidate and election cycle.
 /// </summary>
 /// <param name="reviewCategoryID">The category ID of the desired audit review type.</param>
 /// <param name="candidateID">The CFIS ID of the reviewed candidate.</param>
 /// <param name="electionCycle">The election cycle of the reviews.</param>
 /// <returns>A collection of unique IDs for all audit review CMO messages found.</returns>
 private Dictionary <byte, string> GetAuditReviewMessageIDs(byte reviewCategoryID, string candidateID, string electionCycle)
 {
     if (!new[] { CmoCategory.StatementReviewCategoryID, CmoCategory.ComplianceVisitCategoryID, CmoCategory.DoingBusinessReviewCategoryID }.Contains(reviewCategoryID))
     {
         return(new Dictionary <byte, string>(0));
     }
     using (Data.CmoEntities context = new Data.CmoEntities())
     {
         return((from m in context.CmoMessages
                 join r in context.CmoAuditReviews
                 on new { m.CandidateId, m.MessageId } equals new { r.CandidateId, r.MessageId }
                 where m.PostDate.HasValue && m.CandidateId == candidateID && m.ElectionCycle == electionCycle && m.CmoCategory.CategoryId == reviewCategoryID
                 group r by r.ReviewNumber into rgroup
                 select new { ReviewNumber = rgroup.Key, MessageID = rgroup.Max(r => r.MessageId) }).ToDictionary(r => r.ReviewNumber, r => CmoMessage.ToUniqueID(candidateID, r.MessageID)));
     }
 }
        /// <summary>
        /// Raises the <see cref="Control.DataBinding"/> event.
        /// </summary>
        /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param>
        protected override void OnDataBinding(EventArgs e)
        {
            _rowsArray.Clear();
            string cid = CPProfile.Cid;

            // generate HTML for each public funds determination record
            foreach (PublicFundsDetermination item in this.DataSource)
            {
                string downloadLink = item.MessageID > 0 ? string.Format("<a class=\"pdf-file\" href=\"{0}\" title=\"{1}\">{1}</a>", PageUrlManager.GetMessageUrl(CmoMessage.ToUniqueID(cid, item.MessageID)), "View Letter") : null;
                if (item.PaymentIssued)
                {
                    _rowsArray.Add(string.Format(PaymentRowHtmlTemplate, item.Date, item.PaymentAmount, CPConvert.ToString(item.PaymentMethod), CPConvert.ToString(item.ElectionType), downloadLink));
                }
                else
                {
                    _rowsArray.Add(string.Format(NonPaymentRowHtmlTemplate, item.Date, CPConvert.ToString(item.ElectionType), downloadLink));
                }
            }

            // generate HTML for public funds summary
            _footerHtml = string.Format(FooterHtmlTemplate, this.DataSource.PaymentCount, this.DataSource.TotalPaymentAmount);
        }