Esempio n. 1
0
        private void AddMatchConditionGroups(AdoQueryPayload queryPayload, List<MatchConditionGroup> matchConditionGroups, DateRange dateRange, List<string> servers)
        {
            for (int i = 0; i < matchConditionGroups.Count; i++)
            {
                if(i == 0)
                    AddLogicalOperator(queryPayload, LqlLogicalOperator.And);
                else
                    AddLogicalOperator(queryPayload, matchConditionGroups[i-1].LogicalOperatorToNextGroup);

                AddMatchConditionGroup(queryPayload, matchConditionGroups[i], dateRange, servers);
            }
        }
Esempio n. 2
0
 private void AddDateRangeClause(AdoQueryPayload queryPayload, DateRange dateRange, string tableAlias)
 {
     queryPayload.Append(tableAlias + ".OccurredAt BETWEEN ");
     queryPayload.AddFromDateParameter(dateRange.From);
     queryPayload.Append(" AND ");
     queryPayload.AddToDateParameter(dateRange.To);
     queryPayload.AddNewLine();
 }
Esempio n. 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);
        }
Esempio n. 4
0
        private void AddUnionFilters(AdoQueryPayload queryPayload, MatchCondition matchCondition, DateRange dateRange, List<string> servers)
        {
            AddServerJoin(queryPayload, servers);
            
            if (matchCondition.Object == LqlObject.Application || matchCondition.Object == LqlObject.Fingerprint)
            {
                queryPayload.AppendLine("JOIN ErrorDefinition ED WITH (NOLOCK) ON T.Fingerprint = ED.Fingerprint");
                queryPayload.Append("WHERE ");
            }
            else if (matchCondition.Object == LqlObject.ExceptionType || matchCondition.Object == LqlObject.StackFrame)
            {
                queryPayload.AppendLine("JOIN ErrorBreakdown EB WITH (NOLOCK) ON EB.Fingerprint = T.Fingerprint");
                queryPayload.Append("WHERE ");
            }
            else if (matchCondition.Object == LqlObject.Message)
            {
                queryPayload.Append("WHERE ");
                AddDateRangeClause(queryPayload, dateRange, "T");
                queryPayload.AddNewLine();
                queryPayload.Append("AND ");
            }
            else
                throw new SqlGenerationException("Non supported object type: " + matchCondition.Object);

            AddServersClause(queryPayload, servers, true);
            queryPayload.AddNewLine();
            queryPayload.Append("AND ");
            AddSingleClause(matchCondition, queryPayload);
        }
Esempio n. 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++;
     }
 }
Esempio n. 6
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(")");
        }