😎升级依赖调整文件编码

This commit is contained in:
zuohuaijun 2025-09-18 00:20:32 +08:00
parent a72916e179
commit 78d9af6e5a
4 changed files with 109 additions and 109 deletions

View File

@ -22,7 +22,7 @@
<ItemGroup>
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="4.0.0" />
<PackageReference Include="AlipaySDKNet.Standard" Version="4.9.799" />
<PackageReference Include="AlipaySDKNet.Standard" Version="4.9.808" />
<PackageReference Include="AngleSharp" Version="1.3.0" />
<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" />
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
@ -40,7 +40,7 @@
<PackageReference Include="Magicodes.IE.Pdf" Version="2.7.6" />
<PackageReference Include="Magicodes.IE.Word" Version="2.7.6" />
<PackageReference Include="MailKit" Version="4.13.0" />
<PackageReference Include="MiniExcel" Version="1.41.3" />
<PackageReference Include="MiniExcel" Version="1.41.4" />
<PackageReference Include="MiniWord" Version="0.9.2" />
<PackageReference Include="MQTTnet.Server" Version="5.0.1.1416" />
<PackageReference Include="MySqlBackup.NET.MySqlConnector" Version="2.6.5" />
@ -52,7 +52,7 @@
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.2.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.11.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.13.0" />
<PackageReference Include="SqlSugar.MongoDbCore" Version="5.1.4.262" />
<PackageReference Include="SqlSugar.MongoDbCore" Version="5.1.4.264" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.202" />
<PackageReference Include="SSH.NET" Version="2025.0.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.7" />

View File

