Example #1
0
        ///
        /// Give the user an opportunity to create new reports
        /// for those bills having the highest scores.
        public void Run(Form1 form1, UnreportedBillsForm upreported_form)
        {
            var start_time = DateTime.Now;

            try {
                LogAndDisplay(form1.txtCreatesProgress, "Showing bills that have no report.");
                var bills_with_no_position = CollectNoPositionBills();
                var bills_for_display      = Convert(bills_with_no_position);
                // Display those bills that have no report.
                if (bills_for_display.Any())
                {
                    upreported_form.PrepareDataGridView();
                    upreported_form.AddRows(bills_for_display);
                    upreported_form.ShowDialog();
                }
                else
                {
                    MessageBox.Show("All bills apparently have an associated report.  I do not believe this.");
                }
            } catch (Exception ex) {
                LogAndThrow($"CreateNewReports.Run: {ex.Message}."); //
            }
            var elapsed = DateTime.Now - start_time;

            LogAndDisplay(form1.txtCreatesProgress, $"Through with bill report creation. Elapsed Time: {elapsed.ToString("c")} ");
        }
Example #2
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}");
            }
        }