public void BindRbl() { #region 绑定用户角色 Users user = UserManager.GetUserById(Convert.ToInt32(ViewState["UserId"])); DataTable dtuserrole = UserRoleManager.GetAllUserRoles(); GridViewHelp.BindRBL(dtuserrole, rbtnlistuserrole, "Name", "Id"); foreach (ListItem lt in rbtnlistuserrole.Items) { if (lt.Text == user.UserRoles.Name) { lt.Selected = true; } } #endregion #region 绑定用户状态 DataTable dtuserstate = UserStateManager.GetAllUserState(); GridViewHelp.BindRBL(dtuserstate, rbtnlistuserstate, "Name", "Id"); foreach (ListItem lt in rbtnlistuserstate.Items) { if (lt.Text == user.UserStates.Name) { lt.Selected = true; } } #endregion }
public void RequestIsValid_given_null_token_returns_false() { var cache = new MemoryCache(new MemoryCacheOptions()); var stateManager = new UserStateManager(cache); Assert.False(SecurityFilter.RequestIsValid(null, null, stateManager)); }
public void RequestIsValid_given_invalid_token_returns_true() { var cache = new MemoryCache(new MemoryCacheOptions()); var stateManager = new UserStateManager(cache); Assert.False(SecurityFilter.RequestIsValid("invalidtoken123123", "ABC1234", stateManager)); }
protected void btnupdate_Click(object sender, EventArgs e) { #region 更新用户信息 Users user = new Users(); user.ID = Convert.ToInt32(ViewState["UserId"]); user.LoginId = this.txtLoginId.Text.Trim(); user.Mail = this.txtmail.Text.Trim(); user.Name = this.txtname.Text.Trim(); user.Phone = this.txtphone.Text.Trim(); user.Address = this.txtaddress.Text.Trim(); user.LoginPwd = this.txtpwd.Text.Trim(); foreach (ListItem lt in rbtnlistuserstate.Items) { if (lt.Selected == true) { user.UserStates = UserStateManager.GetUserStatesById(Convert.ToInt32(lt.Value)); } } foreach (ListItem lt in rbtnlistuserrole.Items) { if (lt.Selected == true) { user.UserRoles = UserRoleManager.GetUserRolesById(Convert.ToInt32(lt.Value)); } } if (UserManager.UpdateUser(user)) { Response.Redirect("ListAllUsers.aspx"); } else { Response.Write("<script>alert('更新失败')</script>"); } #endregion }
public void CanGetRoomState(AccountType accountType) { _fakeNowProvider = new FakeNowProvider { Now = new DateTime(2000, 12, 12, 12, 12, 0) }; var usersCache = new MockUserStateRepository(); var calc = FakeTimeCalculatorFactory.GetTimeWarpStateCalculator(); _userStateManager = new UserStateManager(calc, usersCache); _testRoom = new Room(2, "testRoom2", new DateTime(2001, 12, 12)); _roomRepository = new MockRoomRepository(); _roomRepository.Add(_testRoom); _roomStateController = new RoomStateController(_userStateManager, _roomRepository, new RoomRemovalPolicy(), _fakeNowProvider); var newAccount = new Account(0, TestHelper.NameMock, TestHelper.EmailAddressMock + 1, accountType); _testRoom.Add(newAccount); usersCache.Add(new TimeWarpUserState(0, newAccount, TimeWarpState.Resting, _fakeNowProvider.Now, TimeSpan.FromSeconds(1), 0, 1)); var oldAccount = new Account(1, TestHelper.NameMock, TestHelper.EmailAddressMock + 2, accountType); _testRoom.Add(oldAccount); usersCache.Add(new TimeWarpUserState(1, oldAccount, TimeWarpState.Resting, _fakeNowProvider.Now.Subtract(TimeSpan.FromDays(100)), TimeSpan.FromSeconds(1), 0, 1)); var state = _roomStateController.Get(2); Assert.AreEqual(1, state.Count()); Assert.AreEqual(0, state.Single().AccountId); }
protected void grvuserlist_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UserDetail") { #region 转到用户详细信息 Response.Redirect("UserDetail.aspx?UserId=" + e.CommandArgument); #endregion } if (e.CommandName == "UserState") { #region 更改用户状态 int userId = Convert.ToInt32(e.CommandArgument); Users user = UserManager.GetUserById(userId); if (user.UserStates.Id == 1) { user.UserStates.Id = 2; } else { user.UserStates.Id = 1; } user.UserStates = UserStateManager.GetUserStatesById(user.UserStates.Id); UserManager.UpdateUser(user); BindData(); #endregion } }
protected void btnadd_Click(object sender, EventArgs e) { #region 注册用户 Users user = new Users(); user.LoginId = txtLoginId.Text; user.LoginPwd = txtpwd.Text; user.Mail = txtmail.Text; user.Name = txtname.Text; user.Phone = txtphone.Text; user.Address = txtaddress.Text; foreach (ListItem lt in ddluserstate.Items) { if (lt.Selected == true) { user.UserStates = UserStateManager.GetUserStatesById(Convert.ToInt32(lt.Value)); } } foreach (ListItem lt in ddluserrole.Items) { if (lt.Selected == true) { user.UserRoles = UserRoleManager.GetUserRolesById(Convert.ToInt32(lt.Value)); } } if (UserManager.UserReg(user)) { Response.Redirect("ListAllUsers.aspx"); } else { labmessage.Text = "该用户名已被注册,请选择其他用户名"; } #endregion }
public void RequestIsValid_given_valid_token_returns_true() { var cache = new MemoryCache(new MemoryCacheOptions()); var stateManager = new UserStateManager(cache); var token = stateManager.CreateState(1, "ABC1234"); Assert.True(SecurityFilter.RequestIsValid(token, "ABC1234", stateManager)); }
private static Option <UserState> GetTestUserState() { var cache = new MemoryCache(new MemoryCacheOptions()); var stateManager = new UserStateManager(cache); var token = stateManager.CreateState(1, "ABC1234"); return(stateManager.GetState(token)); }
public void CreateState_given_integer_returns_valid_guid_token() { var cache = new MemoryCache(new MemoryCacheOptions()); var stateManager = new UserStateManager(cache); var token = stateManager.CreateState(1, "ABC1234"); Assert.True(Guid.TryParse(token, out _)); }
public void GetState_given_invalid_token_returns_Option_None() { var cache = new MemoryCache(new MemoryCacheOptions()); var stateManager = new UserStateManager(cache); stateManager.CreateState(1, "ABC1234"); var result = stateManager.GetState("invalidToken"); Assert.False(result.HasValue); }
public void BindDDL() { #region 绑定用户角色和状态 DataTable dtuserrole = UserRoleManager.GetAllUserRoles(); GridViewHelp.BindDDL(dtuserrole, ddluserrole, "Name", "Id"); DataTable dtuserstate = UserStateManager.GetAllUserState(); GridViewHelp.BindDDL(dtuserstate, ddluserstate, "Name", "Id"); #endregion }
public void CurrentUserProperty() { var expected = new Person(); var system = new UserStateManager(_session); system.CurrentUser = expected; var actual = system.CurrentUser; Assert.AreSame(expected, actual, "same object"); }
protected void btnallow_Click(object sender, EventArgs e) { #region 批量启用用户 foreach (GridViewRow grv in grvuserlist.Rows) { CheckBox chb = (CheckBox)grv.FindControl("cbok"); if (chb.Checked == true) { Users user = UserManager.GetUserById(Convert.ToInt32(grvuserlist.DataKeys[grv.RowIndex].Value)); user.UserStates = UserStateManager.GetUserStatesById(1); UserManager.UpdateUser(user); } } BindData(); #endregion }
public ActionResult SaveEntitlement(EditEntitlementModel model) { if (model.DateBegin > model.DateEnd) { ModelState.AddModelError("DateEnd", "The end date must be greather then begin date"); } if (ModelState.IsValid) { CheckUserAuthorization();//Check this user before save EEntitlement ent = model.ToEEntitlement(); EntitlementsProvider.SaveEntitlement(ent, UserStateManager.GetUserIdFromCookies(Request)); model.EntitlementId = ent.Id; return(RedirectToAction("EditEntitlement", "Entitlement", new { entitlementId = model.EntitlementId })); } LoadThirdElementsData(model); return(View("EditEntitlement", model)); }
public ActionResult LogIn(AuthenticateModel authParameters) { var cookMan = BaseBindings.CookiesManager; if (ModelState.IsValid) { try { if (UserStateManager.LogIn(Response, authParameters)) { return(RedirectToAction(nameof(Index))); } } catch (Exception ex) { ViewBag.Error = ex.Message; } } return(View(authParameters)); }
// Use this for initialization void Start() { GameObject ws = Instantiate(WebsocketManagerPrefab, this.transform); ws.name = "WebsocketManager"; GameObject um = Instantiate(UserManagerPrefab, this.transform); um.name = "UserStateManager"; UserStateManager usm = um.GetComponent <UserStateManager>(); usm.RegisterGameStateManager(this); ws.GetComponent <WebsocketManager> ().RegisterReceiver(this); ws.GetComponent <WebsocketManager> ().RegisterReceiver(usm); displayedGUI = new List <GameObject> (); EnterState(GameState.MENU_MAIN); }
protected UserControllerTestBase() { FakeNowProvider = new FakeNowProvider { Now = new DateTime(2000, 12, 12, 12, 12, 0) }; var usersCache = new MockUserStateRepository(); var calc = FakeTimeCalculatorFactory.GetTimeWarpStateCalculator(); var account = new Account(AccountId, TestHelper.NameMock, TestHelper.EmailAddressMock, AccountType.Full); var accountRepository = new MockAccountsRepository(); var authenticationManager = new MockTimeWarpAuthenticationManager(); var token = authenticationManager.AddUser(new AccountPassword(account, "bean")); accountRepository.Add(account); var timeWarpUser = new UserStateManager(calc, usersCache); Request = HttpRequestMock.MockRequest(); Request.Headers.Add("login-token", token); Controller = new UserStateController(timeWarpUser, FakeNowProvider, accountRepository, authenticationManager); }
public ActionResult EditEntitlement(decimal entitlementId) { CheckUserAuthorization(); if (entitlementId < 1) { RedirectToAction("Index", "Entitlements"); } decimal currentUser = UserStateManager.GetUserIdFromCookies(Request); var entitlement = EntitlementsProvider.GetEntitlement(entitlementId); if (entitlement == null) { RedirectToAction("Index", "Entitlements"); } if (entitlement.UserCreatorId == currentUser)//TODO check by project members { EditEntitlementModel model = new EditEntitlementModel(); model.LoadEntitlement(entitlement); LoadThirdElementsData(model); return(View("EditEntitlement", model)); } return(RedirectToAction("Index", "Entitlements")); }
/// <summary> /// Initialize a new instance of the AddNumberIntentHandler /// </summary> /// <param name="userStateAccessors"></param> public AddNumberIntentHandler(UserStateManager <SampleUserInfo> userInfoManager) { this.userInfoManager = userInfoManager; }
private static string CreateUserState(IMemoryCache cache, int userId, string sessionKey) { var sm = new UserStateManager(cache); return(sm.CreateState(userId, sessionKey)); }
public SessionController(ISessionRepository sessionRepo, IMemoryCache cache, ISummaryRepository summaryRepo) { this.sessionRepository = sessionRepo; this.summaryRepository = summaryRepo; this.userStateManager = new UserStateManager(cache); }
public ActionResult LogOut() { UserStateManager.LogOut(Request, Response); return(RedirectToAction(nameof(Index))); }
public MemorizedSumResultIntentHandler(UserStateManager <SampleUserInfo> userInfoManager) { this.userInfoManager = userInfoManager; }