コード例 #1
0
        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);
        }
コード例 #2
0
        private static HtmlControl CreateSampleBallotButton(LinkInfo link)
        {
            var button = new HtmlP().AddCssClasses("button");

            new HtmlAnchor {
                HRef = link.HRef.ToString(), InnerText =
                    $"Interactive Sample Ballot for the {link.Description}"
            }.AddTo(button, "link-button");
            return(button);
        }
コード例 #3
0
        private static void AddLinkToLinkBox(Control div, LinkInfo link, string target)
        {
            var p = new HtmlP().AddTo(div);

            new HtmlAnchor
            {
                HRef      = link.HRef.ToString(),
                InnerText = link.Description,
                Title     = link.Description,
                Target    = target
            }.AddTo(p);
        }
コード例 #4
0
        public static HtmlContainerControl CreateParagraph(string id, string className)
        {
            var paragraph = new HtmlP {
                EnableViewState = false
            };

            if (id != null)
            {
                paragraph.ID = id;
            }
            if (className != null)
            {
                paragraph.AddCssClasses(className);
            }
            return(paragraph);
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        public static Control GetMorePart1(string text, int min, int max, string type, string key,
                                           bool linkify = true)
        {
            key = $"{type}:{min}:{max}:{key}";
            var split = GetMoreSplit(text, min, max);
            var p     = new HtmlP();
            var s     = split[0];

            if (linkify)
            {
                s = s.Linkify();
            }
            s = s.ReplaceNewLinesWithParagraphs(false);
            new LiteralControl(s).AddTo(p);
            if (!string.IsNullOrEmpty(split[1]))
            {
                var span = new HtmlSpan().AddTo(p, "more-text");
                span.Attributes.Add("data-key", key);
            }
            return(p);
        }
コード例 #7
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (CodesAreValid || IsNullOrWhiteSpace(StateCode) && this is IAllowEmptyStateCode)
            {
                return;
            }
            var mainContent = Master.MainContentControl;

            mainContent.Controls.Clear();
            var p = new HtmlP();

            if (IsNullOrWhiteSpace(StateCode))
            {
                p.InnerHtml = "StateCode is missing";
            }
            else if (!StateCodeExists)
            {
                p.InnerHtml = "StateCode [" + StateCode + "] is invalid";
            }
            else if (!CountyCodeExists)
            {
                p.InnerHtml = "CountyCode [" + CountyCode + "] is invalid for state + " +
                              StateCode;
            }
            else if (!LocalKeyExists)
            {
                p.InnerHtml = "LocalKey [" + LocalKey + "] is invalid for state + " +
                              StateCode + " and county " + CountyCode;
            }
            else
            {
                // should never happen
                p.InnerHtml = "There was a problem interpreting the query string";
            }
            p.Attributes["class"] = "missing-key";
            mainContent.Controls.Add(p);
        }
コード例 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Report.SignedInReportUser != ReportUser.Public)
            {
                this.IncludeCss("~/css/MainCommon.css");
                this.IncludeCss("~/css/SecondaryCommon.css");
                this.IncludeCss("~/css/All.css");
                this.IncludeCss("~/css/Officials.css");
            }

            if (HasUrlError)
            {
                InnerContent.Controls.Clear();
                var p = new HtmlP().AddTo(InnerContent, "not-found-error");
                new LiteralControl($"We could not show the information you requested: {UrlError}").AddTo(p);
                return;
            }

            _StateCode  = QueryReport;
            _CountyCode = Empty;
            _LocalKey   = Empty;
            if (IsNullOrWhiteSpace(_StateCode))
            {
                _StateCode = QueryState;
            }
            if (StateCache.IsValidStateCode(_StateCode))
            {
                _CountyCode = QueryCounty;
                _LocalKey   = QueryLocal;
            }

            _ElectoralClass = Offices.GetElectoralClass(_StateCode, _CountyCode, _LocalKey);

            AnalyzeElectoralClass();
            var report = OfficialsReportResponsive.GetReport(_StateCode, _CountyCode, _LocalKey);

            report.AddTo(ReportPlaceHolder);
        }
コード例 #9
0
        private void CreateHeading(int officeContestsCount, bool hasBallotMeasures)
        {
            // Link removed per Mantis 840
            //new HtmlAnchor
            //{
            //  HRef = UrlManager.GetElectionPageUri(_ElectionKey).ToString(),
            //  InnerText = _ElectionDescription
            //}.AddTo(ElectionTitle);
            ElectionTitle.InnerText = _ElectionDescription;
            LocationInfo1.InnerHtml = LocationInfo2.InnerHtml =
                FormatLegislativeDistrictsFromQueryStringForHeading(true);

            var stateCode = Elections.GetStateCodeFromKey(QueryElection);

            if (officeContestsCount > 0 || hasBallotMeasures)
            {
            }
            else
            {
                InstructionsAccordion.Visible = false;
                Instructions.InnerText        = "There are no office contests or ballot measures for your legislative districts.";
            }

            if (officeContestsCount > 0 || hasBallotMeasures)
            {
                var additionalInfo = PageCache.Elections.GetElectionAdditionalInfo(QueryElection)
                                     .ReplaceNewLinesWithParagraphs();
                if (IsNullOrWhiteSpace(additionalInfo))
                {
                    additionalInfo =
                        ElectionsDefaults.GetElectionAdditionalInfo(
                            Elections.GetDefaultElectionKeyFromKey(QueryElection));
                }
                if (!IsNullOrWhiteSpace(additionalInfo))
                {
                    new LiteralControl(additionalInfo).AddTo(AdditionalInformation);
                }

                var ballotInstructions = PageCache.Elections.GetBallotInstructions(QueryElection);
                if (IsNullOrWhiteSpace(ballotInstructions))
                {
                    ballotInstructions =
                        ElectionsDefaults.GetBallotInstructions(
                            Elections.GetDefaultElectionKeyFromKey(QueryElection));
                }
                if (!IsNullOrWhiteSpace(ballotInstructions))
                {
                    new LiteralControl(ballotInstructions.ReplaceNewLinesWithParagraphs()).AddTo(
                        BallotInstructions);
                }

                var statesRow = States.GetData(stateCode).FirstOrDefault();
                if (statesRow != null)
                {
                    var controlsToAdd = new List <Control>();

                    if (!IsNullOrWhiteSpace(statesRow.PollHours))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Normal Polling Hours: "
                        });
                        controlsToAdd.Add(new LiteralControl(statesRow.PollHours));
                    }

                    if (!IsNullOrWhiteSpace(statesRow.PollHoursUrl))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.PollHoursUrl),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " polling hours"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.PollPlacesUrl))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.PollPlacesUrl),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " polling places"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.VoterRegistrationWebAddress))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.VoterRegistrationWebAddress),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " voter registration page"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.EarlyVotingWebAddress))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.EarlyVotingWebAddress),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " early voting page"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.VoteByMailWebAddress))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.VoteByMailWebAddress),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " vote by mail page"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.VoteByAbsenteeBallotWebAddress))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.VoteByAbsenteeBallotWebAddress),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " absentee ballot page"
                        });
                    }

                    if (controlsToAdd.Count > 0)
                    {
                        var p = new HtmlP();
                        VotingInformation.Controls.Add(p);
                        foreach (var c in controlsToAdd)
                        {
                            p.Controls.Add(c);
                        }
                    }

                    var howVotingIsDone = Elections.IsPrimaryElection(QueryElection)
            ? statesRow.HowPrimariesAreDone
            : statesRow.HowVotingIsDone;

                    if (!IsNullOrWhiteSpace(howVotingIsDone))
                    {
                        VotingInformation.Controls.Add(
                            new LiteralControl(howVotingIsDone.ReplaceNewLinesWithParagraphs()));
                    }
                }

                var stateElectionKey = Elections.GetStateElectionKeyFromKey(QueryElection);
                var electionsRow     = Elections.GetData(stateElectionKey).FirstOrDefault();
                var defRow           = ElectionsDefaults
                                       .GetData(Elections.GetDefaultElectionKeyFromKey(stateElectionKey))
                                       .FirstOrDefault();
                if (electionsRow != null && defRow != null)
                {
                    var controlsToAdd = new List <Control>();

                    var registrationDeadline = electionsRow.RegistrationDeadline.IsDefaultDate()
            ? defRow.RegistrationDeadline
            : electionsRow.RegistrationDeadline;

                    var earlyVotingBegin = electionsRow.EarlyVotingBegin.IsDefaultDate()
            ? defRow.EarlyVotingBegin
            : electionsRow.EarlyVotingBegin;

                    var earlyVotingEnd = electionsRow.EarlyVotingEnd.IsDefaultDate()
            ? defRow.EarlyVotingEnd
            : electionsRow.EarlyVotingEnd;

                    var mailBallotBegin = electionsRow.MailBallotBegin.IsDefaultDate()
            ? defRow.MailBallotBegin
            : electionsRow.MailBallotBegin;

                    var mailBallotEnd = electionsRow.MailBallotEnd.IsDefaultDate()
            ? defRow.MailBallotEnd
            : electionsRow.MailBallotEnd;

                    var mailBallotDeadline = electionsRow.MailBallotDeadline.IsDefaultDate()
            ? defRow.MailBallotDeadline
            : electionsRow.MailBallotDeadline;

                    var absenteeBallotBegin = electionsRow.AbsenteeBallotBegin.IsDefaultDate()
            ? defRow.AbsenteeBallotBegin
            : electionsRow.AbsenteeBallotBegin;

                    var absenteeBallotEnd = electionsRow.AbsenteeBallotEnd.IsDefaultDate()
            ? defRow.AbsenteeBallotEnd
            : electionsRow.AbsenteeBallotEnd;

                    var absenteeBallotDeadline = electionsRow.AbsenteeBallotDeadline.IsDefaultDate()
            ? defRow.AbsenteeBallotDeadline
            : electionsRow.AbsenteeBallotDeadline;

                    if (!registrationDeadline.IsDefaultDate())
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Registration Deadline: "
                        });
                        controlsToAdd.Add(new LiteralControl(registrationDeadline.ToShortDateString()));
                    }

                    if (!earlyVotingBegin.IsDefaultDate() || !earlyVotingEnd.IsDefaultDate())
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Early Voting: "
                        });
                        var strings = new List <string>();
                        if (!earlyVotingBegin.IsDefaultDate())
                        {
                            strings.Add($"begins {earlyVotingBegin.ToShortDateString()}");
                        }
                        if (!earlyVotingEnd.IsDefaultDate())
                        {
                            strings.Add($"ends {earlyVotingEnd.ToShortDateString()}");
                        }
                        controlsToAdd.Add(new LiteralControl(Join(", ", strings)));
                    }

                    if (!mailBallotBegin.IsDefaultDate() || !mailBallotEnd.IsDefaultDate() ||
                        !mailBallotDeadline.IsDefaultDate())
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Mail-In Ballots: "
                        });
                        var strings = new List <string>();
                        if (!mailBallotBegin.IsDefaultDate())
                        {
                            strings.Add($"begins {mailBallotBegin.ToShortDateString()}");
                        }
                        if (!mailBallotEnd.IsDefaultDate())
                        {
                            strings.Add($"last day to request {mailBallotEnd.ToShortDateString()}");
                        }
                        if (!mailBallotDeadline.IsDefaultDate())
                        {
                            strings.Add($"must be received by {mailBallotDeadline.ToShortDateString()}");
                        }
                        controlsToAdd.Add(new LiteralControl(Join(", ", strings)));
                    }

                    if (!absenteeBallotBegin.IsDefaultDate() || !absenteeBallotEnd.IsDefaultDate() ||
                        !absenteeBallotDeadline.IsDefaultDate())
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Absentee Ballots: "
                        });
                        var strings = new List <string>();
                        if (!absenteeBallotBegin.IsDefaultDate())
                        {
                            strings.Add($"begins {absenteeBallotBegin.ToShortDateString()}");
                        }
                        if (!absenteeBallotEnd.IsDefaultDate())
                        {
                            strings.Add($"last day to request {absenteeBallotEnd.ToShortDateString()}");
                        }
                        if (!absenteeBallotDeadline.IsDefaultDate())
                        {
                            strings.Add(
                                $"must be received by {absenteeBallotDeadline.ToShortDateString()}");
                        }
                        controlsToAdd.Add(new LiteralControl(Join(", ", strings)));
                    }

                    if (controlsToAdd.Count > 0)
                    {
                        var p = new HtmlP();
                        VotingInformation.Controls.Add(p);
                        foreach (var c in controlsToAdd)
                        {
                            p.Controls.Add(c);
                        }
                    }
                }

                // Mantis 349: Show Incumbent always
                //if (
                //  StateCache.GetIsIncumbentShownOnBallots(
                //    Elections.GetStateCodeFromKey(QueryElection)))
                var span = new HtmlSpan().AddTo(AdditionalInfo, "incumbent-note");
                new LiteralControl("* before a candidate&rsquo;s name denotes incumbent").AddTo(span);
            }
        }
