Ejemplo n.º 1
0
        /// <summary>
        /// 是否已登录
        /// </summary>
        /// <returns></returns>
        public virtual int IsOnLine()
        {
            OperatorEntity user = new OperatorEntity();

            if (_loginProvider == "Cookie")
            {
                user = DESEncryptHelper.Decrypt(CookieHelper.GetCookie(LoginUserKey).ToString()).JsonToEntity <OperatorEntity>();

                #region 解决cookie时,设置数据权限较多时无法登陆的bug
                AuthorizeDataModel dataAuthorize = CacheFactory.CacheFactory.GetCacheInstance().GetCache <AuthorizeDataModel>(LoginUserKey);
                user.DataAuthorize = dataAuthorize;
                #endregion
            }
            else
            {
                user = DESEncryptHelper.Decrypt(SessionHelper.GetSession <string>(LoginUserKey).ToString()).JsonToEntity <OperatorEntity>();
            }
            object token = CacheFactory.CacheFactory.GetCacheInstance().GetCache <string>(user.UserId);
            if (token == null)
            {
                return(-1);//过期
            }
            if (user.Token == token.ToString())
            {
                return(1);//正常
            }
            else
            {
                return(0);//已登录
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 当前用户
        /// </summary>
        /// <returns></returns>
        public virtual OperatorEntity Current()
        {
            try
            {
                OperatorEntity user = new OperatorEntity();
                if (_loginProvider == "Cookie")
                {
                    user = DESEncryptHelper.Decrypt(CookieHelper.GetCookie(LoginUserKey).ToString()).JsonToEntity <OperatorEntity>();

                    #region 解决cookie时,设置数据权限较多时无法登陆的bug
                    AuthorizeDataModel dataAuthorize = CacheFactory.CacheFactory.GetCacheInstance().GetCache <AuthorizeDataModel>(LoginUserKey);
                    user.DataAuthorize = dataAuthorize;
                    #endregion
                }
                else
                {
                    user = DESEncryptHelper.Decrypt(SessionHelper.GetSession <string>(LoginUserKey).ToString()).JsonToEntity <OperatorEntity>();
                }
                return(user);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 是否过期
        /// </summary>
        /// <returns></returns>
        public virtual bool IsOverdue()
        {
            try
            {
                string str = "";
                if (_loginProvider == "Cookie")
                {
                    str = CookieHelper.GetCookie(LoginUserKey);

                    #region 解决cookie时,设置数据权限较多时无法登陆的bug
                    AuthorizeDataModel dataAuthorize = CacheFactory.CacheFactory.GetCacheInstance().GetCache <AuthorizeDataModel>(LoginUserKey);

                    if (dataAuthorize == null)
                    {
                        return(true);
                    }
                    #endregion
                }
                else
                {
                    str = SessionHelper.GetSession <string>(LoginUserKey);
                }

                return(string.IsNullOrEmpty(str));
            }
            catch (Exception)
            {
                return(true);
            }
        }