fix: orm批量插入

This commit is contained in:
2248356998 qq.com
2025-10-10 11:19:14 +08:00
parent e74eae50a7
commit aad0f0e8c3
10 changed files with 37 additions and 30 deletions

View File

@@ -14,7 +14,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.7" /> <PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.7" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" /> <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
<PackageReference Include="BootstrapBlazor" Version="9.11.0" /> <PackageReference Include="BootstrapBlazor" Version="9.11.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -8,6 +8,8 @@
// QQ群605534569 // QQ群605534569
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
using ThingsGateway.NewLife;
namespace ThingsGateway; namespace ThingsGateway;
/// <inheritdoc/> /// <inheritdoc/>
@@ -38,10 +40,8 @@ public static class PathExtensions
path = Path.Combine(path, text); path = Path.Combine(path, text);
} }
} }
// 处理路径分隔符兼容Windows和Linux
var sep = Path.DirectorySeparatorChar; path = path.Replace('\\', '/');
var sep2 = sep == '/' ? '\\' : '/';
path = path.Replace(sep2, sep);
return path; return path;
} }
} }

View File

@@ -24,7 +24,7 @@ namespace ThingsGateway.SqlSugar
} }
/// <summary> /// <summary>
/// 逐行读取,包含空行 /// 逐行读取
/// </summary> /// </summary>
/// <param name="text"></param> /// <param name="text"></param>
/// <returns></returns> /// <returns></returns>
@@ -35,7 +35,8 @@ namespace ThingsGateway.SqlSugar
string line = sr.ReadLine(); string line = sr.ReadLine();
while (line != null) while (line != null)
{ {
yield return sr.ReadLine(); yield return line;
line = sr.ReadLine();
} }
} }
} }

View File

