Beispiel #1
0
        public static QuerySpec Parse(TableSpec tabSpec, HttpRequest Request)
        {
            var spec = new QuerySpec();

            if (Request.Query["$count"].Count == 1)
            {
                throw new ArgumentException("Parameter $count is not supported.");
            }
            if (Request.Query["$format"].Count == 1)
            {
                throw new ArgumentException("Parameter $format is not supported.");
            }
            if (Request.Query["$expand"].Count == 1)
            {
                throw new ArgumentException("Parameter $format is not supported.");
            }
            if (Request.Query["$skiptoken"].Count == 1)
            {
                throw new ArgumentException("Parameter $skiptoken is not supported.");
            }

            spec.count   = Request.Path.Value.EndsWith("/$count");
            spec.skip    = Convert.ToInt32(Request.Query["$skip"]);
            spec.top     = Convert.ToInt32(Request.Query["$top"]);
            spec.select  = Request.Query["$select"];
            spec.keyword = Request.Query["$search"];
            ParseSearch(Request.Query["$filter"], spec, tabSpec);
            ParseOrderBy(tabSpec, Request.Query["$orderby"], spec);
            tabSpec.Validate(spec);
            return(spec);
        }
        public static QuerySpec Parse(TableSpec tabSpec, HttpRequest Request)
        {
            var spec = new QuerySpec();

            spec.skip   = Convert.ToInt32(Request.Query["start"]);
            spec.top    = Convert.ToInt32(Request.Query["length"]);
            spec.select = null;//JQuery datatables don't provide column list.
            ParseSearch(Request, spec);
            ParseOrderBy(tabSpec, Request, spec);
            tabSpec.Validate(spec, true);
            return(spec);
        }
Beispiel #3
0
        public static QuerySpec Parse(TableSpec tabSpec, HttpRequestMessage Request)
        {
            var spec       = new QuerySpec();
            var parameters = Request.RequestUri.ParseQueryString();

            spec.count  = (parameters["$count"] != null);
            spec.skip   = Convert.ToInt32(parameters["$skip"]);
            spec.top    = Convert.ToInt32(parameters["$top"]);
            spec.select = parameters["$select"];
            ParseSearch(parameters["$filter"], spec, tabSpec);
            ParseOrderBy(tabSpec, parameters["$orderby"], spec);
            tabSpec.Validate(spec);
            return(spec);
        }
Beispiel #4
0
        public static QuerySpec Parse(TableSpec tabSpec, HttpRequest Request)
        {
            var spec = new QuerySpec();

            spec.skip   = Convert.ToInt32(Request.Query["start"]);
            spec.top    = Convert.ToInt32(Request.Query["length"]);
            spec.select = null;//JQuery datatables don't provide column list.
            ParseSearch(Request, spec);
            ParseOrderBy(tabSpec, Request, spec);
            if (Request.Query.ContainsKey("$systemat"))
            {
                spec.systemTimeAsOf = Request.Query["$systemat"];
                DateTime asof;
                if (!DateTime.TryParse(spec.systemTimeAsOf, out asof))
                {
                    throw new ArgumentException(spec.systemTimeAsOf + " is not valid date.");
                }
            }
            tabSpec.Validate(spec, true);
            return(spec);
        }
        public static QuerySpec Parse(TableSpec tabSpec, HttpRequestMessage Request)
        {
            var spec       = new QuerySpec();
            var parameters = Request.RequestUri.ParseQueryString();

            spec.count  = (parameters["$count"] != null);
            spec.skip   = Convert.ToInt32(parameters["$skip"]);
            spec.top    = Convert.ToInt32(parameters["$top"]);
            spec.select = parameters["$select"];
            ParseSearch(parameters["$filter"], spec, tabSpec);
            ParseGroupBy(Request.Query["$apply"], spec, tabSpec);
            ParseOrderBy(tabSpec, parameters["$orderby"], spec);
            if (Request.Query.ContainsKey("$systemat"))
            {
                spec.systemTimeAsOf = Request.Query["$systemat"];
                DateTime asof;
                if (!DateTime.TryParse(spec.systemTimeAsOf, out asof))
                {
                    throw new ArgumentException(spec.systemTimeAsOf + " is not valid date.");
                }
            }
            tabSpec.Validate(spec);
            return(spec);
        }
        public static QuerySpec Parse(TableSpec tabSpec, HttpRequest Request)
        {
            if (_log == null)
            {
                _log = StartUp.GetLogger <RequestHandler>();
            }

            var spec = new QuerySpec();

            if (Request.Query["$format"].Count == 1 && Request.Query["$format"].ToString().ToLower() != "json")
            {
                if (_log != null)
                {
                    _log.ErrorFormat("Unsupported {parameter} {value} provided to {type} Uri parser", "$format", Request.Query["$format"], "OData");
                }
                throw new ArgumentException("Parameter $format is not supported.");
            }
            foreach (var p in Request.Query.Keys)
            {
                if (p.StartsWith("$") &&
                    !(p == "$select" || p == "$orderby" || p == "$format" ||
                      p == "$apply" || p == "$systemat" ||
                      p == "$top" || p == "$skip" ||
                      p == "$filter" || p == "$search" ||
                      p == "$expand"))
                {
                    if (_log != null)
                    {
                        _log.ErrorFormat("Unsupported {parameter} {value} provided to {type} Uri parser", p, Request.Query[p], "OData");
                    }
                    throw new ArgumentException("Parameter " + p + " is not supported.");
                }
            }
            spec.count = Request.Path.Value.EndsWith("/$count");
            if (Request.Query.ContainsKey("$skip"))
            {
                spec.skip = Convert.ToInt32(Request.Query["$skip"]);
            }
            if (Request.Query.ContainsKey("$top"))
            {
                spec.top = Convert.ToInt32(Request.Query["$top"]);
            }
            spec.select = Request.Query["$select"];
            ParseExpand(Request.Query["$expand"], spec, tabSpec);
            spec.keyword = Request.Query["$search"];
            ParseSearch(Request.Query["$filter"], spec, tabSpec);
            ParseGroupBy(Request.Query["$apply"], spec, tabSpec);
            ParseOrderBy(tabSpec, Request.Query["$orderby"], spec);
            if (Request.Query.ContainsKey("$systemat"))
            {
                spec.systemTimeAsOf = Request.Query["$systemat"];
                DateTime asof;
                if (!DateTime.TryParse(spec.systemTimeAsOf, out asof))
                {
                    if (_log != null)
                    {
                        _log.ErrorFormat("Invalid date {value} provided as {parameter} in {type} Uri parser", spec.systemTimeAsOf, "$systemat", "OData");
                    }
                    throw new ArgumentException(spec.systemTimeAsOf + " is not valid date.");
                }
            }

            tabSpec.Validate(spec);
            return(spec);
        }