更新依赖

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,6 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
using ThingsGateway.Foundation.Extension.String; using ThingsGateway.Foundation.Extension.String;
using ThingsGateway.NewLife;
using TouchSocket.SerialPorts; using TouchSocket.SerialPorts;
@@ -141,10 +140,19 @@ public static class ChannelOptionsExtensions
/// <returns></returns> /// <returns></returns>
private static SerialPortChannel GetSerialPort(this TouchSocketConfig config, IChannelOptions channelOptions) private static SerialPortChannel GetSerialPort(this TouchSocketConfig config, IChannelOptions channelOptions)
{ {
var serialPortOption = FastMapper.Mapper<IChannelOptions,SerialPortOption>(channelOptions); channelOptions.ThrowIfNull(nameof(SerialPortOption));
serialPortOption.ThrowIfNull(nameof(SerialPortOption));
channelOptions.Config = config; 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); SerialPortChannel serialPortChannel = new SerialPortChannel(channelOptions);
return serialPortChannel; return serialPortChannel;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -110,7 +110,11 @@ internal sealed class ChannelService : BaseService<Channel>, IChannelService
var device = devices.Keys.ToList(); var device = devices.Keys.ToList();
ManageHelper.CheckDeviceCount(device.Count); ManageHelper.CheckDeviceCount(device.Count);
foreach (var item in device)
{
item.RedundantEnable = false;
item.RedundantDeviceId = null;
}
await db.Insertable(device).ExecuteCommandAsync().ConfigureAwait(false); await db.Insertable(device).ExecuteCommandAsync().ConfigureAwait(false);
var variable = devices.SelectMany(a => a.Value).ToList(); 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(); var device = devices.Keys.ToList();
ManageHelper.CheckDeviceCount(device.Count); ManageHelper.CheckDeviceCount(device.Count);
foreach (var item in device)
{
item.RedundantEnable = false;
item.RedundantDeviceId = null;
}
await db.Insertable(device).ExecuteCommandAsync().ConfigureAwait(false); await db.Insertable(device).ExecuteCommandAsync().ConfigureAwait(false);
var variable = devices.SelectMany(a => a.Value).ToList(); var variable = devices.SelectMany(a => a.Value).ToList();
@@ -263,6 +267,9 @@ internal sealed class DeviceService : BaseService<Device>, IDeviceService
else else
ManageHelper.CheckDeviceCount(1); 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)) 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.StopBits" Ignore=@(context.ChannelType != ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.DtrEnable" 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.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) /> <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.StopBits" Ignore=@(context.ChannelType!=ChannelTypeEnum.SerialPort) />
<EditorItem @bind-Field="@context.DtrEnable" 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.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) /> <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) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
await base.OnAfterRenderAsync(firstRender); await base.OnAfterRenderAsync(firstRender);
if (firstRender) { if (firstRender)
{
StateHasChanged(); StateHasChanged();
} }
} }

View File

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

View File

@@ -49,12 +49,12 @@ namespace BenchmarkConsoleApp
BenchmarkRunner.Run<MapperBench>( BenchmarkRunner.Run<MapperBench>(
ManualConfig.Create(DefaultConfig.Instance) ManualConfig.Create(DefaultConfig.Instance)
.WithOptions(ConfigOptions.DisableOptimizationsValidator) .WithOptions(ConfigOptions.DisableOptimizationsValidator)
); );
// BenchmarkRunner.Run<ModbusBenchmark>( // BenchmarkRunner.Run<ModbusBenchmark>(
// ManualConfig.Create(DefaultConfig.Instance) // ManualConfig.Create(DefaultConfig.Instance)
// .WithOptions(ConfigOptions.DisableOptimizationsValidator) // .WithOptions(ConfigOptions.DisableOptimizationsValidator)
//); //);
// BenchmarkRunner.Run<S7Benchmark>( // BenchmarkRunner.Run<S7Benchmark>(
//ManualConfig.Create(DefaultConfig.Instance) //ManualConfig.Create(DefaultConfig.Instance)
//.WithOptions(ConfigOptions.DisableOptimizationsValidator) //.WithOptions(ConfigOptions.DisableOptimizationsValidator)

View File

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

View File

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

View File

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