private async Task Import(ProjectCollectionInfo projectCollection, TeamProjectInfo teamProject, string fileName) { string projectCollectionName = projectCollection.Name; string teamProjectName = teamProject.Name; await Tools.WitAdminService.ImportProcessConfig(TFManager, projectCollectionName, teamProjectName, fileName); }
private async Task GetWITypes(TeamProjectInfo teamProject) { string projectCollectionName = CurrentProjectCollection.Name; string teamProjectName = teamProject.Name; WorkItemTypeInfo[] workItemTypeInfos = null; Progress.BeginWorking(); try { try { workItemTypeInfos = (await WitAdminService.ExportWorkItemTypes(TFManager, projectCollectionName, teamProjectName)) .Select(workItemTypeString => new WorkItemTypeInfo() { Name = workItemTypeString, Defenition = null }) .ToArray(); Progress.NextStep(); } catch (WitAdminException) { Progress.FailStep(); } teamProject.WorkItemTypeInfos = workItemTypeInfos; } finally { Progress.EndWorking(); } }
private async Task Export(ProjectCollectionInfo projectCollection, TeamProjectInfo teamProject, string path) { string projectCollectionName = projectCollection.Name; string teamProjectName = teamProject.Name; string fileName = string.Format("{0}.xml", teamProjectName); string fullPath = System.IO.Path.Combine(path, fileName); await Tools.WitAdminService.ExportProcessConfig(TFManager, projectCollectionName, teamProjectName, fullPath); }
public SecurityGroupInfo(TeamProjectInfo teamProject, string sid, string fullName, string description, ICollection <string> members) { this.TeamProject = teamProject; this.Sid = sid; this.FullName = fullName; this.Name = this.FullName.IndexOf('\\') < 0 ? this.FullName : this.FullName.Split('\\')[1]; this.Description = description; this.Members = members ?? new string[0]; this.MembersList = string.Join("; ", this.Members); }
public WorkItemTypeInfo(TeamProjectInfo teamProject, string name, string description, int?workItemCount, ICollection <string> workItemCategories, WorkItemTypeDefinition workItemTypeDefinition) { this.TeamProject = teamProject; this.Name = name; this.Description = description; this.WorkItemCount = workItemCount; this.WorkItemCategories = workItemCategories; this.WorkItemCategoriesList = this.WorkItemCategories == null ? null : string.Join(", ", this.WorkItemCategories); this.WorkItemTypeDefinition = workItemTypeDefinition; }
private async Task Export(ProjectCollectionInfo projectCollection, TeamProjectInfo teamProject, WorkItemTypeInfo workItemType, string path) { string projectCollectionName = projectCollection.Name; string teamProjectName = teamProject.Name; string workItemTypeName = workItemType.Name; string fileName = string.Format("{0}.xml", workItemTypeName); string fullPath = System.IO.Path.Combine(path, fileName); await Tools.WitAdminService.ExportWorkItemDefenition(TFManager, projectCollectionName, teamProjectName, workItemTypeName, fullPath); }
public static IDictionary <string, string> GetTeamProjectMacros(TeamProjectInfo teamProject) { if (teamProject == null) { return(new Dictionary <string, string>()); } else { return(new Dictionary <string, string>() { { MacroNameProjectName, teamProject.Name }, { MacroNameProjectCollectionName, teamProject.TeamProjectCollection.Name }, { MacroNameProjectCollectionUrl, teamProject.TeamProjectCollection.Uri.ToString() }, { MacroNameServerName, teamProject.TeamProjectCollection.TeamFoundationServer.Name }, { MacroNameServerUrl, teamProject.TeamProjectCollection.TeamFoundationServer.Uri.ToString() } }); } }
private async Task Rename() { TeamProjectInfo[] teamProjects = null; if (IsAllTeamProjects) { teamProjects = Tools.CurrentProjectCollection.TeamProjectInfos; } else { teamProjects = new TeamProjectInfo[] { Tools.CurrentTeamProject } }; Tools.Progress.BeginWorking(teamProjects.Length); try { foreach (TeamProjectInfo teamProject in teamProjects) { string projectCollectionName = Tools.CurrentProjectCollection.Name; string teamProjectName = teamProject.Name; string workItemTypeName = Tools.CurrentWorkItemType.Name; try { await Tools.WitAdminService.RenameWorkItem(TFManager, projectCollectionName, teamProjectName, workItemTypeName, NewName); Tools.Progress.NextStep(); } catch (WitAdminException) { Tools.Progress.FailStep(); } } } finally { Tools.Progress.EndWorking(); } }
private async Task <IList <ComponentActivityInfo> > GetXamlBuildActivityAsync(ApplicationTask task, TfsTeamProjectCollection tfs, TeamProjectInfo teamProject, int numberOfActivities, IList <string> userExclusions) { var activities = new List <ComponentActivityInfo>(); var client = tfs.GetClient <XamlBuildHttpClient>(); // There is no paging API for build queries, so we page the results manually by // limiting on the max finish time as being the finish time of the last returned result. // This will yield an overlap of 1 build per page which we can filter out. // Retrieve at least 2 builds to get the "manual paging" system working. var pageSize = Math.Max(2, numberOfActivities); var lastRetrievedBuild = default(Build); while (activities.Count < numberOfActivities && !task.IsCanceled) { var maxFinishTime = lastRetrievedBuild == null ? null : lastRetrievedBuild.FinishTime; var builds = await client.GetBuildsAsync(teamProject.Name, top : pageSize, maxFinishTime : maxFinishTime, queryOrder : Microsoft.TeamFoundation.Build.WebApi.BuildQueryOrder.FinishTimeDescending); var unseenBuilds = builds.Where(b => lastRetrievedBuild == null || b.Uri != lastRetrievedBuild.Uri); foreach (var build in unseenBuilds) { lastRetrievedBuild = build; if (build.RequestedFor == null || !userExclusions.Any(x => build.RequestedFor.DisplayName.IndexOf(x, StringComparison.OrdinalIgnoreCase) >= 0)) { var time = build.FinishTime ?? build.StartTime ?? build.QueueTime ?? DateTime.MinValue; var user = build.RequestedFor.DisplayName; var description = string.Format(CultureInfo.CurrentCulture, "Build Number \"{0}\" from Build Definition \"{1}\"", build.BuildNumber, build.Definition.Name); activities.Add(new ComponentActivityInfo("XAML Build", time, user, description)); } } if (!unseenBuilds.Any()) { break; } } return(activities); }
private async Task Export() { ProjectCollectionInfo projectCollection = Tools.CurrentProjectCollection; TeamProjectInfo[] teamProjects; if (IsAllTeamProjects) { teamProjects = projectCollection.TeamProjectInfos; foreach (TeamProjectInfo teamProject in teamProjects) { if (teamProject.WorkItemTypeInfos == null) { await Tools.GetAllTeamProjectsWITypes(); break; } } } else { teamProjects = new TeamProjectInfo[] { Tools.CurrentTeamProject } }; foreach (TeamProjectInfo teamProject in teamProjects) { WorkItemTypeInfo[] workItemTypeInfos; string path = Path; if (IsAllTeamProjects) { path = System.IO.Path.Combine(path, teamProject.Name); System.IO.Directory.CreateDirectory(path); } workItemTypeInfos = (IsAllWorkItemTypes) ? teamProject.WorkItemTypeInfos : workItemTypeInfos = new WorkItemTypeInfo[] { Tools.CurrentWorkItemType }; Tools.Progress.BeginWorking(workItemTypeInfos.Length); try { foreach (WorkItemTypeInfo workItemTypeInfo in workItemTypeInfos) { try { await Export(projectCollection, teamProject, workItemTypeInfo, path); Tools.Progress.NextStep(); } catch (WitAdminException) { Tools.Progress.FailStep(); } } } finally { Tools.Progress.EndWorking(); } } }
private void Init(IWitAdminService wiAdminService) { WitAdminService = wiAdminService; TargetTemplateName = "Agile"; #region Commands SetAddressCommand = new DelegateCommand(() => { TFManager = DiManager.Current.Resolve <ITFManager>(new { serverAddress = Address }); InitChildViewModelsCommand.Execute(this); GetProjectCollectionInfosCommand.Execute(this); }, () => !string.IsNullOrEmpty(Address) ); ResetTFManagerCommand = new DelegateCommand(() => { TFManager = null; ProjectCollectionInfos = null; }); GetProjectCollectionInfosCommand = new DelegateCommand(async() => { ProjectCollectionInfos = await GetProjectCollectionInfos(TFManager); }, () => TFManager != null ); GetAllTeamProjectsWITypesCommand = new DelegateCommand(async() => { await GetAllTeamProjectsWITypes(); }, () => CurrentProjectCollection != null); GetWITypesCommand = new DelegateCommand(async() => { TeamProjectInfo currentTeamProject = CurrentTeamProject; await GetWITypes(currentTeamProject); }, () => (CurrentProjectCollection != null && CurrentTeamProject != null)); InitChildViewModelsCommand = new DelegateCommand(() => { Progress = DiManager.Current.Resolve <ProgressVM>(new { tools = this }); WIDViewer = DiManager.Current.Resolve <WIDViewerVM>(new { tools = this }); WIDExport = DiManager.Current.Resolve <WIDExportVM>(new { tools = this }); WIDImport = DiManager.Current.Resolve <WIDImportVM>(new { tools = this }); WIDRename = DiManager.Current.Resolve <WIDRenameVM>(new { tools = this }); WIDDestroy = DiManager.Current.Resolve <WIDDestroyVM>(new { tools = this }); CategoriesViewer = DiManager.Current.Resolve <CategoriesViewerVM>(new { tools = this }); CategoriesExport = DiManager.Current.Resolve <CategoriesExportVM>(new { tools = this }); CategoriesImport = DiManager.Current.Resolve <CategoriesImportVM>(new { tools = this }); ProcessConfigViewer = DiManager.Current.Resolve <ProcessConfigViewerVM>(new { tools = this }); ProcessConfigExport = DiManager.Current.Resolve <ProcessConfigExportVM>(new { tools = this }); ProcessConfigImport = DiManager.Current.Resolve <ProcessConfigImportVM>(new { tools = this }); }, () => TFManager != null); ClearOutputCommand = new DelegateCommand(() => { Output = string.Empty; }, () => !string.IsNullOrEmpty(Output)); #endregion #region Events wiAdminService.CommandInvoked += wiAdminService_CommandInvoked; #endregion }
public WorkItemConfigurationItemExport(TeamProjectInfo teamProject, WorkItemConfigurationItem item, string saveAsFileName) { this.TeamProject = teamProject; this.Item = item; this.SaveAsFileName = saveAsFileName; }
public ServiceEndpointInfo(TeamProjectInfo teamProject, ServiceEndpoint serviceEndpoint) { this.TeamProject = teamProject; this.ServiceEndpoint = serviceEndpoint; }
public TaskGroupInfo(TeamProjectInfo teamProject, TaskGroup taskGroup) { this.TeamProject = teamProject; this.TaskGroup = taskGroup; }
public WorkItemConfigurationItemExport(TeamProjectInfo teamProject, WorkItemConfigurationItem item) : this(teamProject, item, null) { }
public static void ReplaceTeamProjectMacros(XmlDocument xml, TeamProjectInfo teamProject) { ReplaceTeamProjectMacros(xml, GetTeamProjectMacros(teamProject)); }
public static string ReplaceTeamProjectMacros(string value, TeamProjectInfo teamProject) { return(ReplaceTeamProjectMacros(value, GetTeamProjectMacros(teamProject))); }
private async Task <IList <ComponentActivityInfo> > GetTfvcActivityAsync(ApplicationTask task, TfsTeamProjectCollection tfs, TeamProjectInfo teamProject, int numberOfActivities, IList <string> userExclusions, IList <string> commentExclusions) { var activities = new List <ComponentActivityInfo>(); try { var client = tfs.GetClient <TfvcHttpClient>(); var skip = 0; var top = numberOfActivities; while (activities.Count < numberOfActivities && !task.IsCanceled) { var changesets = await client.GetChangesetsAsync(project : teamProject.Name, skip : skip, top : top); foreach (var changeset in changesets) { if ((string.IsNullOrEmpty(changeset.Comment) || !commentExclusions.Any(x => changeset.Comment.IndexOf(x, StringComparison.OrdinalIgnoreCase) >= 0)) && !userExclusions.Any(x => changeset.Author.DisplayName.IndexOf(x, StringComparison.OrdinalIgnoreCase) >= 0 || changeset.CheckedInBy.DisplayName.IndexOf(x, StringComparison.OrdinalIgnoreCase) >= 0)) { var commentSuffix = string.IsNullOrEmpty(changeset.Comment) ? null : ": " + changeset.Comment.Trim(); var time = changeset.CreatedDate; var user = changeset.Author.DisplayName; var description = string.Format(CultureInfo.CurrentCulture, "Changeset {0}{1}", changeset.ChangesetId, commentSuffix); activities.Add(new ComponentActivityInfo("TFVC", time, user, description)); } } if (changesets.Count < top) { // There are no more pages. break; } else { skip += top; } } } catch (VssServiceException exc) { // This is thrown when the Team Project doesn't contain a TFVC repository, ignore it. Logger.Log("Error retrieving TFVC activity from Team Project " + teamProject.Name, exc, TraceEventType.Verbose); } return(activities); }
private async Task <IList <ComponentActivityInfo> > GetWorkItemTrackingActivityAsync(ApplicationTask task, TfsTeamProjectCollection tfs, TeamProjectInfo teamProject, int numberOfActivities, IList <string> userExclusions) { var activities = new List <ComponentActivityInfo>(); var client = tfs.GetClient <WorkItemTrackingHttpClient>(); // First execute the query to get the work item id's. var queryBuilder = new StringBuilder(); queryBuilder.Append("SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @project"); foreach (var userExclusion in userExclusions) { queryBuilder.AppendFormat(" AND [System.ChangedBy] NOT CONTAINS '{0}'", userExclusion.Replace("'", "''")); } queryBuilder.Append(" ORDER BY [System.ChangedDate] DESC"); var queryResult = await client.QueryByWiqlAsync(new Wiql { Query = queryBuilder.ToString() }, teamProject.Name, top : numberOfActivities); var ids = queryResult.WorkItems.Select(w => w.Id).ToArray(); // Then get the details for the returned work item id's. if (ids.Any() && !task.IsCanceled) { var workItems = await client.GetWorkItemsAsync(ids, new[] { "System.Id", "System.Title", "System.ChangedDate", "System.ChangedBy", "System.WorkItemType" }, queryResult.AsOf); foreach (var workItem in ids.Select(id => workItems.Single(w => w.Id == id))) { var time = (DateTime)workItem.Fields["System.ChangedDate"]; var user = (string)workItem.Fields["System.ChangedBy"]; var description = string.Format(CultureInfo.CurrentCulture, "{0} {1}: {2}", workItem.Fields["System.WorkItemType"], workItem.Id, workItem.Fields["System.Title"]); activities.Add(new ComponentActivityInfo("Work Item Tracking", time, user, description)); } } return(activities); }
private async Task <IList <ComponentActivityInfo> > GetGitActivityAsync(ApplicationTask task, TfsTeamProjectCollection tfs, TeamProjectInfo teamProject, int numberOfActivities, IList <string> userExclusions, IList <string> commentExclusions) { var activities = new List <ComponentActivityInfo>(); var client = tfs.GetClient <GitHttpClient>(); var top = numberOfActivities; // Find all repos. var repos = await client.GetRepositoriesAsync(project : teamProject.Name); var criteria = new GitQueryCommitsCriteria { Top = top, IncludeLinks = false }; foreach (var repo in repos) { var skip = 0; while (activities.Count < numberOfActivities && !task.IsCanceled) { var commits = await client.GetCommitsAsync(repo.Id, criteria, skip : skip, top : top); foreach (var commit in commits) { if ((string.IsNullOrEmpty(commit.Comment) || !commentExclusions.Any(x => commit.Comment.IndexOf(x, StringComparison.OrdinalIgnoreCase) >= 0)) && !userExclusions.Any(x => commit.Author.Name.IndexOf(x, StringComparison.OrdinalIgnoreCase) >= 0 || commit.Committer.Name.IndexOf(x, StringComparison.OrdinalIgnoreCase) >= 0)) { var commentSuffix = string.IsNullOrEmpty(commit.Comment) ? null : ": " + commit.Comment.Trim(); var time = commit.Author.Date; var user = commit.Author.Name; var description = string.Format(CultureInfo.CurrentCulture, "Commit {0}{1}", commit.CommitId.Substring(0, 7), commentSuffix); activities.Add(new ComponentActivityInfo("Git", time, user, description)); } } if (commits.Count < top) { // There are no more pages. break; } else { skip += top; } } } return(activities); }