public virtual IManageUser Current() { IManageUser user2; try { IManageUser user = new IManageUser(); if (this.LoginProvider == "Cookie") { user = JsonConvert.DeserializeObject <IManageUser>(DESEncrypt.Decrypt(CookieHelper.GetCookie(this.LoginUserKey))); } else { user = JsonConvert.DeserializeObject <IManageUser>(DESEncrypt.Decrypt(SessionHelper.Get(this.LoginUserKey).ToString())); } if (user == null) { throw new Exception("登录信息超时,请重新登录。"); } user2 = user; } catch { throw new Exception("登录信息超时,请重新登录。"); } return(user2); }
public virtual void AddCurrent(IManageUser user) { try { if (this.LoginProvider == "Cookie") { CookieHelper.WriteCookie(this.LoginUserKey, DESEncrypt.Encrypt(JsonConvert.SerializeObject(user)), 0x5a0); } else { SessionHelper.Add(this.LoginUserKey, DESEncrypt.Encrypt(JsonConvert.SerializeObject(user))); } } catch (Exception exception) { throw new Exception(exception.Message); } }