fix: 取消mapster映射忽略大小写,这会导致字典键错误

This commit is contained in:
Diego
2024-06-09 17:16:56 +08:00
parent f4273efef0
commit d7b5fde3c7
6 changed files with 5 additions and 53 deletions

View File

@@ -1,40 +0,0 @@
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://kimdiego2098.github.io/
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Foundation;
/// <summary>
/// 通道配置保存
/// </summary>
public class ChannelConfig : AppConfigBase
{
public static ChannelConfig Default;
static ChannelConfig()
{
Default = AppConfigBase.GetNewDefault<ChannelConfig>();
foreach (var item in Default.ChannelDatas)
{
ChannelData.CreateChannel(item);
}
}
/// <summary>
/// 通道列表
/// </summary>
public ConcurrentList<ChannelData> ChannelDatas { get; set; } = new();
/// <summary>
/// <inheritdoc/>
/// </summary>
public ChannelConfig() : base(($"channel.config.json"))
{
}
}

View File

@@ -97,7 +97,6 @@ internal class AdminTaskService : BackgroundService
.Select(a => Path.GetFileName(a))
.ToArray();
ChannelConfig channelConfig = AppConfigBase.GetNewDefault<ChannelConfig>();
foreach (var item in debugDirs)
{
if (stoppingToken.IsCancellationRequested)
@@ -107,10 +106,7 @@ internal class AdminTaskService : BackgroundService
//删除文件夹
try
{
if (!channelConfig.ChannelDatas.Select(a => a.Id.ToString()).Contains(item))
{
Directory.Delete(debugDir.CombinePathWithOs(item), true);
}
Directory.Delete(debugDir.CombinePathWithOs(item), true);
}
catch { }
}

View File

@@ -349,7 +349,7 @@ public class PluginService : IPluginService
foreach (var propertyInfo in pluginProperties ?? new List<PropertyInfo>())
{
// 在设备属性列表中查找与当前属性相同名称的属性
if (!deviceProperties.TryGetValue(propertyInfo.Name.ToLower(), out var deviceProperty))
if (!deviceProperties.TryGetValue(propertyInfo.Name, out var deviceProperty))
{
continue;
}

View File

@@ -31,11 +31,6 @@ public class Startup : AppStartup
.NameMatchingStrategy(NameMatchingStrategy.Flexible)
.PreserveReference(true);
// 配置默认全局映射(忽略大小写敏感)
TypeAdapterConfig.GlobalSettings.Default
.NameMatchingStrategy(NameMatchingStrategy.IgnoreCase)
.PreserveReference(true);
//运行日志写入数据库配置
services.AddDatabaseLogging<BackendLogDatabaseLoggingWriter>(options =>
{

View File

@@ -11,6 +11,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MQTTnet.AspNetCore;
@@ -60,7 +61,6 @@ public partial class MqttServer : BusinessBaseWithCacheIntervalScript<VariableDa
webBuilder.UseStartup<MqttServerStartup>();
_webHost = webBuilder.UseConfiguration(configuration)
.Build();
_mqttServer = _webHost.Services.GetRequiredService<MqttHostedServer>();
#endregion
@@ -68,7 +68,7 @@ public partial class MqttServer : BusinessBaseWithCacheIntervalScript<VariableDa
protected override async Task ProtectedBeforStartAsync(CancellationToken cancellationToken)
{
_ = _webHost.StartAsync(cancellationToken);
_ = _webHost.RunAsync();
if (_mqttServer != null)
{
_mqttServer.ValidatingConnectionAsync -= MqttServer_ValidatingConnectionAsync;

View File

@@ -12,6 +12,7 @@ using Mapster;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MQTTnet;
using MQTTnet.Internal;