update x inclusione gestione token (da MenuTop
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<UserSecretsId>60fcdaab-6c1e-4bec-9d88-f7727ef1c12c</UserSecretsId>
|
||||
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
|
||||
<Version>1.0.2301.2616</Version>
|
||||
<Version>1.0.2301.2618</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {}
|
||||
}
|
||||
@@ -1,8 +1,16 @@
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<div class="px-2">
|
||||
<button class="btn btn-primary" @onclick="() => flushCache()" title="Forza Refresh Dati correnti"><i class="fas fa-sync-alt"></i></button>
|
||||
<i class="fas fa-user-alt"></i> <b>@userName</b>
|
||||
</div>
|
||||
<div class="pe-2">
|
||||
<button class="btn btn-primary" @onclick="() => flushCache()" title="Forza Refresh Dati correnti"> Force Reload </button>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn @cssToken" title="Test Token" @onclick="() => fixToken()">
|
||||
<i class="fa-solid fa-cloud"></i>
|
||||
</button>
|
||||
<button type="button" class="btn @cssApi" title="Test Comunicazione">
|
||||
<i class="fa-solid fa-certificate"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,18 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using It.FattureInCloud.Sdk.Api;
|
||||
using It.FattureInCloud.Sdk.Client;
|
||||
using It.FattureInCloud.Sdk.OauthHelper;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.JSInterop;
|
||||
using SHERPA.IM;
|
||||
using SHERPA.IM.Shared;
|
||||
using SHERPA.IM.Data;
|
||||
|
||||
namespace SHERPA.IM.Components
|
||||
@@ -34,23 +25,25 @@ namespace SHERPA.IM.Components
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected SIMDataService SDService { get; set; } = null!;
|
||||
protected MessageService MService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } = null!;
|
||||
[Inject]
|
||||
protected MessageService MService { get; set; } = null!;
|
||||
protected SIMDataService SDService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
initConf();
|
||||
await forceReload();
|
||||
}
|
||||
|
||||
@@ -58,16 +51,27 @@ namespace SHERPA.IM.Components
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool hasToken = false;
|
||||
private bool okApi = false;
|
||||
private string userName = "";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string cssApi
|
||||
{
|
||||
get => okApi ? "bg-primary" : "bg-secondary";
|
||||
}
|
||||
|
||||
private string cssToken
|
||||
{
|
||||
get => hasToken ? "bg-primary" : "bg-secondary";
|
||||
}
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavManager { get; set; } = null!;
|
||||
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
@@ -84,8 +88,50 @@ namespace SHERPA.IM.Components
|
||||
{
|
||||
userName = "N.A.";
|
||||
}
|
||||
// test token locale
|
||||
var accessToken = await MService.getUserTokenAsync();
|
||||
hasToken = !string.IsNullOrEmpty(accessToken);
|
||||
// test comunicazione ocn Fatture in Cloud...
|
||||
if (hasToken)
|
||||
{
|
||||
Configuration config = new Configuration();
|
||||
config.AccessToken = accessToken.Replace(@"\", "");
|
||||
try
|
||||
{
|
||||
var userApiInstance = new UserApi(config);
|
||||
// Retrieve User Companies
|
||||
var userCompaniesResponse = userApiInstance.ListUserCompanies();
|
||||
var firstCompanyId = userCompaniesResponse.Data.Companies[0].Id ?? 0;
|
||||
okApi = firstCompanyId > 0;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
private string JumpUrl = "";
|
||||
private string CLIENT_ID = "Cz12xh57900cepFGMQq8yLAa7x8pcSp4";
|
||||
private string CLIENT_SECRET = "PL6kvy0czp6O5sScpovXo7zXwCtSZLPZGJAWpCPl9wGkFnRYrmw16r8C56aLMXQv\r\n";
|
||||
|
||||
/// <summary>
|
||||
/// Effettua recupero token da fatture in cloud...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task fixToken()
|
||||
{
|
||||
initConf();
|
||||
//string code = HttpContext.Request.Query["code"];
|
||||
//var oauth = new OAuth2AuthorizationCodeManager(CLIENT_ID, CLIENT_SECRET, "https://localhost:7208/index");
|
||||
}
|
||||
|
||||
private async void initConf()
|
||||
{
|
||||
JumpUrl = Configuration.GetValue<string>("Application:JumpUrl");
|
||||
//CLIENT_ID= await SDService.
|
||||
}
|
||||
|
||||
[Inject]
|
||||
private IConfiguration Configuration { get; set; } = null!;
|
||||
private async void MService_EA_ShowSearch()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
|
||||
@@ -14,17 +14,18 @@ else
|
||||
{
|
||||
<table class="table table-striped table-sm small">
|
||||
<thead>
|
||||
<tr class="text-uppercase">
|
||||
<th class="col-2">
|
||||
<button class="btn btn-success btn-sm text-uppercase" @onclick="() => uploadAll()">
|
||||
<i class="fa-solid fa-cloud-arrow-up"></i> ALL
|
||||
<tr>
|
||||
<th>
|
||||
<button class="btn btn-success btn-sm" @onclick="() => syncAll()" title="Sync ALL">
|
||||
<i class="fa-solid fa-cloud-arrow-up"></i>
|
||||
</button>
|
||||
</th>
|
||||
<th>Rag.Soc</th>
|
||||
<th>Rag.Sociale</th>
|
||||
<th>Dati Fiscali</th>
|
||||
<th>Fatt.Elettronica</th>
|
||||
<th>Indirizzo</th>
|
||||
<th>Coord.Fiscali</th>
|
||||
<th>Cod.Univoco</th>
|
||||
<th>Pagamento</th>
|
||||
<th>Note</th>
|
||||
<th>Cloud ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -35,7 +36,7 @@ else
|
||||
<td>
|
||||
@if (string.IsNullOrEmpty(item.IdExt))
|
||||
{
|
||||
<button class="btn btn-sm btn-success"><i class="fa-solid fa-cloud-arrow-up"></i></button>
|
||||
<button class="btn btn-sm btn-success" title="Sync Record" @onclick="() => syncCurrent(item)"><i class="fa-solid fa-cloud-arrow-up"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -46,14 +47,6 @@ else
|
||||
<div>@item.RagSoc</div>
|
||||
<div class="small"><i>@item.IdxGruppo</i></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="small">
|
||||
@item.RagSoc, @item.Localita
|
||||
</div>
|
||||
<div class="small">
|
||||
@item.Cap - @item.Provincia
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="small">VAT: <b>@item.PIva</b></div>
|
||||
<div class="small">C.F.: <b>@item.CFisc</b></div>
|
||||
@@ -62,9 +55,20 @@ else
|
||||
<div class="small">C.U.: <b>@item.CodUnivoco </b></div>
|
||||
<div class="small">PEC: <b>@item.Pec</b></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="small">
|
||||
@item.RagSoc, @item.Localita
|
||||
</div>
|
||||
<div class="small">
|
||||
@item.Cap - @item.Provincia
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="small">@item.Pagamento</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="small">@item.Note</div>
|
||||
</td>
|
||||
<td>@item.IdExt</td>
|
||||
</tr>
|
||||
}
|
||||
@@ -72,3 +76,30 @@ else
|
||||
</table>
|
||||
}
|
||||
}
|
||||
@if (IsSynching)
|
||||
{
|
||||
<dialog class="modal fade show" tabindex="-1" style="display:block; background-color: rgba(10,10,10,.6);" aria-modal="true" role="dialog">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="col-12 text-center my-0 py-5 alert alert-success">
|
||||
<div class="d-flex justify-content-around py-5">
|
||||
<div><i class="fas fa-save fa-5x"></i></div>
|
||||
<div>
|
||||
<h2>Cloud Sync in corso</h2>
|
||||
<i>...un attimo di pazienza...</i>
|
||||
</div>
|
||||
<div><i class="fas fa-paper-plane fa-5x"></i></div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-around py-2">
|
||||
<div><i class="fas fa-circle-notch fa-spin fa-5x"></i></div>
|
||||
</div>
|
||||
<div class="w-100">
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width: 90%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
}
|
||||
@@ -13,9 +13,13 @@ namespace SHERPA.IM.Components
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
private string titleSx = "Cloud Sync";
|
||||
private string titleDx = "running";
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected bool IsLoading { get; set; } = false;
|
||||
protected bool IsSynching { get; set; } = false;
|
||||
|
||||
protected List<CustomerModel> ListRecords { get; set; } = new List<CustomerModel>();
|
||||
|
||||
@@ -40,9 +44,18 @@ namespace SHERPA.IM.Components
|
||||
ListRecords = await SDService.CustomersToSync(TipoDoc, Anno, false);
|
||||
}
|
||||
|
||||
private async Task uploadAll()
|
||||
private async Task syncAll()
|
||||
{
|
||||
await Task.Delay(500);
|
||||
IsSynching = true;
|
||||
await Task.Delay(3000);
|
||||
IsSynching = false;
|
||||
}
|
||||
|
||||
private async Task syncCurrent(CustomerModel currItem)
|
||||
{
|
||||
IsSynching = true;
|
||||
await Task.Delay(1500);
|
||||
IsSynching = false;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
@@ -1,6 +1,78 @@
|
||||
namespace SHERPA.IM.Data
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
using NLog;
|
||||
|
||||
namespace SHERPA.IM.Data
|
||||
{
|
||||
public class MessageService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MessageService(ILocalStorageService genLocalStorage, ISessionStorageService sessStore)
|
||||
{
|
||||
localStorage = genLocalStorage;
|
||||
sessionStore = sessStore;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il valore del token F.I.C. da localstorage
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<string> getUserTokenAsync()
|
||||
{
|
||||
string answ = "";
|
||||
var result = await localStorage.GetItemAsync<string>(KeyTokenFIC);
|
||||
if (result != null)
|
||||
{
|
||||
answ = result;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrive il valore del token F.I.C. nel localstoragee
|
||||
/// </summary>
|
||||
/// <param name="newVal"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> setUserTokenAsync(string newVal)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
await localStorage.SetItemAsync(KeyTokenFIC, newVal);
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Eccezione in setUserTokenAsync{Environment.NewLine}{ex}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected const string KeyTokenFIC = "TokenFIC";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected ILocalStorageService localStorage { get; set; } = null!;
|
||||
|
||||
protected ISessionStorageService sessionStore { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
+171
-142
@@ -1,18 +1,16 @@
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using SHERPA.Data.Controllers;
|
||||
using SHERPA.Data.DbModels;
|
||||
using StackExchange.Redis;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime;
|
||||
|
||||
namespace SHERPA.IM.Data
|
||||
{
|
||||
public class SIMDataService : IDisposable
|
||||
{
|
||||
protected static SInManController dbController = null!;
|
||||
#region Public Constructors
|
||||
|
||||
public SIMDataService(IConfiguration configuration, ILogger<SIMDataService> logger, IConnectionMultiplexer redisConnMult, IEmailSender emailSender)
|
||||
{
|
||||
@@ -44,144 +42,10 @@ namespace SHERPA.IM.Data
|
||||
}
|
||||
_logger.LogInformation("Avviata classe GpwDataService");
|
||||
}
|
||||
protected string CodApp { get; set; } = "";
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
#endregion Public Constructors
|
||||
|
||||
private static ILogger<SIMDataService> _logger = null!;
|
||||
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
|
||||
private static 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!;
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan FastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan LongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan UltraLongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
protected Random rnd = new Random();
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
public async Task<bool> FlushRedisCache()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
RedisValue pattern = new RedisValue($"{redisBaseAddr}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPattern(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConn.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
var keyList = server.Keys(redisDb.Database, pattern);
|
||||
foreach (var item in keyList)
|
||||
{
|
||||
await redisDb.KeyDeleteAsync(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco AccoDoc (Accounting Document) filtrati
|
||||
/// </summary>
|
||||
/// <param name="cFilt">Filtro complessivo di selezione</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<vDocsExplModel>> VDocExplGetFilt(SelectDocExp cFilt)
|
||||
{
|
||||
string source = "DB";
|
||||
List<vDocsExplModel>? dbResult = new List<vDocsExplModel>();
|
||||
string currKey = $"{rKeyDocExp}:{cFilt.Anno}:{cFilt.IdxCli}:{cFilt.CodTipo}:{cFilt.IdxGruppo}:{cFilt.RagSoc}:{cFilt.Inizio:yyyyMMdd}:{cFilt.Fine:yyyyMMdd}:{cFilt.Aperta}:{cFilt.SearchVal}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<vDocsExplModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<vDocsExplModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.VDocExplGetFilt(cFilt.Anno, cFilt.IdxCli, cFilt.CodTipo, cFilt.IdxGruppo, cFilt.RagSoc, cFilt.Inizio, cFilt.Fine, cFilt.Aperta, cFilt.SearchVal);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<vDocsExplModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"VDocExplGetFilt | {source} in: {ts.TotalMilliseconds} ms");
|
||||
return dbResult;
|
||||
}
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Customers che richiedono sync tramite stored
|
||||
@@ -227,6 +91,63 @@ namespace SHERPA.IM.Data
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
public async Task<bool> FlushRedisCache()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
RedisValue pattern = new RedisValue($"{redisBaseAddr}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco AccoDoc (Accounting Document) filtrati
|
||||
/// </summary>
|
||||
/// <param name="cFilt">Filtro complessivo di selezione</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<vDocsExplModel>> VDocExplGetFilt(SelectDocExp cFilt)
|
||||
{
|
||||
string source = "DB";
|
||||
List<vDocsExplModel>? dbResult = new List<vDocsExplModel>();
|
||||
string currKey = $"{rKeyDocExp}:{cFilt.Anno}:{cFilt.IdxCli}:{cFilt.CodTipo}:{cFilt.IdxGruppo}:{cFilt.RagSoc}:{cFilt.Inizio:yyyyMMdd}:{cFilt.Fine:yyyyMMdd}:{cFilt.Aperta}:{cFilt.SearchVal}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<vDocsExplModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<vDocsExplModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.VDocExplGetFilt(cFilt.Anno, cFilt.IdxCli, cFilt.CodTipo, cFilt.IdxGruppo, cFilt.RagSoc, cFilt.Inizio, cFilt.Fine, cFilt.Aperta, cFilt.SearchVal);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<vDocsExplModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"VDocExplGetFilt | {source} in: {ts.TotalMilliseconds} ms");
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public async Task<List<vSelCliModel>> VSelCliGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
@@ -263,6 +184,7 @@ namespace SHERPA.IM.Data
|
||||
Log.Debug($"VSelCliGetAll | {source} in: {ts.TotalMilliseconds} ms");
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public async Task<List<vSelGruppiModel>> VSelGruppiGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
@@ -299,6 +221,7 @@ namespace SHERPA.IM.Data
|
||||
Log.Debug($"VSelGruppiGetAll | {source} in: {ts.TotalMilliseconds} ms");
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public async Task<List<vSelTipoModel>> VSelTipoGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
@@ -336,15 +259,121 @@ namespace SHERPA.IM.Data
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected const string passPhrase = "322DBEDA-E470-421C-B4BB-B04EE3384A6B";
|
||||
protected const string redisBaseAddr = "SHERPA:IM";
|
||||
protected const string rKeyAKV = $"{redisBaseAddr}:Cache:AKV";
|
||||
protected const string rKeyDocExp = $"{redisBaseAddr}:Cache:DocExpFilt";
|
||||
protected const string rKeySelCli = $"{redisBaseAddr}:Cache:vSel:Cli";
|
||||
protected const string rKeySyncCust = $"{redisBaseAddr}:Cache:CloudSync:Cust";
|
||||
protected const string rKeySelGruppi = $"{redisBaseAddr}:Cache:vSel:Gruppi";
|
||||
protected const string rKeySelTipo = $"{redisBaseAddr}:Cache:vSel:Tipo";
|
||||
protected const string rKeySyncCust = $"{redisBaseAddr}:Cache:CloudSync:Cust";
|
||||
protected static SInManController dbController = null!;
|
||||
protected Random rnd = new Random();
|
||||
|
||||
protected const string rKeyAKV = $"{redisBaseAddr}:Cache:AKV";
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected string CodApp { get; set; } = "";
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static ILogger<SIMDataService> _logger = null!;
|
||||
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
|
||||
private static 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
|
||||
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan FastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan LongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
private TimeSpan UltraLongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPattern(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConn.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
var keyList = server.Keys(redisDb.Database, pattern);
|
||||
foreach (var item in keyList)
|
||||
{
|
||||
await redisDb.KeyDeleteAsync(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
@page "/ForceReset"
|
||||
@attribute [Authorize]
|
||||
|
||||
@using SHERPA.IM.Data
|
||||
@inject SIMDataService SDataService
|
||||
@inject NavigationManager NavManager
|
||||
@inject MessageService AppMServ
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Data Reset
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h1>@message</h1>
|
||||
<LoadingData></LoadingData>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
protected string message = "Resetting Cache!";
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await SDataService.FlushRedisCache();
|
||||
|
||||
message = "Reset done!";
|
||||
|
||||
// attendo 1 msec
|
||||
await Task.Delay(1);
|
||||
|
||||
// passo a pagina home
|
||||
NavManager.NavigateTo("");
|
||||
|
||||
//// rimando a pagina corrente
|
||||
//NavManager.NavigateTo(NavManager.Uri, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
@page "/"
|
||||
@page "/Home"
|
||||
@page "/Index"
|
||||
|
||||
<PageTitle>Index</PageTitle>
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
<div class="card-header">filtro</div>
|
||||
<div class="card-body">
|
||||
<ul>
|
||||
<li>Tabella elenco clienti NON ok</li>
|
||||
<li>btn invio in BLOCCO clienti mancanti</li>
|
||||
<li>Tabella elenco fatture NON ok</li>
|
||||
<li>btn invio in BLOCCO fatture</li>
|
||||
<li>btn invio fattura singola da pag esistente</li>
|
||||
|
||||
@@ -5,6 +5,10 @@ using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using SHERPA.IM.Data;
|
||||
using StackExchange.Redis;
|
||||
using SHERPA.Data;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using System.Globalization;
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -54,6 +58,9 @@ builder.Services.AddScoped<MessageService>();
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
|
||||
builder.Services.AddBlazoredLocalStorage();
|
||||
builder.Services.AddBlazoredSessionStorage();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
@@ -64,6 +71,18 @@ if (!app.Environment.IsDevelopment())
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
// cultura IT...
|
||||
var supportedCultures = new[]{
|
||||
new CultureInfo("it-IT")
|
||||
};
|
||||
app.UseRequestLocalization(new RequestLocalizationOptions
|
||||
{
|
||||
DefaultRequestCulture = new RequestCulture("it-IT"),
|
||||
SupportedCultures = supportedCultures,
|
||||
FallBackToParentCultures = false
|
||||
});
|
||||
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("it-IT");
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<WebPublishMethod>MSDeploy</WebPublishMethod>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<SiteUrlToLaunchAfterPublish>https://iis01.egalware.com/SHERPA-AD</SiteUrlToLaunchAfterPublish>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<ProjectGuid>be8a9128-4cbc-4ee9-8b71-fcd7a26f0c92</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
<MSDeployServiceURL>https://iis01.egalware.com:8172/MsDeploy.axd</MSDeployServiceURL>
|
||||
<DeployIisAppPath>Default Web Site/SHERPA-AD</DeployIisAppPath>
|
||||
<RemoteSitePhysicalPath />
|
||||
<SkipExtraFilesOnServer>false</SkipExtraFilesOnServer>
|
||||
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
|
||||
<EnableMSDeployBackup>true</EnableMSDeployBackup>
|
||||
<EnableMsDeployAppOffline>true</EnableMsDeployAppOffline>
|
||||
<UserName>jenkins</UserName>
|
||||
<_SavePWD>true</_SavePWD>
|
||||
<_TargetId>IISWebDeploy</_TargetId>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<WebPublishMethod>MSDeploy</WebPublishMethod>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<SiteUrlToLaunchAfterPublish>https://iis03.egalware.com/SHERPA-AD</SiteUrlToLaunchAfterPublish>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<ProjectGuid>be8a9128-4cbc-4ee9-8b71-fcd7a26f0c92</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
<MSDeployServiceURL>https://iis03.egalware.com:8172/MsDeploy.axd</MSDeployServiceURL>
|
||||
<DeployIisAppPath>Default Web Site/SHERPA-AD</DeployIisAppPath>
|
||||
<RemoteSitePhysicalPath />
|
||||
<SkipExtraFilesOnServer>false</SkipExtraFilesOnServer>
|
||||
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
|
||||
<EnableMSDeployBackup>true</EnableMSDeployBackup>
|
||||
<EnableMsDeployAppOffline>true</EnableMsDeployAppOffline>
|
||||
<UserName>jenkins</UserName>
|
||||
<_SavePWD>true</_SavePWD>
|
||||
<_TargetId>IISWebDeploy</_TargetId>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -10,11 +10,19 @@
|
||||
<Content Remove="compilerconfig.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS01.pubxml" />
|
||||
<_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS03.pubxml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="compilerconfig.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.3.0" />
|
||||
<PackageReference Include="It.FattureInCloud.Sdk" Version="2.0.17" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.13" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.13" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
|
||||
@@ -52,6 +52,12 @@
|
||||
<span class="@hideText">Analisi</span>
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-2">
|
||||
<NavLink class="nav-link" href="ForceReset">
|
||||
<i class="fas fa-sync-alt px-2" ></i>
|
||||
<span class="@hideText">Reset Cache</span>
|
||||
</NavLink>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
"Application": {
|
||||
"ContactText": "Our contacts and support sites",
|
||||
"Name": "SHERPA Invoice Management",
|
||||
"ShortName": "SHERPA IM"
|
||||
"ShortName": "SHERPA IM",
|
||||
"JumpUrl": "https://localhost:7208/index"
|
||||
},
|
||||
"ExternalProviders": {
|
||||
"MailKit": {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"token_type":"bearer","access_token":"a/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZWYiOiJWT2RJYW9OSDhFRUJpWDVtUWE2QldobTYySTJuT3pmdCIsImV4cCI6MTY3NDU2OTcxNH0.JvHS1N18mFTAEbQgADtSo1ZMa4QX7TBL6c8z_Nwv-sk","refresh_token":"r/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZWYiOiI2aXN4S3BmUkdORGZOejkzWjlJWkJiYjVOSUtIbjREWiJ9.P5vvglW742pe7wuXzNIZ4O6LNl87l4uOt7i9zHiTdjw","expires_in":86400}
|
||||
{"token_type":"bearer","access_token":"a/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZWYiOiJoaHJYeG9xc1hFcjdTeDlISFRYVnl5aVM3d0RUQzVTNyIsImV4cCI6MTY3NDgzNTEzOX0.MUqz2X8h3Q4Koymh1DSIiwTj9H08q-3VujUsotWq4dQ","refresh_token":"r/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZWYiOiJzdGZSa2FVS05yVkt2VzU4a25relNEMDk5dDBOR3gzTCJ9.l3YeJK3NW74K72KRjd4lQBtADsGnkozeRGtF5wfxaOI","expires_in":86400}
|
||||
Reference in New Issue
Block a user