Ancora update pagina Remnants
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace REMAN.Data
|
||||
}
|
||||
|
||||
protected const string rKeyMaterials = "REMAN:Materials";
|
||||
protected const string rKeyRemnants = "REMAN:Remnants";
|
||||
public async Task<List<MaterialModel>> MaterialsGetAll()
|
||||
{
|
||||
List<MaterialModel> dbResult = new List<MaterialModel>();
|
||||
@@ -79,11 +80,38 @@ namespace REMAN.Data
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<List<RemnantsModel>> RemnantsGetFilt(int matId, int minQty)
|
||||
{
|
||||
List<RemnantsModel> dbResult = new List<RemnantsModel>();
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(rKeyRemnants);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<RemnantsModel>>(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;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
<PageTitle>Index</PageTitle>
|
||||
|
||||
<h1>Hello, world!</h1>
|
||||
<h1>ReMan</h1>
|
||||
|
||||
Welcome to your new app.
|
||||
|
||||
<SurveyPrompt Title="How is Blazor working for you?" />
|
||||
Remnants Management App
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
|
||||
<div class="alert alert-warning text-center display-4">No Record Found</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,7 +1,79 @@
|
||||
@page "/remnants"
|
||||
@page "/Remnants"
|
||||
|
||||
<h3>Remnants</h3>
|
||||
@using REMAN.Components
|
||||
|
||||
@code {
|
||||
<PageTitle>Remnants</PageTitle>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header table-primary pb-0 mb-0">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="px-2">
|
||||
<h2>Remnants</h2>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
filtro sel materiale
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">No Record Found</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@*<div id="qrCodeImg"></div>*@
|
||||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Cod</th>
|
||||
<th>Location</th>
|
||||
<th>Qty</th>
|
||||
<th class="text-right">L x W x T (mm)</th>
|
||||
<th class="text-right">Note</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr>
|
||||
<td class="text-nowrap">
|
||||
<button class="btn btn-sm btn-info" @onclick="() => Select(record)">
|
||||
<i class="oi oi-magnifying-glass"></i>
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
<b>@record.MaterialNav.MatExtCode</b>
|
||||
</td>
|
||||
<td>
|
||||
@record.Location
|
||||
</td>
|
||||
<td>
|
||||
<b>@record.QtyAvail</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span>@record.LMm x @record.WMm x @record.TMm</span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@record.Note
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="card-footer p-1">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
}
|
||||
|
||||
@@ -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<RemnantsModel> SearchRecords;
|
||||
private List<RemnantsModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<div class="alert alert-secondary mt-4">
|
||||
<span class="oi oi-pencil me-2" aria-hidden="true"></span>
|
||||
<strong>@Title</strong>
|
||||
|
||||
<span class="text-nowrap">
|
||||
Please take our
|
||||
<a target="_blank" class="font-weight-bold link-dark" href="https://go.microsoft.com/fwlink/?linkid=2149017">brief survey</a>
|
||||
</span>
|
||||
and tell us what you think.
|
||||
</div>
|
||||
|
||||
@code {
|
||||
// Demonstrates how a parent component can supply parameters
|
||||
[Parameter]
|
||||
public string? Title { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user