Пример #1
0
        ///
        /// Collect all bills that have been updated since the last report written on that bill.
        /// Display a report listing those bills.
        public void Run(Form1 form1, UpdatedBillsForm update_form)
        {
            var start_time = DateTime.Now;

            try {
                // Collect all bill history for the current biennium.
                // Collect all bill reports written for the current biennium.
                var history = BillHistoryRow.RowSet();
                var individual_bill_reports = new BillReportCollection(Config.Instance.HtmlFolder);

                // Collect those bills that have been updated since the last report written on that bill.
                var updated_bills = new List <ChangedBillForDisplay>();
                foreach (var bill in individual_bill_reports)
                {
                    if (IsUpdated(bill, history, out string history_latest_action))
                    {
                        string last_action_date = ExtractLeadingDate(bill.LastAction);
                        updated_bills.Add(new ChangedBillForDisplay(bill.Measure, bill.Position, last_action_date, history_latest_action));
                    }
                }
                update_form.PrepareDataGridView();
                update_form.AddRows(updated_bills);
                update_form.ShowDialog();
            } catch (Exception ex) {
                LogAndThrow($"BillUpdates.Run: {ex.Message}.");
            }
            var elapsed = DateTime.Now - start_time;
            var message = $"Bill Updates report complete. Elapsed Time: {elapsed.ToString("c")} ";

            LogThis(message);
            form1.txtBillUpdatesProgress.Text = message;
            form1.txtBillUpdatesProgress.Update();
        }
Пример #2
0
        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")} ");
        }
Пример #3
0
        private List <ChangedBillForDisplay> CollectUpdatedBills(Form1 form1, UpdatedBillsForm update_form)
        {
            // Collect all bill history for the current biennium.
            // Collect all bill reports written for the current biennium.
            var history = BillHistoryRow.RowSet();
            var individual_bill_reports = new BillReportCollection(Config.Instance.HtmlFolder);

            // Collect those bills that have been updated since the last report written on that bill.
            var updated_bills = new List <ChangedBillForDisplay>();

            foreach (var bill in individual_bill_reports)
            {
                if (IsUpdated(bill, history, out string history_latest_action))
                {
                    string last_action_date = ExtractLeadingDate(bill.LastAction);
                    updated_bills.Add(new ChangedBillForDisplay(bill.Measure, bill.Position, last_action_date, history_latest_action));
                }
            }
            return(updated_bills);
        }
Пример #4
0
        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;
            }
        }