示例#1
0
        /// <summary>
        /// Allocate ResultsPages
        /// </summary>
        /// <returns></returns>

        public ResultsPages NewResultsPages(Query rootQuery)
        {
            ResultsPages pages = new ResultsPages();

            pages.RootQuery = rootQuery;
            return(pages);
        }
示例#2
0
        /// <summary>
        /// Remove any subqueries that have no views remaining
        /// </summary>
        /// <param name="q"></param>

        public void RemoveSubqueriesWithNoViews(Query q)
        {
            int pi;

            q.NormalizeQueryIds();

            Dictionary <int, object> queryDict = new Dictionary <int, object>();

            ResultsPages pages = q.ResultsPages;

            foreach (ResultsPage rp in pages.Pages)
            {
                foreach (ResultsViewProps v in rp.Views)
                {
                    queryDict[v.BaseQuery.InstanceId] = null;
                }
            }

            int sqi = 0;

            while (sqi < q.Subqueries.Count)
            {
                if (queryDict.ContainsKey(q.InstanceId))
                {
                    sqi++;
                }
                else
                {
                    q.Subqueries.RemoveAt(sqi);
                }
            }

            return;
        }
示例#3
0
/// <summary>
/// Add a new page for the specified query
/// </summary>
/// <param name="query"></param>
/// <returns></returns>

        public static ResultsPage AddNewPage(
            Query query)
        {
            int max, intVal;

            ResultsPages pages = query.Root.ResultsPages;

            if (pages == null)
            {
                pages = new ResultsPages();
                query.Root.ResultsPages = pages;
            }

            ResultsPage page = pages.AddNewPage();

            return(page);
        }
示例#4
0
        /// <summary>
        /// Deserialize the results pages in a query
        /// </summary>
        /// <param name="tr"></param>
        /// <returns></returns>

        public static ResultsPages Deserialize(Query q, XmlTextReader tr)
        {
            ResultsPages pages = new ResultsPages();

            pages.RootQuery = q;

            if (!Lex.Eq(tr.Name, "ResultsPages"))
            {
                throw new Exception("ResultsPages element not found");
            }

            if (tr.IsEmptyElement)
            {
                return(pages);                               // no pages
            }
            while (true)
            {
                tr.Read(); tr.MoveToContent();

                if (tr.NodeType == XmlNodeType.EndElement && Lex.Eq(tr.Name, "ResultsPages"))
                {
                    break;
                }

                ResultsPage page = ResultsPage.Deserialize(q, tr);

                if (pages.Pages.Count == 1 && Query.DeserializeTruncateToSingleResultsPage)
                {
                    continue;
                }

                pages.AddPage(page);
            }

            return(pages);
        }