更新依赖

This commit is contained in:
2248356998 qq.com
2025-09-27 23:59:38 +08:00
parent 20c44f10ca
commit 79406ad4a0
26 changed files with 66 additions and 58 deletions

View File

@@ -10,7 +10,6 @@
// ------------------------------------------------------------------------
using System.Security.Cryptography;
using System.Text;
namespace ThingsGateway.DataEncryption;
@@ -72,8 +71,8 @@ public static class PBKDF2Encryption
#if NET10_0_OR_GREATER
var computedHash = Rfc2898DeriveBytes.Pbkdf2(Encoding.UTF8.GetBytes(text), saltBytes, iterationCount, HashAlgorithmName.SHA256, derivedKeyLength);
#else
using var pbkdf2 = new Rfc2898DeriveBytes(text, saltBytes, iterationCount, HashAlgorithmName.SHA256);
var computedHash = pbkdf2.GetBytes(derivedKeyLength);
using var pbkdf2 = new Rfc2898DeriveBytes(text, saltBytes, iterationCount, HashAlgorithmName.SHA256);
var computedHash = pbkdf2.GetBytes(derivedKeyLength);
#endif
return computedHash.SequenceEqual(storedHashBytes);

View File

@@ -1,9 +1,9 @@
<Project>
<PropertyGroup>
<PluginVersion>10.11.73</PluginVersion>
<ProPluginVersion>10.11.73</ProPluginVersion>
<DefaultVersion>10.11.73</DefaultVersion>
<PluginVersion>10.11.75</PluginVersion>
<ProPluginVersion>10.11.75</ProPluginVersion>
<DefaultVersion>10.11.75</DefaultVersion>
<AuthenticationVersion>10.11.6</AuthenticationVersion>
<SourceGeneratorVersion>10.11.6</SourceGeneratorVersion>
<NET8Version>8.0.20</NET8Version>
@@ -12,7 +12,7 @@
<IsTrimmable>false</IsTrimmable>
<ManagementProPluginVersion>10.11.70</ManagementProPluginVersion>
<ManagementPluginVersion>10.11.70</ManagementPluginVersion>
<TSVersion>4.0.0-beta.57</TSVersion>
<TSVersion>4.0.0-beta.70</TSVersion>
</PropertyGroup>

View File

@@ -36,7 +36,7 @@
<EditorItem @bind-Field="@context.StopBits" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.DtrEnable" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.RtsEnable" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.StreamAsync" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.Handshake" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.CacheTimeout" Ignore=@(context.ChannelType == ChannelTypeEnum.UdpSession || context.ChannelType == ChannelTypeEnum.Other) />

View File

@@ -42,7 +42,7 @@
"PortName": "COM Port",
"RemoteUrl": "Remote IP Address",
"RtsEnable": "Rts",
"StreamAsync": "StreamAsync",
"Handshake": "Handshake",
"SaveChannel": "Add/Modify Channel",
"StopBits": "Stop Bits"
},
@@ -102,7 +102,7 @@
"PortName": "PortName",
"RemoteUrl": "RemoteUrl",
"RtsEnable": "RtsEnable",
"StreamAsync": "StreamAsync",
"Handshake": "Handshake",
"StopBits": "StopBits"
}
}

View File

@@ -40,7 +40,7 @@
"PortName": "COM口",
"RemoteUrl": "远程url",
"RtsEnable": "Rts",
"StreamAsync": "串口流读写",
"Handshake": "Handshake",
"SaveChannel": "添加/修改通道",
"StopBits": "停止位"
},
@@ -100,7 +100,7 @@
"PortName": "COM口",
"RemoteUrl": "远程url",
"RtsEnable": "Rts",
"StreamAsync": "串口流读写",
"Handshake": "串口流读写",
"StopBits": "停止位"
}
}

View File

@@ -69,9 +69,9 @@ namespace ThingsGateway.Foundation
public virtual bool DtrEnable { get; set; } = true;
/// <summary>
/// StreamAsync
/// Handshake
/// </summary>
public virtual bool StreamAsync { get; set; } = false;
public virtual Handshake Handshake { get; set; }
/// <summary>
/// RtsEnable

View File

