Beispiel #1
0
 /// <summary>
 /// 新增用户
 /// </summary>
 /// <param name="userDto"></param>
 /// <returns></returns>
 public bool InsertUser(UserDto userDto)
 {
     try
     {
         _sysUserRepository.BeginTran();//开始事务
         SysUser User = new SysUser();
         User.Id           = IdWorkerHelper.NewId();
         User.Account      = userDto.Account;
         User.Password     = DESEncrypt.Encrypt(userDto.Password);
         User.RealName     = userDto.RealName;
         User.Gender       = userDto.Gender;
         User.DepartmentId = userDto.DepartmentId;
         User.Birthday     = userDto.Birthday;
         User.Portrait     = userDto.Portrait;
         User.Email        = userDto.Email;
         User.Phone        = userDto.Phone;
         User.Remark       = userDto.Remark;
         User.Status       = (int)StatusType.Enabled;
         User.IsDeleted    = (int)IsDeletedType.No;
         User.CreateTime   = DateTime.Now;
         User.CreateUserId = _userHelper.Id;
         User.ModifyTime   = DateTime.Now;
         User.ModifyUserId = _userHelper.Id;
         bool result = _sysUserRepository.Insert(User);
         _sysUserRepository.CommitTran();
         return(result);
     }
     catch (Exception ex)
     {
         _sysUserRepository.RollbackTran();//回滚事务
         throw ex;
     }
 }
Beispiel #2
0
 public void InsertData(sys_user dto)
 {
     dto.id            = IdWorkerHelper.NewId();
     dto.create_time   = DateTime.Now;
     dto.create_person = UserCookie.AccountName;
     dto.fax           = dto.fax ?? string.Empty;
     dto.email         = dto.email ?? string.Empty;
     dto.mobile_phone  = dto.mobile_phone ?? string.Empty;
     _sysuserRepository.Insert(dto);
 }
Beispiel #3
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="sysUserInfo"></param>
        /// <returns></returns>
        public bool AddSysUser(SysUserInfo sysUserInfo)
        {
            sysUserInfo.SysNo = EntityGuid.NewComb();
            //获取混淆码
            string passwordSalt = SecurityHelper.GenerateSalt();
            //获取混淆码加密过的密码
            string passwordHash = SecurityHelper.EncodePassword(sysUserInfo.PasswordHash, passwordSalt);

            sysUserInfo.PasswordHash = passwordHash;
            sysUserInfo.PasswordSalt = passwordSalt;

            return(_sysUserRepository.Insert(sysUserInfo) > 0);
        }
Beispiel #4
0
        public void SubmitForm(UserInputDto userInputDto, UserInfo userinfo)
        {
            if (!string.IsNullOrEmpty(userInputDto.Id)) //更新
            {
                SysUserEntity entity = _sysUserRepository.Get(userInputDto.Id);
                entity.UserName    = userInputDto.UserName;
                entity.TrueName    = userInputDto.TrueName;
                entity.QQ          = userInputDto.QQ;
                entity.PhoneNumber = userInputDto.PhoneNumber;
                if (!string.IsNullOrEmpty(userInputDto.RoleId))
                {
                    SysRole2UserEntity roleEntity = _sysRole2UserRepository.GetAll().Where(t => t.SysRoleId.Equals(userInputDto.Id)).FirstOrDefault();
                    if (roleEntity != null)
                    {
                        roleEntity.SysRoleId = userInputDto.RoleId;
                        _sysRole2UserRepository.Update(roleEntity);
                    }
                    else
                    {
                        roleEntity           = new SysRole2UserEntity();
                        roleEntity.Id        = Guid.NewGuid().ToString();
                        roleEntity.SysRoleId = userInputDto.RoleId;
                        roleEntity.SysUserId = entity.Id;
                        _sysRole2UserRepository.Insert(roleEntity);
                    }
                }
                _sysUserRepository.Update(entity);
            }
            else
            {
                SysUserEntity entity = AutoMapper.Mapper.Map <SysUserEntity>(userInputDto);
                entity.Id           = Guid.NewGuid().ToString();
                entity.Password     = Common.Utils.Md5.GetMD5("123456");
                entity.CreatePerson = userinfo.UserID;
                entity.CreateTime   = DateTime.Now;
                _sysUserRepository.Insert(entity);

                SysRole2UserEntity roleEntity = new SysRole2UserEntity();
                roleEntity.Id        = Guid.NewGuid().ToString();
                roleEntity.SysRoleId = userInputDto.RoleId;
                roleEntity.SysUserId = entity.Id;
                _sysRole2UserRepository.Insert(roleEntity);
            }
        }
 public long InsertUser(SysUser user)
 {
     return(userDao.Insert(user));
 }