Пример #1
0
        private void OnQueryMapPagedCompleted(object sender, Service.QueryMapPagedCompletedEventArgs e)
        {
            if (e != null && e.Result != null)
            {
                e.Result.DecompressResponse();
            }

            //ServiceProxy.QueryMapPagedCompleted -= OnQueryMapByIdPagedCompleted;
            Service.QueryResponse queryResponse = e.Result;

            QueryMapResponseStateInfo callerInfo = e.UserState as QueryMapResponseStateInfo;

            Service.QueryResponse aggregatedResponse = callerInfo.AggregatedResponse;//e.UserState as Service.QueryResponse;

            if (aggregatedResponse == null)
            {
                aggregatedResponse.Domain      = queryResponse.Domain;
                aggregatedResponse.NodeContext = queryResponse.NodeContext;

                aggregatedResponse.Nodes         = new Dictionary <Guid, Service.NO>();
                aggregatedResponse.Relationships = new Dictionary <Guid, Service.RE>();
            }

            foreach (KeyValuePair <Guid, Service.NO> nodePair in queryResponse.Nodes)
            {
                aggregatedResponse.Nodes[nodePair.Key] = nodePair.Value;
            }

            foreach (KeyValuePair <Guid, Service.RE> relationshipPair in queryResponse.Relationships)
            {
                aggregatedResponse.Relationships[relationshipPair.Key] = relationshipPair.Value;
            }

            if (queryResponse.LastObjectIndex >= queryResponse.FinalObjectIndex)
            {
                ServerObjects.QueryResponse soAggregatedResponse = ServerObjectConverter.ToQueryResponse(aggregatedResponse);

                Proxy.NodesEventArgs eventArgs = new Proxy.NodesEventArgs();

                Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soAggregatedResponse.Nodes, soAggregatedResponse.Relationships);

                Proxy.INode context = eventArgs.Nodes[e.Result.NodeContext.N];

                if (callerInfo.ResponseType == QueryMapResponseStateType.ById)
                {
                    QueryMapByIdCompleted.FireEvent(context.Id, this, eventArgs);
                }
                else if (callerInfo.ResponseType == QueryMapResponseStateType.ByNode)
                {
                    QueryMapByNodeCompleted.FireEvent(context, this, eventArgs);
                }
            }
            else
            {
                QueryMapResponseStateInfo info = new QueryMapResponseStateInfo();
                info.AggregatedResponse = aggregatedResponse;
                info.ResponseType       = callerInfo.ResponseType;
                ServiceProxy.QueryMapPagedAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), aggregatedResponse.Domain.DomainUid, aggregatedResponse.NodeContext.N, 1, null, null, queryResponse.LastObjectIndex + 1, info);
            }
        }
Пример #2
0
        void OnCreateRootMapCompleted(object sender, Service.CreateRootMapCompletedEventArgs e)
        {
            if (CreateRootMapCompleted != null)
            {
                Proxy.NodesEventArgs        eventArgs       = new Proxy.NodesEventArgs();
                ServerObjects.QueryResponse soQueryResponse = ServerObjectConverter.ToQueryResponse(e.Result);

                Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soQueryResponse.Nodes, soQueryResponse.Relationships);

                CreateRootMapCompleted.FireEvent(this, eventArgs);
            }
        }
Пример #3
0
        private void OnQueryDomainsCompleted(object sender, Service.QueryDomainsCompletedEventArgs e)
        {
            Proxy.NodesEventArgs eventArgs = new Proxy.NodesEventArgs();

            foreach (Service.QueryResponse soapServiceQueryResponse in e.Result.Values)
            {
                ServerObjects.QueryResponse soQueryResponse = ServerObjectConverter.ToQueryResponse(soapServiceQueryResponse);

                Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soQueryResponse.Nodes, soQueryResponse.Relationships);
            }

            QueryDomainsCompleted.FireEvent(this, eventArgs);
        }
Пример #4
0
        private void OnQueryMapByDomainCompleted(object sender, Service.QueryMapByDomainCompletedEventArgs e)
        {
            if (e != null && e.Result != null)
            {
                e.Result.DecompressResponse();
            }

            if (QueryMapByDomainCompleted != null)
            {
                Proxy.NodesEventArgs        eventArgs       = new Proxy.NodesEventArgs();
                ServerObjects.QueryResponse soQueryResponse = ServerObjectConverter.ToQueryResponse(e.Result);

                Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soQueryResponse.Nodes, soQueryResponse.Relationships);

                Proxy.INode nodeContext = Graph.FindNode(soQueryResponse.NodeContext);

                QueryMapByDomainCompleted.FireEvent(nodeContext.DomainId, this, eventArgs);
            }
        }
