private void ProcessCommonStructure(string treeTypeSource, string treeTypeTarget) { NodeInfo sourceNode = (from n in _sourceRootNodes where n.Path.Contains(treeTypeSource) select n).Single(); if (sourceNode == null) // May run into language problems!!! This is to try and detect that { Exception ex = new Exception(string.Format("Unable to load Common Structure for Source. This is usually due to diferent language versions. Validate that '{0}' is the correct name in your version. ", treeTypeSource)); Log.Error(ex, "Unable to load Common Structure for Source."); throw ex; } XmlElement sourceTree = _sourceCommonStructureService.GetNodesXml(new string[] { sourceNode.Uri }, true); NodeInfo structureParent; try // May run into language problems!!! This is to try and detect that { structureParent = _targetCommonStructureService.GetNodeFromPath(string.Format("\\{0}\\{1}", Engine.Target.Config.Project, treeTypeTarget)); } catch (Exception ex) { Exception ex2 = new Exception(string.Format("Unable to load Common Structure for Target.This is usually due to diferent language versions. Validate that '{0}' is the correct name in your version. ", treeTypeTarget), ex); Log.Error(ex2, "Unable to load Common Structure for Target."); throw ex2; } if (_prefixProjectToNodes) { structureParent = CreateNode(Engine.Source.Config.Project, structureParent); } if (sourceTree.ChildNodes[0].HasChildNodes) { CreateNodes(sourceTree.ChildNodes[0].ChildNodes[0].ChildNodes, structureParent, treeTypeTarget); } }
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); }
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); } }
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 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 bool TargetNodeExists(string nodePath) { if (!_foundNodes.ContainsKey(nodePath)) { NodeInfo node = null; try { node = _targetCommonStructureService.GetNodeFromPath(nodePath); _foundNodes.Add(nodePath, true); } catch { _foundNodes.Add(nodePath, false); } } return(_foundNodes[nodePath]); }
/// <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); }
private static string CreateAndCollectInfoForDestinationAreaAndIterations(ITestManagementTeamProject destinationTestProject, Project sourceWitProject) { if (_destinationStructureService == null) { return("******** Couldn't connect to the Destination Structure Service, cannot create Areas or Iterations" + Environment.NewLine); } string rootAreaNodePath = string.Format("\\{0}\\Area", destinationTestProject.TeamProjectName); NodeInfo areaPathRootInfo = _destinationStructureService.GetNodeFromPath(rootAreaNodePath); _destinationAreaNodes.Clear(); RecurseAreas(sourceWitProject.AreaRootNodes, areaPathRootInfo, destinationTestProject.WitProject.AreaRootNodes, destinationTestProject.WitProject); string rootIterationNodePath = string.Format("\\{0}\\Iteration", destinationTestProject.TeamProjectName); NodeInfo iterationPathRootInfo = _destinationStructureService.GetNodeFromPath(rootIterationNodePath); _destinationIterationNodes.Clear(); RecurseIterations(sourceWitProject.IterationRootNodes, iterationPathRootInfo, destinationTestProject.WitProject.IterationRootNodes, destinationTestProject.WitProject); return(string.Empty); }
private void ProcessCommonStructure(string treeType, NodeInfo[] sourceNodes, ICommonStructureService targetCss, ICommonStructureService sourceCss) { NodeInfo sourceNode = (from n in sourceNodes where n.Path.Contains(treeType) select n).Single(); 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); } }
public bool NodeExists(string nodePath) { if (!_foundNodes.Contains(nodePath)) { NodeInfo node = null; try { node = _commonStructure.GetNodeFromPath(nodePath); } catch { return(false); } _foundNodes.Add(nodePath); } return(true); }
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); }
public void GenerateAreas(XmlNode tree, string sourceProjectName) { ICommonStructureService css = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService)); // get project info ProjectInfo projectInfo = css.GetProjectFromName(projectName); NodeInfo[] nodes = css.ListStructures(projectInfo.Uri); // find ProjectModelHierarchy (contains path for area node) var node = nodes.FirstOrDefault(n => n.StructureType == "ProjectModelHierarchy"); if (node == null) { return; } var pathRoot = css.GetNodeFromPath(node.Path); 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) { //node already exists continue; } if (Node.FirstChild != null) { string nodePath = node.Path + "\\" + Node.Attributes["Name"].Value; GenerateSubAreas(Node, nodePath, css); } } } RefreshCache(); }
private NodeInfo CreateNode(ICommonStructureService css, string name, NodeInfo parent) { string nodePath = string.Format(@"{0}\{1}", parent.Path, name); NodeInfo node = null; Trace.Write(string.Format("--CreateNode: {0}", nodePath)); 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); } return(node); }
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); } } }
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; }