private static void EmbedFacebookVideo(Control container, string facebookVideoId, QuestionAndAnswer row, Control heading = null) { // uses fake Facebook player if (!IsNullOrWhiteSpace(facebookVideoId)) { var videoWrapper = new HtmlDiv().AddTo(container, "video-container facebookvideo-container"); var videoPlayer = new HtmlDiv().AddTo(videoWrapper, "video-player facebookvideo-player"); videoPlayer.Attributes.Add("data-type", "fb"); videoPlayer.Attributes.Add("data-id", facebookVideoId); } heading?.AddTo(container); var description = FormatVideoDescription(row.FacebookVideoDescription, row.FacebookVideoRunningTime); var key = $"{row.PoliticianKey}:{row.QuestionKey}:{row.Sequence}"; VotePage.GetMorePart1(description, MoreMinForVideo, MoreMaxForVideo, "fbdesc", key).AddTo(container); var sourceTag = new HtmlP().AddTo(container, "video-source"); new HtmlSpan { InnerText = "Source: Uploaded by candidate " }.AddTo(sourceTag); if (!row.FacebookVideoDate.IsDefaultDate()) { new LiteralControl("(" + row.FacebookVideoDate.ToString("M/d/yyyy") + ")").AddTo( sourceTag); } }
public void HandleException(Exception ex) { string message; try { message = ex.Message; // We don't log routine UI exceptions if (!(ex is VoteUIException)) { VotePage.LogException("Feedback", ex); } } catch (Exception ex2) { // Don't put anything in here that could possibly // throw an exception. In the rare event that this block // executes, we use ex.ToString() instead of ex.Message // to make sure we capture and report the stack trace. message = "Unexpected failure in exception handler: " + ex2 + Environment.NewLine + "Original exception: " + ex; } AddError(message); }
public static Control FormatPartyAnchor(DataRow politician) { Control control; if (string.IsNullOrWhiteSpace(politician.PartyCode())) { control = new Literal(); } else if (string.IsNullOrWhiteSpace(politician.PartyUrl())) { control = new Literal { Text = politician.PartyCode() } } ; else { var a = new HtmlAnchor { HRef = VotePage.NormalizeUrl(politician.PartyUrl()), Title = politician.PartyName() + " Website", Target = OffsiteTarget, InnerText = politician.PartyCode() }; control = a; } return(control); }
protected override string GetCategoryTitle() { return(VotePage.GetPageCache() .LocalDistricts.GetLocalDistrict(StateCode, CountyCode, LocalCode) + ", " + CountyCache.GetCountyName(StateCode, CountyCode) + ", " + StateCache.GetStateName(StateCode) + " Offices"); }
public string UpdateVoteUsaImage(string politicianKey, string url) { var request = (HttpWebRequest)WebRequest.Create(url); var response = (HttpWebResponse)request.GetResponse(); using (var inputStream = response.GetResponseStream()) using (var memoryStream = new MemoryStream()) { Debug.Assert(inputStream != null, "inputStream != null"); inputStream.CopyTo(memoryStream); byte[] originalBlob; Size originalSize; if (PoliticiansImagesBlobs.GetHeadshot100(politicianKey) == null) { ImageManager.UpdateAllPoliticianImages(politicianKey, memoryStream, DateTime.UtcNow, true, out originalSize, out originalBlob); } else { ImageManager.UpdatePoliticianProfileImages(politicianKey, memoryStream, DateTime.UtcNow, true, out originalSize, out originalBlob); } } return(VotePage.GetPoliticianImageUrl(politicianKey, 300, true)); }
private Control CreateOfficeTitleAndKeyAnchor( OfficesAdminReportViewRow row) { var officeClass = row.OfficeLevel.ToOfficeClass(); var container = new PlaceHolder(); var text = Offices.FormatOfficeName(row.OfficeLine1, row.OfficeLine2, row.OfficeKey); if (officeClass.IsLocal()) { text += ", " + VotePage.GetPageCache() .LocalDistricts.GetLocalDistrict(_Options.StateCode, _Options.LocalKey); } if (officeClass.IsCounty() || officeClass.IsLocal()) { text += ", " + CountyCache.GetCountyName(_Options.StateCode, _Options.CountyCode); } CreateOfficePageAnchor(row.OfficeKey, text) .AddTo(container); if (row.IsInactive) { new Literal { Text = " - INACTIVE" } }
protected override string GetCategoryTitle() { var pageCache = VotePage.GetPageCache(); return(pageCache.LocalDistricts.GetLocalDistrict(StateCode, LocalKey) + ", " + CountyCache.GetCountyDescription(StateCode, CountyCode, LocalKey) + ", " + StateCache.GetStateName(StateCode) + " - Local Offices"); }
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 = "* " } }
public void VoteForOptionB() { MyTestInitialize(); VotePage p = new VotePage(Driver); p.Navigate(baseurl); p.VoteB.Click(); MyTestCleanup(); }
public static bool IsValidKey(string stateCode, string localKey) { if (IsNullOrWhiteSpace(stateCode) || IsNullOrWhiteSpace(localKey)) { return(false); } return(VotePage.GetPageCache() .LocalDistricts.Exists(stateCode, localKey)); }
public static HtmlImage CreatePoliticianImageTag(string politicianKey, int imageWidth, bool noCache = false, string align = "left") { var img = new HtmlImage { Src = VotePage.GetPoliticianImageUrl(politicianKey, imageWidth, noCache), Align = align }; return(img); }
public static bool IsValid(string stateCode, string countyCode, string localCode) { if (string.IsNullOrWhiteSpace(stateCode) || string.IsNullOrWhiteSpace(countyCode) || string.IsNullOrWhiteSpace(localCode)) { return(false); } return(VotePage.GetPageCache() .LocalDistricts.Exists(stateCode, countyCode, localCode)); }
private static void MakeCategory(Control parent, string title, string classNamePrefix, string content1, string content2, CategoryOptions options = CategoryOptions.None) { var asLink = (options & CategoryOptions.AsLink) != 0; var isScrollable = (options & CategoryOptions.Scrollable) != 0; var createParagraphs = (options & CategoryOptions.Paragraphs) != 0; var isHeadshot = (options & CategoryOptions.Headshot) != 0; var isProfile = (options & CategoryOptions.Profile) != 0; var isPicture = isHeadshot || isProfile; var heading = new HtmlDiv().AddTo(parent, "category-heading", true); new HtmlSpan { InnerText = title }.AddTo(heading); var hasContent1 = isPicture ? PoliticiansImagesBlobs.PoliticianKeyExists(content1) : !IsNullOrWhiteSpace(content1); var hasContent2 = isPicture ? PoliticiansImagesBlobs.PoliticianKeyExists(content2) : !IsNullOrWhiteSpace(content2); var category = new HtmlDiv().AddTo(parent, classNamePrefix + "-databoxes databoxes clearfix", true); var d1 = new HtmlDiv().AddTo(category, "databox databox-1", true) as HtmlContainerControl; if (!hasContent1) { d1.AddCssClasses("no-content"); } var d2 = new HtmlDiv().AddTo(category, "databox databox-2", true) as HtmlContainerControl; if (!hasContent2) { d2.AddCssClasses("no-content"); } if (isScrollable) { d1.AddCssClasses("scrollable"); d2.AddCssClasses("scrollable"); } if (asLink) { if (!IsNullOrWhiteSpace(content1)) { new HtmlAnchor { InnerText = content1, HRef = VotePage.NormalizeUrl(content1), Target = "content" } }
private static Control MakeWebAddressLink(string url) { if (IsNullOrWhiteSpace(url)) { return(new HtmlNbsp()); } return(new HtmlAnchor { HRef = VotePage.NormalizeUrl(url), Target = "_blank", InnerText = url }); }
//public static DataTable GetAllDataByIssueKeyPoliticianKey(string issueKey, // string politicianKey) //{ // const string cmdText = // "SELECT ig.IssueGroupKey,ig.IssueGroupOrder,ig.Heading AS IssueGroupHeading," + // "ig.SubHeading AS IssueGroupSubHeading,i.IssueKey,igi.IssueOrder,i.IssueLevel,i.Issue,i.IsTextSourceOptional," + // "i.StateCode AS StateCode,q.QuestionKey,q.QuestionOrder,q.Question,a.PoliticianKey,a.Source," + // "a.DateStamp,a.Answer,a.YouTubeUrl,a.YouTubeDescription,a.YouTubeRunningTime,a.YouTubeSourceUrl," + // "a.YouTubeSource,a.YouTubeDate,a.Sequence,a.YouTubeRefreshTime,a.YouTubeAutoDisable," + // "a.FacebookVideoUrl,a.FacebookVideoDescription,a.FacebookVideoRunningTime," + // "a.FacebookVideoDate,a.FacebookVideoRefreshTime,a.FacebookVideoAutoDisable FROM Issues i" + // " INNER JOIN IssueGroupsIssues igi ON igi.IssueKey = i.IssueKey" + // " INNER JOIN IssueGroups ig ON ig.IssueGroupKey = igi.IssueGroupKey" + // " INNER JOIN Questions q ON q.IssueKey = i.IssueKey" + // " LEFT JOIN Answers a on a.QuestionKey = q.QuestionKey AND a.PoliticianKey=@PoliticianKey" + // " WHERE i.IssueKey=@IssueKey" + " AND i.IsIssueOmit=0 AND q.IsQuestionOmit=0" + // " ORDER BY IssueGroupOrder,IssueOrder,QuestionOrder,DateStamp DESC,Sequence DESC"; // var cmd = VoteDb.GetCommand(cmdText); // var table = new DataTable(); // using (var cn = VoteDb.GetOpenConnection()) // { // cmd.Connection = cn; // VoteDb.AddCommandParameter(cmd, "IssueKey", issueKey); // VoteDb.AddCommandParameter(cmd, "PoliticianKey", politicianKey); // DbDataAdapter adapter = new MySqlDataAdapter(cmd as MySqlCommand); // adapter.Fill(table); // return table; // } //} public static DataTable GetAllDataByIssueKeyPoliticianKeyNew(int issueId, string politicianKey, string officeKey = null) { // This is keyed by specificIssueId // and so will not double-fetch questions in more than one issue if (IsNullOrWhiteSpace(officeKey)) { officeKey = VotePage.GetPageCache().Politicians.GetLiveOfficeKey(politicianKey); } var(stateCode, countyCode, localKey, level) = Offices.GetIssuesCoding(officeKey); var cmdText = "SELECT CONVERT(ig.IssueGroupId, CHAR) AS IssueGroupKey, ig.IssueGroupOrder," + "ig.Heading AS IssueGroupHeading,ig.SubHeading AS IssueGroupSubHeading," + "CONVERT(i.IssueId, CHAR) AS IssueKey, igi.IssueOrder,@Level AS IssueLevel,i.Issue," + "CONVERT(q.QuestionId, CHAR) AS QuestionKey, iq.QuestionOrder,q.Question," + "a.PoliticianKey,a.Source,a.DateStamp,a.Answer,a.YouTubeUrl,a.YouTubeDescription," + "a.YouTubeRunningTime,a.YouTubeSourceUrl,a.YouTubeSource,a.YouTubeDate," + "a.Sequence,a.YouTubeRefreshTime,a.YouTubeAutoDisable,a.FacebookVideoUrl," + "a.FacebookVideoDescription,a.FacebookVideoRunningTime,a.FacebookVideoDate," + "a.FacebookVideoRefreshTime,a.FacebookVideoAutoDisable," + "@IsTextSourceOptional AS IsTextSourceOptional FROM Issues2 i" + " INNER JOIN IssueGroupsIssues2 igi ON igi.IssueId = i.IssueId" + " INNER JOIN IssueGroups2 ig ON ig.IssueGroupId = igi.IssueGroupId" + " INNER JOIN IssuesQuestions iq ON iq.IssueId = i.IssueId" + " INNER JOIN Questions2 q ON q.QuestionId = iq.QuestionId" + " INNER JOIN QuestionsJurisdictions qj ON qj.QuestionId = q.QuestionId" + " LEFT JOIN Answers2 a on a.QuestionId = q.QuestionId" + " AND a.PoliticianKey = @PoliticianKey" + " WHERE i.IssueId = @IssueId AND i.IsIssueOmit = 0 AND q.IsQuestionOmit = 0" + $" AND {Questions.QuestionsJurisdictionsWhereClause}" + " ORDER BY IssueGroupOrder,IssueOrder,QuestionOrder,DateStamp DESC, Sequence DESC"; var cmd = VoteDb.GetCommand(cmdText); var table = new DataTable(); using (var cn = VoteDb.GetOpenConnection()) { cmd.Connection = cn; VoteDb.AddCommandParameter(cmd, "IssueId", issueId); VoteDb.AddCommandParameter(cmd, "PoliticianKey", politicianKey); VoteDb.AddCommandParameter(cmd, "StateCode", stateCode); VoteDb.AddCommandParameter(cmd, "CountyCode", countyCode); VoteDb.AddCommandParameter(cmd, "LocalKey", localKey); VoteDb.AddCommandParameter(cmd, "Level", level); VoteDb.AddCommandParameter(cmd, "IsTextSourceOptional", issueId == Issues.IssueId.Biographical.ToInt()); DbDataAdapter adapter = new MySqlDataAdapter(cmd as MySqlCommand); adapter.Fill(table); return(table); } }
//public static DataTable GetAllDataByIssueLevelStateCodePoliticianKey(string issueLevel, // string stateCode, string politicianKey, int commandTimeout = -1) //{ // const string cmdText = // "SELECT ig.IssueGroupKey,ig.IssueGroupOrder,ig.Heading AS IssueGroupHeading," + // "ig.SubHeading AS IssueGroupSubHeading,i.IssueKey,igi.IssueOrder,i.IssueLevel,i.Issue,i.IsTextSourceOptional," + // "i.StateCode AS StateCode,q.QuestionKey,q.QuestionOrder,q.Question,a.PoliticianKey,a.Source," + // "a.DateStamp,a.Answer,a.YouTubeUrl,a.YouTubeDescription,a.YouTubeSource,a.YouTubeRunningTime," + // "a.YouTubeSourceUrl,a.YouTubeDate,a.Sequence,a.YouTubeRefreshTime,a.YouTubeAutoDisable," + // "a.FacebookVideoUrl,a.FacebookVideoDescription,a.FacebookVideoRunningTime," + // "a.FacebookVideoDate,a.FacebookVideoRefreshTime,a.FacebookVideoAutoDisable FROM Issues i" + // " INNER JOIN IssueGroupsIssues ON IssueGroupsIssues.IssueKey = i.IssueKey" + // " INNER JOIN IssueGroups ig ON ig.IssueGroupKey = IssueGroupsIssues.IssueGroupKey" + // " INNER JOIN Questions q ON q.IssueKey = i.IssueKey" + // " LEFT JOIN Answers a on a.QuestionKey = q.QuestionKey AND a.PoliticianKey=@PoliticianKey" + // " WHERE i.StateCode=@StateCode AND i.IssueLevel=@IssueLevel" + // " AND i.IsIssueOmit=0 AND q.IsQuestionOmit=0" + // " ORDER BY IssueGroupOrder,IssueOrder,QuestionOrder,DateStamp DESC,Sequence DESC"; // var cmd = VoteDb.GetCommand(cmdText, commandTimeout); // var table = new DataTable(); // using (var cn = VoteDb.GetOpenConnection()) // { // cmd.Connection = cn; // VoteDb.AddCommandParameter(cmd, "IssueLevel", issueLevel); // VoteDb.AddCommandParameter(cmd, "StateCode", stateCode); // VoteDb.AddCommandParameter(cmd, "PoliticianKey", politicianKey); // DbDataAdapter adapter = new MySqlDataAdapter(cmd as MySqlCommand); // adapter.Fill(table); // return table; // } //} public static DataTable GetAllDataByPoliticianKeyNew(string politicianKey, string officeKey) { // Group to eliminate duplicates caused by questions in multiple issues if (IsNullOrWhiteSpace(officeKey)) { officeKey = VotePage.GetPageCache().Politicians.GetLiveOfficeKey(politicianKey); } var(stateCode, countyCode, localKey, level) = Offices.GetIssuesCoding(officeKey); var cmdText = "SELECT CONVERT(ig.IssueGroupId, CHAR) AS IssueGroupKey," + "ig.IssueGroupOrder,ig.Heading AS IssueGroupHeading," + "ig.SubHeading AS IssueGroupSubHeading,CONVERT(i.IssueId, CHAR) AS IssueKey,i.IssueId," + "igi.IssueOrder,qj.IssueLevel,i.Issue," + "IF(qj.IssueLevel = 'A', 1, 0) AS IsTextSourceOptional,qj.StateCode AS StateCode," + "CONVERT(q.QuestionId, CHAR) AS QuestionKey,q.QuestionId,iq.QuestionOrder,q.Question," + "@PoliticianKey AS PoliticianKey,a.Source,a.DateStamp,a.Answer,a.YouTubeUrl,a.YouTubeDescription," + "a.YouTubeSource,a.YouTubeRunningTime,a.YouTubeSourceUrl,a.YouTubeDate,a.Sequence," + "a.YouTubeRefreshTime,a.YouTubeAutoDisable,a.FacebookVideoUrl," + "a.FacebookVideoDescription,a.FacebookVideoRunningTime,a.FacebookVideoDate," + "a.FacebookVideoRefreshTime,a.FacebookVideoAutoDisable FROM Issues2 i" + " INNER JOIN IssueGroupsIssues2 igi ON igi.IssueId = i.IssueId" + " INNER JOIN IssueGroups2 ig ON ig.IssueGroupId = igi.IssueGroupId" + " INNER JOIN IssuesQuestions iq ON iq.IssueId = i.IssueId" + " INNER JOIN Questions2 q ON q.QuestionId = iq.QuestionId" + " INNER JOIN QuestionsJurisdictions qj ON qj.QuestionId = q.QuestionId" + " LEFT JOIN Answers2 a on a.QuestionId = q.QuestionId" + " AND a.PoliticianKey = @PoliticianKey" + " WHERE i.IsIssueOmit = 0 AND q.IsQuestionOmit = 0" + $" AND {Questions.QuestionsJurisdictionsWhereClause}" + " GROUP BY q.QuestionId,a.Sequence" + " ORDER BY IssueGroupOrder,IssueOrder,QuestionOrder,DateStamp DESC, Sequence DESC"; var cmd = VoteDb.GetCommand(cmdText); var table = new DataTable(); using (var cn = VoteDb.GetOpenConnection()) { cmd.Connection = cn; VoteDb.AddCommandParameter(cmd, "Level", level); VoteDb.AddCommandParameter(cmd, "StateCode", stateCode); VoteDb.AddCommandParameter(cmd, "CountyCode", countyCode); VoteDb.AddCommandParameter(cmd, "LocalKey", localKey); VoteDb.AddCommandParameter(cmd, "PoliticianKey", politicianKey); DbDataAdapter adapter = new MySqlDataAdapter(cmd as MySqlCommand); adapter.Fill(table); return(table); } }
public void Generate(OfficialsReportResponsive officialsReport, bool isForAllStatesReport = false, string stateCode = "", string countyCode = "", string localCode = "", Control reportContainer = null) { if (reportContainer == null) { reportContainer = officialsReport.ReportContainer; } OfficialsReport = officialsReport; StateCode = stateCode; CountyCode = countyCode; _LocalCode = localCode; IsForAllStatesReport = isForAllStatesReport; if (!string.IsNullOrWhiteSpace(_LocalCode)) { LocalName = VotePage.GetPageCache() .LocalDistricts.GetLocalDistrict(StateCode, CountyCode, _LocalCode); } var offices = GetOffices(); if (offices.Count <= 0) { return; } // ReSharper disable once PossibleNullReferenceException (new HtmlDiv().AddTo(reportContainer, "category-title accordion-header") as HtmlGenericControl).InnerHtml = GetCategoryTitle(); var container = new HtmlDiv().AddTo(reportContainer, "category-content accordion-content"); var entries = 0; foreach (var office in offices) { var politicians = office.ToList(); var officeInfo = politicians[0]; entries += OfficialsReport.ReportOneOffice(container, GetOfficeTitle(officeInfo), GetRunningMateTitle(), politicians); } container.AddCssClasses("candidates-" + entries); }
//private static void EmbedVideo(Control container, string youTubeId, QuestionAndAnswer row, // Control heading = null) //{ // if (!string.IsNullOrWhiteSpace(youTubeId)) // { // var videoWrapper = new HtmlDiv().AddTo(container, "video-wrapper"); // var videoWrapperInner = new HtmlDiv().AddTo(videoWrapper, "video-wrapper-inner"); // var iframe = new HtmlGenericControl("iframe").AddTo(videoWrapperInner); // iframe.Attributes.Add("width", "420"); // iframe.Attributes.Add("height", "236"); // iframe.Attributes.Add("src", // "https://www.youtube.com/embed/" + youTubeId + "?rel=0&showinfo=0"); // iframe.Attributes.Add("frameborder", "0"); // iframe.Attributes.Add("allowfullscreen", "allowfullscreen"); // } // if (heading != null) heading.AddTo(container); // var description = FormatYouTubeDescription(row.YouTubeDescription, row.YouTubeRunningTime); // var key = string.Format("{0}:{1}:{2}", row.PoliticianKey, row.QuestionKey, row.Sequence); // VotePage.GetMorePart1(description, MoreMinForYouTube, MoreMaxForYouTube, // "ytdesc", key).AddTo(container); // if (!string.IsNullOrWhiteSpace(row.YouTubeSource) || row.YouTubeDate != VotePage.DefaultDbDate) // { // var sourceTag = new HtmlP().AddTo(container, "video-source"); // if (!string.IsNullOrWhiteSpace(row.YouTubeSource)) // { // new HtmlSpan { InnerText = "Source: " }.AddTo(sourceTag); // if (string.IsNullOrWhiteSpace(row.YouTubeSourceUrl)) // new LiteralControl(row.YouTubeSource).AddTo(sourceTag); // else // new HtmlAnchor // { // HRef = VotePage.NormalizeUrl(row.YouTubeSourceUrl), // InnerHtml = row.YouTubeSource, // Target = "view" // }.AddTo(sourceTag); // if (row.YouTubeDate != VotePage.DefaultDbDate) // new LiteralControl(" ").AddTo(sourceTag); // } // if (row.YouTubeDate != VotePage.DefaultDbDate) // new LiteralControl("(" + row.YouTubeDate.ToString("M/d/yyyy") + ")").AddTo(sourceTag); // } //} private static void EmbedVideo2(Control container, string youTubeId, QuestionAndAnswer row, Control heading = null) { // uses fake YouTube player if (!string.IsNullOrWhiteSpace(youTubeId)) { var videoWrapper = new HtmlDiv().AddTo(container, "youtube-container"); new HtmlDiv().AddTo(videoWrapper, "youtube-player") .Attributes.Add("data-id", youTubeId); //var iframe = new HtmlGenericControl("iframe").AddTo(videoWrapperInner); //iframe.Attributes.Add("width", "420"); //iframe.Attributes.Add("height", "236"); //iframe.Attributes.Add("src", // "https://www.youtube.com/embed/" + youTubeId + "?rel=0&showinfo=0"); //iframe.Attributes.Add("frameborder", "0"); //iframe.Attributes.Add("allowfullscreen", "allowfullscreen"); } heading?.AddTo(container); var description = FormatYouTubeDescription(row.YouTubeDescription, row.YouTubeRunningTime); var key = $"{row.PoliticianKey}:{row.QuestionKey}:{row.Sequence}"; VotePage.GetMorePart1(description, MoreMinForYouTube, MoreMaxForYouTube, "ytdesc", key).AddTo(container); if (!string.IsNullOrWhiteSpace(row.YouTubeSource) || (row.YouTubeDate != VotePage.DefaultDbDate)) { var sourceTag = new HtmlP().AddTo(container, "video-source"); if (!string.IsNullOrWhiteSpace(row.YouTubeSource)) { new HtmlSpan { InnerText = "Source: " }.AddTo(sourceTag); if (string.IsNullOrWhiteSpace(row.YouTubeSourceUrl)) { new LiteralControl(row.YouTubeSource).AddTo(sourceTag); } else { new HtmlAnchor { HRef = VotePage.NormalizeUrl(row.YouTubeSourceUrl), InnerHtml = row.YouTubeSource, Target = "view" } }.AddTo(sourceTag);
public void ClearAddNewCandidate(bool clearErrors = false) { if (clearErrors) { _AddNewCandidateSubTabInfo.ClearValidationErrors(); } ControlAddNewCandidateFName.SetValue(Empty); ControlAddNewCandidateMName.SetValue(Empty); ControlAddNewCandidateNickname.SetValue(Empty); ControlAddNewCandidateLName.SetValue(Empty); ControlAddNewCandidateSuffix.SetValue(Empty); var stateCode = Mode == DataMode.AddPoliticians ? VotePage.GetPage <SecureAdminPage>().StateCode : Offices.GetValidatedStateCodeFromKey(SafeGetOfficeKey()); ControlAddNewCandidateStateCode.SetValue(stateCode); ControlAddNewCandidateStateCode.Enabled = !StateCache.IsValidStateCode(stateCode); }
private Control CreatePartyAnchor() { if (_PoliticianInfo.PartyKey() != null) { if (string.IsNullOrWhiteSpace(_PoliticianInfo.PartyUrl())) { return(new LiteralControl(_PoliticianInfo.PartyName())); } var a = new HtmlAnchor { HRef = VotePage.NormalizeUrl(_PoliticianInfo.PartyUrl()), Title = _PoliticianInfo.PartyName() + " Website", Target = "_self", InnerHtml = _PoliticianInfo.PartyName() }; return(a); } return(new LiteralControl("no party affiliation")); }
protected void ReportParty(DataRow row) { var tr = new HtmlTableRow().AddTo(CurrentHtmlTable, "trReportDetail"); new HtmlTableCell { InnerText = row.PartyOrder().ToString() } .AddTo(tr, "tdReportDetail"); new HtmlTableCell { InnerText = row.PartyKey() } .AddTo(tr, "tdReportDetail"); new HtmlTableCell { InnerText = row.PartyCode() } .AddTo(tr, "tdReportDetail"); var td = new HtmlTableCell().AddTo(tr, "tdReportDetail"); new HtmlAnchor { HRef = SecureAdminPage.GetPartiesPageUrl(row.StateCode(), row.PartyKey()), InnerText = row.PartyName(), Target = "edit" }.AddTo(td); td = new HtmlTableCell().AddTo(tr, "tdReportDetail"); var url = row.PartyUrl(); if (IsNullOrWhiteSpace(url)) { td.InnerHtml = " "; } else { new HtmlAnchor { HRef = VotePage.NormalizeUrl(url), InnerText = row.PartyUrl(), Title = "Party Wensite", Target = "view" } }.AddTo(td);
protected void Page_Load(object sender, EventArgs e) { _SecureAdminPage = VotePage.GetPage <SecureAdminPage>(); if (_SecureAdminPage == null) { throw new VoteException( "The NavigateJurisdiction control can only be used in the SecureAdminPage class"); } if (!IsPostBack) { Page.IncludeCss("~/css/vote/controls/NavigateJurisdiction.css"); var cs = Page.ClientScript; var type = GetType(); const string scriptName = "NavigateJurisdiction"; if (cs.IsStartupScriptRegistered(type, scriptName)) { return; } cs.RegisterStartupScript(type, scriptName, "require(['vote/controls/navigateJurisdiction'], function(){{}});", true); if (IsNullOrWhiteSpace(AdminPageName)) { var match = Regex.Match(VotePage.CurrentPath, @"/([^./]+)\."); if (!match.Success) { throw new VoteException("Missing AdminPageName"); } AdminPageName = match.Groups[1].Value; } PageName.Value = AdminPageName; UserSecurityClass.Value = SecurePage.UserSecurityClass; OriginalStateCode.Value = _SecureAdminPage.StateCode; OriginalCountyCode.Value = _SecureAdminPage.CountyCode; OriginalLocalKey.Value = _SecureAdminPage.LocalKey; Initialize(); } }
protected void Page_Load(object sender, EventArgs e) { try { var name = string.Empty; if (SecurePage.IsPoliticianUser && !string.IsNullOrWhiteSpace(VotePage.UserName)) { var votePage = VotePage.Current; if (votePage != null) { name = votePage.PageCache.Politicians.GetPoliticianName(VotePage.UserName); } } if (name == string.Empty) { name = VotePage.UserName; } if (string.IsNullOrWhiteSpace(name)) { LabelLogin.Text = "<span class=\"logged-in-as\"><a href=\"/SignIn.aspx\">Sign in</a></span>"; } else { LabelLogin.Text = "<span class=\"logged-in-as\">Signed in as: <span class=\"name\">" + name + "</span><br /><a href=\"/SignIn.aspx?Signout=Y\">Sign out</a></span>"; } } catch (Exception ex) { VotePage.Log404Error("AdminHeading.aspx: " + ex.Message); if (!VotePage.IsDebugging) { VotePage.SafeTransferToError500(); } } }
protected void Page_Load(object sender, EventArgs e) { try { var name = Empty; if (SecurePage.IsPoliticianUser && !IsNullOrWhiteSpace(VotePage.UserName)) { var votePage = VotePage.Current; if (votePage != null) { name = votePage.PageCache.Politicians.GetPoliticianName(VotePage.UserName); } } MainBannerHomeLink.HRef = UrlManager.GetSiteUri().ToString(); if (name == Empty) { name = VotePage.UserName; } if (IsNullOrWhiteSpace(name)) { LabelLogin.Text = "<span class=\"logged-in-as\"><a href=\"/SignIn.aspx\">Sign in</a></span>"; } else { LabelLogin.Text = $"<span class=\"logged-in-as\">Signed in as: <span class=\"name\">{name}" + "</span> <a href=\"/SignIn.aspx?Signout=Y\">Sign out</a></span>"; } } catch (Exception ex) { VotePage.Log404Error("AdminHeading.aspx: " + ex.Message); if (!VotePage.IsDebugging) { VotePage.SafeTransferToError500(); } } }
private static Control CreatePoliticianWebsiteAnchor(string webAddress, string anchorText, string title) { Control control; if (IsNullOrEmpty(webAddress)) { control = new Literal(); } else { var a = new HtmlAnchor { HRef = VotePage.NormalizeUrl(webAddress), Target = "view", Title = title, InnerHtml = anchorText ?? webAddress }; control = a; } return(control); }
private static void EmbedYouTube(Control container, string youTubeId, QuestionAndAnswer row, Control heading = null) { // uses fake YouTube player if (!IsNullOrWhiteSpace(youTubeId)) { var videoWrapper = new HtmlDiv().AddTo(container, "video-container youtube-container"); var videoPlayer = new HtmlDiv().AddTo(videoWrapper, "video-player youtube-player"); videoPlayer.Attributes.Add("data-type", "yt"); videoPlayer.Attributes.Add("data-id", youTubeId); } heading?.AddTo(container); var description = FormatVideoDescription(row.YouTubeDescription, row.YouTubeRunningTime); var key = $"{row.PoliticianKey}:{row.QuestionKey}:{row.Sequence}"; VotePage.GetMorePart1(description, MoreMinForVideo, MoreMaxForVideo, "ytdesc", key).AddTo(container); if (!IsNullOrWhiteSpace(row.YouTubeSource) || !row.YouTubeDate.IsDefaultDate()) { var sourceTag = new HtmlP().AddTo(container, "video-source"); if (!IsNullOrWhiteSpace(row.YouTubeSource)) { new HtmlSpan { InnerText = "Source: " }.AddTo(sourceTag); if (IsNullOrWhiteSpace(row.YouTubeSourceUrl)) { new LiteralControl(row.YouTubeSource).AddTo(sourceTag); } else { new HtmlAnchor { HRef = VotePage.NormalizeUrl(row.YouTubeSourceUrl), InnerHtml = row.YouTubeSource, Target = "view" } }.AddTo(sourceTag);
protected Control FormatCandidateWebsite(DataRow candidate) { Control control = new PlaceHolder(); var publicWebAddress = candidate.PublicWebAddress(); if (!string.IsNullOrEmpty(publicWebAddress)) { var div = new HtmlDiv().AddTo(control, "website"); new HtmlImage { Src = "/images/website.png" }.AddTo(div); new HtmlAnchor { HRef = VotePage.NormalizeUrl(publicWebAddress), Target = OffsiteTarget, Title = Politicians.FormatName(candidate) + "'s Website", InnerText = "Website" }.AddTo(new HtmlSpan().AddTo(div)); } return(control); }
private Control CreateOfficeNameAndKey(PoliticiansAdminReportViewRow row) { var officeClass = row.OfficeLevel.ToOfficeClass(); var countyName = row.County.SafeString(); Control control; string literalText; if (officeClass.IsCounty()) { literalText = FormatOfficeName(row) + ", " + countyName; } else if (officeClass.IsLocal()) { countyName = CountyCache.GetCountyName(_Options.StateCode, _Options.CountyCode); var localName = VotePage.GetPageCache() .LocalDistricts.GetLocalDistrict(_Options.StateCode, _Options.LocalKey); literalText = FormatOfficeName(row) + ", " + localName + ", " + countyName; } else { literalText = FormatOfficeName(row); } if (officeClass != OfficeClass.USPresident) { control = CreateAdminOfficeAnchor(row.OfficeKey, literalText, Empty); } else { control = new Literal { Text = literalText } }; return(control); }
private Control GenerateReport(DataRow politician) { var imageContainer = new HtmlDiv().AddTo(ReportContainer, "candidate-image"); CreatePoliticianImageTag(politician.PoliticianKey(), ImageSize300, false, Empty) .AddTo(imageContainer); var infoContainer = new HtmlDiv().AddTo(ReportContainer, "candidate-info"); new HtmlH1 { InnerText = Politicians.FormatOfficeAndStatus(politician) } .AddTo(infoContainer, "candidate-status"); if (politician.LiveOfficeStatus() == "InFutureViewableElection") { var h2 = new HtmlH2(); h2.AddTo(infoContainer, "candidate-election"); // Link removed per Mantis 840 //new HtmlAnchor //{ // HRef = UrlManager.GetElectionPageUri(politician.LiveElectionKey()).ToString(), // InnerText = politician.ElectionDescription() //}.AddTo(h2); h2.InnerText = politician.ElectionDescription(); CreateCompareTheCandidatesAnchor(politician.LiveElectionKey(), politician.LiveOfficeKey()) .AddTo(infoContainer); } Control party; if (politician.PartyKey() != null) { if (IsNullOrWhiteSpace(politician.PartyUrl())) { party = new LiteralControl(politician.PartyName()); } else { party = new HtmlAnchor { HRef = VotePage.NormalizeUrl(politician.PartyUrl()), Title = politician.PartyName() + " Website", Target = "_blank", InnerHtml = politician.PartyName() }; ((HtmlAnchor)party).Attributes["rel"] = "nofollow"; } } else { party = new LiteralControl("no party affiliation"); } if (party is LiteralControl) { var span = new HtmlSpan(); party.AddTo(span); party = span; } party.AddTo(infoContainer, "candidate-party"); FormatWebAddress(infoContainer, politician); FormatSocialMedia(infoContainer, politician); FormatPostalAddress(infoContainer, politician); FormatPhone(infoContainer, politician); FormatAge(infoContainer, politician); return(ReportContainer.AddCssClasses("intro-report clearfix")); }
public static OfficeClass GetOfficeClass(string officeKey) { return(GetOfficeClass(VotePage.GetPageCache(), officeKey)); }