Example #1
0
        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;
        }
Example #2
0
        /// <summary>
        ///     Used to create a custom Profiles Session instance.  This instance is used to track and store user activity as a form of Profiles Network.
        /// </summary>
        /// <param name="session">ref of Framework.Session object that stores the state of a Profiles user session</param>
        public void SessionUpdate(ref Session session)
        {
            string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;
            SessionManagement sm = new SessionManagement();

            SqlConnection dbconnection = new SqlConnection(connstr);

            SqlParameter[] param;

            param = new SqlParameter[6];

            SqlCommand dbcommand = new SqlCommand();

            dbconnection.Open();

            dbcommand.CommandTimeout = this.GetCommandTimeout();

            param[0] = new SqlParameter("@SessionID", session.SessionID);
            param[1] = new SqlParameter("@UserID", session.UserID);

            param[2] = new SqlParameter("@LastUsedDate", DateTime.Now);

            param[3] = new SqlParameter("@SessionPersonNodeID", 0);
            param[3].Direction = ParameterDirection.Output;

            param[4] = new SqlParameter("@SessionPersonURI", SqlDbType.VarChar, 400);
            param[4].Direction = ParameterDirection.Output;

            if (session.LogoutDate > DateTime.Now.AddDays(-5))
            {
                param[5] = new SqlParameter("@LogoutDate", session.LogoutDate.ToString());
            }

            dbcommand.Connection = dbconnection;

            try
            {
                //For Output Parameters you need to pass a connection object to the framework so you can close it before reading the output params value.
                ExecuteSQLDataCommand(GetDBCommand(ref dbconnection, "[User.Session].[UpdateSession]", CommandType.StoredProcedure, CommandBehavior.CloseConnection, param));

            }
            catch (Exception ex) { }

            try
            {
                dbcommand.Connection.Close();
                session.NodeID = Convert.ToInt64(param[3].Value);
                session.PersonURI = param[4].Value.ToString();
            }
            catch (Exception ex)
            {

            }
        }
Example #3
0
        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;
        }