public RetrieveBuildsRequest(TfsProject project, BuildStatus[] buildStatuses) { Contract.Requires <ArgumentNullException>(null != project, nameof(project)); Project = project; BuildStatuses = buildStatuses; }
public void ReadFromDisk(string filename, TfsProject source, TfsProject target) { using (var tw = File.OpenText(filename)) { var serializer = JsonSerializer.Create(); var st = serializer.Deserialize <List <WorkItemFieldMap2> >(new JsonTextReader(tw)); mapping = new Dictionary <WorkItemType, WorkItemType>(); fieldMapping = new List <WorkItemFieldMap>(); foreach (var item in st) { var sourceType = source.project.WorkItemTypes[item.SourceWorkIemType]; var targetType = target.project.WorkItemTypes[item.TargetWorkIemType]; mapping[sourceType] = targetType; var newFm = new WorkItemFieldMap(sourceType, targetType); foreach (var fieldmap in item.MappedReferenceNames) { var sourceFieldDefinition = sourceType.FieldDefinitions.Cast <FieldDefinition>().First(a => a.ReferenceName == fieldmap.Key); var targetFieldDefinition = targetType.FieldDefinitions.Cast <FieldDefinition>().First(a => a.ReferenceName == fieldmap.Value); newFm.mapping[sourceFieldDefinition] = targetFieldDefinition; } fieldMapping.Add(newFm); } } }
public async Task <TFSTeamsResponse> GetTeams(TfsProject project) { var teams = new TFSTeamsResponse(); var tokenString = Convert.ToBase64String( System.Text.Encoding.ASCII.GetBytes( string.Format("{0}:{1}", "", PersonalAccessToken))); using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", tokenString); using (HttpResponseMessage response = client.GetAsync( $"https://bofaz.visualstudio.com/_apis/projects/{project.Id}/teams?%24top=500&%24skip=0").Result) { response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); teams = JsonConvert.DeserializeObject <TFSTeamsResponse>(responseBody); } } return(teams); }
public async Task <TfsIterationsResponse> GetITerations(TFSTeam team, TfsProject project) { Uri uri = new Uri("https://bofaz.visualstudio.com/"); var iterations = new TfsIterationsResponse(); var tokenString = Convert.ToBase64String( System.Text.Encoding.ASCII.GetBytes( string.Format("{0}:{1}", "", PersonalAccessToken))); using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", tokenString); using (HttpResponseMessage response = client.GetAsync( $"{uri.ToString()}{project.Id}/{team.Id}/_apis/work/teamsettings/iterations").Result) { response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); iterations = JsonConvert.DeserializeObject <TfsIterationsResponse>(responseBody); } return(iterations); } }
public List <Models.WorkItem> GetTFSItems(TfsProject project, string iteration) { VssBasicCredential credentials = new VssBasicCredential("", PersonalAccessToken); Uri uri = new Uri("https://bofaz.visualstudio.com/"); var items = new List <Models.WorkItem>(); Wiql wiql = new Wiql() { Query = "Select [System.State], [System.Title], [System.Id]" + "From WorkItems " + "WHERE [System.TeamProject] = '" + project.Name + "' " + "AND [System.IterationPath] = '" + iteration + "' " + "AND [System.AssignedTo] = @Me " }; using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(uri, credentials)) { //execute the query to get the list of work items in the results WorkItemQueryResult workItemQueryResult = workItemTrackingHttpClient.QueryByWiqlAsync(wiql).Result; //some error handling if (workItemQueryResult.WorkItems.ToList().Count != 0) { //need to get the list of our work item ids and put them into an array List <int> list = new List <int>(); foreach (var item in workItemQueryResult.WorkItems) { list.Add(item.Id); } int[] arr = list.ToArray(); //build a list of the fields we want to see string[] fields = new string[3]; fields[0] = "System.Id"; fields[1] = "System.Title"; fields[2] = "System.State"; //get work items for the ids found in query var workItems = workItemTrackingHttpClient.GetWorkItemsAsync(arr, fields, workItemQueryResult.AsOf).Result; //loop though work items and write to console foreach (var workItem in workItems) { var it = new Models.WorkItem() { Description = workItem.Fields["System.Title"].ToString(), State = workItem.Fields["System.State"].ToString(), Iteration = iteration, }; items.Add(it); } } } return(items); }
public AdvancedSettings(JiraProject jiraProject, TfsProject tfsProject, ShowFirst showFirst) { var jira = jiraProject; this.tfsProject = tfsProject; jiraTypeMap = new JiraTypeMap(jira, this.tfsProject); tfsFieldMap = new TfsFieldMap(this.tfsProject.Fields); tfsStateMap = new TfsStateMap(this.tfsProject); tfsPriorityMap = new TfsPriorityMap(); this.showFirst = showFirst; }
private static IEnumerable <Identity> GetUsers(TfsProject SourceProject) { HashSet <Identity> users = new HashSet <Identity>(); Queue <Identity> queuedItems = new Queue <Identity>(); IGroupSecurityService gss = SourceProject.collection.GetService <IGroupSecurityService>(); Identity SIDS = gss.ReadIdentity(SearchFactor.AccountName, "Project Collection Valid Users", QueryMembership.Expanded); Identity[] sourceUserIds = gss.ReadIdentities(SearchFactor.Sid, SIDS.Members, QueryMembership.Direct); foreach (var item in sourceUserIds) { if (item != null) { queuedItems.Enqueue(item); } } while (queuedItems.Any()) { var firstSid = queuedItems.Dequeue(); if (firstSid == null) { continue; } try { users.Add(firstSid); if (firstSid.Members.Length == 0) { continue; } Identity[] members = gss.ReadIdentities(SearchFactor.Sid, firstSid.Members, QueryMembership.Direct); foreach (var item in members) { if (item == null) { continue; } if (users.Add(item)) { if (item.Type == IdentityType.WindowsUser) { continue; } queuedItems.Enqueue(item); } } } catch (Exception ex) { Debug.WriteLine(ex); } } return(users); }
public AdvancedSettings(JiraProject jiraProject, TfsProject tfsProject, ShowFirst showFirst) { var jira = jiraProject; this.tfsProject = tfsProject; jiraTypeMap = new JiraTypeMap(jira, this.tfsProject); tfsFieldMap = new TfsFieldMap(this.tfsProject.Fields); tfsStateMap = new TfsStateMap(this.tfsProject); tfsPriorityMap = new TfsPriorityMap(); this.showFirst = showFirst; }
public void QueueBuild(TfsBuildDefinition tfsBuildDefinition) { TfsProject project = tfsBuildDefinition.BuildDefinitionsContainer.Project; string url = $"{GetProjectUrl(project)}/_apis/build/builds?api-version=2.0"; //REMARK: invalidate cache, show result? HttpResponseMessage response = HttpClient.PostAsync(url, new StringContent($"{{\"definition\":{{\"id\": {tfsBuildDefinition.Id}}}}}", Encoding.UTF8, "application/json")).Result; QueueBuildResponse queueBuildResponse = new QueueBuildResponse(tfsBuildDefinition.Queue.Name, response); queueBuildResponse.Validate(); }
private void tfsConnect_DoWork(object sender, DoWorkEventArgs arguments) { try { var serverDetails = (arguments.Argument as Tuple <string, string>); selectedProject = new TfsProject(serverDetails.Item1, serverDetails.Item2); arguments.Result = null; } catch (Exception e) { arguments.Result = e; } }
public static WorkItemTypeMap MapTypes(TfsProject source, TfsProject target) { WorkItemTypeCollection workItemTypes = target.project.WorkItemTypes; WorkItemTypeMap fieldMap = new WorkItemTypeMap(); foreach (WorkItemType workItemTypeSource in source.project.WorkItemTypes) { List <List <string> > fieldList = new List <List <string> >(); List <string> sourceList = new List <string>(); List <string> targetList = new List <string>(); WorkItemType workItemTypeTarget = null; if (workItemTypes.Contains(workItemTypeSource.Name)) { workItemTypeTarget = workItemTypes[workItemTypeSource.Name]; } else if (workItemTypeSource.Name == "User Story") { workItemTypeTarget = workItemTypes["Product Backlog Item"]; } else if (workItemTypeSource.Name == "Issue") { workItemTypeTarget = workItemTypes["Impediment"]; } else { // not automatically mapped continue; } WorkItemFieldMap m = new WorkItemFieldMap(workItemTypeSource, workItemTypeTarget); m.GenerateDefaultMap(); fieldMap.fieldMapping.Add(m); fieldMap.mapping[workItemTypeSource] = workItemTypeTarget; } return(fieldMap); }
public WorkItemTypeCollection GetCollection(TfsProject source) { return(source.project.WorkItemTypes); }
public TfsProjectNode(TfsProjectCollectionNode parent, TfsProject tfsProject) : base(parent.NodeContext, tfsProject, GetPathName(tfsProject)) { Parent = parent; TfsProject = tfsProject; PathSegment = parent.PathSegment + new PathSegment(GetPathName(tfsProject)); }
public virtual JArray RetrieveBuildDefinitions(TfsProject tfsProject) { string url = $"{GetProjectUrl(tfsProject)}/_apis/build/definitions"; return(ParseCollectionResponse(url)); }
public string GetProjectUrl(TfsProject tfsProject) { return(IsOnline ? $"{Url}/{tfsProject.Name}" : $"{Url}/{tfsProject.ProjectCollection.Name}/{tfsProject.Name}"); }
public MigrateProject(TfsProject sourceTFS, TfsProject targetTFS) { this.sourceTFS = sourceTFS; this.targetTFS = targetTFS; }
public static string GetPathName(TfsProject tfsProject) { return(tfsProject.Name); }
public UserMapper(TfsProject SourceProject, TfsProject TargetProject) { this.SourceProject = SourceProject; this.TargetProject = TargetProject; }