private void button1_Click(object sender, EventArgs e) { fromlink = this.comboBox1.SelectedItem as WorkItemLinkType; tolink = this.comboBox2.SelectedItem as WorkItemLinkType; this.Close(); }
private static void CreateSimpleRelation(WorkItemStore store, WorkItem subItem, int relationId) { WorkItemLinkType hlt = store.WorkItemLinkTypes[CoreLinkTypeReferenceNames.Related]; subItem.Links.Add(new WorkItemLink(hlt.ReverseEnd, relationId)); //subItem.Save(); }
public WorkItem CreateNewTask(int storyId, string taskName) { var workItem = this.project.WorkItemTypes["TASK"].NewWorkItem(); var userStory = this.GetWorkItemById(storyId); var taskTitle = this.CreateValidTaskTitle(taskName); if (userStory != null) { workItem.Title = taskTitle; workItem.Description = ""; workItem.AreaPath = userStory.AreaPath; workItem.IterationPath = userStory.IterationPath; workItem.Fields["Activity"].Value = ""; workItem.Fields["Original Estimate"].Value = 0; workItem.Fields["Remaining Work"].Value = 0; workItem.Fields["Assigned To"].Value = ""; //Create a hierarchy type (Parent-Child) relationship WorkItemLinkType hierarchyLinkType = serverConnector.Store.WorkItemLinkTypes[CoreLinkTypeReferenceNames.Hierarchy]; //Set user story as parent of new task workItem.Links.Add(new WorkItemLink(hierarchyLinkType.ReverseEnd, userStory.Id)); //Save the task workItem.Save(); } return(workItem); }
public WorkItemController() { TFSServer = ConfigurationManager.AppSettings["TFSUrl"]; tpc = new TfsTeamProjectCollection( new Uri(TFSServer)); try { workItemStore = (WorkItemStore)tpc.GetService(typeof(WorkItemStore)); } catch (Exception ex) { MessageBox.Show("Unable to Connect to TFS. Check your VPN Connection. \nError " + ex.Message); Environment.Exit(-1); return; } parentLinkType = workItemStore.WorkItemLinkTypes.FirstOrDefault(l => l.ReverseEnd.Name == "Parent"); workItemProject = workItemStore.Projects[0]; GetAreas(workItemProject); GetIterations(workItemProject); GetUsers(tpc); GetStates(); UpdateQueue = new ObservableCollection <TaskUpdate>(); lastRefresh = DateTime.Now; mainWindow = UICommon.GetProperty("MainWindow") as MainWindow; }
static void Main(string[] args) { int UserStoryID = 53; int TestCaseID = 54; TfsTeamProjectCollection tfs; tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://ictfs2015:8080/tfs/DefaultCollection")); tfs.Authenticate(); var workItemStore = new WorkItemStore(tfs); WorkItem wit = workItemStore.GetWorkItem(UserStoryID); //Set "Tested By" as the link type var linkTypes = workItemStore.WorkItemLinkTypes; WorkItemLinkType testedBy = linkTypes.FirstOrDefault(lt => lt.ForwardEnd.Name == "Tested By"); WorkItemLinkTypeEnd linkTypeEnd = testedBy.ForwardEnd; //Add the link as related link. try { wit.Links.Add(new RelatedLink(linkTypeEnd, TestCaseID)); wit.Save(); Console.WriteLine(string.Format("Linked TestCase {0} to UserStory {1}", TestCaseID, UserStoryID)); } catch (Exception ex) { // ignore "duplicate link" errors if (!ex.Message.StartsWith("TF26181")) { Console.WriteLine("ex: " + ex.Message); } } Console.ReadLine(); }
private void button1_Click(object sender, EventArgs e) { fromlink = this.comboBox1.SelectedItem as WorkItemLinkType; tolink = this.comboBox2.SelectedItem as WorkItemLinkType; this.Close(); }
private static WorkItemLinkType CreateParentChildRelation(WorkItemStore store, WorkItem subItem, int parentId) { WorkItemLinkType hierarchyLinkType = store.WorkItemLinkTypes[CoreLinkTypeReferenceNames.Hierarchy]; subItem.Links.Add(new WorkItemLink(hierarchyLinkType.ReverseEnd, parentId)); // subItem.Save(); return(hierarchyLinkType); }
public WorkItemLinkInfoDetails(WorkItemLinkInfo linkInfo, WorkItem sourceWorkItem, WorkItem targetWorkItem,WorkItemLinkType linkType) { this.LinkInfo = linkInfo; this.SourceWorkItem = sourceWorkItem; this.TargetWorkItem = targetWorkItem; this.LinkType = linkType; }
public WorkItemLinkInfoDetails(WorkItemLinkInfo linkInfo, WorkItem sourceWorkItem, WorkItem targetWorkItem, WorkItemLinkType linkType) { this.LinkInfo = linkInfo; this.SourceWorkItem = sourceWorkItem; this.TargetWorkItem = targetWorkItem; this.LinkType = linkType; }
public static int ChangeLinkTypes(int[] qdata, WorkItemLinkType fromlink, WorkItemLinkType tolink) { int changedlinks = 0; foreach(int itm in qdata) { if (itm == 0) continue; WorkItem wi = Utilities.wistore.GetWorkItem(itm); foreach (var link in wi.Links.OfType<RelatedLink>().Where(x => x.LinkTypeEnd.LinkType.ReferenceName == fromlink.ReferenceName).ToList()) { WorkItemLinkTypeEnd linkTypeEnd = Utilities.wistore.WorkItemLinkTypes.LinkTypeEnds[(link.LinkTypeEnd.IsForwardLink ? tolink.ForwardEnd.Name : tolink.ReverseEnd.Name)]; Utilities.OutputCommandString(string.Format("Updated WorkItemID={0}, OriginalLink={1}, NewLink={2}", wi.Id, link.LinkTypeEnd.Name, linkTypeEnd.Name)); if (wi.IsDirty) { try { wi.Save(); } catch (Exception ex) { var result = MessageBox.Show(ex.Message, "Failed to save dirty Work Item #" + wi.Id, MessageBoxButtons.AbortRetryIgnore); Utilities.OutputCommandString(ex.ToString()); if (result == DialogResult.Abort) return changedlinks; else continue; } } try { wi.Links.Add(new RelatedLink(linkTypeEnd, link.RelatedWorkItemId)); wi.Save(); changedlinks++; } catch (Exception ex) { var result = MessageBox.Show(ex.Message,"Failed to add new link to Work Item #"+wi.Id,MessageBoxButtons.AbortRetryIgnore); Utilities.OutputCommandString(ex.ToString()); if (result == DialogResult.Abort) return changedlinks; else continue; } try { wi.Links.Remove(link); wi.Save(); } catch (Exception ex) { var result = MessageBox.Show(ex.Message, "Failed to remove original link from Work Item #" + wi.Id, MessageBoxButtons.AbortRetryIgnore); Utilities.OutputCommandString(ex.ToString()); if (result == DialogResult.Abort) return changedlinks; else continue; } } } return changedlinks; }
private static void CreateTestedByLink(SharedStepsObject sharedStepsObject, int parentId) { WorkItemStore workItemStore = sharedStepsObject.project.Store; Project teamProject = workItemStore.Projects["Schwans Company"]; var linkTypes = workItemStore.WorkItemLinkTypes; WorkItemLinkType testedBy = linkTypes.FirstOrDefault(lt => lt.ForwardEnd.Name == "Tested By"); WorkItemLinkTypeEnd linkTypeEnd = testedBy.ForwardEnd; sharedStepsObject.testedWorkItem.Links.Add(new RelatedLink(linkTypeEnd, sharedStepsObject.id + 1)); var result = CheckValidationResult(sharedStepsObject.testedWorkItem); }
static void Main(string[] args) { string uri = "https://iiaastfs.ww004.siemens.net/tfs/tia"; string projectName = "TIA"; WorkItemStore workItemStore = GetWorkItemStore(uri); Project tfsProject = workItemStore.Projects[projectName]; WorkItemType wIType = tfsProject.WorkItemTypes["TASK"]; //Create a hierarchy type (Parent-Child) relationship WorkItemLinkType hierarchyLinkType = workItemStore.WorkItemLinkTypes[CoreLinkTypeReferenceNames.Hierarchy]; CreateFeatureTestTasks(uri, projectName, wIType, hierarchyLinkType); //CreateIncrementtestTasks(uri, projectName, wIType, hierarchyLinkType); }
internal static WorkItemLinkTypeWrapper GetInstance() { WorkItemLinkType real = default(WorkItemLinkType); RealInstanceFactory(ref real); var instance = (WorkItemLinkTypeWrapper)WorkItemLinkTypeWrapper.GetWrapper(real); InstanceFactory(ref instance); if (instance == null) { Assert.Inconclusive("Could not Create Test Instance"); } return(instance); }
private static bool IsValidLinkInfo(WorkItemLinkInfo linkInfo, WorkItemLinkType linkType) { if (linkType == null) { return(false); } // If the link id in the link info is 0 we handle a root item --> ann accepted sceanrio if (linkInfo.LinkTypeId == 0) { return(true); } // If the link id from the link info matches the forward end link id of the given link type than we have a link that fits if (linkInfo.LinkTypeId == linkType.ForwardEnd.Id) { return(true); } // IN all other cases the link type being configured does not fit to the link info being returned by a query return(false); }
protected ExtendedLinkProperties GetExtendedLinkProperties(WorkItemLinkType workItemLinkType) { int topologyVal = 0; if (workItemLinkType.IsDirectional) { topologyVal |= (int)ExtendedLinkProperties.ToplogyRuleAndDirectionality.Directed; } if (workItemLinkType.IsNonCircular) { topologyVal |= (int)ExtendedLinkProperties.ToplogyRuleAndDirectionality.NonCircular; } if (workItemLinkType.IsOneToMany) { topologyVal |= (int)ExtendedLinkProperties.ToplogyRuleAndDirectionality.OnlyOneParent; } return(new ExtendedLinkProperties((ExtendedLinkProperties.Topology)topologyVal)); }
internal void AddWorkItemLink(IWorkItemExposed destination, string linkTypeName, IEnumerable <WorkItemLinkType> availableLinkTypes) { WorkItemLinkType workItemLinkType = availableLinkTypes .FirstOrDefault( t => new string[] { t.ForwardEnd.ImmutableName, t.ForwardEnd.Name, t.ReverseEnd.ImmutableName, t.ReverseEnd.Name } .Contains(linkTypeName, StringComparer.OrdinalIgnoreCase)); if (workItemLinkType == null) { throw new ArgumentOutOfRangeException(nameof(linkTypeName)); } WorkItemLinkTypeEnd destLinkType; #pragma warning disable S3240 if ( new string[] { workItemLinkType.ForwardEnd.ImmutableName, workItemLinkType.ForwardEnd.Name } .Contains(linkTypeName, StringComparer.OrdinalIgnoreCase)) { destLinkType = workItemLinkType.ForwardEnd; } else { destLinkType = workItemLinkType.ReverseEnd; } #pragma warning restore S3240 var relationship = new WorkItemLink(destLinkType, this.Id, destination.Id); // check it does not exist already if (!this.workItem.WorkItemLinks.Contains(relationship)) { this.Logger.AddingWorkItemLink(this.Id, destLinkType, destination.Id); this.workItem.WorkItemLinks.Add(relationship); } else { this.Logger.WorkItemLinkAlreadyExists(this.Id, destLinkType, destination.Id); } }
static partial void RealInstanceFactory(ref WorkItemLinkType real, [CallerMemberName] string callerName = "");
static partial void RealInstanceFactory(ref WorkItemLinkType real, string callerName) { real = GetRealInstance(); }
/// <summary> /// Initializes a new instance of the <see cref="TfsWorkItemLinkType"/> class. /// </summary> /// <param name="workItemLinkType">Type of the work item link.</param> /// <param name="linkType">Type of the link.</param> internal TfsWorkItemLinkType(WorkItemLinkType workItemLinkType, LinkType linkType) { _workItemLinkType = workItemLinkType; _linkType = linkType; }
private static WorkItemLinkTypeCollection GetLinks(WorkItemTrackingHttpClient workItemStore) { var types = workItemStore.GetRelationTypesAsync().GetAwaiter().GetResult(); var d = new Dictionary <string, IList <WorkItemRelationType> >(StringComparer.OrdinalIgnoreCase); var d2 = new Dictionary <string, WorkItemLinkType>(StringComparer.OrdinalIgnoreCase); foreach (var type in types.Where(p => (string)p.Attributes["usage"] == "workItemLink")) { var m = ImmutableLinkTypeNameRegex.Match(type.ReferenceName); var linkRef = m.Groups["LinkTypeReferenceName"].Value; if (string.IsNullOrWhiteSpace(linkRef)) { linkRef = type.ReferenceName; } if (!d.ContainsKey(linkRef)) { d[linkRef] = new List <WorkItemRelationType>(); } d[linkRef].Add(type); if (!d2.ContainsKey(linkRef)) { d2[linkRef] = new WorkItemLinkType(linkRef); } } foreach (var kvp in d2) { var type = kvp.Value; var ends = d[kvp.Key]; type.IsDirectional = ends.All(p => (bool)p.Attributes["directional"]); type.IsActive = ends.All(p => (bool)p.Attributes["enabled"]); var forwardEnd = ends.Count == 1 && !type.IsDirectional ? ends[0] : ends.SingleOrDefault(p => p.ReferenceName.EndsWith("Forward")); if (!forwardEnd.ReferenceName.EndsWith("Forward")) { forwardEnd.ReferenceName += "-Forward"; } type.SetForwardEnd(new WorkItemLinkTypeEnd(forwardEnd) { IsForwardLink = true, LinkType = type }); type.SetReverseEnd( type.IsDirectional ? new WorkItemLinkTypeEnd( ends.SingleOrDefault(p => p.ReferenceName.EndsWith("Reverse"))) { LinkType = type } : type.ForwardEnd); // The REST API does not return the ID of the link type. For well-known system links, we can populate the ID value if (CoreLinkTypeReferenceNames.All.Contains(type.ReferenceName, StringComparer.OrdinalIgnoreCase)) { int forwardId = 0, reverseId = 0; if (CoreLinkTypeReferenceNames.Hierarchy.Equals(type.ReferenceName, StringComparison.OrdinalIgnoreCase)) { // The forward should be Child, but the ID used in CoreLinkTypes is -2, should be 2 forwardId = CoreLinkTypes.Child; reverseId = CoreLinkTypes.Parent; } else if (CoreLinkTypeReferenceNames.Related.Equals(type.ReferenceName, StringComparison.OrdinalIgnoreCase)) { forwardId = reverseId = CoreLinkTypes.Related; } else if (CoreLinkTypeReferenceNames.Dependency.Equals(type.ReferenceName, StringComparison.OrdinalIgnoreCase)) { forwardId = CoreLinkTypes.Successor; reverseId = CoreLinkTypes.Predecessor; } ((WorkItemLinkTypeEnd)type.ForwardEnd).Id = -forwardId; ((WorkItemLinkTypeEnd)type.ReverseEnd).Id = -reverseId; } } return(new WorkItemLinkTypeCollection(d2.Values.OfType <IWorkItemLinkType>().ToList())); }
private static void CreateFeatureTestTasks(string uri, string projectName, WorkItemType wIType, WorkItemLinkType hierarchyLinkType) { int parentID = 904830; string titlePrefix = @"LIBS-15-7 driver-instance-global connect"; Console.WriteLine(titlePrefix + " tasks start."); string areaPath = @"TIA\Development\HMI Runtime Innovation Line\IOWA Runtime Innovation Line Platform\Integrationstest\FeatureTest"; string iterationPath = @"TIA\IOWA\Backlog"; // string iterationPath = @"TIA\IOWA\IOWA 2015\Inc 25 (31.08.2013)"; string tags = "DevRelease5"; //string tags = string.Empty; //string assignedTo = "Palotas Gergely"; // string assignedTo = "Csepe Zsombor"; //string assignedTo = "Kiss Zoltan2-Miklos"; string assignedTo = string.Empty; // CreateTask(parentID, titlePrefix + ": KickOff meeting", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 50, tags, assignedTo ); CreateTask(parentID, titlePrefix + ": Create TestSpec.", wIType, hierarchyLinkType, areaPath, iterationPath, 24, 50, tags, assignedTo); CreateTask(parentID, titlePrefix + ": Review meeting TestSpec.", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 50, tags, assignedTo); CreateTask(parentID, titlePrefix + ": Rework TestSpec. after review", wIType, hierarchyLinkType, areaPath, iterationPath, 16, 50, tags, assignedTo); CreateTask(parentID, titlePrefix + ": Testcase implementation Rank1 + Review", wIType, hierarchyLinkType, areaPath, iterationPath, 32, 50, tags, assignedTo); CreateTask(parentID, titlePrefix + ": Testcase implementation", wIType, hierarchyLinkType, areaPath, iterationPath, 32, 50, tags, assignedTo); CreateTask(parentID, titlePrefix + @": BranchTest/IntegrationTest", wIType, hierarchyLinkType, areaPath, iterationPath, 24, 50, tags, assignedTo); Console.WriteLine(titlePrefix + " tasks are ready. Press Enter to close this window."); Console.ReadLine(); }
private static void CreateIncrementtestTasks(string uri, string projectName, WorkItemType wIType, WorkItemLinkType hierarchyLinkType) { int parentID = 966669; string titlePrefix = @"Increment 32 test"; Console.WriteLine(titlePrefix + " tasks start."); string areaPath = @"TIA\Development\HMI Runtime Innovation Line\IOWA Runtime Innovation Line Platform\Integrationstest\Integration"; string iterationPath = @"TIA\IOWA\IOWA 2015\Inc 32 (31.03.2014)"; CreateTask(parentID, titlePrefix + ": AlarmingInEvent", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Csepe Zsombor"); CreateTask(parentID, titlePrefix + ": AlarmLogging", wIType, hierarchyLinkType, areaPath, iterationPath, 4, 30, "", "Bleier, Gerald"); CreateTask(parentID, titlePrefix + ": AlarmText, AlarmText Formatter", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Palotas Gergely"); CreateTask(parentID, titlePrefix + ": APIMAN", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Lenart Gabor"); CreateTask(parentID, titlePrefix + ": BasicSystemFunctions: SCS-13-2, UC53", wIType, hierarchyLinkType, areaPath, iterationPath, 3, 30, "", "Kiss Zoltan2-Miklos"); CreateTask(parentID, titlePrefix + ": BasicSystemFunctions: SCS-13-3, SCS-13-4, ASR46", wIType, hierarchyLinkType, areaPath, iterationPath, 3, 30, "", "Homan-Bakos Krisztina"); CreateTask(parentID, titlePrefix + ": BasicSystemFunctions manual", wIType, hierarchyLinkType, areaPath, iterationPath, 8, 30, "", "Homan-Bakos Krisztina"); CreateTask(parentID, titlePrefix + ": Configuration Access Layer", wIType, hierarchyLinkType, areaPath, iterationPath, 4, 30, "", "Palotas Gergely"); CreateTask(parentID, titlePrefix + ": Caching of Identification", wIType, hierarchyLinkType, areaPath, iterationPath, 4, 30, "", "Lenart Gabor"); CreateTask(parentID, titlePrefix + ": DistributedSystem", wIType, hierarchyLinkType, areaPath, iterationPath, 4, 30, "", "Lenart Gabor"); CreateTask(parentID, titlePrefix + ": Driver", wIType, hierarchyLinkType, areaPath, iterationPath, 2, 30, "", "Bleier, Gerald"); CreateTask(parentID, titlePrefix + ": DriverFramework_Tracing", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Simon Attila (ext)"); CreateTask(parentID, titlePrefix + ": General", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Palotas Gergely"); CreateTask(parentID, titlePrefix + ": Localization", wIType, hierarchyLinkType, areaPath, iterationPath, 4, 30, "", "Kiss Zoltan2-Miklos"); CreateTask(parentID, titlePrefix + ": NameService", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Kiss Zoltan2-Miklos"); CreateTask(parentID, titlePrefix + @": PLCAlarming(S7-300)", wIType, hierarchyLinkType, areaPath, iterationPath, 4, 30, "", "Csepe Zsombor"); CreateTask(parentID, titlePrefix + @": PLCAlarming(S7-400)", wIType, hierarchyLinkType, areaPath, iterationPath, 4, 30, "", "Csepe Zsombor"); CreateTask(parentID, titlePrefix + @": RAM/CPU", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Nagy David (ext)"); CreateTask(parentID, titlePrefix + ": SystemInterfaces_Base", wIType, hierarchyLinkType, areaPath, iterationPath, 2, 30, "", "Palotas Gergely"); CreateTask(parentID, titlePrefix + ": SystemInterfaces_ITimer", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Palotas Gergely"); CreateTask(parentID, titlePrefix + ": SystemInterfaces_LanguageFilter", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Kiss Zoltan2-Miklos"); CreateTask(parentID, titlePrefix + ": TagLogging", wIType, hierarchyLinkType, areaPath, iterationPath, 5, 30, "", "Harmati Daniel"); CreateTask(parentID, titlePrefix + ": TIA Integration RDF Config", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Homan-Bakos Krisztina"); CreateTask(parentID, titlePrefix + ": Timedfunc.", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Csepe Zsombor"); CreateTask(parentID, titlePrefix + ": Tracing", wIType, hierarchyLinkType, areaPath, iterationPath, 1, 30, "", "Simon Attila (ext)"); // CreateTask(parentID, titlePrefix + ": New1", wIType, hierarchyLinkType, areaPath, iterationPath, 4, 30, "", ""); // CreateTask(parentID, titlePrefix + ": New2", wIType, hierarchyLinkType, areaPath, iterationPath, 4, 30, "", ""); Console.WriteLine(titlePrefix + " tasks are ready. Press Enter to close this window."); Console.ReadLine(); }
public static int ChangeLinkTypes(int[] qdata, WorkItemLinkType fromlink, WorkItemLinkType tolink) { int changedlinks = 0; foreach (int itm in qdata) { if (itm == 0) { continue; } WorkItem wi = Utilities.wistore.GetWorkItem(itm); foreach (var link in wi.Links.OfType <RelatedLink>().Where(x => x.LinkTypeEnd.LinkType.ReferenceName == fromlink.ReferenceName).ToList()) { WorkItemLinkTypeEnd linkTypeEnd = Utilities.wistore.WorkItemLinkTypes.LinkTypeEnds[(link.LinkTypeEnd.IsForwardLink ? tolink.ForwardEnd.Name : tolink.ReverseEnd.Name)]; Utilities.OutputCommandString(string.Format("Updated WorkItemID={0}, OriginalLink={1}, NewLink={2}", wi.Id, link.LinkTypeEnd.Name, linkTypeEnd.Name)); if (wi.IsDirty) { try { wi.Save(); } catch (Exception ex) { var result = MessageBox.Show(ex.Message, "Failed to save dirty Work Item #" + wi.Id, MessageBoxButtons.AbortRetryIgnore); Utilities.OutputCommandString(ex.ToString()); if (result == DialogResult.Abort) { return(changedlinks); } else { continue; } } } try { wi.Links.Add(new RelatedLink(linkTypeEnd, link.RelatedWorkItemId)); wi.Save(); changedlinks++; } catch (Exception ex) { var result = MessageBox.Show(ex.Message, "Failed to add new link to Work Item #" + wi.Id, MessageBoxButtons.AbortRetryIgnore); Utilities.OutputCommandString(ex.ToString()); if (result == DialogResult.Abort) { return(changedlinks); } else { continue; } } try { wi.Links.Remove(link); wi.Save(); } catch (Exception ex) { var result = MessageBox.Show(ex.Message, "Failed to remove original link from Work Item #" + wi.Id, MessageBoxButtons.AbortRetryIgnore); Utilities.OutputCommandString(ex.ToString()); if (result == DialogResult.Abort) { return(changedlinks); } else { continue; } } } } return(changedlinks); }
/// <summary> /// /// </summary> /// <param name="parentID"></param> /// <param name="title"></param> /// <param name="wIType"></param> /// <param name="hierarchyLinkType"></param> private static void CreateTask(int parentID, string title, WorkItemType wIType, WorkItemLinkType hierarchyLinkType, string areaPath, string iterationPath, int workingHours, int stackRank, string tags, string assignedTo) { WorkItem workItem = new WorkItem(wIType); workItem.Title = title; workItem.AreaPath = areaPath; workItem.IterationPath = iterationPath; //Set user story as parent of new task workItem.Links.Add(new WorkItemLink(hierarchyLinkType.ReverseEnd, parentID)); //if (String.IsNullOrEmpty(assignedTo)) // workItem.Fields["Assigned to"].Value = workItem.ChangedBy; //else workItem.Fields["Assigned to"].Value = assignedTo; workItem.Fields["Original estimate"].Value = workingHours; workItem.Fields["Remaining work"].Value = workingHours; workItem.Fields["Stack rank"].Value = stackRank; workItem.Fields["Tags"].Value = tags; System.Collections.ArrayList result = workItem.Validate(); if (result.Count > 0) { Console.WriteLine("There was an error adding this work item to the work item repository."); } else { workItem.Save(); } }
static void Main(string[] args) { Console.WriteLine("Enter TFS Server Url: "); var serverUrl = Console.ReadLine(); TfsTeamProjectCollection tfsCollection = new TfsTeamProjectCollection(new Uri(serverUrl)); tfsCollection.EnsureAuthenticated(); WorkItemStore store = (WorkItemStore)tfsCollection.GetService(typeof(WorkItemStore)); Console.WriteLine("Enter TFS Project Name: "); var projectName = Console.ReadLine(); Project project = store.Projects[projectName]; Console.WriteLine("How many Feature do you want to create?: "); var featureCount = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("How many PBIs do you want to create for every feature Item?: "); var pbiCount = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("How many Tasks do you want to create for every PBI Item?: "); var taskCount = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("How many Bugs do you want to create for every PBI Item?: "); var bugCount = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("How many TestCases do you want to create for every PBI Item?: "); var testCount = Convert.ToInt32(Console.ReadLine()); try { for (int i = 0; i < featureCount; i++) { Console.WriteLine("Creating new Feature Work Item ... "); WorkItem workItem = CreateWorkItem(project, "Feature"); workItem.Save(); for (int j = 0; j < pbiCount; j++) { Console.WriteLine("Creating new Product Backlog Item ... "); WorkItem subItem = CreateWorkItem(project, "Product Backlog Item"); SetWorkItemState(subItem, j); WorkItemLinkType hierarchyLinkType = CreateParentChildRelation(store, subItem, workItem.Id); subItem.Save(); Console.WriteLine("Creating new Tasks ... "); for (int k = 0; k < taskCount; k++) { WorkItem subsubItem = CreateWorkItem(project, "Task"); SetWorkItemState(subsubItem, j); WorkItemLinkType hierarchyLinkType2 = CreateParentChildRelation(store, subsubItem, subItem.Id); subsubItem.Save(); } Console.WriteLine("Creating new Bugs ... "); for (int l = 0; l < bugCount; l++) { WorkItem subBugItem = CreateWorkItem(project, "Bug"); SetWorkItemState(subBugItem, j); WorkItemLinkType hierarchyLinkType3 = CreateParentChildRelation(store, subBugItem, workItem.Id); CreateSimpleRelation(store, subBugItem, subItem.Id); subBugItem.Save(); } Console.WriteLine("Creating new Test Cases ... "); for (int k = 0; k < testCount; k++) { WorkItem subTestItem = CreateWorkItem(project, "Test Case"); SetWorkItemState(subTestItem, j); CreateTestRelation(store, subTestItem, subItem.Id); subTestItem.Save(); } } } } catch (Exception ex) { Console.WriteLine("********Cannot Save Work Item Relation*********"); Console.WriteLine(ex.Message); } Console.WriteLine("Es wurden {0} Work Items erstellt.", Count.ToString()); Console.WriteLine("Beenden Sie das Programm mit einer beliebigen Taste ..."); Console.ReadLine(); }