115 lines
3.6 KiB
C#
115 lines
3.6 KiB
C#
using Blazored.LocalStorage;
|
|
using Blazored.SessionStorage;
|
|
using GPW.CORE.Data;
|
|
using GPW.CORE.Services;
|
|
using GPW.CORE.Smart10.Client.Services;
|
|
using GPW.CORE.Smart10.Components;
|
|
using GPW.CORE.Smart10.Data;
|
|
using GPW.CORE.Smart8.Data;
|
|
using Microsoft.AspNetCore.Identity.UI.Services;
|
|
using Microsoft.AspNetCore.Localization;
|
|
using NLog;
|
|
using NLog.Web;
|
|
using StackExchange.Redis;
|
|
using System.Globalization;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
var env = builder.Environment;
|
|
|
|
var logger = LogManager.Setup()
|
|
.LoadConfigurationFromAppSettings()
|
|
.GetCurrentClassLogger();
|
|
|
|
ConfigurationManager configuration = builder.Configuration;
|
|
logger.Info("GPW.Smart10 | Program.cs: startup");
|
|
logger.Info($"Current ASPNETCORE_ENVIRONMENT: {env.EnvironmentName}");
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents()
|
|
.AddInteractiveWebAssemblyComponents();
|
|
|
|
// Enable Controllers
|
|
builder.Services.AddControllers();
|
|
|
|
// REDIS setup
|
|
string connStringRedis = configuration.GetConnectionString("Redis")!;
|
|
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
|
|
|
// abilitazione x email management con MailKit
|
|
builder.Services.AddTransient<IEmailSender, MailKitEmailSender>();
|
|
|
|
builder.Services.Configure<MailKitEmailSenderOptions>(options =>
|
|
{
|
|
options.Host_Address = configuration["ExternalProviders:MailKit:SMTP:Address"]!;
|
|
options.Host_Port = Convert.ToInt32(configuration["ExternalProviders:MailKit:SMTP:Port"]);
|
|
options.Host_Username = configuration["ExternalProviders:MailKit:SMTP:Account"]!;
|
|
options.Host_Password = configuration["ExternalProviders:MailKit:SMTP:Password"]!;
|
|
options.Sender_EMail = configuration["ExternalProviders:MailKit:SMTP:SenderEmail"]!;
|
|
options.Sender_Name = configuration["ExternalProviders:MailKit:SMTP:SenderName"]!;
|
|
});
|
|
|
|
// Smart8 Services (ported to Smart10)
|
|
builder.Services.AddSingleton<CoreSmartDataService>();
|
|
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
|
builder.Services.AddSingleton<RouteModeService>();
|
|
//builder.Services.AddSingleton<LicenseServiceLoc>();
|
|
//builder.Services.AddScoped<MessageServiceLoc>();
|
|
builder.Services.AddScoped<UserStateService>();
|
|
builder.Services.AddScoped<UIMessageService>();
|
|
|
|
// Smart10 Services
|
|
builder.Services.AddScoped<ITimbraturesService, TimbraturesServiceServer>();
|
|
|
|
builder.Services.AddHttpContextAccessor();
|
|
|
|
builder.Services.AddBlazoredLocalStorage();
|
|
builder.Services.AddBlazoredSessionStorage();
|
|
|
|
var app = builder.Build();
|
|
|
|
// 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.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
|
|
|
|
|
// cultura IT...
|
|
var supportedCultures = new[]{
|
|
new CultureInfo("it-IT")
|
|
};
|
|
app.UseRequestLocalization(new RequestLocalizationOptions
|
|
{
|
|
DefaultRequestCulture = new RequestCulture("it-IT"),
|
|
SupportedCultures = supportedCultures,
|
|
FallBackToParentCultures = false
|
|
});
|
|
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("it-IT");
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
|
|
app.MapStaticAssets();
|
|
|
|
// Map Controllers
|
|
app.MapControllers();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode()
|
|
.AddInteractiveWebAssemblyRenderMode()
|
|
.AddAdditionalAssemblies(typeof(GPW.CORE.Smart10.Client._Imports).Assembly);
|
|
|
|
app.Run();
|
|
|