fix log
This commit is contained in:
@@ -58,6 +58,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
{
|
||||
if (_httpContextAccessor.HttpContext!.Request.Headers.TryGetValue("X-Requested-DeviceIp", out var ip))
|
||||
{
|
||||
Logger.LogInformation("设备:{deviceNo} Ip:{ip}", request.DeviceUniqueNo, ip);
|
||||
var device = await DbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == request.DeviceUniqueNo).SingleAsync();
|
||||
device.ConnectionInfo = new
|
||||
{
|
||||
@@ -137,7 +138,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
{
|
||||
//尝试匹配userId
|
||||
var s = long.TryParse(request.UserUniqueNo, out var userId);
|
||||
GainfoEntity gainfo = null;
|
||||
GainfoEntity gainfo;
|
||||
|
||||
if (request.Source == BalanceRecordSourceEnumType.QrCode)
|
||||
{
|
||||
@@ -153,6 +154,10 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
var code = eMealVoucherQrCode.OriginData.Split(':')[2];
|
||||
gainfo = await DbContext.Queryable<GainfoEntity>().Where(x => x.Code == code).SingleAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UserFriendlyException($"无法识别{request.UserUniqueNo}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Dlhis.Middle.Entities;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Mapster;
|
||||
|
||||
namespace Dlhis.Middle.Services.Implements;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Dlhis.Middle.Services.Implements;
|
||||
|
||||
public class HealthCheckService : IHealthCheckService
|
||||
{
|
||||
private bool _isOffline = false;
|
||||
private bool _isOffline;
|
||||
private readonly string _hostName;
|
||||
private readonly ILogger<HealthCheckService> _logger;
|
||||
private int _successRetry;
|
||||
@@ -23,11 +23,13 @@ public class HealthCheckService : IHealthCheckService
|
||||
|
||||
public async Task DoHealthCheckAsync()
|
||||
{
|
||||
var cancellationTokenSource = new CancellationTokenSource(1000);
|
||||
var tcpClient = new TcpClient();
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("tcp connecting {host} {port}", _hostName, 443);
|
||||
await tcpClient.ConnectAsync(_hostName, 443);
|
||||
await tcpClient.ConnectAsync(_hostName, 443, cancellationTokenSource.Token);
|
||||
_retry++;
|
||||
_logger.LogDebug("retry {retry}", _retry);
|
||||
if (tcpClient.Connected)
|
||||
@@ -44,7 +46,7 @@ public class HealthCheckService : IHealthCheckService
|
||||
else
|
||||
{
|
||||
_logger.LogDebug("wait next check in {waitTime}", _successRetry * 1000);
|
||||
await Task.Delay(_successRetry * 1000);
|
||||
await Task.Delay(_successRetry * 1000, cancellationTokenSource.Token);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -52,14 +54,14 @@ public class HealthCheckService : IHealthCheckService
|
||||
_successRetry = 0;
|
||||
_isOffline = true;
|
||||
_logger.LogDebug("current is {status}", "unavailable");
|
||||
await Task.Delay(500);
|
||||
await Task.Delay(500, cancellationTokenSource.Token);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("fail cause :{reason}", ex.Message);
|
||||
_isOffline = true;
|
||||
await Task.Delay(5000);
|
||||
await Task.Delay(5000, cancellationTokenSource.Token);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user