上传bug
parent
bfc0fd4203
commit
65449a9868
|
@ -1,5 +1,6 @@
|
|||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using MailKit.Security;
|
||||
using MimeKit;
|
||||
|
||||
|
@ -9,11 +10,11 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode);
|
||||
|
||||
Task AnolymousSendEmail(string emailAddress, int verificationCode);
|
||||
Task AnolymousSendEmail(string researchProgramNo ,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
|
||||
|
@ -41,13 +42,15 @@ namespace IRaCIS.Application.Services
|
|||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(userName, emailAddress));
|
||||
//主题
|
||||
messageToSend.Subject = "Reset email (Verification Code)";
|
||||
messageToSend.Subject = "重置邮箱";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@"Hey {userName},you are modify your email . The verification code is: {verificationCode}, which is valid within 3 minutes. If it is not your own operation, please ignore it!
|
||||
|
||||
-- GRR"
|
||||
Text = $@" {userName},您好:
|
||||
感谢您使用展影云平台。
|
||||
您正在进行邮箱重置操作,验证码是: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件
|
||||
此邮件属系统自动发出,无需回复。
|
||||
上海展影医疗科技有限公司"
|
||||
};
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
|
@ -80,6 +83,109 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task AnolymousSendEmailForResetAccount( string emailAddress, int 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 = "重置密码";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@" 您好:
|
||||
感谢您使用展影云平台。
|
||||
您正在进行邮箱重置密码操作,验证码是: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件
|
||||
此邮件属系统自动发出,无需回复。
|
||||
上海展影医疗科技有限公司"
|
||||
};
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task AnolymousSendEmail(string researchProgramNo,string emailAddress, int 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 = $"[{researchProgramNo}]中心调研";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@" 感谢您使用展影云平台。
|
||||
您正在参与展影医疗IRC项目中心调研工作,验证码是:: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件。
|
||||
此邮件属系统自动发出,无需回复。
|
||||
上海展影医疗科技有限公司"
|
||||
};
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
smtp.MessageSent += (sender, args) =>
|
||||
{
|
||||
// args.Response
|
||||
var code = verificationCode.ToString();
|
||||
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
||||
{
|
||||
CodeType = 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", 25, SecureSocketOptions.StartTls);
|
||||
|
||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
||||
|
||||
await smtp.SendAsync(messageToSend);
|
||||
|
||||
await smtp.DisconnectAsync(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode)
|
||||
|
@ -130,106 +236,6 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task AnolymousSendEmailForResetAccount(string emailAddress, int 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 = "Reset Password (Verification Code)";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@"Hey ,you are reset passwoed. 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 = 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", 25, SecureSocketOptions.StartTls);
|
||||
|
||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
||||
|
||||
await smtp.SendAsync(messageToSend);
|
||||
|
||||
await smtp.DisconnectAsync(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task AnolymousSendEmail(string emailAddress, int 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 Site survey (Verification Code)";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@"Hey ,you are login for site survey via email. The verification code is: {verificationCode}, which is valid within 3 minutes. 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);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SendEmailForExternalUser(string emailAddress, string verificationCode)
|
||||
{
|
||||
var messageToSend = new MimeMessage();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
public string SeriesInstanceUid { get; set; } = string.Empty;
|
||||
public string SopInstanceUid { get; set; } = string.Empty;
|
||||
public int InstanceNumber { get; set; }
|
||||
public DateTime InstanceTime { get; set; }
|
||||
public DateTime? InstanceTime { get; set; }
|
||||
public bool CPIStatus { get; set; }
|
||||
public int ImageRows { get; set; }
|
||||
public int ImageColumns { get; set; }
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
public string StudyInstanceUid { get; set; } = String.Empty;
|
||||
public string SeriesInstanceUid { get; set; } = String.Empty;
|
||||
public int SeriesNumber { get; set; }
|
||||
public DateTime SeriesTime { get; set; }
|
||||
public DateTime? SeriesTime { get; set; }
|
||||
public string Modality { get; set; } = String.Empty;
|
||||
public string Description { get; set; }=String.Empty;
|
||||
public int InstanceCount { get; set; }
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
public string StudyCode { get; set; } = string.Empty;
|
||||
|
||||
public DateTime StudyTime { get; set; }
|
||||
public DateTime? StudyTime { get; set; }
|
||||
}
|
||||
|
||||
public class DicomStudyDTO
|
||||
|
@ -28,7 +28,7 @@
|
|||
public int Status { get; set; } = 1;
|
||||
|
||||
public string StudyInstanceUid { get; set; } = string.Empty;
|
||||
public DateTime StudyTime { get; set; }
|
||||
public DateTime? StudyTime { get; set; }
|
||||
public string Modalities { get; set; } = string.Empty;
|
||||
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
Id = studyId,
|
||||
StudyInstanceUid = studyInstanceUid,
|
||||
/* StudyTime = dataset.GetSingleValueOrDefault(DicomTag.StudyDate, DateTime.Now).Add(dataset.GetSingleValueOrDefault(DicomTag.StudyTime, DateTime.Now).TimeOfDay),*///dataset.GetDateTime(DicomTag.StudyDate, DicomTag.StudyTime),
|
||||
StudyTime = dataset.GetSingleValue<DateTime?>(DicomTag.StudyDate)?.Add(dataset.GetSingleValueOrDefault(DicomTag.StudyTime, TimeSpan.Zero)),
|
||||
StudyTime = dataset.GetSingleValueOrDefault(DicomTag.StudyDate,(DateTime?)null)?.Add(dataset.GetSingleValueOrDefault(DicomTag.StudyTime, TimeSpan.Zero)),
|
||||
Modalities = dataset.GetSingleValueOrDefault(DicomTag.Modality, string.Empty),
|
||||
Description = dataset.GetSingleValueOrDefault(DicomTag.StudyDescription, string.Empty),
|
||||
InstitutionName = dataset.GetSingleValueOrDefault(DicomTag.InstitutionName, string.Empty),
|
||||
|
@ -358,7 +358,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
SeriesInstanceUid = seriesInstanceUid,
|
||||
SeriesNumber = dataset.GetSingleValueOrDefault(DicomTag.SeriesNumber, 1),
|
||||
//SeriesTime = dataset.GetSingleValueOrDefault(DicomTag.SeriesDate, DateTime.Now).Add(dataset.GetSingleValueOrDefault(DicomTag.SeriesTime, DateTime.Now).TimeOfDay),
|
||||
SeriesTime = dataset.GetSingleValue<DateTime?>(DicomTag.SeriesDate)?.Add(dataset.GetSingleValueOrDefault(DicomTag.SeriesTime, TimeSpan.Zero)),// dataset.GetDateTime(DicomTag.SeriesDate, DicomTag.SeriesTime),
|
||||
SeriesTime = dataset.GetSingleValueOrDefault(DicomTag.SeriesDate, (DateTime?)null)?.Add(dataset.GetSingleValueOrDefault(DicomTag.SeriesTime, TimeSpan.Zero)),// dataset.GetDateTime(DicomTag.SeriesDate, DicomTag.SeriesTime),
|
||||
Modality = dataset.GetSingleValueOrDefault(DicomTag.Modality, string.Empty),
|
||||
Description = dataset.GetSingleValueOrDefault(DicomTag.SeriesDescription, string.Empty),
|
||||
SliceThickness = dataset.GetSingleValueOrDefault(DicomTag.SliceThickness, string.Empty),
|
||||
|
@ -413,7 +413,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
SeriesInstanceUid = dicomSeries.SeriesInstanceUid,
|
||||
SopInstanceUid = sopInstanceUid,
|
||||
InstanceNumber = dataset.GetSingleValueOrDefault(DicomTag.InstanceNumber, 1),
|
||||
InstanceTime = dataset.GetSingleValue<DateTime?>(DicomTag.ContentDate)?.Add(dataset.GetSingleValueOrDefault(DicomTag.ContentTime, TimeSpan.Zero)),
|
||||
InstanceTime = dataset.GetSingleValueOrDefault(DicomTag.ContentDate,(DateTime?)null)?.Add(dataset.GetSingleValueOrDefault(DicomTag.ContentTime, TimeSpan.Zero)),
|
||||
//dataset.GetSingleValueOrDefault(DicomTag.ContentDate,DateTime.Now);//, DicomTag.ContentTime)
|
||||
CPIStatus = false,
|
||||
ImageRows = dataset.GetSingleValueOrDefault(DicomTag.Rows, 0),
|
||||
|
|
|
@ -53,16 +53,6 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
}
|
||||
|
||||
////查找改邮箱或者手机的用户
|
||||
//var exist = await _userRepository.AnyAsync(t => t.EMail == email);
|
||||
|
||||
//if (!exist)
|
||||
//{
|
||||
// return ResponseOutput.NotOk("No user with this email exists.");
|
||||
|
||||
//}
|
||||
//var user = await _userRepository.FirstOrDefaultAsync(t => t.EMail == email);
|
||||
|
||||
|
||||
//验证码 6位
|
||||
int verificationCode = new Random().Next(100000, 1000000);
|
||||
|
@ -73,6 +63,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
}
|
||||
|
||||
|
||||
[HttpPut("{newEmail}/{verificationCode}")]
|
||||
public async Task<IResponseOutput> SetNewEmail(string newEmail, string verificationCode)
|
||||
{
|
||||
|
@ -108,15 +99,15 @@ namespace IRaCIS.Application.Services
|
|||
return ResponseOutput.NotOk("The mailbox for this user type already exists");
|
||||
}
|
||||
|
||||
var success = await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User()
|
||||
await _userRepository.UpdatePartialFields(_userInfo.Id, u => new User()
|
||||
{
|
||||
EMail = newEmail
|
||||
});
|
||||
}, true);
|
||||
|
||||
//删除验证码历史记录
|
||||
await _verificationCodeRepository.BatchDeleteAsync(t => t.UserId == _userInfo.Id && t.CodeType == 0);
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -128,10 +119,10 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
|
||||
|
||||
var success = await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User()
|
||||
await _userRepository.UpdatePartialFields(_userInfo.Id, u => new User()
|
||||
{
|
||||
Phone = newPhone
|
||||
});
|
||||
},true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
@ -145,10 +136,10 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
return ResponseOutput.NotOk("UserId already exists");
|
||||
}
|
||||
var success = await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User()
|
||||
await _userRepository.UpdatePartialFields(_userInfo.Id, u => new User()
|
||||
{
|
||||
UserName = newUserName
|
||||
});
|
||||
},true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
@ -163,13 +154,13 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
public async Task<IResponseOutput> ResetPassword(Guid userId)
|
||||
{
|
||||
var success = await _userRepository.BatchUpdateAsync(t => t.Id == userId, u => new User()
|
||||
await _userRepository.UpdatePartialFields(userId, u => new User()
|
||||
{
|
||||
Password = MD5Helper.Md5(StaticData.DefaultPassword),
|
||||
IsFirstAdd = true
|
||||
});
|
||||
}, true);
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -190,8 +190,11 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
|
||||
public class SiteSurveySendVerifyCode
|
||||
{
|
||||
public VerifyType verificationType { get; set; }
|
||||
public string EmailOrPhone { get; set; } = string.Empty;
|
||||
//public VerifyType verificationType { get; set; }
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
[NotDefault]
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -46,33 +46,58 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
[AllowAnonymous]
|
||||
public async Task<IResponseOutput> SendVerifyCode(SiteSurveySendVerifyCode userInfo, [FromServices] IMailVerificationService _mailVerificationService)
|
||||
{
|
||||
var verificationType = userInfo.verificationType;
|
||||
var verificationType = VerifyType.Email;
|
||||
//检查手机或者邮箱是否有效
|
||||
if (!Regex.IsMatch(userInfo.EmailOrPhone, @"/^1[34578]\d{9}$/") && !Regex.IsMatch(userInfo.EmailOrPhone, @"^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$"))
|
||||
if ( !Regex.IsMatch(userInfo.Email, @"^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$"))
|
||||
{
|
||||
|
||||
throw new BusinessValidationFailedException(verificationType == VerifyType.Email
|
||||
? "Please input a legal email"
|
||||
: "Please input a legal phone");
|
||||
|
||||
throw new BusinessValidationFailedException("Please input a legal email");
|
||||
}
|
||||
|
||||
//邮箱
|
||||
if (verificationType == VerifyType.Email)
|
||||
{
|
||||
|
||||
//验证码 6位
|
||||
int verificationCode = new Random().Next(100000, 1000000);
|
||||
|
||||
await _mailVerificationService.AnolymousSendEmail(userInfo.EmailOrPhone, verificationCode);
|
||||
}
|
||||
//手机短信
|
||||
else
|
||||
{
|
||||
var trialInfo = await _repository.FirstOrDefaultAsync<Trial>(t => t.Id == userInfo.TrialId);
|
||||
|
||||
await _mailVerificationService.AnolymousSendEmail(trialInfo.ResearchProgramNo,userInfo.Email, verificationCode);
|
||||
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
|
||||
#region MyRegion
|
||||
|
||||
//var verificationType = VerifyType.Email;
|
||||
////检查手机或者邮箱是否有效
|
||||
//if (!Regex.IsMatch(userInfo.Email, @"/^1[34578]\d{9}$/") && !Regex.IsMatch(userInfo.Email, @"^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$"))
|
||||
//{
|
||||
|
||||
// throw new BusinessValidationFailedException(verificationType == VerifyType.Email
|
||||
// ? "Please input a legal email"
|
||||
// : "Please input a legal phone");
|
||||
|
||||
//}
|
||||
|
||||
////邮箱
|
||||
//if (verificationType == VerifyType.Email)
|
||||
//{
|
||||
// //验证码 6位
|
||||
// int verificationCode = new Random().Next(100000, 1000000);
|
||||
|
||||
// await _mailVerificationService.AnolymousSendEmail(userInfo.Email, verificationCode);
|
||||
//}
|
||||
////手机短信
|
||||
//else
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//return ResponseOutput.Ok();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -656,7 +681,7 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, item.Email));
|
||||
//主题
|
||||
messageToSend.Subject = "GRR Site survey (Trial Invite)";
|
||||
messageToSend.Subject = $"[{trialInfo.ResearchProgramNo}] 邀请";
|
||||
|
||||
var builder = new BodyBuilder();
|
||||
|
||||
|
@ -816,4 +841,4 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userInfo.Email));
|
||||
//主题
|
||||
messageToSend.Subject = "GRR External User survey (Invite)";
|
||||
messageToSend.Subject = $"[{trialInfo.ResearchProgramNo}] 邀请";
|
||||
|
||||
//var baseApiUrl = sendEmail.BaseUrl.Remove(sendEmail.BaseUrl.IndexOf("#")) + "api";
|
||||
|
||||
|
@ -325,17 +325,18 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
if (editTrialUserPreparation.IsJoin == true)
|
||||
{
|
||||
var trialInfo = await _repository.FirstOrDefaultAsync<Trial>(t => t.Id == needUpdate.TrialId);
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com"));
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, needUpdate.Email));
|
||||
//主题
|
||||
messageToSend.Subject = $"GRR External User survey (Trial {(editTrialUserPreparation.IsJoin == false ? "Reject Success" : "Join Success")})";
|
||||
messageToSend.Subject = $"[{trialInfo.ResearchProgramNo}] 账号信息";
|
||||
|
||||
var builder = new BodyBuilder();
|
||||
|
||||
var trialInfo = await _repository.FirstOrDefaultAsync<Trial>(t => t.Id == needUpdate.TrialId);
|
||||
|
||||
var sysUserInfo = await _userRepository.Where(t => t.Id == needUpdate.SystemUserId).Include(t => t.UserTypeRole).FirstOrDefaultAsync();
|
||||
|
||||
|
@ -493,6 +494,8 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
var success = await _trialExternalUseRepository.SaveChangesAsync();
|
||||
|
||||
var trialInfo = await _repository.FirstOrDefaultAsync<Trial>(t => t.Id == needUpdate.TrialSiteSurvey.TrialId);
|
||||
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
|
@ -500,11 +503,11 @@ namespace IRaCIS.Core.Application.Service
|
|||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, editInfo.IsJoin == true ? needUpdate.Email : revieweUser.EMail));
|
||||
//主题
|
||||
messageToSend.Subject = $"GRR Site survey (Trial {(editInfo.IsJoin == false ? "Reject" : "Join Success")})";
|
||||
messageToSend.Subject = $"[{trialInfo.ResearchProgramNo}] 账号信息";
|
||||
|
||||
|
||||
var builder = new BodyBuilder();
|
||||
|
||||
var trialInfo = await _repository.FirstOrDefaultAsync<Trial>(t => t.Id == needUpdate.TrialSiteSurvey.TrialId);
|
||||
|
||||
var sysUserInfo = await _userRepository.Where(t => t.Id == needUpdate.SystemUserId).Include(t => t.UserTypeRole).FirstOrDefaultAsync();
|
||||
|
||||
|
@ -554,45 +557,6 @@ namespace IRaCIS.Core.Application.Service
|
|||
</div>
|
||||
</div>
|
||||
</body>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
builder.HtmlBody = @$"<body style='font-family: 微软雅黑;padding: 0;margin: 0;'>
|
||||
<div style='padding-left: 40px;background: #f6f6f6'>
|
||||
<div style='padding-top: 20px;padding-bottom:40px'>
|
||||
<div style='line-height: 40px;font-size: 18px'>
|
||||
{revieweUser.LastName + "/" + revieweUser.FirstName}:
|
||||
</div>
|
||||
<div style='line-height: 40px;padding-left: 40px;margin-bottom: 10px;'>
|
||||
您好,{sysUserInfo.LastName + "/" + sysUserInfo.FirstName} 拒绝了参加 {trialInfo.ResearchProgramNo} 项目IRC相关工作的邀请。详细信息如下:
|
||||
</div>
|
||||
<div style='border: 1px solid #eee;box-sizing:border-box;width: 80%;background: #fff;padding: 20px;line-height: 40px;font-size: 14px;border-radius: 5px;margin-left: 60px;margin-bottom: 30px;'>
|
||||
<div>
|
||||
项目编号: {trialInfo.TrialCode}
|
||||
</div>
|
||||
<div>
|
||||
试验方案号: {trialInfo.ResearchProgramNo}
|
||||
</div>
|
||||
<div>
|
||||
试验名称: {trialInfo.ExperimentName}
|
||||
</div>
|
||||
<div>
|
||||
用户名: {sysUserInfo.UserName}
|
||||
</div>
|
||||
<div>
|
||||
角色: {sysUserInfo.UserTypeRole.UserTypeShortName}
|
||||
</div>
|
||||
<div>
|
||||
拒绝原因: {editInfo.RejectReason}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
messageToSend.Body = builder.ToMessageBody();
|
||||
|
||||
|
@ -609,6 +573,47 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
await smtp.DisconnectAsync(true);
|
||||
}
|
||||
}
|
||||
//else
|
||||
//{
|
||||
|
||||
// builder.HtmlBody = @$"<body style='font-family: 微软雅黑;padding: 0;margin: 0;'>
|
||||
// <div style='padding-left: 40px;background: #f6f6f6'>
|
||||
// <div style='padding-top: 20px;padding-bottom:40px'>
|
||||
// <div style='line-height: 40px;font-size: 18px'>
|
||||
// {revieweUser.LastName + "/" + revieweUser.FirstName}:
|
||||
// </div>
|
||||
// <div style='line-height: 40px;padding-left: 40px;margin-bottom: 10px;'>
|
||||
// 您好,{sysUserInfo.LastName + "/" + sysUserInfo.FirstName} 拒绝了参加 {trialInfo.ResearchProgramNo} 项目IRC相关工作的邀请。详细信息如下:
|
||||
// </div>
|
||||
// <div style='border: 1px solid #eee;box-sizing:border-box;width: 80%;background: #fff;padding: 20px;line-height: 40px;font-size: 14px;border-radius: 5px;margin-left: 60px;margin-bottom: 30px;'>
|
||||
// <div>
|
||||
// 项目编号: {trialInfo.TrialCode}
|
||||
// </div>
|
||||
// <div>
|
||||
// 试验方案号: {trialInfo.ResearchProgramNo}
|
||||
// </div>
|
||||
// <div>
|
||||
// 试验名称: {trialInfo.ExperimentName}
|
||||
// </div>
|
||||
// <div>
|
||||
// 用户名: {sysUserInfo.UserName}
|
||||
// </div>
|
||||
// <div>
|
||||
// 角色: {sysUserInfo.UserTypeRole.UserTypeShortName}
|
||||
// </div>
|
||||
// <div>
|
||||
// 拒绝原因: {editInfo.RejectReason}
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// </body>";
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
|
|
@ -336,7 +336,7 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
public DateTime StudyTime { get; set; }
|
||||
public DateTime? StudyTime { get; set; }
|
||||
}
|
||||
|
||||
public class StudyDTO
|
||||
|
|
|
@ -41,56 +41,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
#region 异步部分
|
||||
|
||||
/// <summary>
|
||||
/// 仅仅供字典表插入使用,因为efcore 动态映射列的问题
|
||||
/// </summary>
|
||||
/// <typeparam name="TFrom"></typeparam>
|
||||
/// <param name="from"></param>
|
||||
/// <param name="verify"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public async Task<TEntity> InsertDictionaryAsync<TFrom>(TFrom from, params EntityVerifyExp<TEntity>[] verify)
|
||||
{
|
||||
var entity = _mapper.Map<TEntity>(from);
|
||||
|
||||
foreach (var verifyItem in verify.Where(t => t.verifyType != VerifyEnum.OnlyUpdate && t.IsVerify))
|
||||
{
|
||||
if (await _dbSet.IgnoreQueryFilters().AnyAsync(verifyItem.VerifyExp).ConfigureAwait(false))
|
||||
{
|
||||
throw new BusinessValidationFailedException(verifyItem.VerifyMsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(TEntity) == typeof(Dictionary))
|
||||
{
|
||||
Type type = typeof(TFrom);
|
||||
|
||||
//以下是不要ID这个字段的 比如自增列ID 就不能像上名那样写
|
||||
var properties = type.GetProperties().Where(t => t.Name != "Id");
|
||||
|
||||
|
||||
string strSqlName = string.Join(",", properties.Select(p => $"[{p.Name}]").ToArray());
|
||||
|
||||
string strSqlValue = string.Join(",", properties.Select(P => $"@{P.Name}").ToArray());
|
||||
|
||||
string strSql = $"insert into {nameof(Dictionary)} ( " + strSqlName + " ) values (" + strSqlValue + ")";
|
||||
|
||||
//para Sql是参数
|
||||
SqlParameter[] para = properties.Select(p => new SqlParameter($"@{p.Name}", p.GetValue(from, null))).ToArray();
|
||||
|
||||
|
||||
_dbContext.Database.ExecuteSqlRaw(strSql, para);
|
||||
|
||||
return entity;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("仅仅供字典表插入使用,因为efcore 动态映射列的问题");
|
||||
//await _dbSet.BulkInsertAsync(new List<TEntity>() { entity });
|
||||
|
||||
//return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<TEntity> InsertOrUpdateAsync<TFrom>(TFrom from, bool autoSave = false, params EntityVerifyExp<TEntity>[] verify)
|
||||
{
|
||||
|
@ -729,88 +680,8 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 杨中科 test 有问题 对于guid? 赋值null的时候
|
||||
/// </summary>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="updateFactory"></param>
|
||||
/// <returns></returns>
|
||||
//public async Task<bool> BatchUpdateAsync(Expression<Func<TEntity, bool>> where,
|
||||
// Expression<Func<TEntity, TEntity>> updateFactory)
|
||||
//{
|
||||
// var builder = _dbContext.BatchUpdate<TEntity>();
|
||||
|
||||
// Func<TEntity, TEntity> func = updateFactory.Compile();
|
||||
|
||||
// List<PropertyInfo> list = ((MemberInitExpression)updateFactory.Body).Bindings.Select<MemberBinding, string>((Func<MemberBinding, string>)(_param1 => _param1.Member.Name)).Select<string, PropertyInfo>((Func<string, PropertyInfo>)(_param1 => (PropertyInfo)typeof(TEntity).GetProperty(_param1, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))).ToList<PropertyInfo>();
|
||||
|
||||
// TEntity applyObj = func(new TEntity());
|
||||
|
||||
// foreach (PropertyInfo prop in list)
|
||||
// {
|
||||
// var propName = prop.Name;
|
||||
// var value = prop.GetValue(applyObj);
|
||||
|
||||
|
||||
// builder.Set(propName, value?? DBNull.Value);
|
||||
|
||||
// //PropertyInfo property = typeof(TEntity).GetProperty(prop.Name);
|
||||
// //Type propertyType = property.PropertyType;
|
||||
// //ParameterExpression parameterExpression = Expression.Parameter(typeof(TEntity));
|
||||
// //Type delegateType = typeof(Func<,>).MakeGenericType(typeof(TEntity), propertyType);
|
||||
// //LambdaExpression nameExpr = Expression.Lambda(delegateType, (Expression)Expression.MakeMemberAccess((Expression)parameterExpression, (MemberInfo)property), parameterExpression);
|
||||
// //Expression expression = (Expression)Expression.Constant(value);
|
||||
|
||||
// //expression = (Expression)Expression.Convert(expression, propertyType);
|
||||
|
||||
// //LambdaExpression valueExpr = Expression.Lambda(delegateType, expression, parameterExpression);
|
||||
|
||||
|
||||
// //builder.Set< >(Func<TEntity, c> nameExpr, valueExpr);
|
||||
|
||||
// }
|
||||
// return await builder.Where(where).ExecuteAsync()>0;
|
||||
//}
|
||||
|
||||
//// Z.EntityFramework.Plus.EFCore
|
||||
//public async Task<bool> BatchDeleteAsync(Expression<Func<TEntity, bool>> deleteFilter)
|
||||
//{
|
||||
// return await _dbSet.IgnoreQueryFilters().Where(deleteFilter).DeleteFromQueryAsync() > 0;
|
||||
//}
|
||||
|
||||
//public async Task<bool> BatchUpdateAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, TEntity>> updateFactory)
|
||||
//{
|
||||
// return await _dbSet.IgnoreQueryFilters().Where(where).UpdateFromQueryAsync(updateFactory) > 0;
|
||||
//}
|
||||
|
||||
//public async Task<bool> UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
//{
|
||||
// _dbSet.UpdateRange(entities);
|
||||
|
||||
// if (autoSave)
|
||||
// {
|
||||
// return await SaveChangesAsync(cancellationToken);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//public async Task<bool> DeleteManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
//{
|
||||
// _dbSet.RemoveRange(entities);
|
||||
|
||||
// if (autoSave)
|
||||
// {
|
||||
// return await SaveChangesAsync(cancellationToken);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -912,7 +783,56 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
return _dbSet.AsNoTracking().ProjectTo<TDestination>(configuration, parameters, membersToExpand);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仅仅供字典表插入使用,因为efcore 动态映射列的问题
|
||||
/// </summary>
|
||||
/// <typeparam name="TFrom"></typeparam>
|
||||
/// <param name="from"></param>
|
||||
/// <param name="verify"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public async Task<TEntity> InsertDictionaryAsync<TFrom>(TFrom from, params EntityVerifyExp<TEntity>[] verify)
|
||||
{
|
||||
var entity = _mapper.Map<TEntity>(from);
|
||||
|
||||
foreach (var verifyItem in verify.Where(t => t.verifyType != VerifyEnum.OnlyUpdate && t.IsVerify))
|
||||
{
|
||||
if (await _dbSet.IgnoreQueryFilters().AnyAsync(verifyItem.VerifyExp).ConfigureAwait(false))
|
||||
{
|
||||
throw new BusinessValidationFailedException(verifyItem.VerifyMsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(TEntity) == typeof(Dictionary))
|
||||
{
|
||||
Type type = typeof(TFrom);
|
||||
|
||||
//以下是不要ID这个字段的 比如自增列ID 就不能像上名那样写
|
||||
var properties = type.GetProperties().Where(t => t.Name != "Id");
|
||||
|
||||
|
||||
string strSqlName = string.Join(",", properties.Select(p => $"[{p.Name}]").ToArray());
|
||||
|
||||
string strSqlValue = string.Join(",", properties.Select(P => $"@{P.Name}").ToArray());
|
||||
|
||||
string strSql = $"insert into {nameof(Dictionary)} ( " + strSqlName + " ) values (" + strSqlValue + ")";
|
||||
|
||||
//para Sql是参数
|
||||
SqlParameter[] para = properties.Select(p => new SqlParameter($"@{p.Name}", p.GetValue(from, null))).ToArray();
|
||||
|
||||
|
||||
_dbContext.Database.ExecuteSqlRaw(strSql, para);
|
||||
|
||||
return entity;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("仅仅供字典表插入使用,因为efcore 动态映射列的问题");
|
||||
//await _dbSet.BulkInsertAsync(new List<TEntity>() { entity });
|
||||
|
||||
//return entity;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue