private void Search() { XmlDocument searchresults; Search.Utilities.DataIO data = new Profiles.Search.Utilities.DataIO(); List <EntityState> es = new List <EntityState>(); string searchuri = string.Empty; searchuri = ddlPropertyList.SelectedValue; searchresults = data.Search(data.SearchRequest(txtKeyword.Text.Trim(), "false", "", searchuri, "100", "0"), true); foreach (XmlNode x in searchresults.SelectNodes("SearchResults/Network/Connection")) { es.Add(new EntityState(x.InnerText, x.SelectSingleNode("@URI").Value)); } gridSearchResults.DataSource = es; gridSearchResults.DataBind(); pnlProxySearchResults.Visible = true; }
private void Search() { XmlDocument searchresults; Search.Utilities.DataIO data = new Profiles.Search.Utilities.DataIO(); List<EntityState> es = new List<EntityState>(); string searchuri = string.Empty; searchuri = ddlPropertyList.SelectedValue; searchresults = data.Search(data.SearchRequest(txtKeyword.Text.Trim(),"false", "", searchuri, "100", "0"), true); foreach (XmlNode x in searchresults.SelectNodes("SearchResults/Network/Connection")) { es.Add(new EntityState(x.InnerText, x.SelectSingleNode("@URI").Value)); } gridSearchResults.DataSource = es; gridSearchResults.DataBind(); pnlProxySearchResults.Visible = true; }
private XmlDocument Query(XmlDocument request) { Search.Utilities.DataIO data = new Profiles.Search.Utilities.DataIO(); return data.Search(request,false); }
protected void DrawUIOnLoad() { oDataIO = new DIRECT.Utilities.DataIO(); Profiles.DIRECT.Utilities.DataIO searchDataIO; Profiles.Search.Utilities.DataIO profileDataIO; string DirectServiceURL = Root.Domain + "/DIRECT/Modules/DirectSearch/directservice.aspx";// Request.Url.AbsoluteUri.Replace("&", "&"); string ProfilesURL = Root.Domain; string PopulationTypeText = oDataIO.GetDirectConfig().PopulationType; int QueryTimeout = oDataIO.GetDirectConfig().Timeout; XmlDocument query = new XmlDocument(); XmlDocument result; Framework.Utilities.Namespace rdfnamespaces = new Namespace(); XmlNamespaceManager namespaces = null; string sql = string.Empty; string ResultDetailsURL = string.Empty; string strResult = ""; SqlDataReader dr; if (Request["Request"] == null) { return; } string task = Request["Request"].ToLower(); switch (task) { case "getsites": string ResultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + "<site-list>"; dr = oDataIO.GetSitesOrderBySortOrder(); while (dr.Read()) { Int64 SiteID = Convert.ToInt64(dr["SiteID"]); string SiteName = dr["SiteName"].ToString(); string QueryURL = dr["QueryURL"].ToString(); if (SiteName == null) { SiteName = ""; } if (QueryURL == null) { QueryURL = ""; } ResultStr = ResultStr + "<site-description><site-id>" + SiteID + "</site-id><name>" + cx(SiteName) + "</name><aggregate-query>" + cx(QueryURL) + "</aggregate-query></site-description>"; } if (!dr.IsClosed) { dr.Close(); } ResultStr += "</site-list>"; Response.ContentType = "text/xml"; Response.AddHeader("Content-Type", "text/xml;charset=UTF-8"); //Response.ContentEncoding.CodePage = 65001; Response.Charset = "UTF-8"; Response.Write(ResultStr); break; case "incomingcount": string q = Request["SearchPhrase"].Trim(); // Enter log record sql = "insert into [Direct.].LogIncoming(Details,ReceivedDate,RequestIP,QueryString) " + " values (0,GetDate()," + cs(Request.ServerVariables["REMOTE_ADDR"]) + "," + cs(q) + ")"; oDataIO.ExecuteSQLDataCommand(sql); // Execute query string x = "<SearchOptions>" + "<MatchOptions>" + "<SearchString ExactMatch=\"false\">" + cx(q) + "</SearchString> " + "<SearchFiltersList /> " + "<ClassURI>http://xmlns.com/foaf/0.1/Person</ClassURI> " + "</MatchOptions>" + "<OutputOptions>" + "<Offset>0</Offset>" + "<Limit>1</Limit> " + "<SortByList>" + "</SortByList>" + "</OutputOptions>" + "</SearchOptions>"; query.LoadXml(x); profileDataIO = new Profiles.Search.Utilities.DataIO(); result = profileDataIO.Search(query, false); namespaces = rdfnamespaces.LoadNamespaces(result); string ResultCount = result.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText; // Form result message ResultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; ResultStr += "<aggregation-result>"; ResultStr += "<count>" + ResultCount + "</count>"; ResultStr += "<population-type>" + PopulationTypeText + "</population-type>"; ResultStr += "<preview-URL>" + DirectServiceURL + "?Request=IncomingPreview&SearchPhrase=" + cx(q) + "</preview-URL>"; ResultStr += "<search-results-URL>" + DirectServiceURL + "?Request=IncomingDetails&SearchPhrase=" + cx(q) + "</search-results-URL>"; ResultStr += "</aggregation-result>"; // Send result Response.ContentType = "text/xml"; Response.AddHeader("Content-Type", "text/xml;charset=UTF-8"); //Response.ContentEncoding.CodePage = 65001; Response.Charset = "UTF-8"; Response.Write(ResultStr); break; case "incomingdetails": q = Request["SearchPhrase"].Trim(); // Enter log record sql = "insert into [Direct.].LogIncoming(Details,ReceivedDate,RequestIP,QueryString) "; sql += " values (1,GetDate()," + cs(Request.ServerVariables["REMOTE_ADDR"]) + "," + cs(q) + ")"; oDataIO.ExecuteSQLDataCommand(sql); // Execute query query.LoadXml("<SearchOptions>" + "<MatchOptions>" + "<SearchString ExactMatch=\"false\">" + cx(q) + "</SearchString> " + "<SearchFiltersList /> " + "<ClassURI>http://xmlns.com/foaf/0.1/Person</ClassURI> " + "</MatchOptions>" + "<OutputOptions>" + "<Offset>0</Offset>" + "<Limit>1</Limit> " + "<SortByList>" + "</SortByList>" + "</OutputOptions>" + "</SearchOptions>"); profileDataIO = new Profiles.Search.Utilities.DataIO(); result = profileDataIO.Search(query, false); strResult = result.InnerXml; // Parse results XmlDocument objDoc = new XmlDocument(); objDoc = new XmlDocument(); objDoc.LoadXml(strResult); namespaces = rdfnamespaces.LoadNamespaces(result); ResultCount = result.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText; if (ProfilesURL.Substring(ProfilesURL.Length - 1) != "/") { ProfilesURL += "/"; } Response.Redirect(ProfilesURL + "search/default.aspx?searchtype=people&classuri=http://xmlns.com/foaf/0.1/Person&searchfor=" + q + "&exactPhrase=false"); break; case "incomingpreview": q = Request["SearchPhrase"].Trim(); Utilities.DataIO data = new Profiles.DIRECT.Utilities.DataIO(); string searchphrase = Request["SearchPhrase"].Trim(); Response.Write(data.Search(searchphrase)); break; case "outgoingcount": if (Request["blank"] == "y") { Response.Write("<html><body></body></html>"); Response.End(); } string SearchPhrase = Request["SearchPhrase"]; Response.Write("<script>parent.dsLoading=1;</script>" + Environment.NewLine); dr = oDataIO.GetSitesOrderBySiteID(); SiteIDs = new int[1000]; URLs = new string[1000]; FSIDs = new string[1000]; Site site; ListOfSites = new List <Site>(); Int64 sites = 0; List <AsyncProcessing> ListOfThreads = new List <AsyncProcessing>(); AsyncProcessing async; while (dr.Read()) { SiteIDs[sites] = Convert.ToInt32(dr["SiteID"].ToString()); URLs[sites] = dr["QueryURL"] + SearchPhrase; FSIDs[sites] = dr["FSID"].ToString(); site = new Site(URLs[sites], SiteIDs[sites], FSIDs[sites], SearchPhrase, HttpContext.Current); ListOfSites.Add(site); async = new AsyncProcessing(); async.BeginProcessRequest(site); ListOfThreads.Add(async); sites++; } if (!dr.IsClosed) { dr.Close(); } //eat up the CPU for x number of seconds :) so all the requests can come back. This is set in the web.config file DateTime end = DateTime.Now.AddSeconds(QueryTimeout); while (DateTime.Now < end) { } //close out anything that did not complete in 5 seconds for (int loop = 0; loop < ListOfThreads.Count; loop++) { if (!ListOfThreads[loop].Site.IsDone) { sql = "update [Direct.].LogOutgoing set ResponseTime = datediff(ms,SentDate,GetDate()), " + " ResponseState = " + 1 + " where FSID = " + cs(ListOfThreads[loop].Site.FSID); oDataIO.ExecuteSQLDataCommand(sql); Response.Write("<script>parent.siteResult(" + ListOfThreads[loop].Site.SiteID + ",1,0,'','','','');</script>"); ListOfThreads.Remove(ListOfThreads[loop]); } } try { Response.Flush(); } catch { } break; case "outgoingdetails": string FSID = Request["fsid"].Trim(); string SiteId = string.Empty; if (FSID != "") { dr = oDataIO.GetFsID(cs(FSID)); if (dr.Read()) { SiteId = dr["SiteID"].ToString(); ResultDetailsURL = dr["ResultDetailsURL"].ToString().Replace("\n\t", ""); } if (!dr.IsClosed) { dr.Close(); } } if ((FSID != "") && (SiteId != "") && (ResultDetailsURL != "")) { // Enter log record oDataIO.ExecuteSQLDataCommand("insert into [Direct.].LogOutgoing(FSID,SiteID,Details,SentDate) " + " values ('" + FSID + "'," + SiteId + ",1,GetDate())"); Response.Redirect(ResultDetailsURL); } else { Response.Redirect(ProfilesURL); } break; } Response.End(); }
private void DrawProfilesModule() { XsltArgumentList args = new XsltArgumentList(); string searchfor = string.Empty; string classgroupuri = string.Empty; string classuri = string.Empty; string searchrequest = string.Empty; string exactphrase = string.Empty; XmlDocument xmlsearchrequest; if (Request.QueryString["searchfor"] != null) { searchfor = Request.QueryString["searchfor"]; } else { searchfor = Request.Form["txtSearchFor"]; } if (Request.QueryString["classgroupuri"] != null) { classgroupuri = HttpUtility.UrlDecode(Request.QueryString["classgroupuri"]); } else { classgroupuri = HttpUtility.UrlDecode(Request.Form["classgroupuri"]); } if (classgroupuri != null) { if (classgroupuri.Contains("!")) { classgroupuri = classgroupuri.Replace('!', '#'); } } else { classgroupuri = string.Empty; } if (Request.QueryString["classuri"] != null) { classuri = HttpUtility.UrlDecode(Request.QueryString["classuri"]); } else { classuri = HttpUtility.UrlDecode(Request.Form["classuri"]); } if (classuri != null) { if (classuri.Contains("!")) { classuri = classuri.Replace('!', '#'); } } else { classuri = string.Empty; } Search.Utilities.DataIO data = new Profiles.Search.Utilities.DataIO(); if (Request.QueryString["searchrequest"] != null) { searchrequest = Request.QueryString["searchrequest"]; if (searchfor == null) { xmlsearchrequest = new XmlDocument(); xmlsearchrequest.LoadXml(data.DecryptRequest(searchrequest)); searchfor = xmlsearchrequest.SelectSingleNode("SearchOptions/MatchOptions/SearchString").InnerText; } } if (Request.QueryString["exactphrase"] != null) { exactphrase = Request.QueryString["exactphrase"]; } else { exactphrase = "false"; } //Grab the full results so I can get the counts, this comes from the cache cloud. this.SearchResults = data.Search(data.SearchRequest(searchfor, exactphrase, "", "", "0", "100"), false); Int64 total = 0; foreach (XmlNode x in this.SearchResults.SelectNodes("rdf:RDF/rdf:Description/vivo:overview/prns:matchesClassGroupsList/prns:matchesClassGroup", this.Namespaces)) { total += Convert.ToInt64(x.SelectSingleNode("prns:numberOfConnections", this.Namespaces).InnerText); } args.AddParam("total", "", total); args.AddParam("searchfor", "", searchfor); args.AddParam("exactphrase", "", exactphrase); args.AddParam("root", "", Root.Domain); args.AddParam("classGrpURIpassedin", "", classgroupuri); args.AddParam("classURIpassedin", "", classuri); XslCompiledTransform xslt = new XslCompiledTransform(); litEverythingPassiveResults.Text = XslHelper.TransformInMemory(Server.MapPath("~/Search/Modules/SearchEverythingFacets/SearchEverythingFacets.xslt"), args, this.SearchResults.OuterXml); }
protected void DrawUIOnLoad() { oDataIO = new DIRECT.Utilities.DataIO(); Profiles.DIRECT.Utilities.DataIO searchDataIO; Profiles.Search.Utilities.DataIO profileDataIO; string DirectServiceURL = Root.Domain + "/DIRECT/Modules/DirectSearch/directservice.aspx";// Request.Url.AbsoluteUri.Replace("&", "&"); string ProfilesURL = Root.Domain; string PopulationTypeText = oDataIO.GetDirectConfig().PopulationType; int QueryTimeout = oDataIO.GetDirectConfig().Timeout; XmlDocument query = new XmlDocument(); XmlDocument result; Framework.Utilities.Namespace rdfnamespaces = new Namespace(); XmlNamespaceManager namespaces = null; string sql = string.Empty; string ResultDetailsURL = string.Empty; string strResult = ""; SqlDataReader dr; if (Request["Request"] == null) { return; } string task = Request["Request"].ToLower(); switch (task) { case "getsites": string ResultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + "<site-list>"; dr = oDataIO.GetSitesOrderBySortOrder(); while (dr.Read()) { Int64 SiteID = Convert.ToInt64(dr["SiteID"]); string SiteName = dr["SiteName"].ToString(); string QueryURL = dr["QueryURL"].ToString(); if (SiteName == null) SiteName = ""; if (QueryURL == null) QueryURL = ""; ResultStr = ResultStr + "<site-description><site-id>" + SiteID + "</site-id><name>" + cx(SiteName) + "</name><aggregate-query>" + cx(QueryURL) + "</aggregate-query></site-description>"; } if (!dr.IsClosed) dr.Close(); ResultStr += "</site-list>"; Response.ContentType = "text/xml"; Response.AddHeader("Content-Type", "text/xml;charset=UTF-8"); //Response.ContentEncoding.CodePage = 65001; Response.Charset = "UTF-8"; Response.Write(ResultStr); break; case "incomingcount": string q = Request["SearchPhrase"].Trim(); // Enter log record sql = "insert into [Direct.].LogIncoming(Details,ReceivedDate,RequestIP,QueryString) " + " values (0,GetDate()," + cs(Request.ServerVariables["REMOTE_ADDR"]) + "," + cs(q) + ")"; oDataIO.ExecuteSQLDataCommand(sql); // Execute query string x = "<SearchOptions>" + "<MatchOptions>" + "<SearchString ExactMatch=\"false\">" + cx(q) + "</SearchString> " + "<SearchFiltersList /> " + "<ClassURI>http://xmlns.com/foaf/0.1/Person</ClassURI> " + "</MatchOptions>" + "<OutputOptions>" + "<Offset>0</Offset>" + "<Limit>1</Limit> " + "<SortByList>" + "</SortByList>" + "</OutputOptions>" + "</SearchOptions>"; query.LoadXml(x); profileDataIO = new Profiles.Search.Utilities.DataIO(); result = profileDataIO.Search(query,false); namespaces = rdfnamespaces.LoadNamespaces(result); string ResultCount = result.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText; // Form result message ResultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; ResultStr += "<aggregation-result>"; ResultStr += "<count>" + ResultCount + "</count>"; ResultStr += "<population-type>" + PopulationTypeText + "</population-type>"; ResultStr += "<preview-URL>" + DirectServiceURL + "?Request=IncomingPreview&SearchPhrase=" + cx(q) + "</preview-URL>"; ResultStr += "<search-results-URL>" + DirectServiceURL + "?Request=IncomingDetails&SearchPhrase=" + cx(q) + "</search-results-URL>"; ResultStr += "</aggregation-result>"; // Send result Response.ContentType = "text/xml"; Response.AddHeader("Content-Type", "text/xml;charset=UTF-8"); //Response.ContentEncoding.CodePage = 65001; Response.Charset = "UTF-8"; Response.Write(ResultStr); break; case "incomingdetails": q = Request["SearchPhrase"].Trim(); // Enter log record sql = "insert into [Direct.].LogIncoming(Details,ReceivedDate,RequestIP,QueryString) "; sql += " values (1,GetDate()," + cs(Request.ServerVariables["REMOTE_ADDR"]) + "," + cs(q) + ")"; oDataIO.ExecuteSQLDataCommand(sql); // Execute query query.LoadXml("<SearchOptions>" + "<MatchOptions>" + "<SearchString ExactMatch=\"false\">" + cx(q) + "</SearchString> " + "<SearchFiltersList /> " + "<ClassURI>http://xmlns.com/foaf/0.1/Person</ClassURI> " + "</MatchOptions>" + "<OutputOptions>" + "<Offset>0</Offset>" + "<Limit>1</Limit> " + "<SortByList>" + "</SortByList>" + "</OutputOptions>" + "</SearchOptions>"); profileDataIO = new Profiles.Search.Utilities.DataIO(); result = profileDataIO.Search(query,false); strResult = result.InnerXml; // Parse results XmlDocument objDoc = new XmlDocument(); objDoc = new XmlDocument(); objDoc.LoadXml(strResult); namespaces = rdfnamespaces.LoadNamespaces(result); ResultCount = result.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText; if (ProfilesURL.Substring(ProfilesURL.Length - 1) != "/") { ProfilesURL += "/"; } Response.Redirect(ProfilesURL + "search/default.aspx?searchtype=people&classuri=http://xmlns.com/foaf/0.1/Person&searchfor=" + q); break; case "incomingpreview": q = Request["SearchPhrase"].Trim(); Utilities.DataIO data = new Profiles.DIRECT.Utilities.DataIO(); string searchphrase = Request["SearchPhrase"].Trim(); Response.Write(data.Search(searchphrase)); break; case "outgoingcount": if (Request["blank"] == "y") { Response.Write("<html><body></body></html>"); Response.End(); } string SearchPhrase = Request["SearchPhrase"]; Response.Write("<script>parent.dsLoading=1;</script>" + Environment.NewLine); dr = oDataIO.GetSitesOrderBySiteID(); SiteIDs = new int[1000]; URLs = new string[1000]; FSIDs = new string[1000]; Site site; ListOfSites = new List<Site>(); Int64 sites = 0; List<AsyncProcessing> ListOfThreads = new List<AsyncProcessing>(); AsyncProcessing async; while (dr.Read()) { SiteIDs[sites] = Convert.ToInt32(dr["SiteID"].ToString()); URLs[sites] = dr["QueryURL"] + SearchPhrase; FSIDs[sites] = dr["FSID"].ToString(); site = new Site(URLs[sites], SiteIDs[sites], FSIDs[sites], SearchPhrase, HttpContext.Current); ListOfSites.Add(site); async = new AsyncProcessing(); async.BeginProcessRequest(site); ListOfThreads.Add(async); sites++; } if (!dr.IsClosed) dr.Close(); //eat up the CPU for x number of seconds :) so all the requests can come back. This is set in the web.config file DateTime end = DateTime.Now.AddSeconds(QueryTimeout); while (DateTime.Now < end) { } //close out anything that did not complete in 5 seconds for (int loop = 0; loop < ListOfThreads.Count; loop++) { if (!ListOfThreads[loop].Site.IsDone) { sql = "update [Direct.].LogOutgoing set ResponseTime = datediff(ms,SentDate,GetDate()), " + " ResponseState = " + 1 + " where FSID = " + cs(ListOfThreads[loop].Site.FSID); oDataIO.ExecuteSQLDataCommand(sql); Response.Write("<script>parent.siteResult(" + ListOfThreads[loop].Site.SiteID + ",1,0,'','','','');</script>"); ListOfThreads.Remove(ListOfThreads[loop]); } } try { Response.Flush(); } catch { } break; case "outgoingdetails": string FSID = Request["fsid"].Trim(); string SiteId = string.Empty; if (FSID != "") { dr = oDataIO.GetFsID(cs(FSID)); if (dr.Read()) { SiteId = dr["SiteID"].ToString(); ResultDetailsURL = dr["ResultDetailsURL"].ToString().Replace("\n\t", ""); } if (!dr.IsClosed) dr.Close(); } if ((FSID != "") && (SiteId != "") && (ResultDetailsURL != "")) { // Enter log record oDataIO.ExecuteSQLDataCommand("insert into [Direct.].LogOutgoing(FSID,SiteID,Details,SentDate) " + " values ('" + FSID + "'," + SiteId + ",1,GetDate())"); Response.Redirect(ResultDetailsURL); } else Response.Redirect(ProfilesURL); break; } Response.End(); }