public void Run(Form1 form1) { var start_time = DateTime.Now; try { LogAndDisplay(form1.txtImportProgress, "Initializing BillRows."); new InitializeBillRows().Run(form1); LogAndDisplay(form1.txtImportProgress, "Writing Bill Version table."); BillVersionTable.ClearYourself(); BillVersionRow.WriteRowset(GlobalData.VersionTable.Table); LogAndDisplay(form1.txtImportProgress, "Writing Bill History table."); BillHistoryTable.ClearYourself(); BillHistoryRow.WriteRowset(GlobalData.HistoryTable.Table); LogAndDisplay(form1.txtImportProgress, "Writing Bill Location table."); LocationCodeTable.ClearYourself(); LocationCodeRow.WriteRowset(GlobalData.LocationTable.Table); } catch (Exception ex) { LogAndThrow($"ZipController.Run: {ex.Message}."); } var elapsed = DateTime.Now - start_time; LogAndDisplay(form1.txtImportProgress, $"Data has been imported from legislative files to the local database. Elapsed Time: {elapsed.ToString("c")} "); }
private DateTime DateFromHistoryTable(string path) { string bill = Path.GetFileNameWithoutExtension(path); BillRow row = BillRow.Row(BillUtils.Ensure4DigitNumber(bill)); string name_ext = Path.GetFileName(row.Lob); // BillVersionTable bill_xml is unique BillVersionRow bv_row = GlobalData.VersionTable.Scalar(name_ext); List <BillHistoryRow> history = GlobalData.HistoryTable.RowSet(bv_row.BillID); DateTime.TryParse(history.First().ActionDate, out DateTime date_result); return(date_result); }
private static void Update(List <BillRow> result, int index) { string name_ext = Path.GetFileName(result[index].Lob); // BillVersionTable bill_xml is unique BillVersionRow bv_row = GlobalData.VersionTable.Scalar(name_ext); List <BillHistoryRow> history = GlobalData.HistoryTable.RowSet(bv_row.BillID); var location_code = history.First().TernaryLocation; var location_code_row = GlobalData.LocationTable.Scalar(location_code); result[index].Location = history.First().PrimaryLocation; result[index].Location2nd = location_code_row?.LongDescription; if (result[index].Location2nd == null) { result[index].Location2nd = location_code; // e.g. "Third Reading" } result[index].MeasureState = "m state"; result[index].CurrentHouse = history.First().PrimaryLocation; result[index].CurrentStatus = history.First().EndStatus; }
/// <summary> /// Before a bill is chaptered, the last action is the .First() line in the history. /// When a bill is chaptered, its history may not end with the "Chaptered by Secretary of State" because /// usually multiple actions take place on the same day. Therefore, for a chaptered bill, report /// the line containing "Chaptered by Secretary of State". It may not be the first line in the history. /// </summary> /// <param name="row">BillRow describing the bill being processed</param> /// <returns></returns> protected static string FindLastAction(BillRow row) { string name_ext = Path.GetFileName(row.Lob); // BillVersionTable bill_xml is unique BillVersionRow bv_row = GlobalData.VersionTable.Scalar(name_ext); List <BillHistoryRow> history = GlobalData.HistoryTable.RowSet(bv_row.BillID); string result = "Could not find last action."; if (row.MeasureState != "Chaptered") { result = history.First().Action; } else { var want_this = history.Find(x => x.Action.Contains("Chaptered by Secretary of State")); result = want_this.Action; } return(result); }
/// <summary> /// Generate a new individual report or re-generate one that already exists. /// </summary> /// <param name="row">Bill description from the BillRows table</param> /// <param name="path">Path to the .lob file for the bill's current version</param> /// <returns></returns> protected static List <string> BaseReportContents(BillRow row, string path) { string name_ext = Path.GetFileName(row.Lob); // BillVersionTable bill_xml is unique BillVersionRow bv_row = GlobalData.VersionTable.Scalar(name_ext); List <BillHistoryRow> history = GlobalData.HistoryTable.RowSet(bv_row.BillID); var location_code = history.First().TernaryLocation; var location_code_row = GlobalData.LocationTable.Scalar(location_code); string appropriation = bv_row.Appropriation; string author = row.Author; string bill_id = row.Bill; string fiscal = bv_row.FiscalCommittee; string house = history.First().PrimaryLocation; string last_action = FindLastAction(row); string location = location_code_row == null?BillUtils.WhenNullLocationCode(history) : location_code_row.Description; string local_pgm = bv_row.LocalProgram; string number = row.MeasureNum.TrimStart('0'); string title = row.Title; string type_house = $"{bill_id.First()}B"; string vers_id = row.BillVersionID; string vote = bv_row.VoteRequired; // Position and Summary data come from the previous version of the bill report // If the passed path is null or empty, then this method was called when no previous report exists. // When regenerating a report, there is a previous report. var summary = new List <string>(); var position = new List <string>(); var shortsummary = string.Empty; var committees = string.Empty; var likelihood = string.Empty; if (CommonUtils.IsNullOrEmptyOrWhiteSpace(path)) { // do nothing } else { summary = PreviousReport.Summary(path); position = PreviousReport.Position(path); shortsummary = PreviousReport.ShortSummary(path); committees = PreviousReport.Committees(path); likelihood = PreviousReport.Likelihood(path); } // With all necessary data obtained, generate the report file. // Both initial creation (new bill) and re-generation are processed here. List <string> result = BeginIndividualReport(type_house, number, author, title); // Review result.AddRange(ReportReview(summary)); // Position result.AddRange(ReportPosition(position)); // Short Summary, Committees Prediction and Passage Likelihood result.AddRange(ReportSummaryPredictLikelihood(shortsummary, committees, likelihood)); // Status, Location, etc result.AddRange(ReportStatusLocationEtc(location, last_action, vote, appropriation, fiscal, local_pgm, history)); // Bill History result.AddRange(ReportHistory(history)); return(result); }