public void CreateStealing(string projectName, string username, string title, float time, string activity, bool leaveActive) { var stealingsUS = TFS.GetWorkItemWithRelations(StealingId); Dictionary <string, object> fields = new Dictionary <string, object>(); fields.Add("Title", title); fields.Add("Activity", activity); fields.Add("Priority", 1); fields.Add("System.AssignedTo", username); fields.Add("System.AreaPath", stealingsUS.Fields["System.AreaPath"]); fields.Add("System.IterationPath", stealingsUS.Fields["System.IterationPath"]); fields.Add("Microsoft.VSTS.Scheduling.CompletedWork", time); var item = TFS.CreateWorkItem(projectName, "Eco Task", fields); TFS.AddParentLink(item.Id.Value, StealingId); fields.Clear(); fields.Add("State", "Active"); var r = TFS.UpdateWorkItem(item.Id.Value, fields); Console.WriteLine(r.Url); if (leaveActive == false) { fields.Clear(); fields.Add("State", "Closed"); var r2 = TFS.UpdateWorkItem(item.Id.Value, fields); Console.WriteLine(r2.Url); } }
public void CloneElement(WorkItemElement element) { Dictionary <string, object> fields = new Dictionary <string, object>(); Action <string, object> addIfNotNull = (name, o) => { if (o != null) { fields.Add(name, o); } }; fields.Add("Title", element.Title); fields.Add("Activity", element.Activity); fields.Add("Priority", 1); fields.Add("System.AssignedTo", element.AssignedTo); fields.Add("System.AreaPath", element.AreaPath); fields.Add("System.IterationPath", element.Iteration); addIfNotNull("Microsoft.VSTS.Scheduling.CompletedWork", element.CompletedWork); addIfNotNull("Microsoft.VSTS.common.BugFoundOn", "Test"); var item = TFS2.CreateWorkItem(element.Project, element.Type, fields); TFS2.AddParentLink(item.Id.Value, element.ParentElementId); fields.Clear(); if (element.Type == "eco Bug") { fields.Add("State", "Resolved"); fields.Add("Ecovadis.TargetRelease", "10.66"); TFS2.UpdateWorkItem(item.Id.Value, fields); fields.Clear(); } if (element.Type == "Eco Task") { fields.Add("State", "Active"); TFS2.UpdateWorkItem(item.Id.Value, fields); fields.Clear(); } fields.Add("State", "Closed"); var r = TFS2.UpdateWorkItem(item.Id.Value, fields); Console.WriteLine(item.Url); }