Exemplo n.º 1
0
 private void MarkAsChild(Ast.Expression childExpression)
 {
     if (childExpression.CodeType == CodeType.LogicalExpression)
     {
         ((Ast.LogicalExpression)childExpression).IsChild = true;
     }
 }
Exemplo n.º 2
0
        internal Expression Visit(Expression expression)
        {
            switch (expression.CodeType)
            {
                case CodeType.BlockExpression:
                    return VisitBlockExpression((BlockExpression)expression);
                case CodeType.TypeExpression:
                    return VisitTypeExpression((TypeExpression)expression);
                case CodeType.LambdaExpresion:
                    return VisitLambdaExpression((LambdaExpression)expression);
                case CodeType.LogicalExpression:
                    return VisitLogicalExpression((LogicalExpression)expression);
                case CodeType.BinaryExpression:
                    return VisitBinaryExpression((BinaryExpression)expression);
                case CodeType.LiteralExpression:
                    return VisitLiteralExpression((LiteralExpression)expression);
                case CodeType.MemberExpression:
                    return VisitMemberExpression((MemberExpression)expression);
                case CodeType.OrderbyExpression:
                    return VisitOrderbyExpression((OrderbyExpression)expression);
                case CodeType.MethodCallExpression:
                    return VisitMethodCallExpression((MethodCallExpression)expression);
            }

            throw new ArgumentException("Expression type is not supported");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Invoked during execution of the query, with the
        /// pre populated expression tree.
        /// </summary>
        /// <param name="expression">Target expression block</param>
        /// <returns>Expected result</returns>
        public IEnumerable <T> Execute(Ast.Expression expression)
        {
            Visit(expression);

            var optionsIn     = string.Join(";", Options.Select(x => $"{x.Key}={x.Value}"));
            var objectType    = ObjectTypes.GetObjectType <T>();
            var xmlIn         = WitsmlParser.ToXml(Query, true);
            var originalXmlIn = xmlIn;

            if (Context.Connection.CompressRequests)
            {
                ClientCompression.Compress(ref xmlIn, ref optionsIn);
            }

            Context.LogQuery(Functions.GetFromStore, objectType, originalXmlIn, optionsIn);

            using (var client = Context.Connection.CreateClientProxy().WithUserAgent())
            {
                var    wmls = (IWitsmlClient)client;
                string suppMsgOut, xmlOut = string.Empty;
                var    result = Enumerable.Empty <T>();
                short  returnCode;

                try
                {
                    returnCode = wmls.WMLS_GetFromStore(objectType, xmlIn, optionsIn, null, out xmlOut, out suppMsgOut);
                }
                catch (Exception ex)
                {
                    Logger.ErrorFormat("Error querying store: {0}", ex);
                    returnCode = -1;
                    suppMsgOut = "Error querying store:" + ex.GetBaseException().Message;
                }

                try
                {
                    // Handle servers that compress the response to a compressed request.
                    if (Context.Connection.CompressRequests)
                    {
                        xmlOut = ClientCompression.SafeDecompress(xmlOut);
                    }

                    if (returnCode > 0)
                    {
                        var document = WitsmlParser.Parse(xmlOut);
                        var response = WitsmlParser.Parse <TList>(document.Root);
                        result = (IEnumerable <T>)response.Items;
                    }
                }
                catch (WitsmlException ex)
                {
                    Logger.ErrorFormat("Error parsing query response: {0}{2}{2}{1}", xmlOut, ex, Environment.NewLine);
                    returnCode = (short)ex.ErrorCode;
                    suppMsgOut = ex.Message + " " + ex.GetBaseException().Message;
                }

                Context.LogResponse(Functions.GetFromStore, objectType, originalXmlIn, optionsIn, xmlOut, returnCode, suppMsgOut);
                return(result);
            }
        }
Exemplo n.º 4
0
        internal Ast.Expression Visit(Ast.Expression expression)
        {
            switch (expression.CodeType)
            {
            case CodeType.BlockExpression:
                return(VisitBlockExpression((Ast.BlockExpression)expression));

            case CodeType.TypeExpression:
                return(VisitTypeExpression((Ast.TypeExpression)expression));

            case CodeType.LambdaExpresion:
                return(VisitLambdaExpression((Ast.LambdaExpression)expression));

            case CodeType.LogicalExpression:
                return(VisitLogicalExpression((Ast.LogicalExpression)expression));

            case CodeType.BinaryExpression:
                return(VisitBinaryExpression((Ast.BinaryExpression)expression));

            case CodeType.LiteralExpression:
                return(VisitLiteralExpression((Ast.LiteralExpression)expression));

            case CodeType.MemberExpression:
                return(VisitMemberExpression((Ast.MemberExpression)expression));

            case CodeType.OrderbyExpression:
                return(VisitOrderbyExpression((Ast.OrderbyExpression)expression));
            }

            throw new ArgumentException("Expression type is not supported");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Invoked during execution of the query , with the
        /// pre populated expression tree.
        /// </summary>
        /// <param name="expression">Target expression block</param>
        /// <returns>Expected result</returns>
        public IEnumerable <T> Execute(Ast.Expression expression)
        {
            //TODO: Visit the extender expression to build your meta

            this.Visit(expression);

            ///TOOD: return your result.
            return(null);
        }
Exemplo n.º 6
0
        public IEnumerable <T> Execute(LinqExtender.Ast.Expression expression)
        {
            this._currentExpression = expression;
            this.Visit(expression);

            var listingAction = new ToListAction <T>(this._metadataStore,
                                                     this._hydrator, this._connection, _dialect, _environment);

            var entities = listingAction.GetListing(this.CurrentStatement, this._parameters);

            return(entities);
        }
Exemplo n.º 7
0
 IEnumerable <T> IQueryContext <T> .Execute(Ast.Expression exprssion)
 {
     return(queryContext.Execute(exprssion));
 }