-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added migrator for teams - Added Documentation with mkdocs
- Loading branch information
Showing
5 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
TfsWitMigrator.Core/Configuration/Processing/TeamMigrationConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace VSTS.DataBulkEditor.Engine.Configuration.Processing | ||
{ | ||
public class TeamMigrationConfig : ITfsProcessingConfig | ||
{ | ||
public bool Enabled { get; set; } | ||
public Type Processor | ||
{ | ||
get | ||
{ | ||
return typeof(TeamMigrationContext); | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
136 changes: 136 additions & 0 deletions
136
TfsWitMigrator.Core/Execution/MigrationContext/TeamMigrationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
using Microsoft.TeamFoundation.Client; | ||
using Microsoft.TeamFoundation.ProcessConfiguration.Client; | ||
using Microsoft.TeamFoundation.WorkItemTracking.Client; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using VSTS.DataBulkEditor.Engine.Configuration.Processing; | ||
|
||
namespace VSTS.DataBulkEditor.Engine | ||
{ | ||
public class TeamMigrationContext : MigrationContextBase | ||
{ | ||
|
||
TeamMigrationConfig _config; | ||
MigrationEngine _me; | ||
|
||
public override string Name | ||
{ | ||
get | ||
{ | ||
return "TeamMigrationContext"; | ||
} | ||
} | ||
|
||
public TeamMigrationContext(MigrationEngine me, TeamMigrationConfig config) : base(me, config) | ||
{ | ||
_me = me; | ||
_config = config; | ||
} | ||
|
||
internal override void InternalExecute() | ||
{ | ||
Stopwatch stopwatch = new Stopwatch(); | ||
stopwatch.Start(); | ||
////////////////////////////////////////////////// | ||
WorkItemStoreContext sourceStore = new WorkItemStoreContext(me.Source, WorkItemStoreFlags.BypassRules); | ||
TfsTeamService sourceTS = me.Source.Collection.GetService<TfsTeamService>(); | ||
List<TeamFoundationTeam> sourceTL = sourceTS.QueryTeams(me.Source.Name).ToList(); | ||
Trace.WriteLine(string.Format("Found {0} teams in Source?", sourceTL.Count)); | ||
var sourceTSCS = me.Source.Collection.GetService<TeamSettingsConfigurationService>(); | ||
////////////////////////////////////////////////// | ||
WorkItemStoreContext targetStore = new WorkItemStoreContext(me.Target, WorkItemStoreFlags.BypassRules); | ||
Project targetProject = targetStore.GetProject(); | ||
Trace.WriteLine(string.Format("Found target project as {0}", targetProject.Name)); | ||
TfsTeamService targetTS = me.Target.Collection.GetService<TfsTeamService>(); | ||
List<TeamFoundationTeam> targetTL = targetTS.QueryTeams(me.Target.Name).ToList(); | ||
Trace.WriteLine(string.Format("Found {0} teams in Target?", targetTL.Count)); | ||
var targetTSCS = me.Target.Collection.GetService<TeamSettingsConfigurationService>(); | ||
////////////////////////////////////////////////// | ||
int current = sourceTL.Count; | ||
int count = 0; | ||
long elapsedms = 0; | ||
|
||
/// Create teams | ||
/// | ||
foreach (TeamFoundationTeam sourceTeam in sourceTL) | ||
{ | ||
Stopwatch witstopwatch = new Stopwatch(); | ||
witstopwatch.Start(); | ||
var foundTargetTeam = (from x in targetTL where x.Name == sourceTeam.Name select x).SingleOrDefault(); | ||
if (foundTargetTeam == null) | ||
{ | ||
Trace.WriteLine(string.Format("Processing team {0}", sourceTeam.Name)); | ||
TeamFoundationTeam newTeam = targetTS.CreateTeam(targetProject.Uri.ToString(), sourceTeam.Name, sourceTeam.Description, null); | ||
} | ||
else | ||
{ | ||
Trace.WriteLine(string.Format("Team found.. skipping")); | ||
} | ||
|
||
witstopwatch.Stop(); | ||
elapsedms = elapsedms + witstopwatch.ElapsedMilliseconds; | ||
current--; | ||
count++; | ||
TimeSpan average = new TimeSpan(0, 0, 0, 0, (int)(elapsedms / count)); | ||
TimeSpan remaining = new TimeSpan(0, 0, 0, 0, (int)(average.TotalMilliseconds * current)); | ||
Trace.WriteLine(""); | ||
//Trace.WriteLine(string.Format("Average time of {0} per work item and {1} estimated to completion", string.Format(@"{0:s\:fff} seconds", average), string.Format(@"{0:%h} hours {0:%m} minutes {0:s\:fff} seconds", remaining))); | ||
} | ||
// Set Team Settings | ||
//foreach (TeamFoundationTeam sourceTeam in sourceTL) | ||
//{ | ||
// Stopwatch witstopwatch = new Stopwatch(); | ||
// witstopwatch.Start(); | ||
// var foundTargetTeam = (from x in targetTL where x.Name == sourceTeam.Name select x).SingleOrDefault(); | ||
// if (foundTargetTeam == null) | ||
// { | ||
// Trace.WriteLine(string.Format("Processing team {0}", sourceTeam.Name)); | ||
// var sourceTCfU = sourceTSCS.GetTeamConfigurations((new[] { sourceTeam.Identity.TeamFoundationId })).SingleOrDefault(); | ||
// TeamSettings newTeamSettings = CreateTargetTeamSettings(sourceTCfU); | ||
// TeamFoundationTeam newTeam = targetTS.CreateTeam(targetProject.Uri.ToString(), sourceTeam.Name, sourceTeam.Description, null); | ||
// targetTSCS.SetTeamSettings(newTeam.Identity.TeamFoundationId, newTeamSettings); | ||
// } | ||
// else | ||
// { | ||
// Trace.WriteLine(string.Format("Team found.. skipping")); | ||
// } | ||
|
||
// witstopwatch.Stop(); | ||
// elapsedms = elapsedms + witstopwatch.ElapsedMilliseconds; | ||
// current--; | ||
// count++; | ||
// TimeSpan average = new TimeSpan(0, 0, 0, 0, (int)(elapsedms / count)); | ||
// TimeSpan remaining = new TimeSpan(0, 0, 0, 0, (int)(average.TotalMilliseconds * current)); | ||
// Trace.WriteLine(""); | ||
// //Trace.WriteLine(string.Format("Average time of {0} per work item and {1} estimated to completion", string.Format(@"{0:s\:fff} seconds", average), string.Format(@"{0:%h} hours {0:%m} minutes {0:s\:fff} seconds", remaining))); | ||
|
||
//} | ||
////////////////////////////////////////////////// | ||
stopwatch.Stop(); | ||
Console.WriteLine(@"DONE in {0:%h} hours {0:%m} minutes {0:s\:fff} seconds", stopwatch.Elapsed); | ||
} | ||
|
||
|
||
private TeamSettings CreateTargetTeamSettings(TeamConfiguration sourceTCfU) | ||
{ | ||
/////////////////////////////////////////////////// | ||
TeamSettings newTeamSettings = sourceTCfU.TeamSettings; | ||
newTeamSettings.BacklogIterationPath = newTeamSettings.BacklogIterationPath.Replace(me.Source.Name, me.Target.Name); | ||
List<string> newIterationPaths = new List<string>(); | ||
foreach (var ip in newTeamSettings.IterationPaths) | ||
{ | ||
newIterationPaths.Add(ip.Replace(me.Source.Name, me.Target.Name)); | ||
} | ||
newTeamSettings.IterationPaths = newIterationPaths.ToArray(); | ||
|
||
/////////////////////////////////////////////////// | ||
return newTeamSettings; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Welcome to MkDocs | ||
|
||
For full documentation visit [mkdocs.org](http://mkdocs.org). | ||
|
||
## Commands | ||
|
||
* `mkdocs new [dir-name]` - Create a new project. | ||
* `mkdocs serve` - Start the live-reloading docs server. | ||
* `mkdocs build` - Build the documentation site. | ||
* `mkdocs help` - Print this help message. | ||
|
||
## Project layout | ||
|
||
mkdocs.yml # The configuration file. | ||
docs/ | ||
index.md # The documentation homepage. | ||
... # Other markdown pages, images and other files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
site_name: VSTS Data Bulk Editor | ||
pages: | ||
- Home: index.md | ||
theme: readthedocs |