private Agent(MigrationContext context, Settings settings, VsWebApi.VssConnection restConn, TfsTeamProjectCollection soapConnection) { _context = context; Settings = settings; RestConnection = restConn; Collection = soapConnection; }
public void ReassignState(string workItemId, string oldValue) { var uri = new Uri("https://dev.azure.com"); var personalAccessToken = "xxxxxx"; //Personal access token generated in AzDO var projectName = "xxxxxx"; //Project name in AzDo var credentials = new VssBasicCredential("", personalAccessToken); var connection = new Microsoft.VisualStudio.Services.WebApi.VssConnection(uri, credentials); var workItemTrackingHttpClient = connection.GetClient <WorkItemTrackingHttpClient>(); var wiqlQuery = new Wiql() { Query = "Select * from WorkItems Where [ID] = " + workItemId }; var workItemQueryResultForWiqlBasedQuery = workItemTrackingHttpClient.QueryByWiqlAsync(wiqlQuery).Result; var workItemsForQueryResultForWiqlBasedQuery = workItemTrackingHttpClient .GetWorkItemsAsync( workItemQueryResultForWiqlBasedQuery.WorkItems.Select(workItemReference => workItemReference.Id), expand: WorkItemExpand.All).Result; foreach (var item in workItemsForQueryResultForWiqlBasedQuery) { item.Fields["State"] = oldValue; var auxResult = workItemTrackingHttpClient.UpdateWorkItemAsync(GetUpdateWITOpp(oldValue), (int)item.Id).Result; } }