using System; using nrsnetcli; using nrsnetclasses; namespace nrsnetcliexample { /// /// Summary description for Example. /// class Example { /// /// The main entry point for the application. /// static void Main(string[] args) { nrsnetcli.Connection c = new nrsnetcli.Connection(); c.open("192.168.0.114",2012); nrsnetcli.Statement sql = c.createStatement("select * from NewsGroup"); nrsnetcli.Statement catsql = c.createStatement("select * from Category where current = %ref"); nrsnetcli.Statement wordsql = c.createStatement("select * from UrlWord where sWord like %word"); nrsnetcli.Statement hitsql = c.createStatement("select * from WebDoc where current = %urlref"); wordsql.setString("%word", "page%"); nrsnetcli.ObjectSet wordrecord = wordsql.fetch(); UrlWord word = (UrlWord)wordrecord.getNext(); int i = word.setHits.Length; int x = 0; while (x < i) { // search results are packed into a long. long hit = word.setHits[x]; int hitref = (int)hit; uint hitrid = (uint)(hit >> 32); uint hitweight = (uint)(hitrid & 0xFF000000 >> 24); hitrid = hitrid & 0x00FFFFFF; hitsql.setRef("%urlref", new Reference(hitref)); nrsnetcli.ObjectSet urlrecord = hitsql.fetch(); // following only works in NRS Open Directory // other products need to retrieve the record from a WebDoc object instead of Url object WebDoc wd = (WebDoc)urlrecord.getNext(); Console.WriteLine(wd.sUrl); urlrecord.close(); x++; } wordrecord.close(); nrsnetcli.ObjectSet records = sql.fetch(); while (true) { NewsGroup ng = (NewsGroup)records.getNext(); if (ng == null) break; Console.WriteLine(ng.sName); } records.close(); sql.close(); sql = c.createStatement("select * from Url"); records = sql.fetch(); while (true) { Url url = (Url)records.getNext(); if (url == null) break; catsql.setRef("%ref",url.pCat); nrsnetcli.ObjectSet catrecord = catsql.fetch(); Category cat = (Category)catrecord.getNext(); catrecord.close(); Console.WriteLine(url.sUrl); } records.close(); sql.close(); hitsql.close(); catsql.close(); wordsql.close(); c.commit(); c.close(); } } }