private IEnumerable <Changeset> BuildQuery(ChangesetSearchModel search) { var projectCollection = _tfsServer.GetCollection(); if (projectCollection.HasAuthenticated == false) { projectCollection.Authenticate(); } // Get the Changeset list from the TFS API. _versionControlServer = projectCollection.GetService <VersionControlServer>(); var qryHistroy = _versionControlServer.QueryHistory(search.ProjectSourcePath, VersionSpec.Latest, 0, RecursionType.Full, null, null, null, search.TopN, false, false, false, false) .OfType <Changeset>(); if (search.IsSearchBasedOnRegex) { var rx = new Regex(search.SearchKeyword, RegexOptions.IgnoreCase); qryHistroy = qryHistroy.Where(p => rx.IsMatch(search.SearchKeyword) && (string.IsNullOrEmpty(search.Committer) || p.CommitterDisplayName == search.Committer)); } else { qryHistroy = qryHistroy.Where(p => (string.IsNullOrEmpty(search.SearchKeyword) || p.Comment.Contains(search.SearchKeyword)) && (string.IsNullOrEmpty(search.Committer) || p.CommitterDisplayName == search.Committer)); } return(qryHistroy); }
public async Task <IEnumerable <Changeset> > GetAsync(ChangesetSearchModel search) { Task <IEnumerable <Changeset> > qryHistory; qryHistory = Task.Factory.StartNew(() => BuildQuery(search)); return(await qryHistory); }