Пример #1
0
 /// <summary>
 /// 写入登录信息
 /// </summary>
 /// <param name="user">成员信息</param>
 public virtual void AddCurrent(IManageUser user)
 {
     try
     {
         if (LoginProvider == "Cookie")
         {
             CookieHelper.WriteCookie(LoginUserKey, DESEncrypt.Encrypt(JsonConvert.SerializeObject(user)), 1440);
         }
         else
         {
             SessionHelper.Add(LoginUserKey, DESEncrypt.Encrypt(JsonConvert.SerializeObject(user)));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #2
0
 /// <summary>
 /// 当前用户
 /// </summary>
 /// <returns></returns>
 public virtual IManageUser Current()
 {
     try
     {
         IManageUser user = new IManageUser();
         if (LoginProvider == "Cookie")
         {
             user = JsonConvert.DeserializeObject <IManageUser>(DESEncrypt.Decrypt(CookieHelper.GetCookie(LoginUserKey)));
         }
         else
         {
             user = JsonConvert.DeserializeObject <IManageUser>(DESEncrypt.Decrypt(SessionHelper.Get(LoginUserKey).ToString()));
         }
         if (user == null)
         {
             throw new Exception("登录信息超时,请重新登录。");
         }
         return(user);
     }
     catch
     {
         throw new Exception("登录信息超时,请重新登录。");
     }
 }