Пример #1
0
        public ActionResult DoLogin()
        {
            string res = JsonStringResult.VerifyFail();

            try
            {
                if (GeetestValidate.Validate())
                {
                    CUsers user = UsersBll.Instance.Login(Request["LoginName"].TryParseString(), Request["Password"].TryParseString());
                    if (user != null)
                    {
                        string userJson = JsonConvert.SerializeObject(user, new JsonSerializerSettings
                        {
                            DateFormatString = "yyyy-MM-dd HH:mm:ss"
                        });
                        CookieHelper.SetCookie("User", userJson, DateTime.Now.AddDays(30));
                        res = JsonStringResult.SuccessResult();
                    }
                    else
                    {
                        res = JsonStringResult.Error(OperateResCodeEnum.用户名或密码错误);
                    }
                }
                else
                {
                    res = JsonStringResult.Error(OperateResCodeEnum.验证码错误);
                }
            }
            catch (Exception ex)
            {
                res = JsonStringResult.Error(OperateResCodeEnum.内部错误);
            }
            return(Content(res));
        }
Пример #2
0
        public string GetRoomUsers(string param)
        {
            JObject jobj     = JObject.Parse(param);
            string  gameCode = jobj["TableCode"].TryParseString();
            var     room     = GameRecordBll.Instance.GetUsers(gameCode);

            return(JsonStringResult.SuccessResult(room));
        }
Пример #3
0
        public ActionResult ValidateCode()
        {
            string res = JsonStringResult.Error(OperateResCodeEnum.验证码错误);

            if (GeetestValidate.Validate())
            {
                res = JsonStringResult.SuccessResult();
            }
            return(Content(res));
        }
Пример #4
0
        public string ApplySwitchBanker(string param)
        {
            JObject jobj           = JObject.Parse(param);
            string  userCode       = jobj["UserCode"].TryParseString();
            string  targetUserCode = jobj["TargetUserCode"].TryParseString();
            string  tableCode      = jobj["TableCode"].Value <string>();

            CGameUser user       = GameRecordBll.Instance.GetUser(userCode, tableCode);
            CGameUser targetUser = GameRecordBll.Instance.GetUser(targetUserCode, tableCode);

            SendApplySwitchBankerNotice(user, targetUser);
            return(JsonStringResult.SuccessResult());
        }
Пример #5
0
        public string IAmCancelReady(string param)
        {
            JObject jobj      = JObject.Parse(param);
            string  userCode  = jobj["UserCode"].TryParseString();
            string  tableCode = jobj["TableCode"].Value <string>();

            var res  = GameBll.Instance.CancelBet(userCode, tableCode);
            var user = GameRecordBll.Instance.GetUser(userCode, tableCode);

            //提示客户端
            //SendBordcast(user.GameCode, "用户:" + user.NickName + "已取消下注!", userCode);
            SendReadyStatusNotice(user.GameCode, "用户:" + user.NickName + "已取消下注!", userCode, user);
            return(JsonStringResult.SuccessResult());
        }
Пример #6
0
        public ActionResult DoLogOut()
        {
            string res = JsonStringResult.VerifyFail();

            try
            {
                CookieHelper.RemoveCookie("User");
                res = JsonStringResult.SuccessResult();
            }
            catch (Exception ex)
            {
                res = JsonStringResult.Error(OperateResCodeEnum.内部错误);
            }
            return(Content(res));
        }
Пример #7
0
        public string IAmReady(string param)
        {
            JObject jobj      = JObject.Parse(param);
            string  userCode  = jobj["UserCode"].TryParseString();
            string  tableCode = jobj["TableCode"].Value <string>();
            decimal betMoney  = jobj["BetMoney"].TryParseDecimal(2);

            var res  = GameBll.Instance.Bet(userCode, betMoney, tableCode);
            var user = GameRecordBll.Instance.GetUser(userCode, tableCode);

            //提示客户端
            SendReadyStatusNotice(user.GameCode, "用户:" + user.NickName + "已下注" + betMoney + "之巨!", userCode, user);
            if (res.code == (int)OperateResCodeEnum.成功)
            {
                Clients.Group(user.GameCode, new string[0]).allReady("所有人都已下注!");
            }
            return(JsonStringResult.SuccessResult(user));
        }
Пример #8
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="pwd"></param>
        /// <param name="mobile"></param>
        /// <param name="email"></param>
        /// <param name="invitationCode"></param>
        /// <param name="nickName"></param>
        /// <param name="headImg"></param>
        /// <returns></returns>
        public string Register(string userName, string pwd, string mobile, string email, string nickName, string headImg = "")
        {
            if (userName.IsNullOrEmpty() || pwd.IsNullOrEmpty() || nickName.IsNullOrEmpty())
            {
                return(JsonStringResult.Error(OperateResCodeEnum.参数错误));
            }
            if (!StringUtil.IsNatural_Number(userName))
            {
                return(JsonStringResult.Error(OperateResCodeEnum.参数错误));
            }
            if (IsRepeat(userName))
            {
                return(JsonStringResult.Error(OperateResCodeEnum.用户名重复));
            }
            //if (!mobile.IsNullOrEmpty() && IsMobileRepeat(mobile))
            //{
            //    return OperateJsonRes.Error(OperateResCodeEnum.手机号重复);
            //}
            //if (!email.IsNullOrEmpty() && IsEmailRepeat(email))
            //{
            //    return OperateJsonRes.Error(OperateResCodeEnum.邮箱重复);
            //}
            string userCode = SignUtil.CreateSign(userName + RandomUtil.CreateRandomStr(10) + DateTime.Now.ToString("yyyyMMddHHmmss"));

            FF_User user = new FF_User();

            user.AddTime    = DateTime.Now;
            user.Email      = email.TryParseString();
            user.Mobile     = mobile.TryParseString();
            user.Password   = SignUtil.CreateSign(pwd);
            user.UserCode   = userCode;
            user.UserName   = userName;
            user.NickName   = nickName;
            user.HeadImg    = headImg.TryParseString();
            user.SecretCode = SignUtil.CreateSign(user.UserName + user.UserCode + RandomUtil.CreateRandomStr(10) + DateTime.Now.Ticks);
            user.OpenID     = "";
            _repository.Insert(user);


            return(JsonStringResult.SuccessResult(user.UserCode));
        }
Пример #9
0
        public ActionResult ValidateUserName()
        {
            string res   = JsonStringResult.VerifyFail();
            var    param = JObject.Parse(TempData["param"].TryParseString());

            res = UsersBll.Instance.IsRepeat(param["UserName"].TryParseString()) ? JsonStringResult.Error(OperateResCodeEnum.用户名重复) : JsonStringResult.SuccessResult();
            return(Content(res));
        }
Пример #10
0
 public ActionResult SyncTime()
 {
     return(Content(JsonStringResult.SuccessResult(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))));
 }