From aad0f0e8c33ffe7f9fb3612bdec2cb96454444ea Mon Sep 17 00:00:00 2001 From: "2248356998 qq.com" <2248356998@qq.com> Date: Fri, 10 Oct 2025 11:19:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20orm=E6=89=B9=E9=87=8F=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ThingsGateway.Common.csproj | 2 +- .../Extension/PathExtensions.cs | 8 ++++---- .../QuestDb/QuestDbRestAPHelper.cs | 5 +++-- .../FastestProvider/FastestProvider.cs | 6 +++--- src/Directory.Build.props | 10 +++++----- .../Extensions/LoggerExtensions.cs | 18 +++++++++--------- .../Logger/TextFileReader.cs | 3 ++- .../Utils/ReusableCancellationTokenSource.cs | 12 +++++++++--- .../ChannelDeviceTree.razor.cs | 1 - .../ThingsGateway.Plugin.Kafka.csproj | 2 +- 10 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/Admin/ThingsGateway.Common/ThingsGateway.Common.csproj b/src/Admin/ThingsGateway.Common/ThingsGateway.Common.csproj index 612a60f18..f2009f12d 100644 --- a/src/Admin/ThingsGateway.Common/ThingsGateway.Common.csproj +++ b/src/Admin/ThingsGateway.Common/ThingsGateway.Common.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Admin/ThingsGateway.NewLife.X/Extension/PathExtensions.cs b/src/Admin/ThingsGateway.NewLife.X/Extension/PathExtensions.cs index ec8fb2416..7d8ca2fa7 100644 --- a/src/Admin/ThingsGateway.NewLife.X/Extension/PathExtensions.cs +++ b/src/Admin/ThingsGateway.NewLife.X/Extension/PathExtensions.cs @@ -8,6 +8,8 @@ // QQ群:605534569 //------------------------------------------------------------------------------ +using ThingsGateway.NewLife; + namespace ThingsGateway; /// @@ -38,10 +40,8 @@ public static class PathExtensions path = Path.Combine(path, text); } } - // 处理路径分隔符,兼容Windows和Linux - var sep = Path.DirectorySeparatorChar; - var sep2 = sep == '/' ? '\\' : '/'; - path = path.Replace(sep2, sep); + + path = path.Replace('\\', '/'); return path; } } diff --git a/src/Admin/ThingsGateway.SqlSugar/QuestDb/QuestDbRestAPHelper.cs b/src/Admin/ThingsGateway.SqlSugar/QuestDb/QuestDbRestAPHelper.cs index 2a7d71e43..f436fcc81 100644 --- a/src/Admin/ThingsGateway.SqlSugar/QuestDb/QuestDbRestAPHelper.cs +++ b/src/Admin/ThingsGateway.SqlSugar/QuestDb/QuestDbRestAPHelper.cs @@ -24,7 +24,7 @@ namespace ThingsGateway.SqlSugar } /// - /// 逐行读取,包含空行 + /// 逐行读取 /// /// /// @@ -35,7 +35,8 @@ namespace ThingsGateway.SqlSugar string line = sr.ReadLine(); while (line != null) { - yield return sr.ReadLine(); + yield return line; + line = sr.ReadLine(); } } } diff --git a/src/Admin/ThingsGateway.SqlSugar/Sugar/Abstract/FastestProvider/FastestProvider.cs b/src/Admin/ThingsGateway.SqlSugar/Sugar/Abstract/FastestProvider/FastestProvider.cs index 46fe9b9aa..59c2b5045 100644 --- a/src/Admin/ThingsGateway.SqlSugar/Sugar/Abstract/FastestProvider/FastestProvider.cs +++ b/src/Admin/ThingsGateway.SqlSugar/Sugar/Abstract/FastestProvider/FastestProvider.cs @@ -263,7 +263,7 @@ namespace ThingsGateway.SqlSugar IFastBuilder buider = GetBuider(); buider.Context = context; int result = 0; - if (buider?.DbFastestProperties?.IsDataTable == true) + if (buider?.DbFastestProperties?.IsDataTable != false) { var dt = ToDdateTable(datas); if (buider?.DbFastestProperties?.IsMerge == true) @@ -400,7 +400,7 @@ namespace ThingsGateway.SqlSugar int result = 0; IFastBuilder buider = GetBuider(); buider.Context = context; - if (buider?.DbFastestProperties?.IsDataTable == true) + if (buider?.DbFastestProperties?.IsDataTable != false) { DataTable dt = ToDdateTable(datas); @@ -578,7 +578,7 @@ namespace ThingsGateway.SqlSugar IFastBuilder buider = GetBuider(); buider.Context = context; int result = 0; - if (buider?.DbFastestProperties?.IsDataTable == true) + if (buider?.DbFastestProperties?.IsDataTable != false) { DataTable dt = ToDdateTable(datas); result = await buider.ExecuteBulkCopyAsync(dt).ConfigureAwait(false); diff --git a/src/Directory.Build.props b/src/Directory.Build.props index deaf5068e..c70ae8281 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,17 +1,17 @@ - 10.11.87 - 10.11.87 - 10.11.87 + 10.11.90 + 10.11.90 + 10.11.90 10.11.6 10.11.6 8.0.20 10.0.0-rc.1.25451.107 zh-Hans;en-US false - 10.11.70 - 10.11.70 + 10.11.87 + 10.11.87 4.0.0-beta.96 diff --git a/src/Foundation/ThingsGateway.Foundation/Extensions/LoggerExtensions.cs b/src/Foundation/ThingsGateway.Foundation/Extensions/LoggerExtensions.cs index d0ea070f9..02f1dfcb5 100644 --- a/src/Foundation/ThingsGateway.Foundation/Extensions/LoggerExtensions.cs +++ b/src/Foundation/ThingsGateway.Foundation/Extensions/LoggerExtensions.cs @@ -45,7 +45,7 @@ public static class LoggerExtensions /// public static string GetDebugLogBasePath() { - return "Logs/DebugLog"; + return PathExtensions.CombinePathWithOs("Logs", "DebugLog"); } /// @@ -55,7 +55,7 @@ public static class LoggerExtensions /// public static string GetDebugLogPath(this long channelId) { - return GetDebugLogBasePath().CombinePath(channelId.ToString()); + return GetDebugLogBasePath().CombinePathWithOs(channelId.ToString()); } /// @@ -65,7 +65,7 @@ public static class LoggerExtensions /// public static string GetDebugLogPath(this string channelId) { - return GetDebugLogBasePath().CombinePath(channelId.SanitizeFileName()); + return GetDebugLogBasePath().CombinePathWithOs(channelId.SanitizeFileName()); } /// @@ -73,7 +73,7 @@ public static class LoggerExtensions /// public static string GetChannelLogBasePath() { - return "Logs/ChannelLog"; + return PathExtensions.CombinePathWithOs("Logs", "ChannelLog"); } /// @@ -83,7 +83,7 @@ public static class LoggerExtensions /// public static string GetChannelLogPath(this long channelId) { - return GetChannelLogBasePath().CombinePath(channelId.ToString()); + return GetChannelLogBasePath().CombinePathWithOs(channelId.ToString()); } /// /// 获取日志路径 @@ -92,7 +92,7 @@ public static class LoggerExtensions /// public static string GetChannelLogPath(this string channelId) { - return GetChannelLogBasePath().CombinePath(channelId.SanitizeFileName()); + return GetChannelLogBasePath().CombinePathWithOs(channelId.SanitizeFileName()); } /// @@ -100,7 +100,7 @@ public static class LoggerExtensions /// public static string GetDeviceLogBasePath() { - return "Logs/DeviceLog"; + return PathExtensions.CombinePathWithOs("Logs","DeviceLog"); } /// @@ -110,7 +110,7 @@ public static class LoggerExtensions /// public static string GetDeviceLogPath(this long DeviceId) { - return GetDeviceLogBasePath().CombinePath(DeviceId.ToString()); + return GetDeviceLogBasePath().CombinePathWithOs(DeviceId.ToString()); } /// /// 获取日志路径 @@ -119,7 +119,7 @@ public static class LoggerExtensions /// public static string GetDeviceLogPath(this string DeviceId) { - return GetDeviceLogBasePath().CombinePath(DeviceId.SanitizeFileName()); + return GetDeviceLogBasePath().CombinePathWithOs(DeviceId.SanitizeFileName()); } #region 日志 diff --git a/src/Foundation/ThingsGateway.Foundation/Logger/TextFileReader.cs b/src/Foundation/ThingsGateway.Foundation/Logger/TextFileReader.cs index e3afec3f7..1efc589fa 100644 --- a/src/Foundation/ThingsGateway.Foundation/Logger/TextFileReader.cs +++ b/src/Foundation/ThingsGateway.Foundation/Logger/TextFileReader.cs @@ -63,11 +63,12 @@ public static class TextFileReader public static OperResult> GetLogFiles(string directoryPath) { OperResult> result = new(); // 初始化结果对象 + directoryPath = AppContext.BaseDirectory.CombinePath(directoryPath); // 检查目录是否存在 if (!Directory.Exists(directoryPath)) { result.OperCode = 999; - result.ErrorMessage = "Directory not exists"; + result.ErrorMessage = $"Directory {directoryPath} not exists"; return result; } diff --git a/src/Foundation/ThingsGateway.Foundation/Utils/ReusableCancellationTokenSource.cs b/src/Foundation/ThingsGateway.Foundation/Utils/ReusableCancellationTokenSource.cs index 8715275eb..20a61d46c 100644 --- a/src/Foundation/ThingsGateway.Foundation/Utils/ReusableCancellationTokenSource.cs +++ b/src/Foundation/ThingsGateway.Foundation/Utils/ReusableCancellationTokenSource.cs @@ -29,11 +29,17 @@ public sealed class ReusableCancellationTokenSource : IDisposable private void OnTimeout(object? state) { - TimeoutStatus = true; + try + { + TimeoutStatus = true; - if (_cts?.IsCancellationRequested == false) - _cts?.Cancel(); + if (_cts?.IsCancellationRequested == false) + _cts?.Cancel(); + } + catch + { + } } private readonly LinkedCancellationTokenSourceCache _linkedCtsCache = new(); diff --git a/src/Gateway/ThingsGateway.Gateway.Razor/Pages/GatewayMonitorPage/ChannelDeviceTree.razor.cs b/src/Gateway/ThingsGateway.Gateway.Razor/Pages/GatewayMonitorPage/ChannelDeviceTree.razor.cs index ac6978878..7dca313a0 100644 --- a/src/Gateway/ThingsGateway.Gateway.Razor/Pages/GatewayMonitorPage/ChannelDeviceTree.razor.cs +++ b/src/Gateway/ThingsGateway.Gateway.Razor/Pages/GatewayMonitorPage/ChannelDeviceTree.razor.cs @@ -1423,7 +1423,6 @@ EventCallback.Factory.Create(this, async e => { await ChannelDeviceChanged.Invoke(Value); } - await InvokeAsync(StateHasChanged); } diff --git a/src/Plugin/ThingsGateway.Plugin.Kafka/ThingsGateway.Plugin.Kafka.csproj b/src/Plugin/ThingsGateway.Plugin.Kafka/ThingsGateway.Plugin.Kafka.csproj index e4cffe8ff..2d85c6c98 100644 --- a/src/Plugin/ThingsGateway.Plugin.Kafka/ThingsGateway.Plugin.Kafka.csproj +++ b/src/Plugin/ThingsGateway.Plugin.Kafka/ThingsGateway.Plugin.Kafka.csproj @@ -10,7 +10,7 @@ - + contentFiles;build;buildMultitargeting;buildTransitive;analyzers;