Beispiel #1
0
 private bool IsDefinitionGroup(MatchConditionGroup matchConditionGroup)
 {
     return matchConditionGroup.MatchConditions.All(x => x.Object == LqlObject.Application
         || x.Object == LqlObject.ExceptionType
         || x.Object == LqlObject.StackFrame
         || x.Object == LqlObject.Fingerprint);
 }
Beispiel #2
0
 private bool HasFullTextSearchCompatibleConditions(MatchConditionGroup matchConditionGroup)
 {
     return matchConditionGroup.MatchConditions.Any(x => IsFullTextSearchCompatible(x.Object, x.Operator));
 }
Beispiel #3
0
        private void AddTimelineIdFilterSelectAndJoins(AdoQueryPayload queryPayload, MatchConditionGroup matchConditionGroup, DateRange dateRange, List<string> servers)
        {
            bool hasApplication = matchConditionGroup.MatchConditions.Any(x => x.Object == LqlObject.Application);
            bool hasExceptionType = matchConditionGroup.MatchConditions.Any(x => x.Object == LqlObject.ExceptionType);
            bool hasFingerprint = matchConditionGroup.MatchConditions.Any(x => x.Object == LqlObject.Fingerprint);
            bool hasStackFrame = matchConditionGroup.MatchConditions.Any(x => x.Object == LqlObject.StackFrame);

            queryPayload.AppendLine("   SELECT DISTINCT T.TimelineId FROM Timeline T WITH(NOLOCK)");
            
            if (hasApplication || hasFingerprint)
                queryPayload.AppendLine("   JOIN ErrorDefinition ED WITH(NOLOCK) ON T.Fingerprint = ED.Fingerprint");
            
            if (hasExceptionType || hasStackFrame)
                queryPayload.AppendLine("   JOIN ErrorBreakdown AS EB WITH(NOLOCK) ON T.Fingerprint = EB.Fingerprint");

            if (servers.Any())
            {
                queryPayload.Append("   ");
                AddServerJoin(queryPayload, servers);
            }

            queryPayload.Append("   WHERE ");
            AddDateRangeClause(queryPayload, dateRange, "T");
            AddServersClause(queryPayload, servers, true);
        }
Beispiel #4
0
        private void AddTimelineIdFilterWhereClauses(AdoQueryPayload queryPayload, MatchConditionGroup matchConditionGroup)
        {
            int clauseCounter = 1;
            foreach (var matchCondition in matchConditionGroup.MatchConditions)
            {
                if (clauseCounter == 1)
                    queryPayload.Append("   AND ");
                else
                    queryPayload.Append("   " + matchConditionGroup.LogicalOperator.ToString().ToUpper() + " ");

                AddSingleClause(matchCondition, queryPayload);
                clauseCounter++;
            }
        }
Beispiel #5
0
 private void AddFilterUnionSelects(AdoQueryPayload queryPayload, MatchConditionGroup matchConditionGroup, DateRange dateRange, List<string> servers)
 {
     int counter = 0;
     foreach (var matchCondition in matchConditionGroup.MatchConditions)
     {
         if (counter > 0)
             queryPayload.AppendLine(" UNION ALL ");
         
         queryPayload.AppendLine("SELECT T.TimelineId FROM Timeline T WITH(NOLOCK)");
         AddUnionFilters(queryPayload, matchCondition, dateRange, servers);
         counter++;
     }
 }
Beispiel #6
0
 private bool UseUnionsToAvoidFtsPerfIssue(MatchConditionGroup matchConditionGroup)
 {
     return HasFullTextSearchCompatibleConditions(matchConditionGroup) && matchConditionGroup.LogicalOperator == LqlLogicalOperator.Or;
 }
Beispiel #7
0
        private void AddDefinitionGroup(AdoQueryPayload queryPayload, MatchConditionGroup matchConditionGroup)
        {
            queryPayload.AppendLine("   SELECT DISTINCT ED.Fingerprint FROM ErrorDefinition ED WITH(NOLOCK)");

            if (matchConditionGroup.MatchConditions.Any(x => x.Object == LqlObject.ExceptionType || x.Object == LqlObject.StackFrame))
                queryPayload.AppendLine("   JOIN ErrorBreakdown AS EB WITH(NOLOCK) ON ED.Fingerprint = EB.Fingerprint");

            queryPayload.Append("   WHERE ");

            int conditionCounter = 1;
            foreach (var condition in matchConditionGroup.MatchConditions)
            {
                if (conditionCounter > 1)
                    queryPayload.Append("   " + matchConditionGroup.LogicalOperator.ToString().ToUpper() + " ");

                AddSingleClause(condition, queryPayload);
                conditionCounter++;
            }
        }
Beispiel #8
0
        private void AddMatchConditionGroup(AdoQueryPayload queryPayload, MatchConditionGroup matchConditionGroup, DateRange dateRange, List<string> servers)
        {
            if (matchConditionGroup.Exclude)
                queryPayload.Append(" NOT");

            if (IsDefinitionGroup(matchConditionGroup))
                queryPayload.AppendLine(" T.Fingerprint IN (");
            else
                queryPayload.AppendLine(" T.TimelineId IN (");

            if (IsDefinitionGroup(matchConditionGroup))
            {
                AddDefinitionGroup(queryPayload, matchConditionGroup);
            }
            else
            {
                if (UseUnionsToAvoidFtsPerfIssue(matchConditionGroup))
                {
                    AddFilterUnionSelects(queryPayload, matchConditionGroup, dateRange, servers);
                }
                else
                {
                    AddTimelineIdFilterSelectAndJoins(queryPayload, matchConditionGroup, dateRange, servers);
                    AddTimelineIdFilterWhereClauses(queryPayload, matchConditionGroup);
                }
            }
            
            queryPayload.AppendLine(")");
        }
Beispiel #9
0
        private void SetCurrentMatchConditionGroup()
        {
            if (_searchRequest.Groups == null)
            {
                _searchRequest.Groups = new List<MatchConditionGroup>();
            }

            var group = new MatchConditionGroup();
            _searchRequest.Groups.Add(group);
            _currentGroup = group;
        }