@ -1,13 +1,13 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core;
namespace Admin.NET.Core;
using Microsoft.Extensions.Hosting;
using MQTTnet;
using MQTTnet;
using MQTTnet.Protocol;
using MQTTnet.Server;
using System;
@ -19,34 +19,34 @@ using System.Threading.Tasks;
/// MQTT 服务
/// </summary>
public class MqttHostedService(IOptions<MqttOptions> mqttOptions) : IHostedService, ISingleton
{
{
private readonly MqttOptions _mqttOptions = mqttOptions.Value;
public static MqttServer MqttServer { get; set; }
public static readonly List<MqttEventInterceptor> MqttEventInterceptors = []; // MQTT 事件拦截器集合
/// <summary>
/// 注册 MQTT 事件拦截器
/// </summary>
/// <param name="mqttEventInterceptor"></param>
/// <param name="order"></param>
public static void AddMqttEventInterceptor(MqttEventInterceptor mqttEventInterceptor, int order = 0)
{
mqttEventInterceptor.Order = order;
MqttEventInterceptors.Add(mqttEventInterceptor);
MqttEventInterceptors.Sort((a, b) => b.Order - a.Order);
}
public static MqttServer MqttServer { get; set; }
public static readonly List<MqttEventInterceptor> MqttEventInterceptors = []; // MQTT 事件拦截器集合
/// <summary>
/// 注册 MQTT 事件拦截器
/// </summary>
/// <param name="mqttEventInterceptor"></param>
/// <param name="order"></param>
public static void AddMqttEventInterceptor(MqttEventInterceptor mqttEventInterceptor, int order = 0)
{
mqttEventInterceptor.Order = order;
MqttEventInterceptors.Add(mqttEventInterceptor);
MqttEventInterceptors.Sort((a, b) => b.Order - a.Order);
}
public async Task StartAsync(CancellationToken cancellationToken)
{
if (!_mqttOptions.Enabled) return;
// 注册 MQTT 自定义客户端验证事件拦截器
AddMqttEventInterceptor(new DefaultMqttEventInterceptor());
if (!_mqttOptions.Enabled) return;
// 注册 MQTT 自定义客户端验证事件拦截器
AddMqttEventInterceptor(new DefaultMqttEventInterceptor());
var options = new MqttServerOptionsBuilder()
.WithDefaultEndpoint() // 默认地址127.0.0.1
.WithDefaultEndpointPort(_mqttOptions.Port) // 端口号
//.WithDefaultEndpointBoundIPAddress(_mqttOptions.IPAddress) // IP地址
.WithDefaultEndpointPort(_mqttOptions.Port) // 端口号
//.WithDefaultEndpointBoundIPAddress(_mqttOptions.IPAddress) // IP地址
.WithConnectionBacklog(_mqttOptions.ConnectionBacklog) // 最大连接数
.WithPersistentSessions()
.Build();
@ -85,10 +85,10 @@ public class MqttHostedService(IOptions<MqttOptions> mqttOptions) : IHostedServi
/// <returns></returns>
private async Task MqttServer_StoppedAsync(EventArgs arg)
{
Console.WriteLine($"【MQTT】服务已关闭...... {DateTime.Now}");
foreach (var eh in MqttEventInterceptors)
{
await eh.StoppedAsync(arg);
Console.WriteLine($"【MQTT】服务已关闭...... {DateTime.Now}");
foreach (var eh in MqttEventInterceptors)
{
await eh.StoppedAsync(arg);
}
}
@ -99,11 +99,11 @@ public class MqttHostedService(IOptions<MqttOptions> mqttOptions) : IHostedServi
/// <returns></returns>
private async Task MqttServer_ValidatingConnectionAsync(ValidatingConnectionEventArgs arg)
{
foreach (var eh in MqttEventInterceptors)
{
await eh.ValidatingConnectionAsync(arg);
if (arg.ReasonCode != MqttConnectReasonCode.Success)
break;
foreach (var eh in MqttEventInterceptors)
{
await eh.ValidatingConnectionAsync(arg);
if (arg.ReasonCode != MqttConnectReasonCode.Success)
break;
}
}
@ -113,12 +113,12 @@ public class MqttHostedService(IOptions<MqttOptions> mqttOptions) : IHostedServi
/// <param name="arg"></param>
/// <returns></returns>
private async Task MqttServer_ClientConnectedAsync(ClientConnectedEventArgs arg)
{
foreach (var eh in MqttEventInterceptors)
{
await eh.ClientConnectedAsync(arg);
}
{
foreach (var eh in MqttEventInterceptors)
{
await eh.ClientConnectedAsync(arg);
}
Logging($"客户端连接客户端ID=【{arg.ClientId}】已连接:用户名=【{arg.UserName}】地址=【{arg.RemoteEndPoint}】 {DateTime.Now}");
}
@ -130,11 +130,11 @@ public class MqttHostedService(IOptions<MqttOptions> mqttOptions) : IHostedServi
/// <exception cref="NotImplementedException"></exception>
private async Task MqttServer_ClientDisconnectedAsync(ClientDisconnectedEventArgs arg)
{
foreach (var eh in MqttEventInterceptors)
{
await eh.ClientDisconnectedAsync(arg);
}
foreach (var eh in MqttEventInterceptors)
{
await eh.ClientDisconnectedAsync(arg);
}
Logging($"客户端断开客户端ID=【{arg.ClientId}】已断开:用户名=【{arg.UserName}】地址=【{arg.RemoteEndPoint}】 {DateTime.Now}");
}
@ -145,11 +145,11 @@ public class MqttHostedService(IOptions<MqttOptions> mqttOptions) : IHostedServi
/// <returns></returns>
private async Task MqttServer_ClientSubscribedTopicAsync(ClientSubscribedTopicEventArgs arg)
{
foreach (var eh in MqttEventInterceptors)
{
await eh.ClientSubscribedTopicAsync(arg);
}
foreach (var eh in MqttEventInterceptors)
{
await eh.ClientSubscribedTopicAsync(arg);
}
Logging($"订阅主题客户端ID=【{arg.ClientId}】订阅主题=【{arg.TopicFilter}】 {DateTime.Now}");
}
@ -160,11 +160,11 @@ public class MqttHostedService(IOptions<MqttOptions> mqttOptions) : IHostedServi
/// <returns></returns>
private async Task MqttServer_ClientUnsubscribedTopicAsync(ClientUnsubscribedTopicEventArgs arg)
{
foreach (var eh in MqttEventInterceptors)
{
await eh.ClientUnsubscribedTopicAsync(arg);
}
foreach (var eh in MqttEventInterceptors)
{
await eh.ClientUnsubscribedTopicAsync(arg);
}
Logging($"取消订阅客户端ID=【{arg.ClientId}】取消订阅主题=【{arg.TopicFilter}】 {DateTime.Now}");
}
@ -178,11 +178,11 @@ public class MqttHostedService(IOptions<MqttOptions> mqttOptions) : IHostedServi
if (string.Equals(arg.ClientId, _mqttOptions.MqttServerId))
return;
foreach (var eh in MqttEventInterceptors)
{
await eh.InterceptingPublishAsync(arg);
}
foreach (var eh in MqttEventInterceptors)
{
await eh.InterceptingPublishAsync(arg);
}
Logging($"拦截消息客户端ID=【{arg.ClientId}】 Topic主题=【{arg.ApplicationMessage.Topic}】 消息=【{Encoding.UTF8.GetString(arg.ApplicationMessage.Payload)}】 qos等级=【{arg.ApplicationMessage.QualityOfServiceLevel}】 {DateTime.Now}");
}
@ -192,49 +192,49 @@ public class MqttHostedService(IOptions<MqttOptions> mqttOptions) : IHostedServi
/// <param name="arg"></param>
/// <returns></returns>
private async Task MqttServer_ApplicationMessageNotConsumedAsync(ApplicationMessageNotConsumedEventArgs arg)
{
foreach (var eh in MqttEventInterceptors)
{
await eh.ApplicationMessageNotConsumedAsync(arg);
}
Logging($"接收消息发送端ID=【{arg.SenderId}】 Topic主题=【{arg.ApplicationMessage.Topic}】 消息=【{Encoding.UTF8.GetString(arg.ApplicationMessage.Payload)}】 qos等级=【{arg.ApplicationMessage.QualityOfServiceLevel}】 {DateTime.Now}");
}
/// <summary>
/// 发布主题消息
/// </summary>
/// <param name="topic"></param>
/// <param name="message"></param>
public async Task PublicMessageAsync(string topic, string message)
{
var applicationMessage = new MqttApplicationMessageBuilder()
.WithTopic(topic)
.WithPayload(message)
.Build();
await MqttServer.InjectApplicationMessage(new InjectedMqttApplicationMessage(applicationMessage)
{
SenderClientId = _mqttOptions.MqttServerId,
SenderUserName = _mqttOptions.MqttServerId,
});
Logging($"服务器发布主题:{topic}, 内容:{message}");
{
foreach (var eh in MqttEventInterceptors)
{
await eh.ApplicationMessageNotConsumedAsync(arg);
}
Logging($"接收消息发送端ID=【{arg.SenderId}】 Topic主题=【{arg.ApplicationMessage.Topic}】 消息=【{Encoding.UTF8.GetString(arg.ApplicationMessage.Payload)}】 qos等级=【{arg.ApplicationMessage.QualityOfServiceLevel}】 {DateTime.Now}");
}
/// <summary>
/// 发布主题消息
/// </summary>
/// <param name="topic"></param>
/// <param name="message"></param>
public async Task PublicMessageAsync(string topic, string message)
{
var applicationMessage = new MqttApplicationMessageBuilder()
.WithTopic(topic)
.WithPayload(message)
.Build();
await MqttServer.InjectApplicationMessage(new InjectedMqttApplicationMessage(applicationMessage)
{
SenderClientId = _mqttOptions.MqttServerId,
SenderUserName = _mqttOptions.MqttServerId,
});
Logging($"服务器发布主题:{topic}, 内容:{message}");
}
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
/// <summary>
/// 输出日志
/// </summary>
/// <param name="msg"></param>
protected void Logging(string msg)
{
if (!_mqttOptions.Logging) return;
Console.WriteLine(msg);
Log.Information(msg);
}
/// <summary>
/// 输出日志
/// </summary>
/// <param name="msg"></param>
protected void Logging(string msg)
{
if (!_mqttOptions.Logging) return;
Console.WriteLine(msg);
Log.Information(msg);
}
}

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36429.23
# Visual Studio Version 18
VisualStudioVersion = 18.0.11010.61 d18.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Admin.NET.Application", "Admin.NET.Application\Admin.NET.Application.csproj", "{C3F5AEC5-ACEE-4109-94E3-3F981DC18268}"
EndProject

View File

@ -2,7 +2,7 @@
"name": "admin.net.pro",
"type": "module",
"version": "2.4.33",
"lastBuildTime": "2025.09.16",
"lastBuildTime": "2025.09.17",
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
"author": "zuohuaijun",
"license": "MIT",
@ -81,8 +81,8 @@
"vue-router": "^4.5.1",
"vue-signature-pad": "^3.0.2",
"vue3-tree-org": "^4.2.2",
"vxe-pc-ui": "^4.9.30",
"vxe-table": "^4.16.12",
"vxe-pc-ui": "^4.9.31",
"vxe-table": "^4.16.13",
"xe-utils": "^3.7.9",
"xlsx-js-style": "^1.2.0"
},
@ -90,7 +90,7 @@
"@iconify/vue": "^5.0.0",
"@plugin-web-update-notification/vite": "^2.0.2",
"@types/lodash-es": "^4.17.12",
"@types/node": "^22.18.4",
"@types/node": "^22.18.5",
"@types/nprogress": "^0.2.3",
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "^8.44.0",