52bdaec430
- Aggiunto reset shape nell'aggiunta sashGroup - Tolta chiamatareset dict nel cambiare shape split
86 lines
2.9 KiB
C#
86 lines
2.9 KiB
C#
using EgwCoreLib.Lux.Data;
|
|
using EgwCoreLib.Lux.Data.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using NLog;
|
|
using NLog.Web;
|
|
using StackExchange.Redis;
|
|
using System.Reflection;
|
|
using Test.UI.Client.Pages;
|
|
using Test.UI.Components;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
|
|
|
|
var logger = LogManager.Setup()
|
|
.LoadConfigurationFromAppSettings()
|
|
.GetCurrentClassLogger();
|
|
|
|
ConfigurationManager configuration = builder.Configuration;
|
|
logger.Info("Program.cs: startup");
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents()
|
|
.AddInteractiveWebAssemblyComponents();
|
|
|
|
// costruzione connectionMultiplexer redis...
|
|
string connStr = configuration.GetConnectionString("Redis") ?? "localhost";
|
|
ConnectionMultiplexer redisConn = ConnectionMultiplexer.Connect(connStr);
|
|
// registrazione in blocco servizi con metodo extension custom
|
|
var connectionString = builder.Configuration.GetConnectionString("Lux.All") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
|
builder.Services.AddDbContextFactory<DataLayerContext>(options =>
|
|
{
|
|
var conn = builder.Configuration.GetConnectionString("Lux.All");
|
|
options.UseMySql(conn, ServerVersion.AutoDetect(conn), mySqlOptions =>
|
|
{
|
|
mySqlOptions.EnableStringComparisonTranslations();
|
|
})
|
|
.EnableSensitiveDataLogging(false)
|
|
.EnableDetailedErrors(false)
|
|
.LogTo(_ => { }); // disabilita EF logging;
|
|
});
|
|
builder.Services.AddLuxData(connectionString);
|
|
// registro connMultiplexer REDIS
|
|
builder.Services.AddSingleton<IConnectionMultiplexer>(redisConn);
|
|
// registro wrapper servizi REDIS
|
|
builder.Services.AddSingleton<IRedisService, RedisService>();
|
|
builder.Services.AddSingleton<RedisSubscriptionManager>();
|
|
// Aggiunta servizi specifici
|
|
builder.Services.AddSingleton<DataLayerServices>();
|
|
builder.Services.AddSingleton<ImageCacheService>();
|
|
builder.Services.AddSingleton<ConfigDataService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
// aggiunt base URL x routing corretto
|
|
string baseUrl = configuration.GetValue<string>("ServerConf:BaseUrl") ?? "";
|
|
app.UsePathBase(baseUrl);
|
|
logger.Info($"BaseUrl: {baseUrl}");
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseWebAssemblyDebugging();
|
|
}
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode()
|
|
.AddInteractiveWebAssemblyRenderMode()
|
|
.AddAdditionalAssemblies(typeof(Test.UI.Client._Imports).Assembly);
|
|
|
|
app.Run();
|