Uat_Study
parent
f69909ddcd
commit
6a12ef1277
|
@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Localization;
|
|||
using Localization;
|
||||
using Magicodes.ExporterAndImporter.Core.Filters;
|
||||
using IRaCIS.Core.Application.MediatR.CommandAndQueries;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
|
||||
namespace IRaCIS.Core.API
|
||||
{
|
||||
|
@ -81,6 +82,9 @@ namespace IRaCIS.Core.API
|
|||
})
|
||||
.AddNewtonsoftJsonSetup(); // NewtonsoftJson 序列化 处理
|
||||
|
||||
|
||||
//services.AddScoped<IAuditingData, AuditingData>();
|
||||
|
||||
//动态WebApi + UnifiedApiResultFilter 省掉控制器代码
|
||||
services.AddDynamicWebApiSetup();
|
||||
//AutoMapper
|
||||
|
|
|
@ -318,11 +318,11 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
|||
add =await _dataInspectionRepository.SetDataInspectionDateType(add);
|
||||
|
||||
|
||||
await _repository.AddAsync(add);
|
||||
//await _repository.AddAsync(add);
|
||||
|
||||
|
||||
var success = await _repository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok(success);
|
||||
//var success = await _repository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -131,6 +131,7 @@ namespace IRaCIS.Application.Services
|
|||
[TypeFilter(typeof(TrialResourceFilter))]
|
||||
public async Task<IResponseOutput> AddTrialUsers(TrialUserAddCommand[] userTrialCommands)
|
||||
{
|
||||
|
||||
var addArray = _mapper.Map<TrialUser[]>(userTrialCommands);
|
||||
|
||||
var trialUsers = await _trialUseRepository.AddRangeAsync(addArray);
|
||||
|
|
|
@ -42,5 +42,7 @@ namespace IRaCIS.Core.Domain.Share
|
|||
bool IsEn_Us { get; }
|
||||
|
||||
string RequestUrl { get; }
|
||||
|
||||
Guid? SignId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,6 +224,13 @@ namespace IRaCIS.Core.Domain.Share
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public Guid? SignId
|
||||
{
|
||||
|
||||
get; set;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ClaimAttributes
|
||||
|
|
|
@ -163,6 +163,11 @@ namespace IRaCIS.Core.Domain.Models
|
|||
/// 是否是前端添加
|
||||
/// </summary>
|
||||
public bool? IsFrontAdd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上一条json
|
||||
/// </summary>
|
||||
public string LastJsonDetail { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,331 @@
|
|||
using IRaCIS.Core.Domain.Common;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common.Dto;
|
||||
using IRaCIS.Core.Infra.EFCore.Dto;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加稽查稽查数据
|
||||
/// </summary>
|
||||
public class AuditingData : IAuditingData
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 数据库对象
|
||||
/// </summary>
|
||||
public IRaCISDBContext _dbContext { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户信息
|
||||
/// </summary>
|
||||
public IUserInfo _userInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构造方法
|
||||
/// </summary>
|
||||
/// <param name="dbContext"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
public AuditingData(IRaCISDBContext dbContext, IUserInfo userInfo)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_userInfo = userInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 传入实体对象
|
||||
/// </summary>
|
||||
public async Task IncomingEntitys(List<EntityEntry> entitys)
|
||||
{
|
||||
// 新增
|
||||
await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Added).ToList(), "Add");
|
||||
|
||||
// 修改
|
||||
await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Modified).ToList(), "Update");
|
||||
|
||||
// 删除
|
||||
await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Deleted).ToList(), "Deleted");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入Add的实体
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
public async Task InsertAddEntitys(List<EntityEntry> entitys,string type)
|
||||
{
|
||||
// 项目人员
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialUser)))
|
||||
{
|
||||
await InsertInspection<TrialUser>(item, type, x => new DataInspection()
|
||||
{
|
||||
GeneralId = x.Id
|
||||
});
|
||||
}
|
||||
// 受试者
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Subject)))
|
||||
{
|
||||
await InsertInspection<Subject>(item, type, x => new DataInspection() {
|
||||
SubjectId=x.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入稽查实体
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型</typeparam>
|
||||
/// <param name="data">数据</param>
|
||||
/// <param name="type">类型</param>
|
||||
/// <param name="expression">表达式</param>
|
||||
/// <returns></returns>
|
||||
public async Task InsertInspection<T>(EntityEntry data, string type, Expression<Func<T, DataInspection>> 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);
|
||||
}
|
||||
var originaldata = data.OriginalValues as T;
|
||||
if (originaldata != null)
|
||||
{
|
||||
inspection.LastJsonDetail = originaldata.ToJcJson();
|
||||
}
|
||||
|
||||
await AddInspectionRecordAsync(inspection, data.Entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取URl参数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetRequestUrl()
|
||||
{
|
||||
return _userInfo.RequestUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 映射数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="mapData">要赋值的对象</param>
|
||||
public void MapData(dynamic data, dynamic mapData)
|
||||
{
|
||||
List<string> column = new List<string>() { "TrialId", "SiteId", "SubjectId", "SubjectVisitId", "CreateUserName", "TrialName", "SiteName", "SubjectCode", "SubjectVisitName", "RoleName", "SiteCode", "ResearchProgramNo" };
|
||||
foreach (var item in column)
|
||||
{
|
||||
try
|
||||
{
|
||||
var i = mapData.GetType().GetProperty(item).GetValue(mapData);
|
||||
if (i == null)
|
||||
{
|
||||
var value = data.GetType().GetProperty(item).GetValue(data);
|
||||
mapData.GetType().GetProperty(item).SetValue(mapData, value);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddInspectionRecordAsync(DataInspection add, dynamic data)
|
||||
{
|
||||
MapData(data, add);
|
||||
InspectionGeneralData generalData = new InspectionGeneralData();
|
||||
MapData(add, generalData);
|
||||
await SetInspectionNameValue(generalData);
|
||||
#region 处理标识
|
||||
try
|
||||
{
|
||||
var from = await _dbContext.FrontAuditConfig.FirstOrDefaultAsync(x => x.Identification == add.Identification);
|
||||
add.ObjectType = from?.ObjectTypeId;
|
||||
add.OptType = from?.OptTypeId;
|
||||
add.ChildrenType = from?.ChildrenTypeId;
|
||||
add.ModuleType = from?.ModuleTypeId;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw new BusinessValidationFailedException("操作标识异常");
|
||||
}
|
||||
#endregion
|
||||
if (add.ParentId == null)
|
||||
{
|
||||
add.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId && x.VisitStageId == add.VisitStageId && x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
|
||||
|
||||
}
|
||||
add.CreateUserId = _userInfo.Id;
|
||||
add.IP = _userInfo.IP;
|
||||
if (add.CreateTime == default(DateTime))
|
||||
{
|
||||
add.CreateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
if (_userInfo.SignId!=null)
|
||||
{
|
||||
add.SignId = _userInfo.SignId;
|
||||
add.IsSign = true;
|
||||
}
|
||||
var inspectionData = new InspectionData()
|
||||
{
|
||||
Data = data,
|
||||
Inspection = generalData
|
||||
};
|
||||
add.JsonDetail = inspectionData.ToJcJson();
|
||||
await SetDataInspectionDateType(add);
|
||||
await _dbContext.DataInspection.AddAsync(add);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// IsNullOrEmpty
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private bool IsNullOrEmpty(object value)
|
||||
{
|
||||
if (value == null || value.ToString() == string.Empty)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置项目以及名称
|
||||
/// </summary>
|
||||
/// <param name="Data"></param>
|
||||
/// <returns></returns>
|
||||
public async Task SetInspectionNameValue(InspectionGeneralData Data)
|
||||
{
|
||||
#region 项目名称
|
||||
|
||||
var trialdata = await _dbContext.Trial.Select(x => new { x.Id, x.ResearchProgramNo, x.ExperimentName, }).FirstOrDefaultAsync(x => x.Id == Data.TrialId);
|
||||
if (IsNullOrEmpty(Data.ResearchProgramNo))
|
||||
{
|
||||
|
||||
Data.ResearchProgramNo = trialdata?.ResearchProgramNo;
|
||||
}
|
||||
|
||||
if (IsNullOrEmpty(Data.TrialName))
|
||||
{
|
||||
Data.TrialName = trialdata?.ExperimentName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 测试中心名称
|
||||
|
||||
|
||||
Data.SiteCode = (await _dbContext.TrialSite.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.TrialId == Data.TrialId && x.SiteId == Data.SiteId))?.TrialSiteCode;
|
||||
|
||||
|
||||
|
||||
if (IsNullOrEmpty(Data.SiteName) && Data.SiteId != null)
|
||||
{
|
||||
var sitedata = await _dbContext.Site.Where(x => x.Id == Data.SiteId).Select(x => new { x.SiteName }).FirstOrDefaultAsync();
|
||||
Data.SiteName = sitedata?.SiteName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 受试者
|
||||
|
||||
|
||||
if (IsNullOrEmpty(Data.SubjectCode) && Data.SubjectId != null)
|
||||
{
|
||||
|
||||
Data.SubjectCode = (await _dbContext.Subject.Where(x => x.Id == Data.SubjectId).Select(x => new { x.Code }).FirstOrDefaultAsync())?.Code;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 访视
|
||||
if (IsNullOrEmpty(Data.SubjectVisitName))
|
||||
{
|
||||
Data.SubjectVisitName = (await _dbContext.SubjectVisit.Where(x => x.Id == Data.SubjectVisitId).Select(x => new { x.VisitName }).FirstOrDefaultAsync())?.VisitName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建者
|
||||
|
||||
if (IsNullOrEmpty(Data.CreateUserName))
|
||||
{
|
||||
Data.CreateUserName = _userInfo.RealName;
|
||||
}
|
||||
|
||||
if (IsNullOrEmpty(Data.RoleName))
|
||||
{
|
||||
Data.RoleName = _userInfo.UserTypeShortName;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 格式化日期和时间
|
||||
/// </summary>
|
||||
/// <param name="Data">稽查数据</param>
|
||||
/// <returns></returns>
|
||||
public async Task<DataInspection> SetDataInspectionDateType(DataInspection Data)
|
||||
{
|
||||
var list = await (from parent in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.Identification == Data.Identification)
|
||||
join child in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.EnumType == "Date") on parent.Id equals child.ParentId
|
||||
select new DateDto()
|
||||
{
|
||||
Code = child.Code,
|
||||
DateType = child.DateType,
|
||||
}).ToListAsync();
|
||||
|
||||
var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(Data.JsonDetail);
|
||||
|
||||
foreach (var item in JsonData.Keys)
|
||||
{
|
||||
var datefirst = list.FirstOrDefault(x => x.Code.ToLower() == item.ToLower());
|
||||
if (datefirst != null && !IsNullOrEmpty(JsonData[item]))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (datefirst.DateType == "Date")
|
||||
{
|
||||
JsonData[item] = DateTime.Parse(JsonData[item].ToString()).ToString("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
if (datefirst.DateType == "DateTime")
|
||||
{
|
||||
JsonData[item] = DateTime.Parse(JsonData[item].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Data.JsonDetail = JsonConvert.SerializeObject(JsonData);
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Common.Dto
|
||||
{
|
||||
public class AuditingDto<T>
|
||||
{
|
||||
public Type EntityType { get; set; }
|
||||
|
||||
public Expression<Func<T, DataInspection>> Expression { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Common
|
||||
{
|
||||
public interface IAuditingData
|
||||
{
|
||||
Task IncomingEntitys(List<EntityEntry> entitys);
|
||||
}
|
||||
}
|
|
@ -17,21 +17,28 @@ using Microsoft.EntityFrameworkCore.Metadata;
|
|||
using Microsoft.EntityFrameworkCore.ValueGeneration;
|
||||
using UserTypeGroup = IRaCIS.Core.Domain.Models.UserTypeGroup;
|
||||
using IRaCIS.Core.Infra.EFCore.Dto;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore
|
||||
{
|
||||
public class IRaCISDBContext : DbContext
|
||||
{
|
||||
public readonly IUserInfo _userInfo;
|
||||
//private readonly IAuditingData _auditingData;
|
||||
|
||||
// 在控制台
|
||||
//public static readonly ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder => { builder.AddConsole(); });
|
||||
// 调试窗口
|
||||
public static readonly ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder => { builder.AddDebug(); });
|
||||
|
||||
public IRaCISDBContext(DbContextOptions<IRaCISDBContext> options, IUserInfo userInfo) : base(options)
|
||||
public IRaCISDBContext(DbContextOptions<IRaCISDBContext> options, IUserInfo userInfo
|
||||
|
||||
|
||||
//IAuditingData auditingData
|
||||
) : base(options)
|
||||
{
|
||||
_userInfo = userInfo;
|
||||
//this._auditingData = auditingData;
|
||||
//_configuration = configuration;
|
||||
}
|
||||
|
||||
|
@ -346,84 +353,100 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
#region 废弃
|
||||
|
||||
//public override int SaveChanges()
|
||||
//{
|
||||
// UpdateAuditInfo();
|
||||
// return base.SaveChanges();
|
||||
//}
|
||||
public override int SaveChanges()
|
||||
{
|
||||
//UpdateAuditInfo().GetAwaiter();
|
||||
AddAudit().GetAwaiter();
|
||||
return base.SaveChanges();
|
||||
}
|
||||
|
||||
//public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||
//{
|
||||
// UpdateAuditInfo();
|
||||
// return base.SaveChangesAsync(cancellationToken);
|
||||
//}
|
||||
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||
{
|
||||
//await UpdateAuditInfo();
|
||||
|
||||
await AddAudit();
|
||||
return await base.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
public async Task AddAudit()
|
||||
{
|
||||
var entities = ChangeTracker.Entries().Where(u => (u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added)).Where(x => x.Entity.GetType() != typeof(DataInspection)).ToList();
|
||||
AuditingData auditingData = new AuditingData(this, _userInfo);
|
||||
await auditingData.IncomingEntitys(entities);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写savechange方式 统一增加审计信息 CreateUserId CreateTime UpdateTime UpdateUserId 可用事件绑定的方式UpdateAuitUser
|
||||
/// </summary>
|
||||
private void UpdateAuditInfo()
|
||||
private async Task UpdateAuditInfo()
|
||||
{
|
||||
|
||||
ChangeTracker.DetectChanges(); // Important!
|
||||
|
||||
|
||||
|
||||
|
||||
//ChangeTracker.DetectChanges(); // Important!
|
||||
|
||||
//// 获取所有更改,删除,新增的实体,但排除审计实体(避免死循环)
|
||||
var entities = ChangeTracker.Entries()
|
||||
.Where(u => (u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added));
|
||||
//var entities = ChangeTracker.Entries()
|
||||
// .Where(u => (u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added)).Where(x=>x.Entity.GetType()!=typeof(data)).ToList();
|
||||
//AuditingData auditingData = new AuditingData(this, _userInfo);
|
||||
//await auditingData.IncomingEntitys(entities);
|
||||
//var items = entities.SelectMany(x => x.Entity.GetType().ToString());
|
||||
|
||||
foreach (var t in entities)
|
||||
{
|
||||
switch (t.State)
|
||||
{
|
||||
//foreach (var t in entities)
|
||||
//{
|
||||
// switch (t.State)
|
||||
// {
|
||||
|
||||
case EntityState.Deleted:
|
||||
// case EntityState.Deleted:
|
||||
|
||||
break;
|
||||
case EntityState.Modified:
|
||||
// break;
|
||||
// case EntityState.Modified:
|
||||
|
||||
if (t.Entity is IAuditUpdate updateEntity1)
|
||||
{
|
||||
updateEntity1.UpdateTime = DateTime.UtcNow.AddHours(8);
|
||||
updateEntity1.UpdateUserId = _userInfo.Id;
|
||||
}
|
||||
// if (t.Entity is IAuditUpdate updateEntity1)
|
||||
// {
|
||||
// updateEntity1.UpdateTime = DateTime.UtcNow.AddHours(8);
|
||||
// updateEntity1.UpdateUserId = _userInfo.Id;
|
||||
// }
|
||||
|
||||
|
||||
break;
|
||||
//添加的时候,更新审计字段也赋值
|
||||
case EntityState.Added:
|
||||
// break;
|
||||
// //添加的时候,更新审计字段也赋值
|
||||
// case EntityState.Added:
|
||||
|
||||
////// 仓储添加时 就有id了
|
||||
//if (t.Entity is Entity entity && entity.Id == Guid.Empty)
|
||||
//{
|
||||
// entity.Id = NewId.NextGuid();
|
||||
//}
|
||||
// ////// 仓储添加时 就有id了
|
||||
// //if (t.Entity is Entity entity && entity.Id == Guid.Empty)
|
||||
// //{
|
||||
// // entity.Id = NewId.NextGuid();
|
||||
// //}
|
||||
|
||||
if (t.Entity is IAuditAdd addEntity)
|
||||
{
|
||||
if (addEntity.CreateTime == default(DateTime))
|
||||
{
|
||||
addEntity.CreateTime = DateTime.UtcNow.AddHours(8);
|
||||
}
|
||||
// if (t.Entity is IAuditAdd addEntity)
|
||||
// {
|
||||
// if (addEntity.CreateTime == default(DateTime))
|
||||
// {
|
||||
// addEntity.CreateTime = DateTime.UtcNow.AddHours(8);
|
||||
// }
|
||||
|
||||
addEntity.CreateUserId = _userInfo.Id;
|
||||
}
|
||||
// addEntity.CreateUserId = _userInfo.Id;
|
||||
// }
|
||||
|
||||
if (t.Entity is IAuditUpdate updateEntity)
|
||||
{
|
||||
updateEntity.UpdateTime = DateTime.UtcNow.AddHours(8);
|
||||
updateEntity.UpdateUserId = _userInfo.Id;
|
||||
}
|
||||
|
||||
if (t.Entity is IAuditAddWithUserName addEntity3)
|
||||
{
|
||||
addEntity3.CreateTime = DateTime.UtcNow.AddHours(8);
|
||||
addEntity3.CreateUserId = _userInfo.Id;
|
||||
addEntity3.CreateUser = _userInfo.RealName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if (t.Entity is IAuditUpdate updateEntity)
|
||||
// {
|
||||
// updateEntity.UpdateTime = DateTime.UtcNow.AddHours(8);
|
||||
// updateEntity.UpdateUserId = _userInfo.Id;
|
||||
// }
|
||||
|
||||
// if (t.Entity is IAuditAddWithUserName addEntity3)
|
||||
// {
|
||||
// addEntity3.CreateTime = DateTime.UtcNow.AddHours(8);
|
||||
// addEntity3.CreateUserId = _userInfo.Id;
|
||||
// addEntity3.CreateUser = _userInfo.RealName;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
@ -466,7 +489,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (e.Entry.Entity is IAuditAddWithUserName addEntity2)
|
||||
{
|
||||
switch (e.Entry.State)
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
await _dbSet.AddAsync(entity).ConfigureAwait(false);
|
||||
|
||||
// 添加稽查
|
||||
await AddInspectionAsync(entity, isSaveAudit);
|
||||
//await AddInspectionAsync(entity, isSaveAudit);
|
||||
|
||||
if (autoSave)
|
||||
{
|
||||
|
@ -1021,29 +1021,10 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
await SetDataInspectionDateType(add);
|
||||
}
|
||||
|
||||
await _dbContext.DataInspection.AddRangeAsync(datas);
|
||||
//await _dbContext.DataInspection.AddRangeAsync(datas);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// IsNullOrEmpty
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private bool IsNullOrEmpty(object value)
|
||||
{
|
||||
if (value == null || value.ToString() == string.Empty)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格式化日期和时间
|
||||
/// </summary>
|
||||
|
@ -1052,7 +1033,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
public async Task<DataInspection> SetDataInspectionDateType(DataInspection Data)
|
||||
{
|
||||
var list = await (from parent in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.Identification == Data.Identification)
|
||||
join child in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.EnumType== "Date") on parent.Id equals child.ParentId
|
||||
join child in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.EnumType == "Date") on parent.Id equals child.ParentId
|
||||
select new DateDto()
|
||||
{
|
||||
Code = child.Code,
|
||||
|
@ -1090,6 +1071,25 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
return Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IsNullOrEmpty
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private bool IsNullOrEmpty(object value)
|
||||
{
|
||||
if (value == null || value.ToString() == string.Empty)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置项目以及名称
|
||||
|
|
Loading…
Reference in New Issue