public void ShouldProcessBlocksAsTable() { var labelBlock = new LabelReportBlock(); var containerBlock = new ContainerReportBlock { Childs = new IReportBlock[] { labelBlock, labelBlock }, Orientation = ContainerOrientation.Horizontal }; var paramDict = new ConcurrentDictionary <string, object>(); paramDict.AddOrUpdate(DefaultReportParameters.ContainerUseTable, true, (s, o) => true); using (var stringWriter = new StringWriter()) { using (var htmlTextWriter = new HtmlTextWriter(stringWriter)) { _target.Vizualize(htmlTextWriter, containerBlock, paramDict, null, 1); } var result = stringWriter.ToString(); result.Should().NotBeNullOrEmpty(); } }
private static IReportBlock GetHeader() { var headerBlock = new ContainerReportBlock("HeaderContainerBlock") { Orientation = ContainerOrientation.Horizontal, MarginBottomPx = 20, Childs = new IReportBlock[] { new ContainerReportBlock("HeaderLeftContainerBlock") { Orientation = ContainerOrientation.Vertical, Childs = new IReportBlock[] { new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 24 }, Id = "LabelReportHeaderCompany", Text = "Positive Technologies AI SSDL" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 24 }, Id = "LabelReportHeaderReportName", Text = "Report: $ReportTitle$" } } }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 24 }, Id = "LabelReportCreationTime", Text = "$CurrentDate$", HorizontalAlign = LabelHorizontalAlign.Right, VerticalAlign = LabelVerticalalign.Middle } } }; return(headerBlock); }
public void ShouldVizualizeWithEmptyChildBlocks() { var containerBlock = new ContainerReportBlock { Childs = null }; using (var stringWriter = new StringWriter()) { using (var htmlTextWriter = new HtmlTextWriter(stringWriter)) { _target.Vizualize(htmlTextWriter, containerBlock, null, null, 1); stringWriter.ToString().Should().NotBeNullOrEmpty(); } } }
public static IReportBlock GetOperationDurationChart(string query) { var chartContainer = new ContainerReportBlock("OperationDurationChartContainerBlock") { Orientation = ContainerOrientation.Vertical, Childs = new IReportBlock[] { new ChartReportBlock { Columns = new[] { new ChartColumn { ColumnKey = "OperationDuration", DisplayName = "Operation duration [ms]" } }, HeightPx = 250, Label = new ChartLabel { ColumnKey = "DateTimeLocal" }, Type = ChartType.Line, QueryKey = query }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Text = "Chart A. Operation duration", HorizontalAlign = LabelHorizontalAlign.Center } } }; return(chartContainer); }
public void ShoudBeSerializable() { var containerBlock = new ContainerReportBlock { Childs = new IReportBlock[] { new LabelReportBlock { FontStyle = new LabelFontStyle(46), Text = "Halo" } }, Orientation = ContainerOrientation.Horizontal }; var serialized = containerBlock.ToJson(); var result = serialized.FromJson <ContainerReportBlock>(); result.ShouldBeEquivalentTo(containerBlock); }
public void ShouldProcessBlocks() { var labelBlock = new LabelReportBlock(); var containerBlock = new ContainerReportBlock { Childs = new IReportBlock[] { labelBlock, labelBlock }, Orientation = ContainerOrientation.Vertical }; using (var stringWriter = new StringWriter()) { using (var htmlTextWriter = new HtmlTextWriter(stringWriter)) { _target.Vizualize(htmlTextWriter, containerBlock, null, null, 1); htmlTextWriter.ToString().Should().NotBeNullOrEmpty(); } } }
private static IReportBlock GetSecondPart() { var block = new ContainerReportBlock("DoughnutsContainer") { Orientation = ContainerOrientation.Vertical, Childs = new IReportBlock[] { new ChartReportBlock { Columns = new[] { new ChartColumn { ColumnKey = "High", DisplayName = "High vulnerability severity" }, new ChartColumn { ColumnKey = "Med", DisplayName = "Medium vulnerability sevirity" }, new ChartColumn { ColumnKey = "Low", DisplayName = "Low vulnerability sevirity" } }, HeightPx = 250, Label = new ChartLabel { ColumnKey = "Created" }, Type = ChartType.Line, QueryKey = "ProjectTasks" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Id = "LabelChartOneDescription", Text = "Chart 1. Vulnerabilities distribution by severity", HorizontalAlign = LabelHorizontalAlign.Center }, new ContainerReportBlock { BackgroundColor = new ReportItemColor(236, 236, 236), MarginTopPx = 10, MarginBottomPx = 10, PaddingRightPx = 30, PaddingLeftPx = 80, PaddingTopPx = 15, PaddingBottomPx = 15, Childs = new IReportBlock[] { new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12, Bold = true }, Id = "LabelChartOneDescription", Text = "Placeholder for a something intresting", HorizontalAlign = LabelHorizontalAlign.Center } } }, new ChartReportBlock { Columns = new[] { new ChartColumn { ColumnKey = "Todo", DisplayName = "TO DO" }, new ChartColumn { ColumnKey = "Reopen", DisplayName = "Reopened" }, new ChartColumn { ColumnKey = "Fixed", DisplayName = "Fixed" }, new ChartColumn { ColumnKey = "FP", DisplayName = "False positive" } }, HeightPx = 250, Label = new ChartLabel { ColumnKey = "Created" }, Type = ChartType.Line, QueryKey = "ProjectTasks" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Id = "LabelChartOneDescription", Text = "Chart 2. Vulnerabilities distribution by annotation", HorizontalAlign = LabelHorizontalAlign.Center }, new ContainerReportBlock { BackgroundColor = new ReportItemColor(236, 236, 236), MarginTopPx = 10, MarginBottomPx = 10, PaddingRightPx = 30, PaddingLeftPx = 80, PaddingTopPx = 15, PaddingBottomPx = 15, Childs = new IReportBlock[] { new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12, Bold = true }, Id = "LabelChartOneDescription", Text = "Placeholder for a something intresting", HorizontalAlign = LabelHorizontalAlign.Center } } }, new ChartReportBlock { Columns = new[] { new ChartColumn { ColumnKey = "Total", DisplayName = "Total" }, new ChartColumn { ColumnKey = "Xss", DisplayName = "XSS" }, new ChartColumn { ColumnKey = "Ldap", DisplayName = "LDAP" } }, HeightPx = 250, Label = new ChartLabel { ColumnKey = "Created" }, Type = ChartType.Line, QueryKey = "ProjectTasks" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Id = "LabelChartOneDescription", Text = "Chart 3. Vulnerabilities distribution by type", HorizontalAlign = LabelHorizontalAlign.Center }, new ContainerReportBlock { BackgroundColor = new ReportItemColor(236, 236, 236), MarginTopPx = 10, MarginBottomPx = 10, PaddingRightPx = 30, PaddingLeftPx = 80, PaddingTopPx = 15, PaddingBottomPx = 15, Childs = new IReportBlock[] { new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12, Bold = true }, Id = "LabelChartOneDescription", Text = "Placeholder for a something intresting", HorizontalAlign = LabelHorizontalAlign.Center } } }, new ChartReportBlock { Columns = new[] { new ChartColumn { ColumnKey = "FolderSize", DisplayName = "Folder size [KB]" }, new ChartColumn { ColumnKey = "AnalyzedSize", DisplayName = "Analyzed size [KB]" } }, HeightPx = 250, Label = new ChartLabel { ColumnKey = "Created" }, Type = ChartType.Line, QueryKey = "ProjectTasks" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Id = "LabelChartOneDescription", Text = "Chart 4. Scan process counters", HorizontalAlign = LabelHorizontalAlign.Center }, new ContainerReportBlock { BackgroundColor = new ReportItemColor(236, 236, 236), MarginTopPx = 10, MarginBottomPx = 10, PaddingRightPx = 30, PaddingLeftPx = 80, PaddingTopPx = 15, PaddingBottomPx = 15, Childs = new IReportBlock[] { new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12, Bold = true }, Id = "LabelChartOneDescription", Text = "Placeholder for a something intresting", HorizontalAlign = LabelHorizontalAlign.Center } } }, new TableReportBlock { BorderPx = 1, QueryKey = "ProjectTasks" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Id = "LabelChartOneDescription", Text = "Table 1. Scan task results summary", HorizontalAlign = LabelHorizontalAlign.Center } } }; return(block); }
private static IReportBlock GetFirstPart() { var block = new ContainerReportBlock("ContainerTaskInfo") { BackgroundColor = new ReportItemColor(236, 236, 236), Childs = new IReportBlock[] { new IteratorReportBlock { Id = "IteratorProjectInfo", QueryKey = "Project", Child = new ContainerReportBlock("ContainerTaskStatHead") { BackgroundColor = new ReportItemColor(236, 236, 236), ChildProportions = new[] { 20, 80 }, Childs = new IReportBlock[] { new ContainerReportBlock("ContainerTaskStatHeadLeft") { BackgroundColor = new ReportItemColor(236, 236, 236), Childs = new IReportBlock[] { new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "Project name:" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "Default branch:" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "Created:" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "Modified:" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "Version control plugin:" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "Issue tracker plugin:" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "Latest auto sync:" } }, Orientation = ContainerOrientation.Vertical }, new ContainerReportBlock("ContainerTaskStatHeadRight") { BackgroundColor = new ReportItemColor(236, 236, 236), Childs = new IReportBlock[] { new LabelReportBlock { FontStyle = new LabelFontStyle { Bold = true, FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "$ProjectItem.DisplayName$" }, new LabelReportBlock { FontStyle = new LabelFontStyle { Bold = true, FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "$ProjectItem.DefaultBranchName$" }, new LabelReportBlock { FontStyle = new LabelFontStyle { Bold = true, FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "UTC $ProjectItem.Created$" }, new LabelReportBlock { FontStyle = new LabelFontStyle { Bold = true, FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "UTC $ProjectItem.Modified$" }, new LabelReportBlock { FontStyle = new LabelFontStyle { Bold = true, FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "$ProjectItem.VcsPlugin$" }, new LabelReportBlock { FontStyle = new LabelFontStyle { Bold = true, FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "$ProjectItem.ItPlugin$" }, new LabelReportBlock { FontStyle = new LabelFontStyle { Bold = true, FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 12 }, Text = "$ProjectItem.VcsLastSyncUtc$" } }, Orientation = ContainerOrientation.Vertical } }, Orientation = ContainerOrientation.Horizontal } } }, MarginTopPx = 10, PaddingRightPx = 30, PaddingLeftPx = 80, PaddingTopPx = 15, PaddingBottomPx = 15, Id = "ContainerScanInfo", Orientation = ContainerOrientation.Vertical }; return(block); }
private static IReportBlock GetDohnuts() { var block = new ContainerReportBlock("DoughnutsContainer") { Orientation = ContainerOrientation.Horizontal, Childs = new IReportBlock[] { new ContainerReportBlock { Orientation = ContainerOrientation.Vertical, Childs = new IReportBlock[] { new ChartReportBlock { Columns = new[] { new ChartColumn { BorderWidth = 0, ColumnKey = "Count", DisplayName = "Count" } }, HeightPx = 250, Label = new ChartLabel { ColumnKey = "Operation" }, Type = ChartType.Doughnut, QueryKey = "VcsOperationsByName" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Id = "LabelChartOneDescription", Text = "Chart A. Operations by key", HorizontalAlign = LabelHorizontalAlign.Center } } }, new ContainerReportBlock { Orientation = ContainerOrientation.Vertical, Childs = new IReportBlock[] { new ChartReportBlock { Columns = new[] { new ChartColumn { BorderWidth = 0, ColumnKey = "Count", DisplayName = "Count" } }, HeightPx = 250, Label = new ChartLabel { ColumnKey = "Type" }, Type = ChartType.Doughnut, QueryKey = "VcsOperationsByType" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Id = "LabelChartOneDescription", Text = "Chart B. Operations by plugin type", HorizontalAlign = LabelHorizontalAlign.Center } } } } }; return(block); }
private static IReportBlock GetCharts() { var block = new ContainerReportBlock("ChartsPart") { Orientation = ContainerOrientation.Vertical, Childs = new IReportBlock[] { new ChartReportBlock { Columns = new[] { new ChartColumn { ColumnKey = "OperationDuration", DisplayName = "Operation duration [s]" } }, HeightPx = 200, Label = new ChartLabel { ColumnKey = "DateTimeLocal" }, Type = ChartType.Line, QueryKey = "VcsOperations" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Text = "Chart C. All VCS operations duration", HorizontalAlign = LabelHorizontalAlign.Center }, new ChartReportBlock { Columns = new[] { new ChartColumn { ColumnKey = "OperationDuration", DisplayName = "operation duration [s]" } }, HeightPx = 200, Label = new ChartLabel { ColumnKey = "Time" }, Type = ChartType.Line, QueryKey = "VcsCheckoutOperations" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Text = "Chart D. Chekout VCS operations duration", HorizontalAlign = LabelHorizontalAlign.Center }, new ChartReportBlock { Columns = new[] { new ChartColumn { ColumnKey = "OperationDuration", DisplayName = "Operation duration [s]" } }, HeightPx = 200, Label = new ChartLabel { ColumnKey = "Time" }, Type = ChartType.Line, QueryKey = "VcsCreateBranchOperations" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Text = "Chart E. Create Branch VCS operations duration", HorizontalAlign = LabelHorizontalAlign.Center }, new ChartReportBlock { Columns = new[] { new ChartColumn { ColumnKey = "OperationDuration", DisplayName = "Operation duration [s]" } }, HeightPx = 200, Label = new ChartLabel { ColumnKey = "Time" }, Type = ChartType.Line, QueryKey = "VcsCommitOperations" }, new LabelReportBlock { FontStyle = new LabelFontStyle { FontFamily = "'Myriad Pro', 'Segoe UI', Arial, Sans-Serif", FontSizePx = 14, Bold = true }, Text = "Chart F. Commit Branch VCS operations duration", HorizontalAlign = LabelHorizontalAlign.Center } } }; return(block); }