private void OnUploadProgressCompleted(object sender, EventArgs e) { var fileUploader = sender as LargeFileUpload; if (fileUploader != null) { FileUploaders.Remove(fileUploader); fileUploader.FileStream.Close(); fileUploader.FileStream.Dispose(); } var metadata = new Dictionary <string, string> { { "Name", DroppedFile.Name }, { "Link", string.Format("{0}/{1}/{2}", App.Params.SiteUrl, App.Params.FileUploadLibrary, DroppedFile.Name) } }; IoCContainer.GetInjectionInstance().GetInstance <ISuperGraphNodeFactory>().AddNote(_location, metadata); if (ProgressCompleted != null) { ProgressCompleted(sender, new FileProcessorCompletedEventArgs { NeedRefresh = false }); } }
public CompendiumTransclusionRelationship() { _descriptors = new List <IDescriptor>(); _notes = new List <string>(); _attachments = new List <string>(); RelationshipType = IoCContainer.GetInjectionInstance().GetInstance <CompendiumNodeRelationshipBaseType>(); }
private void MouseManagerOnRightButtonDragReleased(object sender, MouseManagerEventArgs e) { if (IoCContainer.GetInjectionInstance().GetInstance <ArrowCreationManager>().InMotion) { IoCContainer.GetInjectionInstance().GetInstance <ArrowCreationManager>().SetTo(NodeControl); } }
public MainPage() { DebugLogger.Instance.LogMsg("Initialising Glyma... Url: " + HtmlPage.Document.DocumentUri); InitializeComponent(); SetupNetworkChange(); //logs if the network is going up/down Sidebar.Handler = SuperGraph; ZommingControl.Handler = SuperGraph; Breadcrumbs.Handler = SuperGraph; SuperGraph.Ref = this; if (!App.IsDesignTime) { Loader.Visibility = Visibility.Visible; Breadcrumbs.BreadcrumbChanged += OnBreadcrumbChanged; Breadcrumbs.BreadcrumbClicked += OnBreadcrumbClicked; SuperGraph.DataContext = new SuperGraphProperties { NodeTextWidth = GlymaParameters.NodeTextWidth, NodeImageWidth = GlymaParameters.NodeImageWidth, NodeImageHeight = GlymaParameters.NodeImageHeight }; SoapEndPointFactory soapEndPointFactory = new SoapEndPointFactory(new Uri(App.Params.TransactionalMappingToolSvcUrl)); var soapMapManager = new SoapProxy.SoapMapManager(soapEndPointFactory); _mapManager = soapMapManager; _mapManager.InitialiseMapManagerCompleted += OnInitialiseMapManagerCompleted; _mapManager.MapManagerActivityStatusUpdated += OnMapManagerActivityStatusUpdated; IoCContainer.GetInjectionInstance().RegisterComponent <Proxy.IMapManager, SoapProxy.SoapMapManager>(soapMapManager); var binding = new System.ServiceModel.BasicHttpBinding(); binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly; binding.MaxReceivedMessageSize = 2147483647; var utilityServiceAddress = new System.ServiceModel.EndpointAddress(new Uri(App.Params.GlymaUtilitySvcUrl)); var utilityManagerServiceClient = new UtilityProxy.Service.UtilityServiceManagerClient(binding, utilityServiceAddress); var exportServiceManager = new UtilityProxy.ExportServiceManager(utilityManagerServiceClient); IoCContainer.GetInjectionInstance().RegisterComponent <UtilityProxy.IExportServiceManager, UtilityProxy.ExportServiceManager>(exportServiceManager); exportServiceManager.IsExportingAvailableCompleted.RegisterEvent(IsExportingAvailableCompleted); _themeManager = new ThemeManager(); SuperGraph.NodeClicked += NodeClicked; SuperGraph.FilesDropped += FilesDropped; var jsBridge = new JavaScriptBridge(SuperGraph); HtmlPage.RegisterScriptableObject("glymaMapCanvas", jsBridge); exportServiceManager.IsExportingAvailableAsync(); } }
public void OnLeftButtonDragMove(object sender, MouseEventArgs e) { if (IoCContainer.GetInjectionInstance().GetInstance <ArrowCreationManager>().InMotion) { MouseManagingControl.ReleaseMouseCapture(); var args = new MouseManagerEventArgs { Start = new MouseStateProperties { EventOrigin = sender, PositionInformation = e }, End = new MouseStateProperties { EventOrigin = sender, PositionInformation = e } }; MotionHandler.OnLeftButtonDragReleased(sender, args); return; } MotionHandler.OnLeftButtonDragMove(sender, e); }
public void ConsumeWebServiceNode(WebSvcNs.Node node) { if (NodeType != null && NodeType.Id != Guid.Empty) { switch (NodeType.Id.ToString()) { case ConNode.ConNodeTypeId: NodeType = IoCContainer.GetInjectionInstance().GetInstance <ConNode>(); break; case DecisionNode.DecisionNodeTypeId: NodeType = IoCContainer.GetInjectionInstance().GetInstance <DecisionNode>(); break; case IdeaNode.IdeaNodeTypeId: NodeType = IoCContainer.GetInjectionInstance().GetInstance <IdeaNode>(); break; case MapNode.MapNodeTypeId: NodeType = IoCContainer.GetInjectionInstance().GetInstance <MapNode>(); break; case ProNode.ProNodeTypeId: NodeType = IoCContainer.GetInjectionInstance().GetInstance <ProNode>(); break; case QuestionNode.QuestionNodeTypeId: NodeType = IoCContainer.GetInjectionInstance().GetInstance <QuestionNode>(); break; default: break; } Id = node.Id; Name = (string)GetObjectData <string>(node.Data, "Name"); CreatedBy = (string)GetObjectData <string>(node.Data, "CreatedBy"); LastModifiedBy = (string)GetObjectData <string>(node.Data, "LastModifiedBy"); Created = (DateTime)GetObjectData <DateTime>(node.Data, "Created"); LastModified = (DateTime)GetObjectData <DateTime>(node.Data, "LastModified"); } }
public void OnLeftButtonDragStart(object sender, MouseManagerEventArgs e) { if (IoCContainer.GetInjectionInstance().GetInstance <ArrowCreationManager>().InMotion) { return; } MouseManagingControl.CaptureMouse(); //SuperCursor.SetCursorTemplate(MouseManagingControl, ((DataTemplate)(Application.Current.Resources["Move"]))); if (!_selector.HasNode(UserControl)) { _selector.Clear(); _selector.AddNode(UserControl); } var nodeToLoop = _selector.NodeControls.ToList(); foreach (var nodeControl in nodeToLoop) { if (nodeControl.CollapseState == CollapseState.Collapsed) { foreach (var child in nodeControl.GetAllChildNodeControls()) { _selector.AddNode(child); } } else if (nodeControl.CollapseState == CollapseState.SemiCollapsed) { var invisivleChildNodes = nodeControl.GetAllChildNodeControls().Where(q => q.IsCollapsed); foreach (var child in invisivleChildNodes) { _selector.AddNode(child); } } } MotionHandler.OnLeftButtonDragStart(sender, e); }
public void ConsumeNodeXml(XmlReader xml, string domainNodeId, string documentLibraryUrl) { if (xml != null && xml.NodeType == XmlNodeType.Element && xml.Name == "node") { #region Attribute Values #region Id if (xml.MoveToAttribute("id")) { Id = xml.Value; } #endregion #region NodeType if (Id == domainNodeId) { _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["DomainNode"]; } else { if (xml.MoveToAttribute("type")) { switch (xml.Value) { case CON_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumConNode"]; break; case DECISION_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumDecisionNode"]; break; case IDEA_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumIdeaNode"]; break; case MAP_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumMapNode"]; break; case PRO_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumProNode"]; break; case QUESTION_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumQuestionNode"]; break; case REFERENCE_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumReferenceNode"]; break; case ARGUMENT_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumArgumentNode"]; break; case NOTE_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumNoteNode"]; break; case LIST_NODE_TYPE_ID: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumListNode"]; break; default: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <TransactionalNodeService.Proxy.IMapManager>().NodeTypes["CompendiumNoteNode"]; break; } } } #endregion #region CreatedBy if (xml.MoveToAttribute("author")) { CreatedBy = xml.Value; } #endregion #region Created if (xml.MoveToAttribute("created")) { string createdMillisecondsXmlValue = xml.Value; long createdMilliseconds; if (long.TryParse(createdMillisecondsXmlValue, out createdMilliseconds)) { Created = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Created = Created.AddMilliseconds(createdMilliseconds); } } #endregion #region LastModified if (xml.MoveToAttribute("lastModified")) { string lastModifiedMillisecondsXmlValue = xml.Value; long lastModifiedMilliseconds; if (long.TryParse(lastModifiedMillisecondsXmlValue, out lastModifiedMilliseconds)) { LastModified = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); LastModified = LastModified.AddMilliseconds(lastModifiedMilliseconds); } } #endregion #region Name if (xml.MoveToAttribute("label")) { Name = xml.Value; } #endregion #region LastModifiedBy if (xml.MoveToAttribute("lastModificationAuthor")) { LastModifiedBy = xml.Value; } #endregion #endregion while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element) { if (xml.Name.ToLower() == "details") { } if (_nodeType.Name == "CompendiumReferenceNode") { if (xml.Name.ToLower() == "source") { string fullFilePath = xml.ReadInnerXml(); if (!string.IsNullOrEmpty(fullFilePath)) { if (fullFilePath.ToLower().StartsWith("http://") || fullFilePath.ToLower().StartsWith("https://") || fullFilePath.ToLower().StartsWith("ftp://") || fullFilePath.ToLower().StartsWith("ftps://")) { Attachment = fullFilePath; } else { string linkedFileName = string.Empty; if (fullFilePath.LastIndexOf("/") < 0 && fullFilePath.LastIndexOf("\\") > 0) { linkedFileName = fullFilePath.Substring(fullFilePath.LastIndexOf("\\") + 1); } else { linkedFileName = fullFilePath.Substring(fullFilePath.LastIndexOf("/") + 1); } Attachment = documentLibraryUrl + linkedFileName; //set the file name, the node name is can change independently } } } } } else if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "node") { break; } } } }
public CompendiumTransclusionRelationship(IRelationship relationship, CompendiumViewRelationship viewRelationship, INode toNode, INode fromNode, INode transclusionNode, INode mapNode) : this() { _toNode = toNode; IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumToDescriptor>()); _descriptors.Add(toDescriptor); _toNode.AddDescriptor(toDescriptor); _fromNode = fromNode; IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>()); _descriptors.Add(fromDescriptor); _fromNode.AddDescriptor(fromDescriptor); _transclusionNode = transclusionNode; IDescriptor transclusionNodeDescriptor = new CompendiumRelationshipDescriptor(transclusionNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumTransclusionNodeDescriptor>()); _descriptors.Add(transclusionNodeDescriptor); _transclusionNode.AddDescriptor(transclusionNodeDescriptor); _mapNode = mapNode; IDescriptor mapDescriptor = new CompendiumRelationshipDescriptor(mapNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumTransclusionMapDescriptor>()); _descriptors.Add(mapDescriptor); _mapNode.AddDescriptor(mapDescriptor); this.Id = relationship.Id; this.Created = relationship.Created; this.CreatedBy = relationship.CreatedBy; this.LastModified = relationship.LastModified; this.Name = relationship.Name; this.XPosition = viewRelationship.XPosition; this.YPosition = viewRelationship.YPosition; }
public void ConsumeLinkXml(Dictionary <string, INode> nodeList, XmlReader xml) { if (xml != null && xml.NodeType == XmlNodeType.Element && xml.Name == "link") { #region Attribute Values #region Id if (xml.MoveToAttribute("id")) { Id = xml.Value; } #endregion #region NodeType - Not Currently Used /* * if (xml.MoveToAttribute("type")) * { * switch (xml.Value) * { * case ConNodeTypeId: * _nodeType = IoCContainer.GetInjectionInstance().GetInstance<ConNode>(); * break; * * case DecisionNodeTypeId: * _nodeType = IoCContainer.GetInjectionInstance().GetInstance<DecisionNode>(); * break; * * case IdeaNodeTypeId: * _nodeType = IoCContainer.GetInjectionInstance().GetInstance<IdeaNode>(); * break; * * case MapNodeTypeId: * _nodeType = IoCContainer.GetInjectionInstance().GetInstance<MapNode>(); * break; * * case ProNodeTypeId: * _nodeType = IoCContainer.GetInjectionInstance().GetInstance<ProNode>(); * break; * * case QuestionNodeTypeId: * _nodeType = IoCContainer.GetInjectionInstance().GetInstance<QuestionNode>(); * break; * * default: * break; * } * } */ #endregion #region CreatedBy if (xml.MoveToAttribute("author")) { CreatedBy = xml.Value; } #endregion #region Created if (xml.MoveToAttribute("created")) { string createdMillisecondsXmlValue = xml.Value; long createdMilliseconds; if (long.TryParse(createdMillisecondsXmlValue, out createdMilliseconds)) { Created = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Created = Created.AddMilliseconds(createdMilliseconds); } } #endregion #region LastModified if (xml.MoveToAttribute("lastModified")) { string lastModifiedMillisecondsXmlValue = xml.Value; long lastModifiedMilliseconds; if (long.TryParse(lastModifiedMillisecondsXmlValue, out lastModifiedMilliseconds)) { LastModified = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); LastModified = LastModified.AddMilliseconds(lastModifiedMilliseconds); } } #endregion #region Name if (xml.MoveToAttribute("label")) { Name = xml.Value; } #endregion #region LastModifiedBy - Not Currently Used /* * if (xml.MoveToAttribute("lastModificationAuthor")) * { * LastModifiedBy = xml.Value; * } */ #endregion #endregion if (xml.MoveToAttribute("from")) { string from = xml.Value; INode fromNode = nodeList[from]; IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>()); _descriptors.Add(fromDescriptor); fromNode.AddDescriptor(fromDescriptor); } if (xml.MoveToAttribute("to")) { string to = xml.Value; INode toNode = nodeList[to]; IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>()); _descriptors.Add(toDescriptor); toNode.AddDescriptor(toDescriptor); } while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element) { } else if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "link") { break; } } } }
public static void CreateMapRelationship(INode mapNode, INode childNode) { if (childNode != null && mapNode != null) { foreach (IDescriptor descriptor in childNode.Descriptors) { if (descriptor.Relationship is CompendiumMapRelationship) { foreach (IDescriptor altDesc in descriptor.Relationship.Descriptors) { if (altDesc.DescriptorType is CompendiumToDescriptor) { if (altDesc.Node.Id == mapNode.Id) { return; } } } } } CompendiumMapRelationship mapRelationship = new CompendiumMapRelationship(); mapRelationship.Id = mapNode.Id + childNode.Id; IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(mapNode, mapRelationship, IoCContainer.GetInjectionInstance().GetInstance <CompendiumToDescriptor>()); IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(childNode, mapRelationship, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>()); mapRelationship.Descriptors = new IDescriptor[] { fromDescriptor, toDescriptor }; childNode.AddDescriptor(fromDescriptor); mapNode.AddDescriptor(toDescriptor); } }
public void ConsumeNodeXml(XmlReader xml) { if (xml != null && xml.NodeType == XmlNodeType.Element && xml.Name == "node") { #region Attribute Values #region Id if (xml.MoveToAttribute("id")) { Id = xml.Value; } #endregion #region NodeType if (xml.MoveToAttribute("type")) { switch (xml.Value) { case ConNodeTypeId: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <ConNode>(); break; case DecisionNodeTypeId: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <DecisionNode>(); break; case IdeaNodeTypeId: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <IdeaNode>(); break; case MapNodeTypeId: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <MapNode>(); break; case ProNodeTypeId: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <ProNode>(); break; case QuestionNodeTypeId: _nodeType = IoCContainer.GetInjectionInstance().GetInstance <QuestionNode>(); break; default: break; } } #endregion #region CreatedBy if (xml.MoveToAttribute("author")) { CreatedBy = xml.Value; } #endregion #region Created if (xml.MoveToAttribute("created")) { string createdMillisecondsXmlValue = xml.Value; long createdMilliseconds; if (long.TryParse(createdMillisecondsXmlValue, out createdMilliseconds)) { Created = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Created = Created.AddMilliseconds(createdMilliseconds); } } #endregion #region LastModified if (xml.MoveToAttribute("lastModified")) { string lastModifiedMillisecondsXmlValue = xml.Value; long lastModifiedMilliseconds; if (long.TryParse(lastModifiedMillisecondsXmlValue, out lastModifiedMilliseconds)) { LastModified = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); LastModified = LastModified.AddMilliseconds(lastModifiedMilliseconds); } } #endregion #region Name if (xml.MoveToAttribute("label")) { Name = xml.Value; } #endregion #region LastModifiedBy if (xml.MoveToAttribute("lastModificationAuthor")) { LastModifiedBy = xml.Value; } #endregion #endregion while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element) { } else if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "node") { break; } } } }
public void BuildRelationships(Dictionary <string, INode> nodeList) { bool nodeListContainsFrom = nodeList.ContainsKey(_from); bool nodeListContainsTo = nodeList.ContainsKey(_to); INode fromNode = null; INode toNode = null; if (nodeListContainsFrom && nodeListContainsTo) { fromNode = nodeList[_from]; _fromNode = fromNode; IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>()); _descriptors.Add(fromDescriptor); fromNode.AddDescriptor(fromDescriptor); toNode = nodeList[_to]; _toNode = toNode; IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumToDescriptor>()); _descriptors.Add(toDescriptor); toNode.AddDescriptor(toDescriptor); } }
public bool Load(XmlReader xml, string documentLibraryUrl) { _xml = xml; List <CompendiumViewRelationship> viewRelationships = new List <CompendiumViewRelationship>(); bool isDomainNodeRootMapNode = false; if (_xml != null && _xml.NodeType == XmlNodeType.Element && _xml.Name == COMPENDIUM_DOCUMENT_TAG) { _xml.MoveToAttribute("rootview"); string domainNodeId = _xml.Value; while (_xml.Read()) { if (_xml.NodeType == XmlNodeType.Element) { switch (_xml.Name) { case VIEW_RELATIONSHIP_TAG: CompendiumViewRelationship viewRelationship = new CompendiumViewRelationship(); viewRelationship.ConsumeViewXml(_xml, domainNodeId); viewRelationships.Add(viewRelationship); break; case NODE_DETAILS_TAG: XmlCompendiumNode node = new XmlCompendiumNode(_xml, domainNodeId, documentLibraryUrl); _nodes.Add(node.Id, node); break; case LINK_RELATIONSHIP_TAG: CompendiumLinkRelationship nodeRelationship = new CompendiumLinkRelationship(); if (nodeRelationship.ConsumeLinkXml(_nodes, _xml, domainNodeId)) { isDomainNodeRootMapNode = true; } break; default: break; } } else if (_xml.NodeType == XmlNodeType.EndElement) { if (_xml.Name == COMPENDIUM_DOCUMENT_TAG) { break; } } } if (isDomainNodeRootMapNode) { _nodes[domainNodeId].NodeType = IoCContainer.GetInjectionInstance().GetInstance <IMapManager>().NodeTypes["CompendiumMapNode"]; } } foreach (CompendiumViewRelationship viewRelationship in viewRelationships) { viewRelationship.BuildRelationships(_nodes); if (!_rootViewRelationships.Contains(viewRelationship) && viewRelationship.IsRootView) { _rootViewRelationships.Add(viewRelationship); } } List <string> transcludedNodes = new List <string>(); List <string> nonTranscludedNodes = new List <string>(); foreach (CompendiumViewRelationship viewRelationship in viewRelationships) { if (nonTranscludedNodes.Contains(viewRelationship.FromNode.Id)) { /// If this node is in the non-transcluded nodes list then it means it IS a transclusion and needs to be moved out of the transcluded nodes list. transcludedNodes.Add(viewRelationship.FromNode.Id); nonTranscludedNodes.Remove(viewRelationship.FromNode.Id); /// We need to notify all the link relationships for this node that they are part of a transclusion so their "Map" property means something. foreach (IDescriptor descriptor in viewRelationship.FromNode.Descriptors) { if (descriptor.Relationship is CompendiumLinkRelationship) { CompendiumLinkRelationship linkRelationship = descriptor.Relationship as CompendiumLinkRelationship; linkRelationship.ConvertToTransclusionRelationship(_nodes); } } } else if (!transcludedNodes.Contains(viewRelationship.FromNode.Id)) { /// If this ID isn't in the non-transcluded nodes list and it's not in the transcluded nodes list, then it means we haven't added yet. nonTranscludedNodes.Add(viewRelationship.FromNode.Id); } } return(isDomainNodeRootMapNode); }
public bool Load(XmlReader xml, string documentLibraryUrl) { _xml = xml; List <CompendiumViewRelationship> viewRelationships = new List <CompendiumViewRelationship>(); bool isDomainNodeRootMapNode = false; if (_xml != null && _xml.NodeType == XmlNodeType.Element && _xml.Name == COMPENDIUM_DOCUMENT_TAG) { _xml.MoveToAttribute("rootview"); string domainNodeId = _xml.Value; while (_xml.Read()) { if (_xml.NodeType == XmlNodeType.Element) { switch (_xml.Name) { case VIEW_RELATIONSHIP_TAG: CompendiumViewRelationship viewRelationship = new CompendiumViewRelationship(); viewRelationship.ConsumeViewXml(_xml, domainNodeId); viewRelationships.Add(viewRelationship); break; case NODE_DETAILS_TAG: XmlCompendiumNode node = new XmlCompendiumNode(_xml, domainNodeId, documentLibraryUrl); _nodes.Add(node.Id, node); break; case LINK_RELATIONSHIP_TAG: CompendiumLinkRelationship nodeRelationship = new CompendiumLinkRelationship(); if (nodeRelationship.ConsumeLinkXml(_nodes, _xml, domainNodeId)) { isDomainNodeRootMapNode = true; } break; default: break; } } else if (_xml.NodeType == XmlNodeType.EndElement) { if (_xml.Name == COMPENDIUM_DOCUMENT_TAG) { break; } } } if (isDomainNodeRootMapNode) { _nodes[domainNodeId].NodeType = IoCContainer.GetInjectionInstance().GetInstance <MapNode>(); } } foreach (CompendiumViewRelationship viewRelationship in viewRelationships) { viewRelationship.BuildRelationships(_nodes); } Dictionary <CompendiumNodeAddress, CompendiumViewRelationship> allViewRelationships = new Dictionary <CompendiumNodeAddress, CompendiumViewRelationship>(); Dictionary <string, CompendiumViewRelationship> originalRelationships = new Dictionary <string, CompendiumViewRelationship>(); Dictionary <CompendiumNodeAddress, CompendiumViewRelationship> transcludedRelationships = new Dictionary <CompendiumNodeAddress, CompendiumViewRelationship>(); foreach (CompendiumViewRelationship viewRelationship in viewRelationships) { if (!_rootViewRelationships.Contains(viewRelationship) && viewRelationship.IsRootView) { _rootViewRelationships.Add(viewRelationship); originalRelationships.Add(viewRelationship.FromNode.Id, viewRelationship); } else { CompendiumNodeAddress nodeAddress = new CompendiumNodeAddress(); nodeAddress.viewId = viewRelationship.ToNode.Id; nodeAddress.nodeId = viewRelationship.FromNode.Id; allViewRelationships.Add(nodeAddress, viewRelationship); if (originalRelationships.ContainsKey(viewRelationship.FromNode.Id)) { // Perform the test to see if this node is the original or transcluded node. CompendiumViewRelationship originalRelationship = originalRelationships[viewRelationship.FromNode.Id]; if (originalRelationship.Created < viewRelationship.Created) { CompendiumNodeAddress transcludedNodeAddress = new CompendiumNodeAddress(); transcludedNodeAddress.viewId = viewRelationship.ToNode.Id; transcludedNodeAddress.nodeId = viewRelationship.FromNode.Id; transcludedRelationships.Add(transcludedNodeAddress, viewRelationship); } else { originalRelationships.Remove(originalRelationship.FromNode.Id); originalRelationships.Add(viewRelationship.FromNode.Id, viewRelationship); CompendiumNodeAddress transcludedNodeAddress = new CompendiumNodeAddress(); transcludedNodeAddress.viewId = originalRelationship.ToNode.Id; transcludedNodeAddress.nodeId = originalRelationship.FromNode.Id; transcludedRelationships.Add(transcludedNodeAddress, originalRelationship); } } else { // The node doesn't exist so add it to our list of original relationships continue. originalRelationships.Add(viewRelationship.FromNode.Id, viewRelationship); } } } foreach (CompendiumViewRelationship transcludedRelationship in transcludedRelationships.Values) { List <IDescriptor> linkRelationshipsToRemove = new List <IDescriptor>(); // Inspect all the nodes linked to this node. foreach (IDescriptor localDescriptor in transcludedRelationship.FromNode.Descriptors) { // Make sure we're looking at only link relationships and not views or transcluded relationships. if (localDescriptor.Relationship is CompendiumLinkRelationship) { CompendiumTransclusionRelationship transclusionRelationship = null; foreach (IDescriptor foreignDescriptor in localDescriptor.Relationship.Descriptors) { // Make sure we aren't looking at ourself. if (foreignDescriptor != localDescriptor) { // Find the original non-transclusion relationship of the connected node. If this is not in the same view as the original view of the node we're // currently building, then it means this is a transluded node and we need to build the relationship to represent that. if (originalRelationships[foreignDescriptor.Node.Id].ToNode.Id != originalRelationships[localDescriptor.Node.Id].ToNode.Id)//transcludedRelationship.ToNode.Id) { INode fromNode; INode toNode; INode transclusionNode = localDescriptor.Node; INode mapNode = originalRelationships[foreignDescriptor.Node.Id].ToNode; if (localDescriptor.DescriptorType.Name == "From") { toNode = foreignDescriptor.Node; fromNode = localDescriptor.Node; } else { toNode = localDescriptor.Node; fromNode = foreignDescriptor.Node; } transclusionRelationship = new CompendiumTransclusionRelationship(localDescriptor.Relationship, transcludedRelationship, toNode, fromNode, transclusionNode, mapNode); linkRelationshipsToRemove.Add(localDescriptor); linkRelationshipsToRemove.Add(foreignDescriptor); } } } } } foreach (IDescriptor descriptor in linkRelationshipsToRemove) { descriptor.Node.RemoveDescriptor(descriptor); } foreach (IDescriptor descriptor in transcludedRelationship.Descriptors) { descriptor.Node.RemoveDescriptor(descriptor); } } return(isDomainNodeRootMapNode); }