public void UpdateGameUser(int money) { //FormsAuthentication.SetAuthCookie("*****@*****.**", false); HttpCookie cookie = Request.Cookies["UserGame"]; var adminData = new UserGameModel { Team = 3, Project = 0, Money = money, GameSession = "01012017" }; var serializer = new JavaScriptSerializer(); cookie = new HttpCookie("UserGame", serializer.Serialize(adminData)); Response.SetCookie(cookie); //SetCookie() is used for update the cookie. Response.Cookies.Add(cookie); //var adminData = new UserGameModel //{ // Team = 3, // Project = 0, // Money = money, // GameSession = "01012017" //}; //var serializer = new JavaScriptSerializer(); //var cookie = new HttpCookie("UserGame", serializer.Serialize(adminData)) //{ //}; //Response.Cookies.Add(cookie); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: using (var context = new DAL.DataContext()) { var userData = context.Users.FirstOrDefault(x => x.Email == model.Email); //Todo find current game if (userData != null) { var userModel = new UserGameModel { UserId = userData.UserId, TimeZone = "SE Asia Standard Time", Email = model.Email }; } var serializer = new JavaScriptSerializer(); var cookie = new HttpCookie("User", serializer.Serialize(userData)) { Expires = DateTime.Now.AddYears(1) }; Response.Cookies.Add(cookie); } return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
public void InitialGame(int team, int project, int money, int roomId) { HttpCookie cookie = Request.Cookies["UserGame"]; var adminData = new UserGameModel { Team = team, Project = project, Money = money, GameSession = Guid.NewGuid().ToString(), UserId = Singleton.User().UserId, GameRoomId = roomId, }; var serializer = new JavaScriptSerializer(); cookie = new HttpCookie("UserGame", serializer.Serialize(adminData)); Response.SetCookie(cookie); //SetCookie() is used for update the cookie. Response.Cookies.Add(cookie); }
public ActionResult StartGame(int N) { string IP = HttpContext.Request.UserHostAddress; var genNumber = _generatNumber(N); var UG = GenerNumbers.Keys.Where(g => g == IP).FirstOrDefault(); if (UG != null) { GenerNumbers[UG] = new UserGameModel(IP, genNumber, 3, 0); } else { GenerNumbers.Add(IP, new UserGameModel(IP, genNumber, 3, 0)); } return(Json(new { }, JsonRequestBehavior.AllowGet)); }
public void InitialGame() { FormsAuthentication.SetAuthCookie("*****@*****.**", false); var adminData = new UserGameModel { Team = 3, Project = 0, Money = 10000, GameSession = "01012017", UserId = 1 }; var serializer = new JavaScriptSerializer(); var cookie = new HttpCookie("UserGame", serializer.Serialize(adminData)) { Expires = DateTime.Now.AddHours(1) }; Response.Cookies.Add(cookie); }
public async Task <JsonResult> SaveRemark(string id, string remark, bool isTishi) { Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData(); GaiaGame gaiaGame = GameMgr.GetGameByName(id); if (gaiaGame != null) { UserGameModel userGameModel = gaiaGame.UserGameModels.Find(x => x.username.ToString() == HttpContext.User.Identity.Name); //备忘 userGameModel.remark = remark; userGameModel.isTishi = isTishi; jsonData.info.state = 200; } else { jsonData.info.state = 0; jsonData.info.message = "保存失败"; } return(new JsonResult(jsonData)); }
public async Task <JsonResult> SetTishi(string type) { var list = GameMgr.GetAllGame(User.Identity.Name); foreach (KeyValuePair <string, GaiaGame> keyValuePair in list) { UserGameModel singleOrDefault = keyValuePair.Value.UserGameModels.Find(item => item.username == User.Identity.Name); if (singleOrDefault != null) { if (type == "open") { singleOrDefault.isTishi = true; } else { singleOrDefault.isTishi = false; } } } Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData(); jsonData.info.state = 200; return(new JsonResult(jsonData)); }