Merge pull request 'main' (#4) from Admin.NET/Admin.NET.Pro:main into main
Reviewed-on: http://101.43.53.74:3000/coolcalf/Admin.NET.Pro/pulls/4
This commit is contained in:
commit
1ca94438a1
@ -38,7 +38,7 @@
|
|||||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.166" />
|
<PackageReference Include="SqlSugarCore" Version="5.1.4.166" />
|
||||||
<PackageReference Include="SSH.NET" Version="2024.1.0" />
|
<PackageReference Include="SSH.NET" Version="2024.1.0" />
|
||||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.3" />
|
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.3" />
|
||||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1051" />
|
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1052" />
|
||||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public class DictAttribute : ValidationAttribute, ITransient
|
|||||||
// 是否忽略空字符串
|
// 是否忽略空字符串
|
||||||
if (AllowEmptyStrings && string.IsNullOrEmpty(valueAsString)) return ValidationResult.Success;
|
if (AllowEmptyStrings && string.IsNullOrEmpty(valueAsString)) return ValidationResult.Success;
|
||||||
|
|
||||||
var sysDictDataServiceProvider = validationContext.GetRequiredService<SysDictDataService>();
|
var sysDictDataServiceProvider = App.GetRequiredService<SysDictDataService>();
|
||||||
var dictDataList = sysDictDataServiceProvider.GetDataList(DictTypeCode).Result;
|
var dictDataList = sysDictDataServiceProvider.GetDataList(DictTypeCode).Result;
|
||||||
|
|
||||||
// 使用HashSet来提高查找效率
|
// 使用HashSet来提高查找效率
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||||
//
|
//
|
||||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
||||||
//
|
//
|
||||||
@ -35,10 +35,7 @@ public sealed class RedisEventSourceStorer : IEventSourceStorer, IDisposable
|
|||||||
|
|
||||||
private RedisStream<string> _queueBroadcast;
|
private RedisStream<string> _queueBroadcast;
|
||||||
|
|
||||||
/// <summary>
|
private ILogger<RedisEventSourceStorer> _logger;
|
||||||
/// 路由键
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _routeKey;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造函数
|
/// 构造函数
|
||||||
@ -48,6 +45,8 @@ public sealed class RedisEventSourceStorer : IEventSourceStorer, IDisposable
|
|||||||
/// <param name="capacity">存储器最多能够处理多少消息,超过该容量进入等待写入</param>
|
/// <param name="capacity">存储器最多能够处理多少消息,超过该容量进入等待写入</param>
|
||||||
public RedisEventSourceStorer(ICacheProvider cacheProvider, string routeKey, int capacity)
|
public RedisEventSourceStorer(ICacheProvider cacheProvider, string routeKey, int capacity)
|
||||||
{
|
{
|
||||||
|
_logger = App.GetRequiredService<ILogger<RedisEventSourceStorer>>();
|
||||||
|
|
||||||
// 配置通道,设置超出默认容量后进入等待
|
// 配置通道,设置超出默认容量后进入等待
|
||||||
var boundedChannelOptions = new BoundedChannelOptions(capacity)
|
var boundedChannelOptions = new BoundedChannelOptions(capacity)
|
||||||
{
|
{
|
||||||
@ -58,7 +57,6 @@ public sealed class RedisEventSourceStorer : IEventSourceStorer, IDisposable
|
|||||||
_channel = Channel.CreateBounded<IEventSource>(boundedChannelOptions);
|
_channel = Channel.CreateBounded<IEventSource>(boundedChannelOptions);
|
||||||
|
|
||||||
//_redis = redis as FullRedis;
|
//_redis = redis as FullRedis;
|
||||||
_routeKey = routeKey;
|
|
||||||
|
|
||||||
// 创建广播消息订阅者,即所有服务器节点都能收到消息(用来发布重启、Reload配置等消息)
|
// 创建广播消息订阅者,即所有服务器节点都能收到消息(用来发布重启、Reload配置等消息)
|
||||||
FullRedis redis = (FullRedis)cacheProvider.Cache;
|
FullRedis redis = (FullRedis)cacheProvider.Cache;
|
||||||
@ -73,23 +71,29 @@ public sealed class RedisEventSourceStorer : IEventSourceStorer, IDisposable
|
|||||||
_eventConsumer = new EventConsumer<ChannelEventSource>(_queueSingle);
|
_eventConsumer = new EventConsumer<ChannelEventSource>(_queueSingle);
|
||||||
|
|
||||||
// 订阅消息写入 Channel
|
// 订阅消息写入 Channel
|
||||||
_eventConsumer.Received += (send, cr) =>
|
_eventConsumer.Received += async (send, cr) =>
|
||||||
|
{
|
||||||
|
// var oriColor = Console.ForegroundColor;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var oriColor = Console.ForegroundColor;
|
|
||||||
ChannelEventSource ces = (ChannelEventSource)cr;
|
ChannelEventSource ces = (ChannelEventSource)cr;
|
||||||
ConsumeChannelEventSource(ces);
|
await ConsumeChannelEventSourceAsync(ces, ces.CancellationToken);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "处理Received中的消息产生错误!");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
_eventConsumer.Start();
|
_eventConsumer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task OnConsumeBroadcast(string source, Message message, CancellationToken token)
|
private async Task OnConsumeBroadcast(string source, Message message, CancellationToken token)
|
||||||
{
|
{
|
||||||
ChannelEventSource ces = JsonConvert.DeserializeObject<ChannelEventSource>(source);
|
ChannelEventSource ces = JsonConvert.DeserializeObject<ChannelEventSource>(source);
|
||||||
ConsumeChannelEventSource(ces);
|
await ConsumeChannelEventSourceAsync(ces, token);
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConsumeChannelEventSource(ChannelEventSource ces)
|
private async Task ConsumeChannelEventSourceAsync(ChannelEventSource ces, CancellationToken cancel = default)
|
||||||
{
|
{
|
||||||
// 打印测试事件
|
// 打印测试事件
|
||||||
if (ces.EventId != null && ces.EventId.IndexOf(":Test") > 0)
|
if (ces.EventId != null && ces.EventId.IndexOf(":Test") > 0)
|
||||||
@ -99,7 +103,7 @@ public sealed class RedisEventSourceStorer : IEventSourceStorer, IDisposable
|
|||||||
Console.WriteLine($"有消息要处理{ces.EventId},{ces.Payload}");
|
Console.WriteLine($"有消息要处理{ces.EventId},{ces.Payload}");
|
||||||
Console.ForegroundColor = oriColor;
|
Console.ForegroundColor = oriColor;
|
||||||
}
|
}
|
||||||
_channel.Writer.WriteAsync(ces);
|
await _channel.Writer.WriteAsync(ces, cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -19,10 +19,10 @@ public class SysWechatPayService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
private readonly WechatTenpayClient _wechatTenpayClient;
|
private readonly WechatTenpayClient _wechatTenpayClient;
|
||||||
|
|
||||||
public SysWechatPayService(SqlSugarRepository<SysWechatPay> sysWechatPayRep
|
public SysWechatPayService(SqlSugarRepository<SysWechatPay> sysWechatPayRep,
|
||||||
, SqlSugarRepository<SysWechatRefund> sysWechatRefundRep
|
SqlSugarRepository<SysWechatRefund> sysWechatRefundRep,
|
||||||
, IOptions<WechatPayOptions> wechatPayOptions
|
IOptions<WechatPayOptions> wechatPayOptions,
|
||||||
, IOptions<PayCallBackOptions> payCallBackOptions)
|
IOptions<PayCallBackOptions> payCallBackOptions)
|
||||||
{
|
{
|
||||||
_sysWechatPayRep = sysWechatPayRep;
|
_sysWechatPayRep = sysWechatPayRep;
|
||||||
this._sysWechatRefundRep = sysWechatRefundRep;
|
this._sysWechatRefundRep = sysWechatRefundRep;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user