监控时间

This commit is contained in:
2022-04-20 11:00:13 +08:00
parent 84a505bcc4
commit 3de8087fcc
6 changed files with 30 additions and 70 deletions
@@ -59,22 +59,7 @@ namespace IRaCIS.Application.Services
[HttpPost]
public async Task<IResponseOutput> AddOrUpdateBasicDic(AddOrEditBasicDic addOrEditBasic)
{
//if (addOrEditBasic.Id == null)
//{
// var entity = await _dicRepository.InsertDictionaryAsync(addOrEditBasic);
// await _dicRepository.UpdateFromQueryAsync(t => t.ParentId == Guid.Empty,
// u => new Dictionary() { ParentId = null });
// return ResponseOutput.Ok(entity.Id.ToString());
//}
//else
//{
// var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
// return ResponseOutput.Ok(entity.Id.ToString());
//}
var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
return ResponseOutput.Ok(entity.Id.ToString());
@@ -187,7 +187,6 @@ namespace IRaCIS.Application.Services
public async Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode)
{
@@ -236,52 +235,7 @@ namespace IRaCIS.Application.Services
}
}
public async Task SendEmailForExternalUser(string emailAddress, string verificationCode)
{
var messageToSend = new MimeMessage();
//发件地址
messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com"));
//收件地址
messageToSend.To.Add(new MailboxAddress(String.Empty, emailAddress));
//主题
messageToSend.Subject = "GRR External User survey (Verification Code)";
messageToSend.Body = new TextPart("plain")
{
Text = $@"Hey ,you are login for site survey via email. The verification code is: {verificationCode}, If it is not your own operation, please ignore it!
-- GRR"
};
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
{
smtp.MessageSent += (sender, args) =>
{
// args.Response
var code = verificationCode.ToString();
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
{
CodeType = 0,
HasSend = true,
Code = code,
UserId = Guid.Empty,//此时不知道用户
EmailOrPhone = emailAddress,
ExpirationTime = DateTime.Now.AddMinutes(3)
}).Result;
_ = _verificationCodeRepository.SaveChangesAsync().Result;
};
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
await smtp.ConnectAsync("smtp.163.com", 25, SecureSocketOptions.StartTls);
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
await smtp.SendAsync(messageToSend);
await smtp.DisconnectAsync(true);
}
}
}
}