Compare commits

...

2 Commits

Author SHA1 Message Date
Diego
50758b79bc 更新依赖包 2025-04-23 11:48:45 +08:00
Diego
06a1f902ad 修改Startup方法名称 2025-04-23 10:56:03 +08:00
21 changed files with 131 additions and 31 deletions

View File

@@ -10,6 +10,7 @@
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
@@ -23,7 +24,7 @@ namespace ThingsGateway.Admin.Application;
[AppStartup(1000000000)]
public class Startup : AppStartup
{
public void ConfigureAdminApp(IServiceCollection services)
public void Configure(IServiceCollection services)
{
Directory.CreateDirectory("DB");
@@ -75,7 +76,7 @@ public class Startup : AppStartup
}
public void UseAdminCore(IServiceProvider serviceProvider)
public void Use(IApplicationBuilder applicationBuilder)
{
//检查ConfigId
var configIdGroup = DbContext.DbConfigs.GroupBy(it => it.ConfigId);

View File

@@ -19,7 +19,6 @@
<ItemGroup>
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.3" />
<!--<PackageReference Include="MiniExcel" Version="1.39.0" />-->
<PackageReference Include="UAParser" Version="3.1.47" />
<PackageReference Include="Rougamo.Fody" Version="5.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.189" />

View File

@@ -15,7 +15,7 @@ namespace ThingsGateway.Admin.Razor;
[AppStartup(-1)]
public class Startup : AppStartup
{
public void ConfigureAdminApp(IServiceCollection services)
public void Configure(IServiceCollection services)
{
services.AddScoped<IMenuService, MenuService>();
services.AddBootstrapBlazorTableExportService();

View File

@@ -147,7 +147,7 @@ internal sealed class ScheduleHostedService : BackgroundService
await BackgroundProcessing(stoppingToken).ConfigureAwait(false);
}
_logger.LogCritical($"Schedule hosted service is stopped.");
_logger.LogInformation($"Schedule hosted service is stopped.");
}
/// <summary>

View File

@@ -8,6 +8,7 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using ThingsGateway.NewLife;
@@ -48,7 +49,7 @@ public class Startup : AppStartup
}
/// <inheritdoc/>
public void UseService(IServiceProvider serviceProvider)
public void Use(IApplicationBuilder applicationBuilder)
{
}
}

View File

@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="9.0.2" />
<PackageReference Include="BootstrapBlazor" Version="9.5.8" />
<PackageReference Include="BootstrapBlazor" Version="9.5.9" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup>

View File

@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<PluginVersion>10.5.1</PluginVersion>
<ProPluginVersion>10.5.1</ProPluginVersion>
<PluginVersion>10.5.2</PluginVersion>
<ProPluginVersion>10.5.2</ProPluginVersion>
<AuthenticationVersion>2.1.7</AuthenticationVersion>
</PropertyGroup>

View File

