protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // Make sure this reflects changes InvalidatePageCache(); var heading = PageCache.Politicians.GetPoliticianName(PoliticianKey); if (heading != H1.InnerHtml) { H1.InnerHtml = heading; UpdatePanelHeading.Update(); } // This isn't available at Page_Load time if (PageCachingSubHeadingWithHelp.FindTemplateControl("ViewIntroLink") is HtmlAnchor viewIntroLink) { viewIntroLink.HRef = IntroPageUrl; } if (PageCachingSubHeadingWithHelp.FindTemplateControl("CacheExpirationMsg") is HtmlGenericControl cacheExpirationMsg) { cacheExpirationMsg.InnerText = CachePages.DisplayExpiration(MemCache.CacheExpiration); } // We handle post-update processing here so we only have to do it once per postback, // not on each field. if (_UpdateCount <= 0) { return; } Politicians.IncrementDataUpdatedCount(PoliticianKey); }
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 static void PopulateIncumbentsToReinstateList( IEnumerable <IGrouping <string, DataRow> > incumbentsToReinstate, Control parent) { parent.Controls.Clear(); var container = new HtmlDiv().AddTo(parent, "offices"); foreach (var incumbents in incumbentsToReinstate) { var office = incumbents.First(); var div = new HtmlDiv().AddTo(container, "office"); div.Attributes.Add("rel", office.OfficeKey()); new HtmlP { InnerHtml = Offices.FormatOfficeName(office) } .AddTo(div, "office-name"); foreach (var incumbent in incumbents) { var p = new HtmlP().AddTo(div); new HtmlInputCheckBox { Checked = false, Value = incumbent.PoliticianKey() }.AddTo(p, "incumbent"); new LiteralControl(Politicians.FormatName(incumbent)).AddTo(p); } } }
public void UpdateVoteUsaCandidate(string politicianKey, string family, string education, string professional, string military, string civic, string political, string religion, string accomplishments, string birthdate, string email, string website, string facebook, string twitter, string youtube) { DateTime dateOfBirth; if (!DateTime.TryParse(birthdate, out dateOfBirth)) { dateOfBirth = Politicians.GetDateOfBirth(politicianKey, VotePage.DefaultDbDate).Date; } //Politicians.UpdatePersonal(family, politicianKey); //Politicians.UpdateEducation(education, politicianKey); //Politicians.UpdateProfession(professional, politicianKey); //Politicians.UpdateMilitary(military, politicianKey); //Politicians.UpdateCivic(civic, politicianKey); //Politicians.UpdatePolitical(political, politicianKey); //Politicians.UpdateReligion(religion, politicianKey); //Politicians.UpdateAccomplishments(accomplishments, politicianKey); Politicians.UpdateDateOfBirth(dateOfBirth, politicianKey); Politicians.UpdatePublicEmail(Validation.StripWebProtocol(email), politicianKey); Politicians.UpdateWebAddress(Validation.StripWebProtocol(website), politicianKey); Politicians.UpdateFacebookWebAddress(Validation.StripWebProtocol(facebook), politicianKey); Politicians.UpdateTwitterWebAddress(Validation.StripWebProtocol(twitter), politicianKey); Politicians.UpdateYouTubeWebAddress(Validation.StripWebProtocol(youtube), politicianKey); }
private void FillCandidateRecord(IDictionary record, DataRow row, IList <DataRow> issues) { AddField(record, "politicianKey", row.PoliticianKey()); AddField(record, "name", Politicians.FormatName(row)); AddField(record, "address", row.PublicAddress()); AddField(record, "cityStateZip", row.PublicCityStateZip()); AddField(record, "phone", row.PublicPhone()); AddField(record, "dateOfBirth", FormatDate(row.DateOfBirth())); AddField(record, "partyName", row.PartyName()); AddField(record, "email", row.PublicEmail()); AddField(record, "webAddress", row.PublicWebAddress()); if (_Bio) { AddSpecialIssue(record, row, issues, "ALLBio", "bio"); } if (_Reasons) { AddSpecialIssue(record, row, issues, "ALLPersonal", "reasons"); } if (_Issues) { AddIssues(record, row, issues); } if (!row.IsRunningMate()) { AddField(record, "isIncumbent", row.IsIncumbent()); AddField(record, "isWinner", row.IsWinner()); } }
private void LoadContactTabData() { LoadPartiesDropdown(Politicians.GetStateCodeFromKey(PoliticianKey), ControlContactPartyKey, string.Empty, PartyCategories.None, PartyCategories.StateParties, PartyCategories.NationalParties, PartyCategories.NonParties); foreach (var item in _ContactTabInfo) { item.LoadControl(); } if (IsSuperUser) { BallotNameInfo.Visible = false; } else { ControlContactFName.Enabled = false; ControlContactMName.Enabled = false; ControlContactNickname.Enabled = false; ControlContactLName.Enabled = false; ControlContactSuffix.Enabled = false; } }
protected void Page_Load(object sender, EventArgs e) { _PoliticianInfo = Politicians.GetPoliticianIntroReportData(_PoliticianKey); if (_PoliticianInfo == null) { InnerContent.Controls.Clear(); var p = new HtmlP().AddTo(InnerContent, "not-found-error"); new LiteralControl($"Could not find Id {_PoliticianKey}").AddTo(p); return; } _PoliticianName = Politicians.FormatName(_PoliticianInfo); _OfficeAndStatus = Politicians.FormatOfficeAndStatus(_PoliticianInfo); Title = Format(TitleTag, GetCandidateInfo(" | "), PublicMasterPage.SiteName); MetaDescription = Format(MetaDescriptionTag, GetCandidateInfo(", "), PublicMasterPage.SiteName); //MetaKeywords = _PoliticianName; PageHeading.MainHeadingText = Format(PageHeading.MainHeadingText, _PoliticianName); PoliticianInfoResponsive.GetReport(_PoliticianInfo).AddTo(InfoPlaceHolder); IntroIssuesReport.GetReport(_PoliticianInfo).AddTo(ReportPlaceHolder); }
protected void Page_Load(object sender, EventArgs e) { _UpdateCount = 0; if (UserSecurityClass == PoliticianSecurityClass) { PodcastEntry.AddCssClasses("hidden"); } if (!IsPostBack) { var title = PoliticianName + " - Update Intro"; Page.Title = title; H2.InnerHtml = OfficeAndStatus; ShowIntroLink.Attributes["href"] = IntroPageUrl; //UpdateIssuesLink.Attributes["href"] = UpdateIssuesPageUrl; //ShowPoliticianIssueLink.Attributes["href"] = PoliticianIssuePageUrl; // Set temp nocache SetNoCacheForState(); // mark if birthday is needed (politician access only) if (UserSecurityClass == PoliticianSecurityClass && string.IsNullOrWhiteSpace(Politicians.GetDateOfBirthAsString(PoliticianKey))) { Master.FindControl("Body").AddCssClasses("need-dob"); } } }
public static Control GetVideoContent(string politicianKey) { var politician = Politicians.GetPoliticianIntroReportData(politicianKey); var reportObject = new IntroIssuesReport(); return(reportObject.GenerateVideoContent(politician)); }
private static int MoveVideoToAnswers(PoliticiansRow politician, int count, ref int duplicate) { var youTubeId = politician.YouTubeWebAddress.GetYouTubeVideoId(); VideoInfo videoInfo = null; if (!IsNullOrWhiteSpace(youTubeId)) { videoInfo = YouTubeVideoUtility.GetVideoInfo(youTubeId, false, 1); } if (videoInfo != null && videoInfo.IsValid) { count++; // get Why I'm Running answers var answers = Answers.GetDataByPoliticianKeyQuestionKey(politician.PoliticianKey, QuestionKey); if (answers.All(row => row.YouTubeUrl.GetYouTubeVideoId() != youTubeId)) { // doesn't exist -- add to first without a YouTubeUrl var rowToUpdate = answers.FirstOrDefault(row => IsNullOrWhiteSpace(row.YouTubeUrl)); if (rowToUpdate == null) { // new to add a row { rowToUpdate = answers.NewRow(politician.PoliticianKey, QuestionKey, Answers.GetNextSequence(politician.PoliticianKey, QuestionKey), Politicians.GetStateCodeFromKey(politician.PoliticianKey), IssueKey, Empty, Empty, VotePage.DefaultDbDate, "curt", Empty, Empty, default, Empty, Empty,
protected static HtmlAnchor CreatePoliticianIntroAnchor(DataRow politician, string anchorText = "", string title = "", string target = "_self") { var politicianName = Politicians.FormatName(politician, true); if (IsNullOrEmpty(anchorText)) { anchorText = politicianName; } if (IsNullOrEmpty(title)) { title = politicianName + "'s biographical information and positions and views on the issues"; } return(new HtmlAnchor { HRef = UrlManager.GetIntroPageUri(politician.PoliticianKey()) .ToString(), Title = title, Target = target, InnerHtml = anchorText }); }
private void UpdateAll(FeedbackContainerControl feedback) { try { var errorCount = 0; var oldEmail = Politicians.GetPublicEmail(PoliticianKey); foreach (var updateAll in _UpdateAllList) { errorCount += updateAll(false); } var newEmail = Politicians.GetPublicEmail(PoliticianKey); if (oldEmail != newEmail) { LoadContactTabData(); UpdatePanelContact.Update(); LoadSocialMediaTabData(); UpdatePanelSocial.Update(); } feedback.AddInfo(_UpdateCount.ToString(CultureInfo.InvariantCulture) + _UpdateCount.Plural(" item was", " items were") + " updated."); if (errorCount > 0) { feedback.AddError(errorCount.ToString(CultureInfo.InvariantCulture) + errorCount.Plural(" item was", " items were") + " not updated due to errors."); } } catch (Exception ex) { feedback.HandleException(ex); } }
protected static string Subsitutions_Politician_Find(string politicianKey, string strToApplySubsitutions) { var newStr = strToApplySubsitutions; newStr = Regex.Replace(newStr, @"\[\[USERNAME\]\]", Politicians_Str(politicianKey, "PoliticianKey"), RegexOptions.IgnoreCase); newStr = Regex.Replace(newStr, @"\[\[PASSWORD\]\]", Politicians_Str(politicianKey, "Password"), RegexOptions.IgnoreCase); var stateCode = Politicians.GetStateCodeFromKey(politicianKey).ToUpper(); newStr = Regex.Replace(newStr, @"\[\[STATE\]\]", StateCache.GetStateName(stateCode), RegexOptions.IgnoreCase); newStr = Regex.Replace(newStr, @"\[\[VOTEXXANCHOR\]\]" //, db.Anchor(@"http://Vote-" + StateCode + ".org/") , Anchor(UrlManager.GetDefaultPageUri(stateCode)), RegexOptions.IgnoreCase); newStr = Regex.Replace(newStr, @"\[\[MGREMAIL\]\]", Anchor_Mailto_Email("*****@*****.**"), RegexOptions.IgnoreCase); newStr = Regex.Replace(newStr, @"\[\[INTROANCHOR\]\]" //, db.Anchor(@"http://Vote-" + StateCode + ".org/Intro.aspx?Id=" + db.Politicians_Str(PoliticianKey, "PoliticianKey")) , Anchor(UrlManager.GetIntroPageUri(politicianKey)), RegexOptions.IgnoreCase); newStr = Regex.Replace(newStr, @"\[\[POLITICIANENTRY\]\]" //, db.Anchor(@"http://Vote-" + StateCode + ".org/Politician") , Anchor(UrlManager.GetStateUri(stateCode) + "Politician"), RegexOptions.IgnoreCase); return(newStr); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Master.NoMenu = true; Page.Title = PoliticianName; var liveOfficeKey = Politicians.GetLiveOfficeKey(PoliticianKey, Empty); var isPresidentialCandidate = String.Equals(liveOfficeKey, Offices.USPresident, StringComparison.OrdinalIgnoreCase); H1.InnerHtml = PoliticianName; H2.InnerHtml = OfficeAndStatus; if (!isPresidentialCandidate) { H3.InnerHtml = Elections.GetElectionDesc(liveOfficeKey); } MainImage.ImageUrl = NoCacheImageProfile200Url; UpdateIntroLink.Attributes["href"] = UpdateIntroPageUrl; ShowIntroLink.Attributes["href"] = IntroPageUrl; UpdateIssuesLink.Attributes["href"] = UpdateInfoPageUrl; var liveElectionKey = Politicians.GetLiveElectionKey(PoliticianKey, Empty); if (IsNullOrWhiteSpace(liveOfficeKey) || isPresidentialCandidate) { CompareLink.Visible = false; } else { ShowCompareLink.HRef = UrlManager .GetCompareCandidatesPageUri(liveElectionKey, liveOfficeKey).ToString(); } } }
private void GetPoliticianForSingleOption() { var politicianKey = TextBoxPoliticianKey.Text.Trim(); if (string.IsNullOrWhiteSpace(politicianKey)) { throw new VoteUIException("A Politician Key is required."); } if (!Politicians.PoliticianKeyExists(politicianKey)) { throw new VoteUIException(politicianKey + " is not a valid PoliticianKey."); } var item = PoliticianImagesInfo.GetHeadshotDataForPolitician(politicianKey); LabelRows.Text = (item == null ? 0 : 1).ToString(CultureInfo.InvariantCulture); if (item == null) { throw new VoteUIException("Politician for PoliticianKey not found."); } SetLabelsFromItem(item); TextBoxPoliticianKey.Text = string.Empty; // only clear if valid }
public static Control GetOneAnswerContent(string politicianKey, string questionKey) { var politician = Politicians.GetPoliticianIntroReportData(politicianKey); var reportObject = new IntroIssuesReport(); return(reportObject.GenerateOneAnswerContent(politician, questionKey)); }
protected Control FormatCandidate(DataRow candidate, bool showIncumbent, bool showParty) { var placeHolder = new PlaceHolder(); new LiteralControl(Politicians.FormatName(candidate, true)).AddTo(placeHolder); if (showIncumbent && candidate.IsIncumbent()) { new LiteralControl(" *").AddTo( new HtmlSpan().AddTo(placeHolder, "incumbent")); } if (!showParty || string.IsNullOrWhiteSpace(candidate.PartyCode())) { return(placeHolder); } var span = new HtmlSpan().AddTo(placeHolder, "party"); new Literal { Text = " - " }.AddTo(span); FormatPartyAnchor(candidate) .AddTo(span); return(placeHolder); }
private Control GenerateOneCandidateVideoContent(string electionKey, string officeKey, string politicianKey) { var container = new PlaceHolder(); _IssuesDataManager.GetCandidateVideoData(electionKey, officeKey, politicianKey); // for older elections show all responese var electionDate = Elections.GetElectionDateFromKey(electionKey); var oldAnswerCutoff = electionDate > DateTime.UtcNow.AddMonths(-6) ? ElectionsOffices.GetOldAnswerCutoffDate(electionKey, officeKey) : DateTime.MinValue; var issuesData = _IssuesDataManager.GetDataSubset() .Where(r => r.YouTubeDate() >= oldAnswerCutoff); //var isRunningMateOffice = Offices.GetIsRunningMateOffice(officeKey, false) && // !Elections.IsPrimaryElection(electionKey); var isRunningMateOffice = Offices.IsRunningMateOfficeInElection(electionKey, officeKey); var politician = Politicians.GetPoliticianIntroReportData(politicianKey); DataRow runningMate = null; var name = Politicians.FormatName(politician); string runningMateKey = null; string runningMateName = null; if (isRunningMateOffice) { //var cache = PageCache.GetTemporary(); //name = cache.Politicians.GetPoliticianName(politicianKey); runningMateKey = ElectionsPoliticians .GetRunningMateKeyByElectionKeyOfficeKeyPoliticianKey( electionKey, officeKey, politicianKey); runningMate = Politicians.GetPoliticianIntroReportData(runningMateKey); //runningMateName = cache.Politicians.GetPoliticianName(runningMateKey); runningMateName = Politicians.FormatName(runningMate); } var videos = issuesData .Where(r => r.PoliticianKey().IsEqIgnoreCase(politicianKey)).ToList(); var qas = GetQuestionAndAnswerList(videos, politician, true, true); if (qas.Any()) { ReportCandidateVideos(container, politician, qas, name, isRunningMateOffice); } if (!IsNullOrWhiteSpace(runningMateKey)) { var runningMateVideos = issuesData .Where(r => r.PoliticianKey().IsNeIgnoreCase(politicianKey)).ToList(); qas = GetQuestionAndAnswerList(runningMateVideos, runningMate, true, true); if (qas.Any()) { ReportCandidateVideos(container, runningMate, qas, runningMateName, true); } } return(container); }
public void UpdatePoliticianAnswer(string questionKey, int sequence, string issueKey, string newValue, string source, DateTime dateStamp, string youTubeUrl, string youTubeDescription, TimeSpan youTubeRunningTime, string youTubeSource, string youTubeSourceUrl, DateTime youTubeDate, string facebookVideoUrl, string facebookVideoDescription, TimeSpan facebookVideoRunningTime, DateTime facebookVideoDate) { if (IsNullOrWhiteSpace(newValue) && IsNullOrWhiteSpace(youTubeUrl) && IsNullOrWhiteSpace(facebookVideoUrl)) { // Just delete and be done with it Answers.DeleteByPoliticianKeyQuestionKeySequence(PoliticianKey, questionKey, sequence); } else { var table = Answers.GetDataByPoliticianKeyQuestionKeySequence(PoliticianKey, questionKey, sequence); AnswersRow row; if (table.Count == 0) { row = table.NewRow(); row.Sequence = sequence; } else { row = table[0]; } row.PoliticianKey = PoliticianKey; row.QuestionKey = questionKey; row.StateCode = Politicians.GetStateCodeFromKey(PoliticianKey); row.IssueKey = issueKey; row.Answer = newValue; row.Source = source; row.DateStamp = dateStamp; row.UserName = UserName; row.YouTubeUrl = youTubeUrl; row.YouTubeDescription = youTubeDescription; row.YouTubeRunningTime = youTubeRunningTime; row.YouTubeSource = youTubeSource; row.YouTubeSourceUrl = youTubeSourceUrl; row.YouTubeDate = youTubeDate; row.YouTubeRefreshTime = IsNullOrWhiteSpace(youTubeUrl) ? DefaultDbDate : DateTime.UtcNow; row.YouTubeAutoDisable = null; row.FacebookVideoUrl = facebookVideoUrl; row.FacebookVideoDescription = facebookVideoDescription; row.FacebookVideoRunningTime = facebookVideoRunningTime; row.FacebookVideoDate = facebookVideoDate; row.FacebookVideoRefreshTime = IsNullOrWhiteSpace(facebookVideoUrl) ? DefaultDbDate : DateTime.UtcNow; row.FacebookVideoAutoDisable = null; if (table.Count == 0) { table.AddRow(row); } Answers.UpdateTable(table); } }
public bool GetUserSecurityIsOk() { var ok = IsSuperUser || ((UserSecurityClass == MasterSecurityClass) && !IsSuperUserPage); if (!ok) { switch (PageSecurityClass) { case StateAdminSecurityClass: switch (UserSecurityClass) { case StateAdminSecurityClass: ok = ViewStateStateCode == UserStateCode; break; case CountyAdminSecurityClass: ok = (ViewStateStateCode == UserStateCode) && (ViewStateCountyCode == UserCountyCode); break; case LocalAdminSecurityClass: ok = (ViewStateStateCode == UserStateCode) && (ViewStateCountyCode == UserCountyCode) && (ViewStateLocalCode == UserLocalCode); break; } break; case PartySecurityClass: ok = IsPartyUser && (ViewStatePartyKey == UserPartyKey); break; case PoliticianSecurityClass: ok = ViewStatePoliticianKey == UserPoliticianKey; // allow access to the party's politician pages if (!ok && IsPartyUser) { var partyKey = Politicians.GetPartyKey(ViewStatePoliticianKey); if (!string.IsNullOrWhiteSpace(partyKey)) { ok = partyKey.IsEqIgnoreCase(UserPartyKey); } } break; case DesignSecurityClass: ok = IsDesignUser && (ViewStateDesignCode == UserDesignCode); break; case OrganizationSecurityClass: ok = IsOrganizationUser && (ViewStateOrganizationCode == UserOrganizationCode); break; } } return(ok); }
protected void ReportPolitician(DataRow politician, bool isWinner, bool isIncumbent) { var politicianKey = politician.PoliticianKey(); var politicianName = Politicians.FormatName(politician); Control anchorHeadshot = null; switch (ReportUser) { case ReportUser.Public: { anchorHeadshot = CreatePoliticianImageAnchor(UrlManager.GetIntroPageUri(politicianKey) .ToString(), politicianKey, ImageSize100, politicianName + " biographical information and positions and views on the issues"); break; } case ReportUser.Admin: { anchorHeadshot = new HtmlImage { Src = VotePage.GetPoliticianImageUrl(politicianKey, ImageSize75) }; break; } case ReportUser.Master: { anchorHeadshot = CreatePoliticianImageAnchor( SecurePoliticianPage.GetUpdateIssuesPageUrl(politicianKey), politicianKey, ImageSize75, "Edit Issue Topic Responses", "politician"); break; } } var td = new HtmlTableCell().AddTo(CurrentPoliticianRow, "tdReportImage"); Debug.Assert(anchorHeadshot != null, "anchorHeadshot != null"); anchorHeadshot.AddTo(td); var politicianCell = new HtmlTableCell().AddTo(CurrentPoliticianRow, "tdReportDetail"); var nameContainer = new HtmlDiv().AddTo(politicianCell, "detail name"); if (isIncumbent) { new Literal { Text = "* " } }
static void Main(string[] args) { var table = Politicians.GetAllNamesData(); var list = table.Cast <PoliticiansRow>() .Where(row => row.LastName.IsNeIgnoreCase(row.LastName.StripAccents())) .Select( row => new { PoliticianKey = row.PoliticianKey, LastName = row.LastName }) .ToList(); }
public static Uri GetIntroPageUri(string id) { var stateCode = Politicians.GetStateCodeFromKey(id); var qsc = new QueryStringCollection(); AddNonEmptyParm(qsc, "State", stateCode); AddNonEmptyParm(qsc, "Id", id); return(GetStateUri(stateCode, "Intro.aspx", qsc)); }
private Control GenerateVideoContent(DataRow politician) { var container = new PlaceHolder(); _DataManager.GetVideoData(politician.PoliticianKey(), politician.LiveOfficeKey()); ReportCandidateVideos(container, politician, _DataManager.GetDataSubset(), Politicians.FormatName(politician), false); return(container); }
private static string FormatPoliticianName(PoliticiansAdminReportViewRow row, bool breakAfterPosition = false, bool includeAddOn = false) { const int maxNameLineLength = 30; return(Politicians.FormatName(row.FirstName, row.MiddleName, row.Nickname, row.LastName, row.Suffix, includeAddOn ? row.AddOn : null, row.StateCode, breakAfterPosition ? maxNameLineLength : 0)); }
private void button1_Click(object sender, EventArgs e) { foreach (var row in Politicians.GetAllData()) { PoliticiansTest.Insert(row.PoliticianKey, row.StateCode, row.FirstName, row.MiddleName, row.Nickname, row.LastName, row.Suffix, row.LastName.DoubleMetaphone()); } }
public bool GetUserSecurityIsOk() { var ok = IsSuperUser || IsMasterUser && !IsSuperUserPage; if (!ok) { switch (PageSecurityClass) { case StateAdminSecurityClass: switch (UserSecurityClass) { case StateAdminSecurityClass: ok = FindStateCode() == UserStateCode; break; case CountyAdminSecurityClass: ok = FindStateCode() == UserStateCode && FindCountyCode() == UserCountyCode; break; case LocalAdminSecurityClass: ok = FindStateCode() == UserStateCode && FindCountyCode() == UserCountyCode && FindLocalKey() == UserLocalKey; break; } break; case PartySecurityClass: ok = IsPartyUser && FindPartyKey() == UserPartyKey; break; case PoliticianSecurityClass: ok = IsPoliticianUser && FindPoliticianKey() == UserPoliticianKey; if (!ok) { if (IsPartyUser) { // allow access to the party's politician pages var partyKey = Politicians.GetPartyKey(FindPoliticianKey()); if (!IsNullOrWhiteSpace(partyKey)) { ok = partyKey.IsEqIgnoreCase(UserPartyKey); } } else if (IsStateAdminUser) { // allow access to the state's politician pages ok = Politicians.GetStateCodeFromKey(FindPoliticianKey()) == UserStateCode; } } break; } } return(ok); }
public static string Politicians_Str(string politicianKey, Politicians.Column column) { var value = Politicians.GetColumn(column, politicianKey); if (value == null) { return(string.Empty); } return(value as string); }
private static void SetSessionVariables( string usernameEntered, string userSecurityClass, bool superUser) { var session = HttpContext.Current.Session; // Note: we fetch the UserName from the db to normalize casing session["UserSecurity"] = userSecurityClass; session["_UserSecurity"] = session["UserSecurity"]; session["SuperUser"] = superUser ? "Y" : "N"; session["_SuperUser"] = session["SuperUser"]; switch (userSecurityClass) { case PoliticianSecurityClass: session["UserName"] = Politicians.GetPoliticianKey(usernameEntered); session["_UserName"] = session["UserName"]; session["PoliticianKey"] = usernameEntered.ToUpperInvariant(); session["_PoliticianKey"] = session["PoliticianKey"]; break; case PartySecurityClass: session["UserName"] = PartiesEmails.GetPartyEmail(usernameEntered); session["_UserName"] = session["UserName"]; session["UserPartyKey"] = PartiesEmails.GetPartyKey(usernameEntered) .ToUpperInvariant(); session["_UserPartyKey"] = session["UserPartyKey"]; break; default: { var row = Security.GetData(usernameEntered)[0]; session["UserName"] = Security.GetUserName(usernameEntered); session["_UserName"] = session["UserName"]; session["UserStateCode"] = row.UserStateCode.ToUpperInvariant(); session["_UserStateCode"] = session["UserStateCode"]; session["UserCountyCode"] = string.IsNullOrWhiteSpace(row.UserCountyCode) ? string.Empty : row.UserCountyCode.ZeroPad(3); session["_UserCountyCode"] = session["UserCountyCode"]; session["UserLocalCode"] = string.IsNullOrWhiteSpace(row.UserLocalCode) ? string.Empty : row.UserLocalCode.ZeroPad(2); session["_UserLocalCode"] = session["UserLocalCode"]; session["UserDesignCode"] = row.UserDesignCode.ToUpperInvariant(); session["_UserDesignCode"] = session["UserDesignCode"]; session["UserOrganizationCode"] = row.UserOrganizationCode.ToUpperInvariant(); session["_UserOrganizationCode"] = session["UserOrganizationCode"]; session["UserIssuesCode"] = row.UserIssuesCode.ToUpperInvariant(); session["_UserIssuesCode"] = session["UserIssuesCode"]; } break; } }
private void IncludeViewableElectionsOfficesAndCandidates(string domainCode) { // We fetch future US "elections" always, so candidates can be included in their appropriate // state, plus state. var table = Elections.GetElectionsForSitemap(domainCode); var minCompareCandidatesDate = DateTime.UtcNow.Subtract(new TimeSpan(60, 0, 0, 0)); var minIntroDate = DateTime.UtcNow.Subtract(new TimeSpan(365, 0, 0, 0)); // Only add elections that match domain. Don't add US election: The CompareCandidates entry // will be sufficient. if (domainCode != "US") { foreach (var electionKey in table.Rows .Cast <DataRow>() .Select(row => row.ElectionKey()) .Distinct() .Where(key => domainCode.IsEqIgnoreCase(Elections.GetStateCodeFromKey(key)))) { AddElection(electionKey); } } // Add CompareCandidates for all offices with multiple candidates that match domain // but only for elections less than 60 days old foreach (var office in table.Rows .Cast <DataRow>() .Where(row => domainCode.IsEqIgnoreCase(Elections.GetStateCodeFromKey(row.ElectionKey())) && row.ElectionDate() > minCompareCandidatesDate) .GroupBy(row => new { ElectionKey = row.ElectionKey(), OfficeKey = row.OfficeKey() })) { if (office.Count() > 1) { AddCompareCandidates(office.Key.ElectionKey, office.Key.OfficeKey); } } // Add Intro for all candidates and running mates that match domain // but only for elections less than 365 days old foreach (var politicianKey in table.Rows .Cast <DataRow>() .Where(row => row.ElectionDate() > minIntroDate) .Select(row => row.PoliticianKey()) .Where(key => domainCode.IsEqIgnoreCase(Politicians.GetStateCodeFromKey(key))) .Union(table.Rows .Cast <DataRow>() .Select(row => row.RunningMateKey())) .Where(key => domainCode.IsEqIgnoreCase(Politicians.GetStateCodeFromKey(key)))) { AddIntroPages(politicianKey); } }