Exemplo n.º 1
0
        public List <Page> Execute()
        {
            List <Page> pages         = new List <Page>();
            XmlDocument rqlXml        = new XmlDocument();
            XmlElement  ioDataElement = rqlXml.CreateElement("IODATA");
            XmlElement  pageElement   = rqlXml.CreateElement("PAGE");

            pageElement.SetAttribute("action", "search");
            pageElement.SetAttribute("flags", PageType.ToString());
            pageElement.SetAttribute("maxrecords", MaxRecords.ToString());
            if (Headline != null)
            {
                pageElement.SetAttribute("headline", Headline);
                pageElement.SetAttribute("headlinelike", HeadlineExact ? "0" : "-1");
            }
            if (Category != null)
            {
                pageElement.SetAttribute("section", Category);
            }
            if (Keyword != null)
            {
                pageElement.SetAttribute("keyword", Keyword);
                pageElement.SetAttribute("keywordlike", KeywordExact ? "0" : "-1");
            }
            if (Text != null)
            {
                pageElement.SetAttribute("searchtext", Text);
            }
            if (PageIdFrom != -1)
            {
                pageElement.SetAttribute("pageidfrom", PageIdFrom.ToString());
            }
            if (PageIdTo != -1)
            {
                pageElement.SetAttribute("pageidto", PageIdTo.ToString());
            }
            if (CreatedTo != DateTime.MinValue)
            {
                pageElement.SetAttribute("createdateto", ((int)CreatedTo.ToOADate()).ToString());
            }
            if (CreatedFrom != DateTime.MinValue)
            {
                pageElement.SetAttribute("createdatefrom", CreatedFrom.ToString());
            }
            if (Template != null)
            {
                pageElement.SetAttribute("templateguid", Template.GuidString);
            }
            ioDataElement.AppendChild(pageElement);
            rqlXml.AppendChild(ioDataElement);
            _xmlDoc.LoadXml(Session.Execute(rqlXml));
            XmlNodeList xmlNodes = _xmlDoc.GetElementsByTagName("PAGE");

            foreach (XmlNode xmlNode in xmlNodes)
            {
                pages.Add(new Page(xmlNode));
            }
            return(pages);
        }
 public string ToQueryString()
 {
     return("?" + string.Join("&",
                              ConcatPair("SearchText", SearchText),
                              ConcatPair("StartIndex", StartIndex),
                              ConcatPair("MaxItems", MaxItems),
                              ConcatPair("OrderAsc", OrderAsc ? "true" : "false"),
                              ConcatPair("CreatedFrom", CreatedFrom?.ToString("yyyy-MM-dd") ?? ""),
                              ConcatPair("CreatedTo", CreatedTo?.ToString("yyyy-MM-dd") ?? "")));
 }