修改配置

This commit is contained in:
ChenYi 2025-08-19 16:44:04 +08:00
parent a96a63493c
commit ce768e005c
8 changed files with 56 additions and 31 deletions

View File

@ -1,7 +1,7 @@
# FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
FROM registry.cn-qingdao.aliyuncs.com/jisheyun/aspnetcore:9.0.6_ub24_simsun_pdp_v341 AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 10500
EXPOSE 443
ENV TZ=Asia/Shanghai
ENV ASPNETCORE_ENVIRONMENT=Development

View File

@ -75,6 +75,19 @@
<ItemGroup>
<Folder Include="moduleSwagger\" />
<Folder Include="UploadFile\" />
</ItemGroup>
<ItemGroup>
<Content Update="configs\appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="configs\appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="configs\appsettings.Production.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@ -1,3 +1,5 @@
using Microsoft.Extensions.Configuration;
namespace JiShe.IoT;
public class Program
@ -16,11 +18,21 @@ public class Program
SerilogToEsExtensions.SetSerilogConfiguration(
loggerConfiguration,
context.Configuration);
})
.ConfigureAppConfiguration((context, builder) =>
{
var env = context.HostingEnvironment.EnvironmentName;
Log.Information("µ±Ç°»·¾³ £º" + env);
string[] filePathArray = new string[] { Environment.CurrentDirectory, "configs" };
string jsonPath = Path.Combine(filePathArray);
builder.AddJsonFile(Path.Combine(jsonPath, "appsettings.json"), false, true);
builder.AddJsonFile(Path.Combine(jsonPath, $"appsettings.{env}.json"), false, true);
});
await builder.AddApplicationAsync<JiShe.IoT.IoTHttpApiHostModule>();
#if DEBUG
builder.WebHost.ConfigureKestrel((context, options) => { options.Limits.MaxRequestBodySize = 1024 * 50; });
builder.WebHost.UseUrls($"http://+:10500");
#endif
var app = builder.Build();
await app.InitializeApplicationAsync();
await app.RunAsync();

View File

@ -98,8 +98,8 @@
"UseDistributedCache": true
},
"FreeSqlProviderOptions": {
"UsePrepayDB": true,
"UseEnergyDB": true,
"UsePrepayDB": false,
"UseEnergyDB": false,
"PrintLog": false
},
"OneNETSecureReceiveOptions": {

View File

@ -40,41 +40,41 @@ namespace JiShe.IoT.Data
Logger.LogInformation("Started database migrations...");
await MigrateDatabaseSchemaAsync();
await SeedDataAsync();
//await MigrateDatabaseSchemaAsync();
//await SeedDataAsync();
await InitIoTDBTable();
Logger.LogInformation($"Successfully completed host database migrations.");
//Logger.LogInformation($"Successfully completed host database migrations.");
var tenants = await _tenantRepository.GetListAsync(includeDetails: true);
//var tenants = await _tenantRepository.GetListAsync(includeDetails: true);
var migratedDatabaseSchemas = new HashSet<string>();
foreach (var tenant in tenants)
{
using (_currentTenant.Change(tenant.Id))
{
if (tenant.ConnectionStrings.Any())
{
var tenantConnectionStrings = tenant.ConnectionStrings
.Select(x => x.Value)
.ToList();
//var migratedDatabaseSchemas = new HashSet<string>();
//foreach (var tenant in tenants)
//{
// using (_currentTenant.Change(tenant.Id))
// {
// if (tenant.ConnectionStrings.Any())
// {
// var tenantConnectionStrings = tenant.ConnectionStrings
// .Select(x => x.Value)
// .ToList();
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings))
{
await MigrateDatabaseSchemaAsync(tenant);
// if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings))
// {
// await MigrateDatabaseSchemaAsync(tenant);
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings);
}
}
// migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings);
// }
// }
await SeedDataAsync(tenant);
}
// await SeedDataAsync(tenant);
// }
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations.");
}
// Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations.");
//}
Logger.LogInformation("Successfully completed all database migrations.");
Logger.LogInformation("You can safely end this process...");
//Logger.LogInformation("Successfully completed all database migrations.");
//Logger.LogInformation("You can safely end this process...");
}
private async Task MigrateDatabaseSchemaAsync(Tenant tenant = null)