Skip to content

Commit

Permalink
PR 27: Added ability for quer to be passed into Migration context
Browse files Browse the repository at this point in the history
 - Added ability for quer to be passed into Migration context
  • Loading branch information
MrHinsh committed Aug 11, 2016
1 parent ef8b275 commit e15b8b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
assembly-versioning-scheme: None
mode: ContinuousDeployment
next-version: 0.4.8
continuous-delivery-fallback-tag: ''
next-version: 0.5.1
branches:
master:
mode: ContinuousDeployment
Expand Down
21 changes: 14 additions & 7 deletions TfsWitMigrator.Core/MigrationContext/WorkItemMigrationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace VSTS.DataBulkEditor.Engine
{
public class WorkItemMigrationContext : MigrationContextBase
{

string _queryBit;
MigrationEngine _me;
bool _whatIf;

public override string Name
{
get
Expand All @@ -20,9 +25,11 @@ public override string Name
}
}

public WorkItemMigrationContext(MigrationEngine me) : base(me)
public WorkItemMigrationContext(MigrationEngine me, string queryBit, bool whatIf = false) : base(me)
{

_me = me;
_queryBit = queryBit;
_whatIf = whatIf;
}

internal override void InternalExecute()
Expand All @@ -33,14 +40,14 @@ internal override void InternalExecute()
WorkItemStoreContext sourceStore = new WorkItemStoreContext(me.Source, WorkItemStoreFlags.BypassRules);
TfsQueryContext tfsqc = new TfsQueryContext(sourceStore);
tfsqc.AddParameter("TeamProject", me.Source.Name);
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 ";
tfsqc.Query = string.Format(@"SELECT [System.Id], [System.Tags] FROM WorkItems WHERE [System.TeamProject] = @TeamProject {0} ORDER BY [System.ChangedDate] desc", _queryBit);
WorkItemCollection sourceWIS = tfsqc.Execute();
Trace.WriteLine(string.Format("Migrate {0} work items?", sourceWIS.Count));
//////////////////////////////////////////////////
WorkItemStoreContext targetStore = new WorkItemStoreContext(me.Target, WorkItemStoreFlags.BypassRules);
Project destProject = targetStore.GetProject();
Trace.WriteLine(string.Format("Found target project as {0}", destProject.Name));

int current = sourceWIS.Count;
int count = 0;
long elapsedms = 0;
Expand Down Expand Up @@ -185,7 +192,7 @@ private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destPr
newwit.Fields[f.ReferenceName].Value = oldWi.Fields[f.ReferenceName].Value;
}
}
newwit.AreaPath = string.Format(@"{0}\{1}", newwit.Project.Name,oldWi.AreaPath);
newwit.AreaPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.AreaPath);
newwit.IterationPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.IterationPath);
newwit.Fields["System.ChangedDate"].Value = oldWi.Fields["System.ChangedDate"].Value;

Expand All @@ -196,8 +203,8 @@ private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destPr
newwit.Fields["Microsoft.VSTS.Common.Priority"].Value = oldWi.Fields["Microsoft.VSTS.Common.Priority"].Value;
break;
//case "User Story":
//newwit.Fields["COMPANY.DEVISION.Analysis"].Value = oldWi.Fields["COMPANY.PRODUCT.AcceptanceCriteria"].Value;
//break;
//newwit.Fields["COMPANY.DEVISION.Analysis"].Value = oldWi.Fields["COMPANY.PRODUCT.AcceptanceCriteria"].Value;
//break;
default:
break;
}
Expand Down

0 comments on commit e15b8b0

Please sign in to comment.