修改邮件端口测试
parent
341b176f41
commit
e540c32bce
|
@ -0,0 +1,35 @@
|
||||||
|
using MailKit;
|
||||||
|
using MailKit.Security;
|
||||||
|
using MimeKit;
|
||||||
|
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Application.Helper;
|
||||||
|
|
||||||
|
public static class SendEmailHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public static async Task SendEmailAsync(MimeMessage messageToSend, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||||
|
{
|
||||||
|
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||||
|
{
|
||||||
|
if (messageSentSuccess != null)
|
||||||
|
{
|
||||||
|
smtp.MessageSent += messageSentSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||||
|
|
||||||
|
await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls);
|
||||||
|
|
||||||
|
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
||||||
|
|
||||||
|
await smtp.SendAsync(messageToSend);
|
||||||
|
|
||||||
|
await smtp.DisconnectAsync(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ using IRaCIS.Core.Domain.Models;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using MailKit.Security;
|
using MailKit.Security;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
|
using MailKit;
|
||||||
|
|
||||||
namespace IRaCIS.Application.Services
|
namespace IRaCIS.Application.Services
|
||||||
{
|
{
|
||||||
|
@ -10,11 +12,11 @@ namespace IRaCIS.Application.Services
|
||||||
{
|
{
|
||||||
Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode);
|
Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode);
|
||||||
|
|
||||||
Task AnolymousSendEmail(string researchProgramNo ,string emailAddress, int verificationCode);
|
Task AnolymousSendEmail(string researchProgramNo, string emailAddress, int verificationCode);
|
||||||
|
|
||||||
Task SendMailEditEmail(Guid userId, string userName, string emailAddress, int verificationCode);
|
Task SendMailEditEmail(Guid userId, string userName, string emailAddress, int verificationCode);
|
||||||
|
|
||||||
Task AnolymousSendEmailForResetAccount( string emailAddress, int verificationCode);
|
Task AnolymousSendEmailForResetAccount(string emailAddress, int verificationCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MailVerificationService : IMailVerificationService
|
public class MailVerificationService : IMailVerificationService
|
||||||
|
@ -52,42 +54,35 @@ namespace IRaCIS.Application.Services
|
||||||
此邮件属系统自动发出,无需回复。
|
此邮件属系统自动发出,无需回复。
|
||||||
|
|
||||||
祝您顺利!/Best Regards.
|
祝您顺利!/Best Regards.
|
||||||
上海展影医疗科技有限公司"
|
上海展影医疗科技有限公司"
|
||||||
|
|
||||||
};
|
};
|
||||||
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 = userId,
|
|
||||||
ExpirationTime = DateTime.Now.AddMinutes(3)
|
|
||||||
}).Result;
|
|
||||||
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
EventHandler<MessageSentEventArgs> sucessHandle = (sender, args) =>
|
||||||
|
{
|
||||||
|
// args.Response
|
||||||
|
var code = verificationCode.ToString();
|
||||||
|
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
||||||
|
{
|
||||||
|
CodeType = 0,
|
||||||
|
HasSend = true,
|
||||||
|
Code = code,
|
||||||
|
UserId = userId,
|
||||||
|
ExpirationTime = DateTime.Now.AddMinutes(3)
|
||||||
|
}).Result;
|
||||||
|
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
||||||
|
|
||||||
await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls);
|
};
|
||||||
|
|
||||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
|
||||||
|
|
||||||
await smtp.SendAsync(messageToSend);
|
await SendEmailHelper.SendEmailAsync(messageToSend, sucessHandle);
|
||||||
|
|
||||||
await smtp.DisconnectAsync(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//不登录 通过邮箱重置密码
|
//不登录 通过邮箱重置密码
|
||||||
public async Task AnolymousSendEmailForResetAccount( string emailAddress, int verificationCode)
|
public async Task AnolymousSendEmailForResetAccount(string emailAddress, int verificationCode)
|
||||||
{
|
{
|
||||||
var messageToSend = new MimeMessage();
|
var messageToSend = new MimeMessage();
|
||||||
//发件地址
|
//发件地址
|
||||||
|
@ -107,40 +102,30 @@ namespace IRaCIS.Application.Services
|
||||||
祝您顺利!/Best Regards.
|
祝您顺利!/Best Regards.
|
||||||
上海展影医疗科技有限公司"
|
上海展影医疗科技有限公司"
|
||||||
};
|
};
|
||||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
|
||||||
{
|
|
||||||
smtp.MessageSent += (sender, args) =>
|
|
||||||
{
|
|
||||||
// args.Response
|
|
||||||
var code = verificationCode.ToString();
|
|
||||||
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
|
||||||
{
|
|
||||||
CodeType = Core.Domain.Share.VerifyType.Email,
|
|
||||||
HasSend = true,
|
|
||||||
Code = code,
|
|
||||||
UserId = Guid.Empty,//此时不知道用户
|
|
||||||
EmailOrPhone = emailAddress,
|
|
||||||
ExpirationTime = DateTime.Now.AddMinutes(3)
|
|
||||||
}).Result;
|
|
||||||
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
|
||||||
|
|
||||||
};
|
EventHandler<MessageSentEventArgs> sucessHandle = (sender, args) =>
|
||||||
|
{
|
||||||
|
var code = verificationCode.ToString();
|
||||||
|
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
||||||
|
{
|
||||||
|
CodeType = Core.Domain.Share.VerifyType.Email,
|
||||||
|
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", 465, SecureSocketOptions.StartTls);
|
|
||||||
|
|
||||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
await SendEmailHelper.SendEmailAsync(messageToSend, sucessHandle);
|
||||||
|
|
||||||
await smtp.SendAsync(messageToSend);
|
|
||||||
|
|
||||||
await smtp.DisconnectAsync(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//中心调研 登陆
|
//中心调研 登陆
|
||||||
public async Task AnolymousSendEmail(string researchProgramNo,string emailAddress, int verificationCode)
|
public async Task AnolymousSendEmail(string researchProgramNo, string emailAddress, int verificationCode)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var messageToSend = new MimeMessage();
|
var messageToSend = new MimeMessage();
|
||||||
|
@ -161,35 +146,29 @@ namespace IRaCIS.Application.Services
|
||||||
祝您顺利!/Best Regards.
|
祝您顺利!/Best Regards.
|
||||||
上海展影医疗科技有限公司"
|
上海展影医疗科技有限公司"
|
||||||
};
|
};
|
||||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
|
||||||
|
|
||||||
|
EventHandler<MessageSentEventArgs> sucessHandle = (sender, args) =>
|
||||||
{
|
{
|
||||||
smtp.MessageSent += (sender, args) =>
|
// args.Response
|
||||||
{
|
var code = verificationCode.ToString();
|
||||||
// args.Response
|
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
||||||
var code = verificationCode.ToString();
|
{
|
||||||
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
CodeType = VerifyType.Email,
|
||||||
{
|
HasSend = true,
|
||||||
CodeType = VerifyType.Email,
|
Code = code,
|
||||||
HasSend = true,
|
UserId = Guid.Empty,//此时不知道用户
|
||||||
Code = code,
|
EmailOrPhone = emailAddress,
|
||||||
UserId = Guid.Empty,//此时不知道用户
|
ExpirationTime = DateTime.Now.AddMinutes(3)
|
||||||
EmailOrPhone = emailAddress,
|
}).Result;
|
||||||
ExpirationTime = DateTime.Now.AddMinutes(3)
|
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
||||||
}).Result;
|
};
|
||||||
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
|
||||||
|
|
||||||
await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls);
|
await SendEmailHelper.SendEmailAsync(messageToSend, sucessHandle);
|
||||||
|
|
||||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
|
||||||
|
|
||||||
await smtp.SendAsync(messageToSend);
|
|
||||||
|
|
||||||
await smtp.DisconnectAsync(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,35 +197,25 @@ namespace IRaCIS.Application.Services
|
||||||
祝您顺利!/Best Regards.
|
祝您顺利!/Best Regards.
|
||||||
上海展影医疗科技有限公司"
|
上海展影医疗科技有限公司"
|
||||||
};
|
};
|
||||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
|
||||||
|
EventHandler<MessageSentEventArgs> sucessHandle = (sender, args) =>
|
||||||
{
|
{
|
||||||
smtp.MessageSent += (sender, args) =>
|
// args.Response
|
||||||
|
var code = verificationCode.ToString();
|
||||||
|
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
||||||
{
|
{
|
||||||
// args.Response
|
CodeType = 0,
|
||||||
var code = verificationCode.ToString();
|
HasSend = true,
|
||||||
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
Code = code,
|
||||||
{
|
UserId = userId,
|
||||||
CodeType = 0,
|
ExpirationTime = DateTime.Now.AddMinutes(3)
|
||||||
HasSend = true,
|
}).Result;
|
||||||
Code = code,
|
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
||||||
UserId = userId,
|
};
|
||||||
ExpirationTime = DateTime.Now.AddMinutes(3)
|
|
||||||
}).Result;
|
|
||||||
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
|
||||||
|
|
||||||
};
|
await SendEmailHelper.SendEmailAsync(messageToSend, sucessHandle);
|
||||||
|
|
||||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
|
||||||
|
|
||||||
await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls);
|
|
||||||
|
|
||||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
|
||||||
|
|
||||||
await smtp.SendAsync(messageToSend);
|
|
||||||
|
|
||||||
await smtp.DisconnectAsync(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||||
public async Task<IResponseOutput> VerifyQCCanAddChallenge(Guid subjectVisitId, [FromRoute] CurrentQC currentQCType)
|
public async Task<IResponseOutput> VerifyQCCanAddChallenge(Guid subjectVisitId, [FromRoute] CurrentQC currentQCType)
|
||||||
{
|
{
|
||||||
await VerifyIsCanQCAsync(null, subjectVisitId);
|
await VerifyIsCanQCAsync(null, subjectVisitId);
|
||||||
|
|
||||||
if (!await _repository.AnyAsync<TrialQCQuestionAnswer>(t => t.SubjectVisitId == subjectVisitId && t.CurrentQCEnum == currentQCType))
|
if (!await _repository.AnyAsync<TrialQCQuestionAnswer>(t => t.SubjectVisitId == subjectVisitId && t.CurrentQCEnum == currentQCType))
|
||||||
{
|
{
|
||||||
return ResponseOutput.NotOk("请先核查图像,保存审核问题后,再发质疑。");
|
return ResponseOutput.NotOk("请先核查图像,保存审核问题后,再发质疑。");
|
||||||
|
@ -98,7 +99,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||||
{
|
{
|
||||||
if (await _qcChallengeRepository.AnyAsync(t => t.IsClosed == false && t.SubjectVisitId == qaQuestionCommand.SubjectVisitId && t.ReuploadEnum == QCChanllengeReuploadEnum.QCAgreeUpload))
|
if (await _qcChallengeRepository.AnyAsync(t => t.IsClosed == false && t.SubjectVisitId == qaQuestionCommand.SubjectVisitId && t.ReuploadEnum == QCChanllengeReuploadEnum.QCAgreeUpload))
|
||||||
{
|
{
|
||||||
throw new BusinessValidationFailedException("当前访视有未关闭的 同意CRC上传的质疑,不允许再次添加质疑");
|
throw new BusinessValidationFailedException("当前访视有未关闭的 同意CRC重传的质疑,不允许再次添加质疑");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +165,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||||
|
|
||||||
if (dbQCChallenge.ReuploadEnum == QCChanllengeReuploadEnum.CRCRequestReupload || dbQCChallenge.ReuploadEnum == QCChanllengeReuploadEnum.QCAgreeUpload)
|
if (dbQCChallenge.ReuploadEnum == QCChanllengeReuploadEnum.CRCRequestReupload || dbQCChallenge.ReuploadEnum == QCChanllengeReuploadEnum.QCAgreeUpload)
|
||||||
{
|
{
|
||||||
throw new BusinessValidationFailedException("CRC申请重传的/QC同意重传的质疑,在CRC设置重传完成前不允许关闭质疑");
|
throw new BusinessValidationFailedException("CRC申请重传的|QC同意重传的质疑,在CRC设置重传完成前不允许关闭质疑");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ using IRaCIS.Application.Contracts;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using MailKit.Security;
|
using MailKit.Security;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Contracts
|
namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
|
@ -601,24 +602,10 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
messageToSend.Body = builder.ToMessageBody();
|
messageToSend.Body = builder.ToMessageBody();
|
||||||
|
|
||||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
|
||||||
{
|
|
||||||
|
|
||||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
await SendEmailHelper.SendEmailAsync(messageToSend, null);
|
||||||
|
|
||||||
|
|
||||||
await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls);
|
|
||||||
|
|
||||||
|
|
||||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
|
||||||
|
|
||||||
|
|
||||||
await smtp.SendAsync(messageToSend);
|
|
||||||
|
|
||||||
|
|
||||||
await smtp.DisconnectAsync(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
await _trialSiteSurveyRepository.SaveChangesAsync();
|
await _trialSiteSurveyRepository.SaveChangesAsync();
|
||||||
|
|
||||||
return ResponseOutput.Ok();
|
return ResponseOutput.Ok();
|
||||||
|
@ -857,19 +844,9 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
messageToSend.Body = builder.ToMessageBody();
|
messageToSend.Body = builder.ToMessageBody();
|
||||||
|
|
||||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
await SendEmailHelper.SendEmailAsync(messageToSend, null);
|
||||||
{
|
|
||||||
|
|
||||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
|
||||||
|
|
||||||
await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls);
|
|
||||||
|
|
||||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
|
||||||
|
|
||||||
await smtp.SendAsync(messageToSend);
|
|
||||||
|
|
||||||
await smtp.DisconnectAsync(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var trialId = joinCommand.TrialId;
|
var trialId = joinCommand.TrialId;
|
||||||
|
|
|
@ -13,6 +13,7 @@ using MimeKit;
|
||||||
using MailKit.Security;
|
using MailKit.Security;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Panda.DynamicWebApi.Attributes;
|
using Panda.DynamicWebApi.Attributes;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
@ -264,21 +265,10 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
messageToSend.Body = builder.ToMessageBody();
|
messageToSend.Body = builder.ToMessageBody();
|
||||||
|
|
||||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
|
||||||
{
|
|
||||||
|
|
||||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
|
||||||
|
|
||||||
await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls);
|
|
||||||
|
|
||||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
|
||||||
|
|
||||||
await smtp.SendAsync(messageToSend);
|
|
||||||
|
|
||||||
await smtp.DisconnectAsync(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
await SendEmailHelper.SendEmailAsync(messageToSend, null);
|
||||||
|
|
||||||
|
|
||||||
var trialId = sendEmail.TrialId;
|
var trialId = sendEmail.TrialId;
|
||||||
var userId = sysUserInfo.Id;
|
var userId = sysUserInfo.Id;
|
||||||
|
|
||||||
|
@ -305,6 +295,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 老版本流程 现在废弃
|
#region 老版本流程 现在废弃
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue