修改提示
parent
b154540885
commit
5cbefec0b0
|
@ -991,6 +991,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
|
|
||||||
if (!fileName.EndsWith(".xlsx", StringComparison.OrdinalIgnoreCase))
|
if (!fileName.EndsWith(".xlsx", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
// 请用提供格式的模板excel上传需要处理的数据
|
||||||
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_TemplateUploadData"));
|
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_TemplateUploadData"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,32 +1007,41 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
|
|
||||||
if (excelList.Any(t => string.IsNullOrWhiteSpace(t.TrialSiteCode) || string.IsNullOrWhiteSpace(t.FirstName) || string.IsNullOrWhiteSpace(t.LastName) || string.IsNullOrWhiteSpace(t.Email) || string.IsNullOrWhiteSpace(t.UserTypeStr)))
|
if (excelList.Any(t => string.IsNullOrWhiteSpace(t.TrialSiteCode) || string.IsNullOrWhiteSpace(t.FirstName) || string.IsNullOrWhiteSpace(t.LastName) || string.IsNullOrWhiteSpace(t.Email) || string.IsNullOrWhiteSpace(t.UserTypeStr)))
|
||||||
{
|
{
|
||||||
|
//请确保Excel中 每一行的 中心编号,姓名,邮箱,用户类型数据记录完整再进行上传
|
||||||
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_EnsureCompleteData"));
|
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_EnsureCompleteData"));
|
||||||
}
|
}
|
||||||
|
|
||||||
var siteCodeList = excelList.Select(t => t.TrialSiteCode.Trim().ToUpper()).Distinct().ToList();
|
var siteCodeList = excelList.Select(t => t.TrialSiteCode.Trim().ToUpper()).Distinct().ToList();
|
||||||
|
|
||||||
if (_trialSiteRepository.Where(t => t.TrialId==trialId && siteCodeList.Contains(t.TrialSiteCode.ToUpper())).Count() != siteCodeList.Count)
|
if (_trialSiteRepository.Where(t => t.TrialId == trialId && siteCodeList.Contains(t.TrialSiteCode.ToUpper())).Count() != siteCodeList.Count)
|
||||||
{
|
{
|
||||||
|
//在项目中未找到该Excel中部分或全部中心
|
||||||
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_InvalidCenters"));
|
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_InvalidCenters"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excelList.GroupBy(t => new { t.UserTypeStr, t.Email }).Any(g => g.Count() > 1))
|
if (excelList.GroupBy(t => new { t.UserTypeStr, t.Email }).Any(g => g.Count() > 1))
|
||||||
{
|
{
|
||||||
|
// 同一邮箱,同一用户类型,只能生成一个账户,请核查Excel数据
|
||||||
|
|
||||||
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_CheckDuplicateAccounts"));
|
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_CheckDuplicateAccounts"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excelList.Any(t => !t.Email.Contains("@")))
|
if (excelList.Any(t => !t.Email.Contains("@")))
|
||||||
{
|
{
|
||||||
|
//有邮箱不符合邮箱格式,请核查Excel数据
|
||||||
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_InvalidEmail"));
|
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_InvalidEmail"));
|
||||||
}
|
}
|
||||||
var generateUserTypeList = new List<string>() { "CRC", "SR", "CRA" };
|
var generateUserTypeList = new List<string>() { "CRC", "SR", "CRA" };
|
||||||
|
|
||||||
if (excelList.Any(t => !generateUserTypeList.Contains(t.UserTypeStr.ToUpper())))
|
if (excelList.Any(t => !generateUserTypeList.Contains(t.UserTypeStr.ToUpper())))
|
||||||
{
|
{
|
||||||
|
//用户类型仅能为 CRC,SR,CRA 请核查Excel数据
|
||||||
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_InvalidUserType"));
|
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_InvalidUserType"));
|
||||||
}
|
}
|
||||||
|
if (excelList.Count == 0)
|
||||||
|
{
|
||||||
|
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_NoValiddata"));
|
||||||
|
}
|
||||||
//处理好 用户类型 和用户类型枚举
|
//处理好 用户类型 和用户类型枚举
|
||||||
var sysUserTypeList = _usertypeRepository.Where(t => t.UserTypeEnum == UserTypeEnum.CRA || t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator || t.UserTypeEnum == UserTypeEnum.SR).Select(t => new { UserTypeId = t.Id, t.UserTypeEnum }).ToList();
|
var sysUserTypeList = _usertypeRepository.Where(t => t.UserTypeEnum == UserTypeEnum.CRA || t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator || t.UserTypeEnum == UserTypeEnum.SR).Select(t => new { UserTypeId = t.Id, t.UserTypeEnum }).ToList();
|
||||||
var siteList = _trialSiteRepository.Where(t => t.TrialId == trialId && siteCodeList.Contains(t.TrialSiteCode)).Select(t => new { t.TrialSiteCode, t.SiteId }).ToList();
|
var siteList = _trialSiteRepository.Where(t => t.TrialId == trialId && siteCodeList.Contains(t.TrialSiteCode)).Select(t => new { t.TrialSiteCode, t.SiteId }).ToList();
|
||||||
|
@ -1061,10 +1071,13 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
item.SiteId = siteList.FirstOrDefault(t => t.TrialSiteCode.ToUpper() == item.TrialSiteCode.ToUpper()).SiteId;
|
item.SiteId = siteList.FirstOrDefault(t => t.TrialSiteCode.ToUpper() == item.TrialSiteCode.ToUpper()).SiteId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await _trialSiteSurveyService.ImportGenerateAccountAndJoinTrialAsync(trialId, baseUrl, routeUrl, excelList.ToList());
|
await _trialSiteSurveyService.ImportGenerateAccountAndJoinTrialAsync(trialId, baseUrl, routeUrl, excelList.ToList());
|
||||||
|
|
||||||
return ResponseOutput.Ok();
|
return ResponseOutput.Ok();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1202,15 +1215,15 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
|
|
||||||
public enum UploadFileType
|
public enum UploadFileType
|
||||||
{
|
{
|
||||||
DataUpload=1,
|
DataUpload = 1,
|
||||||
|
|
||||||
DataDownload=2,
|
DataDownload = 2,
|
||||||
|
|
||||||
EmailAttachment=3,
|
EmailAttachment = 3,
|
||||||
|
|
||||||
EmailBodyHtml=4,
|
EmailBodyHtml = 4,
|
||||||
|
|
||||||
Other=5
|
Other = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1227,11 +1240,11 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
switch (fileType)
|
switch (fileType)
|
||||||
{
|
{
|
||||||
case UploadFileType.DataUpload:
|
case UploadFileType.DataUpload:
|
||||||
result= await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.DataTemplate,fileName));
|
result = await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.DataTemplate, fileName));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case UploadFileType.DataDownload:
|
case UploadFileType.DataDownload:
|
||||||
result= await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.DataTemplate,fileName));
|
result = await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.DataTemplate, fileName));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case UploadFileType.EmailAttachment:
|
case UploadFileType.EmailAttachment:
|
||||||
|
|
Loading…
Reference in New Issue