From 985e429d3443683fb09c5f9df7b7f1adff6d2cbc Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 23 Dec 2021 14:55:19 +0100 Subject: [PATCH] Modifica x recuperare e msotrare cod licenza --- MP.AppAuth/AppAuthContext.cs | 5 -- MP.AppAuth/Controllers/AppAuthController.cs | 4 +- MP.AppAuth/Controllers/MPController .cs | 51 +++++++++++++++++++ MP.AppAuth/Models/AnagKeyValue.cs | 11 +++- MP.AppAuth/MoonProContext.cs | 56 +++++++++++++++++---- MP.Land/Data/AppAuthService.cs | 13 +++++ MP.Land/MP.Land.csproj | 2 +- MP.Land/Pages/SysInfo.razor | 23 +++++++-- MP.Land/Resources/ChangeLog.html | 2 +- MP.Land/Resources/VersNum.txt | 2 +- MP.Land/Resources/manifest.xml | 2 +- 11 files changed, 146 insertions(+), 25 deletions(-) create mode 100644 MP.AppAuth/Controllers/MPController .cs diff --git a/MP.AppAuth/AppAuthContext.cs b/MP.AppAuth/AppAuthContext.cs index 520acb42..306cc5c2 100644 --- a/MP.AppAuth/AppAuthContext.cs +++ b/MP.AppAuth/AppAuthContext.cs @@ -3,10 +3,6 @@ using Microsoft.Extensions.Configuration; using MP.AppAuth.Models; using NLog; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MP.AppAuth { @@ -60,7 +56,6 @@ namespace MP.AppAuth public virtual DbSet DbSetAnagOpr { get; set; } public virtual DbSet DbSetUpdMan { get; set; } - public virtual DbSet DbSetVocabolario { get; set; } #endregion Public Properties diff --git a/MP.AppAuth/Controllers/AppAuthController.cs b/MP.AppAuth/Controllers/AppAuthController.cs index 26d54e80..e441149a 100644 --- a/MP.AppAuth/Controllers/AppAuthController.cs +++ b/MP.AppAuth/Controllers/AppAuthController.cs @@ -115,8 +115,8 @@ namespace MP.AppAuth.Controllers using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) { dbResult = localDbCtx - .DbSetVocabolario - .ToList(); + .DbSetVocabolario + .ToList(); } return dbResult; } diff --git a/MP.AppAuth/Controllers/MPController .cs b/MP.AppAuth/Controllers/MPController .cs new file mode 100644 index 00000000..0c54dd80 --- /dev/null +++ b/MP.AppAuth/Controllers/MPController .cs @@ -0,0 +1,51 @@ +using Microsoft.Extensions.Configuration; +using NLog; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MP.AppAuth.Controllers +{ + public class MPController + { + #region Private Fields + + private static IConfiguration _configuration; + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + + #region Public Constructors + + public MPController(IConfiguration configuration) + { + _configuration = configuration; + Log.Info("Avviata classe MpController"); + } + + #endregion Public Constructors + + #region Public Methods + + + /// + /// Elenco Record x AnagKeyValue + /// + /// + public List AnagKeyValuesGetAll() + { + List dbResult = new List(); + using (MoonProContext localDbCtx = new MoonProContext(_configuration)) + { + dbResult = localDbCtx + .DbSetAnagKeyValues + .ToList(); + } + return dbResult; + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/MP.AppAuth/Models/AnagKeyValue.cs b/MP.AppAuth/Models/AnagKeyValue.cs index bdeede66..d2be5358 100644 --- a/MP.AppAuth/Models/AnagKeyValue.cs +++ b/MP.AppAuth/Models/AnagKeyValue.cs @@ -1,19 +1,26 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; #nullable disable namespace MP.AppAuth.Models { + // + // This is here so CodeMaid doesn't reorganize this document + // + [Table("AnagKeyValue")] public partial class AnagKeyValue { #region Public Properties - public string Descrizione { get; set; } + [Key] public string NomeVar { get; set; } - public double? ValFloat { get; set; } public int? ValInt { get; set; } + public double? ValFloat { get; set; } public string ValString { get; set; } + public string Descrizione { get; set; } #endregion Public Properties } diff --git a/MP.AppAuth/MoonProContext.cs b/MP.AppAuth/MoonProContext.cs index a1eca39d..7c4d02d8 100644 --- a/MP.AppAuth/MoonProContext.cs +++ b/MP.AppAuth/MoonProContext.cs @@ -1,23 +1,53 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; using MP.AppAuth.Models; - -#nullable disable +using NLog; +using System; namespace MP.AppAuth { public partial class MoonProContext : DbContext { + #region Private Fields + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + private IConfiguration _configuration; + + #endregion Private Fields + #region Public Constructors + [Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")] public MoonProContext() { } - public MoonProContext(DbContextOptions options) - : base(options) + public MoonProContext(IConfiguration configuration) { + _configuration = configuration; + try + { + // se non ci fosse... crea o migra! + Database.Migrate(); + } + catch (Exception exc) + { + Log.Error(exc, "Exception during context initialization 01"); + } + } + + public MoonProContext(DbContextOptions options) : base(options) + { + try + { + // se non ci fosse... crea o migra! + Database.Migrate(); + } + catch (Exception exc) + { + Log.Error(exc, "Exception during context initialization 02"); + } } #endregion Public Constructors @@ -26,7 +56,6 @@ namespace MP.AppAuth public virtual DbSet AnagArticolis { get; set; } public virtual DbSet AnagClassiTempos { get; set; } - public virtual DbSet AnagKeyValues { get; set; } public virtual DbSet AnagraficaCausaliScartos { get; set; } public virtual DbSet AnagraficaFlussis { get; set; } public virtual DbSet AnagraficaIngressis { get; set; } @@ -34,6 +63,7 @@ namespace MP.AppAuth public virtual DbSet AnagraficaOperatoris { get; set; } public virtual DbSet Configs { get; set; } public virtual DbSet DatiMacchines { get; set; } + public virtual DbSet DbSetAnagKeyValues { get; set; } public virtual DbSet FamigliaTipoIngressis { get; set; } public virtual DbSet FamiglieMacchines { get; set; } public virtual DbSet KeepAlives { get; set; } @@ -57,7 +87,15 @@ namespace MP.AppAuth { if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseSqlServer("Data Source=SQL2016DEV;Initial Catalog=MoonPro;Trusted_Connection=True;"); + string connString = _configuration.GetConnectionString("MP.Land"); + if (!string.IsNullOrEmpty(connString)) + { + optionsBuilder.UseSqlServer(connString); + } + else + { + optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro;Trusted_Connection=True;"); + } } } diff --git a/MP.Land/Data/AppAuthService.cs b/MP.Land/Data/AppAuthService.cs index 2d9b5d23..67037c3d 100644 --- a/MP.Land/Data/AppAuthService.cs +++ b/MP.Land/Data/AppAuthService.cs @@ -47,6 +47,7 @@ namespace MP.Land.Data #region Public Fields public static AppAuth.Controllers.AppAuthController dbController; + public static AppAuth.Controllers.MPController MpDbController; #endregion Public Fields @@ -170,6 +171,18 @@ namespace MP.Land.Data return await Task.FromResult(dbResult); } + public async Task> AnagKeyValList() + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = MpDbController.AnagKeyValuesGetAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per AnagKeyValList: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + #endregion Public Methods } } \ No newline at end of file diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index e800dbd7..5340ca47 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net5.0 MP.Land - 6.14.2111.2415 + 6.14.2112.2314 diff --git a/MP.Land/Pages/SysInfo.razor b/MP.Land/Pages/SysInfo.razor index 5b5c2c2a..7de838bd 100644 --- a/MP.Land/Pages/SysInfo.razor +++ b/MP.Land/Pages/SysInfo.razor @@ -3,11 +3,12 @@ @using MP.Land.Data @using Microsoft.Extensions.Configuration +@inject AppAuthService DataService @inject MessageService AppMService @inject IConfiguration Configuration
-
+
@@ -126,6 +127,9 @@
+
@@ -135,6 +139,21 @@ protected string Titolo = "MAPO System Info"; protected string Messaggio = "HW & SW details"; protected HwSwInfo currHwSwInfo = HwSwInfo.man(System.Reflection.Assembly.GetExecutingAssembly()); + + protected async Task masterLic() + { + string answ = "-"; + var akvList = await DataService.AnagKeyValList(); + var licRecord = akvList + .Where(x => x.NomeVar == "MAPO") + .FirstOrDefault(); + if (licRecord != null) + { + answ = licRecord.ValString; + } + return answ; + } + protected string DbNameExample { get @@ -156,6 +175,4 @@ } } - //string connStr = memLayer.ML.confReadString("DbConfConnectionString"); - //currHwSwInfo = currHwSwInfo; } \ No newline at end of file diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index a24b2acd..8e776013 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

Versione: 6.14.2111.2415

+

Versione: 6.14.2112.2314


Note di rilascio:
    diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index 8e83ab18..2fb5c419 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -6.14.2111.2415 +6.14.2112.2314 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index 6288b38d..8d1fc59d 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.14.2111.2415 + 6.14.2112.2314 https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html false