Exemplo n.º 1
0
 public void Run(IIntegrationResult result)
 {
     XmlSerializer serializer = new XmlSerializer(typeof (Modification[]));
     StringWriter writer = new Utf8StringWriter();
     serializer.Serialize(writer, result.Modifications);
     fileSystem.Save(ModificationFile(result), writer.ToString());
 }
        /// <summary>
        /// Write the state to disk, ensuring that it gets there in its entirety.
        /// </summary>
        /// <param name="result">The integration to save the state for.</param>
		public void SaveState(IIntegrationResult result)
		{
			XmlSerializer serializer = new XmlSerializer(typeof (IntegrationResult));
			StringWriter buffer = new Utf8StringWriter();
			serializer.Serialize(buffer, result);

			string path = GetFilePath(result.ProjectName);
			try
			{
				fileSystem.AtomicSave(path, buffer.ToString());
			}
			catch (SystemException e)
			{
				throw new CruiseControlException(
					string.Format(System.Globalization.CultureInfo.CurrentCulture,"Unable to save the IntegrationResult to the specified directory: {0}{1}{2}",
                        path, Environment.NewLine, buffer),
                    e);
			}
		}
        /// <summary>
        /// Executes the specified result.	
        /// </summary>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        protected override bool Execute(IIntegrationResult result)
        {
            result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Writing Modifications");                

            XmlSerializer serializer = new XmlSerializer(typeof(Modification[]));
            StringWriter writer = new Utf8StringWriter();
            serializer.Serialize(writer, result.Modifications);
            string filename = ModificationFile(result);
            fileSystem.EnsureFolderExists(filename);
            fileSystem.Save(filename, writer.ToString());

            return true;
        }