Exemplo n.º 1
0
        public void SetHealthIndex(double healthIndex)
        {
            _overall.Ranges[0].EndValue = (float)healthIndex;
            _overall.GaugeLabel         = QualityAnalyzersManager.GetHealthIndexDescription(healthIndex);

            if (healthIndex <= 10.0)
            {
                _overall.Ranges[0].Color = Color.Red;
            }
            else if (healthIndex <= 20.0)
            {
                _overall.Ranges[0].Color = Color.Yellow;
            }
            else
            {
                _overall.Ranges[0].Color = Color.Green;
            }
        }
Exemplo n.º 2
0
        private void AddSummary([NotNull] PdfDocument doc, [NotNull] PdfPage page, float top,
                                PdfStandardFont font, double healthIndex,
                                IEnumerable <QualityAnalyzerResult> outcomes)
        {
            WriteText(page, "Threat Model Health Index",
                      new PdfStandardFont(font, font.Size, PdfFontStyle.Bold), 0, top);
            var textSize = WriteText(page,
                                     $"{QualityAnalyzersManager.GetHealthIndexDescription(healthIndex)} ({healthIndex.ToString("F1")}/30)",
                                     new PdfStandardFont(font, font.Size, PdfFontStyle.Bold), 0, top, null, true);

            var y = textSize.Height + top + 10;

            page.Graphics.DrawLine(PdfPens.Black, 40, y, page.Graphics.ClientSize.Width - 40, y);

            y += 10;

            var analyzers = QualityAnalyzersManager.QualityAnalyzers?.ToArray();

            if (analyzers?.Any() ?? false)
            {
                foreach (var analyzer in analyzers)
                {
                    if (y > page.Graphics.ClientSize.Height - textSize.Height * 4)
                    {
                        y    = 0;
                        page = doc.Pages.Add();
                    }

                    var outcome = outcomes?.FirstOrDefault(x => x.Id == analyzer.GetExtensionId());
                    if (outcome != null)
                    {
                        WriteText(page, analyzer.Label, font, 0, y);
                        textSize = WriteText(page, outcome.Assessment.GetEnumLabel(),
                                             font, 0, y, null, true);
                        y += textSize.Height + 10;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void CreateSummary([NotNull] ExcelReportEngine engine,
                                   double healthIndex,
                                   IEnumerable <QualityAnalyzerResult> outcomes)
        {
            var p = engine.AddPage("Summary");

            engine.AddHeader(p, "Assessment", "Evaluation");

            engine.AddRow(p, "Threat Model Health Index", QualityAnalyzersManager.GetHealthIndexDescription(healthIndex));

            var analyzers = QualityAnalyzersManager.QualityAnalyzers?.ToArray();

            if (analyzers?.Any() ?? false)
            {
                foreach (var analyzer in analyzers)
                {
                    var outcome = outcomes?.FirstOrDefault(x => x.Id == analyzer.GetExtensionId());
                    if (outcome != null)
                    {
                        engine.AddRow(p, analyzer.Label, outcome.Assessment.GetEnumLabel());
                    }
                }
            }
        }