protected void Page_Load(object sender, EventArgs e) { GeographyBallotCoverageLookup lookup = GetLookupFromCache(); HtmlTableRow tr = null; HtmlTableCell td = null; tr = new HtmlTableRow(); mainTable.Rows.Add(tr); td = CreateCell(tr, "Geography"); td = CreateCell(tr, "GeographyId"); td = CreateCell(tr, "VoterCount"); td = CreateCell(tr, "AdvanceVotingStationsDistro"); td = CreateCell(tr, "AdvanceVotingStationsTotal"); td = CreateCell(tr, "VotingStationsTotal"); td = CreateCell(tr, "VotingStationsDistroSingle"); td = CreateCell(tr, "VotingStationsDistroDouble"); td = CreateCell(tr, "VotingStationsComplete"); td = CreateCell(tr, "WAdvanceVotingStationsDistro"); td = CreateCell(tr, "WAdvanceVotingStationsTotal"); td = CreateCell(tr, "WWAdvanceVotingStationsDistro"); td = CreateCell(tr, "WWAdvanceVotingStationsTotal"); td = CreateCell(tr, "WVotingStationsTotal"); td = CreateCell(tr, "WVotingStationsDistroSingle"); td = CreateCell(tr, "WVotingStationsDistroDouble"); td = CreateCell(tr, "WVotingStationsComplete"); foreach (int geoId in lookup.Keys) { tr = new HtmlTableRow(); mainTable.Rows.Add(tr); GeographyBallotCoverageDataPoint pt = lookup[geoId]; td = CreateCell(tr, "" + Geography.FromIdentity((pt.GeographyId)).Name); td = CreateCell(tr, "" + pt.GeographyId); td = CreateCell(tr, "" + pt.VoterCount); td = CreateCell(tr, "" + pt.AdvanceVotingStationsDistro); td = CreateCell(tr, "" + pt.AdvanceVotingStationsTotal); td = CreateCell(tr, "" + pt.VotingStationsTotal); td = CreateCell(tr, "" + pt.VotingStationsDistroSingle); td = CreateCell(tr, "" + pt.VotingStationsDistroDouble); td = CreateCell(tr, "" + pt.VotingStationsComplete); td = CreateCell(tr, "" + pt.WAdvanceVotingStationsDistro); td = CreateCell(tr, "" + pt.WAdvanceVotingStationsTotal); td = CreateCell(tr, "" + pt.WWAdvanceVotingStationsDistro); td = CreateCell(tr, "" + pt.WWAdvanceVotingStationsTotal); td = CreateCell(tr, "" + pt.WVotingStationsTotal); td = CreateCell(tr, "" + pt.WVotingStationsDistroSingle); td = CreateCell(tr, "" + pt.WVotingStationsDistroDouble); td = CreateCell(tr, "" + pt.WVotingStationsComplete); } }
protected void Page_Load(object sender, EventArgs e) { OrganizationMetadata metadata = OrganizationMetadata.FromUrl(Request.Url.Host); GeographyBallotCoverageLookup lookup = GetLookupFromCache(); Response.ContentType = "text/plain"; if (Request["typ"] == null || Request["typ"] == "F") { Response.Write(lookup[30].WAdvanceVotingCoverage.ToString("##.#", new CultureInfo(Organization.FromIdentity(metadata.OrganizationId).DefaultCountry.Culture))); } else { Response.Write(lookup[30].WVotingCoverage.ToString("##.#", new CultureInfo(Organization.FromIdentity(metadata.OrganizationId).DefaultCountry.Culture))); } }
SeriesCollection GetVotingDayRankingData() { GeographyBallotCoverageLookup lookup = GetLookupFromCache(); Geographies geos = null; string circuitString = Request.QueryString["CircuitId"]; int circuitId = 0; if (String.IsNullOrEmpty(circuitString) || Int32.Parse(circuitString) == Geography.SwedenId) { geos = Geographies.FromLevel(Country.FromCode("SE"), GeographyLevel.ElectoralCircuit); } else { circuitId = Int32.Parse(circuitString); Geographies candidateGeos = Geography.FromIdentity(circuitId).GetTree(); geos = new Geographies(); foreach (Geography geo in candidateGeos) { if (lookup.ContainsKey(geo.Identity) && geo.Identity != circuitId) { geos.Add(geo); } } } Dictionary <int, Geography> geoLookup = new Dictionary <int, Geography>(); foreach (Geography geo in geos) { geoLookup[geo.Identity] = geo; } GeographyBallotCoverageData data = new GeographyBallotCoverageData(); foreach (Geography geo in geos) { if (lookup.ContainsKey(geo.Identity)) { data.Add(lookup[geo.Identity]); } } bool sortByValue = cbSort.Checked; data.Sort( delegate(GeographyBallotCoverageDataPoint p1, GeographyBallotCoverageDataPoint p2) { if (sortByValue) { if (advanceVotingMode) { double i1 = (absoluteMode ? p1.AdvanceVotingCoverage : p1.WWAdvanceVotingCoverage); double i2 = (absoluteMode ? p2.AdvanceVotingCoverage : p2.WWAdvanceVotingCoverage); return(i1.CompareTo(i2)); } else { double i1 = (absoluteMode ? p1.VotingCoverage : p1.WVotingCoverage); double i2 = (absoluteMode ? p2.VotingCoverage : p2.WVotingCoverage); return(i1.CompareTo(i2)); } } else { return(geoLookup[p2.GeographyId].Name.CompareTo(geoLookup[p1.GeographyId].Name)); } }); SeriesCollection collection = new SeriesCollection(); Series seriesPositiveSingle = new Series(); seriesPositiveSingle.Name = "Positive, single distro"; Series seriesPositiveDouble = new Series(); seriesPositiveDouble.Name = "Positive, double distro"; Series seriesPositiveFull = new Series(); seriesPositiveFull.Name = "Positive, full coverage"; Series seriesNegative = new Series(); seriesNegative.Name = "Negative"; // Add empties, then Sweden AddSingleVotingDayDataPoint(lookup[Geography.SwedenId], seriesPositiveSingle, seriesPositiveDouble, seriesPositiveFull, seriesNegative); if (circuitId != 0) { AddSingleVotingDayDataPoint(lookup[circuitId], seriesPositiveSingle, seriesPositiveDouble, seriesPositiveFull, seriesNegative); } seriesPositiveSingle.Elements.Add(new Element()); seriesNegative.Elements.Add(new Element()); foreach (GeographyBallotCoverageDataPoint dataPoint in data) { AddSingleVotingDayDataPoint(dataPoint, seriesPositiveSingle, seriesPositiveDouble, seriesPositiveFull, seriesNegative); } seriesPositiveSingle.DefaultElement.Color = System.Drawing.Color.Yellow; seriesPositiveDouble.DefaultElement.Color = System.Drawing.Color.YellowGreen; seriesPositiveFull.DefaultElement.Color = System.Drawing.Color.Green; seriesPositiveSingle.DefaultElement.ShowValue = true; seriesNegative.DefaultElement.Color = System.Drawing.Color.DarkRed; SeriesCollection result = new SeriesCollection(); result.Add(seriesPositiveSingle); result.Add(seriesPositiveDouble); result.Add(seriesPositiveFull); result.Add(seriesNegative); return(result); }