Example #1
0
        /// <summary>
        /// When the initial report on a bill is generated, it is in so-called "canonical" form, meaning that
        /// no position is taken, there is no meaningful summary, and so on.  In essence, a blank form is generated.
        /// The user is then given the opportunity to edit the blank form, turning it into an actual report on the bill.
        /// Once that editing is complete, the database BillRow table is updated with the position given in the
        /// edited bill report.
        /// </summary>
        /// <param name="measure"></param>
        public static void GenerateCanonicalReport(string measure)
        {
            // Generate the canonical bill
            BillRow       row      = BillRow.Row(BillUtils.Ensure4DigitNumber(measure));
            List <string> contents = BaseReportContents(row, string.Empty);
            string        path     = $"{Path.Combine(Config.Instance.HtmlFolder, BillUtils.EnsureNoLeadingZerosBill(measure))}.html";

            WriteTextFile(contents, path);
            // Let the user edit the canonical bill, which has been written to disk.
            var process = Process.Start("notepad.exe", path);

            if (process != null)
            {
                process.WaitForExit();
            }
            else
            {
                LogAndShow($"CreateNewReports.GenerateCanonicalReport: Failed to start Notepad for {path}.");
            }
            // Update the database position
            BillRow.UpdatePosition(BillUtils.Ensure4DigitNumber(measure), "");
            GetPositionAndSummary(path, out List <string> summary, out List <string> position_list);
            string first_line = position_list.FirstOrDefault();
            string position   = first_line != null?Regex.Replace(first_line, ".*?:(.*)", "$1") : "None Specified";

            BillRow.UpdatePosition(measure, position.Trim());
            LogAndShow($"Completed {path}");
        }
Example #2
0
        /// <summary>
        /// Allow the user to update the current bill report.
        /// If the position is changed, the database BillRow table is updated with the new position.
        /// </summary>
        /// <param name="measure"></param>
        private void UpdateReport(string measure)
        {
            string path    = $"{Path.Combine(Config.Instance.HtmlFolder, BillUtils.EnsureNoLeadingZerosBill(measure))}.html";
            var    process = Process.Start("notepad.exe", path);

            if (process != null)
            {
                process.WaitForExit();
            }
            else
            {
                BaseController.LogAndShow($"CreateNewReports.GenerateCanonicalReport: Failed to start Notepad for {path}.");
            }
            // Update the database position
            BillRow.UpdatePosition(BillUtils.Ensure4DigitNumber(measure), "");
            BaseController.LogAndShow($"Update for {path} is complete.");
        }