diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index f43b0306..bdfc3780 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -412,17 +412,17 @@ namespace MP.Data.Controllers /// /// /// - public List ArticoliGetByTipo(string tipo, string azienda = "*") + public async Task> ArticoliGetByTipoAsync(string tipo, string azienda = "*") { List dbResult = new List(); using (var dbCtx = new MoonProContext(options)) { - dbResult = dbCtx + dbResult = await dbCtx .DbSetArticoli .AsNoTracking() .Where(x => x.Tipo.ToUpper() == tipo.ToUpper() && (azienda == "*" || x.Azienda.ToUpper() == azienda.ToUpper())) .OrderBy(x => x.CodArticolo) - .ToList(); + .ToListAsync(); } return dbResult; } diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index b12f9bc2..0f9f4397 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -392,7 +392,7 @@ namespace MP.Data.Services } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ArticoliGetByTipo | Read from {readType}: {ts.TotalMilliseconds}ms"); + Log.Debug($"ArticoliGetByTipoAsync | Read from {readType}: {ts.TotalMilliseconds}ms"); return result; } diff --git a/MP.SPEC/App.razor b/MP.SPEC/App.razor deleted file mode 100644 index 7431d6a1..00000000 --- a/MP.SPEC/App.razor +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - Not found - -

Sorry, there's nothing at this address.

