예제 #1
0
        public AjaxReponseBase getCode()
        {
            // 生成随机字串
            string verifyCode = string.Empty;
            // 唯一标识
            string uuid      = Guid.NewGuid().ToString().Replace("-", "");
            string verifyKey = YouGeSystemConst.CAPTCHA_CODE_KEY + uuid;


            // 生成图片
            int          w = 111, h = 36;
            MemoryStream stream = new MemoryStream();

            stream = VerifyCodeUtils.outputImage(w, h, out verifyCode, 4);
            YouGeRedisHelper.Set(verifyKey, verifyCode, YouGeSystemConst.CAPTCHA_EXPIRATION * 60);
            try
            {
                AjaxReponseBase ajax = AjaxReponseBase.Success();
                ajax.Add("uuid", uuid);
                ajax.Add("verifyCode", verifyCode);
                byte[] A = stream.ToByteArray();
                stream.Close();
                ajax.Add("img", YouGeBase64.encode(A));
                return(ajax);
            }
            catch (Exception e)
            {
                Log4NetHelper.Error("获取验证码异常 " + e.StackTrace);
                return(AjaxReponseBase.Error(e.Message));
            }
            finally
            {
                stream.Close();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public int insertConfig(SysConfig config)
        {
            int row = this.Add(config);

            if (row > 0)
            {
                YouGeRedisHelper.Set(config.ConfigKey, config.ConfigValue);
            }
            return(row);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public int updateConfig(SysConfig config)
        {
            int row = this.Edit(config);

            if (row > 0)
            {
                YouGeRedisHelper.Set(config.ConfigKey, config.ConfigValue);
            }
            return(row);
        }
예제 #4
0
        public void refreshToken(LoginUser loginUser)
        {
            loginUser.loginTime = DateTimeExtensions.CurrentTimeMillis();
            int expireTime = 30; // TO DO 这个要写在appsettiong.json文件中

            loginUser.expireTime = loginUser.loginTime + expireTime * MILLIS_MINUTE;
            // 根据uuid将loginUser缓存
            string userKey = getTokenKey(loginUser.token);

            YouGeRedisHelper.Set(userKey, loginUser, expireTime * 60);
        }