static string GetAutoIncrementedExistingLabel( RestApi restApi, string repository, string existingLabelName) { Label lastMatchingLabel = FindQueries.FindMostRecentLabel( restApi, repository, DateTime.MinValue, existingLabelName + Tokens.AUTO_INCREMENT_EXISTING_PATTERN); return(NewLabelNameGenerator.GetNewLabelName( existingLabelName + Tokens.AUTO_INCREMENT_EXISTING_PATTERN, lastMatchingLabel)); }
internal static Result CreateLabel( RestApi restApi, int csetId, string repository, string labelPattern, DateTime now) { if (string.IsNullOrEmpty(labelPattern)) { return(new Result(false, string.Empty, Messages.NO_PATTERN_SPECIFIED)); } string plasticFindPattern = PatternTranslator.ToFindPattern(labelPattern, now); if (string.IsNullOrEmpty(plasticFindPattern)) { return(new Result(false, string.Empty, Messages.MALFORMED_PATTERN)); } Label lastMatchingLabel = FindQueries.FindMostRecentLabel( restApi, repository, now.AddYears(-2), plasticFindPattern); string newLabelNameCandidate = NewLabelNameGenerator.GetNewLabelName( plasticFindPattern, lastMatchingLabel); if (string.IsNullOrEmpty(newLabelNameCandidate)) { return(new Result( false, string.Empty, string.Format( Messages.CANNOT_CALCULATE_NAME_CANDIDATE, plasticFindPattern))); } string newLabelName = PickNonExistentLabelName( restApi, repository, newLabelNameCandidate); if (string.IsNullOrEmpty(newLabelName)) { return(new Result( false, string.Empty, string.Format( Messages.CANNOT_CALCULATE_NAME_CANDIDATE_AUTO, newLabelName, newLabelName + Tokens.AUTO_INCREMENT_EXISTING_PATTERN))); } return(CreateLabelInRep(newLabelName, csetId, repository, restApi)); }