private void SetCredentialMessage() { switch (UserSecurityClass) { case MasterSecurityClass: CredentialMessage.InnerHtml = IsSuperUser ? "Your sign-in credentials allow any offices to be updated." : "Your sign-in credentials allow any federal, state, county or local offices to be updated."; break; case StateAdminSecurityClass: CredentialMessage.InnerHtml = "Your sign-in credentials permit any " + States.GetName(StateCode) + " offices to be updated."; break; case CountyAdminSecurityClass: CredentialMessage.InnerHtml = "Your sign-in credentials permit only " + Counties.GetFullName(StateCode, CountyCode) + " offices to be updated."; break; case LocalAdminSecurityClass: CredentialMessage.InnerHtml = "Your sign-in credentials permit only " + LocalDistricts.GetFullName(StateCode, CountyCode, LocalKey) + " offices to be updated."; SelectJurisdictionButton.Visible = false; break; default: throw new VoteException("Unexpected UserSecurityClass: " + UserSecurityClass); } }
private void SetSubHeading() { switch (AdminPageLevel) { //case AdminPageLevel.President: //case AdminPageLevel.PresidentTemplate: //case AdminPageLevel.Federal: // H2.InnerHtml = States.GetName(StateCode) + ", All States"; // break; case AdminPageLevel.State: H2.InnerHtml = "General State Information for " + States.GetName(StateCode); break; case AdminPageLevel.County: H2.InnerHtml = "General County Information for " + Counties.GetFullName(StateCode, CountyCode); break; case AdminPageLevel.Local: H2.InnerHtml = "General Local Information for " + LocalDistricts.GetFullName(StateCode, CountyCode, LocalCode); break; case AdminPageLevel.Unknown: H2.InnerHtml = "No Jurisdiction Selected"; break; } }
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBeProtected.Global // ReSharper disable UnusedMember.Global // ReSharper disable UnusedMethodReturnValue.Global // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnassignedField.Global #endregion ReSharper disable public static Control GetReport(string stateCode, string countyCode, Func <string, string, string, string, Control> getAnchor, bool sortByCode = false) { var localsDictionary = LocalDistricts.GetNamesDictionary(stateCode, countyCode); var reorderedLocals = localsDictionary.OrderBy( kvp => sortByCode ? kvp.Key : kvp.Value) .ReorderVertically(MaxCellsInRow); var htmlTable = new HtmlTable { CellSpacing = 0, Border = 0 }.AddCssClasses("tableAdmin"); HtmlTableRow tr = null; var cellsInCurrentRow = int.MaxValue; // force initial new row foreach (var local in reorderedLocals) { if (cellsInCurrentRow >= MaxCellsInRow) { tr = new HtmlTableRow().AddTo(htmlTable, "trLinks"); cellsInCurrentRow = 0; } cellsInCurrentRow++; var td = new HtmlTableCell().AddTo(tr, "tdLinks"); getAnchor(stateCode, countyCode, local.Key, local.Value) .AddTo(td); } return(htmlTable); }
private void AnalyzeDeletions(string address) { var found = false; found |= AnalyzeCount(States.CountByEmail(address), address, "States.Email"); found |= AnalyzeCount(States.CountByAltEmail(address), address, "States.AltEmail"); found |= AnalyzeCount(Counties.CountByEmail(address), address, "Counties.Email"); found |= AnalyzeCount(Counties.CountByAltEmail(address), address, "Counties.AltEmail"); found |= AnalyzeCount(LocalDistricts.CountByEmail(address), address, "LocalDistricts.Email"); found |= AnalyzeCount(LocalDistricts.CountByAltEmail(address), address, "LocalDistricts.AltEmail"); found |= AnalyzeCount(Politicians.CountByEmail(address), address, "Politicians.Email"); found |= AnalyzeCount(Politicians.CountByCampaignEmail(address), address, "Politicians.CampaignEmail"); found |= AnalyzeCount(Politicians.CountByEmailVoteUSA(address), address, "Politicians.EmailVoteUSA"); found |= AnalyzeCount(Politicians.CountByStateEmail(address), address, "Politicians.StateEmail"); //found |= AnalyzeCount(Politicians.CountByLDSEmail(address), address, "Politicians.LDSEmail"); found |= AnalyzeCount(Addresses.EmailExists(address) ? 1 : 0, address, "Addresses.Email"); found |= AnalyzeCount(PartiesEmails.PartyEmailExists(address) ? 1 : 0, address, "PartiesEmails.PartyEmail"); if (!found) { _Messages.Add($"<p class=\"error\">{address} not found</p>"); } }
private void SetSubHeading() { switch (AdminPageLevel) { case AdminPageLevel.State: H2.InnerHtml = "General State Information for " + States.GetName(StateCode); break; case AdminPageLevel.County: H2.InnerHtml = "General County Information for " + Counties.GetFullName(StateCode, CountyCode); break; case AdminPageLevel.Local: H2.InnerHtml = "General Local Information for " + LocalDistricts.GetFullName(StateCode, CountyCode, LocalKey); FormatOtherCountiesMessage(MultiCountyMessage); break; case AdminPageLevel.Unknown: H2.InnerHtml = "No Jurisdiction Selected"; break; } }
private void SetSubHeading() { switch (AdminPageLevel) { case AdminPageLevel.AllStates: H2.InnerHtml = "Bulk Email for All States"; break; case AdminPageLevel.State: H2.InnerHtml = $"Bulk Email for {States.GetName(StateCode)}"; break; case AdminPageLevel.County: H2.InnerHtml = $"Bulk Email for {Counties.GetFullName(StateCode, CountyCode)}"; break; case AdminPageLevel.Local: H2.InnerHtml = $"Bulk Email for {LocalDistricts.GetFullName(StateCode, CountyCode, LocalKey)}"; break; case AdminPageLevel.Unknown: H2.InnerHtml = "No Jurisdiction Selected"; break; } }
public static string FindLocalKey() { var stateCode = FindStateCode(); if (IsNullOrWhiteSpace(stateCode)) { return(Empty); } var localKey = QueryLocal; if (IsNullOrWhiteSpace(localKey)) { if (IsMasterUser || IsAdminUser) { localKey = UserLocalKey; if (IsNullOrWhiteSpace(localKey)) { localKey = Elections.GetLocalKeyFromKey(QueryElection); } if (IsNullOrWhiteSpace(localKey)) { localKey = Offices.GetLocalKeyFromKey(QueryOffice); } } } return(!IsNullOrWhiteSpace(localKey) && LocalDistricts.IsValidKey(stateCode, localKey) ? localKey : Empty); }
// ReSharper restore UnassignedField.Global // ReSharper restore UnusedAutoPropertyAccessor.Global // ReSharper restore UnusedMethodReturnValue.Global // ReSharper restore UnusedMember.Global // ReSharper restore MemberCanBeProtected.Global // ReSharper restore MemberCanBePrivate.Global #endregion ReSharper restore #endregion Public #region Private private void SetCredentialMessage() { switch (UserSecurityClass) { case MasterSecurityClass: CredentialMessage.InnerHtml = "Your sign-in credentials allow access to all bulk mail capabilities."; break; case StateAdminSecurityClass: CredentialMessage.InnerHtml = $"Your sign-in credentials permit bulk mailing to any {States.GetName(StateCode)} recipients."; break; case CountyAdminSecurityClass: CredentialMessage.InnerHtml = $"Your sign-in credentials permit bulk mailing only to {Counties.GetFullName(StateCode, CountyCode)} recipients."; break; case LocalAdminSecurityClass: CredentialMessage.InnerHtml = $"Your sign-in credentials permit bulk mailing only to {LocalDistricts.GetFullName(StateCode, CountyCode, LocalKey)} recipients."; break; default: throw new VoteException($"Unexpected UserSecurityClass: {UserSecurityClass}"); } }
private void SetCredentialMessage() { switch (UserSecurityClass) { case MasterSecurityClass: CredentialMessage.InnerHtml = "Your sign-in credentials allow any jurisdiction to be updated."; break; case StateAdminSecurityClass: CredentialMessage.InnerHtml = "Your sign-in credentials permit any " + States.GetName(StateCode) + " jurisdiction to be updated."; break; case CountyAdminSecurityClass: CredentialMessage.InnerHtml = "Your sign-in credentials permit only " + Counties.GetFullName(StateCode, CountyCode) + " jurisdictions to be updated."; break; case LocalAdminSecurityClass: CredentialMessage.InnerHtml = "Your sign-in credentials permit only the " + LocalDistricts.GetFullName(StateCode, CountyCode, LocalCode) + " jurisdiction to be updated."; ChangeJurisdictionButton.Visible = false; break; default: throw new VoteException("Unexpected UserSecurityClass: " + UserSecurityClass); } }
private void SetSubHeading() { switch (AdminPageLevel) { case AdminPageLevel.President: case AdminPageLevel.PresidentTemplate: case AdminPageLevel.Federal: H2.InnerHtml = States.GetName(StateCode) + ", All States"; break; case AdminPageLevel.State: H2.InnerHtml = "State Elections for " + States.GetName(StateCode); break; case AdminPageLevel.County: H2.InnerHtml = "County Elections for " + Counties.GetFullName(StateCode, CountyCode); break; case AdminPageLevel.Local: H2.InnerHtml = "Local Elections for " + LocalDistricts.GetFullName(StateCode, CountyCode, LocalKey); int countyCount; if ((countyCount = FormatOtherCountiesMessage(MultiCountyMessage)) > 1) { MultiCountyMessage.InnerText += $". Changes you make to elections will appear in {(countyCount == 2 ? "both" : "all")} counties."; } break; case AdminPageLevel.Unknown: H2.InnerHtml = "No Jurisdiction Selected"; break; } }
public void GenerateAll(ElectedReportResponsive electedReport, string stateCode, string countyCode, Control reportContainer = null) { var localGroups = electedReport.DataManager.GetDataSubset(new LocalFilter(), new OfficialsSort()) .GroupBy(row => row.LocalCode()) .ToList(); if (localGroups.Count == 0) { return; } var localNamesDictionary = LocalDistricts.GetNamesDictionary(stateCode, countyCode); localGroups = localGroups.OrderBy(g => localNamesDictionary[g.Key]) .ToList(); foreach (var local in localGroups) { LocalName = localNamesDictionary[local.Key]; _CurrentData = local.GroupBy(row => row.OfficeKey()) .ToList(); Generate(electedReport, false, stateCode, countyCode, string.Empty, reportContainer); } }
private void SetSubHeading() { switch (AdminPageLevel) { //case AdminPageLevel.President: //case AdminPageLevel.PresidentTemplate: //case AdminPageLevel.Federal: // H2.InnerHtml = States.GetName(StateCode) + ", All States"; // break; case AdminPageLevel.State: H2.InnerHtml = "State Offices for " + States.GetName(StateCode); break; case AdminPageLevel.County: H2.InnerHtml = "County Offices for " + Counties.GetFullName(StateCode, CountyCode); break; case AdminPageLevel.Local: H2.InnerHtml = "Local Offices for " + LocalDistricts.GetFullName(StateCode, CountyCode, LocalKey); FormatOtherCountiesMessage(MuliCountyMessage); break; case AdminPageLevel.Unknown: H2.InnerHtml = "No Jurisdiction Selected"; break; } }
protected void ButtonRemoveMultiCountyDistricts_OnClick(object sender, EventArgs e) { switch (RemoveMultiCountyDistrictsReloading.Value) { case "reloading": { RemoveMultiCountyDistrictsReloading.Value = Empty; _RemoveMultiCountyDistrictsTabInfo.ClearValidationErrors(); var items = FormatMultiCountyLocalsList(LocalDistricts.GetLocalsForRemove(StateCode, CountyCode)); PopulateDistrictsToRemoveDropdown(items); _RemoveMultiCountyDistrictsTabInfo.LoadControls(); FeedbackRemoveMultiCountyDistricts.AddInfo("Remove Multi-County Districts settings loaded."); } break; case "": { try { // normal update _RemoveMultiCountyDistrictsTabInfo.ClearValidationErrors(); var localKey = ControlRemoveMultiCountyDistrictsLocalKey.GetValue(); if (IsNullOrWhiteSpace(localKey)) { throw new VoteException("No district was selected"); } var lic = LocalIdsCodes.GetDataByStateCodeLocalKey(StateCode, localKey); if (lic.Count != 1) { throw new VoteException("Missing LocalIdsCodes row"); } if (lic[0].LocalType != LocalIdsCodes.LocalTypeVote) { throw new VoteException("Invalid LocalType"); } TigerPlacesCounties.DeleteByStateCodeCountyCodeTigerCodeTigerType(StateCode, CountyCode, lic[0].LocalId, lic[0].LocalType); _RemoveMultiCountyDistrictsTabInfo.ClearValidationErrors(); var items = FormatMultiCountyLocalsList(LocalDistricts.GetLocalsForRemove(StateCode, CountyCode)); PopulateDistrictsToRemoveDropdown(items); _RemoveMultiCountyDistrictsTabInfo.LoadControls(); NavigateJurisdictionUpdatePanel.Update(); NavigateJurisdiction.Initialize(); FeedbackRemoveMultiCountyDistricts.AddInfo("Multi-County District removed."); } catch (Exception ex) { FeedbackRemoveMultiCountyDistricts.HandleException(ex); } } break; default: throw new VoteException($"Unknown reloading option: '{RemoveMultiCountyDistrictsReloading.Value}'"); } }
private void AnalyzeElectoralClass() { string titleContentDescription; var metaContentLocation = Empty; switch (_ElectoralClass) { case ElectoralClass.USPresident: titleContentDescription = "Current US President and Vice President"; break; case ElectoralClass.USSenate: titleContentDescription = "Current US Senators"; break; case ElectoralClass.USHouse: titleContentDescription = "Current US House Members"; break; case ElectoralClass.USGovernors: titleContentDescription = "Current State Governors and Lieutenant Governors"; break; case ElectoralClass.State: titleContentDescription = $"Current {StateCache.GetStateName(_StateCode)} Elected Representatives"; break; case ElectoralClass.County: titleContentDescription = "Current County Representatives"; metaContentLocation = $"{CountyCache.GetCountyName(_StateCode, _CountyCode)}, {StateCache.GetStateName(_StateCode)}"; break; case ElectoralClass.Local: titleContentDescription = "Current Local District Representatives"; metaContentLocation = $"{LocalDistricts.GetName(_StateCode, _LocalKey)}," + $" {CountyCache.GetCountyName(_StateCode, _CountyCode)}, {StateCache.GetStateName(_StateCode)}"; break; default: titleContentDescription = "Elected Representatives"; break; } var metaContentDescription = titleContentDescription; if (metaContentLocation != Empty) { metaContentDescription += $", {metaContentLocation}"; } //PageHeading.MainHeadingText = titleContentDescription; H1.InnerText = titleContentDescription; Title = Format(TitleTag, metaContentDescription, PublicMasterPage.SiteName); MetaDescription = Format(MetaDescriptionTag, metaContentDescription); }
public static string Local_Code() { var viewStateLocalCode = SecurePage.GetViewStateLocalCode(); if (viewStateLocalCode != null) { return(viewStateLocalCode); } var localCode = string.Empty; if ( !VotePage.IsSessionStateEnabled || !SecurePage.IsSignedIn ) { if (!string.IsNullOrEmpty(VotePage.QueryElection)) { localCode = Elections.GetLocalCodeFromKey( VotePage.QueryElection); } else if (!string.IsNullOrEmpty(VotePage.QueryOffice)) { localCode = Offices.GetLocalCodeFromKey(VotePage.QueryOffice); } else if (!string.IsNullOrEmpty(VotePage.QueryLocal)) { localCode = VotePage.QueryLocal; } if ( (localCode == "00") || //Directory of Local Districts (LocalDistricts.IsValid(State_Code() , County_Code() , localCode)) ) { return(localCode); } return(string.Empty); } if (!string.IsNullOrEmpty(VotePage.QueryLocal)) { //Session["UserLocalCode"] = db.QueryString("Local"); Session_Put("UserLocalCode", VotePage.QueryLocal); } //Local_Code = db.User_LocalCode(); if (LocalDistricts.IsValid( State_Code() , User_CountyCode() , User_LocalCode())) { return(User_LocalCode()); } return(string.Empty); }
private Control GenerateReportByJurisdiction(string stateCode, string countyCode, string localKey) { ReportContainer.ID = "new-accordions"; ReportContainer.ClientIDMode = ClientIDMode.Static; stateCode = stateCode.ToUpperInvariant(); _DataManager.GetDataByJurisdiction(stateCode, countyCode, localKey); var issueLevelGroups = _DataManager.GetDataSubset() .GroupBy(row => new { IssueGroupId = row.IssueGroupId(), IssueId = row.IssueId() }) .ToList() .GroupBy(g => g.Key.IssueGroupId) .ToList() .GroupBy(g => g.First().First() .IssueLevel()) .OrderBy(g => g.Key) .ToList(); foreach (var issueLevelGroup in issueLevelGroups) { switch (issueLevelGroup.Key) { case Issues.IssueLevelAll: OneReportSection(issueLevelGroup, "Questions Available to All Candidates"); break; case Issues.IssueLevelNational: OneReportSection(issueLevelGroup, "Questions Available to U.S. President, U.S. House and U.S. Senate Candidates"); break; case Issues.IssueLevelState: OneReportSection(issueLevelGroup, $"Questions Available to {StateCache.GetStateName(stateCode)}" + " Statewide, House and Senate Candidates"); break; case Issues.IssueLevelCounty: OneReportSection(issueLevelGroup, $"Questions Available to {Counties.GetName(stateCode, countyCode)}" + $" ({stateCode}) Candidates"); break; case Issues.IssueLevelLocal: OneReportSection(issueLevelGroup, $"Questions Available to {LocalDistricts.GetName(stateCode, localKey)}" + $" ({stateCode}) Candidates"); break; } } return(ReportContainer.AddCssClasses("issue-list-report accordion-container")); }
private void GetLocalElections(Control container, string countyElectionKey) { var stateCode = Elections.GetStateCodeFromKey(countyElectionKey); var countyCode = Elections.GetCountyCodeFromKey(countyElectionKey); var stateElectionKey = Elections.GetStateElectionKeyFromKey(countyElectionKey); // We get a dictionary of locals with elections that match the stateElectionKey // Key: localCode; Value: local electionKey // Locals without an election will not be in the dictionary var localElectionDictionary = ElectionsOffices.GetLocalElections(stateElectionKey, countyCode); // We can't forget the Ballot Measures... var localReferendumDictionary = Referendums.GetLocalElections(stateElectionKey, countyCode); // merge them into the first dictionary foreach (var kvp in localReferendumDictionary) { if (!localElectionDictionary.ContainsKey(kvp.Key)) { localElectionDictionary.Add(kvp.Key, kvp.Value); } } if (localElectionDictionary.Count == 0) { return; } // We also get a dictionary of all local names for the county var localNamesDictionary = LocalDistricts.GetNamesDictionary(stateCode, countyCode); new HtmlDiv { InnerText = "Local District Elections" }.AddTo(container, "accordion-header"); var content = new HtmlDiv().AddTo(container, "category-content accordion-content"); // For reporting we filter only locals with elections and sort by name, var locals = localNamesDictionary.Where( kvp => localElectionDictionary.ContainsKey(kvp.Key)) .OrderBy(kvp => kvp.Value) .ToList(); foreach (var kvp in locals) { var localCode = kvp.Key; var localName = kvp.Value; var localElectionKey = localElectionDictionary[localCode]; new HtmlDiv { InnerText = localName }.AddTo(content, "accordion-header"); new ElectionReportResponsive().GenerateReport(ReportUser, localElectionKey) .AddTo(content, "accordion-content"); } }
// ReSharper disable UnusedMember.Local // Invoked via Reflection internal static void Initialize(BulkEmailPage page) // ReSharper restore UnusedMember.Local { if (!page.IsPostBack) { if (IsNullOrWhiteSpace(page.StateCode)) { StateCache.Populate(page.PreviewSampleStateDropDownList, "<none>", Empty); Utility.PopulateEmpty(page.PreviewSampleElectionDropDownList); Utility.PopulateEmpty(page.PreviewSamplePartyDropDownList); } else { StateCache.Populate(page.PreviewSampleStateDropDownList, page.StateCode); Utility.PopulateFromList(page.PreviewSampleElectionDropDownList, GetPreviewElectionItems(page.StateCode, page.CountyCode, page.LocalKey)); Utility.PopulateFromList(page.PreviewSamplePartyDropDownList, GetPreviewPartyItems(page.StateCode)); } CountyCache.Populate(page.PreviewSampleCountyDropDownList, page.StateCode, "<none>", Empty, page.CountyCode); LocalDistricts.Populate(page.PreviewSampleLocalDropDownList, page.StateCode, page.CountyCode, "<none>", Empty, page.LocalKey); Utility.PopulateEmpty(page.PreviewSampleOfficeDropDownList); Utility.PopulateEmpty(page.PreviewSampleCandidateDropDownList); Utility.PopulateEmpty(page.PreviewSamplePartyEmailDropDownList); switch (UserSecurityClass) { case MasterSecurityClass: break; case StateAdminSecurityClass: page.PreviewSampleStateDropDownList.Enabled = false; break; case CountyAdminSecurityClass: page.PreviewSampleStateDropDownList.Enabled = false; page.PreviewSampleCountyDropDownList.Enabled = false; page.PreviewSamplePartyDropDownList.Enabled = false; page.PreviewSamplePartyEmailDropDownList.Enabled = false; break; case LocalAdminSecurityClass: page.PreviewSampleStateDropDownList.Enabled = false; page.PreviewSampleCountyDropDownList.Enabled = false; page.PreviewSampleLocalDropDownList.Enabled = false; page.PreviewSamplePartyDropDownList.Enabled = false; page.PreviewSamplePartyEmailDropDownList.Enabled = false; break; } } }
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBeProtected.Global // ReSharper disable UnusedMember.Global // ReSharper disable UnusedMethodReturnValue.Global // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnassignedField.Global #endregion ReSharper disable public static void AddLinks(Control parent, string stateCode, string countyCode, Func<string, string, string, string, string, Control> getAnchor) { var localsDictionary = LocalDistricts.GetNamesDictionary(stateCode, countyCode) .OrderBy(kvp => kvp.Value, new AlphanumericComparer()).ToArray(); var otherCounties = LocalIdsCodes.FormatOtherCountyNamesDictionary(stateCode, countyCode, localsDictionary.Select(l => l.Key)); foreach (var local in localsDictionary) getAnchor(stateCode, countyCode, local.Key, local.Value, otherCounties[local.Key]) .AddTo(parent); }
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBeProtected.Global // ReSharper disable UnusedMember.Global // ReSharper disable UnusedMethodReturnValue.Global // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnassignedField.Global #endregion ReSharper disable public static void GetReport(Control container, string countyElectionKey, bool openAll = false) { var stateCode = Elections.GetStateCodeFromKey(countyElectionKey); var countyCode = Elections.GetCountyCodeFromKey(countyElectionKey); var stateElectionKey = Elections.GetStateElectionKeyFromKey(countyElectionKey); // We get a dictionary of locals with elections that match the stateElectionKey // Key: localKey; Value: local electionKey // Locals without an election will not be in the dictionary // We can't forget the Ballot Measures... var localKeys = LocalDistricts.GetLocalKeysForCounty(stateCode, countyCode); var localElectionDictionary = ElectionsOffices.GetLocalElections(stateElectionKey, countyCode, localKeys); var localReferendumDictionary = Referendums.GetLocalElections(stateElectionKey, countyCode, localKeys); // merge them into the first dictionary foreach (var kvp in localReferendumDictionary) if (!localElectionDictionary.ContainsKey(kvp.Key)) localElectionDictionary.Add(kvp.Key, kvp.Value); if (localElectionDictionary.Count == 0) return; // We also get a dictionary of all local names for the county var localNamesDictionary = LocalDistricts.GetNamesDictionary(stateCode, countyCode); new HtmlDiv {InnerText = "Local District Elections"}.AddTo(container, "accordion-header"); var content = new HtmlDiv().AddTo(container, "local-anchors accordion-content"); // For reporting we filter only locals with elections and sort by name, var locals = localNamesDictionary.Where(kvp => localElectionDictionary.ContainsKey(kvp.Key)) .OrderBy(kvp => kvp.Value, new AlphanumericComparer()) .ToList(); // get a dictionary of other county names for multiple counties var otherCountyNames = LocalIdsCodes.FormatOtherCountyNamesDictionary(stateCode, countyCode, locals.Select(l => l.Key)); foreach (var kvp in locals) { var localKey = kvp.Key; var localName = kvp.Value; var otherCounties = otherCountyNames[localKey]; if (!IsNullOrWhiteSpace(otherCounties)) localName += $" (also in {otherCounties})"; var localElectionKey = localElectionDictionary[localKey]; CreatePublicElectionAnchor(localElectionKey, localName, openAll) .AddTo(content, "local-anchor"); } }
protected override bool Update(object newValue) { // everything has been validated already var changed = false; var stateCode = Page.StateCode; var countyCode = Page.CountyCode; foreach (var s in _Submitted) { if (s.New) { CountySupervisors.Insert(stateCode, s.Id, s.Name, countyCode, s.InShapefile); if (s.Create) { // also create local district var localKey = LocalDistricts.GetAvailableLocalKey(stateCode); LocalDistricts.Insert(stateCode, localKey, s.Name, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, false); LocalIdsCodes.Insert(stateCode, LocalIdsCodes.LocalTypeCountySupervisors, s.Id, localKey); changed = true; } } else if (s.Delete) { // can only delete if no local district entry changed |= CountySupervisors.DeleteByStateCodeCountySupervisorsCode(stateCode, s.Id) != 0; } else { // existing item, but may update IsInShapefile or Name changed |= CountySupervisors.UpdateNameByStateCodeCountySupervisorsCode(s.Name, stateCode, s.Id) != 0; changed |= CountySupervisors.UpdateIsInShapefileByStateCodeCountySupervisorsCode( s.InShapefile, stateCode, s.Id) != 0; } } LoadControl(); return(changed); }
public static string GetSpreadsheetListHtml(bool all = false, int?id = null) { var table = all ? ElectionSpreadsheets.GetAllListData() : ElectionSpreadsheets.GetListDataByCompleted(false); if (table.Count == 0) { return("<div>No spreadsheets found</div>"); } // get a dictionary of election descriptions var dictionary = Elections.GetElectionDescriptions(table.Select(recordStates => recordStates.ElectionKey)); // append jurisdictions var mods = new List <KeyValuePair <string, string> >(); foreach (var kvp in dictionary) { if (!Elections.IsStateElection(kvp.Key)) { var stateCode = Elections.GetStateCodeFromKey(kvp.Key); var jurisdiction = Elections.IsCountyElection(kvp.Key) ? Counties.GetCounty(stateCode, Elections.GetCountyCodeFromKey(kvp.Key)) : LocalDistricts.GetLocalDistrict(stateCode, Elections.GetLocalKeyFromKey(kvp.Key)); mods.Add(new KeyValuePair <string, string>(kvp.Key, jurisdiction)); } } foreach (var kvp in mods) { dictionary[kvp.Key] += ", " + kvp.Value; } return(Join(Empty, table.OrderByDescending(r => r.UploadTime).Select(r => $"<div data-completed=\"{r.Completed.ToString().ToLower()}\"" + $" data-id=\"{r.Id}\" data-rows=\"{r.Rows}\"" + $"{(r.Id == id ? " class=\"selected\"" : Empty)}>" + $"{r.Filename} ({r.UploadTime:d}: {dictionary[r.ElectionKey]}" + $"{(r.ElectionScope == "A" ? " et. al." : Empty)}" + $"{(r.JurisdictionScope == "S" ? ", state level only" : Empty)})</div>"))); }
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBeProtected.Global // ReSharper disable UnusedMember.Global // ReSharper disable UnusedMethodReturnValue.Global // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnassignedField.Global #endregion ReSharper disable public static Control GetReport(ReportUser reportUser, string countyElectionKey) { var stateCode = Elections.GetStateCodeFromKey(countyElectionKey); var countyCode = Elections.GetCountyCodeFromKey(countyElectionKey); var stateElectionKey = Elections.GetStateElectionKeyFromKey(countyElectionKey); // We get a dictionary of locals with elections that match the stateElectionKey // Key: localCode; Value: local electionKey // Locals without an election will not be in the dictionary var localElectionDictionary = ElectionsOffices.GetLocalElections(stateElectionKey, countyCode); if (localElectionDictionary.Count == 0) { return(null); } // We also get a dictionary of all local names for the county var localNamesDictionary = LocalDistricts.GetNamesDictionary(stateCode, countyCode); // For reporting we filter only locals with elections, sort by name, // then reorder for vertical presentation var reorderedLocals = localNamesDictionary.Where( kvp => localElectionDictionary.ContainsKey(kvp.Key)) .OrderBy(kvp => kvp.Value) .ToList() .ReorderVertically(MaxCellsInRow); var htmlTable = CreateHtmlTableWithHeading(reportUser, false); HtmlTableRow tr = null; var cellsDisplayedInRow = MaxCellsInRow; // force new row foreach (var kvp in reorderedLocals) { var localCode = kvp.Key; var localName = kvp.Value; var localElectionKey = localElectionDictionary[localCode]; cellsDisplayedInRow = CreateOneAnchorCell(reportUser, htmlTable, ref tr, localName, localElectionKey, cellsDisplayedInRow); } return(htmlTable); }
protected override bool Update(object newValue) { switch (Page.AdminPageLevel) { case AdminPageLevel.State: States.UpdateColumn(StatesColumn, newValue, Page.StateCode); break; case AdminPageLevel.County: Counties.UpdateColumn(CountiesColumn, newValue, Page.StateCode, Page.CountyCode); break; case AdminPageLevel.Local: LocalDistricts.UpdateColumnByStateCodeLocalKey(LocalDistrictsColumn, newValue, Page.StateCode, Page.LocalKey); break; } return(true); }
private static void CheckForFatalCredentialingProblems(string usernameEntered) { switch (UserSecurityClass) { case MasterSecurityClass: // no additional info needed break; case StateAdminSecurityClass: if (!StateCache.IsValidStateCode(UserStateCode)) { HandleCredentialingInconsistency(usernameEntered, "Invalid StateCode"); } break; case CountyAdminSecurityClass: if (!Counties.StateCodeCountyCodeExists(UserStateCode, UserCountyCode)) { HandleCredentialingInconsistency(usernameEntered, "Invalid CountyCode"); } break; case LocalAdminSecurityClass: if (!LocalDistricts.StateCodeLocalKeyExists(UserStateCode, UserLocalKey)) { HandleCredentialingInconsistency(usernameEntered, "Invalid LocalKey"); } break; case PartySecurityClass: if (!Parties.PartyKeyExists(UserPartyKey)) { HandleCredentialingInconsistency(usernameEntered, "Invalid PartyKey"); } break; case PoliticianSecurityClass: // no additional info needed -- // they couldn't get this far without a valid politician key break; } }
private void DoDeletions(string address) { var found = false; found |= DeletionCount(States.UpdateEmailByEmail(Empty, address), address, "States.Email"); found |= DeletionCount(States.UpdateAltEmailByAltEmail(Empty, address), address, "States.AltEmail"); found |= DeletionCount(Counties.UpdateEmailByEmail(Empty, address), address, "Counties.Email"); found |= DeletionCount(Counties.UpdateAltEmailByAltEmail(Empty, address), address, "Counties.AltEmail"); found |= DeletionCount(LocalDistricts.UpdateEmailByEmail(Empty, address), address, "LocalDistricts.Email"); found |= DeletionCount(LocalDistricts.UpdateAltEmailByAltEmail(Empty, address), address, "LocalDistricts.AltEmail"); found |= DeletionCount(Politicians.UpdateEmailByEmail(null, address), address, "Politicians.Email"); found |= DeletionCount( Politicians.UpdateCampaignEmailByCampaignEmail(Empty, address), address, "Politicians.CampaignEmail"); found |= DeletionCount( Politicians.UpdateEmailVoteUSAByEmailVoteUSA(Empty, address), address, "Politicians.EmailVoteUSA"); found |= DeletionCount( Politicians.UpdateStateEmailByStateEmail(Empty, address), address, "Politicians.StateEmail"); if (Addresses.EmailExists(address)) { Addresses.DeleteByEmail(address); found |= DeletionCount(1, address, "Addresses"); } found |= DeletionCount(PartiesEmails.DeleteByPartyEmail(address), address, "PartiesEmails.PartyEmail"); found |= DeletionCount( OrganizationContacts.UpdateEmailByEmail(Empty, address), address, "OrganizationContacts.Email"); if (!found) { _Messages.Add($"<p class=\"error\">{address} not found</p>"); } }
private void BuildLocalsList(string stateCode, string countyCode, string singleLocal = null) { var locals = LocalDistricts.GetNamesDictionary(stateCode, countyCode); LocalsPickerList.Controls.Clear(); foreach (var local in locals.OrderBy(kvp => kvp.Value, new AlphanumericComparer())) { if (singleLocal == null || singleLocal == local.Key) { var p = new HtmlP().AddTo(LocalsPickerList, "sub-label"); p.Attributes["title"] = local.Value; new HtmlInputCheckBox { Value = local.Key, Checked = true }.AddTo(p); new HtmlSpan { InnerHtml = local.Value }.AddTo(p); } } }
private void PopulateLocalDropDown(bool includeSelectMessage = false) { bool hasLocals; if (includeSelectMessage) { hasLocals = LocalDistricts.Populate(LocalDropDownList, _SecureAdminPage.StateCode, _SecureAdminPage.CountyCode, "<select a local district>", Empty); } else { hasLocals = LocalDistricts.Populate(LocalDropDownList, _SecureAdminPage.StateCode, _SecureAdminPage.CountyCode, _SecureAdminPage.LocalKey); } if (!hasLocals) { LocalRadioButton.Disabled = true; LocalDropDownList.AddCssClasses("hidden"); LocalName.RemoveCssClass("hidden"); LocalName.InnerHtml = "no local districts available"; } }
protected override string GetCurrentValue() { switch (Page.AdminPageLevel) { case AdminPageLevel.State: return ((States.GetColumn(StatesColumn, Page.StateCode) ?? Empty).ToString()); case AdminPageLevel.County: return ((Counties.GetColumn(CountiesColumn, Page.StateCode, Page.CountyCode) ?? Empty).ToString()); case AdminPageLevel.Local: return ((LocalDistricts.GetColumnByStateCodeLocalKey(LocalDistrictsColumn, Page.StateCode, Page.LocalKey) ?? Empty).ToString()); default: return(null); } }
private IList <string> GetDistrictList(string proposedName, out bool hasDuplicates) { // break test string into non-generic words var nameWords = proposedName.SafeString() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Where(w => !GenericDistrictWords.Contains(w, StringComparer.OrdinalIgnoreCase)); // format a district list with potential conflicts highlighted in <em> tags var thereWereDuplicates = false; var comparer = new AlphanumericComparer(); var districtList = LocalDistricts.GetLocalsForCounty(StateCode, CountyCode) .Rows.Cast <DataRow>() .OrderBy(r => r.LocalDistrict(), comparer) .Select(r => // Use Format so line breaks can be inserted for readability // ReSharper disable once UseStringInterpolation Format("{0} ({1})", // Format parameter 0: // the district name, with any matching, non-generic words in <em> tags Join(" ", r.LocalDistrict() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Select(w => { if (!nameWords.Contains(w, StringComparer.OrdinalIgnoreCase)) { return(w); } thereWereDuplicates = true; return($"<em>{w}</em>"); })), r.LocalKey())).ToList(); hasDuplicates = thereWereDuplicates; return(districtList.Count == 0 ? null : districtList); }