Fix startup progetto
This commit is contained in:
@@ -1,5 +1,45 @@
|
||||
<h3>CompanyList</h3>
|
||||
|
||||
@code {
|
||||
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm table-striped table-responsive-md border border-dark">
|
||||
<thead>
|
||||
<tr class="bg-dark text-light">
|
||||
<th>
|
||||
@*<button class="btn btn-success btn-sm" @onclick="() => toggleAddNew()"><i class="fas fa-plus"></i></button>*@
|
||||
</th>
|
||||
<th>Company</th>
|
||||
<th>VAT</th>
|
||||
<th class="text-end">Addess</th>
|
||||
<th class="text-end">Guid</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@*@if (!item.Conf)
|
||||
{
|
||||
<button class="btn btn-primary btn-sm" @onclick="() => editRec(item)"><i class="fas fa-pen"></i></button>
|
||||
}*@
|
||||
</td>
|
||||
<td>
|
||||
@item.CompanyName
|
||||
</td>
|
||||
<td>
|
||||
@item.VAT
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@item.Address
|
||||
</td>
|
||||
<td class="text-end">
|
||||
@item.CompanyToken
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WebDoorCreator.Data.DbModels;
|
||||
using WebDoorCreator.UI.Data;
|
||||
|
||||
namespace WebDoorCreator.UI.Components
|
||||
{
|
||||
public partial class CompanyList
|
||||
{
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected WebDoorCreatorService WDService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private List<CompanyModel>? ListRecords = null;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
ListRecords = null;
|
||||
await Task.Delay(1);
|
||||
ListRecords = await WDService.CompanyGetAll();
|
||||
await Task.Delay(1);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
using EgwCoreLib.Razor.Data;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using WebDoorCreator.Data.Controllers;
|
||||
using WebDoorCreator.Data.DbModels;
|
||||
|
||||
@@ -12,21 +10,20 @@ namespace WebDoorCreator.UI.Data
|
||||
{
|
||||
public class WebDoorCreatorService
|
||||
{
|
||||
|
||||
public static WebDoorCreator.Data.Controllers.WebDoorCreatorController dbController = null!;
|
||||
#region Public Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
public static WebDoorCreatorController dbController = null!;
|
||||
|
||||
private static ILogger<WebDoorCreatorController> _logger = null!;
|
||||
#endregion Public Fields
|
||||
|
||||
public WebDoorCreatorService(IConfiguration configuration, ILogger<WebDoorCreatorController> logger, IConnectionMultiplexer redisConnMult, IEmailSender emailSender)
|
||||
#region Public Constructors
|
||||
|
||||
public WebDoorCreatorService(IConfiguration configuration, IConnectionMultiplexer redisConnMult, IEmailSender emailSender)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
_emailSender = emailSender;
|
||||
// Conf cache
|
||||
redisConn = redisConnMult;// ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
//redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
redisConn = redisConnMult;
|
||||
redisDb = this.redisConn.GetDatabase();
|
||||
|
||||
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
|
||||
@@ -34,51 +31,31 @@ namespace WebDoorCreator.UI.Data
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
};
|
||||
|
||||
// cod app
|
||||
CodApp = _configuration["CodApp"];
|
||||
// Conf DB
|
||||
string connStr = _configuration.GetConnectionString("WDC.DB");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
_logger.LogError("ConnString empty!");
|
||||
Log.Info("ConnString empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new WebDoorCreatorController(configuration);
|
||||
}
|
||||
_logger.LogInformation("Avviata classe WebDoorCreatorService");
|
||||
Log.Info("Avviata classe WebDoorCreatorService");
|
||||
}
|
||||
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
#endregion Public Constructors
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly IEmailSender _emailSender;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
private IConnectionMultiplexer redisConn;
|
||||
|
||||
//ISubscriber sub = redis.GetSubscriber();
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
private IDatabase redisDb = null!;
|
||||
#region Public Properties
|
||||
|
||||
public string CodApp { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco AKV
|
||||
@@ -122,6 +99,54 @@ namespace WebDoorCreator.UI.Data
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected const string passPhrase = "9eb4660f-8753-46bc-b23b-08759ba03fe9";
|
||||
|
||||
//#region Protected Fields
|
||||
protected const string redisBaseAddr = "WDC";
|
||||
|
||||
//#endregion Public Methods
|
||||
protected const string rKeyCompany = $"{redisBaseAddr}:Cache:Company";
|
||||
|
||||
protected Random rnd = new Random();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly IEmailSender _emailSender;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
private IConnectionMultiplexer redisConn;
|
||||
|
||||
//ISubscriber sub = redis.GetSubscriber();
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
private IDatabase redisDb = null!;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
//#endregion Public Constructors
|
||||
|
||||
@@ -130,7 +155,6 @@ namespace WebDoorCreator.UI.Data
|
||||
|
||||
//#region Public Methods
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// Recupera l'elenco fasi (tutte)
|
||||
///// </summary>
|
||||
@@ -1381,17 +1405,6 @@ namespace WebDoorCreator.UI.Data
|
||||
// { }
|
||||
// return answ;
|
||||
//}
|
||||
|
||||
//#endregion Public Methods
|
||||
|
||||
//#region Protected Fields
|
||||
|
||||
protected const string passPhrase = "9eb4660f-8753-46bc-b23b-08759ba03fe9";
|
||||
|
||||
protected const string redisBaseAddr = "WDC";
|
||||
|
||||
protected const string rKeyCompany = $"{redisBaseAddr}:Cache:Company";
|
||||
|
||||
//protected const string rKeyAnOrDip = $"{redisBaseAddr}:Cache:AnOrariDip";
|
||||
|
||||
//protected const string rKeyCalcOreFase = $"{redisBaseAddr}:Cache:CalcOreFase";
|
||||
@@ -1437,9 +1450,6 @@ namespace WebDoorCreator.UI.Data
|
||||
//protected const string rKeyWeekStats = $"{redisBaseAddr}:Cache:WeekStats";
|
||||
|
||||
//protected static string connStringBBM = "";
|
||||
|
||||
protected Random rnd = new Random();
|
||||
|
||||
//#endregion Protected Fields
|
||||
|
||||
//#region Protected Methods
|
||||
@@ -1471,16 +1481,14 @@ namespace WebDoorCreator.UI.Data
|
||||
|
||||
//#region Private Fields
|
||||
|
||||
|
||||
|
||||
//private List<string> cachedDataList = new List<string>();
|
||||
|
||||
|
||||
|
||||
//#endregion Private Fields
|
||||
|
||||
//#region Private Properties
|
||||
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
@@ -1505,6 +1513,8 @@ namespace WebDoorCreator.UI.Data
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
//#endregion Private Properties
|
||||
|
||||
//#region Private Methods
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.UI;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using StackExchange.Redis;
|
||||
using System.Globalization;
|
||||
using WebDoorCreator.Data;
|
||||
using WebDoorCreator.UI.Areas.Identity;
|
||||
using WebDoorCreator.UI.Data;
|
||||
@@ -13,6 +17,8 @@ using WebDoorCreator.UI.Data;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
// configuration setup
|
||||
ConfigurationManager configuration = builder.Configuration;
|
||||
|
||||
// AspNetCore Identity setup
|
||||
var connectionString = builder.Configuration.GetConnectionString("Identity.DB");
|
||||
|
||||
// REDIS setup
|
||||
@@ -32,15 +38,22 @@ builder.Services.Configure<MailKitEmailSenderOptions>(options =>
|
||||
options.Sender_EMail = configuration["ExternalProviders:MailKit:SMTP:SenderEmail"];
|
||||
options.Sender_Name = configuration["ExternalProviders:MailKit:SMTP:SenderName"];
|
||||
});
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
||||
options.UseSqlServer(connectionString));
|
||||
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
||||
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddSingleton<WebDoorCreatorService>();
|
||||
builder.Services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<IdentityUser>>();
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
builder.Services.AddBlazoredLocalStorage();
|
||||
builder.Services.AddBlazoredSessionStorage();
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
@@ -55,6 +68,18 @@ else
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
// cultura US...
|
||||
var supportedCultures = new[]{
|
||||
new CultureInfo("en-US")
|
||||
};
|
||||
app.UseRequestLocalization(new RequestLocalizationOptions
|
||||
{
|
||||
DefaultRequestCulture = new RequestCulture("en-US"),
|
||||
SupportedCultures = supportedCultures,
|
||||
FallBackToParentCultures = false
|
||||
});
|
||||
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="fetchdata">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
|
||||
<NavLink class="nav-link" href="CompanyMan">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Company Man
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
|
||||
@@ -9,4 +9,5 @@
|
||||
@using WebDoorCreator.UI
|
||||
@using WebDoorCreator.UI.Components
|
||||
@using WebDoorCreator.UI.Shared
|
||||
@using WebDoorCreator.Data.DbModels
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"Identity.DB": "Server=SQL2016DEV;Database=WebDoorCreator; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=WebDoorCreator.UI;",
|
||||
"Redis": "localhost:6379,DefaultDatabase=15,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false",
|
||||
"Redis": "localhost:6379,DefaultDatabase=11,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false",
|
||||
"WDC.DB": "Server=SQL2016DEV;Database=WebDoorCreator; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=WebDoorCreator.UI;"
|
||||
},
|
||||
"ExternalProviders": {
|
||||
|
||||
Reference in New Issue
Block a user