Ejemplo n.º 1
0
Archivo: Main.cs Proyecto: sotaria/gsf
        private void GenerateReportButton_Click(object sender, EventArgs e)
        {
            CompletenessReportGenerator completenessReportGenerator;
            double level4Threshold;
            double level3Threshold;

            using (FileDialog fileDialog = new SaveFileDialog())
            {
                fileDialog.DefaultExt = "pdf";
                fileDialog.Filter     = "PDF files|*.pdf|All files|*.*";

                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    completenessReportGenerator = new CompletenessReportGenerator()
                    {
                        TitleText         = TitleTextTextBox.Text,
                        CompanyText       = CompanyTextTextBox.Text,
                        ReportDate        = new DateTime(ReportDateDateTimePicker.Value.Ticks, DateTimeKind.Utc),
                        Level4Alias       = Level4AliasTextBox.Text,
                        Level3Alias       = Level3AliasTextBox.Text,
                        GenerateCsvReport = GenerateCsvReportCheckBox.Checked,
                        ReportFilePath    = fileDialog.FileName
                    };

                    if (double.TryParse(Level4ThresholdTextBox.Text, out level4Threshold))
                    {
                        completenessReportGenerator.Level4Threshold = level4Threshold;
                    }

                    if (double.TryParse(Level3ThresholdTextBox.Text, out level3Threshold))
                    {
                        completenessReportGenerator.Level3Threshold = level3Threshold;
                    }

                    completenessReportGenerator.GenerateReport().Save(fileDialog.FileName);
                }
            }
        }
Ejemplo n.º 2
0
        private static void GenerateCompletenessReport()
        {
            CompletenessReportGenerator completenessReportGenerator = new CompletenessReportGenerator();
            Arguments args = new Arguments(Environment.CommandLine, true);
            string    arg;

            string   reportLocation = "";
            string   reportFileName = "";
            DateTime reportDate     = DateTime.UtcNow;
            double   threshold;

            if (TryGetValue(args, "archiveLocation", out arg))
            {
                completenessReportGenerator.ArchiveLocation = arg;
            }

            if (TryGetValue(args, "reportLocation", out arg))
            {
                reportLocation = arg;
            }

            if (TryGetValue(args, "reportFileName", out arg))
            {
                reportFileName = arg;
            }

            if (TryGetValue(args, "title", out arg))
            {
                completenessReportGenerator.TitleText = arg;
            }

            if (TryGetValue(args, "company", out arg))
            {
                completenessReportGenerator.CompanyText = arg;
            }

            if (TryGetValue(args, "reportDate", out arg) && DateTime.TryParse(arg, out reportDate))
            {
                if (reportDate.Kind == DateTimeKind.Unspecified)
                {
                    reportDate = new DateTime(reportDate.Ticks, DateTimeKind.Utc);
                }

                completenessReportGenerator.ReportDate = reportDate;
            }

            if (TryGetValue(args, "level4Threshold", out arg) && double.TryParse(arg, out threshold))
            {
                completenessReportGenerator.Level4Threshold = threshold;
            }

            if (TryGetValue(args, "level3Threshold", out arg) && double.TryParse(arg, out threshold))
            {
                completenessReportGenerator.Level3Threshold = threshold;
            }

            if (TryGetValue(args, "level4Alias", out arg))
            {
                completenessReportGenerator.Level4Alias = arg;
            }

            if (TryGetValue(args, "level3Alias", out arg))
            {
                completenessReportGenerator.Level3Alias = arg;
            }

            if (string.IsNullOrEmpty(reportFileName))
            {
                reportFileName = string.Format("{0} {1:yyyy-MM-dd}.pdf", completenessReportGenerator.TitleText, completenessReportGenerator.ReportDate);
            }

            reportLocation = FilePath.GetAbsolutePath(reportLocation);

            if (!Directory.Exists(reportLocation))
            {
                Directory.CreateDirectory(reportLocation);
            }

            string reportFilePath = Path.Combine(reportLocation, reportFileName);

            // Generate PDF report
            completenessReportGenerator.GenerateReport().Save(reportFilePath);

            // E-mail PDF report if parameters were provided
            EmailReport(args, string.Format("{0} {1} for {2:MMMM dd, yyyy}", completenessReportGenerator.CompanyText, completenessReportGenerator.TitleText, reportDate), reportFilePath);
        }
Ejemplo n.º 3
0
        private static void GenerateCompletenessReport()
        {
            CompletenessReportGenerator completenessReportGenerator = new CompletenessReportGenerator();
            Arguments args = new Arguments(Environment.CommandLine, true);
            string    arg;

            string   reportLocation = "";
            string   reportFileName = "";
            DateTime reportDate;
            double   threshold;

            if (TryGetValue(args, "archiveLocation", out arg))
            {
                completenessReportGenerator.ArchiveLocation = arg;
            }

            if (TryGetValue(args, "reportLocation", out arg))
            {
                reportLocation = arg;
            }

            if (TryGetValue(args, "reportFileName", out arg))
            {
                reportFileName = arg;
            }

            if (TryGetValue(args, "title", out arg))
            {
                completenessReportGenerator.TitleText = arg;
            }

            if (TryGetValue(args, "company", out arg))
            {
                completenessReportGenerator.CompanyText = arg;
            }

            if (TryGetValue(args, "reportDate", out arg) && DateTime.TryParse(arg, out reportDate))
            {
                completenessReportGenerator.ReportDate = reportDate;
            }

            if (TryGetValue(args, "level4Threshold", out arg) && double.TryParse(arg, out threshold))
            {
                completenessReportGenerator.Level4Threshold = threshold;
            }

            if (TryGetValue(args, "level3Threshold", out arg) && double.TryParse(arg, out threshold))
            {
                completenessReportGenerator.Level3Threshold = threshold;
            }

            if (TryGetValue(args, "level4Alias", out arg))
            {
                completenessReportGenerator.Level4Alias = arg;
            }

            if (TryGetValue(args, "level3Alias", out arg))
            {
                completenessReportGenerator.Level3Alias = arg;
            }

            if (string.IsNullOrEmpty(reportFileName))
            {
                reportFileName = string.Format("{0} {1:yyyy-MM-dd}.pdf", completenessReportGenerator.TitleText, completenessReportGenerator.ReportDate);
            }

            reportLocation = FilePath.GetAbsolutePath(reportLocation);

            if (!Directory.Exists(reportLocation))
            {
                Directory.CreateDirectory(reportLocation);
            }

            completenessReportGenerator.GenerateReport().Save(Path.Combine(reportLocation, reportFileName));
        }
Ejemplo n.º 4
0
        private static void GenerateCompletenessReport()
        {
            try
            {
                CompletenessReportGenerator completenessReportGenerator = new CompletenessReportGenerator();
                Arguments args = new Arguments(Environment.CommandLine, true);

                string   reportLocation = "";
                string   reportFileName = "";
                DateTime reportDate     = DateTime.UtcNow;

                if (TryGetValue(args, "archiveLocation", out string arg))
                {
                    completenessReportGenerator.ArchiveLocation = arg;
                }

                if (TryGetValue(args, "reportLocation", out arg))
                {
                    reportLocation = arg;
                }

                if (TryGetValue(args, "reportFileName", out arg))
                {
                    reportFileName = arg;
                }

                if (TryGetValue(args, "title", out arg))
                {
                    completenessReportGenerator.TitleText = arg;
                }

                if (TryGetValue(args, "company", out arg))
                {
                    completenessReportGenerator.CompanyText = arg;
                }

                if (TryGetValue(args, "reportDate", out arg) && DateTime.TryParse(arg, out reportDate))
                {
                    if (reportDate.Kind == DateTimeKind.Unspecified)
                    {
                        reportDate = new DateTime(reportDate.Ticks, DateTimeKind.Utc);
                    }

                    completenessReportGenerator.ReportDate = reportDate;
                }

                if (TryGetValue(args, "level4Threshold", out arg) && double.TryParse(arg, out double threshold))
                {
                    completenessReportGenerator.Level4Threshold = threshold;
                }

                if (TryGetValue(args, "level3Threshold", out arg) && double.TryParse(arg, out threshold))
                {
                    completenessReportGenerator.Level3Threshold = threshold;
                }

                if (TryGetValue(args, "level4Alias", out arg))
                {
                    completenessReportGenerator.Level4Alias = arg;
                }

                if (TryGetValue(args, "level3Alias", out arg))
                {
                    completenessReportGenerator.Level3Alias = arg;
                }

                if (TryGetValue(args, "generateCsvReport", out arg) && bool.TryParse(arg, out bool generateCsvReport))
                {
                    completenessReportGenerator.GenerateCsvReport = generateCsvReport;
                }

                if (string.IsNullOrEmpty(reportFileName))
                {
                    reportFileName = $"{completenessReportGenerator.TitleText} {completenessReportGenerator.ReportDate:yyyy-MM-dd}.pdf";
                }

                reportLocation = FilePath.GetAbsolutePath(reportLocation);

                if (!Directory.Exists(reportLocation))
                {
                    Directory.CreateDirectory(reportLocation);
                }

                completenessReportGenerator.ReportFilePath = Path.Combine(reportLocation, reportFileName);

                // Generate PDF report
                completenessReportGenerator.GenerateReport().Save(completenessReportGenerator.ReportFilePath);

                // E-mail PDF report if parameters were provided
                EmailReport(args, $"{completenessReportGenerator.CompanyText} {completenessReportGenerator.TitleText} for {reportDate:MMMM dd, yyyy}", completenessReportGenerator.ReportFilePath);
            }
            catch (Exception ex)
            {
                Log.Publish(MessageLevel.Error, "GenerateCompletenessReport", exception: ex);
            }
        }