public bool Includes(String information, String separator) { if (Author.Contains(information) || Name.Contains(information) || (Author + separator + Name).Contains(information)) { return(true); } return(false); }
public BillReport(string file_path) { try { var lines = File.ReadLines(file_path).ToList(); // Find Author, Measure, Title var line = lines.Find(x => x.Contains("Title</b>:")); if (line == null) { throw new ApplicationException($"BillReport ctor: {file_path} contents has no title line."); } Measure = rx_measure.Match(line).ToString(); if (!Measure.Contains("B-")) { throw new ApplicationException($"BillReport ctor: {file_path} contents has no measure."); } Author = rx_author.Match(line).ToString(); if (!Author.Contains("(") || !Author.Contains(")")) { throw new ApplicationException($"BillReport ctor: {file_path} contents has no author."); } Author = Author.Trim(new[] { '(', ')' }); var index = line.IndexOf(')'); // Title follows closing author parenthese if (index < 0) { throw new ApplicationException($"BillReport ctor: {file_path} contents has no closing author parenthese."); } Title = line.Substring(index + 1).Trim(); // At least one space before title // Find Position line = lines.Find(x => x.Contains("Position</b>:")); if (line == null) { throw new ApplicationException($"BillReport ctor: {file_path} contents has no position."); } index = line.IndexOf(':'); // Position follows colon Position = line.Substring(index + 1).Trim(); // At least one space before position // Find summary statement line = lines.Find(x => x.Contains("ShortSummary</b>:")); if (line == null) { throw new ApplicationException($"BillReport ctor: {file_path} contents has no summary statement."); } index = line.IndexOf(':'); // Summary follows colon OneLiner = line.Substring(index + 1).Trim(); // At least one space before summary // Find Last Action. The correct source for Last Action is the history data imported from the // legislature site. That data is considered original, data emitted by this program is derivative. BillUtils.ExtractHouseNumber(Measure, out string house, out string number); var bill_id = $"{house}{number}"; BillHistoryRow mostRecent = GlobalData.HistoryTable.LatestFromHouseNumber(bill_id); LastAction = $"{DateUtils.Date(mostRecent.ActionDate)} {mostRecent.Action}"; LastAction = LastAction.Replace("''", "'"); // Governor''s becomes Governor's // Find WIC (Welfare and Institutions Code) and LPS (Lanterman-Petris-Short Act) var most_recent = GlobalData.MostRecentEachBill .Where(row => row.BillID == BillUtils.Ensure4DigitNumber(Measure)).FirstOrDefault(); if (most_recent != null) { if (File.Exists(most_recent.LobPath)) { var contents = FileUtils.FileContents(most_recent.LobPath); // Need text without CRLF var match_string = @"Section\s+\d+.*?Welfare\s+and\s+Institutions\s+Code"; MatchCollection matches = Regex.Matches(contents, match_string); WIC = matches.Count > 0 ? "Yes" : "No"; // Is WIC if WIC referenced LPS = "No"; // LPS defaults to "No" if (WIC == "Yes") { foreach (var match in matches) { var str = match.ToString(); var section_number = Regex.Match(str, @"\d+").ToString(); if (Int64.TryParse(section_number, out long numberResult)) { // If section is between 5000 and 6000, Lanterman-Petris_Short is referenced if (numberResult >= 5000 && numberResult < 6000) { LPS = "Yes"; } } } } } } else { //throw new ApplicationException($"BillReport.ctor({file_path}): {Measure} not in GlobalData.MostRecentEachBill"); } } catch (Exception ex) { BaseController.LogAndShow(ex.Message); throw; } }