private void GenerateReports(ITestListener testListener, Assembly assembly, ReportResult result) { try { string outputPath = GetAppDataPath(""); string nameFormat = assembly.GetName().Name + ".Tests"; string file = HtmlReport.RenderToHtml(result, outputPath, nameFormat); if (file != "") { Uri uri = new Uri("file:" + Path.GetFullPath(file).Replace("\\", "/")); testListener.TestResultsUrl(uri.AbsoluteUri); } else { testListener.WriteLine("Skipping report generation", Category.Info); } } catch (Exception ex) { testListener.WriteLine("failed to create reports", Category.Error); testListener.WriteLine(ex.ToString(), Category.Error); } }
void GenerateReports(ReportResult reportResult, string reportTypes) { Ensure.ArgumentIsNotNull(reportResult, "reportResult"); if (BuildEnvironment.IsTeamCityBuild) { TeamCityReportGenerator.RenderReport(reportResult, this); } if (String.IsNullOrEmpty(reportTypes)) { return; } Log(Level.Info, "Generating reports"); foreach (string reportType in reportTypes.Split(';')) { string reportFileName = null; Log(Level.Verbose, "Report type: {0}", reportType); switch (reportType.ToLower()) { case "text": reportFileName = TextReport.RenderToText(reportResult, ReportDirectory, ReportFileNameFormat); break; case "xml": reportFileName = XmlReport.RenderToXml(reportResult, ReportDirectory, ReportFileNameFormat); break; case "html": reportFileName = HtmlReport.RenderToHtml(reportResult, ReportDirectory, ReportFileNameFormat); break; case "dox": reportFileName = DoxReport.RenderToDox(reportResult, ReportDirectory, ReportFileNameFormat); break; case "transform": if (Transform == null) { throw new BuildException(String.Format("No transform specified for report type '{0}'", reportType)); } reportFileName = HtmlReport.RenderToHtml(reportResult, ReportDirectory, Transform.FullName, TransformReportFileNameFormat); break; default: Log(Level.Error, "Unknown report type {0}", reportType); break; } if (reportFileName != null) { Log(Level.Info, "Created report at {0}", reportFileName); } } }
protected override Task <int> Execute() { var consoleReport = new HtmlReport(HtmlOutputFolderOption.GetValue().FullName); var result = consoleReport.Execute(CoverageLoadedFileOption.GetValue(), ThresholdOption.GetValue()); return(Task.FromResult(result)); }
protected override void ProcessRecord() { base.ProcessRecord(); var logger = new CmdletLoggerPS(this, false); try { var generatedFiles = new List <string>(); var solutionRepository = new SolutionRepository(new CrmServiceClient(ConnectionString), logger); var solutionAuditor = new CrmAuditor(solutionRepository, logger); var publishersToInclude = RequiredPublishers.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList(); var crmInstance = solutionAuditor.AuditCrmInstance(InstanceName, publishersToInclude); logger.Verbose("About to generate HTML report"); var htmlWriter = new HtmlReport(OutputDir); var htmlFiles = htmlWriter.SaveSolutionAudit(crmInstance); generatedFiles.Add(htmlFiles.First(x => x.Contains("Home_"))); logger.Verbose("HTML report completed"); if (GenerateExcelReport) { logger.Verbose("About to generate Excel report"); var excelWriter = new ExcelReport(OutputDir); generatedFiles.AddRange(excelWriter.SaveSolutionAudit(crmInstance)); logger.Verbose("Excel report completed"); } if (GenerateJsonReport) { logger.Verbose("About to generate JSON report"); var jsonWriter = new JsonReport(OutputDir); generatedFiles.AddRange(jsonWriter.SaveSolutionAudit(crmInstance)); logger.Verbose("JSON report completed"); } if (GenerateXmlReport) { logger.Verbose("About to generate XML report"); var xmlWriter = new XmlReport(OutputDir); generatedFiles.AddRange(xmlWriter.SaveSolutionAudit(crmInstance)); logger.Verbose("XML report completed"); } if (!string.IsNullOrWhiteSpace(SendGridKey) && !string.IsNullOrWhiteSpace(ReportsToRecipients)) { SendReportsToRecipients(SendGridKey, ReportsToRecipients, crmInstance.Name.Replace(".dynamics.com", ""), generatedFiles, ReportName); } } catch (Exception exception) { var errorMessage = $"Dynamics365 solution audit failed: {exception.Message}"; logger.Verbose(errorMessage); logger.Error(errorMessage); throw; } }
protected override Task <int> Execute() { var consoleReport = new HtmlReport(_htmlOutputFolderOption.Value.FullName); var result = consoleReport.Execute(_coverageLoadedFileOption.Result, _thresholdOption.Value); return(Task.FromResult(result)); }
static void Main(string[] args) { var _logger = new ConsoleLogger(); var repository = new SolutionRepository(new CrmServiceClient(CrmConnectionString), _logger); var solutionAuditor = new CrmAuditor(repository, _logger); var publisherFilter = new List <string> { "Dynamics 365" }; var crmInstance = solutionAuditor.AuditCrmInstance(InstanceName, publisherFilter); var excelReport = new ExcelReport(_downloadsPath); excelReport.SaveSolutionAudit(crmInstance); var xmlReport = new XmlReport(_downloadsPath); xmlReport.SaveSolutionAudit(crmInstance); var htmlReport = new HtmlReport(_downloadsPath); htmlReport.SaveSolutionAudit(crmInstance); var jsonReport = new JsonReport(_downloadsPath); jsonReport.SaveSolutionAudit(crmInstance); }
IEnumerable <IBatchProcessor> _GetProcessors() { var htmlReporter = HtmlReport.ConstructFor(StoryCache.Stories); if (htmlReporter != null) { yield return(htmlReporter); } var htmlMetroReporter = HtmlMetroReport.ConstructFor(StoryCache.Stories); if (htmlMetroReporter != null) { yield return(htmlMetroReporter); } var markDown = MarkDownReport.ConstructFor(StoryCache.Stories); if (markDown != null) { yield return(markDown); } var diagnostics = DiagnosticsReport.ConstructFor(StoryCache.Stories); if (diagnostics != null) { yield return(diagnostics); } foreach (var addedProcessor in _addedProcessors) { yield return(addedProcessor); } }
public void ShouldWriteMetricInfoIntoBody() { var results = new MetricResultBuilder().CreateMetricResult(); var fileWriter = new FileWriter(); var report = new HtmlReport(fileWriter, "test2.html"); Assert.DoesNotThrow(() => report.Generate(results)); }
public static void AssemblyInitialize(TestContext context) { string url = Convert.ToString(context.Properties["SiteUrl"]); RunSettingsHelper.ReadRunSettings(context); report = new HtmlReport("Selenium Tests", RunSettingsHelper.SiteUrl, "", "Google Chrome", RunSettingsHelper.ScreenshotPath); report.StartReport(); _testContext = context; }
static void Main(string[] args) { // Parse arguments var options = new Options(); var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error)); if (!parser.ParseArguments(args, options)) { Environment.Exit(1); } // Coverage file parser MikeParser mikeParser = new MikeParser(); foreach (String s in options.IncludedNamespaces) { mikeParser.IncludeNamespace(s); } foreach (String s in options.ExcludedNamespaces) { mikeParser.ExcludeNamespace(s); } foreach (String s in options.IncludedFiles) { mikeParser.IncludeFile(s); } foreach (String s in options.ExcludedFiles) { mikeParser.ExcludeFile(s); } // Parse coverage file ProjectElement pe = mikeParser.Parse(options.InputFiles); // Generate clover report if (options.CloverOutput != null) { CloverReport cloverreport = new CloverReport(); using (StreamWriter outfile = new StreamWriter(options.CloverOutput)) { outfile.Write(cloverreport.Execute(pe)); } } // Generate html report if (options.HtmlOutput != null) { HtmlReport htmlreport = new HtmlReport(); using (StreamWriter outfile = new StreamWriter(options.HtmlOutput)) { outfile.Write(htmlreport.Execute(pe)); } } }
public virtual string toHTMLString(string reportName, HttpRequest request, float scale, int pageno) { PageBuilder builder = new PageBuilder(Cells, 0, 0); HtmlReport report = new HtmlReport(builder.getPage(pageno), reportName, request.ApplicationPath, request) { Scale = scale }; return(report.generateHtml()); }
public void ReportToHtml(string outputPath) { if (this.result == null) { AddLog("Result is a null reference. Make sure tests were executed succesfully"); return; } AddLog("Generating HTML report"); System.Diagnostics.Process.Start(HtmlReport.RenderToHtml(this.result, ReportBase.GetAppDataPath(outputPath), GetReportName())); }
public virtual string toHTMLString(string reportName, string domainAndPort, string appMap, float scale) { PageBuilder builder = new PageBuilder(Cells, 999999999, 999999999); HtmlReport report = new HtmlReport(builder.getPage(1), reportName, appMap, null) { AppRoot = domainAndPort.ToString() + appMap.ToString(), Scale = scale }; return(report.generateHtml()); }
public ReportDialog() { InitializeComponent(); _report = new HtmlReport(); _titleTable = _report.AddTable(new int[] { 500 }); _headerTable = _report.AddTable(new int[] { 500, 100, 100 }); // ReportForm = new RdlcCreator(); //ReportForm.InitRdlc("", "DataSet1", "", "", ""); }
public static async Task Main(string[] args) { var directory = "ComplexData"; var activities = await Activities(directory); var report = new HtmlReport(activities); using (var writer = File.CreateText("complex.html")) { await report.Write(writer); } }
public void GenerateHtmlReport() { string outputPath = HtmlReport.RenderToHtml(this.TestDomains.GetReport()); try { System.Diagnostics.Process.Start(outputPath); } catch (Win32Exception) { MessageBox.Show("An error has occurred while trying to load the default browswer. Please ensure the browser is setup correctly.", "Browser loading error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void testReport() { IList <Machine> line = new List <Machine>(); line.Add(new Machine("mixer", "left")); Machine extruder = new Machine("extruder", "center"); extruder.Put("paste"); line.Add(extruder); Machine oven = new Machine("oven", "right"); oven.Put("chips"); line.Add(oven); Robot robot = new Robot(); robot.MoveTo(extruder); robot.Pick(); StringWriter output = new StringWriter(); HtmlReport.report(output, line, robot); string expected = "<h1>FACTORY REPORT</h1>\n" + "<h2>mixer</h2>\n" + "<ul>\n" + "<li>location = left</li>\n" + "<li>no bin</li>\n" + "</ul>\n" + "<h2>extruder</h2>\n" + "<ul>\n" + "<li>location = center</li>\n" + "<li>no bin</li>\n" + "</ul>\n" + "<h2>oven</h2>\n" + "<ul>\n" + "<li>location = right</li>\n" + "<li>bin containing chips</li>\n" + "</ul>\n" + "<h2>Robot</h2>\n" + "<ul>\n" + "<li>location = extruder</li>\n" + "<li>bin containing paste</li>\n" + "</ul>\n"; Assert.That(expected, Is.EqualTo(output.ToString())); }
public String run() { DateTime timestamp = DateTime.Now; String html = HtmlReport.getHeader(); html += "<body>"; html += startApplication(); html += HtmlReport.getFooter(timestamp); Console.Out.WriteLine("Report ready!"); return(html); }
public String run() { DateTime timestamp = DateTime.Now; String html = HtmlReport.getHeader(); html += "<body>"; html += startApplication(); html += HtmlReport.getFooter(timestamp); log.Info("Report ready!"); return(html); }
public IReport ResolveReport(ReportType reportType, string reportName) { var fileWriter = new FileWriter(); IReport report = null; if (reportType == ReportType.Failing) report = new HtmlFailedReport(fileWriter, reportName); else if (reportType == ReportType.TopTen) report = new HtmlTopTenReport(fileWriter, reportName); else if (reportName.EndsWith (".xml")) report = new XmlReport (fileWriter, reportName); else report = new HtmlReport(fileWriter,reportName); return report; }
static void Main(string[] args_) { // run unit test AutoRunner auto = new AutoRunner(); auto.Load(); auto.Run(); HtmlReport report = new HtmlReport(); string fileName; // generate report results fileName = report.Render(auto.Result); // launch results in user's browser System.Diagnostics.Process.Start(fileName); }
private void RenderReport(string reportType) { this.Log.LogMessage("Render report {0}", reportType); string outputFileName = null; switch (reportType.ToLower()) { case "text": outputFileName = TextReport.RenderToText( result, this.ReportOutputDirectory, this.ReportFileNameFormat ); break; case "html": outputFileName = HtmlReport.RenderToHtml( result, this.ReportOutputDirectory, this.ReportFileNameFormat); break; case "xml": outputFileName = XmlReport.RenderToXml( result, this.ReportOutputDirectory, this.ReportFileNameFormat); break; case "dox": outputFileName = DoxReport.RenderToDox( result, this.ReportOutputDirectory, this.ReportFileNameFormat); break; default: this.Log.LogError("Report type {0} not recognized.", reportType); return; } this.Log.LogMessage("Generated {0} report at {1}", reportType, outputFileName); }
private void GenerateReports() { if (result == null) { throw new InvalidOperationException("Report object is a null reference."); } this.Log(Level.Info, "Generating reports"); foreach (string reportType in this.ReportTypes.Split(';')) { string reportName = null; this.Log(Level.Verbose, "Report type: {0}", reportType); switch (reportType.ToLower()) { case "text": reportName = TextReport.RenderToText(result, this.ReportOutputDirectory, this.ReportFileNameFormat); break; case "xml": reportName = XmlReport.RenderToXml(result, this.ReportOutputDirectory, this.ReportFileNameFormat); break; case "html": reportName = HtmlReport.RenderToHtml(result, this.ReportOutputDirectory, this.ReportFileNameFormat); break; case "dox": reportName = DoxReport.RenderToDox(result, this.ReportOutputDirectory, this.ReportFileNameFormat); break; default: this.Log(Level.Error, "Unknown report type {0}", reportType); break; } if (reportName != null) { this.Log(Level.Info, "Created report at {0}", reportName); } } }
private void GenerateReport(MainArguments parsedArgs, ReportResult result) { result.UpdateCounts(); if (parsedArgs.ReportTypes != null && parsedArgs.ReportTypes.Length > 0) { parsedArgs.ReportFolder = ReportBase.GetAppDataPath(parsedArgs.ReportFolder); consoleOut.WriteLine("[info] Creating reports in {0}", Path.GetFullPath(parsedArgs.ReportFolder)); foreach (ReportType rt in parsedArgs.ReportTypes) { string outputPath = null; switch (rt) { case ReportType.Xml: outputPath = XmlReport.RenderToXml(result, parsedArgs.ReportFolder, parsedArgs.Transform, parsedArgs.ReportNameFormat); consoleOut.WriteLine("[info] Created xml report {0}", outputPath); break; case ReportType.Html: outputPath = HtmlReport.RenderToHtml(result, parsedArgs.ReportFolder, parsedArgs.Transform, parsedArgs.ReportNameFormat); consoleOut.WriteLine("[info] Created Html report {0}", outputPath); break; case ReportType.Text: outputPath = TextReport.RenderToText(result, parsedArgs.ReportFolder, parsedArgs.Transform, parsedArgs.ReportNameFormat); consoleOut.WriteLine("[info] Created Text report {0}", outputPath); break; case ReportType.Dox: outputPath = DoxReport.RenderToDox(result, parsedArgs.ReportFolder, parsedArgs.ReportNameFormat); consoleOut.WriteLine("[info] Created Dox report {0}", outputPath); break; } if (parsedArgs.ShowReports && File.Exists(outputPath)) { System.Diagnostics.Process.Start(outputPath); } } } }
/// <summary> /// common steps for creating html report and upload /// </summary> internal static void CreateHtmlReportSteps(List <string> inputTestIds = null) { //Creating HTML Report try { LogFile.AllXmlFilesLocation = string.Join(";", FilePath); // Using new format of report. bool isSummaryRequired = Utility.GetParameter("SummaryReportRequired").ToLower().Equals("true"); bool htmlReportRequired = !Utility.GetParameter("HtmlReportRequired").ToLower().Equals("false"); LogFile.CreateHtmlReport(string.Empty, false, true, Property.IsSauceLabExecution); HtmlReport.CreateHtmlReport(string.Empty, false, true, Property.IsSauceLabExecution, isSummaryRequired, false, false, htmlReportRequired); GetReportSummary(); Property.FinalXmlPath = FilePath[FilePath.Length - 1]; } catch (Exception exception) { TestSuiteResult = 1; KryptonException.ReportException(exception.Data + "\n Message " + exception.Message + "\n StackTrace" + exception.StackTrace + "\n Line Number" + exception.StackTrace.Substring(exception.StackTrace.LastIndexOf(' '))); } Console.WriteLine(ConsoleMessages.MSG_DASHED); Console.WriteLine(ConsoleMessages.MSG_UPLOADING_LOG); Manager.UploadTestExecutionResults(); try { if (Utility.GetParameter("EmailNotification").Equals("true", StringComparison.OrdinalIgnoreCase)) { Utility.EmailNotification("end", false); //Email Notification after completion of the process } } catch (Exception) { Console.WriteLine(Utility.GetCommonMsgVariable("KRYPTONERRCODE0053")); throw; } }
public void HtmlReportTest() { string expected = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "movie.html"); if (File.Exists(expected)) { File.Delete(expected); } Movie movie1 = new Movie(); movie1.Name = "Oblivion"; movie1.PaymentForTomCruise = 2000000M; Movie movie2 = new Movie(); movie2.Name = "Edge of Tomorrow"; movie2.PaymentForTomCruise = 3000000M; CompareLogic compareLogic = new CompareLogic(); compareLogic.Config.MaxDifferences = Int32.MaxValue; ComparisonResult result = compareLogic.Compare(movie1, movie2); HtmlReport htmlReport = new HtmlReport(); // The config object is to overwrite the defaults htmlReport.Config.GenerateFullHtml = true; // if false, it will only generate an html table htmlReport.Config.HtmlTitle = "Comparison Report"; htmlReport.Config.BreadCrumbColumName = "Bread Crumb"; htmlReport.Config.ExpectedColumnName = "Expected"; htmlReport.Config.ActualColumnName = "Actual"; //htmlReport.Config.IncludeCustomCSS(".diff-crumb {background: gray;}"); // add some custom css htmlReport.OutputFile(result.Differences, expected); Assert.IsTrue(File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, expected))); htmlReport.LaunchApplication(expected); }
public void Render(MbUnit task, ReportResult result) { string nameFormat = "mbunit-{0}{1}"; string outputPath = ""; if (this.fileNameFormat.Length != 0) { nameFormat = fileNameFormat; } if (this.OutputDirectory.Length != 0) { outputPath = OutputDirectory; } string outputFileName = null; switch (this.Type) { case FormatterType.Text: outputFileName = TextReport.RenderToText(result, outputPath, nameFormat); break; case FormatterType.Html: outputFileName = HtmlReport.RenderToHtml(result, outputPath, nameFormat); break; case FormatterType.Xml: outputFileName = XmlReport.RenderToXml(result, outputPath, nameFormat); break; case FormatterType.Dox: outputFileName = DoxReport.RenderToDox(result, outputPath, nameFormat); break; } task.Log.LogMessage("Generated {0} report at {1}", this.Type, outputFileName); }
public IReport ResolveReport(ReportType reportType, string reportName) { var fileWriter = new FileWriter(); IReport report = null; if (reportType == ReportType.Failing) { report = new HtmlFailedReport(fileWriter, reportName); } else if (reportType == ReportType.TopTen) { report = new HtmlTopTenReport(fileWriter, reportName); } else if (reportName.EndsWith(".xml")) { report = new XmlReport(fileWriter, reportName); } else { report = new HtmlReport(fileWriter, reportName); } return(report); }
static int Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; var commandLineApplication = new CommandLineApplication(); commandLineApplication.Name = "MiniCover"; commandLineApplication.Description = "MiniCover - Code coverage for .NET Core via assembly instrumentation"; commandLineApplication.Command("instrument", command => { command.Description = "Instrument assemblies"; var workDirOption = CreateWorkdirOption(command); var includeAssembliesOption = command.Option("--assemblies", "Pattern to include assemblies [default: **/*.dll]", CommandOptionType.MultipleValue); var excludeAssembliesOption = command.Option("--exclude-assemblies", "Pattern to exclude assemblies", CommandOptionType.MultipleValue); var includeSourceOption = command.Option("--sources", "Pattern to include source files [default: **/*]", CommandOptionType.MultipleValue); var excludeSourceOption = command.Option("--exclude-sources", "Pattern to exclude source files", CommandOptionType.MultipleValue); var hitsFileOption = command.Option("--hits-file", "Hits file name [default: coverage-hits.txt]", CommandOptionType.SingleValue); var coverageFileOption = CreateCoverageFileOption(command); command.HelpOption("-h | --help"); command.OnExecute(() => { var workdir = UpdateWorkingDirectory(workDirOption); var assemblies = GetFiles(includeAssembliesOption, excludeAssembliesOption, "**/*.dll"); if (assemblies.Length == 0) { throw new Exception("No assemblies found"); } var sourceFiles = GetFiles(includeSourceOption, excludeSourceOption, "**/*.cs"); if (sourceFiles.Length == 0) { throw new Exception("No source files found"); } var hitsFile = GetHitsFile(hitsFileOption); var coverageFile = GetCoverageFile(coverageFileOption); var instrumenter = new Instrumenter(assemblies, hitsFile, sourceFiles, workdir); var result = instrumenter.Execute(); SaveCoverageFile(coverageFile, result); return(0); }); }); commandLineApplication.Command("uninstrument", command => { command.Description = "Uninstrument assemblies"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var result = LoadCoverageFile(coverageFile); Uninstrumenter.Execute(result); return(0); }); }); commandLineApplication.Command("report", command => { command.Description = "Outputs coverage report"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); var thresholdOption = CreateThresholdOption(command); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var threshold = GetThreshold(thresholdOption); var result = LoadCoverageFile(coverageFile); var consoleReport = new ConsoleReport(); return(consoleReport.Execute(result, threshold)); }); }); commandLineApplication.Command("htmlreport", command => { command.Description = "Write html report to folder"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); var thresholdOption = CreateThresholdOption(command); var outputOption = command.Option("--output", "Output folder for html report [default: coverage-html]", CommandOptionType.SingleValue); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var threshold = GetThreshold(thresholdOption); var result = LoadCoverageFile(coverageFile); var output = GetHtmlReportOutput(outputOption); var htmlReport = new HtmlReport(output); return(htmlReport.Execute(result, threshold)); }); }); commandLineApplication.Command("xmlreport", command => { command.Description = "Write an NCover-formatted XML report to folder"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); var thresholdOption = CreateThresholdOption(command); var outputOption = command.Option("--output", "Output file for NCover report [default: coverage.xml]", CommandOptionType.SingleValue); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var threshold = GetThreshold(thresholdOption); var result = LoadCoverageFile(coverageFile); var output = GetXmlReportOutput(outputOption); XmlReport.Execute(result, output, threshold); return(0); }); }); commandLineApplication.Command("opencoverreport", command => { command.Description = "Write an OpenCover-formatted XML report to folder"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); var thresholdOption = CreateThresholdOption(command); var outputOption = command.Option("--output", "Output file for OpenCover report [default: opencovercoverage.xml]", CommandOptionType.SingleValue); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var threshold = GetThreshold(thresholdOption); var result = LoadCoverageFile(coverageFile); var output = GetOpenCoverXmlReportOutput(outputOption); OpenCoverReport.Execute(result, output, threshold); return(0); }); }); commandLineApplication.Command("reset", command => { command.Description = "Reset hits count"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); if (File.Exists(coverageFile)) { var result = LoadCoverageFile(coverageFile); if (File.Exists(result.HitsFile)) { File.Delete(result.HitsFile); } } return(0); }); }); commandLineApplication.HelpOption("-h | --help"); commandLineApplication.OnExecute(() => { commandLineApplication.ShowHelp(); return(0); }); return(commandLineApplication.Execute(args)); }
static void Main(string[] args) { //setting the application path string applicationPath = Application.ExecutablePath; int applicationFilePath = applicationPath.LastIndexOf("\\", StringComparison.Ordinal); if (applicationFilePath >= 0) { Property.ApplicationPath = applicationPath.Substring(0, applicationFilePath + 1); } else { DirectoryInfo dr = new DirectoryInfo("./"); Property.ApplicationPath = dr.FullName; } try { using (StreamReader sr = new StreamReader(Path.Combine(Property.ApplicationPath, "root.ini"))) { string currentProjectName; while ((currentProjectName = sr.ReadLine()) != null) { if (currentProjectName.ToLower().Contains("projectpath")) { CurrentProjectpath = currentProjectName.Substring(currentProjectName.IndexOf(':') + 1).Trim(); break; } } } if (!Path.IsPathRooted(CurrentProjectpath)) { CurrentProjectpath = Path.Combine(Property.ApplicationPath, CurrentProjectpath); } Property.IniPath = Path.GetFullPath(CurrentProjectpath); if (!Directory.Exists(Property.IniPath)) { Property.IniPath = Property.ApplicationPath; } } catch (Exception) { Property.IniPath = Property.ApplicationPath; } try { ReadIniFiles(); } catch (Exception e) { Console.WriteLine(e.Message); } try { if (File.Exists(Property.ApplicationPath + "xmlFiles.txt")) { StreamReader xmlTextFileRead = new StreamReader(Property.ApplicationPath + "xmlFiles.txt"); XmlFileName = xmlTextFileRead.ReadToEnd(); xmlTextFileRead.Close(); } } catch { // ignored } Environment = Utility.GetParameter("Environment"); ReadCommandLineArguments(args); Utility.SetParameter(Property.Environment, Environment); XmlFileName = XmlFileName.Replace("\n", ","); XmlFileName = XmlFileName.Replace("\r", string.Empty); XmlFileName = XmlFileName.Replace("\t", string.Empty); string htmlFile = string.Empty; bool isSummaryRequiredinResultsFolder = false; bool callFromKryptonVbScriptGrid = true; if (XmlrootFolderPath.Length > 0) { isSummaryRequiredinResultsFolder = Utility.GetParameter("SummaryReportRequired").ToLower().Equals("true"); callFromKryptonVbScriptGrid = false; } if (!EmailFor.Equals("start", StringComparison.OrdinalIgnoreCase)) { if (XmlrootFolderPath.Length > 0) { LogFile.AllXmlFilesLocation = GetFileNames(XmlrootFolderPath); Property.HtmlFileLocation = Path.Combine("", XmlrootFolderPath); } else { LogFile.AllXmlFilesLocation = string.Empty; string[] xmlFiles = XmlFileName.Split(','); for (int cntXml = 0; cntXml < xmlFiles.Length; cntXml++) { if (string.IsNullOrWhiteSpace(LogFile.AllXmlFilesLocation)) { LogFile.AllXmlFilesLocation = xmlFiles[cntXml]; } else { LogFile.AllXmlFilesLocation = LogFile.AllXmlFilesLocation + ";" + xmlFiles[cntXml]; } } try { var directoryInfo = new FileInfo(xmlFiles[0]).Directory; if (directoryInfo != null) { if (directoryInfo.Parent != null) { if (directoryInfo.Parent.Parent != null) { Property.HtmlFileLocation = directoryInfo.Parent.Parent.FullName; } } } } catch (Exception e) { Console.WriteLine("Error in path"); } } } else { Property.ExecutionStartDateTime = DateTime.Now.ToString(Utility.GetParameter("DateTimeFormat")); Property.ExecutionEndDateTime = DateTime.Now.ToString(Utility.GetParameter("DateTimeFormat")); } try { htmlFile = string.Empty; if (!string.IsNullOrWhiteSpace(LogFile.AllXmlFilesLocation)) { Property.Date_Time = Utility.GetParameter("DateTimeFormat").Replace("/", "\\/"); htmlFile = "HtmlReport-" + HtmlFileName + "-" + DateTime.Now.ToString("ddMMyyhhmmss") + ".html"; Property.CompanyLogo = Path.IsPathRooted(Utility.GetParameter("CompanyLogo")) ? Utility.GetParameter("CompanyLogo") : string.Concat(Property.IniPath, Utility.GetParameter("CompanyLogo")); if (!File.Exists(Property.CompanyLogo)) { Property.CompanyLogo = string.Empty; } LogFile.CreateHtmlReport(htmlFile, false, false, Property.IsSauceLabExecution); //Always create summpary report because it is called from grid and this summary report is used in grid to send email. HtmlReport.CreateHtmlReport(htmlFile, false, false, Property.IsSauceLabExecution, isSummaryRequiredinResultsFolder, true, callFromKryptonVbScriptGrid, true); } htmlFile = htmlFile.Replace(".html", "smail.html"); // to send mail htmlFile = Path.Combine(Property.HtmlFileLocation, htmlFile); if (XmlrootFolderPath.Length > 0) { EmailRequired = (Utility.GetParameter("EmailNotification").Equals("true", StringComparison.OrdinalIgnoreCase)) ? "yes" : "no"; } if (string.Equals(EmailRequired, "yes")) { try { Utility.EmailNotification(EmailFor, false, htmlFile); } catch (Exception e) { Console.WriteLine(e.Message); } } } catch (Exception exception) { Console.WriteLine(exception.Message); } finally { if (File.Exists(htmlFile)) //delete mailhtml { try { if (!callFromKryptonVbScriptGrid) { File.Delete(htmlFile); } } catch { // ignored } } } }
public virtual string exportToHTML(string fileName, float scale, int pageno, int startPageNo, HttpRequest request, bool isFixRowCol) { string str = ""; Random random = new Random(); string str2 = Convert.ToString(random.Next(40)); string str3 = Convert.ToString(random.Next(40)); if (EformRole.inVer == "ebiaoold") { if (((CellNo.sVersionNo == "") || (CellNo.sVersionNo == "4")) || (CellNo.sVersionNo == "5")) { str = "<script>document.write(\"<div style='position:absolute;left:" + str2 + "px;top:" + str3 + "px;COLOR: #b2b2b2;font-size:11px;'>演示版</div>\");</script>"; } if (CellNo.sVersionNo == "3") { string str6 = CellNo.sCustomerName + @"\n" + CellNo.sProjectName + @"\n\n授权使用!"; string str7 = "<a href='javascript:void(0);' title='" + str6 + "'>关于 </a>"; string str8 = str; str = str8 + "<script>try{var ooCurWin = parent.toolbar; if (ooCurWin==null) {ooCurWin = parent.parent.toolbar;} var oCell = ooCurWin.Toolbar.rows(0).lastChild;oCell.style.fontSize=\"12px\"; oCell.innerHTML=\"" + str7 + "\"; oCell.childNodes(0).onclick=function(){alert('" + str6 + "')}; }catch(e){} </script>"; } } string str4 = ""; StreamWriter writer = null; try { HtmlReport report; if (scale < 0f) { float num = 0.95f; Parser parser = new Parser(Cells); PageFormat pageFormat = parser.PageFormat; if (scale == -1f) { if (parser.CellSetWidth > 0) { scale = (pageFormat.paperImageableWidth * num) / ((float)parser.CellSetWidth); } else { scale = 1f; } } if (scale == -2f) { if (parser.CellSetHeight <= 0) { scale = 1f; } else { scale = (pageFormat.paperImageableHeight * num) / ((float)parser.CellSetHeight); } } } PageBuilder builder = null; int pageWidth = 0; int pageHeight = 0; int pageNo = pageno; if (pageno != -1) { builder = new PageBuilder(Cells, pageWidth, pageHeight, scale); report = new HtmlReport(builder.getPage(pageNo, startPageNo), null, "", request) { Scale = scale }; } else { pageWidth = 999999999; pageHeight = 999999999; pageNo = 1; builder = new PageBuilder(Cells, 999999999, 999999999, 1f); report = new HtmlReport(builder.getPage(1), null, "", request) { Scale = 1f }; } str4 = report.generateHtml(isFixRowCol) + str; Logger.debug("下面写临时文件"); if ((fileName != null) && (fileName.Length > 0)) { writer = new StreamWriter(fileName, false, Encoding.Default, 512); writer.WriteLine(str4); writer.Flush(); writer.Close(); } if (pageno == -1) { builder = new PageBuilder(Cells, 0, 0, scale); } pages = builder.PageCount; IsHavePic = report.IsHavePic; } catch (Exception exception) { throw exception; } finally { if (writer != null) { writer.Close(); } } return(str4); }