public async Task <Messages> AddByUserIdsAsync(int roleId, List <int> userIds, UserClaimModel userClaim) { if (roleId > 0 && userIds != null && userIds.Count > 0) { using (DataTable dt = new DataTable()) { dt.Columns.Add("roleid", typeof(int)); dt.Columns.Add("userid", typeof(int)); foreach (int userid in userIds) { DataRow dr = dt.NewRow(); dr[0] = roleId; dr[1] = userid; dt.Rows.Add(dr); } bool result = await roleUserRepository.AddByDataTableAsync(dt); messages.Msg = result ? "添加成功!!" : "添加失败!!"; messages.Success = result; await logService.AddLogAsync(OperatorLogEnum.Create, string.Format("批量增加角色编号为:{0}的用户编号为{1}{2}", roleId, string.Join(",", userIds), messages.Msg), userClaim.UserId, userClaim.UserName); } } return(messages); }