修改配置

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 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 FROM registry.cn-qingdao.aliyuncs.com/jisheyun/aspnetcore:9.0.6_ub24_simsun_pdp_v341 AS base
WORKDIR /app WORKDIR /app
EXPOSE 8080 EXPOSE 10500
EXPOSE 443 EXPOSE 443
ENV TZ=Asia/Shanghai ENV TZ=Asia/Shanghai
ENV ASPNETCORE_ENVIRONMENT=Development ENV ASPNETCORE_ENVIRONMENT=Development

View File

@ -75,6 +75,19 @@
<ItemGroup> <ItemGroup>
<Folder Include="moduleSwagger\" /> <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> </ItemGroup>
</Project> </Project>

View File

@ -1,3 +1,5 @@
using Microsoft.Extensions.Configuration;
namespace JiShe.IoT; namespace JiShe.IoT;
public class Program public class Program
@ -16,11 +18,21 @@ public class Program
SerilogToEsExtensions.SetSerilogConfiguration( SerilogToEsExtensions.SetSerilogConfiguration(
loggerConfiguration, loggerConfiguration,
context.Configuration); 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>(); await builder.AddApplicationAsync<JiShe.IoT.IoTHttpApiHostModule>();
#if DEBUG builder.WebHost.ConfigureKestrel((context, options) => { options.Limits.MaxRequestBodySize = 1024 * 50; });
builder.WebHost.UseUrls($"http://+:10500"); builder.WebHost.UseUrls($"http://+:10500");
#endif
var app = builder.Build(); var app = builder.Build();
await app.InitializeApplicationAsync(); await app.InitializeApplicationAsync();
await app.RunAsync(); await app.RunAsync();

View File

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

View File

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