public void Run(Form1 form1) { var start_time = DateTime.Now; try { LogAndDisplay(form1.txtImportProgress, "Determining most recent version of each bill."); // Need to know which lob file describes the most recent version of each bill GlobalData.MostRecentEachBill = MostRecentBills.Identify(Config.Instance.BillsFolder); // Need to copy GlobalData.Profiles to a temporary, update the temporary, then copy the temporary back. // BillRanker.Compute(ref GlobalData.Profiles) results in // A property or indexer may not be passed as an out or ref parameter. // Property "Profiles" access returns temporary value. // "ref" argument must be an assignable value, field or array element. LogAndDisplay(form1.txtImportProgress, "Computing positive and negative scores for all bills."); List <BillProfile> mr_profiles = Profiles(GlobalData.MostRecentEachBill); // Prepare for ranking the bills BillRanker.Compute(ref mr_profiles); GlobalData.Profiles = mr_profiles; LogAndDisplay(form1.txtImportProgress, "Initializing BillRows from BILL_TBL.dat and elsewhere."); string path = $"{Path.Combine(Config.Instance.BillsFolder, "BILL_TBL.dat")}"; BuildBillRowsTable(form1, path, GlobalData.Profiles); // Update the database BillRows table LogAndDisplay(form1.txtImportProgress, "Clearing and rewriting BillRows in the database."); BillRow.WriteRowset(GlobalData.BillRows); } catch (Exception ex) { LogAndThrow($"InitializeBillRows.Run: {ex.Message}."); } var elapsed = DateTime.Now - start_time; LogAndDisplay(form1.txtImportProgress, $"BillRows initialization complete. Elapsed Time: {elapsed.ToString("c")} "); }
/// <summary> /// Create a collection of bill reports by iterating over the contents of the passed folder path. /// Ignore the file named WeeklyNewsMonitoredBills.html, as it is the weekly report. /// Each of the remaining files is a single bill report. Construct a BillReport for each. /// </summary> /// <param name="_report_folder">Path to folder containing individual bill reports.</param> public BillReportCollection(string _report_folder) { report_folder = _report_folder; reports = new List <BillReport>(); if (GlobalData.MostRecentEachBill.Count == 0) // True if starting later in sequence than "Import Into Database" { GlobalData.MostRecentEachBill = MostRecentBills.Identify(Config.Instance.BillsFolder); } List <string> files = Directory.GetFiles(report_folder, "*.html").ToList(); foreach (var file in files) { if (!file.Contains("WeeklyNewsMonitoredBills")) { reports.Add(new BillReport(file)); } } reports.Sort((a, b) => a.CompareByMeasure(b)); }