Exemple #1
0
        private static void ProcessSearchQueries(XmlTextWriter writer, string complexSearchXmlPath)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(complexSearchXmlPath);

            string      xpathQuery = "queries/query";
            XmlNodeList queryNodes = doc.SelectNodes(xpathQuery);

            foreach (XmlNode queryNode in queryNodes)
            {
                string       username            = queryNode.GetChildText("username");
                int          maxResults          = 10;
                XmlAttribute maxResultsAttribute = queryNode.Attributes["max-results"];
                if (maxResultsAttribute != null)
                {
                    maxResults = int.Parse(maxResultsAttribute.InnerText);
                }

                List <string> tags = new List <string>();
                foreach (XmlNode tag in queryNode.SelectNodes("tag"))
                {
                    tags.Add(tag.InnerText.Trim());
                }

                var bookmarks = BookmarksDAO.FindBookmarks(username, tags, maxResults);

                WriteBookmark(writer, bookmarks);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            BookmarksEntities context = new BookmarksEntities();

            using (context)
            {
                string      simpleSearchXmlPath = @"..\..\simple-query.xml";
                XmlDocument doc = new XmlDocument();
                doc.Load(simpleSearchXmlPath);
                string xpathQuery = "query";

                XmlNode bookmarkNode = doc.SelectSingleNode(xpathQuery);

                string  username     = null;
                XmlNode usernameNode = bookmarkNode.SelectSingleNode("username");
                if (usernameNode != null)
                {
                    username = usernameNode.InnerText;
                }

                string  tag     = null;
                XmlNode tagNode = bookmarkNode.SelectSingleNode("tag");
                if (tagNode != null)
                {
                    tag = tagNode.InnerText;
                }

                IEnumerable <Bookmark> bookmarks = BookmarksDAO.FindBookmarksByUsernameAndTag(context, username, tag);
                if (bookmarks.Count() > 0)
                {
                    foreach (var bookmark in bookmarks)
                    {
                        Console.WriteLine(bookmark.URL);
                    }
                }
                else
                {
                    Console.WriteLine("Nothing found");
                }
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            string bookmarksXmlPath = @"..\..\bookmarks.xml";

            BookmarksDAO.ImportXmlIntoDatabase(bookmarksXmlPath);
        }