Exemplo n.º 1
0
        // Returns null if the report is empty
        protected static string GenerateReport(
            Alert alert,
            string htmlTemplate,
            IEnumerable <DataModelIssue> issues,
            IEnumerable <string> inputFiles,
            ExpressionUntriaged untriagedExpression)
        {
            IEnumerable <DataModelIssue> matchingIssues = alert.Query.Evaluate(issues);
            var untriagedFlagsMap = new Dictionary <DataModelIssue, ExpressionUntriaged.Flags>();

            foreach (DataModelIssue issue in matchingIssues)
            {
                ExpressionUntriaged.Flags flags = untriagedExpression.GetUntriagedFlags(issue);
                if (flags != 0)
                {
                    untriagedFlagsMap[issue] = flags;
                }
            }

            if (untriagedFlagsMap.None())
            {
                Console.WriteLine("    No untriaged issues, skipping.");
                Console.WriteLine();
                return(null);
            }

            string text = htmlTemplate;

            text = text.Replace("%UNTRIAGED_ISSUES_START%", "");
            text = text.Replace("%UNTRIAGED_ISSUES_END%", "");

            text = text.Replace("%UNTRIAGED_ISSUES_LINKED_COUNTS%",
                                AlertReport.GetLinkedCount("is:issue is:open", untriagedFlagsMap.Keys));

            IEnumerable <IssueEntry> untriagedIssueEntries = untriagedFlagsMap.Keys.Select(issue => new IssueEntry(issue));

            text = text.Replace("%UNTRIAGED_ISSUES_TABLE%", FormatIssueTable(untriagedFlagsMap));

            text = text.Replace("%INPUT_FILES_LIST%", FormatInputFilesList(inputFiles));

            return(text);
        }
Exemplo n.º 2
0
 private static string UntriagedTypeToString(ExpressionUntriaged.Flags flags)
 {
     return(string.Join(", ", ExpressionUntriaged.EnumerateFlags(flags)));
 }