public PluginCommandResponseMessage Execute(string args, UserDTO user) { var mappingArgs = args.Deserialize<AutomapVcsToTpUsersCommandArgs>(); var alreadyMappedAuthors = mappingArgs.Connection.UserMapping.Select(x => x.Key); var vcs = _vcsFactory.Get(mappingArgs.Connection); var authors = vcs.RetrieveAuthors(new DateRange(CurrentDate.Value.AddMonths(-1), CurrentDate.Value)); authors = authors .Where(x => alreadyMappedAuthors.FirstOrDefault(y => y.Trim().ToLower() == x.Trim().ToLower()) == null) .ToArray(); var userLookups = new Dictionary<string, MappingLookup>(); foreach (var author in authors) { var userLookup = GetMatchedUserLookup(author, mappingArgs.TpUsers); if (userLookup != null) { userLookups.Add(author, userLookup); } } var result = new AutomapVcsToTpUsersCommandResponse {UserLookups = userLookups}; UpdateResultComment(result, authors); foreach (var mappingElement in mappingArgs.Connection.UserMapping) { result.UserLookups[mappingElement.Key] = mappingElement.Value; } return new PluginCommandResponseMessage {ResponseData = result.Serialize()}; }
private void UpdateResultComment(AutomapVcsToTpUsersCommandResponse result, IEnumerable<string> authors) { UpdateWithMappedSvnAuthors(result, authors); if (string.IsNullOrEmpty(result.Comment)) { result.Comment += string.Format("No matches for {0} user(s) found", PluginName); } }
private void UpdateResultComment(AutomapVcsToTpUsersCommandResponse result, IEnumerable <string> authors) { UpdateWithMappedSvnAuthors(result, authors); if (string.IsNullOrEmpty(result.Comment)) { result.Comment += string.Format("No matches for {0} user(s) found", PluginName); } }
private void UpdateWithUnmappedSvnAuthors(AutomapVcsToTpUsersCommandResponse result, IEnumerable <string> authors) { var vcsUnmappedUsers = GetVcsUnmappedUsersCount(authors, result.UserLookups.Keys.ToArray()); if (vcsUnmappedUsers != 0) { result.Comment += string.Format(", and no matches were found for {0} {1} user(s)", vcsUnmappedUsers, PluginName); } }
private void UpdateWithMappedSvnAuthors(AutomapVcsToTpUsersCommandResponse result, IEnumerable<string> authors) { if (!result.UserLookups.Empty()) { if (authors.Count() == result.UserLookups.Count) { result.Comment = string.Format("All the {0} {1} user(s) were mapped", result.UserLookups.Count, PluginName); } else { result.Comment = string.Format("{0} {1} user(s) were mapped", result.UserLookups.Count, PluginName); } UpdateWithUnmappedSvnAuthors(result, authors); } }
private void UpdateWithMappedSvnAuthors(AutomapVcsToTpUsersCommandResponse result, IEnumerable <string> authors) { if (!result.UserLookups.Empty()) { if (authors.Count() == result.UserLookups.Count) { result.Comment = string.Format("All the {0} {1} user(s) were mapped", result.UserLookups.Count, PluginName); } else { result.Comment = string.Format("{0} {1} user(s) were mapped", result.UserLookups.Count, PluginName); } UpdateWithUnmappedSvnAuthors(result, authors); } }
public PluginCommandResponseMessage Execute(string args) { var mappingArgs = args.Deserialize <AutomapVcsToTpUsersCommandArgs>(); var alreadyMappedAuthors = mappingArgs.Connection.UserMapping.Select(x => x.Key); var vcs = _vcsFactory.Get(mappingArgs.Connection); var authors = vcs.RetrieveAuthors(new DateRange(CurrentDate.Value.AddMonths(-1), CurrentDate.Value)); authors = authors .Where(x => alreadyMappedAuthors.FirstOrDefault(y => y.Trim().ToLower() == x.Trim().ToLower()) == null) .ToArray(); var userLookups = new Dictionary <string, MappingLookup>(); foreach (var author in authors) { var userLookup = GetMatchedUserLookup(author, mappingArgs.TpUsers); if (userLookup != null) { userLookups.Add(author, userLookup); } } var result = new AutomapVcsToTpUsersCommandResponse { UserLookups = userLookups }; UpdateResultComment(result, authors); foreach (var mappingElement in mappingArgs.Connection.UserMapping) { result.UserLookups[mappingElement.Key] = mappingElement.Value; } return(new PluginCommandResponseMessage { ResponseData = result.Serialize() }); }
private void UpdateWithUnmappedSvnAuthors(AutomapVcsToTpUsersCommandResponse result, IEnumerable<string> authors) { var vcsUnmappedUsers = GetVcsUnmappedUsersCount(authors, result.UserLookups.Keys.ToArray()); if (vcsUnmappedUsers != 0) { result.Comment += string.Format(", and no matches were found for {0} {1} user(s)", vcsUnmappedUsers, PluginName); } }