internal XmlDocument GetTeamProjectSpecificCSSNodeChanges(Project teamProject, int startSeqId, out int maxSeqId) { bool fMore; List <XmlNode> changedNodes = new List <XmlNode>(); using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { var migrationSource = context.RTMigrationSourceSet.Where(s => s.UniqueId.Equals(SourceId)).FirstOrDefault(); Debug.Assert(null != migrationSource); do { fMore = false; string xmlStr = CSS.GetChangedNodes(startSeqId); XmlDocument changeDoc = new XmlDocument(); changeDoc.LoadXml(xmlStr); startSeqId = Convert.ToInt32(GetAttributeString(changeDoc.DocumentElement, "MaxSequence" /*$N18N$*/, true, "-1"), CultureInfo.InvariantCulture); fMore = string.Equals("1", GetAttributeString(changeDoc.DocumentElement, "fMore" /*$N18N$*/, true, "0"), StringComparison.OrdinalIgnoreCase); XmlNodeList nodesUnderProject = changeDoc.DocumentElement.SelectNodes( string.Format("/StructureChanges/StructureElements/StructureElement[@ProjectId='{0}']", teamProject.Uri.AbsoluteUri)); foreach (XmlNode node in nodesUnderProject) { changedNodes.Add(node); XmlElement changedNodeElem = node as XmlElement; if (null != changedNodeElem) { bool deleted = IsStructureElementDeleted(changedNodeElem); string nodeUri = GetStructureElementId(changedNodeElem); var nodeCache = QueryCachedCSSNode(context, nodeUri); if (!deleted) { NodeInfo nodeInfo = CSS.GetNode(nodeUri); SetStructureElementPath(changedNodeElem, nodeInfo.Path); if (nodeCache == null) { nodeCache = CreateCachedCSSNode(migrationSource, nodeUri, nodeInfo.Path); } else { SetStructureElementRenameFromPath(changedNodeElem, nodeCache.ItemData); nodeCache.ItemData = nodeInfo.Path; } } else { if (nodeCache != null && !string.IsNullOrEmpty(nodeCache.ItemData)) { SetStructureElementPath(changedNodeElem, nodeCache.ItemData); } string forwardingId = GetStructureElementForwardingId(changedNodeElem); try { if (!string.IsNullOrEmpty(forwardingId)) { var forwardingNodeInfo = CSS.GetNode(forwardingId); SetStructureElementForwardingNodePath(changedNodeElem, forwardingNodeInfo.Path); } } catch { } } } } } while (fMore); context.TrySaveChanges(); } maxSeqId = startSeqId; if (changedNodes.Count == 0) { return(null); } else { XmlDocument doc = new XmlDocument(); var structureChangesNode = doc.CreateElement("StructureChanges"); var structureElementsNode = doc.CreateElement("StructureElements"); structureChangesNode.AppendChild(structureElementsNode); doc.AppendChild(structureChangesNode); foreach (XmlNode elementNode in changedNodes) { structureElementsNode.AppendChild(doc.ImportNode(elementNode, true)); } return(doc); } }