Exemplo n.º 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();
        }
Exemplo n.º 2
0
        ///
        /// Give the user an opportunity to update existing reports
        /// due to changes that have ocurred.
        public void Run(Form1 form1, UpdatedBillsForm update_form)
        {
            var start_time = DateTime.Now;

            try {
                LogAndDisplay(form1.txtBillUpdatesProgress, "Showing reports that need updating.");
                List <ChangedBillForDisplay> updated_bills = CollectUpdatedBills(form1, update_form);
                // Display those bills that have changed, or else a MessageBox saying nothing has changed
                if (updated_bills.Any())
                {
                    update_form.PrepareDataGridView();
                    update_form.AddRows(updated_bills);
                    update_form.ShowDialog();
                }
                else
                {
                    //MessageBox.Show("No bills have changed.  There is nothing to update");
                }
            } catch (Exception ex) {
                LogAndThrow($"UpdateExistingReports.Run: {ex.Message}.");
            }
            var elapsed = DateTime.Now - start_time;

            LogAndDisplay(form1.txtBillUpdatesProgress, $"Through with updating bill reports. Elapsed Time: {elapsed.ToString("c")} ");
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Run the program through the main sequence.
        /// Note that each case simply increments the seq SeqPoint.
        /// It is debateable whether this is the more readable way to write this.
        /// I think it is.
        /// </summary>
        /// <param name="form">The form on which these controls are displayed</param>
        /// <param name="seq">Next step on the main sequence</param>
        private static void Run(Form1 form, SeqPoint seq)
        {
            bool are_table_files_present = BeforeEnteringMainSequence(form); // Initialize before entering the main sequence.

            if (are_table_files_present || seq <= SeqPoint.extractFromZip)
            {
                var update_form     = new UpdatedBillsForm();
                var unreported_form = new UnreportedBillsForm();
                while (seq != SeqPoint.complete)      // While the main sequence is not complete
                {
                    switch (seq)                      // Perform the current step in the sequence
                    {
                    case SeqPoint.importFromLegSite:
                        new LegSiteController().Run(form); // Download the latest leginfo zip file, which is a zipped file.
                        seq++;
                        break;

                    case SeqPoint.extractFromZip:
                        new ZipController().Run(form); // Extract the contents of the downloaded zip file.
                        if (!are_table_files_present)  // If could not fill database from unzipped table files
                        {
                            if (!BeforeEnteringMainSequence(form))
                            {
                                throw new ApplicationException($"SequenceController.Run: Table files missing, cannot initialize database.");
                            }
                        }
                        seq++;
                        break;

                    case SeqPoint.importToDB:
                        new ImportController().Run(form);// Update the database with the latest data on the bill's text, status, committee location, etc.
                        seq++;
                        break;

                    case SeqPoint.regenBillReports:
                        new Regenerate().Run(form);   // Regenerate the individual bill reports.  In particular, update the bill's history
                        seq++;
                        break;

                    case SeqPoint.updateBillReports:
                        new UpdateExistingReports().Run(form, update_form);// User updates existing bill reports
                        seq++;
                        break;

                    case SeqPoint.createBillReports:
                        new CreateNewReports().Run(form, unreported_form);// User creates reports for newly found bills of interest
                        seq++;
                        break;

                    case SeqPoint.weeklyReport:
                        new WeeklyReport().Run(form); // Generate the weekly report
                        seq++;
                        break;

                    default:
                        throw new ApplicationException($"SequenceControl.Run: Invalid sequence point {seq} encountered.");
                    }
                }
            }
            else
            {
                string msg = "At least one of BILL_HISTORY_TBL.dat, BILL_VERSION_TBL.dat, LOCATION_CODE_TBL.dat are not present.";
                LogAndShow(msg);
                throw new ApplicationException($"SequenceControl.Run: {msg}");
            }
        }