//private void OnGetNodesWithConditionsCompleted(object sender, GetNodesWithConditionsCompletedEventArgs e) //{ // if (e.Error == null) // { // List<INodeProxy> nodes = BuildNodeList(e.Result); // ReturnedNodesEventArgs eventArgs = new ReturnedNodesEventArgs(e.Result.SearchedNode, nodes.ToArray()); // if (GetNodesWithConditionsCompleted != null) // { // GetNodesWithConditionsCompleted.Invoke(this, eventArgs); // } // } //} private void OnGetRelatedNodesByIdAsyncCompleted(object sender, GetRelatedNodesCompletedEventArgs e) { if (e.Error == null) { List <INodeProxy> nodes = BuildNodeList(e.Result); ReturnedNodesEventArgs eventArgs = new ReturnedNodesEventArgs(e.Result.SearchedNode, nodes.ToArray()); if (GetRelatedNodesByIdCompleted != null) { GetRelatedNodesByIdCompleted.Invoke(this, eventArgs); } } }
public void GetRelatedNodesByIdAsync(string mapId, string nodeId, int depth) { if (_localNewNodes.ContainsKey(nodeId)) { ReturnedNodesEventArgs returnedNodesEventArgs = new ReturnedNodesEventArgs(); List <INodeProxy> returnedNodes = new List <INodeProxy>(); returnedNodes.Add(_localNewNodes[nodeId]); returnedNodes.AddRange(_localNewNodes[nodeId].ParentNodes); returnedNodes.AddRange(_localNewNodes[nodeId].ChildNodes); returnedNodesEventArgs.SearchedNode = _localNewNodes[nodeId]; returnedNodesEventArgs.Nodes = returnedNodes.ToArray(); if (GetRelatedNodesByIdCompleted != null) { GetRelatedNodesByIdCompleted.Invoke(this, returnedNodesEventArgs); } } else { _client = Client; _client.GetRelatedNodesAsync(mapId, nodeId, depth); } }
private void GetRelatedNodesByIdAsyncCompleted(object sender, GetRelatedNodesCompletedEventArgs e) { if (e.Error == null) { List <INodeProxy> nodes = new List <INodeProxy>(); foreach (SoapNode soapNode in e.Result.RelatedNodes.Values) { if (!_cachedNodes.ContainsKey(soapNode.Id)) { NodeProxy node = new NodeProxy(soapNode); _cachedNodes.Add(soapNode.Id, node); } } foreach (SoapNode soapNode in e.Result.RelatedNodes.Values) { INodeProxy node = _cachedNodes[soapNode.Id]; foreach (SoapRelationship relationship in soapNode.Relationships) { RelationshipProxy relationshipProxy = new RelationshipProxy(relationship); foreach (DescriptorProxy descriptor in relationshipProxy.Descriptors) { if (_cachedNodes.ContainsKey(descriptor.NodeId)) { INodeProxy connectedNode = _cachedNodes[descriptor.NodeId]; if (!connectedNode.Descriptors.Contains(descriptor)) { descriptor.Node = connectedNode; connectedNode.Descriptors.Add(descriptor); } } } } } INodeProxy nodeProxy = _cachedNodes[e.Result.SearchedNode.Id]; nodes.Add(nodeProxy); foreach (INodeProxy np in _localNewNodes.Values) { nodes.Add(np); } foreach (IDescriptorProxy descriptor in nodeProxy.Descriptors) { foreach (IDescriptorProxy alternateDescriptor in descriptor.Relationship.Descriptors) { if (!nodes.Contains(alternateDescriptor.Node)) { nodes.Add(alternateDescriptor.Node); } } } INodeProxy searchedNode = new NodeProxy(e.Result.SearchedNode); ReturnedNodesEventArgs eventArgs = new ReturnedNodesEventArgs(searchedNode, nodes.ToArray()); if (GetRelatedNodesByIdCompleted != null) { GetRelatedNodesByIdCompleted.Invoke(this, eventArgs); } } }