Пример #1
0
        /// <summary>
        /// 是否已登录
        /// </summary>
        /// <returns></returns>
        public virtual int IsOnLine()
        {
            Operator user = new Operator();

            user = CacheFactory.Cache().GetCache <Operator>(FormsAuth.GetUserKey());
            if (user == null)
            {
                return(-1);
            }
            //if (LoginProvider == "Cookie")
            //{
            //    //user = DESEncrypt.Decrypt(WebHelper.GetCookie(LoginUserKey).ToString()).ToObject<Operator>();
            //     //AuthorizeDataModel dataAuthorize = CacheFactory.Cache().GetCache<AuthorizeDataModel>(user.UserId + "_" + LoginUserKey);
            //}
            //else
            //{
            //    user = DESEncrypt.Decrypt(WebHelper.GetSession(LoginUserKey).ToString()).ToObject<Operator>();
            //}
            object token = CacheFactory.Cache().GetCache <string>(systemName + "_" + user.UserId + "_" + LoginUserKey);

            if (token == null)
            {
                return(-1);//过期
            }
            if (user.Token == token.ToString())
            {
                return(1);//正常
            }
            else
            {
                return(0);//已登录
            }
        }
Пример #2
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);
            }
        }