コード例 #1
0
        private void DeleteNode(Guid nodeUid)
        {
            if (ProxyNodes.ContainsKey(nodeUid))
            {
                ProxyNodes.Remove(nodeUid);
            }

            if (ServiceNodes.ContainsKey(nodeUid))
            {
                ServiceNodes.Remove(nodeUid);
            }
        }
コード例 #2
0
        public Proxy.INode FindNode(Guid nodeId)
        {
            Proxy.INode proxyNode;

            if (ProxyNodes.ContainsKey(nodeId))
            {
                proxyNode = ProxyNodes[nodeId];
            }
            else
            {
                SoapNode soapNode = new SoapNode(MapManager);
                soapNode.PreInitialiseNode(nodeId);

                ProxyNodes.Add(soapNode.Id, soapNode);
                proxyNode = soapNode;
            }

            return(proxyNode);
        }
コード例 #3
0
        public Proxy.INode FindNode(ServerObjects.Node serviceNode)
        {
            Proxy.INode node;

            if (ProxyNodes.ContainsKey(serviceNode.NodeUid))
            {
                node = ProxyNodes[serviceNode.NodeUid];

                SoapNode soapNode = node as SoapNode;

                /// Not all the nodes that are stored in the NodeManager are SoapNodes, some are FacadeNodes. In this scenario we want to check if they have an inner SoapNode and use that instead.
                if (soapNode == null)
                {
                    if (node is FacadeNode)
                    {
                        FacadeNode facadeNode = node as FacadeNode;
                        soapNode = facadeNode.BaseNode as SoapNode;
                    }
                }

                if (soapNode != null)
                {
                    soapNode.UpdateNode(serviceNode);
                }
            }
            else
            {
                SoapNode soapNode = new SoapNode(MapManager);
                soapNode.UpdateNode(serviceNode);

                ProxyNodes.Add(soapNode.Id, soapNode);

                node = soapNode;
            }

            if (!ServiceNodes.ContainsKey(serviceNode.NodeUid))
            {
                ServiceNodes.Add(serviceNode.NodeUid, serviceNode);
            }

            return(node);
        }
