Exemplo n.º 1
0
        private void CreateHtmlReport(DuplicateResultFull lastResultFull)
        {
            if (!Directory.Exists(_htmlReportFolder))
            {
                Directory.CreateDirectory(_htmlReportFolder);
            }
            File.WriteAllText(Path.Combine(_htmlReportFolder, "fullduplicates.html"), lastResultFull.GetHtmlReport());
            var indexHtml = new StringBuilder();

            indexHtml.AppendLine("<html>");
            indexHtml.AppendLine("<head><title>Duplicate Reports</title>");
            indexHtml.AppendLine("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />");
            indexHtml.AppendLine("</head>");
            indexHtml.AppendLine("<body>");
            indexHtml.AppendLine("<h2>REPORT</h2>");
            indexHtml.AppendLine("<a href=\"fullduplicates.html\">Full duplicates report</a><br>");

            indexHtml.AppendLine("<table><tr><th>Revision</th><th>Plus</th><th>Minus</th></tr>");
            DuplicateResultFull previousResult = lastResultFull;
            DuplicateResultFull currentResult;
            int counter = 0;

            for (int i = CommitsList.Count - 2; i >= 0; i--)
            {
                if (++counter > _reportDepthLimit)
                {
                    break;
                }
                currentResult  = previousResult;
                previousResult = new DuplicateResultFull();
                var xmlFileName = Path.Combine(_workingFolder, CommitsList[i].ToString(), "duplicate.xml");
                var xml         = File.ReadAllText(xmlFileName);
                previousResult.InitFromXml(xml);
                var    comparison         = new DuplicateResultComparison(previousResult, currentResult);
                string comparisonFileName = "comparison" + CommitsList[i] + "-" + CommitsList[i + 1] + ".html";
                File.WriteAllText(Path.Combine(_htmlReportFolder, comparisonFileName), comparison.GetHtmlReport());

                indexHtml.AppendLine("<tr><td><a href=\"" + comparisonFileName + "\">" + CommitsList[i + 1] + "</a></td>");
                indexHtml.AppendLine("<td>+" + comparison.PlusCount + "</td>");
                indexHtml.AppendLine("<td>-" + comparison.MinusCount + "</td></tr>");
            }
            indexHtml.AppendLine("</table>");
            indexHtml.AppendLine("</body>");
            indexHtml.AppendLine("</html>");
            File.WriteAllText(Path.Combine(_htmlReportFolder, "index.html"), indexHtml.ToString());
        }
Exemplo n.º 2
0
        static void TestXml()
        {
            var resultFull = new DuplicateResultFull();
            var result1    = new DuplicateResult(5);

            result1.AddUnit("1.txt", 222);
            result1.AddUnit("2.txt", 333);
            var result2 = new DuplicateResult(10);

            resultFull.Add(result1);
            resultFull.Add(result2);
            var xml = resultFull.ToXml();

            Console.WriteLine(xml);

            var newResultFull = new DuplicateResultFull();

            newResultFull.InitFromXml(xml);
            Console.ReadKey();
        }