diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index c7beabb6..d50cd764 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -16,6 +16,13 @@ using System.Threading.Tasks; namespace IRaCIS.Core.Infra.EFCore.Common { + public static class AuditOpt + { + public static readonly string Add = "Add"; + public static readonly string Update = "Update"; + public static readonly string Deleted = "Deleted"; + } + /// /// 添加稽查稽查数据 /// @@ -52,16 +59,16 @@ namespace IRaCIS.Core.Infra.EFCore.Common // 修改 await InsertAddEntitys( entitys.Where(x => x.State == EntityState.Modified && - (!typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) || !(bool)x.Entity.GetType().GetProperty("IsDeleted").GetValue(x.Entity) || NodeleteTableTypes.Contains(x.Entity.GetType())) - ).ToList(), "Update"); + (!typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) || !(bool)x.Entity.GetType().GetProperty(nameof(ISoftDelete.IsDeleted)).GetValue(x.Entity) || NodeleteTableTypes.Contains(x.Entity.GetType())) + ).ToList(), AuditOpt.Update); // 新增 - await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Added).ToList(), "Add"); + await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Added).ToList(), AuditOpt.Add); // 删除 await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Deleted - || (typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) && (bool)x.Entity.GetType().GetProperty("IsDeleted").GetValue(x.Entity) && x.State == EntityState.Modified && !NodeleteTableTypes.Contains(x.Entity.GetType())) - ).ToList(), "Deleted"); + || (typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) && (bool)x.Entity.GetType().GetProperty(nameof(ISoftDelete.IsDeleted)).GetValue(x.Entity) && x.State == EntityState.Modified && !NodeleteTableTypes.Contains(x.Entity.GetType())) + ).ToList(), AuditOpt.Deleted); } @@ -875,7 +882,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common } - inspection.Identification = await GetInspectionRecordIdentificationAsync(entityObj,type); + inspection.Identification = await GetInspectionRecordIdentificationAsync(entityObj, type); //将实体对象属性 映射到稽查实体 MapEntityPropertyToAuditEntity(entityObj, inspection); @@ -906,16 +913,19 @@ namespace IRaCIS.Core.Infra.EFCore.Common inspection.IsSign = true; } - var inspectionData = new InspectionJsonDetail() + + inspection.JsonDetail = new InspectionJsonDetail { - //稽查实体,加上扩充的信息 + //稽查实体,加上扩充的信息 Data = AddJsonItem(entityObj, otherItem), - //通用信息 - Inspection = generalData - }; - inspection.JsonDetail = inspectionData.ToJsonStr(); + //通用信息 每条稽查必须记录的 + CommonData = generalData + + }.ToJsonStr(); + inspection.BatchId = _userInfo.BatchId.Value; + await _dbContext.DataInspection.AddAsync(inspection); @@ -1250,7 +1260,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common Data = AddJsonItem(data, otherItem), //通用信息 - Inspection = generalData + CommonData = generalData }; add.JsonDetail = inspectionData.ToJsonStr(); add.BatchId = _userInfo.BatchId.Value; diff --git a/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs b/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs index 845b97a1..b0721838 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs @@ -88,9 +88,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common.Dto /// public class InspectionJsonDetail { - public dynamic Data { get; set; } + public object Data { get; set; } - public InspectionGeneralData Inspection { get; set; } + public InspectionGeneralData CommonData { get; set; } }