@@ -9,7 +9,6 @@
//------------------------------------------------------------------------------
using ThingsGateway.Foundation.Extension.String;
using ThingsGateway.NewLife;
using TouchSocket.SerialPorts;
@@ -141,10 +140,19 @@ public static class ChannelOptionsExtensions
/// <returns></returns>
private static SerialPortChannel GetSerialPort(this TouchSocketConfig config, IChannelOptions channelOptions)
{
var serialPortOption = FastMapper.Mapper<IChannelOptions,SerialPortOption>(channelOptions);
serialPortOption.ThrowIfNull(nameof(SerialPortOption));
channelOptions.ThrowIfNull(nameof(SerialPortOption));
channelOptions.Config = config;
config.SetSerialPortOption(serialPortOption);
config.SetSerialPortOption(options =>
{
options.PortName = channelOptions.PortName;
options.BaudRate = channelOptions.BaudRate;
options.DataBits = channelOptions.DataBits;
options.Parity = channelOptions.Parity;
options.StopBits = channelOptions.StopBits;
options.DtrEnable = channelOptions.DtrEnable;
options.RtsEnable = channelOptions.RtsEnable;
options.Handshake = channelOptions.Handshake;
});
//载入配置
SerialPortChannel serialPortChannel = new SerialPortChannel(channelOptions);
return serialPortChannel;

View File

@@ -72,11 +72,7 @@ public interface IChannelOptions
/// </summary>
bool RtsEnable { get; set; }
/// <summary>
/// StreamAsync
/// </summary>
bool StreamAsync { get; set; }
Handshake Handshake { get; set; }
#endregion
/// <summary>
/// 最大并发数量

View File

@@ -182,7 +182,7 @@ public class DeviceSingleStreamDataHandleAdapter<TRequest> : CustomDataHandlingA
Span<byte> span = default;
if (Logger?.LogLevel <= LogLevel.Trace)
{
span = writer.GetSpan(sendMessage.MaxLength);
span = writer.GetSpan(sendMessage.MaxLength);
}
sendMessage.Build(ref writer);

View File

@@ -18,8 +18,6 @@ using ThingsGateway.NewLife;
using ThingsGateway.NewLife.Collections;
using ThingsGateway.NewLife.Extension;
using TouchSocket.SerialPorts;
namespace ThingsGateway.Foundation;
/// <summary>

View File

@@ -22,7 +22,7 @@
"PortName": "PortName",
"RemoteUrl": "RemoteUrl",
"RtsEnable": "RtsEnable",
"StreamAsync": "StreamAsync",
"Handshake": "Handshake",
"StopBits": "StopBits"
},
"ThingsGateway.Foundation.ConverterConfig": {

View File

@@ -22,7 +22,7 @@
"PortName": "COM口",
"RemoteUrl": "远程url",
"RtsEnable": "Rts",
"StreamAsync": "串口流读写",
"Handshake": "Handshake",
"StopBits": "停止位"
},
"ThingsGateway.Foundation.ConverterConfig": {

View File

@@ -16,8 +16,6 @@ using ThingsGateway.NewLife.Json.Extension;
using TouchSocket.Core;
using static System.Net.Mime.MediaTypeNames;
namespace ThingsGateway.Gateway.Application;
/// <summary>

View File

@@ -138,11 +138,11 @@ public class Channel : ChannelOptionsBase, IPrimaryIdEntity, IBaseDataEntity, IB
public override bool RtsEnable { get; set; }
/// <summary>
/// StreamAsync
/// Handshake
/// </summary>
[SugarColumn(ColumnDescription = "StreamAsync", IsNullable = true)]
[SugarColumn(ColumnDescription = "Handshake", IsNullable = true)]
[AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
public override bool StreamAsync { get; set; } = false;
public override Handshake Handshake { get; set; }
/// <summary>
/// 缓存超时

View File

@@ -307,7 +307,7 @@
"PortName": "PortName",
"RemoteUrl": "RemoteUrl",
"RtsEnable": "RtsEnable",
"StreamAsync": "StreamAsync",
"Handshake": "Handshake",
"SaveChannel": "Add/Modify Channel",
"SortCode": "SortCode",
"StopBits": "StopBits",

View File

@@ -306,7 +306,7 @@
"PortName": "COM口",
"RemoteUrl": "远程url",
"RtsEnable": "Rts",
"StreamAsync": "串口流读写",
"Handshake": "Handshake",
"SaveChannel": "添加/修改通道",
"SortCode": "排序",
"StopBits": "停止位",

View File

@@ -110,7 +110,11 @@ internal sealed class ChannelService : BaseService<Channel>, IChannelService
var device = devices.Keys.ToList();
ManageHelper.CheckDeviceCount(device.Count);
foreach (var item in device)
{
item.RedundantEnable = false;
item.RedundantDeviceId = null;
}
await db.Insertable(device).ExecuteCommandAsync().ConfigureAwait(false);
var variable = devices.SelectMany(a => a.Value).ToList();

View File

@@ -53,7 +53,11 @@ internal sealed class DeviceService : BaseService<Device>, IDeviceService
{
var device = devices.Keys.ToList();
ManageHelper.CheckDeviceCount(device.Count);
foreach (var item in device)
{
item.RedundantEnable = false;
item.RedundantDeviceId = null;
}
await db.Insertable(device).ExecuteCommandAsync().ConfigureAwait(false);
var variable = devices.SelectMany(a => a.Value).ToList();
@@ -263,6 +267,9 @@ internal sealed class DeviceService : BaseService<Device>, IDeviceService
else
ManageHelper.CheckDeviceCount(1);
if (input.RedundantEnable && GlobalData.IsRedundant(input.RedundantDeviceId ?? 0))
throw Oops.Bah($"Redundancy configuration error, backup device has been planned into another redundancy group");
if (await base.SaveAsync(input, type).ConfigureAwait(false))
{

View File

@@ -114,7 +114,7 @@
<EditorItem @bind-Field="@context.StopBits" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.DtrEnable" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.RtsEnable" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.StreamAsync" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.Handshake" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.CacheTimeout" Ignore=@(context.ChannelType == ChannelTypeEnum.UdpSession || context.ChannelType == ChannelTypeEnum.Other) />

View File

@@ -82,7 +82,7 @@
<EditorItem @bind-Field="@context.StopBits" Ignore=@(context.ChannelType!=ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.DtrEnable" Ignore=@(context.ChannelType!=ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.RtsEnable" Ignore=@(context.ChannelType!=ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.StreamAsync" Ignore=@(context.ChannelType!=ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.Handshake" Ignore=@(context.ChannelType!=ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.CacheTimeout" Ignore=@(context.ChannelType==ChannelTypeEnum.UdpSession||context.ChannelType==ChannelTypeEnum.Other) />

View File

@@ -35,7 +35,8 @@ public partial class RulesPage : ThingsGatewayModuleComponentBase
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender) {
if (firstRender)
{
StateHasChanged();
}
}

View File

@@ -57,10 +57,10 @@ public class ModbusBenchmark : IDisposable
ModbusType = ModbusTypeEnum.ModbusTcp,
};
thingsgatewaymodbus.InitChannel(clientChannel);
await clientChannel.SetupAsync(clientChannel.Config);
await clientChannel.SetupAsync(clientChannel.Config);
clientChannel.Logger.LogLevel = LogLevel.Warning;
await thingsgatewaymodbus.ConnectAsync(CancellationToken.None);
await thingsgatewaymodbus.ReadAsync("40001", 100);
await thingsgatewaymodbus.ConnectAsync(CancellationToken.None);
await thingsgatewaymodbus.ReadAsync("40001", 100);
thingsgatewaymodbuss.Add(thingsgatewaymodbus);
}
@@ -70,7 +70,7 @@ public class ModbusBenchmark : IDisposable
var factory = new NModbus.ModbusFactory();
var nmodbus = factory.CreateMaster(new TcpClient("127.0.0.1", 502));
await nmodbus.ReadHoldingRegistersAsync(1, 0, 100);
await nmodbus.ReadHoldingRegistersAsync(1, 0, 100);
nmodbuss.Add(nmodbus);
}
//for (int i = 0; i < Program.ClientCount; i++)
@@ -86,10 +86,10 @@ public class ModbusBenchmark : IDisposable
for (int i = 0; i < Program.ClientCount; i++)
{
var client = new ModbusTcpMaster();
await client.SetupAsync(new TouchSocketConfig()
.SetRemoteIPHost("127.0.0.1:502"));
await client.ConnectAsync(CancellationToken.None);
await client.ReadHoldingRegistersAsync(0, 100);
await client.SetupAsync(new TouchSocketConfig()
.SetRemoteIPHost("127.0.0.1:502"));
await client.ConnectAsync(CancellationToken.None);
await client.ReadHoldingRegistersAsync(0, 100);
modbusTcpMasters.Add(client);
}
@@ -104,8 +104,8 @@ public class ModbusBenchmark : IDisposable
for (int i = 0; i < Program.ClientCount; i++)
{
var client = factory.GetOrCreateTcpMaster();
await client.ConnectAsync("127.0.0.1", 502);
await client.ReadHoldingRegistersAsync(0x01, 0x00, 10);
await client.ConnectAsync("127.0.0.1", 502);
await client.ReadHoldingRegistersAsync(0x01, 0x00, 10);
_lgbModbusClients.Add(client);
}

View File

@@ -51,10 +51,10 @@ ManualConfig.Create(DefaultConfig.Instance)
.WithOptions(ConfigOptions.DisableOptimizationsValidator)
);
// BenchmarkRunner.Run<ModbusBenchmark>(
// ManualConfig.Create(DefaultConfig.Instance)
// .WithOptions(ConfigOptions.DisableOptimizationsValidator)
//);
// BenchmarkRunner.Run<ModbusBenchmark>(
// ManualConfig.Create(DefaultConfig.Instance)
// .WithOptions(ConfigOptions.DisableOptimizationsValidator)
//);
// BenchmarkRunner.Run<S7Benchmark>(
//ManualConfig.Create(DefaultConfig.Instance)
//.WithOptions(ConfigOptions.DisableOptimizationsValidator)

View File

@@ -14,7 +14,6 @@ using ThingsGateway.Common;
using ThingsGateway.DB;
using ThingsGateway.Debug;
using ThingsGateway.Foundation;
using ThingsGateway.Gateway.Application;
using ThingsGateway.NewLife;
using ThingsGateway.NewLife.Extension;
using ThingsGateway.NewLife.Threading;

View File

@@ -11,7 +11,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MQTTnet.AspNetCore;

View File

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