private void OnGetAllSoapTypesAsyncCompleted(object sender, GetAllSoapTypesCompletedEventArgs e) { if (e.Error == null) { List <INodeTypeProxy> nodeTypeProxies = new List <INodeTypeProxy>(); List <IDescriptorTypeProxy> descriptorTypeProxies = new List <IDescriptorTypeProxy>(); List <IRelationshipTypeProxy> relationshipTypeProxies = new List <IRelationshipTypeProxy>(); List <IMetadataTypeProxy> metadataTypeProxies = new List <IMetadataTypeProxy>(); foreach (SoapTypeElement soapElement in e.Result) { if (soapElement is SoapNodeType) { INodeTypeProxy nodeTypeProxy = new NodeTypeProxy(soapElement as SoapNodeType); nodeTypeProxies.Add(nodeTypeProxy); } else if (soapElement is SoapDescriptorType) { IDescriptorTypeProxy descriptorTypeProxy = new DescriptorTypeProxy(soapElement as SoapDescriptorType); descriptorTypeProxies.Add(descriptorTypeProxy); } else if (soapElement is SoapRelationshipType) { IRelationshipTypeProxy relationshipTypeProxy = new RelationshipTypeProxy(soapElement as SoapRelationshipType); relationshipTypeProxies.Add(relationshipTypeProxy); } else if (soapElement is SoapMetadataType) { IMetadataTypeProxy metadataTypeProxy = new MetadataTypeProxy(soapElement as SoapMetadataType); metadataTypeProxies.Add(metadataTypeProxy); } } if (GetAllSoapTypesCompleted != null) { ReturnedTypesEventArgs eventArgs = new ReturnedTypesEventArgs(); eventArgs.NodeTypes = nodeTypeProxies.ToArray(); eventArgs.DescriptorTypes = descriptorTypeProxies.ToArray(); eventArgs.RelationshipTypes = relationshipTypeProxies.ToArray(); eventArgs.MetadataTypes = metadataTypeProxies.ToArray(); GetAllSoapTypesCompleted.Invoke(this, eventArgs); } } }
private void OnConnectNodesCompleted(object sender, ConnectNodesCompletedEventArgs e) { if (e.Error == null) { List <INodeProxy> nodes = new List <INodeProxy>(); ConnectedNodesResult connectResult = e.Result; foreach (SoapNode soapNode in connectResult.Nodes.Values) { if (_cachedNodes.ContainsKey(soapNode.Id)) { _cachedNodes.Remove(soapNode.Id); } NodeProxy node = new NodeProxy(soapNode); _cachedNodes.Add(soapNode.Id, node); nodes.Add(node); } foreach (INodeProxy nodeProxy in nodes) { foreach (IDescriptorProxy descriptorProxy in nodeProxy.Descriptors) { CompleteRelationship(descriptorProxy.Relationship); } } ConnectedNodesEventArgs connectedNodesEventArgs = new ConnectedNodesEventArgs(); connectedNodesEventArgs.Nodes = nodes.ToArray(); connectedNodesEventArgs.Relationship = new RelationshipProxy(e.Result.Relationship); CompleteRelationship(connectedNodesEventArgs.Relationship); //When a node is connected via a MapContainerRelationship the UserState will be the location of the new node //on the map, it can't be stored in the db until the relationship exists since it's the contectual relationship //that determines where it is located in it's view in this map (it may be elsewhere in transclusions) if (e.UserState != null) { INodeProxy nodeProxy = connectedNodesEventArgs.Nodes[1]; Point location = (Point)e.UserState; if (location != null) { TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>(); IDescriptorTypeProxy descriptorType = null; if (e.Result.Relationship.RelationshipType.Name == "TransclusionRelationship") { descriptorType = typeManager.GetDescriptorType("TransclusionMap"); } else { descriptorType = typeManager.GetDescriptorType("From"); } MetadataContext xPositionKey = new MetadataContext() { NodeUid = nodeProxy.Id, RelationshipUid = e.Result.Relationship.Id, DescriptorTypeUid = descriptorType.Id, MetadataName = "XPosition" }; MetadataContext yPositionKey = new MetadataContext() { NodeUid = nodeProxy.Id, RelationshipUid = e.Result.Relationship.Id, DescriptorTypeUid = descriptorType.Id, MetadataName = "YPosition" }; if (nodeProxy.Metadata != null && nodeProxy.GetNodeMetadata(xPositionKey) != null) { nodeProxy.GetNodeMetadata(xPositionKey).MetadataValue = location.X.ToString(); } else { MetadataTypeProxy metaDataTypeProxy = typeManager.GetMetadataType("double") as MetadataTypeProxy; if (metaDataTypeProxy != null) { SoapMetadata soapMetadata = new SoapMetadata(); soapMetadata.MetadataName = "XPosition"; soapMetadata.MetadataType = metaDataTypeProxy.BaseSoapNodeType; soapMetadata.MetadataValue = location.X.ToString(); nodeProxy.Metadata.Add(xPositionKey, soapMetadata); } } if (nodeProxy.Metadata != null && nodeProxy.GetNodeMetadata(yPositionKey) != null) { nodeProxy.GetNodeMetadata(yPositionKey).MetadataValue = location.Y.ToString(); } else { MetadataTypeProxy metaDataTypeProxy = typeManager.GetMetadataType("double") as MetadataTypeProxy; if (metaDataTypeProxy != null) { SoapMetadata soapMetadata = new SoapMetadata(); soapMetadata.MetadataName = "YPosition"; soapMetadata.MetadataType = metaDataTypeProxy.BaseSoapNodeType; soapMetadata.MetadataValue = location.Y.ToString(); nodeProxy.Metadata.Add(yPositionKey, soapMetadata); } } } } if (ConnectNodesCompleted != null) { ConnectNodesCompleted.Invoke(this, connectedNodesEventArgs); } } }
private void OnGetAllSoapTypesAsyncCompleted(object sender, GetAllSoapTypesCompletedEventArgs e) { if (e.Error == null) { List<INodeTypeProxy> nodeTypeProxies = new List<INodeTypeProxy>(); List<IDescriptorTypeProxy> descriptorTypeProxies = new List<IDescriptorTypeProxy>(); List<IRelationshipTypeProxy> relationshipTypeProxies = new List<IRelationshipTypeProxy>(); List<IMetadataTypeProxy> metadataTypeProxies = new List<IMetadataTypeProxy>(); foreach (SoapTypeElement soapElement in e.Result) { if (soapElement is SoapNodeType) { INodeTypeProxy nodeTypeProxy = new NodeTypeProxy(soapElement as SoapNodeType); nodeTypeProxies.Add(nodeTypeProxy); } else if (soapElement is SoapDescriptorType) { IDescriptorTypeProxy descriptorTypeProxy = new DescriptorTypeProxy(soapElement as SoapDescriptorType); descriptorTypeProxies.Add(descriptorTypeProxy); } else if (soapElement is SoapRelationshipType) { IRelationshipTypeProxy relationshipTypeProxy = new RelationshipTypeProxy(soapElement as SoapRelationshipType); relationshipTypeProxies.Add(relationshipTypeProxy); } else if (soapElement is SoapMetadataType) { IMetadataTypeProxy metadataTypeProxy = new MetadataTypeProxy(soapElement as SoapMetadataType); metadataTypeProxies.Add(metadataTypeProxy); } } if (GetAllSoapTypesCompleted != null) { ReturnedTypesEventArgs eventArgs = new ReturnedTypesEventArgs(); eventArgs.NodeTypes = nodeTypeProxies.ToArray(); eventArgs.DescriptorTypes = descriptorTypeProxies.ToArray(); eventArgs.RelationshipTypes = relationshipTypeProxies.ToArray(); eventArgs.MetadataTypes = metadataTypeProxies.ToArray(); GetAllSoapTypesCompleted.Invoke(this, eventArgs); } } }