Example #1
0
        private IEnumerable <int> GetIdResultsWithLucQuery(int top, int skip, IEnumerable <SortInfo> sort,
                                                           FilterStatus enableAutofilters, FilterStatus enableLifespanFilter, QueryExecutionMode executionMode)
        {
            var queryText = Text;

            if (!queryText.Contains("}}"))
            {
                LucQuery query;

                try
                {
                    query = LucQuery.Parse(queryText);
                }
                catch (ParserException ex)
                {
                    throw new InvalidContentQueryException(queryText, innerException: ex);
                }

                if (skip != 0)
                {
                    query.Skip = skip;
                }

                query.Top = System.Math.Min(top == 0 ? int.MaxValue : top, query.Top == 0 ? int.MaxValue : query.Top);
                if (query.Top == 0)
                {
                    query.Top = GetDefaultMaxResults();
                }

                query.PageSize = query.Top;

                if (sort != null && sort.Count() > 0)
                {
                    query.SetSort(sort);
                }

                if (enableAutofilters != FilterStatus.Default)
                {
                    query.EnableAutofilters = enableAutofilters;
                }
                if (enableLifespanFilter != FilterStatus.Default)
                {
                    query.EnableLifespanFilter = enableLifespanFilter;
                }
                if (executionMode != QueryExecutionMode.Default)
                {
                    query.QueryExecutionMode = executionMode;
                }

                // Re-set settings values. This is important for NodeList that
                // uses the paging info written into the query text.
                this.Settings.Top  = query.PageSize;
                this.Settings.Skip = query.Skip;

                var lucObjects = query.Execute().ToList();

                TotalCount = query.TotalCount;

                return((from luco in lucObjects
                        select luco.NodeId).ToList());
            }
            else
            {
                List <string> log;
                int           count;
                var           result = RecursiveExecutor.ExecuteRecursive(queryText, top, skip,
                                                                          sort, enableAutofilters, enableLifespanFilter, executionMode, this.Settings, out count, out log);

                TotalCount = count;

                return(result);
            }
        }
Example #2
0
        private IEnumerable <int> GetIdResultsWithLucQuery(int top, int skip, IEnumerable <SortInfo> sort,
                                                           bool?enableAutofilters, bool?enableLifespanFilter)
        {
            var queryText = Text;

            if (!queryText.Contains("}}"))
            {
                var query = LucQuery.Parse(queryText);
                if (skip != 0)
                {
                    query.Skip = skip;
                }

                query.Top = System.Math.Min(top == 0 ? int.MaxValue : top, query.Top == 0 ? int.MaxValue : query.Top);
                if (query.Top == 0)
                {
                    query.Top = GetDefaultMaxResults();
                }

                query.PageSize = query.Top;

                if (sort != null && sort.Count() > 0)
                {
                    query.SetSort(sort);
                }

                if (enableAutofilters.HasValue)
                {
                    query.EnableAutofilters = enableAutofilters.Value;
                }
                if (enableLifespanFilter.HasValue)
                {
                    query.EnableLifespanFilter = enableLifespanFilter.Value;
                }

                //Re-set settings values. This is important for NodeList that
                //uses the paging info written into the query text.
                this.Settings.Top  = query.PageSize;
                this.Settings.Skip = query.Skip;
                //this.Settings.Sort = we don't need this

                this.TraceInfo = new[] { query.TraceInfo };

                var lucObjects = query.Execute().ToList();

                TotalCount = query.TotalCount;

                return((from luco in lucObjects
                        select luco.NodeId).ToList());
            }
            else
            {
                List <string> log;
                int           count;
                IEnumerable <QueryTraceInfo> traceInfo;
                var result = RecursiveExecutor.ExecuteRecursive(queryText, top, skip,
                                                                sort, enableAutofilters, enableLifespanFilter, this.Settings, out count, out log, out traceInfo);

                TotalCount = count;

                this.TraceInfo = traceInfo;

                return(result);
            }
        }