Exemple #1
0
    public void SessionEnded()
    {
        if (_isSessionInProgress)
        {
            Timer.TimerReport report = _timer.StopTimer();
            _currentSessionData.Duration            = (int)report.WorkingTime;
            _currentSessionData.PauseIgnoreDuration = (int)report.WorkingTimeWithoutPause;
            _currentSessionData.SesseionStartTime   = report.StartTime;

            ReportContainer container;

            if (_reportsStorage.reports.TryGetValue(UserName, out container))
            {
                container.data.Add(_currentSessionData);
            }
            else
            {
                container = new ReportContainer();
                container.data.Add(_currentSessionData);
                _reportsStorage.reports.Add(UserName, container);
            }


            if (_pauseController != null)
            {
                _pauseController.VisualizationPaused   += OnVisualizationPaused;
                _pauseController.VisualizationUnpaused += OnVisualizationUnpaused;
            }
        }

        TrySendReport();

        _isSessionInProgress = false;
    }
        //private Control GenerateReportByOfficeKey(string officeKey, string electionKey)
        //{
        //  _DataManager.GetDataByOfficeKey(officeKey, electionKey);

        //  var issueGroups = _DataManager.GetDataSubset()
        //    .GroupBy(row => row.IssueKey())
        //    .ToList();

        //  OneReportSection(issueGroups, "Questions");

        //  return ReportContainer.AddCssClasses("issue-list-report");
        //}

        //private Control GenerateReportByPoliticianKey(string politicianKey,
        //  string electionKey)
        //{
        //  _DataManager.GetDataByPoliticianKey(politicianKey, electionKey);

        //  var issueGroups = _DataManager.GetDataSubset()
        //    .GroupBy(row => row.IssueKey())
        //    .ToList();

        //  OneReportSection(issueGroups, "Questions");

        //  return ReportContainer.AddCssClasses("issue-list-report");
        //}

        private Control GenerateReportByStateCode(string stateCode)
        {
            _DataManager.GetDataByStateCode(stateCode);

            var issueLevelGroups = _DataManager.GetDataSubset()
                                   .GroupBy(row => row.IssueKey())
                                   .ToList()
                                   .GroupBy(g => g.First()
                                            .SortIssueLevel())
                                   .ToList();

            foreach (var issueLevelGroup in issueLevelGroups)
            {
                switch (issueLevelGroup.Key)
                {
                case "A":
                    OneReportSection(issueLevelGroup,
                                     "Questions Available to All Candidates");
                    break;

                case "B":
                    OneReportSection(issueLevelGroup,
                                     "Questions Available Only to U.S. President, U.S. House and U.S. Senate Candidates");
                    break;

                case "C":
                    OneReportSection(issueLevelGroup,
                                     "Questions Available Only to " + StateCache.GetStateName(stateCode) +
                                     " Statewide, House and Senate Candidates");
                    break;
                }
            }

            return(ReportContainer.AddCssClasses("issue-list-report"));
        }
Exemple #3
0
        private Control GenerateReport(string stateCode, string countyCode,
                                       string congressionalDistrict, string stateSenateDistrict,
                                       string stateHouseDistrict, bool includeLocals, bool localsSeparated = false)
        {
            ReportUser = ReportUser.Public;

            DataManager.SetData(Offices.GetElectedReportData(stateCode, countyCode,
                                                             congressionalDistrict, stateSenateDistrict, stateHouseDistrict, includeLocals));

            (new USPresidentCategory()).Generate(this);
            (new USSenateCategory()).Generate(this, false, stateCode);
            (new USHouseCategory()).Generate(this, false, stateCode);
            (new USGovernorsCategory()).Generate(this, false, stateCode);
            (new StatewideCategory()).Generate(this, false, stateCode);
            (new StateSenateCategory()).Generate(this, false, stateCode);
            (new StateHouseCategory()).Generate(this, false, stateCode);
            (new CountyCategory()).Generate(this, false, stateCode, countyCode);
            if (includeLocals)
            {
                var reportContainer = ReportContainer;
                if (localsSeparated)
                {
                    new HtmlDiv {
                        InnerText = "Local Elected Officials"
                    }.AddTo(ReportContainer, "category-title accordion-header elected-report-locals");
                    reportContainer = new HtmlDiv().AddTo(ReportContainer,
                                                          "category-content accordion-content elected-report-locals elected-report-locals-content");
                }
                new AllLocalsCategory().GenerateAll(this, stateCode, countyCode, reportContainer);
            }

            return(ReportContainer.AddCssClasses("elected-report"));
        }
