public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            List <string>         rowData   = new List <string>();
            List <CellAttributes> cellProps = new List <CellAttributes>();
            int cellidx = 0;
            // cellProps will contains the properties of the cell (background color) linked to the data by position in the list stored with cellidx.

            List <string> metrics = options.GetOption("METRICS").Trim().Split('|').ToList();
            bool          critical;

            if (options == null || !options.ContainsKey("CRITICAL"))
            {
                critical = false;
            }
            else
            {
                critical = options.GetOption("CRITICAL").Equals("true");
            }

            List <string> qualityRules = MetricsUtility.BuildRulesList(reportData, metrics, critical);

            rowData.Add(Labels.Violations);
            cellidx++;

            if (qualityRules.Count > 0)
            {
                const string bcId                = "60017";
                int          nbLimitTop          = options.GetIntOption("COUNT", 5);
                bool         hasPreviousSnapshot = reportData.PreviousSnapshot != null;

                foreach (string _metric in qualityRules)
                {
                    RuleDescription rule     = reportData.RuleExplorer.GetSpecificRule(reportData.Application.DomainId, _metric);
                    string          ruleName = rule.Name;
                    if (ruleName == null)
                    {
                        continue;
                    }
                    int metricId;
                    if (!int.TryParse(_metric, out metricId))
                    {
                        continue;
                    }
                    ViolStatMetricIdDTO violStats = RulesViolationUtility.GetViolStat(reportData.CurrentSnapshot, metricId);
                    if (violStats == null)
                    {
                        continue;
                    }

                    // if no violations, do not display anything for this rule
                    if (violStats.TotalViolations < 1)
                    {
                        continue;
                    }

                    rowData.Add("");
                    cellidx++;

                    rowData.Add(Labels.ObjectsInViolationForRule + " " + ruleName);
                    cellProps.Add(new CellAttributes(cellidx, Color.Gray, Color.White, "bold"));
                    cellidx++;
                    rowData.Add(Labels.ViolationsCount + ": " + violStats.TotalViolations);
                    cellProps.Add(new CellAttributes(cellidx, Color.White));
                    cellidx++;
                    if (!string.IsNullOrWhiteSpace(rule.Rationale))
                    {
                        rowData.Add(Labels.Rationale + ": ");
                        cellProps.Add(new CellAttributes(cellidx, Color.LightGray));
                        cellidx++;
                        rowData.Add(rule.Rationale);
                        cellProps.Add(new CellAttributes(cellidx, Color.White));
                        cellidx++;
                    }
                    rowData.Add(Labels.Description + ": ");
                    cellProps.Add(new CellAttributes(cellidx, Color.LightGray));
                    cellidx++;
                    rowData.Add(rule.Description);
                    cellProps.Add(new CellAttributes(cellidx, Color.White));
                    cellidx++;
                    if (!string.IsNullOrWhiteSpace(rule.Remediation))
                    {
                        rowData.Add(Labels.Remediation + ": ");
                        cellProps.Add(new CellAttributes(cellidx, Color.LightGray));
                        cellidx++;
                        rowData.Add(rule.Remediation);
                        cellProps.Add(new CellAttributes(cellidx, Color.White));
                        cellidx++;
                    }

                    IEnumerable <Violation> results = reportData.SnapshotExplorer.GetViolationsListIDbyBC(reportData.CurrentSnapshot.Href, _metric, bcId, nbLimitTop, "$all");
                    if (results == null)
                    {
                        continue;
                    }
                    var _violations = results as Violation[] ?? results.ToArray();
                    if (_violations.Length == 0)
                    {
                        continue;
                    }
                    int    violation_counter = 0;
                    string domainId          = reportData.CurrentSnapshot.DomainId;
                    string snapshotId        = reportData.CurrentSnapshot.Id.ToString();
                    cellidx = MetricsUtility.PopulateViolationsBookmarks(reportData, _violations, violation_counter, rowData, cellidx, ruleName, cellProps, hasPreviousSnapshot, domainId, snapshotId, _metric);

                    // Add empty lines for readability
                    for (int i = 1; i < 5; i++)
                    {
                        rowData.Add("");
                        cellidx++;
                    }
                }

                if (rowData.Count <= 1)
                {
                    rowData.Add(Labels.NoViolation);
                }
            }
            else
            {
                rowData.Add(Labels.NoItem);
            }


            var table = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = rowData.Count,
                NbColumns        = 1,
                Data             = rowData,
                CellsAttributes  = cellProps
            };

            return(table);
        }
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            List <string> metrics = options.GetOption("METRICS").Trim().Split('|').ToList();
            bool          critical;

            if (options == null || !options.ContainsKey("CRITICAL"))
            {
                critical = false;
            }
            else
            {
                critical = options.GetOption("CRITICAL").Equals("true");
            }
            bool displayCompliance  = options.GetBoolOption("COMPLIANCE");
            bool sortedByCompliance = displayCompliance && options.GetOption("SORTED", "TOTAL").Equals("COMPLIANCE");

            bool   vulnerability = options.GetOption("LBL", "vulnerabilities").ToLower().Equals("vulnerabilities");
            string lbltotal      = vulnerability ? Labels.TotalVulnerabilities : Labels.TotalViolations;
            string lbladded      = vulnerability ? Labels.AddedVulnerabilities : Labels.AddedViolations;
            string lblremoved    = vulnerability ? Labels.RemovedVulnerabilities : Labels.RemovedViolations;

            // cellProps will contains the properties of the cell (background color) linked to the data by position in the list stored with cellidx.
            List <CellAttributes> cellProps = new List <CellAttributes>();
            int cellidx = 0;

            var headers = new HeaderDefinition();

            headers.Append(Labels.CASTRules);
            cellidx++;
            headers.Append(lbltotal);
            cellidx++;
            headers.Append(lbladded);
            cellidx++;
            headers.Append(lblremoved);
            cellidx++;
            headers.Append(Labels.ComplianceScorePercent, displayCompliance);
            if (displayCompliance)
            {
                cellidx++;
            }

            var dataRow = headers.CreateDataRow();
            var data    = new List <string>();

            List <string> qualityRules = MetricsUtility.BuildRulesList(reportData, metrics, critical);

            List <ApplicationResult> results = sortedByCompliance ?
                                               reportData.CurrentSnapshot?.QualityRulesResults.Where(_ => qualityRules.Contains(_.Reference.Key.ToString())).OrderBy(_ => _.DetailResult.ViolationRatio.Ratio).ToList()
                    : reportData.CurrentSnapshot?.QualityRulesResults.Where(_ => qualityRules.Contains(_.Reference.Key.ToString())).OrderByDescending(_ => _.DetailResult.ViolationRatio.FailedChecks).ToList();

            if (results?.Count > 0)
            {
                foreach (var result in results)
                {
                    var detailResult = result.DetailResult;
                    if (detailResult == null)
                    {
                        continue;
                    }
                    int nbViolations = detailResult.ViolationRatio.FailedChecks ?? 0;

                    dataRow.Set(Labels.CASTRules, (result.Reference?.Name + " (" + result.Reference?.Key + ")").NAIfEmpty());
                    if (nbViolations > 0)
                    {
                        cellProps.Add(new CellAttributes(cellidx, Color.Beige));
                    }
                    cellidx++;
                    dataRow.Set(lbltotal, detailResult.ViolationRatio.FailedChecks.HasValue ? detailResult.ViolationRatio?.FailedChecks.Value.ToString("N0") : Constants.No_Value);
                    if (nbViolations > 0)
                    {
                        cellProps.Add(new CellAttributes(cellidx, Color.Beige));
                    }
                    cellidx++;
                    dataRow.Set(lbladded, detailResult.EvolutionSummary?.AddedViolations.NAIfEmpty("N0"));
                    if (nbViolations > 0)
                    {
                        cellProps.Add(new CellAttributes(cellidx, Color.Beige));
                    }
                    cellidx++;
                    dataRow.Set(lblremoved, detailResult.EvolutionSummary?.RemovedViolations.NAIfEmpty("N0"));
                    if (nbViolations > 0)
                    {
                        cellProps.Add(new CellAttributes(cellidx, Color.Beige));
                    }
                    cellidx++;
                    if (displayCompliance)
                    {
                        dataRow.Set(Labels.ComplianceScorePercent, detailResult.ViolationRatio?.Ratio.FormatPercent(false));
                        if (nbViolations > 0)
                        {
                            cellProps.Add(new CellAttributes(cellidx, Color.Beige));
                        }
                        cellidx++;
                    }
                    data.AddRange(dataRow);
                }
            }

            if (data.Count == 0)
            {
                dataRow.Reset();
                dataRow.Set(0, Labels.NoRules);
                data.AddRange(dataRow);
            }

            data.InsertRange(0, headers.Labels);

            return(new TableDefinition
            {
                Data = data,
                HasColumnHeaders = true,
                HasRowHeaders = false,
                NbColumns = headers.Count,
                NbRows = data.Count / headers.Count,
                CellsAttributes = cellProps
            });
        }