public override bool IsUserInRole(string username, string rolename)
        {
            var parameters = new[] { new MySqlParameter("?rolename", rolename), new MySqlParameter("?username", username) };
            var obj        = _helper.ExecuteOdbcScalar("SELECT COUNT(*) FROM `Users` U JOIN `UserRoles` UR ON (U.`id_user` = UR.`id_user`) JOIN `Roles` R ON (R.`id_role` = UR.`id_role`) WHERE R.`name` = ?rolename AND U.`userName` = ?username; ", parameters);

            return(obj != DBNull.Value ? Convert.ToInt32(obj) > 0 : false);
        }
Пример #2
0
        //
        // MembershipProvider.GetNumberOfUsersOnline
        //

        public override int GetNumberOfUsersOnline()
        {
            var      onlineSpan  = new TimeSpan(0, Membership.UserIsOnlineTimeWindow, 0);
            DateTime compareTime = DateTime.Now.Subtract(onlineSpan);

            var parameters = new[] { new MySqlParameter("?lActiveDate", compareTime) };
            var result     = _helper.ExecuteOdbcScalar("SELECT COUNT(*) FROM `Users` WHERE `lastActivityDate` > ?lActiveDate;", parameters);

            return(result != DBNull.Value ? Convert.ToInt32(result) : 0);
        }