-
-
-
-
diff --git a/MP.SPEC/Components/App.razor b/MP.SPEC/Components/App.razor new file mode 100644 index 00000000..7c2bdacb --- /dev/null +++ b/MP.SPEC/Components/App.razor @@ -0,0 +1,43 @@ + + + + + + + @* *@ + @* *@ + + + + + + MP-SPEC + + + + + + + + @* *@ + + + + + + + + +
+ An error has occurred. + Reload + 🗙 +
+ + + + + + + + diff --git a/MP.SPEC/Shared/MainLayout.razor b/MP.SPEC/Components/Layout/MainLayout.razor similarity index 100% rename from MP.SPEC/Shared/MainLayout.razor rename to MP.SPEC/Components/Layout/MainLayout.razor diff --git a/MP.SPEC/Shared/MainLayout.razor.cs b/MP.SPEC/Components/Layout/MainLayout.razor.cs similarity index 90% rename from MP.SPEC/Shared/MainLayout.razor.cs rename to MP.SPEC/Components/Layout/MainLayout.razor.cs index dffbf458..725d3227 100644 --- a/MP.SPEC/Shared/MainLayout.razor.cs +++ b/MP.SPEC/Components/Layout/MainLayout.razor.cs @@ -1,4 +1,4 @@ -namespace MP.SPEC.Shared +namespace MP.SPEC.Components.Layout { public partial class MainLayout { diff --git a/MP.SPEC/Shared/MainLayout.razor.css b/MP.SPEC/Components/Layout/MainLayout.razor.css similarity index 100% rename from MP.SPEC/Shared/MainLayout.razor.css rename to MP.SPEC/Components/Layout/MainLayout.razor.css diff --git a/MP.SPEC/Shared/MainLayout.razor.less b/MP.SPEC/Components/Layout/MainLayout.razor.less similarity index 100% rename from MP.SPEC/Shared/MainLayout.razor.less rename to MP.SPEC/Components/Layout/MainLayout.razor.less diff --git a/MP.SPEC/Shared/MainLayout.razor.min.css b/MP.SPEC/Components/Layout/MainLayout.razor.min.css similarity index 100% rename from MP.SPEC/Shared/MainLayout.razor.min.css rename to MP.SPEC/Components/Layout/MainLayout.razor.min.css diff --git a/MP.SPEC/Shared/NavMenu.razor b/MP.SPEC/Components/Layout/NavMenu.razor similarity index 100% rename from MP.SPEC/Shared/NavMenu.razor rename to MP.SPEC/Components/Layout/NavMenu.razor diff --git a/MP.SPEC/Shared/NavMenu.razor.cs b/MP.SPEC/Components/Layout/NavMenu.razor.cs similarity index 98% rename from MP.SPEC/Shared/NavMenu.razor.cs rename to MP.SPEC/Components/Layout/NavMenu.razor.cs index 0d2208e9..87d2a650 100644 --- a/MP.SPEC/Shared/NavMenu.razor.cs +++ b/MP.SPEC/Components/Layout/NavMenu.razor.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Mvc.RazorPages; using MP.SPEC.Data; -namespace MP.SPEC.Shared +namespace MP.SPEC.Components.Layout { public partial class NavMenu : IDisposable { diff --git a/MP.SPEC/Shared/NavMenu.razor.css b/MP.SPEC/Components/Layout/NavMenu.razor.css similarity index 100% rename from MP.SPEC/Shared/NavMenu.razor.css rename to MP.SPEC/Components/Layout/NavMenu.razor.css diff --git a/MP.SPEC/Components/ListODL.razor.cs b/MP.SPEC/Components/ListODL.razor.cs index f0cf41b7..480caa30 100644 --- a/MP.SPEC/Components/ListODL.razor.cs +++ b/MP.SPEC/Components/ListODL.razor.cs @@ -1,8 +1,6 @@ using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.DataProtection; using Microsoft.JSInterop; using MP.Data.DbModels; -using MP.SPEC.Components; using MP.SPEC.Data; using MP.SPEC.Services; using NLog; @@ -209,7 +207,7 @@ namespace MP.SPEC.Components protected override async Task OnInitializedAsync() { ListStati = await MDService.AnagStatiComm(); - ListArtKit = MDService.ArticoliGetByTipo("KIT", "*"); + ListArtKit = await MDService.ArticoliGetByTipoAsync("KIT", "*"); string SPEC_PODL_gest = await MDService.ConfigTryGetAsync("SPEC_PODL_gest"); if (!string.IsNullOrEmpty(SPEC_PODL_gest)) { diff --git a/MP.SPEC/Components/ListPODL.razor.cs b/MP.SPEC/Components/ListPODL.razor.cs index 3217b076..29151abe 100644 --- a/MP.SPEC/Components/ListPODL.razor.cs +++ b/MP.SPEC/Components/ListPODL.razor.cs @@ -216,9 +216,8 @@ namespace MP.SPEC.Components .Select(x => x.IdxMacchina) .ToHashSet(); - ListStati = await MDService.AnagStatiComm(); - ListArtKit = MDService.ArticoliGetByTipo("KIT", "*"); + ListArtKit = await MDService.ArticoliGetByTipoAsync("KIT", "*"); string strMachRecipe = await MDService.ConfigTryGetAsync("MachineWithRecipe"); if (!string.IsNullOrEmpty(strMachRecipe)) { diff --git a/MP.SPEC/Components/Routes.razor b/MP.SPEC/Components/Routes.razor new file mode 100644 index 00000000..37c2f803 --- /dev/null +++ b/MP.SPEC/Components/Routes.razor @@ -0,0 +1,12 @@ + + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 46079cca..5d7405d1 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -417,15 +417,15 @@ namespace MP.SPEC.Data /// /// /// - public List ArticoliGetByTipo(string tipo, string azienda = "*") + public async Task> ArticoliGetByTipoAsync(string tipo, string azienda = "*") { - using var activity = ActivitySource.StartActivity("ArticoliGetByTipo"); + using var activity = ActivitySource.StartActivity("ArticoliGetByTipoAsync"); List? result = new List(); string source = "DB"; string sKey = string.IsNullOrEmpty(tipo) ? "ALL" : tipo; string currKey = $"{Utils.redisArtList}:{azienda}:Tipo:{sKey}"; // cerco in redis dato valore sel idxMaccSel... - RedisValue rawData = redisDb.StringGet(currKey); + RedisValue rawData = await redisDb.StringGetAsync(currKey); if (rawData.HasValue) { result = JsonConvert.DeserializeObject>($"{rawData}"); @@ -433,10 +433,10 @@ namespace MP.SPEC.Data } else { - result = dbController.ArticoliGetByTipo(tipo, azienda); + result = await dbController.ArticoliGetByTipoAsync(tipo, azienda); // serializzo e salvo... rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache)); + await redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache)); } if (result == null) { @@ -445,7 +445,7 @@ namespace MP.SPEC.Data activity?.SetTag("data.source", source); activity?.SetTag("result.count", result.Count); activity?.Stop(); - LogTrace($"ArticoliGetByTipo | Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"ArticoliGetByTipoAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -685,34 +685,6 @@ namespace MP.SPEC.Data LogTrace($"ConfigTryGet Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); return value ?? ""; - -#if false - string answ = ""; - using var activity = ActivitySource.StartActivity("ConfigTryGet"); - string source = "DB+REDIS"; - // preselezione valori - if (configData == null || configData.Count == 0) - { - configData = ConfigGetAll(); - } - var currRec = configData.FirstOrDefault(x => x.Chiave == keyName); - - // se non trovato provo a ricaricare.. - if (currRec == null) - { - configData = ConfigGetAll(); - currRec = configData.FirstOrDefault(x => x.Chiave == keyName); - } - // verifico se ci sia il dato... - if (currRec != null) - { - answ = currRec.Valore; - } - activity?.SetTag("data.source", source); - activity?.Stop(); - LogTrace($"ConfigTryGet Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); - return answ; -#endif } /// @@ -732,36 +704,8 @@ namespace MP.SPEC.Data activity?.SetTag("data.source", source); activity?.Stop(); - LogTrace($"ConfigTryGetAsync Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"ConfigTryGetAsync | {keyName} | Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); return value ?? ""; - -#if false - string answ = ""; - using var activity = ActivitySource.StartActivity("ConfigTryGetAsync"); - string source = "DB+REDIS"; - // preselezione valori - if (configData == null || configData.Count == 0) - { - configData = await ConfigGetAllAsync(); - } - var currRec = configData.FirstOrDefault(x => x.Chiave == keyName); - - // se non trovato provo a ricaricare.. - if (currRec != null) - { - configData = await ConfigGetAllAsync(); - currRec = configData.FirstOrDefault(x => x.Chiave == keyName); - } - // verifico se ci sia il dato... - if (currRec != null) - { - answ = currRec.Valore; - } - activity?.SetTag("data.source", source); - activity?.Stop(); - LogTrace($"ConfigTryGetAsync Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); - return answ; -#endif } /// @@ -2070,27 +2014,6 @@ namespace MP.SPEC.Data // chiamo metodo conferma! fatto = await dbController.ODLClose(idxOdl, idxMacchina, matrOpr, confPezzi, confRett, modoConfProd); -#if false - // recupero dati x conf modalità conferma - var configData = await ConfigGetAllAsync(); - if (configData != null) - { - bool confRett = false; - var currRec = configData.FirstOrDefault(x => x.Chiave == "confRett"); - if (currRec != null) - { - bool.TryParse(currRec.Valore, out confRett); - } - int modoConfProd = 0; - currRec = configData.FirstOrDefault(x => x.Chiave == "modoConfProd"); - if (currRec != null) - { - int.TryParse(currRec.Valore, out modoConfProd); - } - // chiamo metodo conferma! - fatto = await dbController.ODLClose(idxOdl, idxMacchina, matrOpr, confPezzi, confRett, modoConfProd); - } -#endif activity?.SetTag("data.source", source); activity?.Stop(); LogTrace($"ODLClose | Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); @@ -3344,17 +3267,6 @@ namespace MP.SPEC.Data #endregion Private Fields - #region Private Properties - -#if false - /// - /// Cache dati config - /// - private List configData { get; set; } = new List(); -#endif - - #endregion Private Properties - #region Private Methods /// @@ -3368,6 +3280,7 @@ namespace MP.SPEC.Data ExecFlushRedisPattern(pattern); } } + private void EnsureConfigLoaded() { if (_configData.Count == 0) @@ -3379,6 +3292,7 @@ namespace MP.SPEC.Data .ToDictionary(g => g.Key, g => g.First().Valore); } } + private async Task EnsureConfigLoadedAsync() { if (_configData.Count == 0) diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 06d98519..e978a1c1 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 8.16.2605.2616 + 8.16.2605.2617 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Pages/_Host.cshtml b/MP.SPEC/Pages/_Host.cshtml deleted file mode 100644 index cc60006b..00000000 --- a/MP.SPEC/Pages/_Host.cshtml +++ /dev/null @@ -1,8 +0,0 @@ -@page "/" -@namespace MP.SPEC.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -@{ - Layout = "_Layout"; -} - - \ No newline at end of file diff --git a/MP.SPEC/Pages/_Layout.cshtml b/MP.SPEC/Pages/_Layout.cshtml deleted file mode 100644 index ce82407f..00000000 --- a/MP.SPEC/Pages/_Layout.cshtml +++ /dev/null @@ -1,69 +0,0 @@ -@using Microsoft.AspNetCore.Components.Web -@namespace MP.SPEC.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers - - - - - MP-SPEC - - - - - - - - - - - - - - @RenderBody() - -
- - An error has occurred. This application may no longer respond until reloaded. - - - An unhandled exception has occurred. See browser dev tools for details. - - Reload - 🗙 -
- - - - - - - - - @*Gestione autoriconnessione: https://github.com/dotnet/aspnetcore/issues/38305 (vedere anche https://docs.microsoft.com/it-it/aspnet/core/blazor/fundamentals/signalr?view=aspnetcore-6.0#modify-the-reconnection-handler-blazor-server)*@ - - - diff --git a/MP.SPEC/Program.cs b/MP.SPEC/Program.cs index 23fcc447..b91a66a0 100644 --- a/MP.SPEC/Program.cs +++ b/MP.SPEC/Program.cs @@ -1,10 +1,6 @@ using Microsoft.AspNetCore.Authentication.Negotiate; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.StaticFiles; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.FileProviders; -using Microsoft.JSInterop; using MP.AppAuth.Services; using MP.Data.Services; using MP.SPEC.Components; @@ -12,7 +8,6 @@ using MP.SPEC.Data; using MP.SPEC.Services; using NLog; using NLog.Targets; -using NLog.Targets.OpenTelemetryProtocol; using NLog.Web; using OpenTelemetry.Resources; using OpenTelemetry.Trace; @@ -21,14 +16,6 @@ using StackExchange.Redis; var builder = WebApplication.CreateBuilder(args); -/*-------------------- - * Note migrazione startup.cs --> program.cs: - * - * - https://stackoverflow.com/questions/69722872/asp-net-core-6-how-to-access-ConfMan-during-startup - * - https://docs.microsoft.com/en-us/aspnet/core/migration/50-to-60?view=aspnetcore-5.0&tabs=visual-studio#where-do-i-put-state-that-was-stored-as-fields-in-my-program-or-startup-class - * - * */ - ConfigurationManager configuration = builder.Configuration; var logger = LogManager.Setup() @@ -141,10 +128,13 @@ builder.Services.AddAuthorization(options => options.FallbackPolicy = options.DefaultPolicy; }); -// redis replliminare +//setup Blazor +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + +// redis preliminare builder.Services.AddSingleton(redisMultiplexer); builder.Services.AddRazorPages(); -builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); @@ -153,20 +143,10 @@ builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); -#if false -builder.Services.AddBlazoredLocalStorage(); -builder.Services.AddBlazoredSessionStorage(); -#endif + // aggiunta helper local/session storage service builder.Services.AddScoped(); builder.Services.AddScoped(); -//builder.Services.AddScoped(); -//builder.Services.AddScoped(); -//builder.Services.AddScoped(sp => -// new SessionStorageService(sp.GetRequiredService())); -//builder.Services.AddScoped(sp => -// new LocalStorageService(sp.GetRequiredService())); - builder.Services.AddHttpClient(); @@ -179,7 +159,9 @@ logger.Info("Build App"); // aggiunt base URL x routing corretto -app.UsePathBase(configuration.GetValue("SpecialConf:AppUrl")); +string baseUrl = configuration.GetValue("SpecialConf:AppUrl") ?? ""; +app.UsePathBase(baseUrl); +logger.Info($"BaseUrl: {baseUrl}"); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) @@ -193,6 +175,13 @@ app.UseHttpsRedirection(); app.UseStaticFiles(); +app.UseRouting(); + +app.UseAuthentication(); +app.UseAuthorization(); + +app.UseAntiforgery(); + // gestione static files: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0 string BasePathOdlReturn = configuration.GetValue("ServerConf:BasePathOdlReturn") ?? configuration.GetValue("OptConf:BasePathOdlReturn") ?? ""; if (!string.IsNullOrEmpty(BasePathOdlReturn)) @@ -234,19 +223,8 @@ if (!string.IsNullOrEmpty(BasePathOdlReturn)) } } -app.UseRouting(); - -app.UseAuthentication(); -app.UseAuthorization(); - -app.UseEndpoints(endpoints => -{ - endpoints.MapControllers(); - endpoints.MapBlazorHub(); - endpoints.MapFallbackToPage("/_Host"); -}); -//app.MapBlazorHub(); -//app.MapFallbackToPage("/_Host"); +app.MapRazorComponents() + .AddInteractiveServerRenderMode(); logger.Info("Run App"); diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 68c19573..323e79be 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 8.16.2605.2616

+

Versione: 8.16.2605.2617


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 418a7c18..e207479d 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2605.2616 +8.16.2605.2617 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 19b26f9f..68083a5c 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2605.2616 + 8.16.2605.2617 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false diff --git a/MP.SPEC/_Imports.razor b/MP.SPEC/_Imports.razor index 8af8acff..1e775e6f 100644 --- a/MP.SPEC/_Imports.razor +++ b/MP.SPEC/_Imports.razor @@ -1,5 +1,6 @@ @using System.Net.Http @using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components @using Microsoft.AspNetCore.Components.Authorization @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @@ -15,6 +16,7 @@ @using MP.SPEC.Components @using MP.SPEC.Components.Chart @using MP.SPEC.Components.Fermate +@using MP.SPEC.Components.Layout @using MP.SPEC.Components.ProdKit @using MP.SPEC.Components.Reparti @using EgwCoreLib.Razor \ No newline at end of file diff --git a/MP.SPEC/appsettings.json b/MP.SPEC/appsettings.json index a061328d..bf3f1ae9 100644 --- a/MP.SPEC/appsettings.json +++ b/MP.SPEC/appsettings.json @@ -81,7 +81,7 @@ "maxChar4Scroll": 21 }, "SpecialConf": { - "AppUrl": "/MP/SPEC", + "AppUrl": "/MP/SPEC/", "CodApp": "MP-SPEC", "CodModulo": "MP-SPEC" }