示例#1
0
        public HttpResponseMessage <JsonQueryResult> Get(
            [FromUri(Name = "request")] string request,
            [FromUri(Name = "name")] string name         = null,
            [FromUri(Name = "typename")] string typeName = null,
            string id    = null,
            string ns    = null,
            string alias = null
            )
        {
            // Get the entityRef
            EntityRef entityRef = MakeEntityRef(id, ns, alias, name, typeName);

            //// Parse the request
            EntityMemberRequest entityRequest = Factory.RequestParser.ParseRequestQuery(request);

            //// Run the query
            //ResponseContext EntityPackage = new ResponseContext();


            var context = new EntityPackage( );

            context.AddEntityRequest(entityRef, entityRequest);

            return(new HttpResponseMessage <JsonQueryResult>(context.GetQueryResult( )));
        }
示例#2
0
        public HttpResponseMessage <JsonQueryResult> Query([FromBody] JsonQueryBatchRequest batch)
        {
            string hintText = Request.RequestUri.Query;

            // Validate arguments
            if (batch == null || batch.Queries == null || batch.Requests == null || batch.Queries.Length == 0 || batch.Requests.Length == 0)
            {
                string error = "Cannot parse post data.";
                if (batch == null)
                {
                    error += "batch was null.";
                }
                else if (batch.Queries == null)
                {
                    error += "batch.Queries was null.";
                }
                else if (batch.Requests == null)
                {
                    error += "batch.Requests was null.";
                }
                else if (batch.Queries.Length == 0)
                {
                    error += "batch.Queries.Length was 0.";
                }
                else if (batch.Requests.Length == 0)
                {
                    error += "batch.Requests.Length was 0.";
                }

                EventLog.Application.WriteError(error);
                return(new HttpResponseMessage <JsonQueryResult>(HttpStatusCode.BadRequest));
            }


            // Prep working objects
            var context = new EntityPackage( );

            context.AddEntityRequestBatch(batch, hintText);

            return(new HttpResponseMessage <JsonQueryResult>(context.GetQueryResult( )));
        }