PageRenderTime 233ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/CCNetPlugins/VersionLabeller.cs

https://github.com/RickyLin/DotNetUtilities
C# | 43 lines | 37 code | 5 blank | 1 comment | 0 complexity | 340603089edbb569819eb6f3675f64eb MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using ThoughtWorks.CruiseControl.Core;
  6. using ThoughtWorks.CruiseControl.Core.Util;
  7. using ThoughtWorks.CruiseControl.Remote;
  8. using ThoughtWorks.CruiseControl.Core.Label;
  9. using Exortech.NetReflector;
  10. namespace CCNetPlugins
  11. {
  12. [ReflectorType("versionLabeller")]
  13. public class VersionLabeller : ILabeller
  14. {
  15. [ReflectorProperty("major")]
  16. public string Major { get; set; }
  17. [ReflectorProperty("minor")]
  18. public string Minor { get; set; }
  19. public string Generate(IIntegrationResult integrationResult)
  20. {
  21. // generate the version string
  22. string[] version = new string[4];
  23. version[0] = Major;
  24. version[1] = Minor;
  25. TimeSpan days, seconds;
  26. DateTime beginDate = new DateTime(2000, 1, 1);
  27. days = DateTime.Today - beginDate;
  28. seconds = DateTime.Now - DateTime.Today.AddHours(-12);
  29. version[2] = days.Days.ToString(); // Build
  30. version[3] = Convert.ToString(Convert.ToInt32(seconds.TotalMinutes)); // Revision
  31. return string.Join(".", version);
  32. }
  33. public void Run(IIntegrationResult result)
  34. {
  35. result.Label = Generate(result);
  36. }
  37. }
  38. }