Skip to content

Commit 1a82975

Browse files
committed
PR 33: Merge AddConfigurationJson to master +semver:patch
- Started adding configration to create fully configurable with no compile.. - Added all Field mapps to configuration +semver: major - Added all work item type mappings... only processors left! - And processors - i hate serilisation - Fixed json hadling of custom objects - Processor done too... now to add other processors... - Moved config bits into engine... - Refactor to bring Config and Execution to the same format - Added version to AI +semver:patch ...
1 parent 859989b commit 1a82975

File tree

6 files changed

+14
-142
lines changed

6 files changed

+14
-142
lines changed

TfsWitMigrator.Core/Configuration/EngineConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace VSTS.DataBulkEditor.Engine.Configuration
1212
public class EngineConfiguration
1313
{
1414
public bool TelemetryEnableTrace { get; set; }
15-
public TeamProjectConfig Target { get; set; }
1615
public TeamProjectConfig Source { get; set; }
16+
public TeamProjectConfig Target { get; set; }
1717
public string ReflectedWorkItemIDFieldName { get; set; }
1818
public List<IFieldMapConfig> FieldMaps { get; set; }
1919
public Dictionary<string, string> WorkItemTypeDefinition { get; set; }
@@ -23,8 +23,8 @@ public static EngineConfiguration GetDefault()
2323
{
2424
EngineConfiguration ec = new EngineConfiguration();
2525
ec.TelemetryEnableTrace = true;
26-
ec.Target = new TeamProjectConfig() { Name = "DemoProjt", Collection = new Uri("https://sdd2016.visualstudio.com/") };
2726
ec.Source = new TeamProjectConfig() { Name = "DemoProjs", Collection = new Uri("https://sdd2016.visualstudio.com/") };
27+
ec.Target = new TeamProjectConfig() { Name = "DemoProjt", Collection = new Uri("https://sdd2016.visualstudio.com/") };
2828
ec.ReflectedWorkItemIDFieldName = "TfsMigrationTool.ReflectedWorkItemId";
2929
ec.FieldMaps = new List<IFieldMapConfig>();
3030
ec.FieldMaps.Add(new FieldValueMapConfig()

TfsWitMigrator.Core/Execution/MigrationContext/WorkItemMigrationContext.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,12 @@ internal override void InternalExecute()
8888
newwit.Save();
8989
Trace.WriteLine(string.Format("...Saved as {0}", newwit.Id));
9090
newwit.Fields["System.CreatedDate"].Value = sourceWI.Fields["System.CreatedDate"].Value;
91-
newwit.Save();
9291
Trace.WriteLine(string.Format("...And Date Created Updated"));
9392
if (sourceWI.Fields.Contains(me.ReflectedWorkItemIdFieldName))
9493
{
9594
sourceWI.Fields[me.ReflectedWorkItemIdFieldName].Value = targetStore.CreateReflectedWorkItemId(newwit);
96-
sourceWI.Save();
9795
}
96+
newwit.Save();
9897

9998
}
10099
catch (Exception ex)
@@ -115,8 +114,7 @@ internal override void InternalExecute()
115114
// sourceWI.Open();
116115
// sourceWI.SyncToLatest();
117116
// sourceWI.Fields["TfsMigrationTool.ReflectedWorkItemId"].Value = destWIFound[0].Id;
118-
119-
sourceWI.Save();
117+
//sourceWI.Save();
120118
}
121119
witstopwatch.Stop();
122120
elapsedms = elapsedms + witstopwatch.ElapsedMilliseconds;
@@ -261,8 +259,8 @@ private static string ReplaceFirstOccurence(string wordToReplace, string replace
261259

262260
private static void BuildFieldTable(WorkItem oldWi, StringBuilder history, bool useHTML = false)
263261
{
262+
history.Append("<p>&nbsp;</p>");
264263
if (useHTML) {
265-
history.Append("<p>&nbsp;</p>");
266264
history.Append("<table border='1' cellpadding='2' style='width:100%;border-color:#C0C0C0;'><tr><td><b>Field</b></td><td><b>Value</b></td></tr>");
267265
}
268266
foreach (Field f in oldWi.Fields)
@@ -274,7 +272,7 @@ private static void BuildFieldTable(WorkItem oldWi, StringBuilder history, bool
274272
history.AppendFormat("<tr><td style='text-align:right;white-space:nowrap;'><b>{0}</b></td><td>n/a</td></tr>", f.Name);
275273
} else
276274
{
277-
history.AppendLine(string.Format("{0}: null", f.Name));
275+
history.AppendLine(string.Format("{0}: null<br />", f.Name));
278276
}
279277
}
280278
else
@@ -285,16 +283,16 @@ private static void BuildFieldTable(WorkItem oldWi, StringBuilder history, bool
285283

286284
}else
287285
{
288-
history.AppendLine(string.Format("{0}: {1}", f.Name, f.Value.ToString()));
286+
history.AppendLine(string.Format("{0}: {1}<br />", f.Name, f.Value.ToString()));
289287
}
290288
}
291289

292290
}
293291
if (useHTML)
294292
{
295293
history.Append("</table>");
296-
history.Append("<p>&nbsp;</p>");
297294
}
295+
history.Append("<p>&nbsp;</p>");
298296
}
299297

300298
private static void BuildCommentTable(WorkItem oldWi, StringBuilder history)

TfsWitMigrator.Core/MigrationEngine.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ private void ProcessConfiguration(EngineConfiguration config)
3838
this.SetSource(new TeamProjectContext(config.Source.Collection, config.Source.Name));
3939
this.SetTarget(new TeamProjectContext(config.Target.Collection, config.Target.Name));
4040
this.SetReflectedWorkItemIdFieldName(config.ReflectedWorkItemIDFieldName);
41-
foreach (IFieldMapConfig fieldmapConfig in config.FieldMaps)
41+
if (config.FieldMaps != null)
4242
{
43-
this.AddFieldMap(fieldmapConfig.WorkItemTypeName, (IFieldMap)Activator.CreateInstance(fieldmapConfig.FieldMap, fieldmapConfig));
44-
}
43+
foreach (IFieldMapConfig fieldmapConfig in config.FieldMaps)
44+
{
45+
this.AddFieldMap(fieldmapConfig.WorkItemTypeName, (IFieldMap)Activator.CreateInstance(fieldmapConfig.FieldMap, fieldmapConfig));
46+
}
47+
}
4548
foreach (string key in config.WorkItemTypeDefinition.Keys)
4649
{
4750
this.AddWorkItemTypeDefinition(key, new DescreteWitdMapper(config.WorkItemTypeDefinition[key]));

UnitTestProject1/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

UnitTestProject1/UnitTestProject1.csproj

Lines changed: 0 additions & 89 deletions
This file was deleted.

UnitTestProject1/packages.config

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)