Esempio n. 1
0
        /// <summary>
        /// 当前用户
        /// </summary>
        /// <returns></returns>
        public virtual Operator Current()
        {
            try
            {
                Operator user = new Operator();

                if (LoginProvider == "AppClient")
                {
                    user = CacheFactory.Cache().GetCache <Operator>(systemName + "_" + AppUserId);
                }
                else
                {
                    //if (LoginProvider == "Cookie")
                    //{
                    //    //user = DESEncrypt.Decrypt(WebHelper.GetCookie(LoginUserKey).ToString()).ToObject<Operator>();
                    //    //#region 解决cookie时,设置数据权限较多时无法登陆的bug
                    //    //AuthorizeDataModel dataAuthorize = CacheFactory.Cache().GetCache<AuthorizeDataModel>(user.UserId + "_" + LoginUserKey);
                    //    //user.DataAuthorize = dataAuthorize;
                    //    //#endregion
                    //    //user = FormsAuth.GetUserData();

                    //}
                    //else
                    //{
                    //    user = CacheFactory.Cache().GetCache<Operator>(FormsAuth.GetUserKey());
                    //    //user = DESEncrypt.Decrypt(WebHelper.GetSession(LoginUserKey).ToString()).ToObject<Operator>();
                    //}
                    user = CacheFactory.Cache().GetCache <Operator>(FormsAuth.GetUserKey());
                    //if (user == null)
                    //{
                    //    //user = CacheFactory.Cache().GetCache<Operator>(systemName + "_" + OperatorProvider.AppUserId);

                    //}
                }

                return(user);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 删除登录信息
 /// </summary>
 public virtual void EmptyCurrent()
 {
     FormsAuth.SingOut();
     if (LoginProvider == "Cookie")
     {
         string val = WebHelper.GetCookie(LoginUserKey);
         if (!string.IsNullOrEmpty(val))
         {
             Operator user = DESEncrypt.Decrypt(WebHelper.GetCookie(LoginUserKey)).ToObject <Operator>();
             WebHelper.RemoveCookie(LoginUserKey.Trim());
             CacheFactory.Cache().RemoveCache(LoginUserKey);
             if (user != null)
             {
                 CacheFactory.Cache().RemoveCache(systemName + "_" + user.UserId + "_" + LoginUserKey);
             }
         }
     }
     else
     {
         WebHelper.RemoveSession(LoginUserKey);
     }
 }