diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs index 2cc7b32b6..cbdc96b79 100644 --- a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs +++ b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs @@ -366,17 +366,26 @@ namespace IRaCIS.Core.Domain.Share { public static string GetClientIP(this HttpContext context) { - var ip = context.Request.Headers["Cdn-Src-Ip"].FirstOrDefault(); - if (!string.IsNullOrEmpty(ip)) + //scp 服务创建的记录不能获取请求上下文 + if (context != null) + { + var ip = context.Request.Headers["Cdn-Src-Ip"].FirstOrDefault(); + if (!string.IsNullOrEmpty(ip)) + return IpReplace(ip); + + ip = context.Request.Headers["X-Forwarded-For"].FirstOrDefault(); + if (!string.IsNullOrEmpty(ip)) + return IpReplace(ip); + + ip = context.Connection.RemoteIpAddress.ToString(); + return IpReplace(ip); - - ip = context.Request.Headers["X-Forwarded-For"].FirstOrDefault(); - if (!string.IsNullOrEmpty(ip)) - return IpReplace(ip); - - ip = context.Connection.RemoteIpAddress.ToString(); - - return IpReplace(ip); + } + else + { + return string.Empty; + } + } static string IpReplace(string inip) diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ImageConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ImageConfigration.cs index fb50a7681..dc0a2af18 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ImageConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ImageConfigration.cs @@ -110,7 +110,7 @@ public class SCPInstanceConfigration : IEntityTypeConfiguration { builder.HasKey(e => e.SeqId); - builder.HasOne(e => e.SCPStudy).WithMany().HasForeignKey(t => t.StudyId).HasPrincipalKey(st => st.Id); + builder.HasOne(e => e.SCPStudy).WithMany(t=>t.InstanceList).HasForeignKey(t => t.StudyId).HasPrincipalKey(st => st.Id); } }