Beispiel #1
0
        public static string GenerateDetailRows(List <ResultDbEntry> resultList)
        {
            string output           = String.Empty;
            string changelogsOutput = String.Empty;

            // FIXME Exception if more than 50 results...
            // FIXME Reverse the copy
            resultList.Reverse();
            bool hasPrevResult = false;
            long prevResult    = 0;
            int  id            = 1;

            foreach (ResultDbEntry entry in resultList)
            {
                string cls = "normal";

                if (!entry.Failure)
                {
                    if (hasPrevResult && UtilFu.GetValueDifference(prevResult, entry.Time) > 0.1)
                    {
                        cls = "red";
                    }
                    else if (hasPrevResult && UtilFu.GetValueDifference(prevResult, entry.Time) < -0.1)
                    {
                        cls = "green";
                    }

                    hasPrevResult = true;
                    prevResult    = entry.Time;
                }
                else
                {
                    cls = "black";
                }

                string html = DetailRowTemplate;
                html = html.Replace("@@DETAIL_CLASS@@", cls);
                html = html.Replace("@@DETAIL_ID@@", id.ToString());
                html = html.Replace("@@PASS_SHORT_NAME@@", entry.Pass.ShortName);

                string author = String.Empty;
                if (entry.Pass.Author != String.Empty)
                {
                    author = String.Format("[{0}]", entry.Pass.Author);
                }

                html = html.Replace("@@PASS_AUTHOR@@", author);

                html = html.Replace("@@DATE@@", entry.Pass.Date.ToString());

                if (!entry.Failure)
                {
                    html = html.Replace("@@RESULT@@", String.Format("{0:0.000}", (entry.Time / (float)1000000)));
                }
                else
                {
                    html = html.Replace("@@RESULT@@", "FAILURE");
                }

                // Add also the detail changelog
                string changelog = ChangelogTemplate;
                changelog = changelog.Replace("@@DETAIL_ID@@", id.ToString());

                if (entry.Pass.ChangeLog != String.Empty)
                {
                    changelog = changelog.Replace("@@DETAIL_CHANGELOG@@", entry.Pass.ChangeLog);
                }
                else
                {
                    changelog = changelog.Replace("@@DETAIL_CHANGELOG@@", "No ChangeLog data");
                }

                changelogsOutput += changelog;
                output            = html + output;
                id += 1;
            }

            return(output + changelogsOutput);
        }
Beispiel #2
0
        public static void GenerateGraph(List <ResultDbEntry> resultList, string filename)
        {
            // FIXME Exception if more than 50 results...

            ImageSurface surface = new ImageSurface(Format.Rgb24, 103, 52);
            Context      context = new Context(surface);

            // Fill with grad
            LinearGradient grad = new LinearGradient(0.0, 0.0, 0.0, 52.0);

            grad.AddColorStopRgb(0.0, new Color(1.0, 1.0, 1.0));
            grad.AddColorStopRgb(1.0, new Color(0.8, 0.8, 0.9));
            context.Pattern = grad;
            context.Paint();

            // Frame
            context.SetSourceRGB(0, 0, 0);
            context.LineWidth = 1.0;
            context.Rectangle(0.5, 0.5, 102.0, 51.0);
            context.Stroke();

            long denominator = (long)(FindBiggestResult(resultList) * 1.2);

            context.LineWidth = 1.5;

            // FIXME Reverse to copy
            resultList.Reverse();

            double x             = 100.5 - ((resultList.Count - 1) * 2.0);
            bool   hasPrevResult = false;
            long   prevResult    = 0;

            foreach (ResultDbEntry entry in resultList)
            {
                if (entry.Failure)
                {
                    x += 2.0;
                    continue;
                }

                double sz = ((double)entry.Time / denominator) * 50.0;

                if (hasPrevResult && UtilFu.GetValueDifference(prevResult, entry.Time) > 0.1)
                {
                    context.SetSourceRGB(1.0, 0.0, 0.0);
                }
                else if (hasPrevResult && UtilFu.GetValueDifference(prevResult, entry.Time) < -0.1)
                {
                    context.SetSourceRGB(0.0, 1.0, 0.0);
                }
                else
                {
                    context.SetSourceRGB(0.4, 0.4, 0.4);
                }

                context.MoveTo(x, 51);
                context.LineTo(x, 51 - sz);
                context.Stroke();

                x += 2.0;

                hasPrevResult = true;
                prevResult    = entry.Time;
            }

            surface.WriteToPng(filename);

            resultList.Reverse();
            ((IDisposable)context).Dispose();
            ((IDisposable)surface).Dispose();
        }