private void FillInStateLink() { new HtmlAnchor { InnerText = $"Go to {StateCache.GetStateName(_StateCode)} State Election", HRef = UrlManager.GetElectionPageUri(Elections.GetStateElectionKeyFromKey(_ElectionKey)).ToString() }.AddTo(HigherLevelLinks, "state-link"); }
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 void ApplyToResult(AddressFinderResult result) { result.Congress = Congress; result.StateSenate = StateSenate; result.StateHouse = StateHouse; result.County = County; result.State = StateCode; var votersUrl = MakeSetCookiesUrl( UrlManager.GetForVotersPageUri(StateCode), result.OriginalInput, result.Remember); result.RedirectUrl = votersUrl; result.SuccessMessage = "Redirecting to the " + StateCache.GetStateName(StateCode) + " 'for Voters' page"; //string electedOfficialsUrl = MakeSetCookiesUrl( // UrlManager.GetElectedPageUri( // StateCode, Congress, StateSenate, StateHouse, County)); //ElectionsTable futureElectionsTable = // Elections.GetFutureViewableDisplayDataByStateCode(StateCode); //if (futureElectionsTable.Count == 0) //{ // result.RedirectUrl = electedOfficialsUrl; // result.SuccessMessage = "Redirecting to your elected officials page"; //} //else //{ // //redirectUri = UrlManager.GetBallotPageUri(StateCode, // // Congress, StateSenate, StateHouse, County); // HtmlGenericControl span = new HtmlSpan(); // span.Attributes["class"] = "selectOne"; // span.Controls.Add(new LiteralControl("Select ")); // HtmlAnchor a = new HtmlAnchor(); // span.Controls.Add(a); // a.HRef = electedOfficialsUrl; // a.InnerText = "Current elected officials"; // a.Title = a.InnerText; // span.Controls.Add(new LiteralControl(" or sample ballot for:")); // foreach (var row in futureElectionsTable) // { // span.Controls.Add(new LiteralControl("<br />")); // a = new HtmlAnchor(); // span.Controls.Add(a); // Uri uri = UrlManager.GetBallotPageUri(row.ElectionKey, // Congress, StateSenate, StateHouse, County); // a.HRef = MakeSetCookiesUrl(uri); // a.InnerText = row.ElectionDesc; // a.Title = a.InnerText; // } // result.SuccessMessage = db.RenderToString(span); //} }
public static void AddStateLinksToDiv(HtmlGenericControl div, string stateCode, bool includeCurrentOfficials, bool includeFutureElections) { if (includeCurrentOfficials) { var linkInfo = new LinkInfo { Description = StateCache.GetStateName(stateCode) + " Current Elected Officials", HRef = UrlManager.GetOfficialsPageUri(stateCode) }; AddLinksToLinkBox(div, new List <LinkInfo> { linkInfo }); } AddLinksToLinkBox(div, GetStateLinks(stateCode, includeFutureElections)); }
private static void AddUpcomingLinksToDiv(Control div, string stateCode) { var links = GetUpcomingLinks(stateCode); if (links.Count > 0) { ForResearchPage.AddLinksToLinkBox(div, links); } else { var p = new HtmlP().AddTo(div); var message = $"No {StateCache.GetStateName(stateCode)} upcoming election reports are available. " + "Please check back later."; new LiteralControl(message).AddTo(p); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var stateName = PublicMasterPage.StateName + " "; if (stateName == "US ") { stateName = Empty; } Title = Format(TitleTag, PublicMasterPage.SiteName); MetaDescription = Format(MetaDescriptionTag, stateName); } string selectedState = null; string firstEntry = null; if (DomainData.IsValidStateCode) // Single state { selectedState = DomainData.FromQueryStringOrDomain; AddStateLinksToDiv(StateLinkEntries, selectedState, true, true); StateName.InnerText = StateCache.GetStateName(selectedState); } else { firstEntry = "<select state>"; new HtmlP { InnerText = "No state selected" }.AddTo(StateLinkEntries); StateName.InnerText = "<no state selected>"; } StateCache.Populate(StateElectionDropDown, firstEntry, "XX", selectedState); GetLinkBox(PresidentLinks, "US President and Vice-President", GetPresidentLinks()); GetLinkBox(SenateLinks, "US Senate", GetSenateLinks()); GetLinkBox(HouseLinks, "US House of Representatives", GetHouseLinks()); GetLinkBox(GovernorLinks, "State Governors and Lieutenant Governors", GetGovernorLinks()); }
public static string FormatLegislativeDistrictsFromQueryString( string separator = "<br />") { var lines = new List <string>(); if (QueryState != "DC") { if (QueryCongress != "000") { lines.Add("US House District " + QueryCongress.TrimStart('0') + " " + StateCache.GetStateName(QueryState)); } if (QueryStateSenate != "000") { lines.Add(StateCache.GetStateName(QueryState) + " Senate District " + QueryStateSenate.TrimStart('0')); } if (QueryStateHouse != "000") { lines.Add(StateCache.GetStateName(QueryState) + " House District " + QueryStateHouse.TrimStart('0')); } if (QueryCounty != string.Empty) { lines.Add(CountyCache.GetCountyName(QueryState, QueryCounty)); } } else if (QueryStateSenate != "000") { lines.Add("Ward " + QueryStateSenate.TrimStart('0')); } if (separator == null) { return("<span>" + string.Join("</span><span>", lines) + "</span>"); } return(string.Join(separator, lines)); }
private void CreateReport() { ReferendumTitle.InnerHtml = _Referendum.ReferendumTitle.ReplaceNewLinesWithParagraphs(); ReferendumSubTitle.InnerHtml = StateCache.GetStateName(Referendums.GetStateCodeFromKey(_ReferendumKey)) + " Ballot Measure / Referendum"; ReferendumSubTitle.Visible = false; // Link removed per Mantis 840 //new HtmlAnchor //{ // HRef = UrlManager.GetElectionPageUri(_ElectionKey).ToString(), // InnerText = _ElectionDescription //}.AddTo(ReferendumElection); ReferendumElection.InnerText = _ElectionDescription; var referendumDescription = _Referendum.ReferendumDescription; if (IsNullOrWhiteSpace(referendumDescription)) { ReferendumDescriptionLabel.Visible = false; ReferendumDescription.Visible = false; } else { ReferendumDescriptionLabel.InnerHtml = "Description:"; ReferendumDescription.InnerHtml = referendumDescription.ReplaceNewLinesWithParagraphs(); } var detail = _Referendum.ReferendumDetail; var detailUrl = _Referendum.ReferendumDetailUrl; if (IsNullOrWhiteSpace(detailUrl) && IsNullOrWhiteSpace(detail)) { ReferendumDetailLabel.Visible = false; ReferendumDetail.Visible = false; } else if (IsNullOrWhiteSpace(detail)) { ReferendumDetailLabel.InnerHtml = CreateAnchor(detailUrl, "Link to Detail", "no-print") .RenderToString(); ReferendumDetail.Visible = false; } else { ReferendumDetailLabel.InnerHtml = $"Detail {CreateAnchor(detailUrl, "(link to detail)", "parenthetical no-print").RenderToString()}"; ReferendumDetail.InnerHtml = detail.ReplaceNewLinesWithParagraphs(); } var fullText = _Referendum.ReferendumFullText; var fullTextUrl = _Referendum.ReferendumFullTextUrl; if (IsNullOrWhiteSpace(fullTextUrl) && IsNullOrWhiteSpace(fullText)) { ReferendumFullTextLabel.Visible = false; ReferendumFullText.Visible = false; } else if (IsNullOrWhiteSpace(fullText)) { ReferendumFullTextLabel.InnerHtml = CreateAnchor(fullTextUrl, "Link to Full Text", "no-print") .RenderToString(); ReferendumFullText.Visible = false; } else { ReferendumFullTextLabel.InnerHtml = $"Full Text {CreateAnchor(fullTextUrl, "(link to full text)").RenderToString()}"; ReferendumFullText.InnerHtml = fullText.ReplaceNewLinesWithParagraphs(); } }
public static string CreateOfficeKey(int officeClass, string stateCode, string countyCode, string localCode, string districtCode, string districtCodeAlpha, string officeLine1, string officeLine2) { //CountyCode - 3 digits //LocalCode - 2 digits //DistrictCode - 3 digits //DistrictCodeAlpha - 1-4 alpha chars //string theOffice = ( // OfficeLine1 + OfficeLine2).Trim(); //theOffice = db.Str_Remove_Puctuation(theOffice); officeLine1 = Str_ReCase(Str_Replace_Puctuation_With(officeLine1, " ")).Trim(); officeLine2 = Str_ReCase(Str_Replace_Puctuation_With(officeLine2, " ")).Trim(); var theOffice = officeLine1 + officeLine2; theOffice = Str_Remove_Puctuation(theOffice); if (theOffice != string.Empty) { var stateNameUpper = StateCache.GetStateName(stateCode).ToUpper(); var stateNamePos = theOffice.ToUpper().IndexOf(stateNameUpper, 0, theOffice.Length, StringComparison.Ordinal); if (stateNamePos >= 0) //State is in the Office Name - remove it { var stateNameLen = stateNameUpper.Length; theOffice = theOffice.Remove(stateNamePos, stateNameLen); } } string districtCodeWithout0S; if (Is_Valid_Integer(districtCode)) { var districtInt = Convert.ToInt32(districtCode); districtCodeWithout0S = districtInt.ToString(CultureInfo.InvariantCulture); } else { districtCodeWithout0S = districtCode.Trim(); } var theOfficeKey = string.Empty; theOffice = Str_Remove_Non_Key_Chars(theOffice); switch (officeClass.ToOfficeClass()) { case OfficeClass.USPresident: theOfficeKey = stateCode.ToUpper(); theOfficeKey += "President"; break; case OfficeClass.USSenate: theOfficeKey = stateCode.ToUpper() + "USSenate" + officeLine2; break; case OfficeClass.USHouse: theOfficeKey = stateCode.ToUpper() + "USHouse" + districtCodeWithout0S; break; case OfficeClass.StateWide: case OfficeClass.StateJudicial: case OfficeClass.StateParty: theOfficeKey = stateCode.ToUpper() + theOffice; break; case OfficeClass.StateSenate: theOfficeKey = stateCode.ToUpper() + "StateSenate" + districtCodeWithout0S + districtCodeAlpha.Trim(); break; case OfficeClass.StateHouse: theOfficeKey = stateCode.ToUpper() + "StateHouse" + districtCodeWithout0S + districtCodeAlpha.Trim(); break; case OfficeClass.StateDistrictMultiCounties: case OfficeClass.StateDistrictMultiCountiesJudicial: case OfficeClass.StateDistrictMultiCountiesParty: theOfficeKey = stateCode.ToUpper() + districtCode + districtCodeAlpha.Trim() + theOffice; break; case OfficeClass.CountyExecutive: case OfficeClass.CountyLegislative: case OfficeClass.CountySchoolBoard: case OfficeClass.CountyCommission: case OfficeClass.CountyJudicial: case OfficeClass.CountyParty: theOfficeKey = stateCode.ToUpper() + countyCode + theOffice; break; case OfficeClass.LocalExecutive: case OfficeClass.LocalLegislative: case OfficeClass.LocalSchoolBoard: case OfficeClass.LocalCommission: case OfficeClass.LocalParty: case OfficeClass.LocalJudicial: theOfficeKey = stateCode.ToUpper() + countyCode + localCode + theOffice; break; } if (theOfficeKey.Length > 150) { theOfficeKey = theOfficeKey.Substring(0, 150); } return(theOfficeKey); }
public static string FormatLegislativeDistrictsFromQueryString( string separator = "<br />") { var lines = new List <string>(); if (QueryState != "DC") { string county = null; if (!IsNullOrWhiteSpace(QueryCounty)) { lines.Add(county = CountyCache.GetCountyName(QueryState, QueryCounty)); } if (!IsNullOrWhiteSpace(QueryCountySupervisors)) { lines.Add(CountySupervisors.GetNameByStateCodeCountySupervisorsCode(QueryState, QueryCountySupervisors)); } string tigerCode; if (QueryCongress != "000") { var congressionalDistrict = QueryCongress; if (congressionalDistrict.Length == 3) { congressionalDistrict = congressionalDistrict.Substring(1); } if ((tigerCode = TigerToVoteCodes.GetTigerCodeByTableTypeStateCodeVoteCode("CD", QueryState, congressionalDistrict)) != null) { congressionalDistrict = tigerCode; } if (congressionalDistrict != "00") { lines.Add("US House District " + congressionalDistrict.TrimStart('0') + " " + StateCache.GetStateName(QueryState)); } } if (QueryStateSenate != "000") { var stateSenateDistrict = QueryStateSenate; if ((tigerCode = TigerToVoteCodes.GetTigerCodeByTableTypeStateCodeVoteCode("SS", QueryState, stateSenateDistrict)) != null) { stateSenateDistrict = tigerCode; } lines.Add(StateCache.GetStateName(QueryState) + " Senate District " + stateSenateDistrict.TrimStart('0')); } if (!IsNullOrWhiteSpace(QueryStateHouse)) { var stateHouseDistrict = QueryStateHouse; if ((tigerCode = TigerToVoteCodes.GetTigerCodeByTableTypeStateCodeVoteCode("SH", QueryState, stateHouseDistrict)) != null) { stateHouseDistrict = tigerCode; } lines.Add(StateCache.GetStateName(QueryState) + " House District " + stateHouseDistrict.TrimStart('0')); } string district = null; string lastResort = null; if (QueryDistrict != Empty) { district = TigerPlaces.GetLongNameByStateCodeTigerCode(QueryState, QueryDistrict); if (!IsNullOrWhiteSpace(district) && district.IsNeIgnoreCase(county)) { if (district.EndsWith(" CCD") || district.EndsWith(" CDP")) { lastResort = district.Substring(0, district.Length - 4); } else { lines.Add(district); } } } if (QueryPlace != Empty) { var place = TigerPlaces.GetLongNameByStateCodeTigerCode(QueryState, QueryPlace); if (!IsNullOrWhiteSpace(place) && place.IsNeIgnoreCase(district) && place.IsNeIgnoreCase(county)) { if (place.EndsWith(" CCD") || place.EndsWith(" CDP")) { lastResort = place.Substring(0, place.Length - 4); } else { lines.Add(place); lastResort = null; } } } if (lastResort != null && (county == null || !county.StartsWith(lastResort, StringComparison.OrdinalIgnoreCase))) { lines.Add(lastResort); } if (!IsNullOrWhiteSpace(QueryCityCouncil)) { lines.Add( CityCouncil.GetNameByStateCodeCityCouncilCode(QueryState, QueryCityCouncil)); } } else if (QueryStateSenate != "000") { if (!IsNullOrWhiteSpace(QueryStateSenate)) { lines.Add("Ward " + QueryStateSenate.TrimStart('0')); } if (!IsNullOrWhiteSpace(QueryCountySupervisors)) { lines.Add( CountySupervisors.GetNameByStateCodeCountySupervisorsCode(QueryState, QueryCountySupervisors)); } } if (!IsNullOrWhiteSpace(QueryElementary)) { lines.Add( TigerSchools.GetNameByStateCodeTigerCodeTigerType(QueryState, QueryElementary, "E")); } if (!IsNullOrWhiteSpace(QuerySecondary)) { lines.Add( TigerSchools.GetNameByStateCodeTigerCodeTigerType(QueryState, QuerySecondary, "S")); } if (!IsNullOrWhiteSpace(QueryUnified)) { lines.Add( TigerSchools.GetNameByStateCodeTigerCodeTigerType(QueryState, QueryUnified, "U")); } if (!IsNullOrWhiteSpace(QuerySchoolDistrictDistrict)) { lines.Add( SchoolDistrictDistricts.GetNameByStateCodeSchoolDistrictDistrictCode( QueryState, QuerySchoolDistrictDistrict)); } if (separator == null) { return("<span>" + Join("</span><span>", lines) + "</span>"); } return(Join(separator, lines)); }