//------------------------------------------------------------------------- public void AddStats(BuildStats stats) { if (Stats.Contains(stats) == false) { Stats.Add(stats); //-- Update stats. // Total build count. TotalBuildsCount++; // Completed builds count. if (stats.End != null) { CompletedBuildsCount++; } // Total build time for all builds. TimeSpan?buildTime = stats.GetBuildTime(); if (buildTime != null) { TotalBuildTime += (TimeSpan)buildTime; } // Average build time. AverageBuildTime = new TimeSpan(0, 0, (int)(TotalBuildTime.TotalSeconds / CompletedBuildsCount)); // Max build time. if (buildTime != null && (MaxBuildTime == null || buildTime > MaxBuildTime)) { MaxBuildTime = (TimeSpan)buildTime; } } }
//------------------------------------------------------------------------- public void AddBuild( DateTime start, DateTime?end, string[] tags) { // Create new stats object. BuildStats stats = new BuildStats(start, end); // Include these stats under the 'all' tag. stats.AddTag(AllBuilds); // Add the tags to the stats object. foreach (string t in tags) { // 'All' is reserved. if (t.ToLower() == "all") { throw new Exception("The tag 'all' is reserved for internal use."); } // Add the tag to the stats. BuildTag tag = BuildTag.GetTag(t); stats.AddTag(tag); } // Add build to the relevant tags' build collection. foreach (BuildTag tag in stats.GetTags()) { if (Stats.ContainsKey(tag) == false) { Stats.Add(tag, new BuildStatsCollection()); } Stats[tag].AddStats(stats); } }