Aggiunta memorystorage x dati ripetuti
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
@using NLog;
|
||||
@using MP.Data.Services;
|
||||
@using NLog;
|
||||
@using System.Net.Http
|
||||
@using System.Net.Http.Json
|
||||
@inject HttpClient Http
|
||||
@inject MemStorUtil CIServ
|
||||
|
||||
<div class="row small">
|
||||
<div class="col-12 col-sm-6 col-xl-3 mb-2">
|
||||
@@ -141,11 +143,14 @@
|
||||
}
|
||||
protected async Task ReloadMacchine()
|
||||
{
|
||||
string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictMacc?MatrOpr={MatrOpr}";
|
||||
var rawData = await Http.GetFromJsonAsync<Dictionary<string, string>>(ApiUrl);
|
||||
if (rawData != null)
|
||||
if (ListMacchineAll == null || ListMacchineAll.Count == 0)
|
||||
{
|
||||
ListMacchineAll = rawData;
|
||||
string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictMacc?MatrOpr={MatrOpr}";
|
||||
var rawData = await Http.GetFromJsonAsync<Dictionary<string, string>>(ApiUrl);
|
||||
if (rawData != null)
|
||||
{
|
||||
ListMacchineAll = rawData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +199,12 @@
|
||||
}
|
||||
|
||||
protected string IdxMaccSel { get; set; } = "";
|
||||
protected Dictionary<string, string> ListMacchineAll { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> ListMacchineAll
|
||||
{
|
||||
get => MemStorUtil.DictMacchine;
|
||||
set => MemStorUtil.DictMacchine = value;
|
||||
}
|
||||
|
||||
protected Dictionary<string, string> ListArticoliAll { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string>? ListArticoli { get; set; } = null;
|
||||
protected int TotalCount { get; set; } = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@* @attribute [RenderModeAuto] *@
|
||||
@attribute [RenderModeServer]
|
||||
@attribute [RenderModeAuto]
|
||||
@* @attribute [RenderModeServer] *@
|
||||
|
||||
@using MP.Data.Services;
|
||||
@using MP.Data;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
using MP.Data.Services;
|
||||
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
|
||||
// servizio cache locale dati
|
||||
builder.Services.AddScoped<MemStorUtil>();
|
||||
|
||||
// aggiunto x gestione chiamate WebAPI
|
||||
builder.Services.AddScoped(sp =>
|
||||
new HttpClient
|
||||
@@ -9,4 +13,5 @@ builder.Services.AddScoped(sp =>
|
||||
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
|
||||
});
|
||||
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<meta name="description" content="MP Tablet" />
|
||||
<meta name="author" content="EgalWare" />
|
||||
<link rel="shortcut icon" href="~/favicon.ico" />
|
||||
<link rel="shortcut icon" href="images/favicon.ico" />
|
||||
<base href="/MP/TAB2/" />
|
||||
@* <link rel="stylesheet" href="bootstrap/bootstrap.min.css" /> *@
|
||||
<link rel="stylesheet" href="lib/font-awesome/css/all.min.css" />
|
||||
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="font.min.css" />
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
@inject NavigationManager NavMan
|
||||
@inject ListSelectDataSrv MDataService
|
||||
@inject MemStorUtil MStor
|
||||
|
||||
<div class="page">
|
||||
|
||||
@@ -21,7 +24,7 @@
|
||||
@* <div class="row w-100 slideMen"> *@
|
||||
<div class="row w-100 slideMen">
|
||||
<div class="">
|
||||
<MP_TAB.Client.Components.SlideMenu MenuItems="@CurrMenuItems"></MP_TAB.Client.Components.SlideMenu>
|
||||
<SlideMenu MenuItems="@CurrMenuItems"></SlideMenu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,7 +35,7 @@
|
||||
@Body
|
||||
</div>
|
||||
<div class="sidebar" id="barLat">
|
||||
<NavMenu MenuItems="@CurrMenuItems" />
|
||||
<NavMenu MenuItems="@CurrMenuItems"></NavMenu>
|
||||
</div>
|
||||
</article>
|
||||
</main>
|
||||
@@ -50,10 +53,11 @@
|
||||
/// Elenco items da menù per pagina corrente...
|
||||
/// </summary>
|
||||
protected List<LinkMenu> CurrMenuItems { get; set; } = new List<LinkMenu>();
|
||||
|
||||
/// <summary>
|
||||
/// Livello corrente del menu
|
||||
/// </summary>
|
||||
protected string CurrLevel = "T2H";
|
||||
protected string CurrLevel { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Init struttura dati
|
||||
@@ -61,8 +65,16 @@
|
||||
/// <returns></returns>
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
CurrLevel = MemStorUtil.PageLevel(NavMan.Uri);
|
||||
if (MemStorUtil.DictMenu.ContainsKey(CurrLevel))
|
||||
{
|
||||
CurrMenuItems = MemStorUtil.DictMenu[CurrLevel];
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrMenuItems = await MDataService.ListLinkFilt(CurrLevel);
|
||||
MemStorUtil.DictMenu.Add(CurrLevel, CurrMenuItems);
|
||||
}
|
||||
await Task.Delay(1);
|
||||
CurrMenuItems = await MDataService.ListLinkFilt(CurrLevel);
|
||||
// return base.OnInitializedAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
@inject ListSelectDataSrv MDataService
|
||||
@inject NavigationManager NavMan
|
||||
@inject ListSelectDataSrv MDataService
|
||||
|
||||
@* <div class="row w-100 slideMen"> *@
|
||||
@* <div class="row w-100 slideMen">
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
@inject NavigationManager NavMan
|
||||
@inject ListSelectDataSrv MDataService
|
||||
@inject MemStorUtil MStor
|
||||
|
||||
@* @attribute [StreamRendering(true)] *@
|
||||
|
||||
<!-- Temporary workaround until MapRazorComponents supports AddAdditionalAssemblies -->
|
||||
<!-- Once that is implemented, the main project won't need to include this file -->
|
||||
<MP_TAB.Client.Components.SlideMenu MenuItems="@MenuItems"></MP_TAB.Client.Components.SlideMenu>
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public List<LinkMenu> MenuItems { get; set; } = new List<LinkMenu>();
|
||||
|
||||
}
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
|
||||
@* @attribute [StreamRendering(true)] *@
|
||||
|
||||
<!-- Temporary workaround until MapRazorComponents supports AddAdditionalAssemblies -->
|
||||
<!-- Once that is implemented, the main project won't need to include this file -->
|
||||
@* @if (listMSE == null || listMSE.Count == 0)
|
||||
{
|
||||
<div class="row">
|
||||
@@ -21,4 +18,7 @@
|
||||
else
|
||||
{
|
||||
} *@
|
||||
|
||||
<!-- Temporary workaround until MapRazorComponents supports AddAdditionalAssemblies -->
|
||||
<!-- Once that is implemented, the main project won't need to include this file -->
|
||||
<MP_TAB.Client.Pages.StatusMap ListMSE="@listMSE"></MP_TAB.Client.Pages.StatusMap>
|
||||
|
||||
@@ -12,3 +12,7 @@
|
||||
@using MP.Data.Services
|
||||
@using MP_TAB
|
||||
@using MP_TAB.Components
|
||||
@*
|
||||
@using MP_TAB.Client.Components
|
||||
@using MP_TAB.Client.Pages
|
||||
*@
|
||||
@@ -20,7 +20,7 @@ namespace MP_TAB.Controllers
|
||||
Log.Info("Starting ODLController");
|
||||
_configuration = configuration;
|
||||
CtrDataServ = DataService;
|
||||
Log.Info("Avviato ODLController");
|
||||
Log.Trace("Avviato ODLController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
@@ -110,6 +110,12 @@
|
||||
<Content Update="wwwroot\fonts\roboto-v27-latin-regular.woff2">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\images\favicon.ico">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\images\favicon.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\images\macchine\small\Steamware.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
@@ -19,6 +19,7 @@ builder.Services.AddSingleton<StatusData>();
|
||||
builder.Services.AddSingleton<ListSelectDataSrv>();
|
||||
builder.Services.AddSingleton<OrderDataSrv>();
|
||||
builder.Services.AddScoped<UserServ>();
|
||||
builder.Services.AddScoped<MemStorUtil>();
|
||||
|
||||
// nuova versione contenuti...
|
||||
builder.Services.AddRazorComponents()
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
@@ -581,11 +581,11 @@ namespace MP.Data.Controllers
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetLinkMenu
|
||||
.Where(x => x.TipoLink == tipoLink)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.ordine)
|
||||
.ToList();
|
||||
.DbSetLinkMenu
|
||||
.Where(x => x.TipoLink == tipoLink)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.ordine)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using MP.Data.DatabaseModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
public class MemStorUtil
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Matricola operatore corrente (x filtraggio dati)
|
||||
/// ToDo: gestire login!!!
|
||||
/// </summary>
|
||||
public static int MatrOpr = 102;
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario macchine
|
||||
/// </summary>
|
||||
public static Dictionary<string, string> DictMacchine { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario Menu
|
||||
/// </summary>
|
||||
public static Dictionary<string, List<LinkMenu>> DictMenu {get;set;} = new Dictionary<string, List<LinkMenu>>();
|
||||
|
||||
/// <summary>
|
||||
/// Reset cache memory
|
||||
/// </summary>
|
||||
public void ResetCache()
|
||||
{
|
||||
DictMacchine = new Dictionary<string, string>();
|
||||
DictMenu = new Dictionary<string, List<LinkMenu>>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il livello pagina dato URL
|
||||
/// - se contiene ?IdxMacc --> T2D (detail)
|
||||
/// - altrimenti --> T2H
|
||||
/// </summary>
|
||||
/// <param name="pageUrl"></param>
|
||||
/// <returns></returns>
|
||||
public static string PageLevel(string pageUrl)
|
||||
{
|
||||
string answ = "T2H";
|
||||
if(pageUrl.Contains("?IdxMacc="))
|
||||
{
|
||||
answ = "T2D";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user