Beispiel #1
0
        // Token: 0x06000028 RID: 40 RVA: 0x000033A8 File Offset: 0x000015A8
        public static LogEvaluator FromCondition(LogCondition condition, CsvTable table)
        {
            Dictionary <string, LogVariableEvaluator> variables = new Dictionary <string, LogVariableEvaluator>();
            LogEvaluator logEvaluator = LogEvaluator.FromCondition(condition, table, variables, 100);

            LogEvaluator.CheckOptimization(condition, logEvaluator.searches, table.IndexedFields, 0);
            return(logEvaluator);
        }
Beispiel #2
0
        // Token: 0x060000F0 RID: 240 RVA: 0x00006E80 File Offset: 0x00005080
        public void SetQuery(LogQuery query)
        {
            ExTraceGlobals.ServiceTracer.TraceDebug((long)this.GetHashCode(), "MsExchangeLogSearch LogSession SetQuery");
            LogEvaluator evaluator = LogEvaluator.FromCondition(query.Filter, this.log.Table);
            LogFilter    filter    = new LogFilter(this.log, this.schemaVersion, evaluator, query.Beginning, query.End);

            this.search = new LogBackgroundReader(filter, 32768);
        }
Beispiel #3
0
        // Token: 0x0600002D RID: 45 RVA: 0x000035B8 File Offset: 0x000017B8
        private static LogEvaluator FromCondition(LogCondition condition, CsvTable table, Dictionary <string, LogVariableEvaluator> variables, int depthAllowed)
        {
            if (depthAllowed == 0)
            {
                throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_QUERY_TOO_COMPLEX);
            }
            if (condition == null)
            {
                throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_MISSING_QUERY_CONDITION);
            }
            if (condition is LogTrueCondition)
            {
                return(LogEvaluator.True);
            }
            if (condition is LogFalseCondition)
            {
                return(LogEvaluator.False);
            }
            LogCompoundCondition logCompoundCondition = condition as LogCompoundCondition;

            if (logCompoundCondition != null)
            {
                LogCompoundEvaluator logCompoundEvaluator;
                if (logCompoundCondition is LogAndCondition)
                {
                    logCompoundEvaluator = new LogAndEvaluator();
                }
                else
                {
                    if (!(logCompoundCondition is LogOrCondition))
                    {
                        throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_INVALID_QUERY_CONDITION);
                    }
                    logCompoundEvaluator = new LogOrEvaluator();
                }
                foreach (LogCondition condition2 in logCompoundCondition.Conditions)
                {
                    logCompoundEvaluator.Conditions.Add(LogEvaluator.FromCondition(condition2, table, variables, depthAllowed - 1));
                }
                return(logCompoundEvaluator);
            }
            LogUnaryCondition logUnaryCondition = condition as LogUnaryCondition;

            if (logUnaryCondition != null)
            {
                LogUnaryEvaluator      logUnaryEvaluator      = null;
                LogQuantifierCondition logQuantifierCondition = condition as LogQuantifierCondition;
                if (logQuantifierCondition != null)
                {
                    LogQuantifierEvaluator logQuantifierEvaluator;
                    if (logQuantifierCondition is LogForAnyCondition)
                    {
                        logQuantifierEvaluator = new LogForAnyEvaluator();
                    }
                    else
                    {
                        if (!(logQuantifierCondition is LogForEveryCondition))
                        {
                            throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_INVALID_QUERY_CONDITION);
                        }
                        logQuantifierEvaluator = new LogForEveryEvaluator();
                    }
                    if (logQuantifierCondition.Field.Name == null)
                    {
                        throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_UNRECOGNIZED_QUERY_FIELD);
                    }
                    logQuantifierEvaluator.FieldIndex = table.NameToIndex(logQuantifierCondition.Field.Name);
                    if (logQuantifierEvaluator.FieldIndex == -1)
                    {
                        throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_UNRECOGNIZED_QUERY_FIELD);
                    }
                    Type type = table.Fields[logQuantifierEvaluator.FieldIndex].Type;
                    if (!type.IsArray)
                    {
                        throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_INCOMPATIBLE_QUERY_OPERAND_TYPES);
                    }
                    if (logQuantifierCondition.Variable.Name == null)
                    {
                        throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_MISSING_BOUND_VARIABLE_NAME);
                    }
                    if (variables.ContainsKey(logQuantifierCondition.Variable.Name))
                    {
                        throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_DUPLICATE_BOUND_VARIABLE_DECLARATION);
                    }
                    logQuantifierEvaluator.Variable = new LogVariableEvaluator();
                    logQuantifierEvaluator.Variable.BoundFieldIndex = logQuantifierEvaluator.FieldIndex;
                    variables.Add(logQuantifierCondition.Variable.Name, logQuantifierEvaluator.Variable);
                    logUnaryEvaluator = logQuantifierEvaluator;
                }
                else if (logUnaryCondition is LogNotCondition)
                {
                    logUnaryEvaluator = new LogNotEvaluator();
                }
                logUnaryEvaluator.Condition = LogEvaluator.FromCondition(logUnaryCondition.Condition, table, variables, depthAllowed - 1);
                if (logQuantifierCondition != null)
                {
                    variables.Remove(logQuantifierCondition.Variable.Name);
                }
                return(logUnaryEvaluator);
            }
            LogBinaryOperatorCondition logBinaryOperatorCondition = condition as LogBinaryOperatorCondition;

            if (logBinaryOperatorCondition != null)
            {
                bool convertToUppercase = false;
                LogComparisonCondition     logComparisonCondition = logBinaryOperatorCondition as LogComparisonCondition;
                LogBinaryOperatorEvaluator logBinaryOperatorEvaluator;
                if (logComparisonCondition != null)
                {
                    LogStringComparisonCondition logStringComparisonCondition = logComparisonCondition as LogStringComparisonCondition;
                    LogComparisonEvaluator       logComparisonEvaluator;
                    if (logStringComparisonCondition != null)
                    {
                        LogStringComparisonEvaluator logStringComparisonEvaluator = new LogStringComparisonEvaluator();
                        convertToUppercase = logStringComparisonCondition.IgnoreCase;
                        logStringComparisonEvaluator.IgnoreCase = logStringComparisonCondition.IgnoreCase;
                        logComparisonEvaluator = logStringComparisonEvaluator;
                    }
                    else
                    {
                        logComparisonEvaluator = new LogComparisonEvaluator();
                    }
                    logComparisonEvaluator.Operator = logComparisonCondition.Operator;
                    logBinaryOperatorEvaluator      = logComparisonEvaluator;
                }
                else
                {
                    if (!(logBinaryOperatorCondition is LogBinaryStringOperatorCondition))
                    {
                        throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_INVALID_QUERY_CONDITION);
                    }
                    LogBinaryStringOperatorEvaluator logBinaryStringOperatorEvaluator;
                    if (logBinaryOperatorCondition is LogStringStartsWithCondition)
                    {
                        logBinaryStringOperatorEvaluator = new LogStringStartsWithEvaluator();
                    }
                    else if (logBinaryOperatorCondition is LogStringEndsWithCondition)
                    {
                        logBinaryStringOperatorEvaluator = new LogStringEndsWithEvaluator();
                    }
                    else
                    {
                        if (!(logBinaryOperatorCondition is LogStringContainsCondition))
                        {
                            throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_INVALID_QUERY_CONDITION);
                        }
                        logBinaryStringOperatorEvaluator = new LogStringContainsEvaluator();
                    }
                    convertToUppercase = ((LogBinaryStringOperatorCondition)logBinaryOperatorCondition).IgnoreCase;
                    logBinaryStringOperatorEvaluator.IgnoreCase = ((LogBinaryStringOperatorCondition)logBinaryOperatorCondition).IgnoreCase;
                    logBinaryOperatorEvaluator = logBinaryStringOperatorEvaluator;
                }
                logBinaryOperatorEvaluator.Left  = LogEvaluator.FromConditionOperand(logBinaryOperatorCondition.Left, table, variables, convertToUppercase);
                logBinaryOperatorEvaluator.Right = LogEvaluator.FromConditionOperand(logBinaryOperatorCondition.Right, table, variables, convertToUppercase);
                Type valueType  = logBinaryOperatorEvaluator.Left.GetValueType(table);
                Type valueType2 = logBinaryOperatorEvaluator.Right.GetValueType(table);
                if (valueType != valueType2)
                {
                    throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_INCOMPATIBLE_QUERY_OPERAND_TYPES);
                }
                return(logBinaryOperatorEvaluator);
            }
            else
            {
                LogUnaryOperatorCondition logUnaryOperatorCondition = condition as LogUnaryOperatorCondition;
                if (logUnaryOperatorCondition == null)
                {
                    throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_INVALID_QUERY_CONDITION);
                }
                if (logUnaryOperatorCondition is LogIsNullOrEmptyCondition)
                {
                    return(new LogIsNullOrEmptyEvaluator
                    {
                        Operand = LogEvaluator.FromConditionOperand(logUnaryOperatorCondition.Operand, table, variables, false)
                    });
                }
                throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_INVALID_QUERY_CONDITION);
            }
        }