Skip to content

Commit e15b8b0

Browse files
committed
PR 27: Added ability for quer to be passed into Migration context
- Added ability for quer to be passed into Migration context
1 parent ef8b275 commit e15b8b0

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

GitVersion.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
assembly-versioning-scheme: None
22
mode: ContinuousDeployment
3-
next-version: 0.4.8
3+
continuous-delivery-fallback-tag: ''
4+
next-version: 0.5.1
45
branches:
56
master:
67
mode: ContinuousDeployment

TfsWitMigrator.Core/MigrationContext/WorkItemMigrationContext.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ namespace VSTS.DataBulkEditor.Engine
1212
{
1313
public class WorkItemMigrationContext : MigrationContextBase
1414
{
15+
16+
string _queryBit;
17+
MigrationEngine _me;
18+
bool _whatIf;
19+
1520
public override string Name
1621
{
1722
get
@@ -20,9 +25,11 @@ public override string Name
2025
}
2126
}
2227

23-
public WorkItemMigrationContext(MigrationEngine me) : base(me)
28+
public WorkItemMigrationContext(MigrationEngine me, string queryBit, bool whatIf = false) : base(me)
2429
{
25-
30+
_me = me;
31+
_queryBit = queryBit;
32+
_whatIf = whatIf;
2633
}
2734

2835
internal override void InternalExecute()
@@ -33,14 +40,14 @@ internal override void InternalExecute()
3340
WorkItemStoreContext sourceStore = new WorkItemStoreContext(me.Source, WorkItemStoreFlags.BypassRules);
3441
TfsQueryContext tfsqc = new TfsQueryContext(sourceStore);
3542
tfsqc.AddParameter("TeamProject", me.Source.Name);
36-
tfsqc.Query = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [TfsMigrationTool.ReflectedWorkItemId] = '' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] IN ('Shared Steps', 'Shared Parameter', 'Test Case', 'Requirement', 'Task', 'User Story', 'Bug') ORDER BY [System.ChangedDate] ass "; // AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] = 'Test Case' AND [System.AreaPath] = 'Platform' ";// AND [System.Id] = 452603 ";
43+
tfsqc.Query = string.Format(@"SELECT [System.Id], [System.Tags] FROM WorkItems WHERE [System.TeamProject] = @TeamProject {0} ORDER BY [System.ChangedDate] desc", _queryBit);
3744
WorkItemCollection sourceWIS = tfsqc.Execute();
3845
Trace.WriteLine(string.Format("Migrate {0} work items?", sourceWIS.Count));
3946
//////////////////////////////////////////////////
4047
WorkItemStoreContext targetStore = new WorkItemStoreContext(me.Target, WorkItemStoreFlags.BypassRules);
4148
Project destProject = targetStore.GetProject();
4249
Trace.WriteLine(string.Format("Found target project as {0}", destProject.Name));
43-
50+
4451
int current = sourceWIS.Count;
4552
int count = 0;
4653
long elapsedms = 0;
@@ -185,7 +192,7 @@ private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destPr
185192
newwit.Fields[f.ReferenceName].Value = oldWi.Fields[f.ReferenceName].Value;
186193
}
187194
}
188-
newwit.AreaPath = string.Format(@"{0}\{1}", newwit.Project.Name,oldWi.AreaPath);
195+
newwit.AreaPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.AreaPath);
189196
newwit.IterationPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.IterationPath);
190197
newwit.Fields["System.ChangedDate"].Value = oldWi.Fields["System.ChangedDate"].Value;
191198

@@ -196,8 +203,8 @@ private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destPr
196203
newwit.Fields["Microsoft.VSTS.Common.Priority"].Value = oldWi.Fields["Microsoft.VSTS.Common.Priority"].Value;
197204
break;
198205
//case "User Story":
199-
//newwit.Fields["COMPANY.DEVISION.Analysis"].Value = oldWi.Fields["COMPANY.PRODUCT.AcceptanceCriteria"].Value;
200-
//break;
206+
//newwit.Fields["COMPANY.DEVISION.Analysis"].Value = oldWi.Fields["COMPANY.PRODUCT.AcceptanceCriteria"].Value;
207+
//break;
201208
default:
202209
break;
203210
}

0 commit comments

Comments
 (0)