/// <summary> /// Retrieves the Post Election Audit Draft Audit Report for a specific candidate and election cycle. /// </summary> /// <param name="candidateID">The ID of the candidate whose DAR is to be retrieved.</param> /// <param name="electionCycle">The election cycle in which to search.</param> /// <param name="published">Whether or not to retrieve published data.</param> /// <returns>The Post Election Draft Audit Report for the candidate and election cycle specified if found; otherwise, null.</returns> public DraftAuditReport GetDraftAuditReport(string candidateID, string electionCycle, bool published) { using (DataClient client = new DataClient()) { DraftAuditReport dar = client.GetDraftAuditReport(candidateID, electionCycle, published); if (dar != null && published) { // populate tolling events, which have to be retrieved separately due to WCF serialization limitation with respect to interfaces dar.LoadTollingEvents(this.GetTollingEvents(candidateID, electionCycle, true)); } return(dar); } }
// GET: Audit/PostElection public ActionResult Index() { var idr = GetReport(AuditReportType.InitialDocumentationRequest); var dar = GetReport(AuditReportType.DraftAuditReport); var far = GetReport(AuditReportType.FinalAuditReport); var cid = CPProfile.Cid; var ec = CPProfile.ElectionCycle; var training = CPProfile.TrainingStatus; bool trainingComplete = training != null && training.AuditComplianceAchieved; var model = AuditViewModelFactory.PostElectionFrom( idr: idr, dar: dar, far: far, agencyPhone: CPProviders.SettingsProvider.AgencyPhoneNumber, darTollingDays: idr != null ? idr.TollingDaysIncurred : InitialDocumentationRequest.CountDarTollingDaysIncurred(cid, ec), farTollingDays: dar != null ? dar.TollingDaysIncurred : DraftAuditReport.CountFarTollingDaysIncurred(cid, ec), darIssueDate: DraftAuditReport.GetOriginalIssuanceDate(cid, ec), farIssueDate: FinalAuditReport.GetOriginalIssuanceDate(cid, ec), farOffsetMonths: trainingComplete ? FinalAuditReport.TrainingCompliantFarTargetOffsetMonths : 0, suspended: CPProfile.PESuspension != null); return(View(model)); }
/// <summary> /// Retrieves the Post Election Audit Draft Audit Report for a specific candidate and election cycle. /// </summary> /// <param name="candidateID">The ID of the candidate whose DAR is to be retrieved.</param> /// <param name="electionCycle">The election cycle in which to search.</param> /// <param name="published">Whether or not to retrieve published data.</param> /// <returns>The Post Election Draft Audit Report for the candidate and election cycle specified if found; otherwise, null.</returns> public DraftAuditReport GetDraftAuditReport(string candidateID, string electionCycle, bool published) { DraftAuditReport dar = null; using (PostElectionTds ds = new PostElectionTds()) { if (published) { using (DraftAuditReportTableAdapter ta = new DraftAuditReportTableAdapter()) { ta.Fill(ds.DraftAuditReport, candidateID, electionCycle); } foreach (PostElectionTds.DraftAuditReportRow row in ds.DraftAuditReport) { if (row.IsSentDateNull()) { continue; } dar = new DraftAuditReport(row.SentDate); if (!row.IsReceiptDateNull()) { dar.ReceiptDate = row.ReceiptDate; } if (!row.IsResponseSubmittedDateNull()) { dar.ResponseSubmittedDate = row.ResponseSubmittedDate; } if (!row.IsSecondReceiptDateNull()) { dar.SecondReceiptDate = row.SecondReceiptDate; } if (!row.IsSecondSentDateNull()) { dar.SecondSentDate = row.SecondSentDate; } dar.ResponseDeadline = new DarResponseDeadline(row.DueDate, dar) { ResponseReceivedDate = row.IsResponseReceivedDateNull() ? null : (DateTime?)row.ResponseReceivedDate, SecondDueDate = row.IsSecondDueDateNull() ? null : (DateTime?)row.SecondDueDate }; break; } } else { using (DraftAuditReportDirectTableAdapter ta = new DraftAuditReportDirectTableAdapter()) { ta.Fill(ds.DraftAuditReportDirect, candidateID, electionCycle); } foreach (PostElectionTds.DraftAuditReportDirectRow row in ds.DraftAuditReportDirect) { if (row.IsSentDateNull()) { continue; } dar = new DraftAuditReport(row.SentDate); if (!row.IsReceiptDateNull()) { dar.ReceiptDate = row.ReceiptDate; } if (!row.IsResponseSubmittedDateNull()) { dar.ResponseSubmittedDate = row.ResponseSubmittedDate; } if (!row.IsSecondReceiptDateNull()) { dar.SecondReceiptDate = row.SecondReceiptDate; } if (!row.IsSecondSentDateNull()) { dar.SecondSentDate = row.SecondSentDate; } dar.ResponseDeadline = new DarResponseDeadline(row.DueDate, dar) { ResponseReceivedDate = row.IsResponseReceivedDateNull() ? null : (DateTime?)row.ResponseReceivedDate, SecondDueDate = row.IsSecondDueDateNull() ? null : (DateTime?)row.SecondDueDate }; break; } } } return(dar); }
/// <summary> /// Raises the <see cref="Control.Load"/> event. /// </summary> /// <param name="e">The <see cref="EventArgs"/> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.EnsureChildControls(); // detect DAR/FAR availability _idr = CPProfile.InitialDocumentationRequest; _dar = CPProfile.DraftAuditReport; _far = CPProfile.FinalAuditReport; // detect post election audit report navigation info if (!Page.IsPostBack || !this.IsDataBound || !_postElectionAuditNavigation.EnableViewState) { _postElectionAuditNavigation.DarPresent = _dar != null; _postElectionAuditNavigation.DarTollingPresent = _idr != null && _idr.TollingEvents.Count > 0; _postElectionAuditNavigation.FarPresent = _far != null; _postElectionAuditNavigation.FarTollingPresent = _dar != null && _dar.TollingEvents.Count > 0; } // populate immediate page data if (!Page.IsPostBack || !this.IsDataBound) { // DAR issue dates int darTollingDays = _idr != null ? _idr.TollingDaysIncurred : InitialDocumentationRequest.CountDarTollingDaysIncurred(CPProfile.Cid, CPProfile.ElectionCycle); _darTollingDaysLabel.Text = darTollingDays.ToString(); DateTime?issueDate = DraftAuditReport.GetOriginalIssuanceDate(CPProfile.Cid, CPProfile.ElectionCycle); if (issueDate.HasValue) { _darOriginalIssueDateLabel.Text = issueDate.Value.ToShortDateString(); _darCurrentIssueDateLabel.Text = issueDate.Value.AddDays(darTollingDays).ToShortDateString(); } // FAR issue dates int farTollingDays = _dar != null ? _dar.TollingDaysIncurred : DraftAuditReport.CountFarTollingDaysIncurred(CPProfile.Cid, CPProfile.ElectionCycle); _farTollingDaysLabel.Text = farTollingDays.ToString(); _totalTollingDaysLabel.Text = (darTollingDays + farTollingDays).ToString(); issueDate = CPProfile.FarIssuanceDate; if (issueDate.HasValue) { _farOriginalIssueDateLabel.Text = issueDate.Value.ToShortDateString(); // BUGFIX #54: FAR Original Date is wrong when Audit Training Compliance status is achieved TrainingStatus training = CPProfile.TrainingStatus; if (this.TrainingCompliance.Visible = this.TrainingComplianceReference.Visible = training != null && training.AuditComplianceAchieved) { issueDate = issueDate.Value.AddMonths(FinalAuditReport.TrainingCompliantFarTargetOffsetMonths); } _farCurrentIssueDateLabel.Text = issueDate.Value.AddDays(darTollingDays + farTollingDays).ToShortDateString(); } // immediate report data switch (_postElectionAuditNavigation.SelectedReportType) { case AuditReportType.DraftAuditReport: DataBindToReport(_dar); // check for "no findings" condition _reportSummary.NoFindingsOverride = _dar == null && _far != null; break; case AuditReportType.FinalAuditReport: DataBindToReport(_far); break; default: _idr = CPProfile.InitialDocumentationRequest; DataBindToReport(_idr); break; } // current status/suspension check if (CPProfile.PESuspension != null) { _currentStatus.Text = SuspensionText; _currentStatus.CssClass = "campaign"; _darCurrentIssueDateLabel.Text = _farCurrentIssueDateLabel.Text = "(n/a)"; } else if (_far != null) { _currentStatus.Text = FinalAuditCompleteText; _currentStatus.CssClass = null; } else { bool responseReceived = false; InadequateEventBase inadequate; if (_dar != null) { inadequate = _dar.InadequateNotice; if (inadequate != null) { responseReceived = inadequate.ResponseReceived; _currentStatus.Text = responseReceived ? UnderReviewText : DarInadequatePendingText; } else { responseReceived = _dar.ResponseReceived; _currentStatus.Text = responseReceived ? UnderReviewText : DarPendingText; } } else if (_idr != null) { inadequate = _idr.InadequateNotice; if (inadequate != null) { responseReceived = inadequate.ResponseReceived; _currentStatus.Text = responseReceived ? UnderReviewText : IdrInadequatePendingText; } else { responseReceived = _idr.ResponseReceived; _currentStatus.Text = responseReceived ? UnderReviewText : IdrPendingText; } } if (!responseReceived) { _currentStatus.CssClass = "campaign"; } } _tollingEventsList.DataBind(); this.MarkAsDataBound(); } }