From 78ce9a21d11a94175f36db531da475b2cd770cff Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 14 Nov 2022 17:57:52 +0100 Subject: [PATCH] Aggiunta log in INVE --- MP.Data/Controllers/MpInveController.cs | 32 ++++++++-- MP.Data/DatabaseModels/AnagOperatoriModel.cs | 7 ++- MP.Data/MoonProContext.cs | 1 + MP.Data/MoonPro_InveContext.cs | 1 - MP.INVE/Components/CmpTop.razor | 1 - MP.INVE/Components/CmpTop.razor.cs | 9 +-- MP.INVE/Data/MiDataService.cs | 66 +++++++++----------- MP.INVE/MP.INVE.csproj | 2 +- MP.INVE/Pages/Index.razor.cs | 10 --- MP.INVE/Pages/OperatoreLogin.razor | 27 ++++++++ MP.INVE/Pages/OperatoreLogin.razor.cs | 55 ++++++++++++++++ MP.INVE/Program.cs | 2 +- MP.INVE/Resources/ChangeLog.html | 2 +- MP.INVE/Resources/VersNum.txt | 2 +- MP.INVE/Resources/manifest.xml | 2 +- MP.INVE/Services/IOApiService.cs | 4 +- MP.INVE/Shared/NavMenu.razor | 1 - MP.INVE/appsettings.json | 1 + MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 22 files changed, 157 insertions(+), 76 deletions(-) create mode 100644 MP.INVE/Pages/OperatoreLogin.razor create mode 100644 MP.INVE/Pages/OperatoreLogin.razor.cs diff --git a/MP.Data/Controllers/MpInveController.cs b/MP.Data/Controllers/MpInveController.cs index db9d4176..462222bf 100644 --- a/MP.Data/Controllers/MpInveController.cs +++ b/MP.Data/Controllers/MpInveController.cs @@ -92,22 +92,46 @@ namespace MP.Data.Controllers /// /// Elenco operatori /// - /// /// public List ElencoOperatori() { List dbResult = new List(); - using (var dbCtx = new MoonPro_InveContext(_configuration)) + using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx .DbOperatori + .Where(s=>s.MatrOpr>0) .AsNoTracking() - .OrderByDescending(x => x.MatrOpr) + .OrderBy(x => x.MatrOpr) .ToList(); } return dbResult; } - + /// + /// login operatore con controllo matricola + authkey + /// + /// /// + /// /// + /// + public bool LoginOperatore(int MatrOpr, string authKey) + { + List dbResult = new List(); + bool result = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbOperatori + .Where(s => (s.MatrOpr > 0) && (s.MatrOpr == MatrOpr) && (s.authKey == authKey)) + .AsNoTracking() + .OrderBy(x => x.MatrOpr) + .ToList(); + } + if (dbResult.Count == 1) + { + result = true; + } + return result; + } #endregion Public Methods #region Private Fields diff --git a/MP.Data/DatabaseModels/AnagOperatoriModel.cs b/MP.Data/DatabaseModels/AnagOperatoriModel.cs index 2db51371..78c32afb 100644 --- a/MP.Data/DatabaseModels/AnagOperatoriModel.cs +++ b/MP.Data/DatabaseModels/AnagOperatoriModel.cs @@ -8,6 +8,9 @@ using System.Threading.Tasks; namespace MP.Data.DatabaseModels { + // + // This is here so CodeMaid doesn't reorganize this document + // [Table("AnagraficaOperatori")] public class AnagOperatoriModel { @@ -16,7 +19,7 @@ namespace MP.Data.DatabaseModels public string Cognome { get; set; } = ""; public string Nome { get; set; } = ""; public bool isAdmin { get; set; } = false; - public int authKey { get; set; } - public int CodOprExt { get; set; } + public string authKey { get; set; } + public string CodOprExt { get; set; } } } diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 5cf650a3..fcfb0a25 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -52,6 +52,7 @@ namespace MP.Data public virtual DbSet DbSetStatoProd { get; set; } public virtual DbSet DbSetEvList { get; set; } public virtual DbSet DbSetVocabolario { get; set; } + public virtual DbSet DbOperatori { get; set; } #endregion Public Properties diff --git a/MP.Data/MoonPro_InveContext.cs b/MP.Data/MoonPro_InveContext.cs index 357f1010..c8844cb6 100644 --- a/MP.Data/MoonPro_InveContext.cs +++ b/MP.Data/MoonPro_InveContext.cs @@ -47,7 +47,6 @@ namespace MP.Data public virtual DbSet DbInveSess { get; set; } public virtual DbSet DbScanData { get; set; } - public virtual DbSet DbOperatori { get; set; } #endregion Public Properties diff --git a/MP.INVE/Components/CmpTop.razor b/MP.INVE/Components/CmpTop.razor index 566fd8c1..c2578ed2 100644 --- a/MP.INVE/Components/CmpTop.razor +++ b/MP.INVE/Components/CmpTop.razor @@ -4,7 +4,6 @@ @using Microsoft.AspNetCore.Components.Authorization @inject AuthenticationStateProvider AuthenticationStateProvider -@inject MessageService MService
diff --git a/MP.INVE/Components/CmpTop.razor.cs b/MP.INVE/Components/CmpTop.razor.cs index 1da748b8..0fc621ce 100644 --- a/MP.INVE/Components/CmpTop.razor.cs +++ b/MP.INVE/Components/CmpTop.razor.cs @@ -12,7 +12,6 @@ namespace MP.INVE.Components public async Task flushCache() { await Task.Delay(1); - await MDService.FlushRedisCache(); await Task.Delay(1); // rimando a pagina corrente NavManager.NavigateTo(NavManager.Uri, true); @@ -25,18 +24,12 @@ namespace MP.INVE.Components [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; - [Inject] - protected MpDataService MDService { get; set; } = null!; - - protected bool ShowSearch { get => MService.ShowSearch; set => MService.ShowSearch = value; } - #endregion Protected Properties #region Protected Methods protected override async Task OnInitializedAsync() { - MService.EA_ShowSearch += MService_EA_ShowSearch; await forceReload(); } @@ -53,7 +46,7 @@ namespace MP.INVE.Components [Inject] private NavigationManager NavManager { get; set; } = null!; - private string TipoSearch { get => MService.TipoSearch; set => MService.TipoSearch = value; } + #endregion Private Properties diff --git a/MP.INVE/Data/MiDataService.cs b/MP.INVE/Data/MiDataService.cs index ec8ffa65..ad77c49e 100644 --- a/MP.INVE/Data/MiDataService.cs +++ b/MP.INVE/Data/MiDataService.cs @@ -13,10 +13,10 @@ namespace MP.INVE.Data { #region Public Constructors - public MiDataService(IConfiguration configuration, ILogger logger) + public MiDataService(IConfiguration configuration, ILogger logger) { _logger = logger; - _logger.LogInformation("Starting MpDataService INIT"); + _logger.LogInformation("Starting MiDataService INIT"); _configuration = configuration; // setup compoenti REDIS @@ -30,10 +30,11 @@ namespace MP.INVE.Data _logger.LogInformation("Redis INIT"); // conf DB - string connStr = _configuration.GetConnectionString("Mp.Data"); - if (string.IsNullOrEmpty(connStr)) + string connStrData = _configuration.GetConnectionString("Mp.Data"); + string connStrInve = _configuration.GetConnectionString("Mp.Inve"); + if (string.IsNullOrEmpty(connStrData) || string.IsNullOrEmpty(connStrInve)) { - _logger.LogError("DbController: ConnString empty!"); + _logger.LogError($"DbController: ConnString empty! connStrData: {connStrData} | connStrInve: {connStrInve}"); } else { @@ -44,6 +45,10 @@ namespace MP.INVE.Data #endregion Public Constructors + public void Dispose() + { + } + #region Public Properties public static MP.Data.Controllers.MpInveController dbController { get; set; } = null!; @@ -55,7 +60,24 @@ namespace MP.INVE.Data #endregion Public Properties - + #region Public Methods + + public List ElencoOperatori() + { + List? result = new List(); + result = dbController.ElencoOperatori(); + return result; + } + + public bool LoginOperatore(int MatrOpr, string authKey) + { + bool result = false; + result = dbController.LoginOperatore(MatrOpr, authKey); + return result; + } + + + #endregion Public Methods #region Protected Fields @@ -80,38 +102,6 @@ namespace MP.INVE.Data #region Private Fields - private const string redisArtByDossier = redisBaseAddr + "SPEC:Cache:ArtByDossier"; - - private const string redisArtList = redisBaseAddr + "SPEC:Cache:ArtList"; - - private const string redisBaseAddr = "MP:"; - - private const string redisConfKey = redisBaseAddr + "SPEC:Cache:Config"; - - private const string redisDossByMac = redisBaseAddr + "SPEC:Cache:DossByMac"; - - private const string redisFluxByMac = redisBaseAddr + "SPEC:Cache:FluxByMac"; - - private const string redisFluxLogFilt = redisBaseAddr + "SPEC:Cache:FluxLogFilt"; - - private const string redisMacByFlux = redisBaseAddr + "SPEC:Cache:MacByFlux"; - - private const string redisMacList = redisBaseAddr + "SPEC:Cache:MacList"; - - private const string redisOdlCurrByMac = redisBaseAddr + "SPEC:Cache:OdlByMac"; - - private const string redisPOdlList = redisBaseAddr + "SPEC:Cache:POdlList"; - - private const string redisPOdlByPOdl = redisBaseAddr + "SPEC:Cache:POdlByPOdl"; - - private const string redisPOdlByOdl = redisBaseAddr + "SPEC:Cache:POdlByOdl"; - - private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom"; - - private const string redisTipoArt = redisBaseAddr + "SPEC:Cache:TipoArt"; - - private const string redisVocabolario = redisBaseAddr + "SPEC:Cache:Vocabolario"; - private static IConfiguration _configuration = null!; private static ILogger _logger = null!; diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj index e54368a5..28000fb5 100644 --- a/MP.INVE/MP.INVE.csproj +++ b/MP.INVE/MP.INVE.csproj @@ -5,7 +5,7 @@ enable enable MP.INVE - 6.16.2211.1412 + 6.16.2211.1417 diff --git a/MP.INVE/Pages/Index.razor.cs b/MP.INVE/Pages/Index.razor.cs index 34b76e70..1bf390b6 100644 --- a/MP.INVE/Pages/Index.razor.cs +++ b/MP.INVE/Pages/Index.razor.cs @@ -12,16 +12,6 @@ namespace MP.INVE.Pages #endregion Public Properties - #region Protected Properties - - //[Inject] - //protected MpDataService MDService { get; set; } = null!; - - //[Inject] - //protected MessageService MessageService { get; set; } = null!; - - #endregion Protected Properties - #region Protected Methods protected override async Task OnInitializedAsync() diff --git a/MP.INVE/Pages/OperatoreLogin.razor b/MP.INVE/Pages/OperatoreLogin.razor new file mode 100644 index 00000000..73e37eab --- /dev/null +++ b/MP.INVE/Pages/OperatoreLogin.razor @@ -0,0 +1,27 @@ +@page "/OperatoreLogin" + +

OperatoreLogin

+ +
+
+ + +
+
+ +
+
+ +
+
+ + + diff --git a/MP.INVE/Pages/OperatoreLogin.razor.cs b/MP.INVE/Pages/OperatoreLogin.razor.cs new file mode 100644 index 00000000..e6b2a3a5 --- /dev/null +++ b/MP.INVE/Pages/OperatoreLogin.razor.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +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 MP.INVE; +using MP.INVE.Data; +using MP.INVE.Shared; +using MP.INVE.Components; +using MP.Data.DatabaseModels; + +namespace MP.INVE.Pages +{ + public partial class OperatoreLogin + { + [Inject] + private MiDataService MIDataservice { get; set; } = null!; + [Inject] + private NavigationManager NavManager { get; set; } = null!; + + private int idOperatore { get; set; } + private string authKey { get; set; } + + private List? elencoOperatori; + + protected override async Task OnInitializedAsync() + { + //await FilterChanged.InvokeAsync(actFilter); + await Task.Delay(1); + elencoOperatori = MIDataservice.ElencoOperatori(); + } + + private void login() + { + var ok = MIDataservice.LoginOperatore(idOperatore, authKey); + + if (ok) + { + NavManager.NavigateTo("/Starter", true); + } + else + { + + } + } + } +} \ No newline at end of file diff --git a/MP.INVE/Program.cs b/MP.INVE/Program.cs index 6a3dc552..ae34829e 100644 --- a/MP.INVE/Program.cs +++ b/MP.INVE/Program.cs @@ -36,7 +36,7 @@ builder.Services.AddAuthorization(options => builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(redisMultiplexer); -builder.Services.AddSingleton(); +builder.Services.AddSingleton(); builder.Services.AddScoped(); builder.Services.AddHttpClient(); diff --git a/MP.INVE/Resources/ChangeLog.html b/MP.INVE/Resources/ChangeLog.html index 7cdbda82..84719f4a 100644 --- a/MP.INVE/Resources/ChangeLog.html +++ b/MP.INVE/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOINVE -

Versione: 6.16.2211.1412

+

Versione: 6.16.2211.1417


Note di rilascio:
  • diff --git a/MP.INVE/Resources/VersNum.txt b/MP.INVE/Resources/VersNum.txt index b7a3fd27..a8e43652 100644 --- a/MP.INVE/Resources/VersNum.txt +++ b/MP.INVE/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2211.1412 +6.16.2211.1417 diff --git a/MP.INVE/Resources/manifest.xml b/MP.INVE/Resources/manifest.xml index 13e2158d..268d80e6 100644 --- a/MP.INVE/Resources/manifest.xml +++ b/MP.INVE/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2211.1412 + 6.16.2211.1417 https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html false diff --git a/MP.INVE/Services/IOApiService.cs b/MP.INVE/Services/IOApiService.cs index ba985879..06287fc5 100644 --- a/MP.INVE/Services/IOApiService.cs +++ b/MP.INVE/Services/IOApiService.cs @@ -15,7 +15,7 @@ namespace MP.INVE.Services public class IOApiService { private readonly IHttpClientFactory _clientFactory; - private static ILogger _logger = null!; + private static ILogger _logger = null!; private static IConfiguration _configuration = null!; @@ -24,7 +24,7 @@ namespace MP.INVE.Services private static string MpIoBaseUrl = ""; - public IOApiService(IHttpClientFactory clientFactory, IConfiguration configuration, ILogger logger) + public IOApiService(IHttpClientFactory clientFactory, IConfiguration configuration, ILogger logger) { _logger = logger; _logger.LogInformation("Starting IOApiService INIT"); diff --git a/MP.INVE/Shared/NavMenu.razor b/MP.INVE/Shared/NavMenu.razor index a8a4e815..4a7f7eb4 100644 --- a/MP.INVE/Shared/NavMenu.razor +++ b/MP.INVE/Shared/NavMenu.razor @@ -1,6 +1,5 @@ @using MP.INVE.Components @using MP.INVE.Data -@*@inject MpDataService MDService*@