public IEnumerable <ReleaseApproval> ListPendingApprovalsForASpecificARelease() { string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name; // Get a release client instance VssConnection connection = Context.Connection; ReleaseHttpClient2 releaseClient = connection.GetClient <ReleaseHttpClient2>(); var releases = releaseClient.GetReleasesAsync(project: projectName).Result; int releaseIdFilter = releases.FirstOrDefault().Id; List <ReleaseApproval> releaseApprovals = new List <ReleaseApproval>(); // Iterate (as needed) to get the full set of approvals int continuationToken = 0; bool parseResult; do { IPagedCollection <ReleaseApproval> releaseApprovalsPage = releaseClient.GetApprovalsAsync2(project: projectName, releaseIdsFilter: new List <int> { releaseIdFilter }, continuationToken: continuationToken).Result; releaseApprovals.AddRange(releaseApprovalsPage); int parsedContinuationToken = 0; parseResult = int.TryParse(releaseApprovalsPage.ContinuationToken, out parsedContinuationToken); if (parseResult) { continuationToken = parsedContinuationToken; } } while ((continuationToken != 0) && parseResult); // Show the approvals foreach (ReleaseApproval releaseApproval in releaseApprovals) { Console.WriteLine("{0} {1}", releaseApproval.Id.ToString().PadLeft(6), releaseApproval.Status); } return(releaseApprovals); }
public IEnumerable <ReleaseApproval> ListPendingApprovalsForASpecificUser() { string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name; string assignedToFilter = ClientSampleHelpers.GetCurrentUserDisplayName(this.Context); // Get a release client instance VssConnection connection = Context.Connection; ReleaseHttpClient2 releaseClient = connection.GetClient <ReleaseHttpClient2>(); List <ReleaseApproval> releaseApprovals = new List <ReleaseApproval>(); // Iterate (as needed) to get the full set of approvals int continuationToken = 0; bool parseResult; do { IPagedCollection <ReleaseApproval> releaseApprovalsPage = releaseClient.GetApprovalsAsync2(project: projectName, assignedToFilter: assignedToFilter, continuationToken: continuationToken).Result; releaseApprovals.AddRange(releaseApprovalsPage); int parsedContinuationToken = 0; parseResult = int.TryParse(releaseApprovalsPage.ContinuationToken, out parsedContinuationToken); if (parseResult) { continuationToken = parsedContinuationToken; } } while ((continuationToken != 0) && parseResult); // Show the approvals foreach (ReleaseApproval releaseApproval in releaseApprovals) { Context.Log("{0} {1}", releaseApproval.Id.ToString().PadLeft(6), releaseApproval.Status); } return(releaseApprovals); }