diff --git a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs index 35f475d4a..8a24b14bb 100644 --- a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs @@ -255,7 +255,7 @@ namespace IRaCIS.Core.Application.Service DateType=data.DataType, DictionaryCode=data.DictionaryCode, DictionaryType=data.DictionaryType, - + InterfaceName=data.InterfaceName, }; diff --git a/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs b/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs index a9b6856d0..380b2536c 100644 --- a/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs +++ b/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs @@ -211,6 +211,13 @@ namespace IRaCIS.Core.Domain.Models public string ForeignKeyText { get; set; } + /// + /// 接口名 + /// + + public string InterfaceName { get; set; } + + } } diff --git a/IRaCIS.Core.Domain/Trial/DataInspection.cs b/IRaCIS.Core.Domain/Trial/DataInspection.cs index ac68168aa..59a6fba9d 100644 --- a/IRaCIS.Core.Domain/Trial/DataInspection.cs +++ b/IRaCIS.Core.Domain/Trial/DataInspection.cs @@ -38,7 +38,8 @@ namespace IRaCIS.Core.Domain.Models /// /// 项目iD /// - public Guid? TrialId { get; set; } + [Required] + public Guid TrialId { get; set; } /// /// 中心 diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index c959cbe7b..ea74da4e7 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -65,21 +65,54 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// public async Task InsertAddEntitys(List entitys,string type) { + + #region 所有 + //foreach (var item in entitys) + //{ + // await InsertInspection(item, type); + //} + #endregion + + #region 区分 + + + // 项目人员 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialUser))) { - await InsertInspection(item, type, x => new DataInspection() - { - GeneralId = x.Id - }); + await InsertInspection(item, type); } // 受试者 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Subject))) { - await InsertInspection(item, type, x => new DataInspection() { - SubjectId=x.Id + await InsertInspection(item, type, x => new DataInspection() + { + SubjectId = x.Id }); } + + // 访视 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit))) + { + await InsertInspection(item, type, x => new DataInspection() + { + SubjectId = x.Id + }); + } + #endregion + + + + + + // 插入稽查信息 + //async Task InsertInspectionData(Expression> expression = null) + //{ + // await InsertInspection(item, type, x => new DataInspection() + // { + // GeneralId = x.Id + // }); + //} } /// @@ -92,14 +125,15 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// public async Task InsertInspection(EntityEntry data, string type, Expression> expression = null) where T:class { + DataInspection inspection = new DataInspection(); - inspection.Identification = $"{GetRequestUrl()}/{ data.GetType().ToString().Substring(data.GetType().ToString().LastIndexOf('.') + 1)}/{type}"; if (expression != null) { var f = expression.Compile(); var entity = data.Entity as T; inspection = f(entity); } + inspection.Identification = $"{GetRequestUrl()}/{ data.GetType().ToString().Substring(data.GetType().ToString().LastIndexOf('.') + 1)}/{type}"; var originaldata = data.OriginalValues as T; if (originaldata != null) { @@ -109,6 +143,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common await AddInspectionRecordAsync(inspection, data.Entity); } + + + + /// /// 获取URl参数 /// @@ -131,7 +169,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common try { var i = mapData.GetType().GetProperty(item).GetValue(mapData); - if (i == null) + if (i == null|| i==default(Guid)) { var value = data.GetType().GetProperty(item).GetValue(data); mapData.GetType().GetProperty(item).SetValue(mapData, value);