From d852de4a5b4b7908151c24c3e480a90229c271b7 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 20 Dec 2024 12:50:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A8=BD=E6=9F=A5=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs | 29 ++++++++++++------- .../EntityConfigration/ImageConfigration.cs | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) 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); } }