コード例 #1
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);
        }
コード例 #2
0
        private Control GenerateReport(string stateOrFederalCode,
                                       string countyCode = "", string localCode = "")
        {
            _ElectoralClass = Offices.GetElectoralClass(stateOrFederalCode, countyCode,
                                                        localCode);

            var options = new OfficialsReportOptions
            {
                ElectoralClass =
                    Offices.GetElectoralClass(stateOrFederalCode, countyCode, localCode),
                StateCode  = stateOrFederalCode,
                CountyCode = countyCode,
                LocalCode  = localCode
            };

            DataManager.GetData(options);

            switch (options.ElectoralClass)
            {
            case ElectoralClass.USPresident:
                new USPresidentCategory().Generate(this, true);
                break;

            case ElectoralClass.USSenate:
                foreach (var stateCode in StateCache.All51StateCodes)
                {
                    new USSenateCategory().Generate(this, true, stateCode);
                }
                break;

            case ElectoralClass.USHouse:
                foreach (var stateCode in StateCache.All51StateCodes)
                {
                    new USHouseCategory().Generate(this, true, stateCode);
                }
                break;

            case ElectoralClass.USGovernors:
                foreach (var stateCode in StateCache.All51StateCodes)
                {
                    new USGovernorsCategory().Generate(this, true, stateCode);
                }
                break;

            case ElectoralClass.State:
                new USPresidentCategory().Generate(this);
                new USSenateCategory().Generate(this, false, stateOrFederalCode);
                new USHouseCategory().Generate(this, false, stateOrFederalCode);
                new USGovernorsCategory().Generate(this, false, stateOrFederalCode);
                new StatewideCategory().Generate(this, false, stateOrFederalCode);
                new StateSenateCategory().Generate(this, false, stateOrFederalCode);
                new StateHouseCategory().Generate(this, false, stateOrFederalCode);
                break;

            case ElectoralClass.County:
                new CountyCategory().Generate(this, false, stateOrFederalCode, countyCode);
                break;

            case ElectoralClass.Local:
                new LocalCategory().Generate(this, false, stateOrFederalCode, countyCode,
                                             localCode);
                break;
            }

            switch (_ElectoralClass)
            {
            case ElectoralClass.State:
            case ElectoralClass.County:
                CreateLowerLevelOfficialsAnchors(stateOrFederalCode, countyCode);
                break;
            }

            return(ReportContainer.AddCssClasses("officials-report"));
        }