public string Generate(IIntegrationResult integrationResult)
{
Version oldVersion;
// try getting old version
try
{
Log.Debug(string.Concat("Old build label is: ", integrationResult.LastIntegration.Label));
oldVersion = new Version(integrationResult.LastIntegration.Label);
}
catch (Exception)
{
oldVersion = new Version(0, 0, 0, 0);
}
Log.Debug(string.Concat("Old version is: ", oldVersion.ToString()));
// get current year, month and day
DateTime now = DateTime.Now;
int currentYear = now.Year - 2000;
int currentMonth = now.Month;
int currentDay = now.Day;
// get current build number
int currentBuild = 1;
if (currentYear == oldVersion.Major
&& currentMonth == oldVersion.Minor
&& currentDay == oldVersion.Build)
currentBuild = oldVersion.Revision + 1;
Version newVersion = new Version(
currentYear,
currentMonth,
currentDay,
currentBuild);
Log.Debug(string.Concat("New version is: ", newVersion.ToString()));
// return new version string
return newVersion.ToString();
}