修改日志区域
continuous-integration/drone/push Build is passing Details

Uat_Study^2
hang 2024-05-30 15:53:16 +08:00
parent 1b1ac3ee65
commit 4b7fff9869
7 changed files with 68 additions and 6 deletions

View File

@ -50,7 +50,8 @@ namespace IRaCIS.Core.API
//triggerOptions.AddTrigger<AddlTrialUserTrigger>();
triggerOptions.AddTrigger<VisitTaskIsFrontTaskNeedSignButNotSignTrigger>();
triggerOptions.AddTrigger<VisitTaskIAfterSignTrigger>();
triggerOptions.AddTrigger<UserLogTrigger>();
});

View File

@ -77,6 +77,7 @@
<PackageReference Include="fo-dicom.Codecs" Version="5.10.8" />
<PackageReference Include="FreeSpire.Doc" Version="11.6.0" />
<PackageReference Include="Hangfire.Core" Version="1.8.5" />
<PackageReference Include="IP2Region.Net" Version="2.0.2" />
<PackageReference Include="Magicodes.IE.Core" Version="2.7.4.5" />
<PackageReference Include="Magicodes.IE.Csv" Version="2.7.4.5">
<TreatAsUsed>true</TreatAsUsed>

View File

@ -978,7 +978,7 @@
<param name="currentInspectionId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.SetDataInspectionDateType(System.Collections.Generic.List{System.String},System.String)">
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.SetDataInspectionDateType(System.Collections.Generic.List{System.String},System.String,System.String)">
<summary>
格式化日期和时间
</summary>
@ -986,7 +986,7 @@
<param name="jsonStr"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.GetInspectionEnumValue(System.Collections.Generic.List{System.String},System.String)">
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.GetInspectionEnumValue(System.Collections.Generic.List{System.String},System.String,System.String)">
<summary>
获取外键表数据
</summary>
@ -994,7 +994,7 @@
<param name="jsonStr"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.SetEnum(System.Guid,System.Collections.Generic.List{System.String},System.String)">
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.SetEnum(System.Guid,System.Collections.Generic.List{System.String},System.String,System.String)">
<summary>
获取枚举
</summary>

View File

@ -47,10 +47,17 @@ namespace IRaCIS.Core.Application.ViewModel
public string? LoginFaildName { get; set; }
public string? LoginUserName { get; set; }
public DateTime? BeginDate { get; set; }
public DateTime? EndDate { get; set; }
public UserTypeEnum? LoginUserTypeEnum { get; set; }
public Guid? UserTypeId { get; set; }
public Guid? UserId { get; set; }
}

View File

@ -661,7 +661,9 @@ namespace IRaCIS.Application.Services
failCount++;
_cache.Set(cacheKey, failCount, TimeSpan.FromMinutes(lockoutMinutes));
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = Guid.Empty, OptUserId=Guid.Empty, LoginFaildName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError }, true);
var errorPwdUserId = await _userRepository.Where(u => u.UserName == userName).Select(t => t.Id).FirstOrDefaultAsync();
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = errorPwdUserId, OptUserId=Guid.Empty, LoginFaildName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError }, true);
return ResponseOutput.NotOk(_localizer["User_CheckNameOrPw"], new LoginReturnDTO());
@ -694,15 +696,22 @@ namespace IRaCIS.Application.Services
[HttpPost]
public async Task<PageOutput<UserLogView>> GetUserLogList(UserLogQuery inQuery)
{
DateTime? trialCreateTime = inQuery.TrialId != null ? _repository.Where<Trial>(t => t.Id == inQuery.TrialId).Select(t => t.CreateTime).FirstOrDefault() : null;
var userLogQueryable =
_userLogRepository
.WhereIf(inQuery.TrialId != null, t => t.LoginUser.UserTrials.Any(c => c.TrialId == inQuery.TrialId && c.UserId == t.LoginUserId))
.WhereIf(inQuery.TrialId != null, t => t.LoginUser.UserTrials.Any(c => c.TrialId == inQuery.TrialId && (c.UserId == t.LoginUserId || c.UserId == t.OptUserId)))
.WhereIf(trialCreateTime != null, t => t.CreateTime >= trialCreateTime)
.WhereIf(inQuery.OptType != null, t => t.OptType == inQuery.OptType)
.WhereIf(inQuery.UserId != null, t => t.LoginUserId == inQuery.UserId)
.WhereIf(inQuery.BeginDate != null, t => t.CreateTime >= inQuery.BeginDate)
.WhereIf(inQuery.EndDate != null, t => t.CreateTime <= inQuery.EndDate)
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginUserName), t => t.LoginUser.UserName.Contains(inQuery.LoginUserName!))
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginFaildName), t => t.LoginFaildName.Contains(inQuery.LoginFaildName!))
.WhereIf(!string.IsNullOrEmpty(inQuery.IP), t => t.IP.Contains(inQuery.IP!))
.WhereIf(inQuery.LoginUserTypeEnum != null, t => t.LoginUser.UserTypeEnum == inQuery.LoginUserTypeEnum)
.WhereIf(inQuery.UserTypeId != null, t => t.LoginUser.UserTypeId == inQuery.UserTypeId)
.ProjectTo<UserLogView>(_mapper.ConfigurationProvider);
var pageList = await userLogQueryable.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? "Id" : inQuery.SortField, inQuery.Asc);

View File

@ -0,0 +1,42 @@
using EntityFrameworkCore.Triggered;
using IP2Region.Net.Abstractions;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Application.Triggers
{
public class UserLogTrigger : IBeforeSaveTrigger<UserLog>
{
public ISearcher _searcher;
public ILogger<UserLogTrigger> _logger;
public UserLogTrigger(ISearcher searcher,ILogger<UserLogTrigger> logger)
{
_searcher = searcher;
_logger= logger;
}
//国家|区域|省份|城市|ISP 缺省的地域信息默认是0
//0|0|0|内网IP|内网IP
// 中国|0|湖北省|武汉市|电信
public async Task BeforeSave(ITriggerContext<UserLog> context, CancellationToken cancellationToken)
{
var userLog = context.Entity;
if (context.ChangeType == ChangeType.Added)
{
var ipinfo = _searcher.Search(userLog.IP);
userLog.IPRegion = string.Join('|', ipinfo.Split('|').TakeLast(3));
}
}
}
}

View File

@ -47,6 +47,8 @@ namespace IRaCIS.Core.Domain.Models
[JsonIgnore]
public User OptUser { get; set; }
public string IPRegion { get; set; }
}
/// <summary>