diff --git a/REMAN/NKC.Data/Controllers/NKCController.cs b/REMAN/NKC.Data/Controllers/NKCController.cs index 863198f..5e6d8f5 100644 --- a/REMAN/NKC.Data/Controllers/NKCController.cs +++ b/REMAN/NKC.Data/Controllers/NKCController.cs @@ -58,7 +58,7 @@ namespace NKC.Data.Controllers dbResult = localDbCtx .DbSetRemnants .Where(x => (x.MatID == matId || matId == 0) && (x.QtyAvail >= minQty || minQty == 0)) - .OrderBy(o => o.Area) + //.OrderBy(o => o.Area) .ToList(); } return dbResult; diff --git a/REMAN/REMAN/Data/RDataService.cs b/REMAN/REMAN/Data/RDataService.cs index cc6b38b..b5b6561 100644 --- a/REMAN/REMAN/Data/RDataService.cs +++ b/REMAN/REMAN/Data/RDataService.cs @@ -55,6 +55,7 @@ namespace REMAN.Data } protected const string rKeyMaterials = "REMAN:Materials"; + protected const string rKeyRemnants = "REMAN:Remnants"; public async Task> MaterialsGetAll() { List dbResult = new List(); @@ -79,11 +80,38 @@ namespace REMAN.Data } return await Task.FromResult(dbResult); } + + public async Task> RemnantsGetFilt(int matId, int minQty) + { + List dbResult = new List(); + string rawData; + var redisDataList = await distributedCache.GetAsync(rKeyRemnants); + if (redisDataList != null) + { + rawData = Encoding.UTF8.GetString(redisDataList); + dbResult = JsonConvert.DeserializeObject>(rawData); + } + else + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + var rawList = dbController.RemnantsGetFilt(matId, minQty); + dbResult = rawList.OrderBy(o => o.Area).ToList(); + rawData = JsonConvert.SerializeObject(dbResult); + redisDataList = Encoding.UTF8.GetBytes(rawData); + await distributedCache.SetAsync(rKeyRemnants, redisDataList, cacheOpt(false)); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB + caching per RemnantsGetAll: {ts.TotalMilliseconds} ms"); + } + return await Task.FromResult(dbResult); + } + public void Dispose() { // Clear database controller dbController.Dispose(); - } + } private DistributedCacheEntryOptions cacheOpt(bool fastCache) { var numSecAbsExp = fastCache ? chAbsExp : chAbsExp * 10; diff --git a/REMAN/REMAN/Pages/Index.razor b/REMAN/REMAN/Pages/Index.razor index 6085c4a..586f38a 100644 --- a/REMAN/REMAN/Pages/Index.razor +++ b/REMAN/REMAN/Pages/Index.razor @@ -2,8 +2,6 @@ Index -

Hello, world!

+

ReMan

-Welcome to your new app. - - +Remnants Management App diff --git a/REMAN/REMAN/Pages/Materials.razor b/REMAN/REMAN/Pages/Materials.razor index 0f9048c..607eafa 100644 --- a/REMAN/REMAN/Pages/Materials.razor +++ b/REMAN/REMAN/Pages/Materials.razor @@ -14,7 +14,7 @@ } else if (totalCount == 0) { -
Nessun record trovato
+
No Record Found
} else { diff --git a/REMAN/REMAN/Pages/Remnants.razor b/REMAN/REMAN/Pages/Remnants.razor index 5390ac2..78178bf 100644 --- a/REMAN/REMAN/Pages/Remnants.razor +++ b/REMAN/REMAN/Pages/Remnants.razor @@ -1,7 +1,79 @@ -@page "/remnants" +@page "/Remnants" -

Remnants

+@using REMAN.Components -@code { +Remnants + +
+
+
+
+

Remnants

+
+
+ filtro sel materiale +
+
+
+
+ @if (ListRecords == null) + { + + } + else if (totalCount == 0) + { +
No Record Found
+ } + else + { +
+
+ @*
*@ + + + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + + + } + +
CodLocationQtyL x W x T (mm)Note
+ + + @record.MaterialNav.MatExtCode + + @record.Location + + @record.QtyAvail + + @record.LMm x @record.WMm x @record.TMm + + @record.Note +
+
+
+ } +
+ +
-} diff --git a/REMAN/REMAN/Pages/Remnants.razor.cs b/REMAN/REMAN/Pages/Remnants.razor.cs new file mode 100644 index 0000000..0a3d44e --- /dev/null +++ b/REMAN/REMAN/Pages/Remnants.razor.cs @@ -0,0 +1,124 @@ +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 REMAN; +using REMAN.Shared; +using REMAN.Components; +using NKC.Data.DbModels; +using REMAN.Data; + +namespace REMAN.Pages +{ + public partial class Remnants : ComponentBase, IDisposable + { + + private List SearchRecords; + private List ListRecords; + + + private int _currPage { get; set; } = 1; + + private int _numRecord { get; set; } = 10; + + private int currPage + { + get => _currPage; + set + { + if (_currPage != value) + { + _currPage = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + private bool isLoading { get; set; } = false; + + private int numRecord + { + get => _numRecord; + set + { + if (_numRecord != value) + { + _numRecord = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + [Inject] + protected RDataService DataService { get; set; } + + [Inject] + protected IJSRuntime JSRuntime { get; set; } + + protected int totalCount + { + get + { + int answ = 0; + if (ListRecords != null) + { + answ = ListRecords.Count; + } + return answ; + } + } + + private async Task ReloadData() + { + isLoading = true; + SearchRecords = await DataService.RemnantsGetFilt(0, 0); + ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + isLoading = false; + } + + protected void ForceReload(int newNum) + { + numRecord = newNum; + } + + protected void ForceReloadPage(int newNum) + { + currPage = newNum; + } + + protected override async Task OnInitializedAsync() + { + //SelPlantId = 0; + //SelTranspId = 0; + //AppMService.ShowSearch = false; + //AppMService.PageName = "Fornitore"; + //AppMService.PageIcon = "fas fa-industry pr-2"; + //AppMService.EA_SearchUpdated += OnSeachUpdated; + await ReloadData(); + } + + protected void Select(RemnantsModel selRecord) + { + } + + protected void ResetData() + { + //DataService.rollBackEdit(currRecord); + } + + public void Dispose() + { + //AppMService.EA_SearchUpdated -= OnSeachUpdated; + } + } +} \ No newline at end of file diff --git a/REMAN/REMAN/Shared/SurveyPrompt.razor b/REMAN/REMAN/Shared/SurveyPrompt.razor deleted file mode 100644 index e3e6429..0000000 --- a/REMAN/REMAN/Shared/SurveyPrompt.razor +++ /dev/null @@ -1,16 +0,0 @@ -
- - @Title - - - Please take our - brief survey - - and tell us what you think. -
- -@code { - // Demonstrates how a parent component can supply parameters - [Parameter] - public string? Title { get; set; } -}