コード例 #1
0
ファイル: OperatorProvider.cs プロジェクト: depweili/SxcAdmin
        /// <summary>
        /// 是否已登录
        /// </summary>
        /// <returns></returns>
        public virtual int IsOnLine()
        {
            Operator user = new Operator();

            if (LoginProvider == "Cookie")
            {
                user = DESEncrypt.Decrypt(WebHelper.GetCookie(LoginUserKey).ToString()).ToObject <Operator>();
                #region 解决cookie时,设置数据权限较多时无法登陆的bug
                AuthorizeDataModel dataAuthorize = CacheFactory.Cache().GetCache <AuthorizeDataModel>(LoginUserKey);
                user.DataAuthorize = dataAuthorize;
                #endregion
            }
            else
            {
                user = DESEncrypt.Decrypt(WebHelper.GetSession(LoginUserKey).ToString()).ToObject <Operator>();
            }
            object token = CacheFactory.Cache().GetCache <string>(user.UserId);
            if (token == null)
            {
                return(-1);//过期
            }
            if (user.Token == token.ToString())
            {
                return(1);//正常
            }
            else
            {
                return(0);//已登录
            }
        }
コード例 #2
0
ファイル: OperatorProvider.cs プロジェクト: depweili/SxcAdmin
 /// <summary>
 /// 当前用户
 /// </summary>
 /// <returns></returns>
 public virtual Operator Current()
 {
     try
     {
         Operator user = new Operator();
         if (LoginProvider == "Cookie")
         {
             user = DESEncrypt.Decrypt(WebHelper.GetCookie(LoginUserKey).ToString()).ToObject <Operator>();
             #region 解决cookie时,设置数据权限较多时无法登陆的bug
             AuthorizeDataModel dataAuthorize = CacheFactory.Cache().GetCache <AuthorizeDataModel>(LoginUserKey);
             user.DataAuthorize = dataAuthorize;
             #endregion
         }
         else if (LoginProvider == "AppClient")
         {
             user = CacheFactory.Cache().GetCache <Operator>(AppUserId);
         }
         else
         {
             user = DESEncrypt.Decrypt(WebHelper.GetSession(LoginUserKey).ToString()).ToObject <Operator>();
         }
         return(user);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
コード例 #3
0
ファイル: OperatorProvider.cs プロジェクト: depweili/SxcAdmin
        /// <summary>
        /// 是否过期
        /// </summary>
        /// <returns></returns>
        public virtual bool IsOverdue()
        {
            try
            {
                object             str           = "";
                AuthorizeDataModel dataAuthorize = null;
                if (LoginProvider == "Cookie")
                {
                    str = WebHelper.GetCookie(LoginUserKey);
                    #region 解决cookie时,设置数据权限较多时无法登陆的bug
                    dataAuthorize = CacheFactory.Cache().GetCache <AuthorizeDataModel>(LoginUserKey);

                    if (dataAuthorize == null)
                    {
                        return(true);
                    }
                    #endregion
                }
                else
                {
                    str = WebHelper.GetSession(LoginUserKey);
                }
                if (str != null && str.ToString() != "")
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                return(true);
            }
        }