protected void GenerateIndicatorPanel(string id, string title, RiskRuleCategory category, List <HealthcheckRiskRule> rules, List <RuleBase <HealthcheckData> > applicableRules) { Add(@" <div class=""row""><div class=""col-lg-12 mt-2""> <a data-toggle=""collapse"" data-target=""#" + id + @"""> <h2>" ); Add(title); Add(@" ["); Add(GetRulesNumberForCategory(rules, category).ToString()); Add(@" rules matched on a total of "); Add(GetApplicableRulesNumberForCategory(applicableRules, category).ToString()); Add(@"]</h2> </a> </div></div> <div class=""row collapse show"" id=""" ); Add(id); Add(@"""><div class=""col-lg-12""> "); bool hasRule = false; foreach (HealthcheckRiskRule rule in rules) { if (rule.Category == category) { hasRule = true; break; } } if (hasRule) { GenerateAccordion("rules" + category.ToString(), () => { rules.Sort((HealthcheckRiskRule a, HealthcheckRiskRule b) => { return(-a.Points.CompareTo(b.Points)); } ); foreach (HealthcheckRiskRule rule in rules) { if (rule.Category == category) { GenerateIndicatorPanelDetail(category.ToString(), rule); } } }); } else { Add("<p>No rule matched</p>"); } Add(@" </div> </div>" ); }
protected void GenerateIndicatorPanelDetail(RiskRuleCategory category, HealthcheckRiskRule rule) { string safeRuleId = rule.RiskId.Replace("$", "dollar"); GenerateAccordionDetail("rules" + safeRuleId, "rules" + category.ToString(), rule.Rationale, rule.Points, true, () => { var hcrule = RuleSet <T> .GetRuleFromID(rule.RiskId); if (hcrule == null) { } else { Add("<h3>"); Add(hcrule.Title); Add("</h3>\r\n<strong>Description:</strong><p class=\"text-justify\">"); Add(NewLineToBR(hcrule.Description)); Add("</p>\r\n<strong>Technical explanation:</strong><p class=\"text-justify\">"); Add(NewLineToBR(hcrule.TechnicalExplanation)); Add("</p>\r\n<strong>Advised solution:</strong><p class=\"text-justify\">"); Add(NewLineToBR(hcrule.Solution)); Add("</p>\r\n<strong>Points:</strong><p>"); Add(NewLineToBR(hcrule.GetComputationModelString())); Add("</p>\r\n"); if (!String.IsNullOrEmpty(hcrule.Documentation)) { Add("<strong>Documentation:</strong><p>"); Add(hcrule.Documentation); Add("</p>"); } } if ((rule.Details != null && rule.Details.Count > 0) || (hcrule != null && !String.IsNullOrEmpty(hcrule.ReportLocation))) { Add("<strong>Details:</strong>"); if (!String.IsNullOrEmpty(hcrule.ReportLocation)) { Add("<p>"); Add(hcrule.ReportLocation); Add("</p>"); } if (rule.Details != null && rule.Details.Count > 0) { Add("<p>"); Add(String.Join("<br>\r\n", rule.Details.ToArray())); Add("</p>"); } } }); }
protected void GenerateIndicatorPanelDetail(RiskRuleCategory category, HealthcheckRiskRule rule) { string safeRuleId = rule.RiskId.Replace("$", "dollar"); GenerateAccordionDetail("rules" + safeRuleId, "rules" + category.ToString(), rule.Rationale, rule.Points, true, () => { var hcrule = RuleSet<T>.GetRuleFromID(rule.RiskId); if (hcrule == null) { } else { Add("<h3>"); Add(hcrule.Title); Add("</h3>\r\n<strong>Description:</strong><p class=\"text-justify\">"); Add(NewLineToBR(hcrule.Description)); Add("</p>\r\n<strong>Technical explanation:</strong><p class=\"text-justify\">"); Add(NewLineToBR(hcrule.TechnicalExplanation)); Add("</p>\r\n<strong>Advised solution:</strong><p class=\"text-justify\">"); Add(NewLineToBR(hcrule.Solution)); Add("</p>\r\n<strong>Points:</strong><p>"); Add(NewLineToBR(hcrule.GetComputationModelString())); Add("</p>\r\n"); if (!String.IsNullOrEmpty(hcrule.Documentation)) { Add("<strong>Documentation:</strong><p>"); Add(hcrule.Documentation); Add("</p>"); } } if ((rule.Details != null && rule.Details.Count > 0) || (hcrule != null && !String.IsNullOrEmpty(hcrule.ReportLocation))) { Add("<strong>Details:</strong>"); if (!String.IsNullOrEmpty(hcrule.ReportLocation)) { Add("<p>"); Add(hcrule.ReportLocation); Add("</p>"); } if (rule.Details != null && rule.Details.Count > 0 && !string.IsNullOrEmpty(rule.Details[0])) { var test = rule.Details[0].Replace("Domain controller:","Domain_controller:").Split(' '); if (test.Length > 1 && test[0].EndsWith(":")) { var tokens = new List<string>(); for (int i = 0; i < test.Length; i++) { if (!string.IsNullOrEmpty(test[i]) && test[i].EndsWith(":")) { tokens.Add(test[i]); } } Add(@"<div class=""row""> <div class=""col-md-12 table-responsive""> <table class=""table table-striped table-bordered""> <thead><tr>"); foreach(var token in tokens) { Add("<th>"); AddEncoded(token.Replace("Domain_controller:", "Domain controller:").Substring(0, token.Length - 1)); Add("</th>"); } Add("</tr></thead><tbody>"); foreach (var d in rule.Details) { if (string.IsNullOrEmpty(d)) continue; Add("<tr>"); var t = d.Replace("Domain controller:", "Domain_controller:").Split(' '); for (int i = 0, j = 0; i < t.Length && j <= tokens.Count; i++) { if (j < tokens.Count && t[i] == tokens[j]) { j++; if (j != 0) Add("</td>"); Add("<td>"); } else { Add(t[i]); Add(" "); } } Add("</td>"); Add("</tr>"); } Add("</tbody></table></div></div>"); } else { Add("<p>"); Add(String.Join("<br>\r\n", rule.Details.ToArray())); Add("</p>"); } } } }); }