public static ArrayList LoadBillAvailabeTextVersions() { BillType type; int session, number; ParseBill2(out session, out type, out number); ArrayList ret = new ArrayList(); string[][] statuses = Bills.GetBillTextStatusCodes(type); foreach (string[] s in statuses) { bool hashtml = System.IO.File.Exists(Bills.GetBillTextFileName(session, type, number, "html", s[0], null)); bool hastxt = System.IO.File.Exists(Bills.GetBillTextFileName(session, type, number, "txt", s[0], null)); if (!hashtml && !hastxt) { continue; } Hashtable h = new Hashtable(); h["code"] = s[0]; h["name"] = s[1]; h["description"] = s[2]; h["format"] = (hashtml ? "html" : "text"); h["size"] = (hashtml ? new System.IO.FileInfo(Bills.GetBillTextFileName(session, type, number, "html", s[0], null)).Length : 0); ret.Add(h); try { XmlDocument mods = new XmlDocument(); XmlNamespaceManager ns = new XmlNamespaceManager(mods.NameTable); ns.AddNamespace("mods", "http://www.loc.gov/mods/v3"); mods.Load(Bills.GetBillTextFileName(session, type, number, "mods.xml", s[0], null)); h["sortdate"] = mods.SelectSingleNode("mods:mods/mods:originInfo/mods:dateIssued", ns).InnerText; h["date"] = Util.DTToDateString((string)h["sortdate"]); } catch (Exception e) { // remove this try block when we fill in the missing files h["date"] = "No Date"; } } ret.Reverse(); return(ret); }
public static object LoadBillText() { BillType type; int session, number; ParseBill2(out session, out type, out number); string format = "html"; string version = HttpContext.Current.Request["version"]; string compareto = HttpContext.Current.Request["compareto"]; if (version == null) { string[][] statuses = Bills.GetBillTextStatusCodes(type); foreach (string[] s in statuses) { if (System.IO.File.Exists(Bills.GetBillTextFileName(session, type, number, format, s[0], null))) { version = s[0]; } } if (version == null) { if (format == "html") { format = "txt"; foreach (string[] s in statuses) { if (System.IO.File.Exists(Bills.GetBillTextFileName(session, type, number, format, s[0], null))) { version = s[0]; } } if (version == null) { return(TextNotAvailable()); } } } compareto = null; } else { foreach (char c in version) { if (!char.IsLetter(c) && !char.IsDigit(c)) { throw new UserException("Invalid bill version code."); } } if (compareto != null) { foreach (char c in compareto) { if (!char.IsLetter(c) && !char.IsDigit(c)) { throw new UserException("Invalid bill version code (compareto)."); } } } } try { object ret = Bills.LoadBillText(session, type, number, format, version, compareto); if (ret is string) { Hashtable x = new Hashtable(); x["text"] = ret; ret = x; } return(ret); } catch (System.IO.IOException e) { Console.Error.WriteLine(e); return(TextNotAvailable()); } }