/// <summary> /// Retrieves a collection of the specified candidate's complete threshold status history for the specified election cycle. /// </summary> /// <param name="candidateID">The ID of the candidate whose Conflict of Interest Board receipts are to be retrieved.</param> /// <param name="electionCycle">The election cycle in which to search.</param> /// <returns>A collection of the specified candidate's complete threshold status history for the specified election cycle.</returns> public ThresholdHistory GetThresholdHistory(string candidateID, string electionCycle) { Election election = GetElections(CPProviders.SettingsProvider.MinimumElectionCycle)[electionCycle]; if (election == null || string.IsNullOrEmpty(candidateID)) { return(null); } using (ThresholdTds ds = new ThresholdTds()) { using (ThresholdTableAdapter ta = new ThresholdTableAdapter()) { ta.Fill(ds.Threshold, candidateID, election.Cycle); } var statements = this.GetStatements(election.Cycle); ThresholdHistory history = new ThresholdHistory(); ThresholdStatus status; foreach (ThresholdTds.ThresholdRow row in ds.Threshold.Rows) { try { Statement statement; if (!statements.TryGetValue((byte)row.Statement, out statement)) { continue; } // if a new statement is being added, create a new status statement group if (!history.History.TryGetValue(statement.Number, out status)) { status = new ThresholdStatus(statement.Number); history.History.Add(statement.Number, status); } NycBorough borough = CPConvert.ToNycBorough(row.BoroughCode.Trim()); status.Add(new ThresholdRevision(statement, CPConvert.ToThresholdRevisionType(row.Type.Trim())) { Date = row.Date, Number = (ushort)row.Number, NumberRequired = (ushort)row.NumberRequired, Funds = row.Funds, FundsRequired = row.FundsRequired, Office = (borough != NycBorough.Unknown) ? new NycPublicOffice(borough) : new NycPublicOffice(CPConvert.ToNycPublicOfficeType(row.OfficeCode.Trim())) }); } catch (InvalidCastException) { } } return(history); } }
public NotificationServiceFactory(NotificationOrigins origin , string userId , Dictionary <string, string> data , ThresholdStatus status ) { _origin = origin; _userId = userId; // Addin notification level data.Add("NotificationLevel", GetNotificationLevel(status)); _data = data; _userProfileRepo = new UserProfileRepository(); _accountRepository = new AccountRepository(); }
private static string GetNotificationLevel(ThresholdStatus status) { switch (status) { case ThresholdStatus.Good: return(NotificationLevel.Info.ToFriendlyString()); case ThresholdStatus.Warning: return(NotificationLevel.Warning.ToFriendlyString()); case ThresholdStatus.Critical: return(NotificationLevel.Critical.ToFriendlyString()); default: throw new ArgumentOutOfRangeException("status"); } }