コード例 #10
0
        public static void Report()
        {
            // Get yesterday's activity
            var placeholder = new PlaceHolder();
            var date        = DateTime.UtcNow.Date.AddDays(-1);
            var logins      = LogLogins.GetPoliticianLoginsByDateStampRange(date).Rows.OfType <DataRow>()
                              .ToList();

            var message = new HtmlP();

            message.AddTo(placeholder);
            message.Style.Add(HtmlTextWriterStyle.FontFamily, "arial");
            message.Style.Add(HtmlTextWriterStyle.FontSize, "8pt");
            if (logins.Count == 0)
            {
                message.InnerText = $"There were no politician sign-ins on {date:d}";
            }
            else
            {
                message.InnerText = $"These politicians signed in on {date:d}";
                var lines = logins.Select(r =>
                {
                    var tr = new TableRow {
                        TableSection = TableRowSection.TableBody
                    };
                    new TableCell {
                        Text = r.StateCode()
                    }.AddTo(tr);
                    new TableCell {
                        Text = r.PoliticianKey()
                    }.AddTo(tr);
                    new TableCell {
                        Text = Politicians.FormatName(r)
                    }.AddTo(tr);
                    new TableCell {
                        Text = Offices.FormatOfficeName(r)
                    }.AddTo(tr);
                    new TableCell {
                        Text = r.ElectionDescription()
                    }.AddTo(tr);
                    new TableCell {
                        Text = r.LiveOfficeStatus()
                    }.AddTo(tr);
                    foreach (var td in tr.Controls.OfType <TableCell>())
                    {
                        td.Style.Add(HtmlTextWriterStyle.BorderWidth, "1px");
                        td.Style.Add(HtmlTextWriterStyle.BorderStyle, "solid");
                        td.Style.Add(HtmlTextWriterStyle.BorderColor, "#cccccc");
                        td.Style.Add(HtmlTextWriterStyle.Padding, "3px");
                    }
                    return(tr);
                });

                var table = new Table();
                table.AddTo(placeholder);
                table.Style.Add(HtmlTextWriterStyle.BorderCollapse, "collapse");
                table.Style.Add(HtmlTextWriterStyle.FontFamily, "arial");
                table.Style.Add(HtmlTextWriterStyle.FontSize, "8pt");
                table.Style.Add(HtmlTextWriterStyle.MarginTop, "20px");

                // Add the heading row
                var thr = new TableHeaderRow();
                thr.AddTo(table);
                thr.TableSection = TableRowSection.TableHeader;
                thr.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
                thr.Style.Add(HtmlTextWriterStyle.Color, "#ffffff");
                thr.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#666666");
                new TableHeaderCell {
                    Text = "State"
                }.AddTo(thr);
                new TableHeaderCell {
                    Text = "Politician Key"
                }.AddTo(thr);
                new TableHeaderCell {
                    Text = "Name"
                }.AddTo(thr);
                new TableHeaderCell {
                    Text = "Office"
                }.AddTo(thr);
                new TableHeaderCell {
                    Text = "Election"
                }.AddTo(thr);
                new TableHeaderCell {
                    Text = "Status"
                }.AddTo(thr);
                foreach (var th in thr.Controls.OfType <TableHeaderCell>())
                {
                    th.Style.Add(HtmlTextWriterStyle.BorderWidth, "1px");
                    th.Style.Add(HtmlTextWriterStyle.BorderStyle, "solid");
                    th.Style.Add(HtmlTextWriterStyle.BorderColor, "#666666");
                    th.Style.Add(HtmlTextWriterStyle.Padding, "3px");
                    th.Style.Add(HtmlTextWriterStyle.TextAlign, "left");
                }

                foreach (var line in lines)
                {
                    line.AddTo(table);
                }
            }

            SendEmails(placeholder, date);
        }