This class stores the Profiles custom session state
示例#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[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", session.LastUsedDate);

            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)
            {

            }
        }
示例#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 SessionCreate(ref Session session)
        {
            SqlDataReader dbreader;
            SqlParameter[] param = new SqlParameter[2];
            param[0] = new SqlParameter("@RequestIP", session.RequestIP);
            param[1] = new SqlParameter("@UserAgent", session.UserAgent);

            dbreader = GetSQLDataReader(GetDBCommand("", "[User.Session].[CreateSession]", CommandType.StoredProcedure, CommandBehavior.CloseConnection, param));
            if (dbreader != null)
            {
                if (dbreader.Read()) //Returns a data ready with one row of user Session Info.  {Profiles Session Info, not IIS}
                {
                    session.SessionID = dbreader["SessionID"].ToString();
                    session.CreateDate = dbreader["CreateDate"].ToString();
                    session.LastUsedDate = Convert.ToDateTime(dbreader["LastUsedDate"].ToString());

                    Utilities.DebugLogging.Log("Session object created:" + session.SessionID + " On " + session.CreateDate);
                }
                //Always close your readers
                if (!dbreader.IsClosed)
                    dbreader.Close();

            }
            else
            {
                session = null;
            }
        }
        /// <summary>
        ///     Public method used to create an instance of the custom Profiles session object.
        /// </summary>
        public void SessionCreate()
        {
            string sessionid = HttpContext.Current.Request.Headers["SessionID"];

            DataIO dataio = new DataIO();
            Session session = new Session();
            string hostname = System.Net.Dns.GetHostName();

            string ipaddress = string.Empty;
            try
            {
                ipaddress = System.Net.Dns.GetHostAddresses(hostname).GetValue(1).ToString();
            }
            catch (Exception ex)
            {
                Framework.Utilities.DebugLogging.Log(ex.Message + " ++ " + ex.StackTrace);
                ipaddress = "";
            }

            session.RequestIP = ipaddress;
            session.UserAgent = HttpContext.Current.Request.UserAgent;

            if (sessionid == null)
                dataio.SessionCreate(ref session);
            else
            {
                session.SessionID = sessionid;
            }

            //Store the object in the current session of the user.
            HttpContext.Current.Session["PROFILES_SESSION"] = session;
        }
        /// <summary>
        ///     Public method used to create an instance of the custom Profiles session object.
        /// </summary>
        public void SessionCreate()
        {
            string sessionid = string.Empty;
            string ORNGViewer = null;

            if (HttpContext.Current.Request["ContainerSessionID"] != null)
            {
                // ORNG this means it is from shindigorng. Grab the associated session and user
                sessionid = HttpContext.Current.Request["ContainerSessionID"];
                ORNGViewer = HttpContext.Current.Request["Viewer"];
            }
            else if (HttpContext.Current.Request.Headers["SessionID"] != null)
                sessionid = HttpContext.Current.Request.Headers["SessionID"];

            DataIO dataio = new DataIO();
            Session session = new Session();
            string hostname = System.Net.Dns.GetHostName();

            string ipaddress = string.Empty;
            try
            {
                ipaddress = System.Net.Dns.GetHostAddresses(hostname).GetValue(1).ToString();
            }
            catch (Exception ex)
            {
                Framework.Utilities.DebugLogging.Log(ex.Message + " ++ " + ex.StackTrace);
                ipaddress = "";
            }

            session.RequestIP = ipaddress;
            session.UserAgent = HttpContext.Current.Request.UserAgent;
            session.IsBot = IsBot(session.UserAgent);

            if (sessionid == string.Empty)
                dataio.SessionCreate(ref session);
            else
            {
                session.SessionID = sessionid;
                if (ORNGViewer != null && ORNGViewer.LastIndexOf('/') > 0)
                {
                    session.UserID = Convert.ToInt32(ORNGViewer.Substring(ORNGViewer.LastIndexOf('/') + 1));
                }
            }

            //Store the object in the current session of the user.
            HttpContext.Current.Session["PROFILES_SESSION"] = session;
        }
示例#5
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 = this.GetConnectionString();
            SessionManagement sm = new SessionManagement();

            SqlConnection dbconnection = new SqlConnection(connstr);

            SqlParameter[] param;

            param = new SqlParameter[8];

            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", session.LastUsedDate);

            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("@UserURI", SqlDbType.VarChar, 400);
            param[5].Direction = ParameterDirection.Output;

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

            if (session.LogoutDate > DateTime.Now.AddDays(-5))
            {
                param[7] = 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)
            {
                Framework.Utilities.DebugLogging.Log("ERROR" + ex.StackTrace);
            }

            try
            {
                dbcommand.Connection.Close();
                if (param[3].Value != null && param[3].Value != DBNull.Value)
                {
                    session.NodeID = Convert.ToInt64(param[3].Value);
                }
                if (param[4].Value != null && param[4].Value != DBNull.Value)
                {
                    session.PersonURI = param[4].Value.ToString();
                }
                session.UserURI = param[5].Value.ToString();
                session.ShortDisplayName = param[6].Value.ToString();
            }
            catch (Exception ex)
            {
                Framework.Utilities.DebugLogging.Log("ERROR" + ex.StackTrace);
            }
        }