コード例 #1
0
        public IHttpActionResult Main()
        {
            var body = new RequestBody();

            var mobile   = body.GetPostString("mobile");
            var password = body.GetPostString("password");
            var code     = body.GetPostString("code");

            var dbCode = DbCacheManager.GetValue($"SiteServer.API.Controllers.Users.SendSms.{mobile}.Code");

            var    isRegister = false;
            string errorMessage;

            if (code != dbCode)
            {
                errorMessage = "短信验证码不正确";
            }
            else
            {
                var userInfo = new UserInfo
                {
                    UserName = mobile,
                    Mobile   = mobile,
                    Password = password
                };
                isRegister = BaiRongDataProvider.UserDao.Insert(userInfo, PageUtils.GetIpAddress(), out errorMessage);
            }

            return(Ok(new {
                IsRegister = isRegister,
                ErrorMessage = errorMessage
            }));
        }
コード例 #2
0
        public NameValueCollection GetTableNameCache()
        {
            NameValueCollection nameValueCollection = null;
            var cacheValue = DbCacheManager.GetValue(GetTableNameNameValueCollectionDbCacheKey());

            if (!string.IsNullOrEmpty(cacheValue))
            {
                nameValueCollection = TranslateUtils.ToNameValueCollection(cacheValue);
            }
            return(nameValueCollection);
        }
コード例 #3
0
        public IHttpActionResult IsCodeCorrect()
        {
            var body   = new RequestBody();
            var mobile = body.GetPostString("mobile");
            var code   = body.GetPostString("code");

            var dbCode = DbCacheManager.GetValue($"SiteServer.API.Controllers.Users.SendSms.{mobile}.Code");

            var isCorrect = code == dbCode;
            var token     = string.Empty;

            if (isCorrect)
            {
                token = RequestBody.GetUserTokenStr(BaiRongDataProvider.UserDao.GetUserNameByMobile(mobile));
            }

            return(Ok(new
            {
                IsCorrect = isCorrect,
                Token = token
            }));
        }
コード例 #4
0
ファイル: ServiceManager.cs プロジェクト: yankaics/cms-1
        public static bool IsServiceOnline()
        {
            var cacheValue = CacheManager.GetCache(CacheKeyStatus) as string;

            if (TranslateUtils.ToBool(cacheValue))
            {
                return(true);
            }

            var retval = true;

            var value = DbCacheManager.GetValue(CacheKeyStatus);

            if (string.IsNullOrEmpty(value))
            {
                retval = false;
            }
            else
            {
                var ts = DateTime.Now - TranslateUtils.ToDateTime(value);
                if (ts.TotalMinutes > 30)
                {
                    retval = false;
                }
                else
                {
                    CacheManager.SetCache(CacheKeyStatus, true.ToString(), DateTime.Now.AddMinutes(10));
                }
            }

            if (!retval)
            {
                CacheManager.SetCache(CacheKeyStatus, false.ToString(), DateTime.Now.AddMinutes(10));
            }

            return(retval);
        }
コード例 #5
0
        private static NameValueCollection GetColumnsMap()
        {
            var columnsMap = TranslateUtils.ToNameValueCollection(DbCacheManager.GetValue("SiteServer.BackgroundPages.Cms.BackgroundGatherDatabaseRuleAdd.TableMatchColumnsMap"));

            return(columnsMap);
        }