Exemplo n.º 1
0
        private void GenerateAndShowReport(ReportSectionDisplayType reportPartType)
        {
            // Create the objects collection that are going to be presented in the report


            /* Create the report contents with the type of display.
             *
             * Table: to display the collection as a HTML table in the report
             * Label: to display the collection as a HTML label in the report
             * Paragraph: to display the collection as a HTML paragraph in the report
             * */

            // Generate the report
            IReportBuilder reportGenerator = new HtmlReportBuilder();

            reportGenerator.AppendReportSection(
                reportPartType,
                this.GetReportData(),
                "Employee list",
                "You are truely appreciated for all your effort in each day.");

            var htmlReport = reportGenerator.Build(
                "Employee list",
                "Below is the list of our employees.",
                "Copyright © MyCompany");

            this.ShowReport(htmlReport);
            this.SaveReport(htmlReport);
        }
Exemplo n.º 2
0
        private async Task <string> GenerateLargeReportAsync(ReportSectionDisplayType reportPartType, int count)
        {
            // Create the objects collection that are going to be presented in the report


            /* Create the report contents with the type of display.
             *
             * Table: to display the collection as a HTML table in the report
             * Label: to display the collection as a HTML label in the report
             * Paragraph: to display the collection as a HTML paragraph in the report
             * */

            // Demo purpose only. Wait for 10 seconds.
            await Task.Delay(10000);

            // Generate the report
            IReportBuilder reportGenerator = new HtmlReportBuilder();

            reportGenerator.AppendReportSection(
                reportPartType,
                this.GetReportLargeData(count),
                "Employee list",
                "You are truely appreciated for all your effort in each day.");

            var htmlReport = reportGenerator.Build(
                "Employee list",
                "Below is the list of our employees.",
                "Copyright © MyCompany",
                currentToken);

            return(htmlReport);
        }
Exemplo n.º 3
0
        private string GenerateReportUsingHtmlReportBuilder(
            ReportSectionDisplayType reportPartType,
            CancellationToken cancellationToken,
            IList <Employee> reportData,
            string xsltPath = null)
        {
            // Generate the report
            IReportBuilder reportGenerator;

            if (string.IsNullOrWhiteSpace(xsltPath))
            {
                reportGenerator = new HtmlReportBuilder();
            }
            else
            {
                reportGenerator = new HtmlReportBuilder(xsltPath);
            }

            reportGenerator.AppendReportSection(
                reportPartType,
                reportData,
                "Employee list",
                "You are truely appreciated for all your effort in each day.",
                cancellationToken);
            var htmlReport = reportGenerator.Build(
                "Employee list",
                "Below is the list of our employees.",
                "Copyright © MyCompany",
                cancellationToken);

            return(htmlReport);
        }
Exemplo n.º 4
0
        private void BtnMultiPartReport_Click(object sender, EventArgs e)
        {
            IObjectToXmlConverterFactory factory = new ObjectToXmlConverterFactory();
            IReportBuilder reportGenerator       = new HtmlReportBuilder(factory);

            // Create the objects collection that are going to be presented in the report
            IList <Blogger> bloggersCollection = new List <Blogger>
            {
                new Blogger(1, "Satheesh Krishnasamy."),
                new Blogger(2, "Martin Fowler")
            };



            /* Create the report contents with the type of display.
             *
             * Table: to display the collection as a HTML table in the report
             * Label: to display the collection as a HTML label in the report
             * Paragraph: to display the collection as a HTML paragraph in the report
             * */
            reportGenerator.AppendReportSection(
                ReportSectionDisplayType.Table,
                bloggersCollection,
                "Bloggers list",
                "You are truely appreciated for all your effort in each day. Wish you all thebest !!!!!",
                currentToken);


            // Create the objects collection that are going to be presented in the report
            IList <Article> articleCollection = new List <Article>
            {
                new Article("How safe is the anti-forgery token?", "This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token."),
                new Article("How safe is the viewstate field?", "This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. ")
            };


            // Generate the report


            reportGenerator.AppendReportSection(ReportSectionDisplayType.Paragraph,
                                                articleCollection,
                                                "Article published today",
                                                DateTime.Now.ToLongTimeString());

            reportGenerator.AppendReportSection(ReportSectionDisplayType.Label,
                                                articleCollection,
                                                "Article published today",
                                                DateTime.Now.ToLongTimeString());

            var htmlReport = txtXmlReport.Text = reportGenerator.Build("My blog", "Articles published today.", "Copyright © MyCompany");
            // save the file
            var          reportFilePath = $"Reports\\HTMLReport_{DateTime.Now.ToString("yyyyMMddhhmmss")}.html";
            IReportSaver saver          = new ReportFileSaver();

            saver.SaveReport(Path.Combine(Environment.CurrentDirectory, reportFilePath), htmlReport, true);
            OpenFolderInWindowsExplorer(reportFilePath, "");
        }
