private static void LoadPopularBills() { ArrayList popularbills = new ArrayList(); XmlDocument populars = new XmlDocument(); try { Hashtable usedsubjs = new Hashtable(); populars.Load("/home/govtrack/data/misc/popularbills.xml"); foreach (XmlElement m in populars.SelectNodes("popular-bills/bill")) { BillMonitor mon = (BillMonitor)Monitor.FromString("bill:" + m.GetAttribute("id")); string billtitle = mon.Display().ToLower(); string terms = ""; foreach (XmlElement t in m.SelectNodes("search-string")) { if (billtitle.IndexOf(t.InnerText) >= 0) { continue; } if (terms != "") { terms += ", "; } terms += '"' + t.InnerText + '"'; } Hashtable h = new Hashtable(); h["monitor"] = mon.Encoded(); h["title"] = mon.Display(); h["link"] = mon.Link(); h["terms"] = terms; popularbills.Add(h); if (popularbills.Count > 30) { break; } } } catch { } PopularBills = popularbills; }
private void GetVotesFromBill(BillMonitor bm, Hashtable votes) { XPathNavigator bill = Bills.LoadBill(bm.Session, bm.Type, bm.Number); string title = Bills.DisplayString(bill.Select("*"), 10000); string statusstr = Bills.GetStatusSource(bill.Select("*")); ArrayList rolls = new ArrayList(); XPathNodeIterator votesiter = bill.Select("bill/actions/vote"); while (votesiter.MoveNext()) { string roll = votesiter.Current.GetAttribute("roll", ""); string date = votesiter.Current.GetAttribute("datetime", ""); string where = votesiter.Current.GetAttribute("where", ""); if (roll != null && roll != "" && date != null && date != "") { rolls.Add(date + ":" + where + Util.DTToYearString(date) + "-" + roll); } } AddBillInfo(EnumsConv.BillTypeToString(bm.Type), bm.Session, bm.Number, (string[])rolls.ToArray(typeof(string)), title, statusstr, votes); }
/*public class Votes { * public object[] Data; * public int HasMore, Start; * public string Url; * }*/ public Hashtable GetVotes() { Hashtable votes = new Hashtable(); IList monitors; bool wascustom = false; if (HttpContext.Current.Request["monitors"] != null) { monitors = Login.ParseMonitors(HttpContext.Current.Request["monitors"]); wascustom = true; } else { monitors = Login.GetMonitors(); } foreach (string mon in monitors) { Monitor m = Monitor.FromString(mon); if (m == null) { continue; } if (m is SubjectCommitteeMonitor) { SubjectCommitteeMonitor scm = (SubjectCommitteeMonitor)m; GetSubjectVotes(Util.CurrentSession, scm.Type, scm.Term, votes); } if (m is ActiveBillsMonitor) { GetAllBillVotes(Util.CurrentSession, votes); } if (m is BillMonitor) { BillMonitor bm = (BillMonitor)m; GetVotesFromBill(bm, votes); } } if (votes.Count == 0 && !wascustom) { GetAllBillVotes(Util.CurrentSession, votes); } int start = 0; int count = 25; if (HttpContext.Current.Request["start"] != null) { start = int.Parse(HttpContext.Current.Request["start"]) - 1; } ArrayList ret1 = new ArrayList(votes.Values); ret1.Sort(new VoteSorter()); if (start + count > ret1.Count) { count = ret1.Count - start; } if (count < 0) { count = 0; } object[] ret = new object[count]; ret1.CopyTo(start, ret, 0, count); Hashtable v = new Hashtable(); v["Data"] = ret; v["Start"] = start + 1; v["HasMore"] = (ret1.Count > start + count) ? 1 : 0; string url = ""; if (HttpContext.Current.Request["people"] != null) { url += "&people=" + HttpContext.Current.Request["people"]; } if (HttpContext.Current.Request["monitors"] != null) { url += "&monitors=" + HttpContext.Current.Request["monitors"]; } v["Url"] = url; return(v); }