diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index d217141d5..84de882fd 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -66,6 +66,13 @@ + + + 删除某个目录的文件 + + + + https://www.cnblogs.com/NBDWDYS2214143926/p/13329231.html @@ -979,6 +986,49 @@ + + + IR 影像上传任务列表 + + + + + + + IR 上传任务 dicom 列表 后处理的数据不能排序 + + + + + + + IR 上传任务 nonedicom 列表 后处理的数据不能排序 + + + + + + + IQC 获取CRC 上传到某一个访视的的检查信息 (原始影像信息 包含dicom 非dicom) + + + + + + + IR 阅片页面 和IR 任务列表页面下载 勾选下载列表(后端要考虑到一致性分析 subjectCode的问题) + + + + + + + IR 阅片页面获取下载检查的信息 会根据标准进行过滤检查,(后端要考虑到一致性分析 subjectCode的问题) + + + + + 指定资源Id,渲染Dicom检查的Jpeg预览图像 Dicom检查的Id @@ -10299,6 +10349,11 @@ 子数据Lable + + + 前端渲染数组 数组名 和数组值 英文名称 + + 子数据Value @@ -10334,6 +10389,11 @@ 外键Text + + + 英文的翻译 + + 接口名 @@ -11434,6 +11494,23 @@ ISystemDocumentService + + + NoneDicomStudyService + + + + + NoneDicomStudyService + + + + + 非Dicom检查 文件列表 + + + + UserTypeRoleView 列表视图模型 @@ -11744,23 +11821,6 @@ 语言类型 - - - NoneDicomStudyService - - - - - NoneDicomStudyService - - - - - 非Dicom检查 文件列表 - - - - 系统QC 问题管理 @@ -15419,7 +15479,7 @@ - + 真删除项目 方便清理测试数据 临床试验项目Id diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 931eb9a6e..7f83a3957 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -25,6 +25,7 @@ using System.Reflection.Metadata; namespace IRaCIS.Core.Infra.EFCore { + #region 连接池废弃 /// /// 报错,添加subject 报错,重复添加访视 /// @@ -47,6 +48,8 @@ namespace IRaCIS.Core.Infra.EFCore // return context; // } //} + #endregion + public class IRaCISDBContext : DbContext { @@ -72,42 +75,7 @@ namespace IRaCIS.Core.Infra.EFCore builder.HasNoKey(); }); - modelBuilder.Entity().HasMany(t => t.NoneDicomFileList).WithOne(s => s.NoneDicomStudy).HasForeignKey(t => t.NoneDicomStudyId); - modelBuilder.Entity().HasMany(t => t.TaskNoneDicomFileList).WithOne(s => s.OriginNoneDicomStudy).HasForeignKey(t => t.OriginNoneDicomStudyId); - - modelBuilder.Entity().HasQueryFilter(p => p.IsAdditional == false); - - - modelBuilder.Entity().HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId).IsRequired(false); - - - //modelBuilder.Entity().HasMany(t => t.DoctorTrialVisitTaskList).WithOne(t => t.DoctorTaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId }); - - //modelBuilder.Entity().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.TaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId }); - - //会导致级联删除 - //modelBuilder.Entity().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t => t.SujectArm).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum }) - // ./*IsRequired(false)*/OnDelete(DeleteBehavior.NoAction); - - // modelBuilder.Entity().HasOne(t => t.SujectArm).WithMany(s => s.SubjectArmVisitTaskList).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum }); - - modelBuilder.Entity().HasMany(t => t.JudgeVisitList).WithOne(t => t.JudgeVisitTask); - - - modelBuilder.Entity().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId); - - modelBuilder.Entity().HasOne(t => t.Subject).WithMany(s => s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId); - - modelBuilder.Entity().HasMany(t => t.TaskInfluenceList).WithOne(s => s.OriginalTask).HasForeignKey(t => t.OriginalTaskId); - - - modelBuilder.Entity().HasMany(t => t.GlobalVisitResultList).WithOne(s => s.GlobalVisitTask).HasForeignKey(t => t.GlobalTaskId); - - modelBuilder.Entity().HasMany(t => t.ChildList).WithOne(t => t.Parent); - modelBuilder.Entity().HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser); - - modelBuilder.Entity().HasQueryFilter(b => b.Subject.IsDeleted == false); - + //遍历实体模型手动配置 var typesToRegister = Assembly.GetExecutingAssembly().GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null); foreach (var type in typesToRegister) @@ -138,7 +106,7 @@ namespace IRaCIS.Core.Infra.EFCore } - #region + #region 存储过程或者视图 public IQueryable GetTableList() { return Set().FromSqlRaw("EXEC dbo.procGetTableList"); @@ -150,6 +118,92 @@ namespace IRaCIS.Core.Infra.EFCore } #endregion + + public override async Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()) + { + // 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因 + await AddAudit(); + + try + { + return await base.SaveChangesAsync(cancellationToken); + + } + catch (UniqueConstraintException ex) + { + _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); + + throw new DBSaveFailedException("该唯一键已经存在于数据库中。"); + + } + catch (TimeoutException ex) + { + _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); + + throw new DBSaveFailedException("数据库操作已经超时,请稍后重试。"); + + } + catch (CannotInsertNullException ex) + { + _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); + + throw new DBSaveFailedException("无法在非空列上插入空值。"); + } + catch (MaxLengthExceededException ex) + { + _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); + + throw new DBSaveFailedException("字符串超过了数据库列的最大长度。"); + } + catch (NumericOverflowException ex) + { + _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); + throw new DBSaveFailedException("数值超过了数据类型的范围。"); + } + catch (SyntaxErrorException ex) + { + _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); + + throw new DBSaveFailedException("SQL 查询中存在语法错误。"); + } + catch (ReferenceConstraintException ex) + { + _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); + throw new DBSaveFailedException("无法进行当前操作,当前数据不符合外键约束。"); + } + catch (DbUpdateConcurrencyException ex) + { + _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); + + throw new DBSaveFailedException("SQL 事务失败,请检查环境。"); + } + + } + + + public async Task AddAudit() + { + + //触发器里面提交事务 业务方法里面提交事务 会记录两次 + var inspectionGeneralIdList = ChangeTracker.Entries().Where(t => typeof(DataInspection).IsAssignableFrom(t.Entity.GetType())).Select(t => ((DataInspection)t.Entity).GeneralId).ToList(); + + var entities = ChangeTracker.Entries().Where(u => (u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added)) + .Where(t => !typeof(DataInspection).IsAssignableFrom(t.Entity.GetType()) && !inspectionGeneralIdList.Contains(((Entity)t.Entity).Id)) + .ToList(); + AuditingData auditingData = new AuditingData(this, _userInfo); + + //await auditingData.IncomingEntitys(entities); + + + if (entities.Count > 0) + { + await auditingData.InsertAddEntitys(entities); + + } + + + } + #region Doctor public virtual DbSet Dictionary { get; set; } public virtual DbSet Doctor { get; set; } @@ -400,8 +454,6 @@ namespace IRaCIS.Core.Infra.EFCore #endregion - - #region Document public virtual DbSet SystemDocument { get; set; } public virtual DbSet TrialDocument { get; set; } @@ -414,41 +466,7 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet TrialDocConfirmedUser { get; set; } #endregion - #region 暂时未用 - - #region 工作量分配 - //public virtual DbSet WorkloadTPs { get; set; } - //public virtual DbSet WorkloadGlobals { get; set; } - //public virtual DbSet WorkloadADs { get; set; } - //public virtual DbSet WorkloadDetails { get; set; } - #endregion - //public virtual DbSet SysMessages { get; set; } - //public virtual DbSet TrialAttachment { get; set; } - //public virtual DbSet SystemLogs { get; set; } - //public virtual DbSet TU { get; set; } - //public virtual DbSet TR { get; set; } - //public virtual DbSet RS { get; set; } - //public virtual DbSet Reports { get; set; } - //public virtual DbSet StudyReviewer { get; set; } - - //public virtual DbSet KeyInstances { get; set; } - //public virtual DbSet GlobalRS { get; set; } - //public virtual DbSet GlobalResult { get; set; } - //public virtual DbSet ImageLabels { get; set; } - - //public virtual DbSet QaTemplateItem { get; set; } - //public virtual DbSet QaTemplateItemDictionary { get; set; } - //public virtual DbSet QaTemplateTemplateItem { get; set; } - //public virtual DbSet QATrailTemplate { get; set; } - //public virtual DbSet QATrialTemplateItem { get; set; } - //public virtual DbSet QARecordTrialTemplateItem { get; set; } - //public virtual DbSet QARecordTemplateItemDetail { get; set; } - //public virtual DbSet QATemplate { get; set; } - //public virtual DbSet QANoticeUser { get; set; } - //public virtual DbSet QANotice { get; set; } - //public virtual DbSet TrialUserPreparation { get; set; } - - #endregion + #region 未分类 public virtual DbSet ShortcutKey { get; set; } @@ -509,96 +527,6 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet UserFeedBack { get; set; } - - public override async Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()) - { - // 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因 - await AddAudit(); - - try - { - return await base.SaveChangesAsync(cancellationToken); - - } - catch (UniqueConstraintException ex) - { - _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); - - throw new DBSaveFailedException("该唯一键已经存在于数据库中。"); - - } - catch (TimeoutException ex) - { - _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); - - throw new DBSaveFailedException("数据库操作已经超时,请稍后重试。"); - - } - catch (CannotInsertNullException ex) - { - _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); - - throw new DBSaveFailedException("无法在非空列上插入空值。"); - } - catch (MaxLengthExceededException ex) - { - _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); - - throw new DBSaveFailedException("字符串超过了数据库列的最大长度。"); - } - catch (NumericOverflowException ex) - { - _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); - throw new DBSaveFailedException("数值超过了数据类型的范围。"); - } - catch (SyntaxErrorException ex) - { - _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); - - throw new DBSaveFailedException("SQL 查询中存在语法错误。"); - } - catch (ReferenceConstraintException ex) - { - _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); - throw new DBSaveFailedException("无法进行当前操作,当前数据不符合外键约束。"); - } - catch (DbUpdateConcurrencyException ex) - { - _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); - - throw new DBSaveFailedException("SQL 事务失败,请检查环境。"); - } - - } - - - - public async Task AddAudit() - { - - //触发器里面提交事务 业务方法里面提交事务 会记录两次 - var inspectionGeneralIdList = ChangeTracker.Entries().Where(t => typeof(DataInspection).IsAssignableFrom(t.Entity.GetType())).Select(t => ((DataInspection)t.Entity).GeneralId).ToList(); - - var entities = ChangeTracker.Entries().Where(u => (u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added)) - .Where(t => !typeof(DataInspection).IsAssignableFrom(t.Entity.GetType()) && !inspectionGeneralIdList.Contains(((Entity)t.Entity).Id)) - .ToList(); - AuditingData auditingData = new AuditingData(this, _userInfo); - - //await auditingData.IncomingEntitys(entities); - - - if (entities.Count > 0) - { - await auditingData.InsertAddEntitys(entities); - - } - - - } - - - - public virtual DbSet TaskAllocationRule { get; set; } public virtual DbSet VisitTask { get; set; } @@ -627,15 +555,9 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet TrialVirtualSiteCodeUpdate { get; set; } public virtual DbSet EnrollReadingCriterion { get; set; } + #endregion } - public class MySequentialGuidValueGenerator : ValueGenerator - { - public override Guid Next(EntityEntry entry) - { - return NewId.NextGuid(); - } - public override bool GeneratesTemporaryValues => false; - } + } \ No newline at end of file diff --git a/IRaCIS.Core.Infra.EFCore/Context/Triggers/AuditAddTrigger.cs b/IRaCIS.Core.Infra.EFCore/Context/Triggers/AuditAddTrigger.cs deleted file mode 100644 index 6b2978476..000000000 --- a/IRaCIS.Core.Infra.EFCore/Context/Triggers/AuditAddTrigger.cs +++ /dev/null @@ -1,66 +0,0 @@ -//using System; -//using System.Threading; -//using System.Threading.Tasks; -//using EntityFrameworkCore.Triggered; -//using IRaCIS.Core.Domain.Models; -//using IRaCIS.Core.Domain.Share; - -//namespace IRaCIS.Core.Application.Triggers -//{ -// public class AuditAddTrigger: IBeforeSaveTrigger -// { -// private readonly IUserInfo _userInfo; - -// public AuditAddTrigger(IUserInfo userInfo) -// { -// _userInfo = userInfo; -// } - -// public Task BeforeSave(ITriggerContext context, CancellationToken cancellationToken) -// { -// if (context.ChangeType == ChangeType.Added) -// { -// context.Entity.CreateUserId = _userInfo.Id; - -// if (context.Entity.CreateTime == default(DateTime)) -// { -// context.Entity.CreateTime = DateTime.Now; - -// } - -// } - -// return Task.CompletedTask; - -// } -// } - -// public class AuditAddWithUsernameTrigger : IBeforeSaveTrigger -// { -// private readonly IUserInfo _userInfo; - -// public AuditAddWithUsernameTrigger(IUserInfo userInfo) -// { -// _userInfo = userInfo; -// } - -// public Task BeforeSave(ITriggerContext context, CancellationToken cancellationToken) -// { -// if (context.ChangeType == ChangeType.Added) -// { -// context.Entity.CreateUserId = _userInfo.Id; -// context.Entity.CreateUser = _userInfo.UserName; - -// if (context.Entity.CreateTime == default(DateTime)) -// { -// context.Entity.CreateTime = DateTime.Now; -// } -// } - - - -// return Task.CompletedTask; - -// } -// } -//} \ No newline at end of file diff --git a/IRaCIS.Core.Infra.EFCore/Context/Triggers/AuditUpdateTrigger.cs b/IRaCIS.Core.Infra.EFCore/Context/Triggers/AuditUpdateTrigger.cs deleted file mode 100644 index 5b0d732a4..000000000 --- a/IRaCIS.Core.Infra.EFCore/Context/Triggers/AuditUpdateTrigger.cs +++ /dev/null @@ -1,33 +0,0 @@ -//using System; -//using System.Threading; -//using System.Threading.Tasks; -//using EntityFrameworkCore.Triggered; -//using IRaCIS.Core.Domain.Models; -//using IRaCIS.Core.Domain.Share; - -//namespace IRaCIS.Core.Application.Triggers -//{ -// public class AuditUpdateTrigger : IBeforeSaveTrigger -// { -// private readonly IUserInfo _userInfo; - -// public AuditUpdateTrigger(IUserInfo userInfo) -// { -// _userInfo = userInfo; -// } - -// public Task BeforeSave(ITriggerContext context, CancellationToken cancellationToken) -// { -// if (context.ChangeType == ChangeType.Modified || context.ChangeType == ChangeType.Added) -// { -// context.Entity.UpdateTime = DateTime.Now; - -// context.Entity.UpdateUserId = _userInfo.Id; - -// } - -// return Task.CompletedTask; - -// } -// } -//} \ No newline at end of file diff --git a/IRaCIS.Core.Infra.EFCore/Context/Triggers/SoftDeleteTrigger.cs b/IRaCIS.Core.Infra.EFCore/Context/Triggers/SoftDeleteTrigger.cs deleted file mode 100644 index 27c036748..000000000 --- a/IRaCIS.Core.Infra.EFCore/Context/Triggers/SoftDeleteTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ -//using System; -//using System.Threading; -//using System.Threading.Tasks; -//using EntityFrameworkCore.Triggered; -//using IRaCIS.Core.Domain.Models; -//using IRaCIS.Core.Domain.Share; - -//namespace IRaCIS.Core.Application.Triggers -//{ - -// public class SoftDeleteTrigger : IBeforeSaveTrigger -// { -// private readonly IUserInfo _userInfo; - -// public SoftDeleteTrigger(IUserInfo userInfo) -// { -// _userInfo = userInfo; -// } - -// //Generator Detached 状态才会进去 误用 -// //modelBuilder.Entity(entityType.ClrType).Property(nameof(ISoftDelete.DeletedTime)).HasValueGenerator().ValueGeneratedOnAddOrUpdate(); -// public Task BeforeSave(ITriggerContext context, CancellationToken cancellationToken) -// { -// if (context.ChangeType == ChangeType.Modified) -// { -// if (context.Entity.IsDeleted) -// { -// context.Entity.DeleteUserId = _userInfo.Id; -// context.Entity.DeletedTime = DateTime.Now; -// } -// else -// { -// context.Entity.DeletedTime = null; -// } -// } - -// return Task.CompletedTask; - -// } -// } -//} \ No newline at end of file diff --git a/IRaCIS.Core.Infra.EFCore/Context/ValueGenerator/MySequentialGuidValueGenerator.cs b/IRaCIS.Core.Infra.EFCore/Context/ValueGenerator/MySequentialGuidValueGenerator.cs new file mode 100644 index 000000000..782a28300 --- /dev/null +++ b/IRaCIS.Core.Infra.EFCore/Context/ValueGenerator/MySequentialGuidValueGenerator.cs @@ -0,0 +1,18 @@ +using System; +using IRaCIS.Core.Domain.Models; +using MassTransit; +using Microsoft.EntityFrameworkCore.ChangeTracking; +using Microsoft.EntityFrameworkCore.ValueGeneration; + +namespace IRaCIS.Core.Infra.EFCore +{ + public class MySequentialGuidValueGenerator : ValueGenerator + { + public override Guid Next(EntityEntry entry) + { + return NewId.NextGuid(); + } + public override bool GeneratesTemporaryValues => false; + } + +} \ No newline at end of file diff --git a/IRaCIS.Core.Infra.EFCore/Context/ValueGenerator/UploadTotalMillisecondsIntervalGenerator.cs b/IRaCIS.Core.Infra.EFCore/Context/ValueGenerator/UploadTotalMillisecondsIntervalGenerator.cs deleted file mode 100644 index a50964821..000000000 --- a/IRaCIS.Core.Infra.EFCore/Context/ValueGenerator/UploadTotalMillisecondsIntervalGenerator.cs +++ /dev/null @@ -1,34 +0,0 @@ -//using System; -//using IRaCIS.Core.Domain.Models; -//using Microsoft.EntityFrameworkCore.ChangeTracking; -//using Microsoft.EntityFrameworkCore.ValueGeneration; - -//namespace IRaCIS.Core.Infra.EFCore.ValueGenerator -//{ -// /// -// /// 上传监控 时间间隔存储 需要按照这个字段进行排序 -// /// -// public class UploadTotalMillisecondsInterval : ValueGenerator -// { - -// //code first must migration dbfirst must config in db and also need config in code -// //modelBuilder.Entity().Property(e => e.TotalMillisecondsInterval).HasComputedColumnSql("datediff(MS,UploadStartTime,UploadFinishedTime)"); - -// //modelBuilder.Entity().Property(e => e.TestInterval).ValueGeneratedOnAddOrUpdate().HasDefaultValueSql("datediff(MS,UploadStartTime,UploadFinishedTime)"); - -// public override int Next(EntityEntry entry) -// { -// if (entry.Entity is StudyMonitor entity) -// { -// return (entity.UploadFinishedTime - entity.UploadStartTime)?.Milliseconds; -// } -// else -// { -// throw new ArgumentException("ValueGenerator用在了不适合的实体"); - -// } -// } -// public override bool GeneratesTemporaryValues => false; -// } - -//} \ No newline at end of file diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs new file mode 100644 index 000000000..1326060fc --- /dev/null +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs @@ -0,0 +1,24 @@ +using IRaCIS.Core.Domain.Models; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Infra.EFCore.EntityConfigration +{ + public class DictionaryConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + + + builder.HasMany(t => t.ChildList).WithOne(t => t.Parent); + + } + } +} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs index a0d0f1744..a9011126a 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.Reflection.Emit; namespace IRaCIS.Core.Infra.EFCore.EntityConfigration @@ -28,16 +29,5 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration - public class DictionaryConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - //builder.Property(e => e.MappedValue).Metadata.SetBeforeSaveBehavior(PropertySaveBehavior.Ignore); - // builder.Property(e => e.MappedValue).Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); - - } - } + } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/NoneDicomStudyConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/NoneDicomStudyConfigration.cs index 506e3a7cf..a2a0f9ce9 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/NoneDicomStudyConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/NoneDicomStudyConfigration.cs @@ -1,6 +1,7 @@ using IRaCIS.Core.Domain.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.Reflection.Emit; namespace IRaCIS.Core.Infra.EFCore.EntityConfigration @@ -12,7 +13,8 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration public void Configure(EntityTypeBuilder builder) { - + builder.HasMany(t => t.NoneDicomFileList).WithOne(s => s.NoneDicomStudy).HasForeignKey(t => t.NoneDicomStudyId); + builder.HasMany(t => t.TaskNoneDicomFileList).WithOne(s => s.OriginNoneDicomStudy).HasForeignKey(t => t.OriginNoneDicomStudyId); } } } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingPeriodSiteConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingPeriodSiteConfigration.cs deleted file mode 100644 index 547a1e0c8..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingPeriodSiteConfigration.cs +++ /dev/null @@ -1,18 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class ReadingPeriodSiteConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - - } - } -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingQuestionTrialConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingQuestionTrialConfigration.cs new file mode 100644 index 000000000..85d875028 --- /dev/null +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingQuestionTrialConfigration.cs @@ -0,0 +1,25 @@ +using IRaCIS.Core.Domain.Models; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Infra.EFCore.EntityConfigration +{ + + public class ReadingQuestionTrialConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + + + builder.HasQueryFilter(p => p.IsAdditional == false); + + } + } +} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyMonitorConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyMonitorConfigration.cs deleted file mode 100644 index d687884b5..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyMonitorConfigration.cs +++ /dev/null @@ -1,19 +0,0 @@ -using IRaCIS.Core.Domain.Models; -//using IRaCIS.Core.Infra.EFCore.ValueGenerator; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class StudyMonitorConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - - } - } -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialDocument.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialDocumentConfigration.cs similarity index 100% rename from IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialDocument.cs rename to IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialDocumentConfigration.cs diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs index 9601c8f56..ffc7a2ba8 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs @@ -20,4 +20,15 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration } } + + public class UserConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + builder.HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId).IsRequired(false); + + } + } } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs new file mode 100644 index 000000000..6cf3de657 --- /dev/null +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs @@ -0,0 +1,57 @@ +using IRaCIS.Core.Domain.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.Reflection.Emit; + + +namespace IRaCIS.Core.Infra.EFCore.EntityConfigration +{ + public class VisitTaskConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + + builder.HasMany(t => t.JudgeVisitList).WithOne(t => t.JudgeVisitTask); + + + builder.HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId); + + builder.HasOne(t => t.Subject).WithMany(s => s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId); + + builder.HasMany(t => t.TaskInfluenceList).WithOne(s => s.OriginalTask).HasForeignKey(t => t.OriginalTaskId); + + + builder.HasMany(t => t.GlobalVisitResultList).WithOne(s => s.GlobalVisitTask).HasForeignKey(t => t.GlobalTaskId); + + + + builder.HasQueryFilter(b => b.Subject.IsDeleted == false); + + + //modelBuilder.Entity().HasMany(t => t.DoctorTrialVisitTaskList).WithOne(t => t.DoctorTaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId }); + + //modelBuilder.Entity().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.TaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId }); + + //会导致级联删除 + //modelBuilder.Entity().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t => t.SujectArm).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum }) + // ./*IsRequired(false)*/OnDelete(DeleteBehavior.NoAction); + + // builder.HasOne(t => t.SujectArm).WithMany(s => s.SubjectArmVisitTaskList).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum }); + + + } + } + + public class SubjectUserConfigration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser); + } + } + + + +}