public XmlDocument Search(string personid, bool secure) { System.Text.StringBuilder sql = new System.Text.StringBuilder(); string xmlstr = string.Empty; XmlDocument xmlrtn = new XmlDocument(); SessionManagement sm = new SessionManagement(); Int64 nodeid = 0; string sessionid = string.Empty; try { Convert.ToInt16(personid); } catch (Exception ex) { personid = "'" + personid + "'"; } string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString; sql.AppendLine("select i.nodeid from [RDF.Stage].internalnodemap i with(nolock) join [Profile.Data].Person p with(nolock) on i.InternalID = p.PersonID where i.class = 'http://xmlns.com/foaf/0.1/Person' and i.internalid = " + personid + " and p.IsActive = 1 "); SqlConnection dbconnection = new SqlConnection(connstr); SqlCommand dbcommand = new SqlCommand(); SqlDataReader dbreader; dbconnection.Open(); dbcommand.CommandType = CommandType.Text; dbcommand.CommandText = sql.ToString(); dbcommand.CommandTimeout = 5000; dbcommand.Connection = dbconnection; dbreader = dbcommand.ExecuteReader(CommandBehavior.CloseConnection); while (dbreader.Read()) { nodeid = Convert.ToInt32(dbreader[0].ToString()); } if (!dbreader.IsClosed) dbreader.Close(); dbcommand = new SqlCommand(); dbcommand.CommandType = CommandType.StoredProcedure; dbcommand.CommandTimeout = 5000; dbconnection.Open(); dbcommand.Connection = dbconnection; dbcommand.CommandText = "[RDF.].[GetDataRDF]"; dbcommand.Parameters.Add(new SqlParameter("@subject", nodeid)); dbcommand.Parameters.Add(new SqlParameter("@predicate", 0)); dbcommand.Parameters.Add(new SqlParameter("@object", 0)); dbcommand.Parameters.Add(new SqlParameter("@showDetails", "true")); dbcommand.Parameters.Add(new SqlParameter("@expand", "true")); sessionid = sm.SessionCreate(); Session session = new Session(); if (secure) { User user = new User(); user.UserName = ConfigurationSettings.AppSettings["SecureGenericUserName"]; user.UserID = Convert.ToInt32(ConfigurationSettings.AppSettings["SecureGenericUserID"]); session.UserID = user.UserID; session.SessionID = sessionid; } this.SessionUpdate(ref session); dbcommand.Parameters.Add(new SqlParameter("@sessionid", sessionid)); dbcommand.Connection = dbconnection; dbreader = dbcommand.ExecuteReader(CommandBehavior.CloseConnection); while (dbreader.Read()) { xmlstr += dbreader[0].ToString(); } dbconnection.Dispose(); if (!dbreader.IsClosed) dbreader.Close(); dbreader.Dispose(); try { xmlrtn.LoadXml(xmlstr); } catch (Exception ex) { } return xmlrtn; }
public XmlDocument Search(XmlDocument searchoptions, bool secure) { string xmlstr = string.Empty; XmlDocument xmlrtn = new XmlDocument(); string cachekey = searchoptions.OuterXml + secure.ToString(); SessionManagement sm = new SessionManagement(); string sessionid = string.Empty; if (Utility.CacheUtil.Fetch(cachekey) == null) { try { string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString; sessionid = sm.SessionCreate(); SqlConnection dbconnection = new SqlConnection(connstr); SqlCommand dbcommand = new SqlCommand(); SqlDataReader dbreader; dbconnection.Open(); dbcommand.CommandType = CommandType.StoredProcedure; dbcommand.CommandText = "[Search.].[GetNodes]"; dbcommand.CommandTimeout = this.GetCommandTimeout(); Session session = new Session(); session.SessionID = sessionid; if (secure) { dbcommand.Parameters.Add(new SqlParameter("@UseCache", "Private")); User user = new User(); user.UserName = ConfigurationSettings.AppSettings["SecureGenericUserName"]; user.UserID = Convert.ToInt32(ConfigurationSettings.AppSettings["SecureGenericUserID"]); } this.SessionUpdate(ref session); dbcommand.Parameters.Add(new SqlParameter("@sessionid", sessionid)); dbcommand.Parameters.Add(new SqlParameter("@SearchOptions", searchoptions.OuterXml)); dbcommand.Connection = dbconnection; dbreader = dbcommand.ExecuteReader(CommandBehavior.CloseConnection); while (dbreader.Read()) { xmlstr += dbreader[0].ToString(); } if (!dbreader.IsClosed) dbreader.Close(); xmlrtn.LoadXml(xmlstr); Utility.CacheUtil.Set(cachekey, xmlrtn); xmlstr = string.Empty; } catch (Exception e) { throw new Exception(e.Message); } } else { xmlrtn = Utility.CacheUtil.Fetch(cachekey); } return xmlrtn; }