@@ -263,7 +263,7 @@ namespace ThingsGateway.SqlSugar
IFastBuilder buider = GetBuider(); IFastBuilder buider = GetBuider();
buider.Context = context; buider.Context = context;
int result = 0; int result = 0;
if (buider?.DbFastestProperties?.IsDataTable == true) if (buider?.DbFastestProperties?.IsDataTable != false)
{ {
var dt = ToDdateTable(datas); var dt = ToDdateTable(datas);
if (buider?.DbFastestProperties?.IsMerge == true) if (buider?.DbFastestProperties?.IsMerge == true)
@@ -400,7 +400,7 @@ namespace ThingsGateway.SqlSugar
int result = 0; int result = 0;
IFastBuilder buider = GetBuider(); IFastBuilder buider = GetBuider();
buider.Context = context; buider.Context = context;
if (buider?.DbFastestProperties?.IsDataTable == true) if (buider?.DbFastestProperties?.IsDataTable != false)
{ {
DataTable dt = ToDdateTable(datas); DataTable dt = ToDdateTable(datas);
@@ -578,7 +578,7 @@ namespace ThingsGateway.SqlSugar
IFastBuilder buider = GetBuider(); IFastBuilder buider = GetBuider();
buider.Context = context; buider.Context = context;
int result = 0; int result = 0;
if (buider?.DbFastestProperties?.IsDataTable == true) if (buider?.DbFastestProperties?.IsDataTable != false)
{ {
DataTable dt = ToDdateTable(datas); DataTable dt = ToDdateTable(datas);
result = await buider.ExecuteBulkCopyAsync(dt).ConfigureAwait(false); result = await buider.ExecuteBulkCopyAsync(dt).ConfigureAwait(false);

View File

@@ -1,17 +1,17 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<PluginVersion>10.11.87</PluginVersion> <PluginVersion>10.11.90</PluginVersion>
<ProPluginVersion>10.11.87</ProPluginVersion> <ProPluginVersion>10.11.90</ProPluginVersion>
<DefaultVersion>10.11.87</DefaultVersion> <DefaultVersion>10.11.90</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>
<NET10Version>10.0.0-rc.1.25451.107</NET10Version> <NET10Version>10.0.0-rc.1.25451.107</NET10Version>
<SatelliteResourceLanguages>zh-Hans;en-US</SatelliteResourceLanguages> <SatelliteResourceLanguages>zh-Hans;en-US</SatelliteResourceLanguages>
<IsTrimmable>false</IsTrimmable> <IsTrimmable>false</IsTrimmable>
<ManagementProPluginVersion>10.11.70</ManagementProPluginVersion> <ManagementProPluginVersion>10.11.87</ManagementProPluginVersion>
<ManagementPluginVersion>10.11.70</ManagementPluginVersion> <ManagementPluginVersion>10.11.87</ManagementPluginVersion>
<TSVersion>4.0.0-beta.96</TSVersion> <TSVersion>4.0.0-beta.96</TSVersion>

View File

@@ -45,7 +45,7 @@ public static class LoggerExtensions
/// </summary> /// </summary>
public static string GetDebugLogBasePath() public static string GetDebugLogBasePath()
{ {
return "Logs/DebugLog"; return PathExtensions.CombinePathWithOs("Logs", "DebugLog");
} }
/// <summary> /// <summary>
@@ -55,7 +55,7 @@ public static class LoggerExtensions
/// <returns></returns> /// <returns></returns>
public static string GetDebugLogPath(this long channelId) public static string GetDebugLogPath(this long channelId)
{ {
return GetDebugLogBasePath().CombinePath(channelId.ToString()); return GetDebugLogBasePath().CombinePathWithOs(channelId.ToString());
} }
/// <summary> /// <summary>
@@ -65,7 +65,7 @@ public static class LoggerExtensions
/// <returns></returns> /// <returns></returns>
public static string GetDebugLogPath(this string channelId) public static string GetDebugLogPath(this string channelId)
{ {
return GetDebugLogBasePath().CombinePath(channelId.SanitizeFileName()); return GetDebugLogBasePath().CombinePathWithOs(channelId.SanitizeFileName());
} }
/// <summary> /// <summary>
@@ -73,7 +73,7 @@ public static class LoggerExtensions
/// </summary> /// </summary>
public static string GetChannelLogBasePath() public static string GetChannelLogBasePath()
{ {
return "Logs/ChannelLog"; return PathExtensions.CombinePathWithOs("Logs", "ChannelLog");
} }
/// <summary> /// <summary>
@@ -83,7 +83,7 @@ public static class LoggerExtensions
/// <returns></returns> /// <returns></returns>
public static string GetChannelLogPath(this long channelId) public static string GetChannelLogPath(this long channelId)
{ {
return GetChannelLogBasePath().CombinePath(channelId.ToString()); return GetChannelLogBasePath().CombinePathWithOs(channelId.ToString());
} }
/// <summary> /// <summary>
/// 获取日志路径 /// 获取日志路径
@@ -92,7 +92,7 @@ public static class LoggerExtensions
/// <returns></returns> /// <returns></returns>
public static string GetChannelLogPath(this string channelId) public static string GetChannelLogPath(this string channelId)
{ {
return GetChannelLogBasePath().CombinePath(channelId.SanitizeFileName()); return GetChannelLogBasePath().CombinePathWithOs(channelId.SanitizeFileName());
} }
/// <summary> /// <summary>
@@ -100,7 +100,7 @@ public static class LoggerExtensions
/// </summary> /// </summary>
public static string GetDeviceLogBasePath() public static string GetDeviceLogBasePath()
{ {
return "Logs/DeviceLog"; return PathExtensions.CombinePathWithOs("Logs","DeviceLog");
} }
/// <summary> /// <summary>
@@ -110,7 +110,7 @@ public static class LoggerExtensions
/// <returns></returns> /// <returns></returns>
public static string GetDeviceLogPath(this long DeviceId) public static string GetDeviceLogPath(this long DeviceId)
{ {
return GetDeviceLogBasePath().CombinePath(DeviceId.ToString()); return GetDeviceLogBasePath().CombinePathWithOs(DeviceId.ToString());
} }
/// <summary> /// <summary>
/// 获取日志路径 /// 获取日志路径
@@ -119,7 +119,7 @@ public static class LoggerExtensions
/// <returns></returns> /// <returns></returns>
public static string GetDeviceLogPath(this string DeviceId) public static string GetDeviceLogPath(this string DeviceId)
{ {
return GetDeviceLogBasePath().CombinePath(DeviceId.SanitizeFileName()); return GetDeviceLogBasePath().CombinePathWithOs(DeviceId.SanitizeFileName());
} }
#region #region

View File

@@ -63,11 +63,12 @@ public static class TextFileReader
public static OperResult<List<string>> GetLogFiles(string directoryPath) public static OperResult<List<string>> GetLogFiles(string directoryPath)
{ {
OperResult<List<string>> result = new(); // 初始化结果对象 OperResult<List<string>> result = new(); // 初始化结果对象
directoryPath = AppContext.BaseDirectory.CombinePath(directoryPath);
// 检查目录是否存在 // 检查目录是否存在
if (!Directory.Exists(directoryPath)) if (!Directory.Exists(directoryPath))
{ {
result.OperCode = 999; result.OperCode = 999;
result.ErrorMessage = "Directory not exists"; result.ErrorMessage = $"Directory {directoryPath} not exists";
return result; return result;
} }

View File

@@ -29,11 +29,17 @@ public sealed class ReusableCancellationTokenSource : IDisposable
private void OnTimeout(object? state) private void OnTimeout(object? state)
{ {
TimeoutStatus = true; try
{
TimeoutStatus = true;
if (_cts?.IsCancellationRequested == false) if (_cts?.IsCancellationRequested == false)
_cts?.Cancel(); _cts?.Cancel();
}
catch
{
}
} }
private readonly LinkedCancellationTokenSourceCache _linkedCtsCache = new(); private readonly LinkedCancellationTokenSourceCache _linkedCtsCache = new();

View File

@@ -1423,7 +1423,6 @@ EventCallback.Factory.Create<MouseEventArgs>(this, async e =>
{ {
await ChannelDeviceChanged.Invoke(Value); await ChannelDeviceChanged.Invoke(Value);
} }
await InvokeAsync(StateHasChanged);
} }

View File

@@ -10,7 +10,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj"> <ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj">
</ProjectReference> </ProjectReference>
<PackageReference Include="Confluent.Kafka" Version="2.11.1" GeneratePathProperty="true"> <PackageReference Include="Confluent.Kafka" Version="2.12.0" GeneratePathProperty="true">
<PrivateAssets>contentFiles;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets> <PrivateAssets>contentFiles;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>