Merge branch 'master' of http://192.168.1.2:8033/IRaCIS_Core_Api
commit
c403951050
|
@ -477,7 +477,6 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
return await userQueryable.ToPagedListAsync(param.PageIndex, param.PageSize, param.SortField == string.Empty ? "UserName" : param.SortField, param.Asc);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -192,8 +192,8 @@ namespace IRaCIS.Core.Application
|
|||
|
||||
ToBeCheckedCount = t.SubjectVisitList.Where(u => u.CheckState == CheckStateEnum.ToCheck).Count(),
|
||||
|
||||
ToBeRepliedCount = t.SubjectVisitList.Where(u => u.CheckState == CheckStateEnum.ToCheck &&
|
||||
u.CheckChallengeDialogList.Any(t => t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator)).Count(),
|
||||
ToBeRepliedCount = t.SubjectVisitList.Where(u => u.CheckState == CheckStateEnum.CVIng &&
|
||||
u.CheckChallengeDialogList.OrderByDescending(t=>t.CreateTime).First().UserTypeEnum== UserTypeEnum.ClinicalResearchCoordinator).Count(),
|
||||
});
|
||||
|
||||
|
||||
|
@ -204,8 +204,8 @@ namespace IRaCIS.Core.Application
|
|||
.Where(u => u.CheckState == CheckStateEnum.ToCheck).CountAsync();
|
||||
|
||||
var totalToBeRepliedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id))
|
||||
.Where(u => u.CheckState == CheckStateEnum.ToCheck &&
|
||||
u.CheckChallengeDialogList.Any(t => t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator)).CountAsync();
|
||||
.Where(u => u.CheckState == CheckStateEnum.CVIng &&
|
||||
u.CheckChallengeDialogList.OrderByDescending(t => t.CreateTime).First().UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).CountAsync();
|
||||
|
||||
return ResponseOutput.Ok(result, new { TotalToBeCheckedCount = totalToBeCheckedCount, TotalToBeRepliedCount = totalToBeRepliedCount });
|
||||
|
||||
|
@ -892,7 +892,7 @@ namespace IRaCIS.Core.Application
|
|||
[FromServices] IRepository<TaskMedicalReview> _taskMedicalReviewRepository)
|
||||
{
|
||||
|
||||
var isPM = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager;
|
||||
var isPM = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager|| _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM;
|
||||
var isCRC = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator;
|
||||
var isIQC = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.IQC;
|
||||
var isMIM = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.MIM;
|
||||
|
@ -917,9 +917,13 @@ namespace IRaCIS.Core.Application
|
|||
TrialStatusStr=t.TrialStatusStr,
|
||||
|
||||
ExpetiedTaskCount= isPM ? t.VisitTaskList.Where(t=>t.IsUrgent).Count():0,
|
||||
|
||||
ReReadingApprovalCount= isPM? t.VisitTaskReReadingList.Where(t=>t.OriginalReReadingTask.ReReadingApplyState==ReReadingApplyState.DocotorHaveApplyed).Count():0,
|
||||
|
||||
PendingReconciliationCount=isPM? t.SubjectVisitList.Where(t=>t.CheckState==CheckStateEnum.ToCheck).Count():0,
|
||||
|
||||
PendingResponseCount=isPM? t.SubjectVisitList.Where(u => u.CheckState == CheckStateEnum.CVIng &&
|
||||
u.CheckChallengeDialogList.OrderByDescending(t => t.CreateTime).First().UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).Count() : 0
|
||||
|
||||
|
||||
|
||||
|
@ -934,6 +938,9 @@ namespace IRaCIS.Core.Application
|
|||
return ResponseOutput.Ok(result, new { TotalToBeReUploadCount = 0 });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,28 +17,32 @@ using Microsoft.EntityFrameworkCore.ValueGeneration;
|
|||
using UserTypeGroup = IRaCIS.Core.Domain.Models.UserTypeGroup;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using IRaCIS.Core.Infra.EFCore.Common.Dto;
|
||||
using Microsoft.Identity.Client;
|
||||
using EntityFramework.Exceptions.Common;
|
||||
using System.Data;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore
|
||||
{
|
||||
public class IRaCISDBContext : DbContext
|
||||
{
|
||||
public readonly IUserInfo _userInfo;
|
||||
//private readonly IAuditingData _auditingData;
|
||||
|
||||
public readonly ILogger<IRaCISDBContext> _logger;
|
||||
// 在控制台
|
||||
//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
|
||||
public IRaCISDBContext(DbContextOptions<IRaCISDBContext> options, IUserInfo userInfo, ILogger<IRaCISDBContext> logger
|
||||
|
||||
|
||||
//IAuditingData auditingData
|
||||
//IAuditingData auditingData
|
||||
) : base(options)
|
||||
{
|
||||
_logger= logger;
|
||||
_userInfo = userInfo;
|
||||
//this._auditingData = auditingData;
|
||||
//_configuration = configuration;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -496,12 +500,69 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
return base.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||
{
|
||||
// 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因
|
||||
SetCommonEntityAuditInfo();
|
||||
await AddAudit();
|
||||
return await base.SaveChangesAsync(cancellationToken);
|
||||
|
||||
try
|
||||
{
|
||||
return await base.SaveChangesAsync(cancellationToken);
|
||||
|
||||
}
|
||||
catch (UniqueConstraintException ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
|
||||
throw new DBSaveFailedException("该唯一键已经存在于数据库中。");
|
||||
|
||||
}
|
||||
catch (TimeoutException ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
|
||||
throw new DBSaveFailedException("数据库操作已经超时,请稍后重试。");
|
||||
|
||||
}
|
||||
catch (CannotInsertNullException ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
|
||||
throw new DBSaveFailedException("无法在非空列上插入空值。");
|
||||
}
|
||||
catch (MaxLengthExceededException ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
|
||||
throw new DBSaveFailedException("字符串超过了数据库列的最大长度。");
|
||||
}
|
||||
catch (NumericOverflowException ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
|
||||
throw new DBSaveFailedException("数值超过了数据类型的范围。");
|
||||
}
|
||||
catch (SyntaxErrorException ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
|
||||
throw new DBSaveFailedException("SQL 查询中存在语法错误。");
|
||||
}
|
||||
catch (ReferenceConstraintException ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
throw new DBSaveFailedException("无法进行当前操作,当前数据不符合外键约束。");
|
||||
}
|
||||
catch (DbUpdateConcurrencyException ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
|
||||
throw new DBSaveFailedException("SQL 事务失败,请检查环境。");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -670,7 +731,6 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public virtual DbSet<TaskAllocationRule> TaskAllocationRule { get; set; }
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Infrastructure
|
||||
|
||||
{
|
||||
|
||||
|
||||
public class DBSaveFailedException : Exception
|
||||
{
|
||||
|
||||
public DBSaveFailedException()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DBSaveFailedException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue