Merge branch 'master' into develop

This commit is contained in:
Samuele Locatelli
2022-11-16 11:46:12 +01:00
23 changed files with 674 additions and 427 deletions
+45 -115
View File
@@ -24,11 +24,6 @@ variables:
dotnet nuget add source https://nexus.steamware.net/repository/nuget-proxy-v3/index.json -n nexus-proxy-v3 -u nugetUser -p viaDante16 --store-password-in-clear-text
echo "Has Source: $hasSource"
.fixVers: &fixVers
- |
$VersScript = $env:APP_NAME + "\bin\publish\post-build.ps1 -ProjectDir $CI_PROJECT_DIR\$env:APP_NAME -ProjectPath $CI_PROJECT_DIR\$env:APP_NAME\$env:APP_NAME.csproj"
echo "Script called: $VersScript"
# helper creazione hash files x IIS
.hashBuild: &hashBuild
- |
@@ -265,7 +260,8 @@ LAND:IIS01:deploy:
- develop
needs: ["LAND:test"]
script:
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
PROG:IIS01:deploy:
stage: deploy
@@ -281,7 +277,8 @@ PROG:IIS01:deploy:
- develop
needs: ["PROG:test"]
script:
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
STAT:IIS01:deploy:
stage: deploy
@@ -297,7 +294,8 @@ STAT:IIS01:deploy:
- develop
needs: ["STAT:test"]
script:
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
MON:IIS01:deploy:
stage: deploy
@@ -313,24 +311,8 @@ MON:IIS01:deploy:
- develop
needs: ["MON:test"]
script:
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
# WAMON:IIS01:deploy:
# stage: deploy
# tags:
# - win
# variables:
# PROJ_PATH: MP.WASM.Mon\Server
# APP_NAME: MP.WASM.Mon.Server
# SOL_NAME: MP-WAMON
# before_script:
# - *nuget-fix
# - dotnet restore "$env:SOL_NAME.sln"
# only:
# - develop
# needs: ["WAMON:test"]
# script:
# - dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:PROJ_PATH/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
SPEC:IIS01:deploy:
stage: deploy
@@ -346,7 +328,8 @@ SPEC:IIS01:deploy:
- develop
needs: ["SPEC:test"]
script:
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
LAND:IIS02:deploy:
stage: deploy
@@ -362,8 +345,9 @@ LAND:IIS02:deploy:
- master
needs: ["LAND:build"]
script:
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
PROG:IIS02:deploy:
stage: deploy
@@ -379,8 +363,9 @@ PROG:IIS02:deploy:
- master
needs: ["PROG:build"]
script:
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
STAT:IIS02:deploy:
stage: deploy
@@ -396,8 +381,9 @@ STAT:IIS02:deploy:
- master
needs: ["STAT:build"]
script:
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
MON:IIS02:deploy:
stage: deploy
@@ -413,26 +399,9 @@ MON:IIS02:deploy:
- master
needs: ["MON:build"]
script:
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
# WAMON:IIS02:deploy:
# stage: deploy
# tags:
# - win
# variables:
# PROJ_PATH: MP.WASM.Mon\Server
# APP_NAME: MP.WASM.Mon.Server
# SOL_NAME: MP-WAMON
# before_script:
# - *nuget-fix
# - dotnet restore "$env:SOL_NAME.sln"
# only:
# - master
# needs: ["WAMON:build"]
# script:
# - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:PROJ_PATH/$env:APP_NAME.csproj
# - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:PROJ_PATH/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
SPEC:IIS02:deploy:
stage: deploy
@@ -448,8 +417,9 @@ SPEC:IIS02:deploy:
- master
needs: ["SPEC:build"]
script:
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj
LAND:installer:
stage: installer
@@ -467,9 +437,9 @@ LAND:installer:
- master
needs: ["LAND:build"]
script:
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish -p:verbosity=quiet
# qui il deploy su nexus...
- *fixVers
- *hashBuild
- *nexusUpload
@@ -489,9 +459,9 @@ PROG:installer:
- master
needs: ["PROG:build"]
script:
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish -p:verbosity=quiet
# qui il deploy su nexus...
- *fixVers
- *hashBuild
- *nexusUpload
@@ -511,9 +481,9 @@ STAT:installer:
- master
needs: ["STAT:build"]
script:
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish -p:verbosity=quiet
# qui il deploy su nexus...
- *fixVers
- *hashBuild
- *nexusUpload
@@ -533,34 +503,12 @@ MON:installer:
- master
needs: ["MON:build"]
script:
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish -p:verbosity=quiet
# qui il deploy su nexus...
- *fixVers
- *hashBuild
- *nexusUpload
# WAMON:installer:
# stage: installer
# tags:
# - win
# variables:
# PROJ_PATH: MP.WASM.Mon\Server
# APP_NAME: MP.WASM.Mon.Server
# SOL_NAME: MP-WAMON
# NEXUS_PATH: MP-WAMON
# before_script:
# - *nuget-fix
# - dotnet restore "$env:SOL_NAME.sln"
# only:
# - develop
# - master
# needs: ["WAMON:build"]
# script:
# - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:PROJ_PATH/$env:APP_NAME.csproj -o:publish
# # qui il deploy su nexus...
# - *hashBuild
# - *nexusUpload
SPEC:installer:
stage: installer
tags:
@@ -577,9 +525,9 @@ SPEC:installer:
- master
needs: ["SPEC:build"]
script:
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish -p:verbosity=quiet
# qui il deploy su nexus...
- *fixVers
- *hashBuild
- *nexusUpload
@@ -605,7 +553,8 @@ LAND:release:
paths:
- publish/
script:
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj -p:verbosity=quiet
PROG:release:
stage: release
@@ -629,7 +578,8 @@ PROG:release:
paths:
- publish/
script:
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj -p:verbosity=quiet
STAT:release:
stage: release
@@ -653,7 +603,8 @@ STAT:release:
paths:
- publish/
script:
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj -p:verbosity=quiet
MON:release:
stage: release
@@ -675,30 +626,8 @@ MON:release:
paths:
- publish/
script:
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj
# WAMON:release:
# stage: release
# tags:
# - win
# variables:
# PROJ_PATH: MP.WASM.Mon\Server
# APP_NAME: MP.WASM.Mon.Server
# SOL_NAME: MP-WAMON
# NEXUS_PATH: MP-WAMON
# before_script:
# - *nuget-fix
# - dotnet restore "$env:SOL_NAME.sln"
# only:
# - tags
# except:
# - branches
# needs: ["WAMON:build"]
# artifacts:
# paths:
# - publish/
# script:
# - dotnet publish -c Release -o ./publish $env:PROJ_PATH/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj -p:verbosity=quiet
SPEC:release:
stage: release
@@ -720,5 +649,6 @@ SPEC:release:
paths:
- publish/
script:
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj -p:verbosity=quiet
+10 -6
View File
@@ -23,18 +23,20 @@ namespace Egw.Core
public static string DecryptString(string Message, string Passphrase)
{
string answ = Message;
byte[] Results = null;
byte[] Results = new byte[8];
UTF8Encoding UTF8 = new UTF8Encoding();
// Step 1. We hash the passphrase using MD5
// We use the MD5 hash generator as the result is a 128 bit byte array
// which is a valid length for the TripleDES encoder we use below
MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
var HashProvider = MD5.Create();
//MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));
// Step 2. Create a new TripleDESCryptoServiceProvider object
TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();
var TDESAlgorithm = TripleDES.Create();
//TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();
// Step 3. Setup the decoder
TDESAlgorithm.Key = TDESKey;
@@ -42,7 +44,7 @@ namespace Egw.Core
TDESAlgorithm.Padding = PaddingMode.PKCS7;
// Step 4. Convert the input string to a byte[]
byte[] DataToDecrypt = null;
byte[] DataToDecrypt = new byte[8];
try
{
DataToDecrypt = Convert.FromBase64String(Message);
@@ -84,11 +86,13 @@ namespace Egw.Core
// We use the MD5 hash generator as the result is a 128 bit byte array
// which is a valid length for the TripleDES encoder we use below
MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
var HashProvider = MD5.Create();
//MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));
// Step 2. Create a new TripleDESCryptoServiceProvider object
TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();
var TDESAlgorithm = TripleDES.Create();
//TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();
// Step 3. Setup the encoder
TDESAlgorithm.Key = TDESKey;
+1 -1
View File
@@ -39,7 +39,7 @@ namespace Egw.Core
}
answ = Convert.ToDateTime(datePart);
}
catch (Exception exc)
catch //(Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore decodifica auth key:{0}AuthKey: {1}{0}cliente:{2}{0}applicativo:{3}{0}errore:{4}", Environment.NewLine, authKey, cliente, applicativo, exc), tipoLog.EXCEPTION);
}
+39 -2
View File
@@ -1,13 +1,14 @@
using Blazored.SessionStorage;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Configuration;
using Microsoft.JSInterop;
using MP.Data.DTO;
using MP.INVE.Data;
namespace MP.INVE.Components
{
public partial class CmpTop
public partial class CmpTop:IDisposable
{
#region Public Methods
@@ -42,6 +43,8 @@ namespace MP.INVE.Components
protected override async Task OnInitializedAsync()
{
LServ.EA_LogIn += LServ_EA_LogIn;
LServ.EA_LogOut += LServ_EA_LogOut;
await forceReload();
}
protected async Task getId()
@@ -58,11 +61,20 @@ namespace MP.INVE.Components
}
}
private void LServ_EA_LogOut()
{
NavManager.NavigateTo("OperatoreLogin", true);
}
private void LServ_EA_LogIn()
{
NavManager.NavigateTo("Starter", true);
}
#endregion Protected Methods
#region Private Fields
private string userName = "";
#endregion Private Fields
@@ -79,7 +91,32 @@ namespace MP.INVE.Components
private async Task forceReload()
{
<<<<<<< HEAD
await Task.Delay(1);
// controllo per login
if (LServ.matrOpr <= 0 && !NavManager.Uri.Contains("OperatoreLogin"))
{
NavManager.NavigateTo("OperatoreLogin", true);
}
}
private async Task logOut()
{
await Task.Delay(1);
LServ.LogOut();
}
private string userName
{
get
{
string answ = "ND";
answ = $"{LServ.Cognome} {LServ.Cognome} ({LServ.matrOpr})";
return answ;
}
=======
await getId();
>>>>>>> develop
}
private async void MService_EA_ShowSearch()
+255
View File
@@ -0,0 +1,255 @@
using MP.Data.DTO;
using Newtonsoft.Json;
using NLog;
using StackExchange.Redis;
using System.Diagnostics;
namespace MP.INVE.Data
{
public class LoginService : IDisposable
{
#region Public Constructors
public LoginService(IConfiguration configuration, ILogger<LoginService> logger, HttpClient httpClient,
IHttpContextAccessor httpContextAccessor)
{
this.HttpClient = httpClient;
HttpContextAccessor = httpContextAccessor;
_logger = logger;
_logger.LogInformation("Starting LoginService INIT");
_configuration = configuration;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin"));
redisDb = redisConn.GetDatabase();
// leggo cache lungo periodo
int.TryParse(_configuration.GetValue<string>("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
_logger.LogInformation("Redis LoginService INIT");
}
#endregion Public Constructors
#region Public Events
public event Action EA_LogIn = null!;
public event Action EA_LogOut = null!;
#endregion Public Events
#region Public Properties
public string Cognome
{
get
{
string answ = "NA";
if (matrOpr > 0 && !string.IsNullOrEmpty(authKey))
{
var currUser = UserDTO(matrOpr, authKey);
if (currUser != null)
{
answ = currUser.Cognome;
}
}
return answ;
}
}
public int matrOpr
{
get
{
int answ = 0;
if (HttpContextAccessor.HttpContext != null)
{
#if false
var token = HttpContextAccessor.HttpContext.Request.Cookies["userId_token"];
if (token != null)
{
int.TryParse(token, out answ);
}
#endif
var currUser = UserDTO(matrOpr, authKey);
if (currUser != null)
{
answ = currUser.MatrOpr;
}
}
return answ;
}
set
{
CookieOptions options = new CookieOptions();
options.Expires = DateTime.Now.AddDays(1);
if (HttpContextAccessor.HttpContext != null)
{
HttpContextAccessor.HttpContext.Response.Cookies.Append("userId_token", $"{value}", options);
}
}
}
public string Nome
{
get
{
string answ = "NA";
if (matrOpr > 0 && !string.IsNullOrEmpty(authKey))
{
var currUser = UserDTO(matrOpr, authKey);
if (currUser != null)
{
answ = currUser.Nome;
}
}
return answ;
}
}
#endregion Public Properties
#region Public Methods
public void Dispose()
{
}
public void LogOut()
{
OperatoreDTO resetData = new OperatoreDTO();
UserDTOSave(resetData);
}
/// <summary>
/// Ricerca su REDIS dell'utente loggato
/// NB: da rifare con unico JWT che contenga tutto
/// </summary>
/// <param name="matrOpr"></param>
/// <param name="authKey"></param>
/// <returns></returns>
public OperatoreDTO? UserDTO(int matrOpr, string authKey)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
OperatoreDTO? result = null;
string source = "REDIS";
// cerco in redis...
RedisValue rawData = redisDb.StringGet($"{redisUserSession}:{matrOpr}");
if (!string.IsNullOrEmpty($"{rawData}"))
{
try
{
result = JsonConvert.DeserializeObject<OperatoreDTO>($"{rawData}");
}
catch
{ }
}
#if false
else
{
result = await Task.FromResult(dbController.AnagStatiComm());
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
await redisDb.StringSetAsync(redisUserSession, rawData, getRandTOut(redisLongTimeCache));
source = "DB";
}
#endif
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"LoggedUser Read from {source}: {ts.TotalMilliseconds}ms");
// restituisco
return result;
}
/// <summary>
/// Salva su REDIS dati dell'utente loggato
/// </summary>
/// <returns></returns>
public bool UserDTOSave(OperatoreDTO userData)
{
bool fatto = false;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string source = "REDIS";
// cerco in redis...
string rawData = JsonConvert.SerializeObject(userData);
fatto = redisDb.StringSet($"{redisUserSession}:{userData.MatrOpr}", rawData, TimeSpan.FromMinutes(60));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"UserDTO write to {source}: {ts.TotalMilliseconds}ms");
// restituisco
return fatto;
}
#endregion Public Methods
#region Protected Properties
protected string authKey
{
get
{
string answ = "";
if (HttpContextAccessor.HttpContext != null)
{
var token = HttpContextAccessor.HttpContext.Request.Cookies["authKey_token"];
if (token != null)
{
answ = token;
}
}
return answ;
}
set
{
CookieOptions options = new CookieOptions();
options.Expires = DateTime.Now.AddDays(1);
if (HttpContextAccessor.HttpContext != null)
{
HttpContextAccessor.HttpContext.Response.Cookies.Append("authKey_token", value, options);
}
}
}
protected HttpClient HttpClient { get; set; }
protected IHttpContextAccessor HttpContextAccessor { get; set; }
#endregion Protected Properties
#region Private Fields
private const string redisBaseAddr = "MP:INVE";
private const string redisUserSession = redisBaseAddr + ":User:";
private static IConfiguration _configuration = null!;
private static ILogger<LoginService> _logger = null!;
private static Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
private ConnectionMultiplexer redisConn = null!;
/// <summary>
/// Oggetto per connessione a REDIS modalità admin (ex flux dati)
/// </summary>
private ConnectionMultiplexer redisConnAdmin = null!;
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
private IDatabase redisDb = null!;
private int redisLongTimeCache = 5;
#endregion Private Fields
}
}
+1 -1
View File
@@ -53,7 +53,7 @@
get => searchVal;
set
{
//if (searchVal != value)
//if (_nome != value)
//{
searchVal = value;
+16 -16
View File
@@ -1090,37 +1090,37 @@ namespace MP.INVE.Data
#region Private Fields
private const string redisArtByDossier = redisBaseAddr + "SPEC:Cache:ArtByDossier";
private const string redisArtByDossier = redisBaseAddr + ":Cache:ArtByDossier";
private const string redisArtList = redisBaseAddr + "SPEC:Cache:ArtList";
private const string redisArtList = redisBaseAddr + ":Cache:ArtList";
private const string redisBaseAddr = "MP:";
private const string redisBaseAddr = "MP:SPEC";
private const string redisConfKey = redisBaseAddr + "SPEC:Cache:Config";
private const string redisConfKey = redisBaseAddr + ":Cache:Config";
private const string redisDossByMac = redisBaseAddr + "SPEC:Cache:DossByMac";
private const string redisDossByMac = redisBaseAddr + ":Cache:DossByMac";
private const string redisFluxByMac = redisBaseAddr + "SPEC:Cache:FluxByMac";
private const string redisFluxByMac = redisBaseAddr + ":Cache:FluxByMac";
private const string redisFluxLogFilt = redisBaseAddr + "SPEC:Cache:FluxLogFilt";
private const string redisFluxLogFilt = redisBaseAddr + ":Cache:FluxLogFilt";
private const string redisMacByFlux = redisBaseAddr + "SPEC:Cache:MacByFlux";
private const string redisMacByFlux = redisBaseAddr + ":Cache:MacByFlux";
private const string redisMacList = redisBaseAddr + "SPEC:Cache:MacList";
private const string redisMacList = redisBaseAddr + ":Cache:MacList";
private const string redisOdlCurrByMac = redisBaseAddr + "SPEC:Cache:OdlByMac";
private const string redisOdlCurrByMac = redisBaseAddr + ":Cache:OdlByMac";
private const string redisPOdlList = redisBaseAddr + "SPEC:Cache:POdlList";
private const string redisPOdlList = redisBaseAddr + ":Cache:POdlList";
private const string redisPOdlByPOdl = redisBaseAddr + "SPEC:Cache:POdlByPOdl";
private const string redisPOdlByPOdl = redisBaseAddr + ":Cache:POdlByPOdl";
private const string redisPOdlByOdl = redisBaseAddr + "SPEC:Cache:POdlByOdl";
private const string redisPOdlByOdl = redisBaseAddr + ":Cache:POdlByOdl";
private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom";
private const string redisStatoCom = redisBaseAddr + ":Cache:StatoCom";
private const string redisTipoArt = redisBaseAddr + "SPEC:Cache:TipoArt";
private const string redisTipoArt = redisBaseAddr + ":Cache:TipoArt";
private const string redisVocabolario = redisBaseAddr + "SPEC:Cache:Vocabolario";
private const string redisVocabolario = redisBaseAddr + ":Cache:Vocabolario";
private static IConfiguration _configuration = null!;
+1
View File
@@ -36,6 +36,7 @@ builder.Services.AddAuthorization(options =>
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddHttpContextAccessor();
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
builder.Services.AddSingleton<MiDataService>();
builder.Services.AddScoped<MessageService>();
+5 -5
View File
@@ -185,8 +185,8 @@ Invio aggregato dei dati di
# Revisione Documento
| Date | Edit | Version | Note |
|------------|----------------|:-------:|-----------------:|
| 2022.11.10 | S.E. Locatelli | 0.1 | Initial draft |
| 2022.11.10 | Gian / Zac | 0.2 | Second draft |
| 2022.11.16 | Zac | 0.3 | Aggiunta condizione modifica previo controllo esistenza |
| Date | Edit | Version | Note |
| ---------- | -------------- | :-----: | ------------------------------------------------------: |
| 2022.11.10 | S.E. Locatelli | 0.1 | Initial draft |
| 2022.11.10 | Gian / Zac | 0.2 | Second draft |
| 2022.11.16 | Zac | 0.3 | Aggiunta condizione modifica previo controllo esistenza |
Binary file not shown.
+2 -2
View File
@@ -4,12 +4,12 @@
@using MP.Land.Data
@inject MessageService AppMessages
@*@inject AuthenticationStateProvider AuthenticationStateProvider*@
@inject AuthenticationStateProvider AuthenticationStateProvider
<div class="form-row pt-3">
<div class="col-7 col-md-6 col-lg-4 col-xl-3">
@*<LoginDisplay></LoginDisplay>*@
@*<i class="fas fa-user-alt"></i> <b>@userName</b>*@
<i class="fas fa-user-alt"></i> <b>@userName</b>
</div>
<div class="col-12 col-lg-4 col-xl-6 d-none d-lg-block text-center h4 text-truncate">
<span class="@PageIcon" aria-hidden="true"></span> @PageName
+11 -14
View File
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using System;
using System.Threading.Tasks;
@@ -62,20 +63,16 @@ namespace MP.Land.Components
private async Task forceReload()
{
userName = "N.A.";
await Task.Delay(1);
#if false
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
userName = $"{user.Identity.Name}";
}
else
{
userName = "N.A.";
}
#endif
await Task.Delay(1); var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity != null && user.Identity.IsAuthenticated)
{
userName = $"{user.Identity.Name}";
}
else
{
userName = "N.A.";
}
}
#endregion Private Methods
+263 -253
View File
@@ -12,6 +12,8 @@ using System.Text;
using System.Threading.Tasks;
using System.Web;
#nullable enable
namespace MP.Land.Data
{
/// <summary>
@@ -19,56 +21,6 @@ namespace MP.Land.Data
/// </summary>
public class LicenseService
{
#region Private Fields
private static IConfiguration? _configuration;
private static ILogger<LicenseService>? _logger;
/// <summary>
/// URL dell'API x chiamate gestione licenze
/// </summary>
private static string apiUrl = "https://liman.egalware.com/ELM.API/";
//private static string apiUrl = "https://localhost:44351/";
/// <summary>
/// Chiave redis x info della licenza
/// </summary>
private static string rkeyAppInfo = "LongCache:AppInfo";
private readonly IDistributedCache distributedCache;
/// <summary>
/// Elenco obj in cache
/// </summary>
private List<string> cachedDataList = new List<string>();
/// <summary>
/// Fattorte conversione cache sliding --> 1 h
/// </summary>
private int cacheFact = 12;
/// <summary>
/// Durata assoluta massima della cache IN SECONDI
/// </summary>
private int chAbsExp = 60 * 5;
/// <summary>
/// Durata della cache IN SECONDI in modalità inattiva (non acceduta) prima di venire rimossa
/// NON estende oltre il tempo massimo di validità della cache (chAbsExp)
/// </summary>
private int chSliExp = 60 * 1;
#endregion Private Fields
#region Protected Fields
/// <summary>
/// Chiave redis x attivazioni della licenza
/// </summary>
protected const string rKeyAttByLic = "LongCache:AttByLic";
#endregion Protected Fields
#region Public Constructors
/// <summary>
@@ -95,9 +47,7 @@ namespace MP.Land.Data
#region Public Properties
public List<LiManObj.AttivazioneDTO> ActivList { get; set; } = new List<LiManObj.AttivazioneDTO>();
public List<AnagKeyValueModel> AKVList { get; set; } = new List<AnagKeyValueModel>();
public string Applicazione { get; set; } = "";
public bool HasActivData
@@ -158,74 +108,212 @@ namespace MP.Land.Data
#endregion Public Properties
#region Private Methods
#region Public Methods
/// <summary>
/// Opzioni cache con moltiplicatore durata risp durata base (1/5 minuti)
/// </summary>
/// <param name="multFact"></param>
/// <returns></returns>
private DistributedCacheEntryOptions cacheOpt(int multFact)
public async Task<List<LiManObj.AttivazioneDTO>> ActivListCache()
{
var numSecAbsExp = chAbsExp * multFact;
var numSecSliExp = chSliExp * multFact;
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp));
}
/// <summary>
/// Elenco attivazioni attuali
/// </summary>
private async Task<List<LiManObj.AttivazioneDTO>?> OnlineActivationList()
{
List<LiManObj.AttivazioneDTO>? answ = new List<LiManObj.AttivazioneDTO>();
// cerco online
RestClient client = new RestClient(apiUrl);
//client.Authenticator = new HttpBasicAuthenticator("username", "password");
string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
var request = new RestRequest($"api/attivazioni/?chiave={MKeyEnc}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == System.Net.HttpStatusCode.OK)
List<LiManObj.AttivazioneDTO> dbResult = new List<LiManObj.AttivazioneDTO>();
string cacheKey = $"{rKeyAttByLic}:{MasterKey}";
trackCache(cacheKey);
string rawData = await getRSV(cacheKey);
if (!string.IsNullOrEmpty(rawData))
{
// salvo in redis contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<LiManObj.AttivazioneDTO>?>(rawData);
var cacheRes = JsonConvert.DeserializeObject<List<LiManObj.AttivazioneDTO>?>(rawData);
if (cacheRes != null)
{
dbResult = cacheRes;
}
}
return await Task.FromResult(answ);
return await Task.FromResult(dbResult);
}
/// <summary>
/// Recupera info licenza da remoto
/// Verifica attivazione licenza
/// </summary>
private async Task<List<LiManObj.ApplicativoDTO>> OnlineAppInfo()
/// <param name="authKey"></param>
/// <returns></returns>
public bool checkLicenseActive(string authKey)
{
List<LiManObj.ApplicativoDTO> answ = new List<LiManObj.ApplicativoDTO>();
bool answ = false;
//cerco anche nelle info AKV
if (AKVList != null)
{
var recLic = AKVList.Where(x => x.ValString == authKey).FirstOrDefault();
int numLic = 0;
//cerco in record
if (recLic != null && recLic.ValInt != null)
{
numLic = (int)recLic.ValInt;
// verifico scadenza licenza!
DateTime scadenza = licenseManGLS.expiryDateByAuthKey(Installazione, recLic.NomeVar, numLic, authKey);
answ = scadenza > DateTime.Today;
}
else
{
_logger.LogInformation($"checkLicenseActive | Record non trovato per {authKey}");
}
}
return answ;
}
/// <summary>
/// Stato server gestione licenze
/// </summary>
public async Task<string> checkLimanServer()
{
string answ = "ND";
// cerco online
RestClient client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
//string mKey = System.Net.WebUtility.UrlEncode(MasterKey);
string reqUrl = $"api/licenza/{Installazione}?CodApp={Applicazione}&Chiave={MKeyEnc}";
var request = new RestRequest(reqUrl, Method.Get);
var request = new RestRequest($"api/health", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
// verifico risposta
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<LiManObj.ApplicativoDTO>?>(rawData);
if (response.Content != null)
{
answ = response.Content.Replace("\"", "");
}
}
return await Task.FromResult(answ);
}
private void ReportUpdated()
/// <summary>
/// Verifica scadenza licenza
/// </summary>
/// <param name="authKey"></param>
/// <returns></returns>
public DateTime getLicenseExpiry(string authKey)
{
DateTime answ = DateTime.Today.AddDays(-1);
//cerco anche nelle info AKV
if (AKVList != null)
{
var recLic = AKVList.Where(x => x.ValString == authKey).FirstOrDefault();
int numLic = 0;
//cerco in record
if (recLic != null && recLic.ValInt != null)
{
numLic = (int)recLic.ValInt;
// verifico scadenza licenza!
DateTime scadenza = licenseManGLS.expiryDateByAuthKey(Installazione, recLic.NomeVar, numLic, authKey);
answ = scadenza;
}
else
{
_logger.LogInformation($"getLicenseExpiry | Record non trovato per {authKey}");
}
}
return answ;
}
/// <summary>
/// Init della classe con variabili di base da Redis/DB
/// </summary>
public bool InitAkv()
{
bool fatto = false;
Applicazione = "MAPO";
Installazione = getAVKStr("Installazione");
MasterKey = getAVKStr(Applicazione);
NumLicDb = getAVKInt(Applicazione);
fatto = !string.IsNullOrEmpty($"{Installazione}{MasterKey}");
return fatto;
}
public async Task<List<LiManObj.ApplicativoDTO>> LicAppCache()
{
List<LiManObj.ApplicativoDTO> dbResult = new List<LiManObj.ApplicativoDTO>();
string cacheKey = $"{rkeyAppInfo}:{MasterKey}";
trackCache(cacheKey);
string rawData = await getRSV(cacheKey);
if (!string.IsNullOrEmpty(rawData))
{
var cacheRes = JsonConvert.DeserializeObject<List<LiManObj.ApplicativoDTO>?>(rawData);
if (cacheRes != null)
{
dbResult = cacheRes;
}
}
return await Task.FromResult(dbResult);
}
/// <summary>
/// Init della classe con variabili di base da Redis/DB
/// </summary>
public async Task<bool> RefreshLicense()
{
bool fatto = false;
// scadenza info a 15 gg...
int numDays = 15;
// dati applicativo
var appData = await OnlineAppInfo();
if (appData != null)
{
if (appData.Count > 0)
{
fatto = await setAppInfo(appData, numDays);
// salvo info licenza...
NumLicRemote = appData[0].NumLicenze;
}
}
// dati attivazioni
var onlineAct = await OnlineActivationList();
if (onlineAct != null)
{
if (onlineAct.Count > 0)
{
infoExpiry = DateTime.Now.AddDays(numDays);
ActivList = onlineAct;
fatto = await setActivList(onlineAct, numDays);
}
}
await Task.Delay(1);
return fatto;
}
public async Task<bool> setActivList(List<LiManObj.AttivazioneDTO> newActList, int numDays)
{
bool fatto = false;
string cacheKey = $"{rKeyAttByLic}:{MasterKey}";
var rawData = JsonConvert.SerializeObject(newActList);
await setRSV(cacheKey, rawData, numDays * cacheFact * 24);
fatto = true;
if (EA_InfoUpdated != null)
{
EA_InfoUpdated?.Invoke();
}
return fatto;
}
#endregion Private Methods
public async Task<bool> setAppInfo(List<LiManObj.ApplicativoDTO> newAppInfo, int numDays)
{
bool fatto = false;
string cacheKey = $"{rkeyAppInfo}:{MasterKey}";
var rawData = JsonConvert.SerializeObject(newAppInfo);
await setRSV(cacheKey, rawData, numDays * cacheFact * 24);
fatto = true;
if (EA_InfoUpdated != null)
{
EA_InfoUpdated?.Invoke();
}
return fatto;
}
#endregion Public Methods
#region Protected Fields
/// <summary>
/// Chiave redis x attivazioni della licenza
/// </summary>
protected const string rKeyAttByLic = "LongCache:AttByLic";
#endregion Protected Fields
#region Protected Methods
@@ -329,198 +417,120 @@ namespace MP.Land.Data
#endregion Protected Methods
#region Public Methods
#region Private Fields
public async Task<List<LiManObj.AttivazioneDTO>> ActivListCache()
{
List<LiManObj.AttivazioneDTO> dbResult = new List<LiManObj.AttivazioneDTO>();
string cacheKey = $"{rKeyAttByLic}:{MasterKey}";
trackCache(cacheKey);
string rawData = await getRSV(cacheKey);
if (!string.IsNullOrEmpty(rawData))
{
var cacheRes = JsonConvert.DeserializeObject<List<LiManObj.AttivazioneDTO>?>(rawData);
if (cacheRes != null)
{
dbResult = cacheRes;
}
}
return await Task.FromResult(dbResult);
}
private static IConfiguration? _configuration;
/// <summary>
/// Verifica attivazione licenza
/// URL dell'API x chiamate gestione licenze
/// </summary>
/// <param name="authKey"></param>
private static string apiUrl = "https://liman.egalware.com/ELM.API/";
/// <summary>
/// Chiave redis x info della licenza
/// </summary>
private static string rkeyAppInfo = "LongCache:AppInfo";
//private static string apiUrl = "https://localhost:44351/";
private readonly IDistributedCache distributedCache;
/// <summary>
/// Elenco obj in cache
/// </summary>
private List<string> cachedDataList = new List<string>();
/// <summary>
/// Fattorte conversione cache sliding --> 1 h
/// </summary>
private int cacheFact = 12;
/// <summary>
/// Durata assoluta massima della cache IN SECONDI
/// </summary>
private int chAbsExp = 60 * 5;
/// <summary>
/// Durata della cache IN SECONDI in modalità inattiva (non acceduta) prima di venire
/// rimossa NON estende oltre il tempo massimo di validità della cache (chAbsExp)
/// </summary>
private int chSliExp = 60 * 1;
#endregion Private Fields
#region Private Properties
private static ILogger<LicenseService> _logger { get; set; } = null!;
#endregion Private Properties
#region Private Methods
/// <summary>
/// Opzioni cache con moltiplicatore durata risp durata base (1/5 minuti)
/// </summary>
/// <param name="multFact"></param>
/// <returns></returns>
public bool checkLicenseActive(string authKey)
private DistributedCacheEntryOptions cacheOpt(int multFact)
{
bool answ = false;
//cerco anche nelle info AKV
if (AKVList != null)
{
var recLic = AKVList.Where(x => x.ValString == authKey).FirstOrDefault();
int numLic = 0;
//cerco in record
if (recLic != null)
{
numLic = (int)recLic.ValInt;
// verifico scadenza licenza!
DateTime scadenza = licenseManGLS.expiryDateByAuthKey(Installazione, recLic.NomeVar, numLic, authKey);
answ = scadenza > DateTime.Today;
}
else
{
_logger.LogInformation($"checkLicenseActive | Record non trovato per {authKey}");
}
}
return answ;
}
/// <summary>
/// Verifica scadenza licenza
/// </summary>
/// <param name="authKey"></param>
/// <returns></returns>
public DateTime getLicenseExpiry(string authKey)
{
DateTime answ = DateTime.Today.AddDays(-1);
//cerco anche nelle info AKV
if (AKVList != null)
{
var recLic = AKVList.Where(x => x.ValString == authKey).FirstOrDefault();
int numLic = 0;
//cerco in record
if (recLic != null)
{
numLic = (int)recLic.ValInt;
// verifico scadenza licenza!
DateTime scadenza = licenseManGLS.expiryDateByAuthKey(Installazione, recLic.NomeVar, numLic, authKey);
answ = scadenza;
}
else
{
_logger.LogInformation($"getLicenseExpiry | Record non trovato per {authKey}");
}
}
return answ;
var numSecAbsExp = chAbsExp * multFact;
var numSecSliExp = chSliExp * multFact;
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp));
}
/// <summary>
/// Stato server gestione licenze
/// Elenco attivazioni attuali
/// </summary>
public async Task<string> checkLimanServer()
private async Task<List<LiManObj.AttivazioneDTO>?> OnlineActivationList()
{
string answ = "ND";
List<LiManObj.AttivazioneDTO>? answ = new List<LiManObj.AttivazioneDTO>();
// cerco online
RestClient client = new RestClient(apiUrl);
var request = new RestRequest($"api/health", Method.Get);
//client.Authenticator = new HttpBasicAuthenticator("username", "password");
string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
var request = new RestRequest($"api/attivazioni/?chiave={MKeyEnc}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
// verifico risposta
answ = response.Content.Replace("\"", "");
// salvo in redis contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<LiManObj.AttivazioneDTO>?>(rawData);
}
return await Task.FromResult(answ);
}
/// <summary>
/// Init della classe con variabili di base da Redis/DB
/// Recupera info licenza da remoto
/// </summary>
public bool InitAkv()
private async Task<List<LiManObj.ApplicativoDTO>> OnlineAppInfo()
{
bool fatto = false;
Applicazione = "MAPO";
Installazione = getAVKStr("Installazione");
MasterKey = getAVKStr(Applicazione);
NumLicDb = getAVKInt(Applicazione);
fatto = !string.IsNullOrEmpty($"{Installazione}{MasterKey}");
return fatto;
List<LiManObj.ApplicativoDTO>? answ = new List<LiManObj.ApplicativoDTO>();
// cerco online
RestClient client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
//string mKey = System.Net.WebUtility.UrlEncode(MasterKey);
string reqUrl = $"api/licenza/{Installazione}?CodApp={Applicazione}&Chiave={MKeyEnc}";
var request = new RestRequest(reqUrl, Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
// verifico risposta
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<LiManObj.ApplicativoDTO>?>(rawData);
}
// restituisce valori o insieme vuoto
return await Task.FromResult(answ ?? new List<LiManObj.ApplicativoDTO>());
}
public async Task<List<LiManObj.ApplicativoDTO>> LicAppCache()
private void ReportUpdated()
{
List<LiManObj.ApplicativoDTO> dbResult = new List<LiManObj.ApplicativoDTO>();
string cacheKey = $"{rkeyAppInfo}:{MasterKey}";
trackCache(cacheKey);
string rawData = await getRSV(cacheKey);
if (!string.IsNullOrEmpty(rawData))
{
var cacheRes = JsonConvert.DeserializeObject<List<LiManObj.ApplicativoDTO>?>(rawData);
if (cacheRes != null)
{
dbResult = cacheRes;
}
}
return await Task.FromResult(dbResult);
}
/// <summary>
/// Init della classe con variabili di base da Redis/DB
/// </summary>
public async Task<bool> RefreshLicense()
{
bool fatto = false;
// scadenza info a 15 gg...
int numDays = 15;
// dati applicativo
var appData = await OnlineAppInfo();
if (appData != null)
{
if (appData.Count > 0)
{
fatto = await setAppInfo(appData, numDays);
// salvo info licenza...
NumLicRemote = appData[0].NumLicenze;
}
}
// dati attivazioni
var onlineAct = await OnlineActivationList();
if (onlineAct != null)
{
if (onlineAct.Count > 0)
{
infoExpiry = DateTime.Now.AddDays(numDays);
ActivList = onlineAct;
fatto = await setActivList(onlineAct, numDays);
}
}
await Task.Delay(1);
return fatto;
}
public async Task<bool> setActivList(List<LiManObj.AttivazioneDTO> newActList, int numDays)
{
bool fatto = false;
string cacheKey = $"{rKeyAttByLic}:{MasterKey}";
var rawData = JsonConvert.SerializeObject(newActList);
await setRSV(cacheKey, rawData, numDays * cacheFact * 24);
fatto = true;
if (EA_InfoUpdated != null)
{
EA_InfoUpdated?.Invoke();
}
return fatto;
}
public async Task<bool> setAppInfo(List<LiManObj.ApplicativoDTO> newAppInfo, int numDays)
{
bool fatto = false;
string cacheKey = $"{rkeyAppInfo}:{MasterKey}";
var rawData = JsonConvert.SerializeObject(newAppInfo);
await setRSV(cacheKey, rawData, numDays * cacheFact * 24);
fatto = true;
if (EA_InfoUpdated != null)
{
EA_InfoUpdated?.Invoke();
}
return fatto;
}
#endregion Public Methods
#endregion Private Methods
}
}
+2 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Land</RootNamespace>
<Version>6.16.2211.0416</Version>
<Version>6.16.2211.1518</Version>
</PropertyGroup>
<ItemGroup>
@@ -45,6 +45,7 @@
<ItemGroup>
<PackageReference Include="DiffMatchPatch" Version="1.0.3" />
<PackageReference Include="Majorsoft.Blazor.Components.Debounce" Version="1.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+2 -2
View File
@@ -1,7 +1,7 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"windowsAuthentication": true,
"anonymousAuthentication": false,
"iisExpress": {
"applicationUrl": "http://localhost:7314",
"sslPort": 44311
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo gestione Programmi MAPO</i>
<h4>Versione: 6.16.2211.0416</h4>
<h4>Versione: 6.16.2211.1518</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2211.0416
6.16.2211.1518
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2211.0416</version>
<version>6.16.2211.1518</version>
<url>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+14 -2
View File
@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Authentication.Negotiate;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Hosting;
@@ -75,8 +76,8 @@ namespace MP.Land
app.UseRouting();
//app.UseAuthentication();
//app.UseAuthorization();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
@@ -103,6 +104,17 @@ namespace MP.Land
o.SlidingExpiration = true;
});
services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
.AddNegotiate();
services.AddAuthorization(options =>
{
// By default, all incoming requests will be authorized according to the default policy.
options.FallbackPolicy = options.DefaultPolicy;
});
services.AddStackExchangeRedisCache(options =>
{
//options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 1, EndPoints = { { "localhost", 6379 } } };
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Stats</RootNamespace>
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
<Version>6.16.2210.2110</Version>
<Version>6.16.2211.1517</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo statistiche MAPO</i>
<h4>Versione: 6.16.2210.2110</h4>
<h4>Versione: 6.16.2211.1517</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2210.2110
6.16.2211.1517
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2210.2110</version>
<version>6.16.2211.1517</version>
<url>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>