using System.IO; using System.Text; using ThoughtWorks.CruiseControl.Core.Reporting.Dashboard.Navigation; using ThoughtWorks.CruiseControl.WebDashboard.IO; using ThoughtWorks.CruiseControl.WebDashboard.MVC; using ThoughtWorks.CruiseControl.WebDashboard.MVC.Cruise; namespace ThoughtWorks.CruiseControl.WebDashboard.Plugins.CCTray { public class CCTrayDownloadAction : ICruiseAction { public const string ActionName = "CCTrayDownload"; private readonly IPhysicalApplicationPathProvider physicalApplicationPathProvider; public CCTrayDownloadAction(IPhysicalApplicationPathProvider physicalApplicationPathProvider) { this.physicalApplicationPathProvider = physicalApplicationPathProvider; } public IResponse Execute(ICruiseRequest cruiseRequest) { DirectoryInfo cctrayPath = new DirectoryInfo(physicalApplicationPathProvider.GetFullPathFor("CCTray")); if (cctrayPath.Exists) { FileInfo[] files = cctrayPath.GetFiles("*CCTray*.*"); if (files.Length == 1) { return new RedirectResponse("CCTray/" + files[0].Name); } else if (files.Length > 1) { StringBuilder installerList = new StringBuilder(); installerList.Append(@"

Multiple CCTray installers available

"); installerList.Append(@"

Choose one of the following CCTray installers:"); installerList.Append(@"

"); installerList.Append(@"

"); return new HtmlFragmentResponse(installerList.ToString()); } } return new HtmlFragmentResponse("

Unable to locate CCTray installer at path: " + cctrayPath + "

"); } } }