Ejemplo n.º 1
0
        /// <summary>
        /// Log out from application
        /// </summary>
        protected bool LogoutByNewUser(Guid user_id, string pass)
        {
            try
            {
                Guid?loggedsession_id = null;
                using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SumonERPContext"].ConnectionString.ToString()))
                {
                    var        sql = "select session_id from sessionManagements where user_id='" + user_id + "' and Password ='******'";
                    SqlCommand cmd = new SqlCommand(sql, con);
                    con.Open();
                    SqlDataReader oReader = cmd.ExecuteReader();
                    if (((System.Data.SqlClient.SqlDataReader)(oReader)).HasRows)
                    {
                        while (oReader.Read())
                        {
                            loggedsession_id = Guid.Parse(Convert.ToString(oReader["session_id"]));
                            if (loggedsession_id != null)
                            {
                                SecurityServices.CloseSession(loggedsession_id.ToString());
                            }
                        }
                    }
                    oReader.Close();

                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }