public void AddLogin(LoginEntity loginEntity, string password) { UserPassowrdEntity pwdEntity = new UserPassowrdEntity(); pwdEntity.UserId = loginEntity.UserId; pwdEntity.UserName = loginEntity.UserName; pwdEntity.IsCanLogin = loginEntity.IsCanLogin; pwdEntity.RegisterTime = DateTime.Now; pwdEntity.Password = EncryptTool.MD5(password); persistence.Add(pwdEntity); }
public void Register(UserInfo user, string password) { LoginEntity loginEntity = new LoginEntity(); loginEntity.UserId = user.UserId; loginEntity.UserName = user.UserName; loginEntity.IsCanLogin = true; UserBaseEntity userBaseEntity = new UserBaseEntity(); userBaseEntity.UserId = user.UserId; userBaseEntity.RealName = user.RealName; userBaseEntity.Email = user.Email; userBaseEntity.CardType = user.IdCardType; userBaseEntity.CardNumber = user.IdCardNumber; userBaseEntity.Mobile = user.Mobile; UserBalanceEntity balanceEntity = new UserBalanceEntity(); balanceEntity.UserId = user.UserId; balanceEntity.Balance = 0; balanceEntity.Freeze = 0; try { using (ILHDBTran tran = BeginTran()) { UserManager manager = new UserManager(tran); password = EncryptTool.MD5(password); manager.AddLogin(loginEntity, password); manager.AddUserBase(userBaseEntity); manager.AddBalance(balanceEntity); tran.Commit(); } } catch (Exception ex) { string errMsg = "注册新用户失败 - 系统异常,请联系系统管理员!"; throw HandleException(LogCategory.Register, errMsg, ex); } }