コード例 #1
0
        private IValue GetIValueFromDslToken()
        {
            IValue    returnValue = null;
            DslObject obj         = GetObject(_lookaheadFirst);

            if (obj == DslObject.Variable)
            {
                returnValue = new VariableValue();
                var varName = _lookaheadFirst.Value;
                if (varName.StartsWith("[") && varName.EndsWith("]"))
                {
                    varName = varName.Remove(varName.Length - 1).Substring(1);
                }
                (returnValue as VariableValue).VariableName = varName;
                DiscardToken();
            }
            else if (obj == DslObject.FixedValue)
            {
                returnValue = new FixedValue();
                (returnValue as FixedValue).Value = _lookaheadFirst.Value;
                DiscardToken();
            }
            else if (obj == DslObject.NULL)
            {
                returnValue = new NullValue();
                DiscardToken();
            }
            else if (obj == DslObject.DataType)
            {
                returnValue = new DataTypeValue();
                (returnValue as DataTypeValue).TypeName = _lookaheadFirst.Value;
                DiscardToken();
            }
            else if (obj == DslObject.Function)
            {
                returnValue = new FunctionCallValue();
                var x = returnValue as FunctionCallValue;
                x.FunctionName = _lookaheadFirst.Value.Remove(_lookaheadFirst.Value.Length - 1);
                DiscardToken();
                while (_lookaheadFirst.TokenType != TokenType.CloseParenthesis)
                {
                    x.Parameters.Add(GetIValueFromDslToken());
                    if (!(_lookaheadFirst.TokenType == TokenType.Comma || _lookaheadFirst.TokenType == TokenType.CloseParenthesis))
                    {
                        throw new ArgumentException(", or ) expected " + _lookaheadFirst.Value + " found");
                    }
                    if (_lookaheadFirst.TokenType == TokenType.Comma)
                    {
                        DiscardToken();
                    }
                }
                DiscardToken();
            }

            return(returnValue);
        }
コード例 #2
0
        private void AddParameter(DslObject dslObject, string value)
        {
            IncrementParamCounter();
            var paramName = GetParameterName();

            _sb.Append(paramName);

            var parameter = new SqlParameter(paramName, SqlDbType.VarChar, GetVarcharLength(dslObject));

            parameter.Value = value;
            Parameters.Add(parameter);
        }
コード例 #3
0
        private void AddInParameters(DslObject dslObject, List <string> values)
        {
            int counter = 0;

            foreach (var value in values)
            {
                if (counter > 0)
                {
                    _sb.Append(",");
                }

                IncrementParamCounter();
                var paramName = GetParameterName();
                var parameter = new SqlParameter(paramName, SqlDbType.VarChar, GetVarcharLength(dslObject));
                parameter.Value = value;
                Parameters.Add(parameter);
                _sb.Append(paramName);

                counter++;
            }
        }
コード例 #4
0
        private int GetVarcharLength(DslObject dslObject)
        {
            switch (dslObject)
            {
            case DslObject.Application:
                return(200);

            case DslObject.StackFrame:
                return(1000);

            case DslObject.ExceptionType:
                return(200);

            case DslObject.Message:
                return(1000);

            case DslObject.Fingerprint:
                return(32);

            default:
                return(50);
            }
        }
コード例 #5
0
        private string GetColumnName(DslObject dslObject)
        {
            switch (dslObject)
            {
            case DslObject.Application:
                return("ED.ApplicationId");

            case DslObject.Fingerprint:
                return("ED.FingerprintText");

            case DslObject.StackFrame:
                return("EB.StackFrame");

            case DslObject.ExceptionType:
                return("EB.ExceptionType");

            case DslObject.Message:
                return("T.MessageDetails");

            default:
                throw new Exception("LQL object not supported for SQL generation: " + dslObject.ToString());
            }
        }
コード例 #6
0
 public void AppendColumnName(DslObject dslObject)
 {
     _sb.Append(GetColumnName(dslObject));
 }