Пример #5
0
        public ServerObjects.QueryResponse ToQueryResponse(Service.QueryResponse soapServiceQueryResponse)
        {
            ServerObjects.QueryResponse soQueryResponse = new ServerObjects.QueryResponse();

            if (soapServiceQueryResponse == null || soapServiceQueryResponse.Domain == null)
            {
                return(soQueryResponse);
            }

            soQueryResponse.Domain              = soapServiceQueryResponse.Domain.DomainUid;
            soQueryResponse.ErrorId             = soapServiceQueryResponse.ErrorId;
            soQueryResponse.ErrorMessage        = soapServiceQueryResponse.ErrorMessage;
            soQueryResponse.FinalObjectIndex    = soapServiceQueryResponse.FinalObjectIndex;
            soQueryResponse.LastObjectIndex     = soapServiceQueryResponse.LastObjectIndex;
            soQueryResponse.StartingObjectIndex = soapServiceQueryResponse.StartingObjectIndex;

            if (soapServiceQueryResponse.NodeContext != null)
            {
                soQueryResponse.NodeContext = ToNode(soapServiceQueryResponse.NodeContext);
            }

            foreach (Service.NO soapServiceNode in soapServiceQueryResponse.Nodes.Values)
            {
                ServerObjects.Node soNode = ToNode(soapServiceNode);

                soQueryResponse.Nodes.Add(soNode.NodeUid, soNode);
            }

            foreach (Service.RE soapServiceRelationship in soapServiceQueryResponse.Relationships.Values)
            {
                ServerObjects.Relationship soRelationship = ToRelationship(soapServiceRelationship);

                soQueryResponse.Relationships.Add(soRelationship.RelationshipUid, soRelationship);
            }

            return(soQueryResponse);
        }
Пример #6
0
        private void OnQueryMapCompleted(object sender, Service.QueryMapCompletedEventArgs e)
        {
            if (e != null && e.Result != null)
            {
                e.Result.DecompressResponse();
            }

            Proxy.NodesEventArgs eventArgs = new Proxy.NodesEventArgs();

            Service.QueryResponse     soapServiceQueryResponse = e.Result;
            QueryMapResponseStateInfo callerInfo = e.UserState as QueryMapResponseStateInfo;

            if (soapServiceQueryResponse.FinalObjectIndex <= 0)
            {
                ServerObjects.QueryResponse soQueryResponse = ServerObjectConverter.ToQueryResponse(soapServiceQueryResponse);

                Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soQueryResponse.Nodes, soQueryResponse.Relationships);

                if (e.Result.NodeContext != null)
                {
                    Proxy.INode context = eventArgs.Nodes[e.Result.NodeContext.N];

                    if (callerInfo.ResponseType == QueryMapResponseStateType.ById)
                    {
                        QueryMapByIdCompleted.FireEvent(context.Id, this, eventArgs);
                    }
                    else if (callerInfo.ResponseType == QueryMapResponseStateType.ByNode)
                    {
                        QueryMapByNodeCompleted.FireEvent(context, this, eventArgs);
                    }
                }
                else
                {
                    /// TODO: Need to find a nicer way of handling this exception rather than just ignoring it altogether.
                    //throw new NodeNotFoundException("The given node wasn't found");
                }
            }
            else
            {
                Service.QueryResponse aggregatedResponse = new Service.QueryResponse();

                aggregatedResponse.Domain      = soapServiceQueryResponse.Domain;
                aggregatedResponse.NodeContext = soapServiceQueryResponse.NodeContext;

                aggregatedResponse.Nodes         = new Dictionary <Guid, Service.NO>();
                aggregatedResponse.Relationships = new Dictionary <Guid, Service.RE>();

                foreach (KeyValuePair <Guid, Service.NO> nodePair in soapServiceQueryResponse.Nodes)
                {
                    aggregatedResponse.Nodes[nodePair.Key] = nodePair.Value;
                }

                foreach (KeyValuePair <Guid, Service.RE> relationshipPair in soapServiceQueryResponse.Relationships)
                {
                    aggregatedResponse.Relationships[relationshipPair.Key] = relationshipPair.Value;
                }

                //ServiceProxy.QueryMapPagedCompleted += OnQueryMapByIdPagedCompleted;
                QueryMapResponseStateInfo info = new QueryMapResponseStateInfo();
                info.AggregatedResponse = aggregatedResponse;
                info.ResponseType       = callerInfo.ResponseType;
                ServiceProxy.QueryMapPagedAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), aggregatedResponse.Domain.DomainUid, aggregatedResponse.NodeContext.N, 1, null, null, soapServiceQueryResponse.LastObjectIndex + 1, info);
            }
        }
        public ServerObjects.QueryResponse ToQueryResponse(Service.QueryResponse soapServiceQueryResponse)
        {
            ServerObjects.QueryResponse soQueryResponse = new ServerObjects.QueryResponse();

            if (soapServiceQueryResponse == null || soapServiceQueryResponse.Domain == null)
            {
                return soQueryResponse;
            }

            soQueryResponse.Domain = soapServiceQueryResponse.Domain.DomainUid;
            soQueryResponse.ErrorId = soapServiceQueryResponse.ErrorId;
            soQueryResponse.ErrorMessage = soapServiceQueryResponse.ErrorMessage;
            soQueryResponse.FinalObjectIndex = soapServiceQueryResponse.FinalObjectIndex;
            soQueryResponse.LastObjectIndex = soapServiceQueryResponse.LastObjectIndex;
            soQueryResponse.StartingObjectIndex = soapServiceQueryResponse.StartingObjectIndex;

            if (soapServiceQueryResponse.NodeContext != null)
            {
                soQueryResponse.NodeContext = ToNode(soapServiceQueryResponse.NodeContext);
            }

            foreach (Service.NO soapServiceNode in soapServiceQueryResponse.Nodes.Values)
            {
                ServerObjects.Node soNode = ToNode(soapServiceNode);

                soQueryResponse.Nodes.Add(soNode.NodeUid, soNode);
            }

            foreach (Service.RE soapServiceRelationship in soapServiceQueryResponse.Relationships.Values)
            {
                ServerObjects.Relationship soRelationship = ToRelationship(soapServiceRelationship);

                soQueryResponse.Relationships.Add(soRelationship.RelationshipUid, soRelationship);
            }

            return soQueryResponse;
        }