/// <summary> /// 发送邮件 /// </summary> /// <param name="mailOutBox"></param> /// <param name="mailContent"></param> /// <param name="isAdd">是否新增</param> /// <returns></returns> public int Send(Model.MailOutBox mailOutBox, Model.MailContent mailContent, bool isAdd) { Organize organize = new Organize(); return(mailOutBoxData.Send(mailOutBox, mailContent, organize.GetAllUsers(mailOutBox.ReceiveUsers), organize.GetAllUsers(mailOutBox.CarbonCopy), organize.GetAllUsers(mailOutBox.SecretCopy), isAdd)); }
/// <summary> /// 得到一批人员所在部门所有人员 /// </summary> /// <param name="userId">guid(人ID),u_guid(人ID),r_guid(关系表ID)</param> /// <returns></returns> public List <Model.User> GetOrganizeUsers(List <string> userIds) { List <Model.User> users = new List <Model.User>(); Organize organize = new Organize(); foreach (string userId in userIds) { Guid organzieId = GetOrganizeId(userId); users.AddRange(organize.GetAllUsers(organzieId)); } return(users); }
/// <summary> /// 发布一个问卷 /// </summary> /// <param name="voteId"></param> /// <param name="localizer">语言包</param> /// <returns>返回“1”发布成功,其它为错误信息</returns> public string Publish(Guid voteId, IStringLocalizer localizer = null) { var voteModel = GetVote(voteId); if (null == voteModel) { return(localizer == null ? "未找到要发布的问卷!" : localizer["NotFoundPublishVote"]); } if (voteModel.Status != 0) { return(localizer == null ? "该问卷已发布!" : localizer["VoteIsPublish"]); } if (voteModel.PartakeUsers.IsNullOrWhiteSpace()) { return(localizer == null ? "该问卷没有设置要参与的人员!" : localizer["VoteNotSetUser"]); } Organize organize = new Organize(); var users = organize.GetAllUsers(voteModel.PartakeUsers); if (users.Count == 0) { return(localizer == null ? "该问卷没有要参与的人员!" : localizer["VoteNotSetUser"]); } if (GetVoteItems(voteId).Count == 0) { return(localizer == null ? "该问卷未设置选题!" : localizer["VoteNotTopic"]); } if (voteModel.ResultViewUsers.IsNullOrWhiteSpace()) { return(localizer == null ? "该问卷没有设置结果查看人员!" : localizer["VoteNotSetResustViewUser"]); } var resultUsers = organize.GetAllUsers(voteModel.ResultViewUsers); if (resultUsers.Count == 0) { return(localizer == null ? "该问卷没有结果查看人员!" : localizer["VoteNotSetResustViewUser"]); } User buser = new User(); List <Model.VotePartakeUser> votePartakeUsers = new List <Model.VotePartakeUser>(); foreach (var user in users) { votePartakeUsers.Add(new Model.VotePartakeUser() { Id = Guid.NewGuid(), UserId = user.Id, UserName = user.Name, UserOrganize = buser.GetOrganizeMainShowHtml(user.Id, false), VoteId = voteId, Status = 0 }); } List <Model.VoteResultUser> voteResultUsers = new List <Model.VoteResultUser>(); foreach (var user in resultUsers) { voteResultUsers.Add(new Model.VoteResultUser() { Id = Guid.NewGuid(), UserId = user.Id, VoteId = voteId }); } //if (!voteResultUsers.Exists(p => p.Id == voteModel.CreateUserId))//如果结果查询人员没有选择自己加上自己 //{ // voteResultUsers.Add(new Model.VoteResultUser() // { // Id = Guid.NewGuid(), // UserId = voteModel.CreateUserId, // VoteId = voteId // }); //} return(votePartakeUserData.Add(votePartakeUsers, voteResultUsers) > 0 ? "1" : (localizer == null ? "发布失败!" : localizer["PublishFail"])); }