升级efcore 清理之前的写法
parent
423f2fcb7c
commit
a27dcd6399
|
@ -21,7 +21,7 @@ namespace IRaCIS.Core.API
|
|||
.MinimumLevel.Override("Hangfire", LogEventLevel.Warning)
|
||||
.MinimumLevel.Override("System.Net.Http.HttpClient.HttpReports", LogEventLevel.Warning)
|
||||
.Enrich.WithClientIp()
|
||||
.Enrich.WithClientAgent()
|
||||
|
||||
.Enrich.FromLogContext()
|
||||
|
||||
//控制台 方便调试 问题 我们显示记录日志 时 获取上下文的ip 和用户名 用户类型
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace IRaCIS.Core.API
|
||||
{
|
||||
public class JsonPatchDocumentFilter : IDocumentFilter
|
||||
{
|
||||
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
|
||||
{
|
||||
var schemas = swaggerDoc.Components.Schemas.ToList();
|
||||
foreach (var item in schemas)
|
||||
{
|
||||
if (item.Key.StartsWith("Operation") || item.Key.StartsWith("JsonPatchDocument"))
|
||||
swaggerDoc.Components.Schemas.Remove(item.Key);
|
||||
}
|
||||
|
||||
swaggerDoc.Components.Schemas.Add("Operation", new OpenApiSchema
|
||||
{
|
||||
Type = "object",
|
||||
Properties = new Dictionary<string, OpenApiSchema>
|
||||
{
|
||||
{ "op", new OpenApiSchema { Type = "string" } },
|
||||
{"value", new OpenApiSchema{ Type = "object", Nullable = true } },
|
||||
{ "path", new OpenApiSchema { Type = "string" } }
|
||||
}
|
||||
});
|
||||
|
||||
swaggerDoc.Components.Schemas.Add("JsonPatchDocument", new OpenApiSchema
|
||||
{
|
||||
Type = "array",
|
||||
Items = new OpenApiSchema
|
||||
{
|
||||
Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "Operation" }
|
||||
},
|
||||
Description = "Array of operations to perform"
|
||||
});
|
||||
|
||||
foreach (var path in swaggerDoc.Paths.SelectMany(p => p.Value.Operations)
|
||||
.Where(p => p.Key == Microsoft.OpenApi.Models.OperationType.Patch))
|
||||
{
|
||||
foreach (var item in path.Value.RequestBody.Content.Where(c => c.Key != "application/json-patch+json"))
|
||||
path.Value.RequestBody.Content.Remove(item.Key);
|
||||
|
||||
var response = path.Value.RequestBody.Content.SingleOrDefault(c => c.Key == "application/json-patch+json");
|
||||
|
||||
response.Value.Schema = new OpenApiSchema
|
||||
{
|
||||
Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "JsonPatchDocument" }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -63,7 +63,6 @@ namespace IRaCIS.Core.API
|
|||
// 在header中添加token,传递到后台
|
||||
options.OperationFilter<SecurityRequirementsOperationFilter>();
|
||||
|
||||
options.DocumentFilter<JsonPatchDocumentFilter>();
|
||||
|
||||
// 添加登录按钮
|
||||
options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme()
|
||||
|
|
|
@ -249,7 +249,7 @@ namespace IRaCIS.Application.Services
|
|||
public async Task<Dictionary<string, List<BasicDicSelectCopy>>> GetBasicDataSelect(string[] searchArray)
|
||||
{
|
||||
|
||||
var searchList = await _dicRepository.Where(t => searchArray.Contains(t.Parent.Code) && t.ParentId != null && t.IsEnable).ProjectTo<BasicDicSelectCopy>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
var searchList = await _dicRepository.Where(t => searchArray.Contains(t.Parent.Code) && t.ParentId != null && t.IsEnable).ProjectTo<BasicDicSelectCopy>(_mapper.ConfigurationProvider,new { isEn_Us = _userInfo.IsEn_Us}).ToListAsync();
|
||||
|
||||
return searchList.GroupBy(t => t.ParentCode).ToDictionary(g => g.Key, g => g.OrderBy(t => t.ShowOrder).ToList());
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
CreateMap<Dictionary, BasicDicSelectCopy>()
|
||||
.ForMember(o => o.ParentChildCodeEnum, t => t.MapFrom(u => u.Parent.ChildCodeEnum))
|
||||
.ForMember(o => o.Value, t => t.MapFrom(u => u.MappedValue))
|
||||
.ForMember(o => o.Value, t => t.MapFrom(u => isEn_Us? u.Value : u.ValueCN ))
|
||||
.ForMember(o => o.ParentCode, t => t.MapFrom(u => u.Parent.Code));
|
||||
|
||||
CreateMap<Dictionary, BasicDicSelect>()
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
SignViewMinimumMinutes = sysDoc.SignViewMinimumMinutes,
|
||||
Name = sysDoc.Name,
|
||||
Path = sysDoc.Path,
|
||||
FileType = sysDoc.FileType.MappedValue,
|
||||
FileType = _userInfo.IsEn_Us? sysDoc.FileType.Value: sysDoc.FileType.ValueCN,
|
||||
UpdateTime = sysDoc.UpdateTime,
|
||||
|
||||
FullFilePath = sysDoc.Path ,
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
var trialDocumentQueryable = _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == queryTrialDocument.TrialId)
|
||||
.WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Name), t => t.Name.Contains(queryTrialDocument.Name))
|
||||
.WhereIf(queryTrialDocument.FileTypeId != null, t => t.FileTypeId == queryTrialDocument.FileTypeId)
|
||||
.ProjectTo<TrialDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken });
|
||||
.ProjectTo<TrialDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, isEn_Us=_userInfo.IsEn_Us });
|
||||
|
||||
return await trialDocumentQueryable.ToPagedListAsync(queryTrialDocument.PageIndex, queryTrialDocument.PageSize, queryTrialDocument.SortField, queryTrialDocument.Asc);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
Name = needConfirmedUserType.SystemDocument.Name,
|
||||
Path = needConfirmedUserType.SystemDocument.Path,
|
||||
FileTypeId = needConfirmedUserType.SystemDocument.FileTypeId,
|
||||
FileType = needConfirmedUserType.SystemDocument.FileType.MappedValue,
|
||||
FileType = _userInfo.IsEn_Us? needConfirmedUserType.SystemDocument.FileType.Value: needConfirmedUserType.SystemDocument.FileType.ValueCN,
|
||||
UpdateTime = needConfirmedUserType.SystemDocument.UpdateTime,
|
||||
|
||||
FullFilePath = needConfirmedUserType.SystemDocument.Path ,
|
||||
|
@ -189,7 +189,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
Name = trialDoc.Name,
|
||||
Path = trialDoc.Path,
|
||||
FileTypeId = trialDoc.FileTypeId,
|
||||
FileType = trialDoc.FileType.MappedValue,
|
||||
FileType = _userInfo.IsEn_Us ? trialDoc.FileType.Value: trialDoc.FileType.ValueCN,
|
||||
UpdateTime = trialDoc.UpdateTime,
|
||||
SignViewMinimumMinutes = trialDoc.SignViewMinimumMinutes,
|
||||
|
||||
|
@ -311,7 +311,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
Name = trialDocumentNeedConfirmedUserType.TrialDocument.Name,
|
||||
Path = trialDocumentNeedConfirmedUserType.TrialDocument.Path,
|
||||
FileTypeId = trialDocumentNeedConfirmedUserType.TrialDocument.FileTypeId,
|
||||
FileType = trialDocumentNeedConfirmedUserType.TrialDocument.FileType.MappedValue,
|
||||
FileType = _userInfo.IsEn_Us ? trialDocumentNeedConfirmedUserType.TrialDocument.FileType.Value : trialDocumentNeedConfirmedUserType.TrialDocument.FileType.ValueCN,
|
||||
UpdateTime = trialDocumentNeedConfirmedUserType.TrialDocument.UpdateTime,
|
||||
|
||||
|
||||
|
@ -345,7 +345,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
SignViewMinimumMinutes = needConfirmEdUserType.SystemDocument.SignViewMinimumMinutes,
|
||||
Name = needConfirmEdUserType.SystemDocument.Name,
|
||||
Path = needConfirmEdUserType.SystemDocument.Path,
|
||||
FileType = needConfirmEdUserType.SystemDocument.FileType.MappedValue,
|
||||
FileType = _userInfo.IsEn_Us ? needConfirmEdUserType.SystemDocument.FileType.Value : needConfirmEdUserType.SystemDocument.FileType.ValueCN,
|
||||
FileTypeId = needConfirmEdUserType.SystemDocument.FileTypeId,
|
||||
UpdateTime = needConfirmEdUserType.SystemDocument.UpdateTime,
|
||||
|
||||
|
|
|
@ -14,12 +14,13 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
var userId = Guid.Empty;
|
||||
var token = string.Empty;
|
||||
var isEn_Us = false;
|
||||
CreateMap<SystemDocument, SystemDocumentView>()
|
||||
.ForMember(d => d.FileType, u => u.MapFrom(s => s.FileType.Value))
|
||||
.ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path));
|
||||
|
||||
CreateMap<TrialDocument, TrialDocumentView>()
|
||||
.ForMember(d => d.FileType, u => u.MapFrom(s => s.FileType.MappedValue))
|
||||
.ForMember(d => d.FileType, u => u.MapFrom(s => isEn_Us ? s.FileType.Value : s.FileType.ValueCN ))
|
||||
.ForMember(d => d.IsSomeUserSigned, u => u.MapFrom(s => s.TrialDocConfirmedUserList.Any(t=>t.ConfirmTime!=null)))
|
||||
.ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path ));
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace IRaCIS.Application.Services
|
|||
.WhereIf(multiCriteriaSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.Criterion) == multiCriteriaSelectCount)
|
||||
.WhereIf(multiReviewTypeSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.ReviewType) == multiReviewTypeSelectCount)
|
||||
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id && t.IsDeleted == false) && t.IsDeleted == false)
|
||||
.ProjectTo<TrialDetailDTO>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.Id });
|
||||
.ProjectTo<TrialDetailDTO>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.Id , isEn_Us= _userInfo.IsEn_Us });
|
||||
|
||||
return await query.ToPagedListAsync(searchParam.PageIndex, searchParam.PageSize, string.IsNullOrWhiteSpace(searchParam.SortField) ? "CreateTime" : searchParam.SortField, searchParam.Asc);
|
||||
|
||||
|
@ -118,7 +118,7 @@ namespace IRaCIS.Application.Services
|
|||
[HttpGet("{projectId:guid}")]
|
||||
public async Task<TrialDetailDTO> GetTrialInfoAndLockState(Guid projectId)
|
||||
{
|
||||
return (await _trialRepository.Where(o => o.Id == projectId).IgnoreQueryFilters().ProjectTo<TrialDetailDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
return (await _trialRepository.Where(o => o.Id == projectId).IgnoreQueryFilters().ProjectTo<TrialDetailDTO>(_mapper.ConfigurationProvider, new {isEn_Us = _userInfo.IsEn_Us }).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -65,16 +65,17 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
var userId = Guid.Empty;
|
||||
var userTypeEnumInt = 0;
|
||||
var isEn_Us = false;
|
||||
CreateMap<Trial, TrialDetailDTO>()
|
||||
.ForMember(x=>x.CriterionList,y=>y.MapFrom(z=>z.ReadingQuestionCriterionTrialList.Where(n=>n.IsConfirm).Select(m=>m.CriterionName)))
|
||||
.ForMember(d => d.DictionaryList, u => u.MapFrom(s => s.TrialDicList.Select(t => t.Dictionary).OrderBy(t => t.ShowOrder)))
|
||||
//.ForMember(d => d.Code, u => u.MapFrom(s => s.TrialCode))
|
||||
.ForMember(d => d.Sponsor, u => u.MapFrom(s => s.Sponsor.SponsorName))
|
||||
.ForMember(d => d.Phase, u => u.MapFrom(s => s.Phase.MappedValue))
|
||||
.ForMember(d => d.Phase, u => u.MapFrom(s => isEn_Us? s.Phase.Value: s.Phase.ValueCN))
|
||||
//.ForMember(d => d.DeclarationType, u => u.MapFrom(s => s.DeclarationType.MappedValue))
|
||||
.ForMember(d => d.IndicationType, u => u.MapFrom(s => s.IndicationType.MappedValue))
|
||||
.ForMember(d => d.IndicationType, u => u.MapFrom(s => isEn_Us ? s.IndicationType.Value:s.IndicationType.ValueCN))
|
||||
.ForMember(d => d.CRO, u => u.MapFrom(s => s.CRO.CROName))
|
||||
.ForMember(d => d.ReviewMode, u => u.MapFrom(s => s.ReviewMode.MappedValue))
|
||||
.ForMember(d => d.ReviewMode, u => u.MapFrom(s => isEn_Us ? s.ReviewMode.Value:s.ReviewMode.ValueCN))
|
||||
//.ForMember(d => d.ReviewType, u => u.MapFrom(s => s.ReviewType.Value))
|
||||
|
||||
//.ForMember(d => d.SiteCount, u => u.MapFrom(s => userTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator ? s.TrialSiteUserList.Count(k => k.UserId == userId) : s.TrialSiteList.Count()))
|
||||
|
|
|
@ -56,9 +56,6 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public List<Dictionary> ChildList { get; set; } = new List<Dictionary>();
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public string MappedValue { get; set; }
|
||||
|
||||
|
||||
[Projectable]
|
||||
public string TranslateValue( string value, string valueCN,bool isCN) => isCN?valueCN:value;
|
||||
|
|
|
@ -122,14 +122,15 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
|
||||
modelBuilder.Entity<Dictionary>().HasMany(t => t.ChildList).WithOne(t => t.Parent);
|
||||
if (_userInfo.IsEn_Us)
|
||||
{
|
||||
modelBuilder.Entity<Dictionary>().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
modelBuilder.Entity<Dictionary>().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.ValueCN));
|
||||
}
|
||||
modelBuilder.Entity<SubjectUser>().HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser);
|
||||
//if (_userInfo.IsEn_Us)
|
||||
//{
|
||||
// modelBuilder.Entity<Dictionary>().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.Value));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// modelBuilder.Entity<Dictionary>().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.ValueCN));
|
||||
//}
|
||||
|
||||
|
||||
//遍历实体模型手动配置
|
||||
|
|
|
@ -1,158 +0,0 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace IRaCIS.Core.Infrastructure.Extention
|
||||
{
|
||||
public static class HttpContextExtension
|
||||
{
|
||||
|
||||
public static T GetService<T>(this HttpContext context) where T : class
|
||||
{
|
||||
return context.RequestServices.GetService(typeof(T)) as T;
|
||||
}
|
||||
|
||||
|
||||
public static string GetUserIp(this HttpContext context)
|
||||
{
|
||||
string realIP = null;
|
||||
string forwarded = null;
|
||||
string remoteIpAddress = context.Connection.RemoteIpAddress.ToString();
|
||||
if (context.Request.Headers.ContainsKey("X-Real-IP"))
|
||||
{
|
||||
realIP = context.Request.Headers["X-Real-IP"].ToString();
|
||||
if (realIP != remoteIpAddress)
|
||||
{
|
||||
remoteIpAddress = realIP;
|
||||
}
|
||||
}
|
||||
if (context.Request.Headers.ContainsKey("X-Forwarded-For"))
|
||||
{
|
||||
forwarded = context.Request.Headers["X-Forwarded-For"].ToString();
|
||||
if (forwarded != remoteIpAddress)
|
||||
{
|
||||
remoteIpAddress = forwarded;
|
||||
}
|
||||
}
|
||||
return remoteIpAddress;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取Request值
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="parameter"></param>
|
||||
/// <returns></returns>
|
||||
public static string Request(this HttpContext context, string parameter)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (context == null)
|
||||
return null;
|
||||
if (context.Request.Method == "POST")
|
||||
return context.Request.Form[parameter].ToString();
|
||||
else
|
||||
return context.Request.Query[parameter].ToString();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Console.Write(ex.Message + ex.InnerException);
|
||||
return context.RequestString(parameter);
|
||||
}
|
||||
}
|
||||
|
||||
public static T Request<T>(this HttpContext context, string parameter) where T : class
|
||||
{
|
||||
return context.RequestString(parameter)?.DeserializeObject<T>();
|
||||
}
|
||||
public static string RequestString(this HttpContext context, string parameter)
|
||||
{
|
||||
string requestParam = context.GetRequestParameters();
|
||||
if (string.IsNullOrEmpty(requestParam)) return null;
|
||||
Dictionary<string, object> keyValues = requestParam.DeserializeObject<Dictionary<string, object>>();
|
||||
if (keyValues == null || keyValues.Count == 0) return null;
|
||||
if (keyValues.TryGetValue(parameter, out object value))
|
||||
{
|
||||
if (value == null) return null;
|
||||
if (value.GetType() == typeof(string))
|
||||
{
|
||||
return value?.ToString();
|
||||
}
|
||||
return value.Serialize();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否为ajax请求
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsAjaxRequest(this HttpContext context)
|
||||
{
|
||||
return context.Request("X-Requested-With") == "XMLHttpRequest"
|
||||
|| (context.Request.Headers != null
|
||||
&& context.Request.Headers["X-Requested-With"] == "XMLHttpRequest");
|
||||
}
|
||||
|
||||
public static UserAgent GetAgentType(this HttpContext context)
|
||||
{
|
||||
string agent = context.Request.Headers["User-Agent"].ToString().ToLower();
|
||||
|
||||
if (agent.Contains("ios") || agent.Contains("ipod") || agent.Contains("ipad"))
|
||||
{
|
||||
return UserAgent.IOS;
|
||||
}
|
||||
if (agent.Contains("windows"))
|
||||
{
|
||||
return UserAgent.Windows;
|
||||
}
|
||||
return UserAgent.Android;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取请求的参数
|
||||
/// net core 2.0已增加回读方法 context.Request.EnableRewind();
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static string GetRequestParameters(this HttpContext context)
|
||||
{
|
||||
if (context.Request.Body == null || !context.Request.Body.CanRead || !context.Request.Body.CanSeek)
|
||||
return null;
|
||||
if (context.Request.Body.Length == 0)
|
||||
return null;
|
||||
if (context.Request.Body.Position > 0)
|
||||
context.Request.Body.Position = 0;
|
||||
|
||||
string prarameters = null;
|
||||
var bodyStream = context.Request.Body;
|
||||
|
||||
using (var buffer = new MemoryStream())
|
||||
{
|
||||
bodyStream.CopyToAsync(buffer);
|
||||
buffer.Position = 0L;
|
||||
bodyStream.Position = 0L;
|
||||
using (var reader = new StreamReader(buffer, Encoding.UTF8))
|
||||
{
|
||||
buffer.Seek(0, SeekOrigin.Begin);
|
||||
prarameters = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
return prarameters;
|
||||
}
|
||||
}
|
||||
public enum UserAgent
|
||||
{
|
||||
IOS = 0,
|
||||
Android = 1,
|
||||
Windows = 2,
|
||||
Linux
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace IRaCIS.Core.Infrastructure
|
||||
{
|
||||
public class IPHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否为ip
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsIP(string ip)
|
||||
{
|
||||
return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
|
||||
}
|
||||
|
||||
public static string GetIP(HttpRequest request)
|
||||
{
|
||||
if (request == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string ip = request.Headers["X-Real-IP"].FirstOrDefault();
|
||||
if (string.IsNullOrEmpty(ip))
|
||||
{
|
||||
ip = request.Headers["X-Forwarded-For"].FirstOrDefault();
|
||||
}
|
||||
if (string.IsNullOrEmpty(ip))
|
||||
{
|
||||
ip = request.HttpContext?.Connection?.RemoteIpAddress?.ToString();
|
||||
}
|
||||
if (string.IsNullOrEmpty(ip) || !IsIP(ip))
|
||||
{
|
||||
ip = "127.0.0.1";
|
||||
}
|
||||
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,12 +9,12 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CSRedisCore" Version="3.8.669" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.10" />
|
||||
<PackageReference Include="SharpCompress" Version="0.32.2" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.4.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.20" />
|
||||
<PackageReference Include="AutoMapper" Version="12.0.1" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.8.671" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.12" />
|
||||
<PackageReference Include="SharpCompress" Version="0.34.1" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.5" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue