Test commento sezione startup.cs
This commit is contained in:
@@ -1,27 +1,21 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
using HealthChecks.UI.Client;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.UI;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using StackExchange.Redis;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
using System.Text.Json.Serialization;
|
||||
using WebDoorCreator.Data;
|
||||
using WebDoorCreator.Data.Services;
|
||||
using WebDoorCreator.UI;
|
||||
using WebDoorCreator.UI.Areas.Identity;
|
||||
using WebDoorCreator.UI.Data;
|
||||
using static Org.BouncyCastle.Math.EC.ECCurve;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
// configuration setup
|
||||
@@ -30,6 +24,10 @@ Microsoft.Extensions.Configuration.ConfigurationManager configuration = builder.
|
||||
|
||||
// REDIS setup
|
||||
string connStringRedis = configuration.GetConnectionString("Redis");
|
||||
if (string.IsNullOrEmpty(connStringRedis))
|
||||
{
|
||||
connStringRedis = "localhost:6379, DefaultDatabase=11, connectTimeout=5000, syncTimeout=5000, asyncTimeout=5000, abortConnect=false, ssl=false";
|
||||
}
|
||||
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
|
||||
// avvio oggetto shared x redis...
|
||||
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
@@ -37,27 +35,34 @@ var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
// AspNetCore Identity setup
|
||||
var connectionString = configuration.GetConnectionString("Identity.DB");
|
||||
string dbServerAddr = "127.0.0.1";
|
||||
if (connectionString.Contains("Server"))
|
||||
if (string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
bool trovato = false;
|
||||
var dbTokens = connectionString.Split(";");
|
||||
int numTok = dbTokens.Count();
|
||||
int idx = 0;
|
||||
while (!trovato && idx < numTok)
|
||||
connectionString = "Server=SQL2016DEV;Database=WebDoorCreator; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=WebDoorCreator.SRV;";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (connectionString.Contains("Server"))
|
||||
{
|
||||
if (dbTokens[idx].StartsWith("Server="))
|
||||
bool trovato = false;
|
||||
var dbTokens = connectionString.Split(";");
|
||||
int numTok = dbTokens.Count();
|
||||
int idx = 0;
|
||||
while (!trovato && idx < numTok)
|
||||
{
|
||||
// rimuovo la chaive Server...
|
||||
dbServerAddr = dbTokens[idx].Replace("Server=", "");
|
||||
// se ci fosse un nome (tipo \\sqlexpress) rimuovo...
|
||||
if (dbServerAddr.Contains("\\"))
|
||||
if (dbTokens[idx].StartsWith("Server="))
|
||||
{
|
||||
int sIdx = dbServerAddr.IndexOf("\\");
|
||||
dbServerAddr = dbServerAddr.Substring(0, sIdx);
|
||||
// rimuovo la chaive Server...
|
||||
dbServerAddr = dbTokens[idx].Replace("Server=", "");
|
||||
// se ci fosse un nome (tipo \\sqlexpress) rimuovo...
|
||||
if (dbServerAddr.Contains("\\"))
|
||||
{
|
||||
int sIdx = dbServerAddr.IndexOf("\\");
|
||||
dbServerAddr = dbServerAddr.Substring(0, sIdx);
|
||||
}
|
||||
trovato = true;
|
||||
}
|
||||
trovato = true;
|
||||
idx++;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
// healthchecks
|
||||
@@ -73,16 +78,18 @@ builder.Services.AddHealthChecks()
|
||||
.AddAsyncCheck($"Doors Table", () => WebDoorCreator.UI.Health.Checks.DoorsCount(configuration))
|
||||
;
|
||||
|
||||
#if false
|
||||
builder.Services
|
||||
.AddHealthChecksUI(s =>
|
||||
{
|
||||
s.AddHealthCheckEndpoint("WDC_UI_HC", "health");
|
||||
s.SetEvaluationTimeInSeconds(60);
|
||||
s.SetMinimumSecondsBetweenFailureNotifications(120);
|
||||
s.SetApiMaxActiveRequests(5);
|
||||
s.SetHeaderText("WDC.UI Health Check Status");
|
||||
})
|
||||
.AddInMemoryStorage();
|
||||
.AddHealthChecksUI(s =>
|
||||
{
|
||||
s.AddHealthCheckEndpoint("WDC_UI_HC", "health");
|
||||
s.SetEvaluationTimeInSeconds(60);
|
||||
s.SetMinimumSecondsBetweenFailureNotifications(120);
|
||||
s.SetApiMaxActiveRequests(5);
|
||||
s.SetHeaderText("WDC.UI Health Check Status");
|
||||
})
|
||||
.AddInMemoryStorage();
|
||||
#endif
|
||||
|
||||
// abilitazione x email management con MailKit
|
||||
builder.Services.AddTransient<IEmailSender, MailKitEmailSender>();
|
||||
|
||||
Reference in New Issue
Block a user