Exemple #4
0
        public override void Execute(string[] args)
        {
            Report report = ReportContainer.GetInstance().report;

            report.NewChartData += new Report.ChartDataHandler(report_NewChartData);
            report.DoReport();
        }
        private Control GenerateReport(string electionKey, string countyCode, string district,
                                       string place, string elementary, string secondary, string unified, string cityCouncil,
                                       string countySupervisors, string schoolDistrictDistrict)
        {
            _ElectionKey = electionKey;
            _StateCode   = Elections.GetStateCodeFromKey(_ElectionKey);
            _CountyCode  = countyCode;

            _DataManager.GetData(electionKey, countyCode, district, place, elementary, secondary,
                                 unified, cityCouncil, countySupervisors, schoolDistrictDistrict);

            if (Elections.IsStateElection(_ElectionKey))
            {
                ReportStateReferendums();
            }

            if (Elections.IsStateElection(_ElectionKey) ||
                Elections.IsCountyElection(_ElectionKey))
            {
                ReportCountyReferendums();
            }

            if (Elections.IsLocalElection(_ElectionKey))
            {
                ReportLocalReferendumsForOneLocal();
            }
            else
            {
                ReportLocalReferendumsForAllLocals();
            }

            return(ReportContainer.AddCssClasses("ballot-referendum-report ballot-checks-container"));
        }
Exemple #6
0
        private Control GenerateReport(string electionKey, string countyCode)
        {
            _ElectionKey = electionKey;
            _StateCode   = Elections.GetStateCodeFromKey(_ElectionKey);
            _CountyCode  = countyCode;

            _DataManager.GetData(_ElectionKey, _CountyCode);

            //_MainHtmlTable =
            //  new HtmlTable {CellSpacing = 0, CellPadding = 0}.AddCssClasses("tablePage");

            if (Elections.IsStateElection(_ElectionKey))
            {
                ReportStateReferendums();
            }

            if (Elections.IsStateElection(_ElectionKey) ||
                Elections.IsCountyElection(_ElectionKey))
            {
                ReportCountyReferendums();
            }

            if (Elections.IsLocalElection(_ElectionKey))
            {
                ReportLocalReferendumsForOneLocal();
            }
            else
            {
                ReportLocalReferendumsForAllLocals();
            }

            //return _MainHtmlTable;
            return(ReportContainer.AddCssClasses("ballot-referendum-report ballot-checks-container"));
        }
Exemple #7
0
        private Control GenerateReportByJurisdiction(string stateCode, string countyCode, string localKey)
        {
            ReportContainer.ID           = "new-accordions";
            ReportContainer.ClientIDMode = ClientIDMode.Static;
            stateCode = stateCode.ToUpperInvariant();
            _DataManager.GetDataByJurisdiction(stateCode, countyCode, localKey);

            var issueLevelGroups = _DataManager.GetDataSubset()
                                   .GroupBy(row => new
            {
                IssueGroupId = row.IssueGroupId(),
                IssueId      = row.IssueId()
            })
                                   .ToList()
                                   .GroupBy(g => g.Key.IssueGroupId)
                                   .ToList()
                                   .GroupBy(g => g.First().First()
                                            .IssueLevel())
                                   .OrderBy(g => g.Key)
                                   .ToList();

            foreach (var issueLevelGroup in issueLevelGroups)
            {
                switch (issueLevelGroup.Key)
                {
                case Issues.IssueLevelAll:
                    OneReportSection(issueLevelGroup,
                                     "Questions Available to All Candidates");
                    break;

                case Issues.IssueLevelNational:
                    OneReportSection(issueLevelGroup,
                                     "Questions Available to U.S. President, U.S. House and U.S. Senate Candidates");
                    break;

                case Issues.IssueLevelState:
                    OneReportSection(issueLevelGroup,
                                     $"Questions Available to {StateCache.GetStateName(stateCode)}" +
                                     " Statewide, House and Senate Candidates");
                    break;

                case Issues.IssueLevelCounty:
                    OneReportSection(issueLevelGroup,
                                     $"Questions Available to {Counties.GetName(stateCode, countyCode)}" +
                                     $" ({stateCode}) Candidates");
                    break;

                case Issues.IssueLevelLocal:
                    OneReportSection(issueLevelGroup,
                                     $"Questions Available to {LocalDistricts.GetName(stateCode, localKey)}" +
                                     $" ({stateCode}) Candidates");
                    break;
                }
            }

            return(ReportContainer.AddCssClasses("issue-list-report accordion-container"));
        }
        public override void Execute(string[] args)
        {
            double fs = 1;

            if (args.Length > 0)
            {
                double.TryParse(args[0], out fs);
            }
            PlotPowerSpectralDensity psd = new PlotPowerSpectralDensity(fs);

            ReportContainer.GetInstance().report.AddSinglePlot(psd);
        }
