public void VerifyFormattedDateString()
		{
			DateTime date = new DateTime(1971, 5, 14, 15, 0, 0);
			string actual = new LogFile("log19710514150000.xml").FormattedDateString;
			string expected = DateUtil.FormatDate(date);
			Assert.AreEqual(expected, actual);
		}
	    public ConditionalGetFingerprint GetFingerprint(IRequest request)
	    {
	        // TODO - Maybe should get date from Build type rather than LogFile?
	        ICruiseRequest cruiseRequest = new NameValueCruiseRequestFactory().CreateCruiseRequest(request, urlBuilder, retriever);
            LogFile logFile = new LogFile(cruiseRequest.BuildSpecifier.BuildName);
	        DateTime buildDate = logFile.Date;
	        ConditionalGetFingerprint logFingerprint = fingerprintFactory.BuildFromDate(buildDate);
	        ConditionalGetFingerprint templateFingerprint = fingerprintFactory.BuildFromFileNames(TEMPLATE_NAME);
	        return logFingerprint.Combine(templateFingerprint);
	    }
 public ConditionalGetFingerprint GetFingerprint(IRequest request)
 {
     ICruiseRequest cruiseRequest = new NameValueCruiseRequestFactory().CreateCruiseRequest(request, urlBuilder, retriever);
     IBuildSpecifier mostRecentBuildSpecifier =
         farmService.GetMostRecentBuildSpecifiers(cruiseRequest.ProjectSpecifier, 1, cruiseRequest.RetrieveSessionToken())[0];
     DateTime mostRecentBuildDate = new LogFile(mostRecentBuildSpecifier.BuildName).Date;
     ConditionalGetFingerprint mostRecentBuildFingerprint =
         fingerprintFactory.BuildFromDate(mostRecentBuildDate);
     ConditionalGetFingerprint mostRecentTemplateFingerprint =
         fingerprintFactory.BuildFromFileNames(@"BuildRows.vm", @"RecentBuilds.vm", @"AllBuilds.vm");
     return mostRecentBuildFingerprint.Combine(mostRecentTemplateFingerprint);
 }
        /// <summary>
        /// Appends a build to the document.
        /// </summary>
        /// <param name="build">The build.</param>
        /// <param name="xmlWriter">The XML writer.</param>
        /// <param name="basePath">The base path.</param>
        private void AppendBuild(IBuildSpecifier build, XmlWriter xmlWriter, string basePath)
        {
            var logFile = new LogFile(build.BuildName);
            xmlWriter.WriteStartElement("event");
            xmlWriter.WriteAttributeString("start", logFile.Date.ToString("r"));
            xmlWriter.WriteAttributeString("title", logFile.Succeeded ? "Success (" + logFile.Label + ")" : "Failure");
            xmlWriter.WriteAttributeString("color", logFile.Succeeded ? "green" : "red");
            xmlWriter.WriteAttributeString("icon", basePath + "dark-" + (logFile.Succeeded ? "green" : "red") + "-circle.png");

            var buildUrl = this.urlBuilder.BuildBuildUrl(BuildReportBuildPlugin.ACTION_NAME, build);
            xmlWriter.WriteString("<a href=\"" + buildUrl + "\">View Build</a>");
            xmlWriter.WriteEndElement();
        }
        public BuildSummary Details(string project, string id)
        {
            this.ValidateServer();

            var entity = this.RetrieveProject(project);
            if (entity == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var model = new LogFile(id).ToModel();
            var result = this.CruiseServer.GetFinalBuildStatus(new BuildRequest(null, entity.Name) { BuildName = id });
            model.Tasks = result.Snapshot.ToModel();
            return model;
        }
 /// <summary>
 /// List the available packages for a build.
 /// </summary>
 /// <param name="buildSpecifier"></param>
 /// <param name="sessionToken"></param>
 /// <returns></returns>
 public virtual PackageDetails[] RetrievePackageList(IBuildSpecifier buildSpecifier, string sessionToken)
 {
     var logFile = new LogFile(buildSpecifier.BuildName);
     var response = GetCruiseManager(buildSpecifier, sessionToken)
         .RetrievePackageList(buildSpecifier.ProjectSpecifier.ProjectName, logFile.Label);
     return response.ToArray();
 }
 public virtual RemotingFileTransfer RetrieveFileTransfer(IBuildSpecifier buildSpecifier, string fileName, string sessionToken)
 {
     var logFile = new LogFile(buildSpecifier.BuildName);
     var fullName = string.Format(System.Globalization.CultureInfo.CurrentCulture,"{0}\\{1}", logFile.Label, fileName);
     var fileTransfer = GetCruiseManager(buildSpecifier, sessionToken)
         .RetrieveFileTransfer(buildSpecifier.ProjectSpecifier.ProjectName, fullName);
     return fileTransfer as RemotingFileTransfer;
 }
        public BuildSummary Log(string project, string id, string format)
        {
            this.ValidateServer();

            var entity = this.RetrieveProject(project);
            if (entity == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var model = new LogFile(id).ToModel();
            var result = this.CruiseServer.GetLog(new BuildRequest(null, entity.Name) { BuildName = id });
            if (string.IsNullOrEmpty(format))
            {
                model.Log = result.Data;
            }
            else
            {
                var xslt = new XslCompiledTransform();
                var path = Path.Combine(Environment.CurrentDirectory, "Templates", format + ".xsl");
                if (!File.Exists(path))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }

                using (var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (var reader = XmlReader.Create(stream))
                    {
                        xslt.Load(reader);
                    }
                }

                var xml = new XmlDocument();
                xml.LoadXml(result.Data);
                var builder = new StringBuilder();
                using (var output = XmlWriter.Create(builder))
                {
                    xslt.Transform(xml, output);
                }

                model.Log = builder.ToString();
            }

            return model;
        }
 public string GetPrettyBuildName(IBuildSpecifier buildSpecifier, IFormatProvider formatter)
 {
     LogFile logFile = new LogFile(buildSpecifier.BuildName, formatter);
     //return string.Format("{0} ({1})", logFile.FormattedDateString, logFile.Succeeded ? logFile.Label : "Failed");
     return string.Format("{0} ({1})", logFile.FormattedDateString, logFile.Label);
 }
		private void CheckDateString(string expected, string filename)
		{
			string actual = new LogFile(filename).FilenameFormattedDateString;
			Assert.AreEqual(expected, actual);
		}
		public string GetPrettyBuildName(IBuildSpecifier buildSpecifier, IFormatProvider formatter)
		{
			LogFile logFile = new LogFile(buildSpecifier.BuildName, formatter);
			return string.Format(System.Globalization.CultureInfo.CurrentCulture,"{0} ({1})", logFile.FormattedDateString, logFile.Succeeded ? logFile.Label : "Failed");	
		}