/// <summary> /// Set the root node URI for Area Path and Iteration Path /// </summary> /// <param name="css">Handle to Common Structure Services</param> /// <param name="projectName">Team Foundation Project Name</param> private static void SetDefaultCSSUri(ICommonStructureService css, string projectName) { if (RootAreaNodeUri == null && RootIterationNodeUri == null) { ProjectInfo m_project = css.GetProjectFromName(projectName); NodeInfo[] nodes = css.ListStructures(m_project.Uri); bool fFoundArea = false; bool fFoundIteration = false; for (int i = 0; (fFoundArea == false || fFoundIteration == false) && i < nodes.Length; i++) { if (!fFoundArea && string.Equals(nodes[i].StructureType, VSTSConstants.AreaRoot, StringComparison.OrdinalIgnoreCase)) { RootAreaNodeUri = nodes[i].Uri; fFoundArea = true; } if (!fFoundIteration && string.Equals(nodes[i].StructureType, VSTSConstants.IterationRoot, StringComparison.OrdinalIgnoreCase)) { RootIterationNodeUri = nodes[i].Uri; fFoundIteration = true; } } } }
private void GenerateSubAreas(XmlNode tree, string nodePath, ICommonStructureService css) { var path = css.GetNodeFromPath(nodePath); int nodeCount = tree.FirstChild.ChildNodes.Count; for (int i = 0; i < nodeCount; i++) { XmlNode Node = tree.ChildNodes[0].ChildNodes[i]; try { css.CreateNode(Node.Attributes["Name"].Value, path.Uri); } catch (Exception ex) { logger.Error(string.Format("{0}", path.Uri), ex); //node already exists continue; } if (Node.FirstChild != null) { string newPath = nodePath + "\\" + Node.Attributes["Name"].Value; GenerateSubAreas(Node, newPath, css); } } }
public static NodeInfo AddNode(ICommonStructureService commonStructureService, string elementPath, string projectName, eStructureType nodeType) { NodeInfo retVal; string rootNodePath = "\\" + projectName + "\\" + nodeType.ToString(); if (CheckIfPathAlreadyExists(commonStructureService, elementPath, rootNodePath)) { return null; } int backSlashIndex = GetBackSlashIndex(elementPath); string newpathname = GetNewPathName(elementPath, backSlashIndex); string path = GetActualNodePath(elementPath, backSlashIndex); string pathRoot = rootNodePath + path; NodeInfo previousPath = GetPreviousPath(commonStructureService, pathRoot); if (previousPath == null) { // call this method to create the parent paths. previousPath = AddNode(commonStructureService, path, projectName, nodeType); } string newPathUri = commonStructureService.CreateNode(newpathname, previousPath.Uri); return commonStructureService.GetNode(newPathUri); }
private static bool CheckIfPathAlreadyExists(ICommonStructureService commonStructureService, string elementPath, string rootNodePath) { bool result = false; if (!elementPath.StartsWith("\\")) { elementPath = "\\" + elementPath; } string newPath = rootNodePath + elementPath; try { if (DoesNodeExistInPath(commonStructureService, newPath)) { result = true; } } catch (Exception ex) { if (!ExceptionMeansThatPathDoesNotExists(ex)) { throw; } } return result; }
public TfsNodeStructureEnricher(IMigrationEngine engine, ILogger <TfsNodeStructureEnricher> logger) : base(engine, logger) { _sourceCommonStructureService = (ICommonStructureService)Engine.Source.GetService <ICommonStructureService>(); _targetCommonStructureService = (ICommonStructureService)Engine.Target.GetService <ICommonStructureService4>(); _sourceProjectInfo = _sourceCommonStructureService.GetProjectFromName(Engine.Source.Config.AsTeamProjectConfig().Project); _sourceRootNodes = _sourceCommonStructureService.ListStructures(_sourceProjectInfo.Uri); }
static void Main(string[] args) { // Try to parse options from command line var options = new Options(); if (Parser.Default.ParseArguments(args, options)) { try { _collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(options.TeamCollection)); _buildServer = _collection.GetService<IBuildServer>(); _commonStructureService = _collection.GetService<ICommonStructureService>(); _printer = new TabbedPrinter(); PrintDefinitions(options); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine("An error occured:"); Console.WriteLine(ex.Message); Console.WriteLine(); } } else { Console.WriteLine("Couldn't read options"); Console.WriteLine(); } }
internal static string GetAreaRootNodeUri(string projectUri) { string nodeUri = String.Empty; ICommonStructureService cssProxy = (ICommonStructureService)GetProxy(m_teamSystemName, typeof(ICommonStructureService)); NodeInfo[] nodeInfos = cssProxy.ListStructures(projectUri); if (nodeInfos == null) { throw new ConverterException(VSTSResource.InvalidStructureNode); } foreach (NodeInfo nodeInfo in nodeInfos) { if (TFStringComparer.StructureType.Equals(nodeInfo.StructureType, StructureType.ProjectModelHierarchy)) { nodeUri = nodeInfo.Uri; break; } } if (String.IsNullOrEmpty(nodeUri)) { throw new ConverterException(VSTSResource.InvalidStructureNode); } return(nodeUri); }
private void ProcessCommonStructure(string treeType, NodeInfo[] sourceNodes, ICommonStructureService targetCss, ICommonStructureService sourceCss) { NodeInfo sourceNode = null; sourceNode = (from n in sourceNodes where n.Path.Contains(treeType) select n)?.SingleOrDefault(); if (sourceNode == null && treeType == "Iteration") { sourceNode = (from n in sourceNodes where n.Name.Equals("Milestone", StringComparison.OrdinalIgnoreCase) select n)?.SingleOrDefault(); } if (sourceNode == null) { throw new Exception($"No elements found in the sequence for the tree type {treeType}. Please check the process template and project details."); } XmlElement sourceTree = sourceCss.GetNodesXml(new string[] { sourceNode.Uri }, true); NodeInfo structureParent = targetCss.GetNodeFromPath(string.Format("\\{0}\\{1}", me.Target.Name, treeType)); if (config.PrefixProjectToNodes) { structureParent = CreateNode(targetCss, me.Source.Name, structureParent); } if (sourceTree.ChildNodes[0].HasChildNodes) { CreateNodes(sourceTree.ChildNodes[0].ChildNodes[0].ChildNodes, targetCss, structureParent, treeType); } }
/// <summary> /// Loads the list of projects and enables the project combo box /// </summary> private void LoadProjects() { //Get the list of projects and display them _css = (ICommonStructureService)_tfs.GetService(typeof(ICommonStructureService)); cboProjects.ItemsSource = _css.ListProjects(); cboProjects.IsEnabled = true; }
public void ShowProjects() { ICommonStructureService css = Driver.TeamFoundationServer.GetService(typeof(ICommonStructureService)) as ICommonStructureService; ProjectInfo[] projects = css.ListProjects(); Array.Sort(projects, new ProjectInfoComparer()); int GUID_SIZE = 36; int maxName = WindowWidth - GUID_SIZE - 2; string line = String.Format("{0} {1}", "Guid".PadRight(GUID_SIZE), "Name".PadRight(maxName)); Console.WriteLine(line); line = String.Format("{0} {1}", "-".PadRight(GUID_SIZE, '-'), "-".PadRight(maxName, '-')); Console.WriteLine(line); foreach (ProjectInfo pinfo in (projects)) { int indx = Math.Max(pinfo.Uri.LastIndexOf('/') + 1, 0); string guid = pinfo.Uri.Substring(indx); Console.WriteLine(guid + " " + pinfo.Name); } }
public static NodeInfo AddNode(ICommonStructureService commonStructureService, string elementPath, string projectName, eStructureType nodeType) { NodeInfo retVal; string rootNodePath = "\\" + projectName + "\\" + nodeType.ToString(); if (CheckIfPathAlreadyExists(commonStructureService, elementPath, rootNodePath)) { return(null); } int backSlashIndex = GetBackSlashIndex(elementPath); string newpathname = GetNewPathName(elementPath, backSlashIndex); string path = GetActualNodePath(elementPath, backSlashIndex); string pathRoot = rootNodePath + path; NodeInfo previousPath = GetPreviousPath(commonStructureService, pathRoot); if (previousPath == null) { // call this method to create the parent paths. previousPath = AddNode(commonStructureService, path, projectName, nodeType); } string newPathUri = commonStructureService.CreateNode(newpathname, previousPath.Uri); return(commonStructureService.GetNode(newPathUri)); }
public Dictionary <string, string> PopulateIterations() { ICommonStructureService css = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService)); //Gets Area/Iteration base Project ProjectInfo projectInfo = css.GetProjectFromName(projectName); NodeInfo[] nodes = css.ListStructures(projectInfo.Uri); XmlElement areaTree = css.GetNodesXml(new[] { nodes.Single(n => n.StructureType == "ProjectModelHierarchy").Uri }, true); XmlElement iterationsTree = css.GetNodesXml(new[] { nodes.Single(n => n.StructureType == "ProjectLifecycle").Uri }, true); XmlNode areaNodes = areaTree.ChildNodes[0]; Queue <XmlNode> nodesToDo = new Queue <XmlNode>(); nodesToDo.Enqueue(iterationsTree.ChildNodes[0]); var map = new Dictionary <string, string>(); while (nodesToDo.Any()) { var current = nodesToDo.Dequeue(); var path = current.Attributes["Path"].Value; var nodeId = current.Attributes["NodeID"].Value; map.Add(path, nodeId); foreach (XmlNode item in current.ChildNodes) { foreach (XmlNode child in ((XmlNode)item).ChildNodes) { nodesToDo.Enqueue(child); } } } return(map); }
private void RefreshCache() { ICommonStructureService css = tfs.GetService <ICommonStructureService>(); WorkItemServer server = tfs.GetService <WorkItemServer>(); server.SyncExternalStructures(WorkItemServer.NewRequestId(), css.GetProjectFromName(projectName).Uri); }
public MyTfsProjectCollection(CatalogNode teamProjectCollectionNode, TfsConfigurationServer tfsConfigurationServer, NetworkCredential networkCredential) { try { Name = teamProjectCollectionNode.Resource.DisplayName; ServiceDefinition tpcServiceDefinition = teamProjectCollectionNode.Resource.ServiceReferences["Location"]; var configLocationService = tfsConfigurationServer.GetService<ILocationService>(); var tpcUri = new Uri(configLocationService.LocationForCurrentConnection(tpcServiceDefinition)); _tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcUri, new MyCredentials(networkCredential)); _commonStructureService = _tfsTeamProjectCollection.GetService<ICommonStructureService>(); _buildServer = _tfsTeamProjectCollection.GetService<IBuildServer>(); _tswaClientHyperlinkService = _tfsTeamProjectCollection.GetService<TswaClientHyperlinkService>(); CurrentUserHasAccess = true; } catch (TeamFoundationServiceUnavailableException ex) { _log.Debug("Can't access " + Name + ". This could be because the project collection is currently offline.", ex); CurrentUserHasAccess = false; } catch (TeamFoundationServerUnauthorizedException ex) { _log.Debug("Unauthorized access to " + teamProjectCollectionNode, ex); CurrentUserHasAccess = false; } }
private void CreateNodes(XmlNodeList nodeList, ICommonStructureService css, NodeInfo parentPath, string treeType) { foreach (XmlNode item in nodeList) { string newNodeName = item.Attributes["Name"].Value; NodeInfo targetNode; if (treeType == "Iteration") { DateTime?startDate = null; DateTime?finishDate = null; if (item.Attributes["StartDate"] != null) { startDate = DateTime.Parse(item.Attributes["StartDate"].Value); } if (item.Attributes["FinishDate"] != null) { finishDate = DateTime.Parse(item.Attributes["FinishDate"].Value); } targetNode = CreateNode(css, newNodeName, parentPath, startDate, finishDate); } else { targetNode = CreateNode(css, newNodeName, parentPath); } if (item.HasChildNodes) { CreateNodes(item.ChildNodes[0].ChildNodes, css, targetNode, treeType); } } }
private static bool CheckIfPathAlreadyExists(ICommonStructureService commonStructureService, string elementPath, string rootNodePath) { bool result = false; if (!elementPath.StartsWith("\\")) { elementPath = "\\" + elementPath; } string newPath = rootNodePath + elementPath; try { if (DoesNodeExistInPath(commonStructureService, newPath)) { result = true; } } catch (Exception ex) { if (!ExceptionMeansThatPathDoesNotExists(ex)) { throw; } } return(result); }
public AreaAndIterationPathCreator(Project project) { m_project = project; m_store = project.Store; m_css = (ICommonStructureService)m_store.TeamProjectCollection.GetService(typeof(ICommonStructureService)); GetRootNodes(); }
private void AddArea(TfsTeamProjectCollection tpc, string teamProject, string nodeValue, string parentValue = "") { try { // Get service and hierarchy ICommonStructureService css = tpc.GetService <ICommonStructureService>(); ProjectInfo project = css.GetProjectFromName(teamProject); NodeInfo[] hierarchy = css.ListStructures(project.Uri); XmlElement tree; if (hierarchy[0].Name.ToLower() == "area") { tree = css.GetNodesXml(new string[] { hierarchy[0].Uri }, true); } else { tree = css.GetNodesXml(new string[] { hierarchy[1].Uri }, true); } string parentUri = ""; if (parentValue == "") { parentUri = tree.FirstChild.Attributes["NodeID"].Value; } else { parentUri = tree.SelectSingleNode("//Children/Node[@Name='" + parentValue + "']").Attributes["NodeID"].Value; } css.CreateNode(nodeValue, parentUri); } catch { } }
public void GenerateAreas(XmlNode tree, string sourceProjectName) { ICommonStructureService css = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService)); string rootNodePath = string.Format("\\{0}\\Area", projectName); var pathRoot = css.GetNodeFromPath(rootNodePath); if (tree.FirstChild != null) { int myNodeCount = tree.FirstChild.ChildNodes.Count; for (int i = 0; i < myNodeCount; i++) { XmlNode Node = tree.ChildNodes[0].ChildNodes[i]; try { css.CreateNode(Node.Attributes["Name"].Value, pathRoot.Uri); } catch (Exception ex) { logger.Error(string.Format("{0}", pathRoot.Uri), ex); //node already exists continue; } if (Node.FirstChild != null) { string nodePath = rootNodePath + "\\" + Node.Attributes["Name"].Value; GenerateSubAreas(Node, nodePath, css); } } } RefreshCache(); }
public MyTfsProjectCollection(MyTfsServer myTfsServer, CatalogNode teamProjectCollectionNode) { try { _myTfsServer = myTfsServer; Name = teamProjectCollectionNode.Resource.DisplayName; ServiceDefinition tpcServiceDefinition = teamProjectCollectionNode.Resource.ServiceReferences["Location"]; var configLocationService = myTfsServer.GetConfigLocationService(); var tpcUri = new Uri(configLocationService.LocationForCurrentConnection(tpcServiceDefinition)); _tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcUri); _commonStructureService = _tfsTeamProjectCollection.GetService <ICommonStructureService>(); _buildServer = _tfsTeamProjectCollection.GetService <IBuildServer>(); _tswaClientHyperlinkService = _tfsTeamProjectCollection.GetService <TswaClientHyperlinkService>(); CurrentUserHasAccess = true; } catch (TeamFoundationServiceUnavailableException ex) { _log.Debug("Can't access " + Name + ". This could be because the project collection is currently offline.", ex); CurrentUserHasAccess = false; } catch (TeamFoundationServerUnauthorizedException ex) { _log.Debug("Unauthorized access to " + teamProjectCollectionNode, ex); CurrentUserHasAccess = false; } }
/// <summary> /// Queries TFS for a list of build definitions /// </summary> /// <param name="projectName">If set, only builddefs for this project are queried</param> /// <param name="buildName"></param> /// <returns></returns> public static IEnumerable<IBuildDefinitionQueryResult> QueryBuildDefinitions(ICommonStructureService css, IBuildServer bs, string projectName = "", string buildName = "") { var specs = new List<IBuildDefinitionSpec>(); if (String.IsNullOrWhiteSpace(projectName)) { // Get a query spec for each team project if (String.IsNullOrWhiteSpace(buildName)) specs.AddRange(css.ListProjects().Select(pi => bs.CreateBuildDefinitionSpec(pi.Name))); else specs.AddRange(css.ListProjects().Select(pi => bs.CreateBuildDefinitionSpec(pi.Name, buildName))); } else { // Get a query spec just for this team project if (String.IsNullOrWhiteSpace(buildName)) specs.Add(bs.CreateBuildDefinitionSpec(projectName)); else specs.Add(bs.CreateBuildDefinitionSpec(projectName, buildName)); } // Query the definitions var results = bs.QueryBuildDefinitions(specs.ToArray()); return results; }
private NodeInfo CreateNode(ICommonStructureService css, string name, NodeInfo parent, DateTime?startDate, DateTime?finishDate) { string nodePath = string.Format(@"{0}\{1}", parent.Path, name); NodeInfo node = null; Trace.Write(string.Format("--CreateNode: {0}, start date: {1}, finish date: {2}", nodePath, startDate, finishDate)); try { node = css.GetNodeFromPath(nodePath); Trace.Write("...found"); } catch (CommonStructureSubsystemException ex) { Telemetry.Current.TrackException(ex); Trace.Write("...missing"); string newPathUri = css.CreateNode(name, parent.Uri); Trace.Write("...created"); node = css.GetNode(newPathUri); ((ICommonStructureService4)css).SetIterationDates(node.Uri, startDate, finishDate); Trace.Write("...dates assigned"); } Trace.WriteLine(String.Empty); return(node); }
/// <summary> /// Initializes URI of root area and iteration nodes. /// </summary> private void GetRootNodes() { if (!m_hasRootNodes) { ICommonStructureService css = Css; NodeInfo[] nodes = css.ListStructures(m_store.Projects[m_cfg.Project].Uri.ToString()); string areaUri = null; string iterationUri = null; for (int i = 0; i < nodes.Length; i++) { NodeInfo n = nodes[i]; if (TFStringComparer.CssStructureType.Equals(n.StructureType, "ProjectLifecycle")) { iterationUri = n.Uri; } else if (TFStringComparer.CssStructureType.Equals(n.StructureType, "ProjectModelHierarchy")) { areaUri = n.Uri; } } m_areaNodeUri = areaUri; m_iterationNodeUri = iterationUri; m_hasRootNodes = true; } }
public NodeStructureEnricher(IMigrationEngine engine) { Engine = engine; _sourceCommonStructureService = (ICommonStructureService)Engine.Source.GetService <ICommonStructureService>(); _targetCommonStructureService = (ICommonStructureService)Engine.Target.GetService <ICommonStructureService4>(); _sourceProjectInfo = _sourceCommonStructureService.GetProjectFromName(Engine.Source.Config.Project); _sourceRootNodes = _sourceCommonStructureService.ListStructures(_sourceProjectInfo.Uri); }
/// <summary> /// Initializes a new instance of the <see cref="TeamProjects" /> class. /// </summary> /// <param name="tfsCollectionUri">The TFS collection URI.</param> /// <param name="tfsCredentials">The TFS credentials.</param> public TeamProjects(Uri tfsCollectionUri, ITfsCredentials tfsCredentials) { this._tfsCollectionUri = tfsCollectionUri; this._tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsCollectionUri, tfsCredentials); this._registration = (IRegistration)this._tfsTeamProjectCollection.GetService(typeof(IRegistration)); this._commonStructureService = this._tfsTeamProjectCollection.GetService <ICommonStructureService>(); }
public TfsBuildStatusPoll(IBuildServer buildServer, IDeployerFactory deployerFactory) { _buildServer = buildServer; _deployerFactory = deployerFactory; _webAccessLinks = _buildServer.TeamProjectCollection.GetService <TswaClientHyperlinkService>(); _structureService = _buildServer.TeamProjectCollection.GetService <ICommonStructureService>(); _timer = new Timer(state => PollBuildQualityChanges()); }
/// <summary> /// Initializes a new instance of the <see cref="TeamProjects" /> class. /// </summary> /// <param name="tfsCollectionUri">The TFS collection URI.</param> /// <param name="tfsCredentials">The TFS credentials.</param> public TeamProjects(Uri tfsCollectionUri, ITfsCredentials tfsCredentials) { this._tfsCollectionUri = tfsCollectionUri; this._tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsCollectionUri, tfsCredentials); this._registration = (IRegistration)this._tfsTeamProjectCollection.GetService(typeof(IRegistration)); this._commonStructureService = this._tfsTeamProjectCollection.GetService<ICommonStructureService>(); }
public NodeDetecomatic(WorkItemStore store) { _store = store; if (_commonStructure == null) { _commonStructure = (ICommonStructureService4)store.TeamProjectCollection.GetService(typeof(ICommonStructureService4)); } }
// http://blogs.microsoft.co.il/shair/2009/01/13/tfs-api-part-3-get-project-list-using-icommonstructureservice/ private static ProjectInfo[] GetDefaultProjectInfo(TfsTeamProjectCollection tfs) { // Create ICommonStructureService object that will take TFS Structure Service. ICommonStructureService structureService = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService)); // Use ListAllProjects method to get all Team Projects in the TFS. ProjectInfo[] projects = structureService.ListAllProjects(); return(projects); }
private void cboCollectionURL_SelectionChanged(object sender, SelectionChangedEventArgs e) { cboProject.Items.Clear(); cboBuildController.Items.Clear(); if (cboCollectionURL.SelectedItem != null) { ClientCollectionSource source = cboCollectionURL.SelectedItem as ClientCollectionSource; Uri collectionUri = null; TfsTeamProjectCollection collection = null; try { collectionUri = new Uri(source.Uri); collection = new TfsTeamProjectCollection(collectionUri); ICommonStructureService commonStructure = collection.GetService <ICommonStructureService>(); foreach (ProjectInfo project in commonStructure.ListProjects()) { cboProject.Items.Add(new ComboBoxItem() { Content = project.Name, DataContext = project.Name }); } } catch (Exception ex) { cboProject.Items.Clear(); cboBuildController.Items.Clear(); MessageBox.Show(ex.Message, string.Format("Error retrieving projects from {0}", collectionUri), MessageBoxButton.OK, MessageBoxImage.Error); return; } try { IBuildServer buildServer = collection.GetService <IBuildServer>(); foreach (IBuildController buildController in buildServer.QueryBuildControllers()) { cboBuildController.Items.Add(new ComboBoxItem() { Content = buildController.Name, DataContext = buildController.Name }); } } catch (Exception ex) { cboBuildController.Items.Clear(); MessageBox.Show(ex.Message, string.Format("Error retrieving build controllers from {0}", collectionUri), MessageBoxButton.OK, MessageBoxImage.Error); return; } } }
/// <summary> /// Creates path. /// </summary> /// <param name="type">Type of the node to be created</param> /// <param name="parentUri">Parent node</param> /// <param name="nodes">Node names</param> /// <param name="first">Index of the first node to create</param> /// <returns>Id of the node</returns> private int CreatePath( Node.TreeType type, string parentUri, string[] nodes, int first) { Debug.Assert(first < nodes.Length, "Nothing to create!"); // Step 1: create in CSS ICommonStructureService css = Css; for (int i = first; i < nodes.Length; i++) { string node = nodes[i]; if (!string.IsNullOrEmpty(node)) { try { parentUri = css.CreateNode(node, parentUri); } catch (CommonStructureSubsystemException cssEx) { if (cssEx.Message.Contains("TF200020")) { // TF200020 may be thrown if the tree node metadata has been propagated // from css to WIT cache. In this case, we will wait for the node id // Microsoft.TeamFoundation.Server.CommonStructureSubsystemException: // TF200020: The parent node already has a child node with the following name: {0}. // Child nodes must have unique names. Node existingNode = WaitForTreeNodeId(type, new string[] { node }); if (existingNode == null) { throw; } else { parentUri = existingNode.Uri.AbsoluteUri; } } } } } // Step 2: locate in the cache // Syncing nodes into WIT database is an asynchronous process, and there's no way to tell // the exact moment. Node newNode = WaitForTreeNodeId(type, nodes); if (newNode == null) { return(-1); } else { return(newNode.Id); } }
/// <summary> /// This method is called when the plug-in is loaded for the fist /// time. /// </summary> /// <param name="ds">An IDataStore instance.</param> public void Initialize(IDataStore ds) { m_dataStore = ds; var tfs = TeamFoundationServerFactory.GetServer( TeamFoundationApplication.TfsNameUrl); m_commonStructureService = (ICommonStructureService) tfs.GetService(typeof(ICommonStructureService)); }
public CSSAdapter(ICommonStructureService css, Guid migrationSourceId) { if (css == null) { throw new ArgumentNullException("css"); } CSS = css; SourceId = migrationSourceId; }
/// <summary> /// Create the CSS path (Area Path or Iteration Path) /// </summary> /// <param name="css">Handle to ICommonStructureService</param> /// <param name="cssPath">Path to be created</param> /// <param name="defaultUri">URI for the root node</param> private static void CreateCSSPath(ICommonStructureService css, string cssPath, string defaultUri) { string[] cssPathFragments = cssPath.Split('\\'); int pathLength = 0; string tempPath = String.Empty; NodeInfo rootNode = css.GetNode(defaultUri); NodeInfo parentNode = rootNode; // parent is root for now Logger.Write(LogSource.WorkItemTracking, TraceLevel.Verbose, "Creating CSS path [{0}]", cssPath); // for each fraction of path, see if it exists for (pathLength = 0; pathLength < cssPathFragments.Length; pathLength++) { tempPath = String.Concat(parentNode.Path, "\\", cssPathFragments[pathLength]); NodeInfo childNode = null; try { if (NodeInfoCache.ContainsKey(tempPath)) { childNode = NodeInfoCache[tempPath]; } else { childNode = css.GetNodeFromPath(tempPath); NodeInfoCache.Add(tempPath, childNode); } } catch (SoapException) { // node does not exist.. ignore the exception } catch (ArgumentException) { // node does not exist.. ignore the exception } if (childNode == null) { // given node does not exist.. create it for (int restCSSPath = pathLength; restCSSPath < cssPathFragments.Length; restCSSPath++) { string nodeUri = css.CreateNode(cssPathFragments[restCSSPath], parentNode.Uri); // once a node is created, all the subsequent nodes can be created without any lookup // set the parent node parentNode = css.GetNode(nodeUri); } break; // out of for loop } else { // set the parent node to current node parentNode = childNode; } } }
private static bool DoesNodeExistInPath(ICommonStructureService commonStructureService, string newPath) { bool result = false; NodeInfo retVal = commonStructureService.GetNodeFromPath(newPath); if (retVal != null) { result = true; } return result; }
private static bool DoesNodeExistInPath(ICommonStructureService commonStructureService, string newPath) { bool result = false; NodeInfo retVal = commonStructureService.GetNodeFromPath(newPath); if (retVal != null) { result = true; } return(result); }
/// <summary> /// Connects the specified tfsServer name. /// </summary> /// <returns></returns> public static bool Connect(LoginInfo info) { Disconnect(); bool loginByLoggedUser = info.UserName == null; UIContext.Instance.LogMessage(new IconListEntry { Icon = UIContext.Instance.GetLogImage(LogImage.Info), Text = string.Format("Connecting to server '{0}' using '{1}'...", info.ServerName, loginByLoggedUser ? "current windows logged user credentials" : string.Format("credentials with user name '{0}' and domain: '{1}'", info.UserName, info.Domain)) }); loginInfo = info; bool result = TFSUtils.TestConnection(info); if (result) { tfsServer = TFSUtils.LastConnectedServer; result = (tfsServer != null); if (result) { eventService = (IEventService)tfsServer.GetService(typeof(IEventService)); cSSproxy = (ICommonStructureService)tfsServer.GetService(typeof(ICommonStructureService)); itemStore = (WorkItemStore)tfsServer.GetService(typeof(WorkItemStore)); securityService = (IGroupSecurityService)tfsServer.GetService(typeof(IGroupSecurityService)); buildServer = (IBuildServer)tfsServer.GetService(typeof(IBuildServer)); controlServer = (VersionControlServer)tfsServer.GetService(typeof(VersionControlServer)); } } isConnected = result; if (result) { UIContext.Instance.LogMessage(new IconListEntry { Icon = UIContext.Instance.GetLogImage(LogImage.Info), Text = string.Format("Connected successfully as: {0} ({1})", Context.LoggedDisplayUser, Context.LoggedUser) }); } UIContext.Instance.LogMessage(new IconListEntry { Icon = UIContext.Instance.GetLogImage(result ? LogImage.Info : LogImage.Error), Text = string.Format("Connecting to server '{0}' {1}", info.ServerName, result ? "was successfull" : "failed") }); return(result); }
private void button1_Click(object sender, EventArgs e) { TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.MultiProject, false); if (tpp.ShowDialog() == System.Windows.Forms.DialogResult.OK) { tpc = tpp.SelectedTeamProjectCollection; projects = tpp.SelectedProjects; toolStripStatusLabel1.Text = string.Format("Connected to: [{0}]", tpc.Uri.ToString()); } css = tpc.GetService<ICommonStructureService>(); FillProjects(); }
public CommonStructure(BaseUpdateOptions options) { // Read config options Collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(options.TeamCollection)); BuildServer = Collection.GetService<IBuildServer>(); CommonStructureService = Collection.GetService<ICommonStructureService>(); string standardTemplateName = GetConfigValueAsString(SettingsKeys.StandardTemplateName, Constants.DefaultStandardTemplateName); string servicesTemplateName = GetConfigValueAsString(SettingsKeys.ServicesTemplate, Constants.DefaultServicesTemplateName); string noCompileFullTemplateName = GetConfigValueAsString(SettingsKeys.NoCompileFullTemplate, Constants.DefaultNoCompileFullTemplateName); StandardTemplatePath = String.Format("$/{0}/BuildProcessTemplates/{1}", options.TemplatesTeamProject, standardTemplateName); ServicesTemplatePath = String.Format("$/{0}/BuildProcessTemplates/{1}", options.TemplatesTeamProject, servicesTemplateName); NoCompileFullTemplatePath = String.Format("$/{0}/BuildProcessTemplates/{1}", options.TemplatesTeamProject, noCompileFullTemplateName); StandardTemplate = CheckCreate(options.TemplatesTeamProject, StandardTemplatePath); if (StandardTemplate == null) Console.WriteLine("Standard template not found in '{0}' of '{1}'", StandardTemplatePath, options.TeamCollection); ServicesTemplate = CheckCreate(options.TemplatesTeamProject, ServicesTemplatePath); if (ServicesTemplate == null) Console.WriteLine("Services template not found in '{0}' of '{1}'", ServicesTemplatePath, options.TeamCollection); NoCompileFullTemplate = CheckCreate(options.TemplatesTeamProject, NoCompileFullTemplatePath); if (NoCompileFullTemplate == null) Console.WriteLine("No-compile template not found in '{0}' of '{1}'", NoCompileFullTemplatePath, options.TeamCollection); DeploymentPackagesLocation = GetConfigValueAsString(SettingsKeys.PackagesDropLocation, Constants.DefaultPackagesDropLocation); }
private void GenerateSubAreas(XmlNode tree, string nodePath, ICommonStructureService css) { var path = css.GetNodeFromPath(nodePath); int nodeCount = tree.FirstChild.ChildNodes.Count; for (int i = 0; i < nodeCount; i++) { XmlNode node = tree.ChildNodes[0].ChildNodes[i]; try { css.CreateNode(node.Attributes["Name"].Value, path.Uri); } catch (Exception ex) { //node already exists continue; } if (node.FirstChild != null) { string newPath = nodePath + "\\" + node.Attributes["Name"].Value; GenerateSubAreas(node, newPath, css); } } }
/// <summary> /// Opens the Common TFS Project Selection Form. /// </summary> /// <returns></returns> public static ITestManagementTeamProject SelectTfsProject(bool isDestinationProject) { TeamProjectPicker teamProjectPicker = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); DialogResult result = teamProjectPicker.ShowDialog(); if (result == DialogResult.OK && teamProjectPicker.SelectedTeamProjectCollection != null) { if (isDestinationProject && teamProjectPicker.SelectedTeamProjectCollection != null) { TfsTeamProjectCollection destinationTeamProjectCollection = teamProjectPicker.SelectedTeamProjectCollection; destinationTeamProjectCollection.Connect(ConnectOptions.IncludeServices); _destinationStructureService = destinationTeamProjectCollection.GetService(typeof(ICommonStructureService)) as ICommonStructureService; } TfsTeamProjectCollection teamProjectCollection = teamProjectPicker.SelectedTeamProjectCollection; ITestManagementService testManagementService = (ITestManagementService)teamProjectCollection.GetService(typeof(ITestManagementService)); ITestManagementTeamProject project = testManagementService.GetTeamProject(teamProjectPicker.SelectedProjects[0].Name); return project; } return null; }
private static NodeInfo GetPreviousPath(ICommonStructureService commonStructureService, string pathRoot) { NodeInfo result = null; try { result = commonStructureService.GetNodeFromPath(pathRoot); } catch (Exception ex) { if (!ExceptionMeansThatPathDoesNotExists(ex)) { throw; } } return result; }