using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using Bowin.Common.Utility; using Bowin.Common.Mail; using Bowin.Common.Log; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.SystemView; using EMIS.DataLogic.SystemDAL; namespace EMIS.CommonLogic.SystemServices { public class MailVerifyServices : BaseServices, IMailVerifyServices { public UserDAL UserDAL { get; set; } public MailVerifyCodeDAL MailVerifyCodeDAL { get; set; } public void SendVerifyMail(string applicationPath, Guid userID, string email) { var user = UserDAL.UserRepository.GetSingle(x => x.UserID == userID, (x => x.Sys_MailVerifyCode)); if (user == null) throw new Exception("验证码发送失败,无法找到该用户的信息。"); string verifyCode = Guid.NewGuid().ToString().Replace("-", ""); string title = "【验证邮件】欢迎使用鉴定考试报名管理系统"; string content = user.Name + @",你好:

感谢您使用鉴定考试报名管理系统,请点击以下链接进行密码修改:
" + verifyCode.ToUpper() + ""; try { MailHelper.SendMail(email, title, content); var userVerifyCode = MailVerifyCodeDAL.MailVerifyCodeRepository.GetSingle(x => x.UserID == userID); if (userVerifyCode != null) { UnitOfWork.Remove(userVerifyCode); } userVerifyCode = new Sys_MailVerifyCode() { UserID = userID, VerifyCode = verifyCode, RecordStatus = (int)SYS_STATUS.USABLE, CreateTime = DateTime.Now, CreateUserID = userID, ModifyTime = DateTime.Now, ModifyUserID = userID }; UnitOfWork.Add(userVerifyCode); UnitOfWork.Commit(); } catch (Exception ex) { throw (ex); } } public bool Verify(Guid userID, string verifyCode) { var userVerifyCode = MailVerifyCodeDAL.MailVerifyCodeRepository.GetSingle(x => x.UserID == userID); if (userVerifyCode == null || userVerifyCode.VerifyCode.Trim() != verifyCode.Trim()) { return false; } return true; } } }