public void CreateAreas() { TfsTeamProjectCollection tpc = TfsConnect(); XmlDocument xmlInput = new XmlDocument(); xmlInput.Load(InputFile); int count = 0; XmlNodeList areas = xmlInput.SelectNodes("//areas/area"); foreach (XmlNode area in areas) { count++; Console.Write("."); if (area.Attributes["parent"] != null) { AddArea(tpc, TeamProject, area.InnerText, area.Attributes["parent"].Value); } else { AddArea(tpc, TeamProject, area.InnerText); } } // RefreshCache and SyncToCache WorkItemStore store = new WorkItemStore(tpc); store.RefreshCache(); store.SyncToCache(); Console.WriteLine(string.Format(" ({0} areas created)", count)); }
private void RefreshCache() { ICommonStructureService css = tfs.GetService <ICommonStructureService>(); WorkItemServer server = tfs.GetService <WorkItemServer>(); server.SyncExternalStructures(WorkItemServer.NewRequestId(), css.GetProjectFromName(projectName).Uri); store.RefreshCache(); }
private Node WaitForTreeNodeId( Node.TreeType type, string[] nodes, int first) { int[] TIMEOUTS = { 100, 500, 1000, 5000 }; int[] RetryTimes = { 1, 2, 70, 36 }; for (int i = 0; i < TIMEOUTS.Length; ++i) { for (int k = 0; k < RetryTimes[i]; ++k) { System.Threading.Thread.Sleep(TIMEOUTS[i]); Debug.Write(string.Format("Wake up from {0} millisec sleep for polling CSS node Id", TIMEOUTS[i])); m_store.RefreshCache(); Project p = m_store.Projects[m_project.Name]; NodeCollection nc = type == Node.TreeType.Area ? p.AreaRootNodes : p.IterationRootNodes; Node n = null; int numNodesToCheck = nodes.Length - 1; if (first != -1) { numNodesToCheck = first; } try { for (int j = 0; j <= numNodesToCheck; j++) { string name = nodes[j]; if (!string.IsNullOrEmpty(name)) { n = nc[name]; nc = n.ChildNodes; } } return(n); } catch (DeniedOrNotExistException) { // The node is not there yet. Try one more time... } } } return(null); }
public TFSService(MergeOptions opts) { _collection = new TfsTeamProjectCollection(new Uri(opts.CollectionUrl)); _collection.EnsureAuthenticated(); _sourceControl = _collection.GetService <VersionControlServer>(); Workstation.Current.EnsureUpdateWorkspaceInfoCache(_sourceControl, _sourceControl.AuthorizedUser); _workspace = _sourceControl.GetWorkspace(opts.Workspace, _sourceControl.AuthorizedUser); // Or WindowsIdentity.GetCurrent().Name _workitemStore = _collection.GetService <WorkItemStore>(); _workitemStore.RefreshCache(); _source = opts.Source; _target = opts.Target; _workitemID = opts.Workitem; SubscribeEvents(); }
internal void CreateWorkItem(string sprintWI, string title, string iterationPath, Dictionary <string, object> fields) { wiStore.RefreshCache(); WorkItem newItm = new WorkItem(wiTypes[sprintWI]); newItm.Title = title; newItm.IterationPath = ReplaceFirst(iterationPath, @"\" + teamProjectName + @"\Iteration\", teamProjectName + @"\"); foreach (KeyValuePair <string, object> kvp in fields) { newItm.Fields[kvp.Key].Value = kvp.Value; } newItm.Save(); }
/// <summary> /// Associate Work Item to our shelveset /// </summary> public static void AssociateWorkItemToShelveset() { WorkItemCheckinInfo work = new WorkItemCheckinInfo(workItemReviewCode, WorkItemCheckinAction.Associate); work.CheckinAction = WorkItemCheckinAction.Associate; List <WorkItemCheckinInfo> workCollection = new List <WorkItemCheckinInfo>(); workCollection.Add(work); shelveset.WorkItemInfo = workCollection.ToArray(); if (shelvesetExist) { //TODO Ne pas remplacer le ShelveSet mais Creér un id Unique workspace.Shelve(shelveset, changes, ShelvingOptions.Replace); } else { workspace.Shelve(shelveset, changes, ShelvingOptions.None); wiStore.SyncToCache(); wiStore.RefreshCache(); } }
/// <summary> /// Import "My WIT" work item type if it has not been imported yet. /// </summary> /// <param name="wis">A WorkItemStore instance</param> /// <param name="projectName">The name of the team project</param> private static void EnsureWITImported(WorkItemStore wis, string projectName) { Project project = wis.Projects[projectName]; if (!project.WorkItemTypes.Contains("My WIT")) { using (var reader = new StreamReader("My WIT.xml")) { // Read work item definition from "My WIT.xml". var definition = reader.ReadToEnd(); // Import the work item definition. project.WorkItemTypes.Import(definition); // Refresh work item cache. wis.RefreshCache(); // Switch the WorkItemStore instance to use the latest metadata. wis.SyncToCache(); } } }
public void CreateIterations() { try { TfsTeamProjectCollection tpc = TfsConnect(); DateTime startDate = DateTime.Today; int count = 0; // Get service and hierarchy ICommonStructureService4 css = tpc.GetService <ICommonStructureService4>(); ProjectInfo project = css.GetProjectFromName(TeamProject); NodeInfo[] hierarchy = css.ListStructures(project.Uri); XmlElement tree; if (hierarchy[0].Name.ToLower() == "iteration") { tree = css.GetNodesXml(new string[] { hierarchy[0].Uri }, true); } else { tree = css.GetNodesXml(new string[] { hierarchy[1].Uri }, true); } string parentUri = tree.FirstChild.Attributes["NodeID"].Value; int lastSprint = 1; for (int release = 1; release <= TotalReleases; release++) { string releaseUri = css.CreateNode("Release " + release.ToString(), parentUri); css.SetIterationDates(releaseUri, startDate, startDate.AddDays(SprintsPerRelease * WeeksPerSprint * 7 - 1)); for (int sprint = 1; sprint <= SprintsPerRelease; sprint++) { string sprintUri; count++; Console.Write("."); if (ResetSprintsEachRelease) { sprintUri = css.CreateNode("Sprint " + sprint.ToString(), releaseUri); } else { sprintUri = css.CreateNode("Sprint " + lastSprint, releaseUri); } css.SetIterationDates(sprintUri, startDate, startDate.AddDays(WeeksPerSprint * 7 - 1)); startDate = startDate.AddDays(WeeksPerSprint * 7); lastSprint++; } } // RefreshCache and SyncToCache WorkItemStore store = new WorkItemStore(tpc); store.RefreshCache(); store.SyncToCache(); Console.WriteLine(string.Format(" ({0} releases, {1} sprints created)", TotalReleases, count)); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); throw; } }