コード例 #4
0
            private void BuildRelationships(ref Queue <TransactionFramework.TransactionChain> transactionQueue)
            {
                int transactionCounts = 0;

                TransactionFramework.TransactionChain chain = new TransactionFramework.TransactionChain();

                foreach (XmlModel.INode node in Nodes)
                {
                    foreach (XmlModel.IDescriptor descriptor in node.Descriptors)
                    {
                        if (descriptor.DescriptorType == null || descriptor.DescriptorType.Name == "From")
                        {
                            continue;
                        }

                        XmlModel.IRelationship relationship  = descriptor.Relationship;
                        XmlModel.INode         connectedNode = null;

                        foreach (XmlModel.IDescriptor linkedDescriptor in relationship.Descriptors)
                        {
                            if (linkedDescriptor != descriptor)
                            {
                                connectedNode = linkedDescriptor.Node;
                                break;
                            }
                        }

                        if (connectedNode == null)
                        {
                            // This means that there was no connected nodes or there may have been a circular reference.
                            continue;
                        }

                        Proxy.INode proxyNode;

                        if (ProxyNodes.ContainsKey(node.Id))
                        {
                            proxyNode = ProxyNodes[node.Id];
                        }
                        else
                        {
                            continue;
                        }

                        Proxy.INode proxyConnectedNode;

                        if (ProxyNodes.ContainsKey(connectedNode.Id))
                        {
                            proxyConnectedNode = ProxyNodes[connectedNode.Id];
                        }
                        else
                        {
                            continue;
                        }

                        if (proxyNode.NodeType == MapManager.NodeTypes["DomainNode"] || proxyConnectedNode.NodeType == MapManager.NodeTypes["DomainNode"])
                        {
                            continue;
                        }

                        if (transactionCounts >= 150)
                        {
                            transactionQueue.Enqueue(chain);
                            chain             = new TransactionFramework.TransactionChain();
                            transactionCounts = 0;
                        }
                        else
                        {
                            transactionCounts++;
                        }

                        if (relationship is CompendiumLinkRelationship)
                        {
                            CompendiumLinkRelationship linkRelationship = relationship as CompendiumLinkRelationship;

                            if (!linkRelationship.IsTransclusion)
                            {
                                // In this situation the relationship is between two nodes in a map.
                                Proxy.IRelationship newRelationship = MapManager.CreateRelationship(Map.DomainId, Map.RootMapId.Value, MapManager.RelationshipTypes["FromToRelationship"], string.Empty, ref chain);
                                newRelationship.ConnectNode(MapManager.ConnectionTypes["To"], proxyNode, ref chain);
                                newRelationship.ConnectNode(MapManager.ConnectionTypes["From"], proxyConnectedNode, ref chain);
                            }
                            else
                            {
                                Proxy.INode proxyMap = ProxyNodes[linkRelationship.Map.Id];

                                // In this situation the relationship is a transclusion so we'll need to handle it slightly differently.
                                //Proxy.IRelationship newTranscludedNodeRelationship = MapManager.CreateRelationship(Map.DomainId, MapManager.RelationshipTypes["MapContainerRelationship"], string.Empty, ref chain);
                                //newTranscludedNodeRelationship.ConnectNode(MapManager.ConnectionTypes["To"], proxyMap, ref chain);
                                //newTranscludedNodeRelationship.ConnectNode(MapManager.ConnectionTypes["From"], transclusionNode, ref chain);

                                //transclusionNode.Metadata.Add(newTranscludedNodeRelationship, MapManager.ConnectionTypes["From"], "XPosition", transclusionRelationship.XPosition.ToString(), ref chain);
                                //transclusionNode.Metadata.Add(newTranscludedNodeRelationship, MapManager.ConnectionTypes["From"], "YPosition", transclusionRelationship.YPosition.ToString(), ref chain);

                                Proxy.IRelationship newTransclusionRelationship = MapManager.CreateRelationship(Map.DomainId, Map.RootMapId.Value, MapManager.RelationshipTypes["TransclusionFromToRelationship"], string.Empty, ref chain);

                                newTransclusionRelationship.ConnectNode(MapManager.ConnectionTypes["TransclusionMap"], proxyMap, ref chain);
                                newTransclusionRelationship.ConnectNode(MapManager.ConnectionTypes["To"], proxyNode, ref chain);
                                newTransclusionRelationship.ConnectNode(MapManager.ConnectionTypes["From"], proxyConnectedNode, ref chain);
                            }
                        }
                        else if (relationship is CompendiumViewRelationship)
                        {
                            CompendiumViewRelationship viewRelationship = relationship as CompendiumViewRelationship;

                            if (!viewRelationship.IsRootView)
                            {
                                // In this situation the relationship is between a node and a map node.
                                Proxy.IRelationship newRelationship = MapManager.CreateRelationship(Map.DomainId, Map.RootMapId.Value, MapManager.RelationshipTypes["MapContainerRelationship"], string.Empty, ref chain);
                                newRelationship.ConnectNode(MapManager.ConnectionTypes["To"], proxyNode, ref chain);
                                newRelationship.ConnectNode(MapManager.ConnectionTypes["From"], proxyConnectedNode, ref chain);

                                proxyConnectedNode.Metadata.Add(newRelationship, MapManager.ConnectionTypes["From"], "XPosition", viewRelationship.XPosition.ToString(), ref chain);
                                proxyConnectedNode.Metadata.Add(newRelationship, MapManager.ConnectionTypes["From"], "YPosition", viewRelationship.YPosition.ToString(), ref chain);
                            }
                        }
                        else
                        {
                            // In this situation the relationship is of an unknown type so lets just skip it.
                            continue;
                        }
                    }
                    //chains.Enqueue(chain);

                    //MapManager.ExecuteTransaction(chain);
                    ///
                }
                if (chain != null && chain.NumOfTransactions > 0)
                {
                    transactionQueue.Enqueue(chain);
                }
            }