public void ExecuteTask(WaitHandle stopSignal) { // retrieve the latest history from the revision control RevisionControlHistoryData history = rcHistoryFacility.FetchHistory(); List <string> chartImageFileNames = new List <string>(); // generate charts and save their storage locations chartImageFileNames.Add(DrawCommitsPerDayPerAuthorChart(history)); chartImageFileNames.Add(DrawCommittedFilesPerDayPerActionChart(history)); // translate storage locations to URLs for (int i = 0; i < chartImageFileNames.Count; i++) { string chartImageFileName = chartImageFileNames[i]; Uri url = fileManager.TranslateToUrl(chartImageFileName); chartImageFileNames[i] = url.ToString(); } // generate wrapper HTML document // and save it to the project's storage location Hashtable templateContext = new Hashtable(); templateContext.Add("project", projectRegistry.GetProject(projectId)); templateContext.Add("reportImages", chartImageFileNames); templateEngine.ApplyTemplate( "RevisionControlHistory.vm", templateContext, fileManager.GetProjectFullFileName(projectId, ModuleId, "RevisionControlHistory.html", true)); }
private string DrawCommitsPerDayPerAuthorChart(RevisionControlHistoryData history) { FluentChart chart = FluentChart.Create("Commits History", null, "commits per day") .SetBarSettings(BarType.Stack, 0) .UseDateAsAxisY(history.MinTime.Date, history.MaxTime.Date); string[] colors = { "blue", "red", "green", "yellow", "orange", "brown" }; IDictionary <string, SortedList <DateTime, double> > commitsPerAuthorPerDay = RevisionControlHistoryDataMiner.FetchCommitsPerAuthorPerDay(history); int i = 0; foreach (string author in commitsPerAuthorPerDay.Keys) { chart .AddBarSeries(author, colors[i++]) .AddDataByDate(commitsPerAuthorPerDay[author], history.MinTime.Date, history.MaxTime.Date); } string chartImageFileName = fileManager.GetProjectFullFileName( projectId, ModuleId, "CommitsPerDayPerAuthorChart.png", true); chart .ExportToBitmap(chartImageFileName, ImageFormat.Png, 2000, 800); return(chartImageFileName); }
public void DrawCommitsPerDayPerAuthorChart() { RevisionControlHistoryData data = LoadHistoryFromFile(); FluentChart chart = FluentChart.Create("Commits History", null, "commits per day") .SetBarSettings(BarType.Stack, 0) .UseDateAsAxisY(data.MinTime.Date, data.MaxTime.Date); string[] colors = { "blue", "red", "green", "yellow", "orange", "brown" }; IDictionary <string, SortedList <DateTime, double> > commitsPerAuthorPerDay = RevisionControlHistoryDataMiner.FetchCommitsPerAuthorPerDay(data); int i = 0; foreach (string author in commitsPerAuthorPerDay.Keys) { chart .AddBarSeries(author, colors[i++]) .AddDataByDate(commitsPerAuthorPerDay[author], data.MinTime.Date, data.MaxTime.Date); } chart .ExportToBitmap("test.png", ImageFormat.Png, 2000, 800); }
public void DrawCommittedFilesPerDayPerActionChart() { RevisionControlHistoryData data = LoadHistoryFromFile(); FluentChart chart = FluentChart.Create("Committed Files History", null, "commited files per day") .SetBarSettings(BarType.Stack, 0) .UseDateAsAxisY(data.MinTime.Date, data.MaxTime.Date); string[] colors = { "blue", "red", "green", "yellow", "orange", "brown" }; IDictionary <RevisionControlHistoryEntryAction, SortedList <DateTime, double> > reportData = RevisionControlHistoryDataMiner.FetchCommittedFilesPerActionTypePerDay(data); int i = 0; foreach (RevisionControlHistoryEntryAction action in reportData.Keys) { chart .AddBarSeries(action.ToString(), colors[i++]) .AddDataByDate(reportData[action], data.MinTime.Date, data.MaxTime.Date); } chart .ExportToBitmap("test.png", ImageFormat.Png, 2000, 800); }
private static void ReadLog(RevisionControlHistoryData historyData, XmlReader xmlReader) { xmlReader.Read(); while (xmlReader.NodeType != XmlNodeType.EndElement) { switch (xmlReader.Name) { case "logentry": ReadLogEntry(historyData, xmlReader); break; default: throw new NotSupportedException(); } } }
public static RevisionControlHistoryData LoadHistory(Stream stream) { RevisionControlHistoryData historyData = new RevisionControlHistoryData(); XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.IgnoreComments = true; xmlReaderSettings.IgnoreProcessingInstructions = true; xmlReaderSettings.IgnoreWhitespace = true; using (XmlReader xmlReader = XmlReader.Create(stream, xmlReaderSettings)) { xmlReader.Read(); while (false == xmlReader.EOF) { switch (xmlReader.NodeType) { case XmlNodeType.XmlDeclaration: xmlReader.Read(); continue; case XmlNodeType.Element: if (xmlReader.Name != "log") { throw new XmlException("<log> element expected."); } ReadLog(historyData, xmlReader); return(historyData); default: throw new XmlException(); } } } return(null); }
private static void ReadLogEntry(RevisionControlHistoryData historyData, XmlReader xmlReader) { RevisionControlHistoryEntry entry = new RevisionControlHistoryEntry(); entry.Revision = xmlReader.GetAttribute("revision"); xmlReader.Read(); while (xmlReader.NodeType != XmlNodeType.EndElement) { switch (xmlReader.Name) { case "author": entry.Author = xmlReader.ReadElementContentAsString(); break; case "date": entry.Time = xmlReader.ReadElementContentAsDateTime(); break; case "msg": entry.Message = xmlReader.ReadElementContentAsString(); break; case "paths": ReadPaths(entry, xmlReader); break; default: throw new NotSupportedException(); } } xmlReader.Read(); historyData.AddEntry(entry); }
public void LoadHistory() { RevisionControlHistoryData data = LoadHistoryFromFile(); Assert.AreEqual(834, data.Entries.Count); }
public RevisionControlHistoryData FetchHistory() { // load the previously fetched history from the persistent storage using (ISessionState sessionState = sessionStorage.LoadSession( String.Format( CultureInfo.InvariantCulture, "SubversionHistoryFacility_{0}", facilityId))) { RevisionControlHistoryData lastFetchedHistory = sessionState.GetValue <RevisionControlHistoryData>(SessionKeyLastFetchedHistory); // find the last revision that was fetched string lastRevisionFetched = null; if (lastFetchedHistory != null) { lastRevisionFetched = lastFetchedHistory.LastRevision; } // svn log d:\svn\mobilkom.nl-bhwr\trunk\src -v --xml --non-interactive >D:\BuildArea\builds\mobilkom.nl-bhwr\svn-log.xml // -r 1729:HEAD using (Process process = new Process()) { StringBuilder argumentsBuilder = new StringBuilder(); argumentsBuilder.AppendFormat( CultureInfo.InvariantCulture, @"log ""{0}"" --xml --non-interactive", svnRootPath); // add revisions range, if we have history data fetched previously if (lastRevisionFetched != null) { int lastRevisionFetchedInt = Int32.Parse(lastRevisionFetched, CultureInfo.InvariantCulture); argumentsBuilder.AppendFormat( CultureInfo.InvariantCulture, " -r {0}:HEAD", lastRevisionFetchedInt + 1); } process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.FileName = svnToolPath; process.StartInfo.Arguments = argumentsBuilder.ToString(); process.Start(); process.WaitForExit(); // merge the two histories RevisionControlHistoryData historyData = LoadHistory(process.StandardOutput.BaseStream); if (lastFetchedHistory != null) { historyData.Merge(lastFetchedHistory); } // save the new history to the session state sessionState.SetValue(SessionKeyLastFetchedHistory, historyData); return(historyData); } } }