Exemple #9
0
 public override void Execute(string[] args)
 {
     if (args.Length > 0)
     {
         Report rep = new Report(null, args[0]);
         ReportContainer.NewReport(rep);
     }
     else
     {
         throw new CommandException("You must supply a filename");
     }
 }
Exemple #10
0
        private XtraReport Report(string ReportDisplayName)
        {
            if (ReportDataProvider.ReportsStorage.ReportDataType != null)
            {
                return(ReportDataProvider.ReportsStorage.LoadReport(this.ReportData(ReportDisplayName)));
            }
            else
            {
                IReportDataV2   reportData = ReportObjectSpaceProvider.FindObject <ReportDataV2>(new BinaryOperator("DisplayName", ReportDisplayName));
                ReportContainer container  = new ReportContainer(reportData);

                return(container.Report);
            }
        }
        public void AddTable_NoAdd_TableIsNull()
        {
            ICSVTable           table           = null;
            IUniqueNameProvider nameProvider    = new Dummy_UniqueNameProvider();
            IReportContainer    reportContainer = new ReportContainer(nameProvider);
            bool expected = true;

            //Act
            reportContainer.AddTable(table);
            bool actual = reportContainer.Tables.Count == 0;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void AddPropertyStr_AddsToContainer()
        {
            //Arrange
            IUniqueNameProvider nameProvider    = new Dummy_UniqueNameProvider();
            IReportContainer    reportContainer = new ReportContainer(nameProvider);
            bool expected = true;

            //Act
            reportContainer.AddProperty("val");
            bool actual = reportContainer.Properties.Count == 1;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void AddTable_AddsToContainer()
        {
            //Arrange
            ICSVTable           table           = new Dummy_CSVTable();
            IUniqueNameProvider nameProvider    = new Dummy_UniqueNameProvider();
            IReportContainer    reportContainer = new ReportContainer(nameProvider);
            bool expected = true;

            //Act
            reportContainer.AddTable(table);
            bool actual = reportContainer.Tables.Count == 1;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        private Control GenerateReport(string electionKey, string officeKey, bool forBallotPage = false)
        {
            _CandidatesDataManager.GetData(electionKey, officeKey);
            var candidates = _CandidatesDataManager.GetDataSubset(new RunningMateFilter());

            if (candidates.Count > 0)
            {
                var isRunningMateOffice = Offices.IsRunningMateOfficeInElection(electionKey, candidates[0].OfficeKey());

                if (!forBallotPage)
                {
                    var candidatesContainer = new HtmlDiv()
                                              .AddTo(ReportContainer, "candidates-container office-cell");
                    candidatesContainer.Attributes.Add("data-key", officeKey.ToUpperInvariant());
                    var positions = GetElectionPositions(electionKey, candidates[0]);
                    if (positions > 1)
                    {
                        candidatesContainer.Attributes.Add("data-positions",
                                                           positions.ToString(CultureInfo.InvariantCulture));
                    }
                    ReportOffice(candidatesContainer, isRunningMateOffice, candidates, _CandidatesDataManager,
                                 true, true);
                }

                CreateIssueListLink(officeKey);

                var candidateKeys = GetCandidateKeys(isRunningMateOffice, candidates);

                _IssuesDataManager.GetData(electionKey, officeKey);
                if (VotePage.EnableIssueGroups)
                {
                    ReportIssues3(candidateKeys, _IssuesDataManager.GetDataSubset(),
                                  isRunningMateOffice, candidates.Count);
                }
                else
                {
                    // for older elections show all responese
                    var electionDate    = Elections.GetElectionDateFromKey(electionKey);
                    var oldAnswerCutoff = electionDate > DateTime.UtcNow.AddMonths(-6)
            ? ElectionsOffices.GetOldAnswerCutoffDate(electionKey, officeKey)
            : DateTime.MinValue;
                    ReportIssues(candidateKeys, _IssuesDataManager.GetDataSubset(), oldAnswerCutoff,
                                 isRunningMateOffice, candidates.Count);
                }
            }

            return(ReportContainer.AddCssClasses("compare-candidates-report ballot-checks-container"));
        }
        public void ToJSON_IncludesAddedTables()
        {
            //Arrange
            string           sample          = "{\"table_1\":[{\"name\":\"sam\", \"age\":42},{\"name\":\"tom\", \"age\":77}],\"table_2\":[{\"name\":\"sam\", \"favorite-Food\":\"pizza\"},{\"name\":\"tom\", \"favorite-Food\":\"apples\"}]}";
            JObject          sampleObject    = JObject.Parse(sample);
            IReportContainer reportContainer = new ReportContainer(new Dummy_UniqueNameProvider());
            ICSVTable        table_1         = new Dummy_CSVTable("[{\"name\":\"sam\", \"age\":42},{\"name\":\"tom\", \"age\":77}]");
            ICSVTable        table_2         = new Dummy_CSVTable("[{\"name\":\"sam\", \"favorite-Food\":\"pizza\"},{\"name\":\"tom\", \"favorite-Food\":\"apples\"}]");

            reportContainer.AddTable("table_1", table_1);
            reportContainer.AddTable("table_2", table_2);
            bool expected = true;

            //Act
            string resultJSON = reportContainer.ToJSON();
            bool   actual     = resultJSON == sampleObject.ToString();

            //Assert
            Assert.AreEqual(expected, actual);
        }
        private Control GenerateReport(string electionKey, string officeKey)
        {
            _CandidatesDataManager.GetData(electionKey, officeKey);
            var candidates = _CandidatesDataManager.GetDataSubset(new RunningMateFilter());

            if (candidates.Count > 0)
            {
                var isRunningMateOffice = candidates[0].IsRunningMateOffice() &&
                                          !Elections.IsPrimaryElection(electionKey);
                var candidatesContainer = new HtmlDiv()
                                          .AddTo(ReportContainer, "candidates-container office-cell");
                candidatesContainer.Attributes.Add("data-key", officeKey.ToUpperInvariant());
                var positions = GetElectionPositions(electionKey, candidates[0]);
                if (positions > 1)
                {
                    candidatesContainer.Attributes.Add("data-positions",
                                                       positions.ToString(CultureInfo.InvariantCulture));
                }
                ReportOffice(candidatesContainer, isRunningMateOffice, candidates, _CandidatesDataManager,
                             true, true);

                var issueListLink = new HtmlDiv().AddTo(ReportContainer, "issue-list-link");
                new HtmlAnchor
                {
                    HRef      = UrlManager.GetIssueListPageUri(Offices.GetStateCodeFromKey(officeKey)).ToString(),
                    InnerText = "View a list of all questions available to the candidates"
                }.AddTo(issueListLink);
                new LiteralControl(
                    ". Questions are included below only if at least one candidate responded.").AddTo(
                    issueListLink);

                var candidateKeys = GetCandidateKeys(isRunningMateOffice, candidates);

                _IssuesDataManager.GetData(electionKey, officeKey);
                ReportIssues(candidateKeys, _IssuesDataManager.GetDataSubset(), isRunningMateOffice,
                             candidates.Count);
            }

            return(ReportContainer.AddCssClasses("compare-candidates-report ballot-checks-container"));
        }
Exemple #17
0
        private Control GenerateReport(string electionKey, string congress,
                                       string stateSenate, string stateHouse, string countyCode,
                                       out int totalContests)
        {
            _ElectionKey      = electionKey;
            _StateElectionKey = Elections.GetStateElectionKeyFromKey(_ElectionKey);
            _StateCode        = Elections.GetStateCodeFromKey(_ElectionKey);
            //_Congress = congress;
            //_StateSenate = stateSenate;
            //_StateHouse = stateHouse;
            _CountyCode = countyCode;
            //_UseExplorer = useExplorer;

            _DataManager.GetData(_ElectionKey, congress, stateSenate, stateHouse,
                                 _CountyCode);

            if (Elections.IsStateElection(_ElectionKey))
            {
                ReportStateContests();
            }

            if (Elections.IsStateElection(_ElectionKey) ||
                Elections.IsCountyElection(_ElectionKey))
            {
                ReportCountyContests();
            }

            if (Elections.IsLocalElection(_ElectionKey))
            {
                ReportLocalContestsForOneLocal();
            }
            else
            {
                ReportLocalContestsForAllLocals();
            }

            totalContests = _TotalContests;
            return(ReportContainer.AddCssClasses("ballot-report ballot-checks-container"));
        }
        private Control GenerateReport(DataRow politician)
        {
            _DataManager.GetData(politician.PoliticianKey(), politician.LiveOfficeKey());

            var issueListLink = new HtmlDiv().AddTo(ReportContainer, "issue-list-link");

            new HtmlAnchor
            {
                HRef =
                    UrlManager.GetIssueListPageUri(Offices.GetStateCodeFromKey(politician.LiveOfficeKey()))
                    .ToString(),
                InnerText = "View a list of all questions available to the candidate"
            }.AddTo(issueListLink);
            new LiteralControl(". Questions are included below only if the candidate responded.").AddTo(
                issueListLink);

            ReportIssues(new List <DataRow> {
                politician
            }, _DataManager.GetDataSubset(), false, 1, true);

            return(ReportContainer.AddCssClasses("intro-issues-report"));
        }
        public void ToJSON_IncludesAddedProperties()
        {
            //Arrange
            string sample = "{\n" +
                            "\"name\": \"report\",\n" +
                            "\"measure\": \"pounds\"\n" +
                            "}";
            JObject          sampleObject    = JObject.Parse(sample);
            IReportContainer reportContainer = new ReportContainer(new Dummy_UniqueNameProvider());

            reportContainer.AddProperty("name", "report");
            reportContainer.AddProperty("measure", "pounds");
            bool expected = true;

            //Act
            string jsonResult = reportContainer.ToJSON();

            bool actual = sampleObject.ToString() == jsonResult;

            //Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #20
0
        private Control GenerateReport(string electionKey, string congress, string stateSenate,
                                       string stateHouse, string countyCode, string district, string place,
                                       string elementary, string secondary, string unified, string cityCouncil,
                                       string countySupervisors, string schoolDistrictDistrict, out List <string> totalContests)
        {
            _ElectionKey      = electionKey;
            _StateElectionKey = Elections.GetStateElectionKeyFromKey(_ElectionKey);
            _StateCode        = Elections.GetStateCodeFromKey(_ElectionKey);
            _CountyCode       = countyCode;

            _DataManager.GetData(electionKey, congress, stateSenate, stateHouse, countyCode, district,
                                 place, elementary, secondary, unified, cityCouncil, countySupervisors,
                                 schoolDistrictDistrict);

            if (Elections.IsStateElection(_ElectionKey))
            {
                ReportStateContests();
            }

            if (Elections.IsStateElection(_ElectionKey) ||
                Elections.IsCountyElection(_ElectionKey))
            {
                ReportCountyContests();
            }

            if (Elections.IsLocalElection(_ElectionKey))
            {
                ReportLocalContestsForOneLocal();
            }
            else
            {
                ReportLocalContestsForAllLocals();
            }

            //totalContests = _TotalContests;
            totalContests = _AllOffices;
            return(ReportContainer.AddCssClasses("ballot-report ballot-checks-container"));
        }
Exemple #21
0
        private Control GenerateReport(DataRow politician)
        {
            _DataManager.GetData(politician.PoliticianKey(), politician.LiveOfficeKey());

            CreateIssueListLink(politician.LiveOfficeKey());

            if (VotePage.EnableIssueGroups)
            {
                ReportIssues3(new List <DataRow> {
                    politician
                }, _DataManager.GetDataSubset(), false, 1,
                              true);
            }
            else
            {
                ReportIssues(new List <DataRow> {
                    politician
                }, _DataManager.GetDataSubset(), DateTime.MinValue, false, 1,
                             true);
            }

            return(ReportContainer.AddCssClasses("intro-issues-report"));
        }
        private Control GenerateReport(string electionKey, bool complete,
                                       PlaceHolder multiCountySection = null)
        {
            _MultiCountySection = multiCountySection;
            _DataManager.GetData(electionKey);

            var electoralClass = Elections.GetElectoralClass(electionKey);

            switch (electoralClass)
            {
            case ElectoralClass.USPresident:
                if (Elections.GetElectionTypeFromKey(electionKey) ==
                    Elections.ElectionTypeUSPresidentialPrimary)
                {
                    new USPresidentCategory().Generate(this, electionKey);
                }
                else
                {
                    foreach (var stateCode in StateCache.All51StateCodes)
                    {
                        new USPresidentCategory().Generate(this,
                                                           Elections.InsertStateCodeIntoElectionKey(electionKey, stateCode), true);
                    }
                }
                break;

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

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

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

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

            case ElectoralClass.County:
                new CountyCategory().Generate(this, electionKey);
                break;

            case ElectoralClass.Local:
                new LocalCategory().Generate(this, electionKey);
                break;
            }

            ReportReferendums(electionKey);

            switch (electoralClass)
            {
            case ElectoralClass.State:
            case ElectoralClass.County:
                if (complete)
                {
                    CreateLowerLevelElectionReports(electionKey);
                }
                else
                {
                    CreateLowerLevelElectionAnchors(electionKey);
                }
                break;
            }

            return(ReportContainer.AddCssClasses("election-report"));
        }
Exemple #23
0
        private Control GenerateReport(ReportUser reportUser, string electionKey, bool openAll = false)
        {
            ReportUser = reportUser;

            if (ReportUser == ReportUser.Master)
            {
                var recentElections =
                    Elections.GetLatestElectionsByStateCode(
                        Elections.GetStateCodeFromKey(electionKey));
                _IsMostRecentElection = recentElections.Contains(electionKey,
                                                                 StringComparer.OrdinalIgnoreCase);
            }

            _OpenAll = openAll;
            _DataManager.GetData(electionKey);

            var electoralClass = Elections.GetElectoralClass(electionKey);

            switch (electoralClass)
            {
            case ElectoralClass.USPresident:
                if (Elections.GetElectionTypeFromKey(electionKey) ==
                    Elections.ElectionTypeUSPresidentialPrimary)
                {
                    new USPresidentCategory().Generate(this, electionKey);
                }
                else
                {
                    foreach (var stateCode in StateCache.All51StateCodes)
                    {
                        new USPresidentCategory().Generate(this,
                                                           Elections.InsertStateCodeIntoElectionKey(electionKey, stateCode), true);
                    }
                }
                break;

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

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

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

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

            case ElectoralClass.County:
                new CountyCategory().Generate(this, electionKey);
                break;

            case ElectoralClass.Local:
                new LocalCategory().Generate(this, electionKey);
                break;
            }

            ReportReferendums(electionKey);

            switch (electoralClass)
            {
            case ElectoralClass.State:
            case ElectoralClass.County:
                if (ReportUser == ReportUser.Master)
                {
                    CreateLowerLevelElectionReports(electionKey);
                }
                else
                {
                    CreateLowerLevelElectionAnchors(electionKey);
                }
                break;
            }

            return(ReportContainer.AddCssClasses("election-report"));
        }
        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"));
        }
Exemple #25
0
        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"));
        }
Exemple #26
0
 protected ResponsiveIssuesReport()
 {
     ReportContainer.AddCssClasses("issues-report");
 }
        protected override void ExecuteTask()
        {
            int           TestCount        = 0;
            int           TestPassingCount = 0;
            StringBuilder FailingTestInfo  = new StringBuilder();

            ReportContainer Report = new ReportContainer();


            foreach (String Fixture in Fixtures)
            {
                if (!this.Project.ScriptFileInfoList.Contains(Fixture))
                {
                    throw new BuildException(string.Format("There is no fixture loaded for {0}.", Fixture), this.Location);
                }
                ScriptFileInfo FixtureProject = this.Project.ScriptFileInfoList[Fixture];

                FixtureReport fixtureReport = new FixtureReport(Fixture);
                Report.FixtureReports.Add(fixtureReport);

                try
                {
                    this.TryRun(string.Format("{0}.{1}", FixtureProject.ProjectName, FixtureSetUp), FixtureProject);

                    foreach (Target FixtureTarget in FixtureProject.Targets)
                    {
                        if (FixtureTarget.Name.EndsWith("Test"))
                        {
                            TestReport testReport = new TestReport(FixtureTarget.Name);
                            fixtureReport.TestReports.Add(testReport);
                            try
                            {
                                TestCount++;
                                this.TryRun(string.Format("{0}.{1}", FixtureProject.ProjectName, SetUpName), FixtureProject);
                                FixtureTarget.Execute();
                                TestPassingCount++;
                                testReport.Passed = true;
                            }
                            catch (BuildException bx)
                            {
                                string FailureInfo = string.Format("{0} at:{1}{2}{3}{4}", bx.Message, Environment.NewLine, bx.Location.ToString(), Environment.NewLine, bx.ToString());
                                Log(Level.Error, FailureInfo);
                                FailingTestInfo.AppendLine(FailureInfo);

                                testReport.Passed           = false;
                                testReport.FailureException = bx.ToString();
                            }
                            catch (Exception ex)
                            {
                                string FailureInfo = string.Format("{0} in {1}{2}{3}", ex.Message, FixtureTarget.Name, Environment.NewLine, ex.ToString());
                                Log(Level.Error, FailureInfo);
                                FailingTestInfo.AppendLine(FailureInfo);

                                testReport.Passed           = false;
                                testReport.FailureException = ex.ToString();
                            }
                            finally
                            {
                                this.TryRun(string.Format("{0}.{1}", FixtureProject.ProjectName, TearDownName), FixtureProject);
                            }
                        }
                    }
                }
                finally
                {
                    this.TryRun(string.Format("{0}.{1}", FixtureProject.ProjectName, FixtureTearDown), FixtureProject);
                }
            }

            int TestFailingCount = TestCount - TestPassingCount;

            Log(Level.Info, "Tests Run: {0}", TestCount);
            Log(Level.Info, "Tests Passing: {0}", TestPassingCount);
            Log(Level.Info, "Tests Failing: {0}", TestFailingCount);
            Log(Level.Info, "Test Assertions Executed: {0}", MbUnit.Framework.Assert.AssertCount);
            Console.WriteLine(FailingTestInfo.ToString());

            if (File.Exists(FilePath))
            {
                File.Delete(FilePath);
            }

            XmlSerializer Serializer = new XmlSerializer(typeof(ReportContainer));

            using (FileStream ReportStream = File.OpenWrite(FilePath))
            {
                Serializer.Serialize(ReportStream, Report);
            }

            if (TestFailingCount > 0)
            {
                throw new BuildException(string.Format("{0} tests failed.", TestFailingCount));
            }
        }
Exemple #28
0
 protected ResponsiveIssuesReport()
 {
     ReportContainer.AddCssClasses("issues-report");
     ReportContainer.ID           = "new-accordions";
     ReportContainer.ClientIDMode = ClientIDMode.Static;
 }