Пример #1
0
 internal static void AppendKeywordOrClause(StringBuilder query, PropertyKeyword keyword, ICollection <string> valuesToQuery)
 {
     EnumValidator.ThrowIfInvalid <PropertyKeyword>(keyword);
     if (valuesToQuery != null && valuesToQuery.Count > 0)
     {
         bool flag = false;
         foreach (string value in valuesToQuery)
         {
             if (!string.IsNullOrEmpty(value))
             {
                 if (!flag)
                 {
                     flag = true;
                     AqsQueryBuilder.AppendLeadingSpaceIfNecessary(query);
                     query.Append(keyword.ToString().ToLower()).Append(":(");
                 }
                 else
                 {
                     query.Append(AqsQueryBuilder.AqsQueryORSeparator);
                 }
                 query.Append("\"").Append(value).Append("\"");
             }
         }
         if (flag)
         {
             query.Append(")");
         }
     }
 }
Пример #2
0
        internal static void AppendDateClause(StringBuilder query, PropertyKeyword keyword, DateRangeQueryOperation operation, DateTime date)
        {
            EnumValidator.ThrowIfInvalid <PropertyKeyword>(keyword, AqsQueryBuilder.ValidDateKeywords);
            EnumValidator.ThrowIfInvalid <DateRangeQueryOperation>(operation);
            AqsQueryBuilder.AppendLeadingSpaceIfNecessary(query);
            query.Append(keyword.ToString().ToLower()).Append(":(");
            switch (operation)
            {
            case DateRangeQueryOperation.Equal:
                query.Append("=");
                break;

            case DateRangeQueryOperation.GreaterThan:
                query.Append(">");
                break;

            case DateRangeQueryOperation.GreaterThanOrEqual:
                query.Append(">=");
                break;

            case DateRangeQueryOperation.LessThan:
                query.Append("<");
                break;

            case DateRangeQueryOperation.LessThanOrEqual:
                query.Append("<=");
                break;
            }
            query.Append(date.ToLocalTime().ToString(AqsQueryBuilder.AqsDateTimeFormat, CultureInfo.InvariantCulture));
            query.Append(")");
        }
Пример #3
0
            private IEnumerable <ItemType> FindItemsPaged()
            {
                QueryStringType searchQueryStringToUse = this.queryString;
                bool            keepLooking;

                do
                {
                    keepLooking = false;
                    ItemType[] items;
                    if (this.queryString != null)
                    {
                        items = this.auditLog.ewsClient.FindItemsWithFAST(this.auditLog.auditFolderId, null, EwsAuditLog.EwsAuditLogQueryContext.SortByReceivedTime, searchQueryStringToUse);
                    }
                    else
                    {
                        items = this.auditLog.ewsClient.FindItems(this.auditLog.auditFolderId, null, EwsAuditLog.EwsAuditLogQueryContext.SortByReceivedTime, this.queryFilter);
                    }
                    DateTime?earliestReceivedTime = null;
                    bool     useLessOrEqualFilter = false;
                    if (this.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        this.Tracer.TraceDebug <int>(0L, "Query results returned: {0}.", items.Length);
                    }
                    if (EwsAuditLog.EwsAuditLogQueryContext.IsSearchResultLimitedByFast(this.queryString, items))
                    {
                        if (this.IsTraceEnabled(TraceType.DebugTrace))
                        {
                            this.Tracer.TraceDebug(0L, "Query results may be limited by FAST.");
                        }
                        if (items[items.Length - 1].DateTimeReceivedSpecified)
                        {
                            earliestReceivedTime = new DateTime?(items[items.Length - 1].DateTimeReceived);
                            useLessOrEqualFilter = (items[0].DateTimeReceived != earliestReceivedTime.Value);
                            keepLooking          = true;
                            if (this.IsTraceEnabled(TraceType.DebugTrace))
                            {
                                this.Tracer.TraceDebug <DateTime?, bool>(0L, "Earliest item seen=[{0}] useLessOrEqualFilter=[{1}].", earliestReceivedTime, useLessOrEqualFilter);
                            }
                        }
                    }
                    foreach (ItemType item in items)
                    {
                        yield return(item);
                    }
                    if (keepLooking)
                    {
                        searchQueryStringToUse = null;
                        if (this.queryString != null && this.queryString.Value != null && earliestReceivedTime != null)
                        {
                            ExDateTime    exDateTime    = new ExDateTime(ExTimeZone.UtcTimeZone, earliestReceivedTime.Value);
                            StringBuilder stringBuilder = new StringBuilder(this.queryString.Value);
                            AqsQueryBuilder.AppendDateClause(stringBuilder, PropertyKeyword.Received, useLessOrEqualFilter ? DateRangeQueryOperation.LessThanOrEqual : DateRangeQueryOperation.LessThan, exDateTime.UniversalTime);
                            searchQueryStringToUse = new QueryStringType
                            {
                                Value = stringBuilder.ToString()
                            };
                        }
                        keepLooking = (searchQueryStringToUse != null);
                    }
                    if (this.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        this.Tracer.TraceDebug <bool>(0L, "Make another query: [{0}]", keepLooking);
                    }
                }while (keepLooking);
                yield break;
            }