Esempio n. 1
0
 /// <summary>
 /// 通过sessionid获取用户
 /// </summary>
 /// <param name="sessionId"></param>
 /// <returns></returns>
 public virtual UserModel GetUser(string sessionId)
 {
     try
     {
         RedisCacheUtils.Select(1);
         return(RedisCacheUtils.Get <UserModel>(sessionId));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 当前账号在他地登录session 是否已经登录
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public virtual string UserSession(string userId)
 {
     try
     {
         RedisCacheUtils.Select(0);
         return(RedisCacheUtils.Get <string>(GrobalConfig.RedisUserTitle + userId));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 当前用户
 /// </summary>
 /// <returns></returns>
 public virtual UserModel Current()
 {
     try
     {
         string sessionId = getCurrentSession();
         RedisCacheUtils.Select(1);
         return(RedisCacheUtils.Get <UserModel>(sessionId));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 删除登录信息
        /// </summary>
        /// <param name="userId"></param>
        public virtual void EmptyUser(string userId)
        {
            try
            {
                string userIdKey = GrobalConfig.RedisUserTitle + userId;

                RedisCacheUtils.Select(0);
                string otherSessionId = RedisCacheUtils.Get <string>(userIdKey);
                RedisCacheUtils.Remove(userIdKey);

                RedisCacheUtils.Select(1);
                RedisCacheUtils.Remove(otherSessionId);
                //todo:clear other session
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
 private string RedisGetClient(string clientSessionId)
 {
     RedisCacheUtils.Select(2);
     return(RedisCacheUtils.Get <string>(clientSessionId));
 }
Esempio n. 6
0
 private string RedisGetTicket(string ticket)
 {
     RedisCacheUtils.Select(3);
     return(RedisCacheUtils.Get <string>(ticket));
 }