Exemplo n.º 5
0
        public void CreateHtmlReportFileTest()
        {
            // arrange
            var rss        = new HtmlReportBuilder();
            var xmlPath    = ReturnXmlFullPath("books.xml", HtmlReport);
            var outputPath = ReturnXmlFullPath("", HtmlReport, "Output");

            // act
            rss.CreateRssFeedFile(xmlPath, Path.Combine(AppDirectory, outputPath));
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            ResultDirectory = args.FirstOrDefault(it => it.StartsWith(WriteOutput.ResultDirectoryArgumentName))?.Replace(WriteOutput.ResultDirectoryArgumentName, "");

            Console.WriteLine($"Results Directory is: {ResultDirectory}");

            if (ResultDirectory == null)
            {
                return;
            }

            var scenarios = GetScenarios(ResultDirectory);
            var testTimer = GetTestTimer(scenarios);

            var reportPathByStory      = Path.Combine(ResultDirectory, FileNames.ReportByStory);
            var reportPathAllScenarios = Path.Combine(ResultDirectory, FileNames.ReportAllScenarios);
            var testDataJsonPath       = Path.Combine(ResultDirectory, FileNames.TestDataJson);
            var testDataXmlPath        = Path.Combine(ResultDirectory, FileNames.TestDataXml);

            DeleteExistingFiles(reportPathByStory, reportPathAllScenarios, testDataJsonPath, testDataXmlPath);

            var warnings = GetWarnings();

            scenarios.AddRange(warnings.StoppedEarlyTests);

            var dataToOutput = new DataOutputModel
            {
                Scenarios = scenarios,
                TestTimer = testTimer,
                Warnings  = warnings
            };

            var settings = new JsonSerializerSettings
            {
                PreserveReferencesHandling = PreserveReferencesHandling.Objects
            };

            var jsonData = JsonConvert.SerializeObject(dataToOutput, Formatting.Indented, settings);

            File.WriteAllText(Path.Combine(ResultDirectory, FileNames.TestDataJson), jsonData);
            File.WriteAllText(Path.Combine(ResultDirectory, FileNames.TestDataXml), JsonConvert.DeserializeXmlNode(jsonData, "TestData").ToXmlString());

            HtmlReportBuilder.CreateReport(dataToOutput);

            try
            {
                CopyFolder.Copy(Path.Combine(FileLocations.ProjectDirectory, "css"), Path.Combine(ResultDirectory, "css"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 7
0
        public static void Main(string[] args)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String resultsFolder = "target"+java.io.File.separatorChar+"results";
            string resultsFolder = "target" + Path.DirectorySeparatorChar + "results";
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String reportsFolder = "target"+java.io.File.separatorChar+"reports";
            string reportsFolder = "target" + Path.DirectorySeparatorChar + "reports";

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String htmlReportFilename = reportsFolder + java.io.File.separatorChar + "sql-statement-log-report.html";
            string htmlReportFilename = reportsFolder + Path.DirectorySeparatorChar + "sql-statement-log-report.html";

            const string jsonReportFilename = "sql-statement-log-report.json";
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String jsonReportPath = reportsFolder + java.io.File.separatorChar + jsonReportFilename;
            string jsonReportPath = reportsFolder + Path.DirectorySeparatorChar + jsonReportFilename;

            const string csvReportFilename = "sql-statement-log-report.csv";
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String csvReportPath = reportsFolder + java.io.File.separatorChar + csvReportFilename;
            string csvReportPath = reportsFolder + Path.DirectorySeparatorChar + csvReportFilename;

            // make sure reports folder exists
            File reportsFolderFile = new File(reportsFolder);

            if (!reportsFolderFile.exists())
            {
                reportsFolderFile.mkdir();
            }

            SqlStatementCountAggregator aggregator        = new SqlStatementCountAggregator(resultsFolder);
            TabularResultSet            aggregatedResults = aggregator.execute();

            // write Json report
            JsonUtil.writeObjectToFile(jsonReportPath, aggregatedResults);
            // write CSV Report
            CsvUtil.saveResultSetToFile(csvReportPath, aggregatedResults);

            // format HTML report
            HtmlReportBuilder reportWriter = (new HtmlReportBuilder(aggregatedResults)).name("Sql Statement Log Report").resultDetailsFolder(".." + Path.DirectorySeparatorChar + "results" + Path.DirectorySeparatorChar).createImageLinks(true).jsonSource(jsonReportFilename).csvSource(csvReportFilename);

            string report = reportWriter.execute();

            FileUtil.writeStringToFile(report, htmlReportFilename);
        }
Exemplo n.º 8
0
        private static void writeReport(string resultsFolder, string reportsFolder, string benchmarkName, TabularResultAggregator aggregator, string reportDescription)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String htmlReportFilename = reportsFolder + java.io.File.separatorChar + benchmarkName+"-report.html";
            string htmlReportFilename = reportsFolder + Path.DirectorySeparatorChar + benchmarkName + "-report.html";

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String jsonReportFilename = benchmarkName+"-report.json";
            string jsonReportFilename = benchmarkName + "-report.json";
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String jsonReportPath = reportsFolder + java.io.File.separatorChar + jsonReportFilename;
            string jsonReportPath = reportsFolder + Path.DirectorySeparatorChar + jsonReportFilename;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String csvReportFilename = benchmarkName+"-report.csv";
            string csvReportFilename = benchmarkName + "-report.csv";
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String csvReportPath = reportsFolder + java.io.File.separatorChar + csvReportFilename;
            string csvReportPath = reportsFolder + Path.DirectorySeparatorChar + csvReportFilename;

            // make sure reports folder exists
            File reportsFolderFile = new File(reportsFolder);

            if (!reportsFolderFile.exists())
            {
                reportsFolderFile.mkdir();
            }

            TabularResultSet aggregatedResults = aggregator.execute();

            // write Json report
            JsonUtil.writeObjectToFile(jsonReportPath, aggregatedResults);

            // format HTML report
            HtmlReportBuilder reportWriter = (new HtmlReportBuilder(aggregatedResults)).name(reportDescription).resultDetailsFolder(".." + Path.DirectorySeparatorChar + "results" + Path.DirectorySeparatorChar).createImageLinks(true).jsonSource(jsonReportFilename).csvSource(csvReportFilename);

            string report = reportWriter.execute();

            FileUtil.writeStringToFile(report, htmlReportFilename);

            // write CSV report
            CsvUtil.saveResultSetToFile(csvReportPath, aggregatedResults);
        }
        public void ShouldProduceExpectedHtml()
        {
            // somehow the scenario id keeps increasing on TC
            // resetting here explicitly
            Configurator.IdGenerator.Reset();

            // setting the culture to make sure the date is formatted the same on all machines
            using (new TemporaryCulture("en-GB"))
            {
                var model = new HtmlReportViewModel(
                    new DefaultHtmlReportConfiguration(),
                    new ReportTestData().CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds());

                var sut = new HtmlReportBuilder {
                    DateProvider = () => new DateTime(2014, 3, 25, 11, 30, 5)
                };
                var result = sut.CreateReport(model);
                Approvals.Verify(result);
            }
        }
        private void ExportReport()
        {
            var            resultsCollection = this.GetResults(chkGroupResults.Checked);
            IReportBuilder reportGenerator   = new HtmlReportBuilder();

            var errors = this.FilterBySeverity(resultsCollection, SeverityType.Error);

            if (errors.Count > 0)
            {
                reportGenerator.AppendReportSection(
                    ReportSectionDisplayType.Table,
                    errors,
                    "Severity: Error",
                    string.Empty);
            }

            var warnings = this.FilterBySeverity(resultsCollection, SeverityType.Warning);

            if (warnings.Count > 0)
            {
                reportGenerator.AppendReportSection(
                    ReportSectionDisplayType.Table,
                    warnings,
                    "Severity: warning",
                    string.Empty);
            }

            var infos = this.FilterBySeverity(resultsCollection, SeverityType.Info);

            if (infos.Count > 0)
            {
                reportGenerator.AppendReportSection(
                    ReportSectionDisplayType.Table,
                    infos,
                    "Severity: information",
                    string.Empty);
            }

            var appreciations = this.FilterBySeverity(resultsCollection, SeverityType.Appreciation);

            if (appreciations.Count > 0)
            {
                reportGenerator.AppendReportSection(
                    ReportSectionDisplayType.Table,
                    appreciations,
                    "Other good things",
                    string.Empty);
            }

            var htmlReport = reportGenerator.Build(
                "Analysis result",
                string.Empty,
                "Copyright © MyCompany");

            // save the file
            var          reportFilePath = $"Reports\\HTMLReport_{DateTime.Now.ToString("yyyyMMddhhmmss")}.html";
            IReportSaver saver          = new ReportFileSaver();

            saver.SaveReport(Path.Combine(Environment.CurrentDirectory, reportFilePath), htmlReport, true);
            openFolderInWindowsExplorer(reportFilePath, "");
        }
Exemplo n.º 11
0
        public static void Main(string[] args)
        {
            Args = string.Join(" ", args);

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            ResultDirectory = args.FirstOrDefault(it => it.StartsWith(Arguments.ResultDirectoryArgumentName))?.Replace(Arguments.ResultDirectoryArgumentName, "");

            SetSettingsFromArgs(args);

            if (string.IsNullOrWhiteSpace(ResultDirectory))
            {
                return;
            }

            var scenarios = GetScenarios(ResultDirectory);
            var testTimer = GetTestTimer(scenarios);

            var reportPathByStory      = Path.Combine(ResultDirectory, FileNames.ReportByStory);
            var reportPathAllScenarios = Path.Combine(ResultDirectory, FileNames.ReportAllScenarios);
            var testDataJsonPath       = Path.Combine(ResultDirectory, FileNames.TestDataJson);
            var testDataXmlPath        = Path.Combine(ResultDirectory, FileNames.TestDataXml);

            DeleteExistingFiles(reportPathByStory, reportPathAllScenarios, testDataJsonPath, testDataXmlPath);

            var warnings = GetWarnings();

            scenarios.AddRange(warnings.StoppedEarlyTests);

            var dataToOutput = new DataOutputModel
            {
                Scenarios = scenarios,
                TestTimer = testTimer,
                Warnings  = warnings
            };

            var settings = new JsonSerializerSettings
            {
                PreserveReferencesHandling = PreserveReferencesHandling.Objects
            };

            var jsonData = JsonConvert.SerializeObject(dataToOutput, Formatting.Indented, settings);


            WriteJsonOutput(jsonData);

            WriteXmlOutput(jsonData);

            PruneData();

            HtmlReportBuilder.CreateReport(dataToOutput);

            try
            {
                CopyFolder.Copy(Path.Combine(FileLocations.ProjectDirectory, "css"), Path.Combine(ResultDirectory, "css"));
            }
            catch (Exception)
            {
                // ignored
            }
        }