@@ -15,7 +15,7 @@ namespace ThingsGateway.Debug;
[AppStartup(100000000)]
public class Startup : AppStartup
{
public void ConfigureAdminApp(IServiceCollection services)
public void Configure(IServiceCollection services)
{
services.AddScoped<IPlatformService, PlatformService>();
}

View File

@@ -10,6 +10,10 @@
using Mapster;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Reflection;
namespace ThingsGateway.Gateway.Application;
@@ -17,7 +21,7 @@ namespace ThingsGateway.Gateway.Application;
[AppStartup(-100)]
public class Startup : AppStartup
{
public void ConfigureAdminApp(IServiceCollection services)
public void Configure(IServiceCollection services)
{
services.AddConfigurableOptions<ChannelThreadOptions>();
services.AddConfigurableOptions<GatewayLogOptions>();
@@ -62,8 +66,9 @@ public class Startup : AppStartup
services.AddGatewayHostedService<IGatewayMonitorHostedService, GatewayMonitorHostedService>();
}
public void UseAdminCore(IServiceProvider serviceProvider)
public void Use(IApplicationBuilder applicationBuilder)
{
var serviceProvider = applicationBuilder.ApplicationServices;
//检查ConfigId
var configIdGroup = DbContext.DbConfigs.GroupBy(it => it.ConfigId);
foreach (var configId in configIdGroup)
@@ -88,16 +93,29 @@ public class Startup : AppStartup
try
{
using var db = DbContext.GetDB<Channel>();
if (!db.DbMaintenance.IsAnyColumn(nameof(Channel), "LogEnable", false)) return;
var tables = db.DbMaintenance.DropColumn(nameof(Channel), "LogEnable");
if (db.DbMaintenance.IsAnyColumn(nameof(Channel), "LogEnable", false))
{
var tables = db.DbMaintenance.DropColumn(nameof(Channel), "LogEnable");
}
}
catch { }
try
{
using var db = DbContext.GetDB<Device>();
if (!db.DbMaintenance.IsAnyColumn(nameof(Device), "LogEnable", false)) return;
var tables = db.DbMaintenance.DropColumn(nameof(Device), "LogEnable");
if (db.DbMaintenance.IsAnyColumn(nameof(Device), "LogEnable", false))
{
var tables = db.DbMaintenance.DropColumn(nameof(Device), "LogEnable");
}
}
catch { }
serviceProvider.GetService<IHostApplicationLifetime>().ApplicationStarted.Register(() =>
{
serviceProvider.GetService<ILoggerFactory>().CreateLogger(nameof(ThingsGateway)).LogInformation("ThingsGateway is started...");
});
serviceProvider.GetService<IHostApplicationLifetime>().ApplicationStopping.Register(() =>
{
serviceProvider.GetService<ILoggerFactory>().CreateLogger(nameof(ThingsGateway)).LogInformation("ThingsGateway is stopping...");
});
}
}

View File

@@ -7,7 +7,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="SqlSugar.TDengineCore" Version="4.18.6" />
<PackageReference Include="Rougamo.Fody" Version="5.0.0" />
<PackageReference Include="TouchSocket.Dmtp" Version="3.0.26" />
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.0.26" />

View File

@@ -15,7 +15,7 @@ namespace ThingsGateway.Gateway.Razor;
[AppStartup(-1000)]
public class Startup : AppStartup
{
public void ConfigureAdminApp(IServiceCollection services)
public void Configure(IServiceCollection services)
{
services.AddBootstrapBlazorWinBoxService();
}

View File

@@ -8,6 +8,8 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Builder;
using System.Reflection;
using ThingsGateway.Gateway.Application;
@@ -18,7 +20,7 @@ namespace ThingsGateway.Management;
[AppStartup(10000000)]
public class Startup : AppStartup
{
public void ConfigureAdminApp(IServiceCollection services)
public void Configure(IServiceCollection services)
{
services.AddSingleton<IRedundancyService, RedundancyService>();
services.AddGatewayHostedService<IRedundancyHostedService, RedundancyHostedService>();
@@ -29,8 +31,9 @@ public class Startup : AppStartup
}
public void UseAdminCore(IServiceProvider serviceProvider)
public void Use(IApplicationBuilder applicationBuilder)
{
var serviceProvider = applicationBuilder.ApplicationServices;
//检查ConfigId
var configIdGroup = DbContext.DbConfigs.GroupBy(it => it.ConfigId);
foreach (var configId in configIdGroup)

View File

@@ -8,6 +8,7 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
@@ -20,15 +21,16 @@ namespace ThingsGateway.Management;
[AppStartup(10000000)]
public class Startup : AppStartup
{
public void ConfigureAdminApp(IServiceCollection services)
public void Configure(IServiceCollection services)
{
services.AddSingleton<IRulesService, RulesService>();
services.AddGatewayHostedService<IRulesEngineHostedService, RulesEngineHostedService>();
}
public void UseAdminCore(IServiceProvider serviceProvider)
public void Use(IApplicationBuilder applicationBuilder)
{
var serviceProvider = applicationBuilder.ApplicationServices;
//检查ConfigId
var configIdGroup = DbContext.DbConfigs.GroupBy(it => it.ConfigId);
foreach (var configId in configIdGroup)

View File

@@ -8,6 +8,7 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace ThingsGateway.Debug;
@@ -22,7 +23,7 @@ public class Startup : AppStartup
.AddScoped<IMenuService, DefaultMenuService>();
}
public void UseService(IServiceProvider serviceProvider)
public void Use(IApplicationBuilder applicationBuilder)
{
}
}

View File

@@ -1,6 +1,28 @@
<Project>
<Target Name="CopyNugetPackages" AfterTargets="Build">
<ItemGroup>
<!-- setting up the variable for convenience -->
<!--<SqlSugar_QuestDb_RestAPIApplicationPackageFiles Include="$(PkgSqlSugar_QuestDb_RestAPI)\lib\netstandard2.1\*.*" />
<CsvHelperApplicationPackageFiles Include="$(PkgCsvHelper)\lib\net8.0\*.*" />-->
<SqlSugar_TDengineCoreApplicationPackageFiles Include="$(PkgSqlSugar_TDengineCore)\lib\netstandard2.1\*.*" />
<TDengine_Ado_DataApplicationPackageFiles Include="$(PkgTDengine_Ado_Data)\lib\netstandard2.1\*.*" />
<TDengine_ConnectorPackageFiles Include="$(PkgTDengine_Connector)\lib\net6.0\*.*" />
</ItemGroup>
<PropertyGroup>
<ApplicationFolder>$(TargetDir)</ApplicationFolder>
</PropertyGroup>
<Copy SourceFiles="@(SqlSugar_QuestDb_RestAPIApplicationPackageFiles)" DestinationFolder="$(ApplicationFolder)%(RecursiveDir)" />
<Copy SourceFiles="@(CsvHelperApplicationPackageFiles)" DestinationFolder="$(ApplicationFolder)%(RecursiveDir)" />
<Copy SourceFiles="@(SqlSugar_TDengineCoreApplicationPackageFiles)" DestinationFolder="$(ApplicationFolder)%(RecursiveDir)" />
<Copy SourceFiles="@(TDengine_Ado_DataApplicationPackageFiles)" DestinationFolder="$(ApplicationFolder)%(RecursiveDir)" />
<Copy SourceFiles="@(TDengine_ConnectorPackageFiles)" DestinationFolder="$(ApplicationFolder)%(RecursiveDir)" />
</Target>
<!--在构建后触发的。它通过在 Nuget 包的 Content 文件夹中包含目标目录中的所有文件和子文件夹来创建 nuget 包-->
<Target Name="IncludeAllFilesInTargetDir" AfterTargets="Build">
@@ -9,6 +31,18 @@
<Pack>true</Pack>
<PackagePath>Content</PackagePath>
</Content>
<Content Include="$(ProjectDir)bin\$(Configuration)\$(TargetFramework)\**\*TDengine*.dll">
<Pack>true</Pack>
<PackagePath>Content</PackagePath>
</Content>
<Content Include="$(ProjectDir)bin\$(Configuration)\$(TargetFramework)\**\*QuestDb*.dll">
<Pack>true</Pack>
<PackagePath>Content</PackagePath>
</Content>
<Content Include="$(ProjectDir)bin\$(Configuration)\$(TargetFramework)\**\*CsvHelper*.dll">
<Pack>true</Pack>
<PackagePath>Content</PackagePath>
</Content>
</ItemGroup>
</Target>

View File

@@ -12,8 +12,12 @@ using BootstrapBlazor.Components;
using Mapster;
using Newtonsoft.Json.Linq;
using SqlSugar;
using System.Reflection;
using ThingsGateway.Admin.Application;
using ThingsGateway.Foundation;
using ThingsGateway.NewLife.Extension;
@@ -63,9 +67,21 @@ public partial class TDengineDBProducer : BusinessBaseWithCacheIntervalVariableM
}
protected override async Task InitChannelAsync(IChannel? channel, CancellationToken cancellationToken)
{
InstanceFactory.RemoveCache();
List<Assembly> assemblies = new();
foreach (var item in InstanceFactory.CustomAssemblies)
{
if (item.FullName != typeof(SqlSugar.TDengine.TDengineProvider).Assembly.FullName)
{
assemblies.Add(item);
}
}
assemblies.Add(typeof(SqlSugar.TDengine.TDengineProvider).Assembly);
InstanceFactory.CustomAssemblies = assemblies.ToArray();
_config = new TypeAdapterConfig();
_config.ForType<VariableRuntime, TDengineDBHistoryValue>()
.Map(dest => dest.Value, src => src.Value == null ? string.Empty : src.Value.ToString() ?? string.Empty)
.Map(dest => dest.Value, src => src.Value != null ? src.Value.GetType() == typeof(string) ? src.Value.ToString() : JToken.FromObject(src.Value).ToString() : string.Empty)
//.Map(dest => dest.Id, src => CommonUtils.GetSingleId())
.Map(dest => dest.Id, src => src.Id)//Id更改为变量Id
;//注意sqlsugar插入时无时区直接utc时间

View File

@@ -9,6 +9,27 @@
</ProjectReference>
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Razor\ThingsGateway.Gateway.Razor.csproj">
</ProjectReference>
<!--<PackageReference Include="SqlSugar.QuestDb.RestAPI" Version="4.1.17" GeneratePathProperty="true">
<PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
</PackageReference>
<PackageReference Include="CsvHelper" Version="31.0.2" GeneratePathProperty="true">
<PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
</PackageReference>-->
<PackageReference Include="SqlSugar.TDengineCore" Version="4.18.8" GeneratePathProperty="true">
<PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
</PackageReference>
<PackageReference Include="TDengine.Ado.Data" Version="3.1.7" GeneratePathProperty="true">
<PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
</PackageReference>
<PackageReference Include="TDengine.Connector" Version="3.1.6" GeneratePathProperty="true">
<PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
@@ -17,5 +38,5 @@
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@@ -8,10 +8,14 @@
// QQ群605534569
//------------------------------------------------------------------------------
using CSScripting;
using SqlSugar;
using System.Reflection;
using ThingsGateway.Extension.Generic;
namespace ThingsGateway.Server;
/// <summary>
@@ -36,8 +40,6 @@ public class SingleFilePublish : ISingleFilePublish
/// <returns></returns>
public string[] IncludeAssemblyNames()
{
InstanceFactory.CustomAssemblies =
[typeof(SqlSugar.TDengine.TDengineProvider).Assembly];
return
[
"ThingsGateway.Furion",

View File

@@ -8,6 +8,7 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
@@ -21,15 +22,16 @@ namespace ThingsGateway.Upgrade;
[AppStartup(-1)]
public class Startup : AppStartup
{
public void ConfigureAdminApp(IServiceCollection services)
public void Configure(IServiceCollection services)
{
services.AddSingleton<IUpdateZipFileHostedService, UpdateZipFileHostedService>();
services.AddSingleton(typeof(IFileHostService), typeof(FileHostService));
services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, IFileHostService>(seriveProvider => seriveProvider.GetService<IFileHostService>()));
services.AddConfigurableOptions<UpgradeServerOptions>();
}
public void UseAdminCore(IServiceProvider serviceProvider)
public void Use(IApplicationBuilder applicationBuilder)
{
var serviceProvider = applicationBuilder.ApplicationServices;
//检查ConfigId
var configIdGroup = DbContext.DbConfigs.GroupBy(it => it.ConfigId);
foreach (var configId in configIdGroup)

View File

@@ -17,8 +17,9 @@ namespace ThingsGateway.Upgrade;
[AppStartup(100000000)]
public class Startup1 : AppStartup
{
public void UseService(IServiceProvider serviceProvider)
public void Use(IApplicationBuilder applicationBuilder)
{
var serviceProvider = applicationBuilder.ApplicationServices;
//检查ConfigId
var configIdGroup = DbContext.DbConfigs.GroupBy(it => it.ConfigId);
foreach (var configId in configIdGroup)

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>10.5.1</Version>
<Version>10.5.2</Version>
</PropertyGroup>
<ItemGroup>