/// <summary> /// 添加用户 /// </summary> /// <param name="dbHelper">数据库连接</param> /// <param name="userInfo">用户信息</param> /// <param name="userEntity">用户实体</param> /// <param name="statusCode">状态码</param> /// <param name="statusMessage">状态信息</param> /// <returns>主键</returns> public string AddUser(IDbHelper dbHelper, BaseUserInfo userInfo, BaseUserEntity userEntity, out string statusCode, out string statusMessage) { // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif string returnValue = string.Empty; BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); // 若是系统需要用加密的密码,这里需要加密密码。 if (BaseSystemInfo.ServerEncryptPassword) { userEntity.UserPassword = userManager.EncryptUserPassword(userEntity.UserPassword); // 安全通讯密码、交易密码也生成好 userEntity.CommunicationPassword = userManager.EncryptUserPassword(userEntity.CommunicationPassword); } returnValue = userManager.Add(userEntity, out statusCode); statusMessage = userManager.GetStateMessage(statusCode); // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了 if (userEntity.Enabled == 0 && statusCode.Equals(StatusCode.OKAdd.ToString())) { // 不是系统管理员添加 if (!userInfo.IsAdministrator) { // 给超级管理员群组发信息 BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo); string[] roleIds = roleManager.GetIds(new KeyValuePair <string, object>(BaseRoleEntity.FieldCode, "Administrators")); string[] userIds = userManager.GetIds(new KeyValuePair <string, object>(BaseUserEntity.FieldCode, "Administrator")); // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.FunctionCode = MessageFunction.WaitForAudit.ToString(); // Pcsky 2012.05.04 显示申请的用户名 messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.UserName + AppMessage.UserService_Check; //messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.RealName + AppMessage.UserService_Check; BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo); messageManager.BatchSend(userIds, null, roleIds, messageEntity, false); } } return(returnValue); }