public void Insert_Transaction() { using (var context = new Table()) { int ID; var userInfo = new UserVO() { UserName = "******", GetDate = DateTime.Now }; // 将标识设置到标识字段 context.User.Insert(userInfo, true); Assert.IsTrue(userInfo.ID > 0); if (!(Table.Data.DbProvider is PostgreSqlProvider)) { // 设置out ID userInfo.ID++; context.User.Insert(userInfo, out ID); Assert.IsTrue(userInfo.ID > 0 && userInfo.ID == ID); } // 不同逻辑删除方式新入(主键为GUID) context.Orders.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-1", CreateAt = DateTime.Now, CreateName = "用户1" }); context.OrdersAt.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-2", CreateAt = DateTime.Now, CreateName = "用户1" }); context.OrdersBool.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-3", CreateAt = DateTime.Now, CreateName = "用户1" }); context.OrdersNum.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-4", CreateAt = DateTime.Now, CreateName = "用户1" }); context.SaveChanges(); } }
public async Task <TokenVO> ValidateCredentials(UserVO userCredentials) { User user = await _service.ValidateCredentials(userCredentials); if (user == null) { return(null); } var claims = new List <Claim> { new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N")), new Claim(JwtRegisteredClaimNames.UniqueName, user.Username) }; var AccessToken = _TokenService.GenerateAccessToken(claims); var refreshToken = _TokenService.GenerateRefreshToken(); user.RefreshToke = refreshToken; user.RefreshTokenExpiryTime = DateTime.Now.AddDays(_configuration.DaysToExpire); DateTime createDate = DateTime.Now; DateTime expirationDate = createDate.AddMinutes(_configuration.Minutes); return(new TokenVO( true, createDate.ToString(DATE_FORMAT), expirationDate.ToString(DATE_FORMAT), AccessToken, refreshToken )); }
public void Insert() { var count = Table.Data.User.Count(); var currentCount = 0; UserVO info; using (var context = new Table()) { info = new UserVO() { UserName = "******" }; context.User.Insert(info, true); context.SaveChanges(); Assert.IsTrue(info.ID.GetValueOrDefault() > 0); info = context.User.Desc(o => o.ID).ToEntity(); Assert.IsTrue(info.UserName == "xx"); currentCount = context.User.Count(); Assert.IsTrue(currentCount == count + 1); } Table.Data.User.Insert(new UserVO() { UserName = "******" }); info = Table.Data.User.Desc(o => o.ID).ToEntity(); Assert.IsTrue(info.UserName == "yy"); currentCount = Table.Data.User.Count(); Assert.IsTrue(currentCount == count + 2); // GUID Table.Data.Orders.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "1234567890", CreateAt = DateTime.Now, CreateID = 1, CreateName = "用户1" }); }
public DomainMembershipUser(string providername, string username, object providerUserKey, string email, string passwordQuestion, string comment, bool isApproved, bool isLockedOut, DateTime creationDate, DateTime lastLoginDate, DateTime lastActivityDate, DateTime lastPasswordChangedDate, DateTime lastLockedOutDate, UserVO userVO) : base(providername, username, providerUserKey, email, passwordQuestion, comment, isApproved, isLockedOut, creationDate, lastLoginDate, lastActivityDate, lastPasswordChangedDate, lastLockedOutDate) { this.UserVO = userVO; }
public List <UserVO> findAllUsers() { List <UserVO> users = new List <UserVO>(); string sql = "select * from [User]"; SqlConnection connection = new SqlConnection("Data Source=127.0.0.1;Initial Catalog=rheaxu;Persist Security Info=True;User ID=rheaxu;Password=qGF8FeUu"); connection.Open(); SqlCommand command = new SqlCommand(sql, connection); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { string username = reader["username"].ToString(); string password = reader["password"].ToString(); string email = reader["email"].ToString(); string firstName = reader["firstName"].ToString(); string lastName = reader["lastName"].ToString(); DateTime dob = Convert.ToDateTime(reader["dob"]); UserVO user = new UserVO(username, password, email, firstName, lastName, dob); users.Add(user); } connection.Close(); return(users); }
public void create(UserVO newUser) { string sql = "INSERT INTO [User] (username, password,email,firstName,lastName,dob) VALUES(@username,@password,@email,@firstName,@lastName,@dob)"; SqlConnection connection = new SqlConnection("Data Source=127.0.0.1;Initial Catalog=rheaxu;Persist Security Info=True;User ID=rheaxu;Password=qGF8FeUu"); connection.Open(); SqlCommand command = new SqlCommand(sql, connection); SqlParameter usernameParam = new SqlParameter("@username", newUser.username); SqlParameter passwordParam = new SqlParameter("@password", newUser.password); SqlParameter emailParam = new SqlParameter("@email", newUser.email); SqlParameter firstNameParam = new SqlParameter("@firstName", newUser.firstName); SqlParameter lastNameParam = new SqlParameter("@lastName", newUser.lastName); SqlParameter dobParam = new SqlParameter("@dob", newUser.dob); command.Parameters.Add(usernameParam); command.Parameters.Add(passwordParam); command.Parameters.Add(emailParam); command.Parameters.Add(firstNameParam); command.Parameters.Add(lastNameParam); command.Parameters.Add(dobParam); command.ExecuteNonQuery(); connection.Close(); }
//#region Overrides //public override void ProcessCommand(Enum cmd, object arg) //{ // base.ProcessCommand(cmd, arg); //} //#endregion //public enum SplashScreenCommand //{ //} private void btnDangNhap_Click(object sender, EventArgs e) { int quyen = 1; if (rbQuanTri.Checked) { quyen = 1; } else { quyen = 2; } UserVO user = _userBUS.getUserEmailByName(txtTenDangNhap.Text, txtMatKhau.Text, quyen); Utils.Acount = user.TenDangNhap; if (user.Quyen == 1) { FormMainAdmin fm = new FormMainAdmin(); fm.ShowDialog(); } else { if (user.Quyen == 2) { FormMainGiaoVien fgvDN = new FormMainGiaoVien(); fgvDN.ShowDialog(); } else { MessageBox.Show("Xem lại thông tin đăng nhập", "Thông Báo"); } } }
public User ValidateCredentials(UserVO user) { var pass = ComputeHash(user.Password, new SHA256CryptoServiceProvider()); User userRet = _context.Users.SingleOrDefault(u => (u.UserName == user.UserName) && (u.Password == pass)); return(userRet); }
/// <summary> /// Set logged in user information /// </summary> /// <param name="session">The session object</param> public static void SetUser(this HttpSessionStateBase session, UserVO userVO) { if (session[SessionKeys.User] == null) { session[SessionKeys.User] = userVO; } }
public void LoadUserDetails() { UserManagementBO bo = new UserManagementBO(); UserVO vo = null; if (Username != null) { vo = bo.GetUser(Username); UserID = vo.UserID; } else if (UserID != 0) { vo = bo.GetUser(UserID); Username = vo.Username; } usernameLabel.Text = "<h1>" + vo.Username + "</h1>"; ratingLabel.Text = vo.Rating + " collective positive rating"; joinDateLabel.Text = "Joined on " + vo.RegisterDate.ToLongDateString(); if (Session["login"] != null) { if (Session["login"].ToString() == Username) { passwordChangePanel.Visible = true; } } //Load the content in the first time we visit if (!Page.IsPostBack) { GenerateRecentContent("submissions"); } }
public int UpdateUser(UserVO vo) { string sql = "update TBL_USER set user_name = @user_name, user_national = @user_national, user_hiredate = @user_hiredate, user_pwd = @user_pwd, user_phone = @user_phone, user_birth = @user_birth, department_id = @department_id, user_udate = replace(convert(varchar(10), getdate(), 120), '-', '-') where user_id = @user_id"; try { using (SqlCommand cmd = new SqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@user_id", vo.user_id); cmd.Parameters.AddWithValue("@user_name", vo.user_name); cmd.Parameters.AddWithValue("@user_national", vo.user_national); cmd.Parameters.AddWithValue("@user_hiredate", vo.user_hiredate); cmd.Parameters.AddWithValue("@user_pwd", vo.user_pwd); cmd.Parameters.AddWithValue("@user_phone", vo.user_phone); cmd.Parameters.AddWithValue("@user_birth", vo.user_birth); cmd.Parameters.AddWithValue("@department_id", vo.department_id); int iRow = cmd.ExecuteNonQuery(); return(iRow); } } catch (Exception err) { string msg = err.Message; return(0); } }
public void TestInitializeDB() { var db = new UserContext(); db.Database.CreateIfNotExists(); UserVO userTeste = new UserVO() { Domain = "testes", Email = "*****@*****.**", Logon = "george", Name = "George Hamilton Hamann" }; db.users.Add(userTeste); db.SaveChanges(); var dados = from u in db.users select u; foreach (var item in dados) { UserVO u = item; } }
private void btnDangky_Click(object sender, EventArgs e) { UserVO user = new UserVO(this.txtUser.Text, this.txtMatkhau.Text, this.txtEmail.Text, this.txtPhone.Text); StringBuilder builder = new StringBuilder(); builder.Append("dangky#"); builder.Append(user.UserName1); builder.Append("*"); builder.Append(user.PassWord1); builder.Append("*"); builder.Append(user.Email1); builder.Append("*"); builder.Append(user.Phone1); builder.Append("*"); connect.Bw.Write(builder.ToString()); connect.Bw.Flush(); string str = connect.Br.ReadString(); if (str == "True") { MessageBox.Show("Đăng ký thành công"); } else { MessageBox.Show("Đăng ký thất bại"); } }
public ActionResult Post([FromBody] UserVO userRequest) { try { bool authorize = _userService.ValidateUser(userRequest.Username, userRequest.Password); if (!authorize) { throw new UnauthorizedAccessException(); } var token = new JsonWebTokenVO { Expires_in = int.Parse(_configuration["Auth:Jwt:TokenExpirationInMinutes"]), Refresh_Token = "30 Minutes" }; Response.Headers.Add("access-control-expose-headers", "Authorization"); Response.Headers.Add("Authorization", "Bearer " + CreateToken()); return(Ok(token)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void Normal_Insert() { int ID; var userInfo = new UserVO() { UserName = "******", GetDate = DateTime.Now }; var insertUser = new InsertUserVO() { PassWord = "******", UserName = "******" }; // 将标识设置到标识字段 Table.Data.User.Insert(userInfo, true); Assert.IsTrue(userInfo.ID > 0); // 设置out ID userInfo.ID++; Table.Data.User.Insert(userInfo, out ID); Assert.IsTrue(userInfo.ID > 0 && userInfo.ID == ID); // 缓存表 Table.Data.UserRole.Insert(new UserRoleVO { Caption = "标题", Descr = "不清楚" }); // 不同逻辑删除方式新入(主键为GUID) Table.Data.Orders.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-1", CreateAt = DateTime.Now, CreateName = "用户1" }); Table.Data.OrdersAt.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-2", CreateAt = DateTime.Now, CreateName = "用户1" }); Table.Data.OrdersBool.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-3", CreateAt = DateTime.Now, CreateName = "用户1" }); Table.Data.OrdersNum.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-4", CreateAt = DateTime.Now, CreateName = "用户1" }); Table.Data.OrdersBoolCache.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-5", CreateAt = DateTime.Now, CreateName = "用户1" }); // 存储过程 Table.Data.InsertUser.Execute(insertUser); Assert.IsTrue(insertUser.ID > 0); // 配置SQL Table.Data.InsertNewUser.Execute(); // 手动SQL var table = Table.Data; table.ManualSql.Execute("INSERT INTO Members_User (UserName,PassWord) VALUES(@UserName,@PassWord)", table.DbProvider.CreateDbParam("UserName", "steden1"), table.DbProvider.CreateDbParam("PassWord", "steden1")); }
public void DoAuthenticationWithDbTest() { LdapAuthenticator ldapAuth = new LdapAuthenticator(); UserVO expected = ldapAuth.CreateSession("testes.nddigital.local", "matheus.silva", "ndd@123"); Assert.AreEqual(expected.Logon, "matheus.silva"); }
public void Transaction_Update() { using (var context = new Table()) { var userInfo = new UserVO() { UserName = "******", GetDate = DateTime.Now }; var ID = context.User.Desc(o => o.ID).GetValue(o => o.ID); // 重载 context.User.Update(userInfo, ID); // Where条件 context.User.Where(o => o.ID == ID).Update(userInfo); // 批量 var IDs = context.User.Desc(o => o.ID).ToSelectList(5, o => o.ID); context.User.Update(userInfo, IDs); // 缓存表 ID = context.UserRole.Cache.OrderByDescending(o => o.ID).GetValue(o => o.ID); context.UserRole.Update(new UserRoleVO { Caption = "标题", Descr = "不清楚" }, ID); // 不同逻辑删除方式新入(主键为GUID) var ID2 = context.Orders.Desc(o => o.ID).GetValue(o => o.ID); context.Orders.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-1", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); context.OrdersAt.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-2", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); context.OrdersBool.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-3", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); context.OrdersNum.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-4", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); context.OrdersBoolCache.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-5", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); // 手动SQL ID = context.User.Desc(o => o.ID).GetValue(o => o.ID); var table = context; table.ManualSql.Execute("UPDATE Members_User SET UserName=@UserName,PassWord =@PassWord WHERE ID = @ID", table.DbProvider.CreateDbParam("UserName", "steden1"), table.DbProvider.CreateDbParam("PassWord", "steden1"), table.DbProvider.CreateDbParam("ID", ID)); context.SaveChanges(); } }
public object FindByLogin(UserVO user) { bool credentialIsValid = false; if (user != null && !string.IsNullOrWhiteSpace(user.Login)) { var baseUser = _userRepository.FindByLogin(user.Login); credentialIsValid = (baseUser != null && user.Login == baseUser.Login && user.AccessKey == baseUser.AccessKey); } if (credentialIsValid) { ClaimsIdentity identity = new ClaimsIdentity( new GenericIdentity(user.Login, "Login"), new[] { new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N")), new Claim(JwtRegisteredClaimNames.UniqueName, user.Login) } ); DateTime createDate = DateTime.Now; DateTime expirationDate = createDate + TimeSpan.FromSeconds(_tokenConfiguration.Seconds); var handler = new JwtSecurityTokenHandler(); string token = CreateToken(identity, createDate, expirationDate, handler); return(SuccessObject(createDate, expirationDate, token)); } else { return(ExceptionObject()); } }
void btn_updateUser_Click() { m_user = new UserVO( txt_userName.text, txt_firstName.text, txt_lastName.text, txt_email.text, txt_password.text, txt_department.text); if (m_user.IsValid) { if (m_mode == UserFormMode.ADD) { if (AddUser != null) { AddUser(); } } else { if (UpdateUser != null) { UpdateUser(); } } } }
/// <summary> /// Save user details (new or edited user) /// </summary> /// <param name="userVO">user value object</param> public void SaveUser(UserVO userVO) { if (userVO != null && !string.IsNullOrEmpty(userVO.EmailID)) { UserVO userExist = userDAL.GetUserByEmailId(userVO.EmailID); //Check whether user already exist or not if (userExist != null && userVO.ID != userExist.ID) { throw new ApplicationException(Constants.EMAIL_ID_EXIST); } else { //Check if at least one company is associated with user if (!userVO.AssociatedCompanyList.Exists(x => x.IsSelected == true)) { throw new ApplicationException(Constants.USER_MUST_BE_ASSOCIATED_WITH_ATLEAST_ONE_COMPANY); } //Check if default company is assciated with selected companies bool isDefaultCompanyExistInAssociatedCompanyList = userVO.AssociatedCompanyList.Exists(x => x.IsSelected == true && x.CompanyID == userVO.DefaultCompanyId); if (isDefaultCompanyExistInAssociatedCompanyList == false) { throw new ApplicationException(Constants.DEFAULT_COMPANY_MUST_BE_FROM_SELECTED_COMPANY_LIST); } userVO.Password = MD5Hash(userVO.Password); userDAL.SaveUser(userVO); } } }
public async Task <ActionResult> GetPaths(string origin, string destination) { string Baseurl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/"; UserVO user = (UserVO)Session["userProfile"]; string[] paths = new string[10]; using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage Res = await client.GetAsync("api/Values/Get?origin=" + origin + "&destination=" + destination + "&userId=" + user.userId + "&password="******"paths"] = paths; } return(View("Index", ViewData)); } }
/// <summary> /// Save user details /// </summary> /// <param name="model">user model</param> public ActionResult UserSave(MODEL.UserModel model) { try { if (ModelState.IsValid) { //Get user id int?userId = Session.GetUserId(); //UserVO userVO = new UserVO(model, userId); UserVO userVO = model.Transpose(userId); UserService userService = new UserService(); userService.SaveUser(userVO); return(new HttpStatusCodeResult(200)); } else { throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.USER)); } } catch (Exception e) { return(new HttpStatusCodeAndErrorResult(500, e.Message)); } }
// remove a role from the user public void RemoveRoleFromUser(UserVO user, RoleEnum role) { if (DoesUserHaveRole(user, role)) { for (int i = 0; i < Roles.Count; i++) { if (Roles[i].UserName.Equals(user.UserName)) { IList <RoleEnum> userRoles = Roles[i].Roles; foreach (RoleEnum curRole in userRoles) { if (curRole.Equals(role)) { userRoles.Remove(role); SendNotification(NotiConst.DEL_ROLE, role); break; } } break; } } } }
public int RegistUser(UserVO vo) { string sql = @"insert into TBL_USER (user_name, user_national, user_hiredate, user_pwd, user_phone, user_birth, department_id) values(@user_name, @user_national, @user_hiredate, @user_pwd, @user_phone, @user_birth, @department_id)"; try { using (SqlCommand cmd = new SqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@user_name", vo.user_name); cmd.Parameters.AddWithValue("@user_national", vo.user_national); cmd.Parameters.AddWithValue("@user_hiredate", vo.user_hiredate); cmd.Parameters.AddWithValue("@user_pwd", vo.user_pwd); cmd.Parameters.AddWithValue("@user_phone", vo.user_phone); cmd.Parameters.AddWithValue("@user_birth", vo.user_birth); cmd.Parameters.AddWithValue("@department_id", vo.department_id); int iRow = cmd.ExecuteNonQuery(); return(iRow); } } catch (Exception err) { string msg = err.Message; return(0); } }
static void TestToList(int count = 100000) { var dt = Table.Data.User.ToTable(); for (var i = 0; i < count; i++) { dt.Rows.Add(1, "xxxxxx", "ffffffffff", 0, 0, "xxxx", 0, DateTime.Now); } SpeedTest.ConsoleTime("自动赋值", 1, () => { dt.ToList <UserVO>(); }); SpeedTest.ConsoleTime("手动赋值", 1, () => { var lst = new List <UserVO>(); foreach (DataRow row in dt.Rows) { var info = new UserVO { ID = row["ID"].ConvertType(0), UserName = row["UserName"].ConvertType(""), PassWord = row["PassWord"].ConvertType(""), GenderType = row["GenderType"].ConvertType(eumGenderType.Man), LogCount = row["LoginCount"].ConvertType(0), LoginIP = row["LoginIP"].ConvertType(""), CreateAt = row["CreateAt"].ConvertType(DateTime.Now), }; lst.Add(info); } }); }
public void ShowUser(UserVO user, UserFormMode mode) { if (!CheckAccess()) { Dispatcher.BeginInvoke(new ShowUserDelegate(ShowUser), new object[] { user, mode }); return; } m_mode = mode; if (user == null) { ClearForm(); } else { m_user = user; formGrid.DataContext = user; firstName.Text = user.FirstName; lastName.Text = user.LastName; email.Text = user.Email; userName.Text = user.UserName; password.Password = confirmPassword.Password = user != null ? user.Password : ""; department.SelectedItem = user.Department; firstName.Focus(); UpdateButtons(); } }
public List <UserVO> deserializeToListUsers(string response) { IDictionary search = Json.Deserialize(response) as IDictionary; List <UserVO> users = new List <UserVO>(); foreach (var key in search.Keys) { IDictionary temp = (IDictionary)search[key]; UserVO user = new UserVO(); user.key = key.ToString(); user.username = temp["username"].ToString(); user.email = temp["email"].ToString(); user.password = temp["password"].ToString(); user.isTeacher = (bool)temp["isTeacher"]; List <object> sbj = temp["subjects"] as List <object>; List <string> subjects = new List <string>(); foreach (var item in sbj) { subjects.Add(item.ToString()); } user.subjects = subjects; user.status = false; users.Add(user); } return(users); }
public HttpResponseMessage outstoretallying(int isscanf, int outtype, string outno, string datacode) { List <DBData> list = new List <DBData>(); UserVO userByPk = UserBO.GetUserByPk(base.User.Identity.Name); return(HttpHelper.toJson(OutStoretallyingBo.outstoretallying(isscanf, outtype, outno, datacode, userByPk.Code))); }
public object FindByLogin(UserVO user) { var credendialsIsValid = false; if (user != null && !string.IsNullOrWhiteSpace(user.Login)) { var userBase = _userRepository.FindByLogin(user.Login); credendialsIsValid = (userBase != null && user.Login.Equals(userBase.Login) && user.AccessKey.Equals(userBase.AccessKey)); } if (!credendialsIsValid) { return(ExceptionObject()); } ClaimsIdentity claimsIdentity = new ClaimsIdentity( new GenericIdentity(user.Login, "Login"), new[] { new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N")), new Claim(JwtRegisteredClaimNames.UniqueName, user.Login) } ); DateTime createDate = DateTime.Now; DateTime expirationDate = createDate + TimeSpan.FromSeconds(_tokenConfiguration.Seconds); //JwtSecurityTokenHandler = classe responsavel por criar o Token var handler = new JwtSecurityTokenHandler(); string token = CreateToken(claimsIdentity, createDate, expirationDate, handler); return(SuccessObject(createDate, expirationDate, token)); }
public IActionResult Create([FromBody] UserVO user) { var userDO = new UserDO { UserNumber = user.UserNumber, UserPassword = user.UserPassword, Email = user.Email, Radio = user.Radio, City = user.City, Date = user.Date }; try { var inserteduser = _userService.Insert(userDO); return(Json(new { code = "success", data = inserteduser })); } catch (Exception ex) { return(Json(new { code = "fail", message = ex.Message })); } }
/// <summary> /// 增加item /// </summary> /// <param name="user"></param> public void AddUserItem(UserVO user) { if (Users != null) { Users.Add(user); } }
public ActionResult ResetPassword(String email) { UserModel userModel = null; try { if (ModelState.IsValid) { UserService userService = new UserService(); UserVO userVO = new UserVO(); userVO = userService.GetUserByEmailIdForForgotPassword(email); //Validate the User Model if (userVO != null) { userModel = new UserModel(userVO); string temporaryPassword = GenerateRandomPassword(); userService.SetTemporaryPassword(userVO, temporaryPassword); SendResetPasswordMail(email, userVO.UserName, temporaryPassword); } else { ModelState.AddModelError(string.Empty, "The email address entered does not exist."); } return(new HttpStatusCodeResult(200)); } } catch (Exception e) { return(new HttpStatusCodeAndErrorResult(500, e.Message)); } return(View()); }
/// <summary> /// 删除Item /// </summary> /// <param name="user"></param> public void RemoveUserItem(UserVO user) { if (Users != null && Users.Contains(user)) { Users.Remove(user); } }
private void btnDangnhap_Click(object sender, EventArgs e) { UserVO user = new UserVO(this.txtUser.Text, this.txtMatkhau.Text, "", ""); StringBuilder builder = new StringBuilder(); builder.Append("dangnhap#"); builder.Append(user.UserName1); builder.Append("*"); builder.Append(user.PassWord1); builder.Append("*"); connect.Bw.Write(builder.ToString()); connect.Bw.Flush(); string str = connect.Br.ReadString(); if (str == "False") { MessageBox.Show("Tài khoản không tồn tại"); } else { frmXacnhan frm = new frmXacnhan(this); frm.ShowDialog(); if (check) { connect.UserID = Int32.Parse(str); this.Close(); frmCAmanager frmManager = new frmCAmanager(connect); frmManager.Show(); } } }
public TokenVO ValidateCredentials(UserVO userCredentials) { var user = _repository.ValidateCredentials(userCredentials); if (user == null) { return(null); } var claims = new List <Claim> { new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N")), new Claim(JwtRegisteredClaimNames.UniqueName, user.UserName) }; var accessToken = _tokenService.GenerateAccessToken(claims); var refreshToken = _tokenService.GenerateRefreshToken(); user.RefreshToken = refreshToken; user.RefreshTokenExpiryTime = DateTime.Now.AddDays(_configuration.DaysToExpiry); _repository.RefreshUserInfo(user); DateTime createDate = DateTime.Now; DateTime expirationDate = createDate.AddMinutes(_configuration.Minutes); return(new TokenVO( true, createDate.ToString(DATE_FORMAT), expirationDate.ToString(DATE_FORMAT), accessToken, refreshToken )); }
protected void Page_Load(object sender, EventArgs e) { Collection<UserVO> vos = new Collection<UserVO>(); for (int i = 0; i < 10; i++) { UserVO vo = new UserVO(); vo.Id = i.ToString(); vo.Name = "name " + i.ToString(); vos.Add(vo); } gvUserDetails.DataSource = vos; gvUserDetails.DataBind(); }
/// <summary> /// @see MembershipExample.Domain.IUserDao#UserVOToEntity(MembershipExample.VO.UserVO) /// </summary> public User UserVOToEntity(UserVO userVO) { if (userVO == null) { return null; } // VO to entity conversion User entity = User.Factory.NewInstance(); entity.Id = userVO.Id; entity.Username = userVO.Username; entity.Email = userVO.Email; entity.IsActive = userVO.IsActive; entity.Comment = userVO.Comment; entity.CreationDate = userVO.CreationDate; return entity; }
static void TestGetValueCache(int count = 1000000) { var user = new UserVO(); var propertyInfo = user.GetType().GetProperty("UserName"); SpeedTest.ConsoleTime("手动取值", count, () => { var a = user.UserName; }); SpeedTest.ConsoleTime("表达式树取值", count, () => { var a = PropertyGetCacheManger.Cache(propertyInfo, user); }); SpeedTest.ConsoleTime("反射取值", count, () => { var a = propertyInfo.GetValue(user, null); }); }
static void TestSetValueCache(int count = 10000000) { var user = new UserVO(); var propertyInfo = user.GetType().GetProperty("UserName"); SpeedTest.ConsoleTime("手动赋值", count, () => { user.UserName = "******"; }); SpeedTest.ConsoleTime("表达式树赋值", count, () => { CacheManger.SetValue(propertyInfo, user, "jj"); }); SpeedTest.ConsoleTime("反射赋值", count, () => { propertyInfo.SetValue(user, "jj", null); }); }
protected void Page_Load(object sender, EventArgs e) { Collection<UserVO> vos = new Collection<UserVO>(); for (int i = 0; i < 10; i++) { UserVO vo = new UserVO(); vo.Id = i.ToString(); vo.Name = "name " + i.ToString(); vos.Add(vo); } Collection<PurchaseOrderHeaderText> objs = PurchaseOrderController.SearchPurchaseOrder(); gvUserDetails.DataSource = objs; gvUserDetails.DataBind(); }
/// <summary> /// @see MembershipExample.Domain.IUserDao#ToUserVO(MembershipExample.Domain.User) /// </summary> public UserVO ToUserVO(User entity) { if (entity == null) { return null; } string[] roles = new string[entity.Roles.Count]; int i = 0; foreach (UserRole role in entity.Roles) { roles[i++] = role.Role.ToString(); } UserVO userVO = new UserVO(entity.Id, entity.Username, entity.Email, entity.IsActive, entity.Comment, entity.CreationDate, roles); return userVO; }
public void Insert_Normal() { int ID; var userInfo = new UserVO() { UserName = "******", GetDate = DateTime.Now }; // 将标识设置到标识字段 Table.Data.User.Insert(userInfo, true); Assert.IsTrue(userInfo.ID > 0); if (!(Table.Data.DbProvider is PostgreSqlProvider)) { // 设置out ID userInfo.ID++; Table.Data.User.Insert(userInfo, out ID); Assert.IsTrue(userInfo.ID > 0 && userInfo.ID == ID); } // 不同逻辑删除方式新入(主键为GUID) Table.Data.Orders.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-1", CreateAt = DateTime.Now, CreateName = "用户1" }); Table.Data.OrdersAt.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-2", CreateAt = DateTime.Now, CreateName = "用户1" }); Table.Data.OrdersBool.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-3", CreateAt = DateTime.Now, CreateName = "用户1" }); Table.Data.OrdersNum.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-4", CreateAt = DateTime.Now, CreateName = "用户1" }); }
/// <summary> /// @see MembershipExample.Service.MembershipService#CreateUser(User) /// </summary> protected void HandleCreateUser(UserVO userVo, string password) { User entity = this.UserDao.UserVOToEntity(userVo); entity.Password = password; this.UserDao.Create(entity); }
/// <summary> /// @see MembershipExample.Service.MembershipService#IsUserInRole(User user, RoleType role) /// </summary> protected bool HandleIsUserInRole(UserVO user, Role role) { foreach (string currole in user.Roles) { if (currole.Equals(role.ToString())) { return true; } } return false; }
public UserVO EchoUser(UserVO user) { return user; }
public UserVO GetUser() { UserVO user = new UserVO(); user.userid = 1; user.username = "******"; EmailVO email = new EmailVO(); email.emailaddress = "someaddress@com"; user.email = email; return user; }
/// <summary> /// @see MembershipExample.Service.MembershipService#UpdateUser(User) /// </summary> protected void HandleUpdateUser(UserVO membershipUser) { User entity = this.UserDao.Load(membershipUser.Id); entity.Comment = membershipUser.Comment; entity.Email = membershipUser.Email; entity.IsActive = membershipUser.IsActive; // Synchronize roles if (membershipUser.Roles != null) { ArrayList rolesToRemove = new ArrayList(); foreach (UserRole role in entity.Roles) { if (!RoleIsInList(membershipUser.Roles, role.Role)) { rolesToRemove.Add(role); } } foreach (UserRole role in rolesToRemove) { entity.Roles.Remove(role); } foreach (string rolestring in membershipUser.Roles) { UserRole role = RoleIsInList(entity.Roles, rolestring); if (role == null) { role = UserRole.Factory.NewInstance(); role.Role = (Role)Enum.Parse(typeof(Role), rolestring); role.User = entity; entity.Roles.Add(role); } } } this.UserDao.Update(entity); }
static void TestToList(int count = 100000) { var dt = Tablex.Data.User.ToTable(); for (var i = 0; i < count; i++) { dt.Rows.Add(1, "xxxxxx", "ffffffffff", 0, 0, "xxxx", 0, DateTime.Now); } SpeedTest.ConsoleTime("自动赋值", 1, () => { dt.ToList<UserVO>(); }); SpeedTest.ConsoleTime("手动赋值", 1, () => { var lst = new List<UserVO>(); foreach (DataRow row in dt.Rows) { var info = new UserVO { ID = row["ID"].ConvertType(0), UserName = row["UserName"].ConvertType(""), PassWord = row["PassWord"].ConvertType(""), GenderType = row["GenderType"].ConvertType(eumGenderType.Man), LogCount = row["LoginCount"].ConvertType(0), LoginIP = row["LoginIP"].ConvertType(""), CreateAt = row["CreateAt"].ConvertType(DateTime.Now), }; lst.Add(info); } }); }
private MembershipUser ConvertUserVOToMembershipUser(UserVO userVO) { if (userVO == null) return null; DateTime createDate = DateTime.MinValue; if (userVO.CreationDate.HasValue) createDate = userVO.CreationDate.Value; return new DomainMembershipUser(this.Name, userVO.Username, userVO.Id, userVO.Email, string.Empty, userVO.Comment, true, !userVO.IsActive, DateTime.MinValue, createDate, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, userVO); }
private UserVO ConvertMembershipUserToUserVO(MembershipUser membershipUser) { if (membershipUser == null) return null; UserVO userVO = new UserVO(); if (membershipUser.ProviderUserKey != null) { userVO.Id = (long)membershipUser.ProviderUserKey; } userVO.Username = membershipUser.UserName; userVO.Email = membershipUser.Email; userVO.Comment = membershipUser.Comment; userVO.IsActive = !membershipUser.IsLockedOut; userVO.CreationDate = membershipUser.CreationDate; return userVO; }
public void Update_Transaction() { using (var context = new Table()) { var userInfo = new UserVO() { UserName = "******", GetDate = DateTime.Now }; var ID = context.User.Desc(o => o.ID).GetValue(o => o.ID); // 重载 context.User.Update(userInfo, ID); // Where条件 context.User.Where(o => o.ID == ID).Update(userInfo); // 批量 var IDs = context.User.Desc(o => o.ID).ToSelectList(5, o => o.ID); context.User.Update(userInfo, IDs); var ID2 = context.Orders.Desc(o => o.ID).GetValue(o => o.ID); context.Orders.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-1", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); context.OrdersAt.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-2", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); context.OrdersBool.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-3", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); context.OrdersNum.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-4", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); context.SaveChanges(); } }
/// <summary> /// Adds a new membership user to the data source. /// </summary> /// <param name="username">The user name for the new user.</param> /// <param name="password">The password for the new user.</param> /// <param name="email">The e-mail address for the new user.</param> /// <param name="passwordQuestion">The password question for the new user.</param> /// <param name="passwordAnswer">The password answer for the new user</param> /// <param name="isApproved">Whether or not the new user is approved to be validated.</param> /// <param name="providerUserKey">The unique identifier from the membership data source for the user.</param> /// <param name="status">A <see cref="T:System.Web.Security.MembershipCreateStatus"></see> enumeration value indicating whether the user was created successfully.</param> /// <returns> /// A <see cref="T:System.Web.Security.MembershipUser"></see> object populated with the information for the newly created user. /// </returns> public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { UserVO userVO = new UserVO(); userVO.Username = username; userVO.Email = email; userVO.IsActive = !isApproved; userVO.CreationDate = DateTime.Now; string pass = EncodePassword(password, (int)_PasswordFormat, GetSalt()); if (pass.Length > 128) { status = MembershipCreateStatus.InvalidPassword; return null; } if (MembershipService.GetUser(username) != null) { status = MembershipCreateStatus.DuplicateUserName; return null; } if (this.RequiresUniqueEmail && !string.IsNullOrEmpty(MembershipService.GetUserNameByEmail(email))) { status = MembershipCreateStatus.DuplicateEmail; return null; } MembershipService.CreateUser(userVO, pass); status = MembershipCreateStatus.Success; return ConvertUserVOToMembershipUser(userVO); }
public void Update_Normal() { var userInfo = new UserVO() { UserName = "******", GetDate = DateTime.Now }; var ID = Table.Data.User.Desc(o => o.ID).GetValue(o => o.ID); // 重载 Table.Data.User.Update(userInfo, ID); // Where条件 Table.Data.User.Where(o => o.ID == ID).Update(userInfo); // 批量 var IDs = Table.Data.User.Desc(o => o.ID).ToSelectList(5, o => o.ID); Table.Data.User.Update(userInfo, IDs); var ID2 = Table.Data.Orders.Desc(o => o.ID).GetValue(o => o.ID); Table.Data.Orders.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-1", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); Table.Data.OrdersAt.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-2", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); Table.Data.OrdersBool.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-3", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); Table.Data.OrdersNum.Update(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-4", CreateAt = DateTime.Now, CreateName = "用户1" }, ID2); }