Beispiel #1
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[7];

            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;

            // UCSF
            param[5] = new SqlParameter("@ShortDisplayName", SqlDbType.VarChar, 400);
            param[5].Direction = ParameterDirection.Output;

            if (session.LogoutDate > DateTime.Now.AddDays(-5))
            {
                param[6] = 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)
            {

            }
        }
Beispiel #2
0
        public XmlDocument Search(Search.SearchOptions searchoptions, bool lookup)
        {
            string xmlstr = string.Empty;

            XmlDocument xmlrtn = new XmlDocument();
            SessionManagement sm = new SessionManagement();
            string sessionid = string.Empty;

            xmlstr = Utilities.SerializeXML.SerializeToString(searchoptions);

            xmlstr = xmlstr.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
            xmlstr = xmlstr.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", "");

            try
            {
                string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;
                bool secure = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSecure"]);

                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();

                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"]);

                    Session session = new Session();
                    session.UserID = user.UserID;
                    session.SessionID = sessionid;
                    this.SessionUpdate(ref session);
                }

                dbcommand.Parameters.Add(new SqlParameter("@SearchOptions", xmlstr));

                dbcommand.Parameters.Add(new SqlParameter("@sessionid", sessionid));

                if (lookup)
                    dbcommand.Parameters.Add(new SqlParameter("@Lookup", 1));

                dbcommand.Connection = dbconnection;

                dbreader = dbcommand.ExecuteReader(CommandBehavior.CloseConnection);

                xmlstr = string.Empty;

                while (dbreader.Read())
                {
                    xmlstr += dbreader[0].ToString();
                }

                xmlrtn.LoadXml(xmlstr);

                if (!dbreader.IsClosed)
                    dbreader.Close();

                Utilities.DebugLogging.Log(xmlstr);

            }
            catch (Exception e)
            {
                Utilities.DebugLogging.Log(e.Message + " " + e.StackTrace);
            }

            return xmlrtn;
        }