Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
305 views
in Technique[技术] by (71.8m points)

c# - TFS 2012 API Set TeamSettings Programmatically

Is it possible to set the TeamSettings Programmatically?

var teamConfig = _tfs.GetService<TeamSettingsConfigurationService>();
                var css = _tfs.GetService<ICommonStructureService4>();

                var configs = teamConfig.GetTeamConfigurationsForUser(new[] { _selectedTeamProject.Uri });
                var team = configs.Where(c => c.TeamName == "Demo").FirstOrDefault() as TeamConfiguration;

The above code gives me the Team Configuration for the team Demo. Look at the TeamSettings, it contains the property BacklogIterationPath, CurrentIterationPath, IterationPaths. How can these be set programmatically?

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think I have solved it myself.

        // Set up default team sprint date and time
        var teamConfig = _tfs.GetService<TeamSettingsConfigurationService>();
        var css = _tfs.GetService<ICommonStructureService4>();

        string rootNodePath = string.Format("\{0}\Iteration\Release 1\Sprint 1", _selectedTeamProject.Name);
        var pathRoot = css.GetNodeFromPath(rootNodePath);

        css.SetIterationDates(pathRoot.Uri, DateTime.Now.AddDays(-5), DateTime.Now.AddDays(7));

        var configs = teamConfig.GetTeamConfigurationsForUser(new[] { _selectedTeamProject.Uri });
        var team = configs.Where(c => c.TeamName == "Demo").FirstOrDefault();

        var ts = team.TeamSettings;
        ts.BacklogIterationPath = string.Format(@"{0}Release 1", _selectedTeamProject.Name);
        ts.IterationPaths = new string[] { string.Format(@"{0}Release 1Sprint 1", _selectedTeamProject.Name), string.Format(@"{0}Release 1Sprint 2", _selectedTeamProject.Name) };

        var tfv = new TeamFieldValue();
        tfv.IncludeChildren = true;
        tfv.Value = _selectedTeamProject.Name;
        ts.TeamFieldValues = new []{tfv};

        teamConfig.SetTeamSettings(team.TeamId, ts);

This sets up,

1. Iteration Start and Finish Date for an Iteration
2. Backlog Iteration Path for the team Demo
3. Sets up Iteration Paths for the team Demo
4. Sets up the default Area Path for the team Demo

HTH Cheers, Tarun


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...