清明节前导表预提交
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
using Magicodes.ExporterAndImporter.Core;
|
||||
using Magicodes.ExporterAndImporter.Core.Filters;
|
||||
using Magicodes.ExporterAndImporter.Core.Models;
|
||||
using Magicodes.ExporterAndImporter.Excel;
|
||||
using MediatR;
|
||||
using MiniExcelLibs.Attributes;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
|
||||
namespace IRaCIS.Core.Application.MediatR.CommandAndQueries
|
||||
{
|
||||
@@ -19,19 +24,76 @@ namespace IRaCIS.Core.Application.MediatR.CommandAndQueries
|
||||
public Guid StudyId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class ImportResultFilteTest : IImportResultFilter
|
||||
{
|
||||
|
||||
|
||||
public ImportResult<T> Filter<T>(ImportResult<T> importResult) where T : class, new()
|
||||
{
|
||||
if (typeof(T).IsAssignableFrom(typeof(CheckViewModel)))
|
||||
{
|
||||
var data = (List<CheckViewModel>)importResult.Data;
|
||||
|
||||
var dt = DateTime.Now ;
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
|
||||
var index= data.IndexOf(item);
|
||||
if ( DateTime.TryParse(item.StudyDate, out dt) == false)
|
||||
{
|
||||
importResult.RowErrors.Add(new DataRowErrorInfo() { RowIndex = index, FieldErrors = new Dictionary<string, string> { { "检查技术", "时间格式不对" } } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return importResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[ExcelImporter(/*ImportResultFilter = typeof(ImportResultFilteTest),*/ IsLabelingError = true)]
|
||||
|
||||
public class CheckViewModel
|
||||
{
|
||||
[Required(ErrorMessage = "中心编号不能为空")]
|
||||
[ImporterHeader(Name = "中心编号", AutoTrim = true)]
|
||||
[ExcelColumnName("中心编号")]
|
||||
public string SiteCode { get; set; } = string.Empty;
|
||||
|
||||
|
||||
[Required(ErrorMessage = "受试者筛选号不能为空")]
|
||||
[ImporterHeader(Name = "受试者筛选号", AutoTrim = true)]
|
||||
[ExcelColumnName("受试者筛选号")]
|
||||
public string SubjectCode { get; set; } = string.Empty;
|
||||
|
||||
[Required(ErrorMessage = "访视名称不能为空")]
|
||||
[ImporterHeader(Name = "访视名称", AutoTrim = true)]
|
||||
[ExcelColumnName("访视名称")]
|
||||
public string VisitName { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
[Required(ErrorMessage = "检查日期不能为空")]
|
||||
[CanConvertToTime(ErrorMessage = "检查日期格式有问题")]
|
||||
|
||||
[ImporterHeader(Name = "检查日期", AutoTrim = true)]
|
||||
[ExcelColumnName("检查日期")]
|
||||
public string StudyDate { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
[Required(ErrorMessage = "Modality不能为空")]
|
||||
[ImporterHeader(Name = "检查技术", AutoTrim = true)]
|
||||
[ExcelColumnName("检查技术")]
|
||||
public string Modality { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null) return false;
|
||||
|
||||
Reference in New Issue
Block a user