Merge branch 'release/FixCoreProj'

This commit is contained in:
Samuele Locatelli
2023-03-02 10:27:48 +01:00
13 changed files with 655 additions and 187 deletions
+1 -1
View File
@@ -303,11 +303,11 @@ namespace StockMan.CORE.Components
#region Private Properties
private int _totalCount { get; set; } = 0;
[Inject]
private IConfiguration Configuration { get; set; } = null!;
private int _totalCount { get; set; } = 0;
private int currPage
{
get => actFilter.CurrPage;
@@ -0,0 +1,93 @@
@if (isLoading)
{
<LoadingData></LoadingData>
}
else if (listLocAll == null)
{
<div class="alert alert-warning">Nessun record trovato</div>
}
else
{
<div class="card">
<div class="card-header d-flex justify-content-between">
<div class="py-1">
Lista Posizioni
</div>
<div>
<button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#modalNewFam">Aggiungi Operatore</button>
</div>
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>
Desc
</th>
<th>
Tipo
</th>
<th>
</th>
</tr>
</thead>
<tbody>
@foreach (var item in listLocAll)
{
<tr>
<td>
@item.Descr
</td>
<td>
@(item.LocTypeNav?.Descr ?? "")
</td>
<td>
<button class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#modalNewFam" @onclick="()=>setCurrLoc(item)"><i class="fa-solid fa-pen-to-square"></i></button>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="modalNewFam" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="modalNewFamLabel">Aggiungere nuovo articolo</h1>
<button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="w-100">
<div class="form-floating">
<input id="id" @bind="@ID" class="form-control w-100 my-1" />
<label for="id" class="form-label">Id locazione</label>
</div>
<div class="form-floating">
<input id="descr" @bind="@descr" class="form-control w-100 my-1" />
<label for="descr" class="form-label">Descrizione</label>
</div>
<div class="form-floating">
<select class="form-select" id="locType" @bind="@loctype">
<option value="0">---Selezionare un record---</option>
@if (listLocTypes != null)
{
@foreach (var item in listLocTypes)
{
<option value="@item.Id">@item.Descr</option>
}
}
</select>
<label for="locType" class="form-label">Tipo di locazione</label>
</div>
</div>
<div class="text-center mt-5">
<button class="btn btn-success" @onclick="()=>ModLoc()"><i class="fa-regular fa-circle-check"></i></button>
<button class="btn btn-danger" data-bs-dismiss="modal"><i class="fa-solid fa-ban"></i></button>
</div>
</div>
</div>
</div>
</div>
}
@@ -0,0 +1,138 @@
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 EgwCoreLib.Razor;
using EgwCoreLib.Razor.Data;
using StockMan.CORE;
using StockMan.CORE.Data;
using StockMan.CORE.Shared;
using StockMan.Data.DbModels;
using StockMan.Data;
namespace StockMan.CORE.Components
{
public partial class ListPosizioni
{
#region Public Properties
[Parameter]
public PosizioniSelectFilter actFilter { get; set; } = new PosizioniSelectFilter();
[Parameter]
public EventCallback<int> updateRecordCount { get; set; }
public LocationModel? currLoc { get; set; } = null;
public bool isLoading { get; set; } = false;
#endregion Public Properties
#region Protected Fields
protected string _descr = "";
protected string _ID = "";
protected string _loctype = "";
protected List<LocationModel>? listLocAll = null;
protected List<LocationModel>? searchRecord = null;
protected List<LocTypeModel>? listLocTypes = null;
#endregion Protected Fields
#region Protected Properties
protected string descr
{
get => _descr;
set { _descr = value; }
}
protected string ID
{
get => _ID;
set { _ID = value; }
}
protected string loctype
{
get => _loctype;
set { _loctype = value; }
}
[Inject]
protected NavigationManager NavManager { get; set; } = null!;
[Inject]
protected StockDataService SDService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
private int _totalCount { get; set; } = 0;
private int currPage
{
get => actFilter.CurrPage;
set => actFilter.CurrPage = value;
}
private int numRecord
{
get => actFilter.NumRec;
set => actFilter.NumRec = value;
}
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
updateRecordCount.InvokeAsync(value);
}
}
}
protected async Task ModLoc()
{
LocationModel currRecToMod = new LocationModel()
{
Id = ID,
Descr = descr,
LocTypeId = loctype
};
var done = await SDService.LocationMod(currRecToMod);
if (done)
{
NavManager.NavigateTo(NavManager.Uri, true);
}
}
protected override async Task OnParametersSetAsync()
{
isLoading = true;
listLocTypes = await SDService.LocTypeGetAll();
searchRecord = await SDService.LocationGetAll();
totalCount = searchRecord.Count;
listLocAll = searchRecord.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
protected async Task setCurrLoc(LocationModel currRecToMod)
{
await Task.Delay(1);
ID = currRecToMod.Id;
descr = currRecToMod.Descr;
loctype = currRecToMod.LocTypeId;
}
#endregion Protected Methods
}
}
+20 -16
View File
@@ -55,27 +55,31 @@ else
</tr>
</thead>
<tbody>
@foreach (var item in listItemByLoc)
@if (listItemByLoc != null)
{
<tr>
<td><button class="btn btn-sm btn-dark" @onclick="()=>selItemToDet(item.ItemNav.Id)"><i class="fa-solid fa-magnifying-glass"></i></button></td>
<td>
@item.ItemNav.Descr
</td>
<td>
@item.QtyConf
</td>
<td>
@($"{item.ItemNav.CurrValue:C2}")
</td>@if (isSX)
{
<td><button class="btn btn-sm btn-info text-nowrap" @onclick="()=>SetMove(item)">Sposta <i class="fa-solid fa-arrow-right"></i></button></td>
}
</tr>
@foreach (var item in listItemByLoc)
{
<tr>
<td><button class="btn btn-sm btn-dark" @onclick="()=>selItemToDet(item.ItemNav.Id)"><i class="fa-solid fa-magnifying-glass"></i></button></td>
<td>
@item.ItemNav.Descr
</td>
<td>
@item.QtyConf
</td>
<td>
@($"{item.ItemNav.CurrValue:C2}")
</td>@if (isSX)
{
<td><button class="btn btn-sm btn-info text-nowrap" @onclick="()=>SetMove(item)">Sposta <i class="fa-solid fa-arrow-right"></i></button></td>
}
</tr>
}
}
</tbody>
</table>
</div>
</div>
}
+75 -3
View File
@@ -1,3 +1,4 @@
using EgwCoreLib.Razor;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using StockMan.CORE.Data;
@@ -36,10 +37,52 @@ namespace StockMan.CORE.Components
[Parameter]
public string locSX_ID { get; set; } = "";
public int qty { get; set; } = 0;
[Parameter]
public string UserName { get; set; } = "";
[Parameter]
public LocSXSelectFilter actFilterSX { get; set; } = new LocSXSelectFilter();
[Parameter]
public LocDXSelectFilter actFilterDX { get; set; } = new LocDXSelectFilter();
[Parameter]
public EventCallback<int> updateRecordCount { get; set; }
private int currPageSX
{
get => actFilterSX.CurrPage;
set => actFilterSX.CurrPage = value;
}
private int numRecordSX
{
get => actFilterSX.NumRec;
set => actFilterSX.NumRec = value;
}
private int currPageDX
{
get => actFilterDX.CurrPage;
set => actFilterDX.CurrPage = value;
}
private int numRecordDX
{
get => actFilterDX.NumRec;
set => actFilterDX.NumRec = value;
}
private int _totalCount = 0;
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
updateRecordCount.InvokeAsync(value);
}
}
}
public int qty { get; set; } = 0;
protected DataPager? pagerLocation;
#endregion Public Properties
@@ -84,6 +127,7 @@ namespace StockMan.CORE.Components
protected IJSRuntime JSRuntime { get; set; } = null!;
protected List<ItemStockModel>? listItemByLoc { get; set; } = null;
protected List<ItemStockModel>? listSearch { get; set; } = null;
protected string locSxoDx
{
@@ -110,6 +154,25 @@ namespace StockMan.CORE.Components
#region Protected Methods
protected void ForceReloadSX(int newNum)
{
numRecordSX = newNum;
}
protected void ForceReloadPageSX(int newNum)
{
currPageSX = newNum;
}
protected void ForceReloadDX(int newNum)
{
numRecordDX = newNum;
}
protected void ForceReloadPageDX(int newNum)
{
currPageDX = newNum;
}
protected async Task Move()
{
bool done = false;
@@ -168,7 +231,16 @@ namespace StockMan.CORE.Components
protected async Task ReloadData()
{
isLoading = true;
listItemByLoc = await SDService.ItemsGetByLocation(currLoc);
listSearch = await SDService.ItemsGetByLocation(currLoc);
totalCount = listSearch.Count;
if (isSX)
{
listItemByLoc = listSearch.Skip(numRecordSX * (currPageSX - 1)).Take(numRecordSX).ToList();
}
else
{
listItemByLoc = listSearch.Skip(numRecordDX * (currPageDX - 1)).Take(numRecordDX).ToList();
}
isLoading = false;
}
+68
View File
@@ -0,0 +1,68 @@
namespace StockMan.CORE.Data
{
public class LocDXSelectFilter
{
#region Public Constructors
public LocDXSelectFilter()
{ }
#endregion Public Constructors
#region Public Properties
public int CurrPage { get; set; } = 1;
public int MaxRecord { get; set; } = 100;
public int NumRec { get; set; } = 10;
public int TotCount { get; set; } = 0;
#endregion Public Properties
#region Public Methods
public LocDXSelectFilter clone()
{
LocDXSelectFilter clonedData = new LocDXSelectFilter()
{
CurrPage = this.CurrPage,
MaxRecord = this.MaxRecord,
NumRec = this.NumRec,
TotCount = this.TotCount,
};
return clonedData;
}
public override bool Equals(object? obj)
{
if (obj == null)
return false;
if (!(obj is LocDXSelectFilter item))
return false;
if (MaxRecord != item.MaxRecord)
return false;
if (NumRec != item.NumRec)
return false;
if (TotCount != item.TotCount)
return false;
if (CurrPage != item.CurrPage)
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
}
+68
View File
@@ -0,0 +1,68 @@
namespace StockMan.CORE.Data
{
public class LocSXSelectFilter
{
#region Public Constructors
public LocSXSelectFilter()
{ }
#endregion Public Constructors
#region Public Properties
public int CurrPage { get; set; } = 1;
public int MaxRecord { get; set; } = 100;
public int NumRec { get; set; } = 10;
public int TotCount { get; set; } = 0;
#endregion Public Properties
#region Public Methods
public LocSXSelectFilter clone()
{
LocSXSelectFilter clonedData = new LocSXSelectFilter()
{
CurrPage = this.CurrPage,
MaxRecord = this.MaxRecord,
NumRec = this.NumRec,
TotCount = this.TotCount,
};
return clonedData;
}
public override bool Equals(object? obj)
{
if (obj == null)
return false;
if (!(obj is LocSXSelectFilter item))
return false;
if (MaxRecord != item.MaxRecord)
return false;
if (NumRec != item.NumRec)
return false;
if (TotCount != item.TotCount)
return false;
if (CurrPage != item.CurrPage)
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
}
@@ -0,0 +1,68 @@
namespace StockMan.CORE.Data
{
public class PosizioniSelectFilter
{
#region Public Constructors
public PosizioniSelectFilter()
{ }
#endregion Public Constructors
#region Public Properties
public int CurrPage { get; set; } = 1;
public int MaxRecord { get; set; } = 100;
public int NumRec { get; set; } = 10;
public int TotCount { get; set; } = 0;
#endregion Public Properties
#region Public Methods
public PosizioniSelectFilter clone()
{
PosizioniSelectFilter clonedData = new PosizioniSelectFilter()
{
CurrPage = this.CurrPage,
MaxRecord = this.MaxRecord,
NumRec = this.NumRec,
TotCount = this.TotCount,
};
return clonedData;
}
public override bool Equals(object? obj)
{
if (obj == null)
return false;
if (!(obj is PosizioniSelectFilter item))
return false;
if (MaxRecord != item.MaxRecord)
return false;
if (NumRec != item.NumRec)
return false;
if (TotCount != item.TotCount)
return false;
if (CurrPage != item.CurrPage)
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
}
+40
View File
@@ -587,6 +587,46 @@ namespace StockMan.CORE.Data
Log.Debug($"LocationGetAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
/// <summary>
/// Lista Location
/// </summary>
/// <returns></returns>
public async Task<List<LocTypeModel>> LocTypeGetAll()
{
string source = "DB";
List<LocTypeModel>? dbResult = new List<LocTypeModel>();
string currKey = $"{rKeyLocType}:*";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<LocTypeModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<LocTypeModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.LocTypeGetAll();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
}
if (dbResult == null)
{
dbResult = new List<LocTypeModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"LocTypeGetAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
/// <summary>
/// Lista Location
+3 -88
View File
@@ -1,91 +1,6 @@
@page "/Posizioni"
@using StockMan.CORE.Components;
<ListPosizioni updateRecordCount="UpdateTotCount" actFilter="currFilter"></ListPosizioni>
@if (isLoading)
{
<LoadingData></LoadingData>
}
else if (listLocAll == null)
{
<div class="alert alert-warning">Nessun record trovato</div>
}
else
{
<div class="card">
<div class="card-header d-flex justify-content-between">
<div class="py-1">
Lista Operatori
</div>
<div>
<button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#modalNewFam">Aggiungi Operatore</button>
</div>
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>
Desc
</th>
<th>
Tipo
</th>
<th>
</th>
</tr>
</thead>
<tbody>
@foreach (var item in listLocAll)
{
<tr>
<td>
@item.Descr
</td>
<td>
@(item.LocTypeNav?.Descr??"")
</td>
<td>
<button class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#modalNewFam" @onclick="()=>setCurrLoc(item)"><i class="fa-solid fa-pen-to-square"></i></button>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="modalNewFam" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="modalNewFamLabel">Aggiungere nuovo articolo</h1>
<button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="w-100">
<div class="form-floating">
<input id="codExt" @bind="@descr" class="form-control w-100 my-1" />
<label for="codExt" class="form-label">Descrizione</label>
</div>
<div class="form-floating">
<input id="Cognome" @bind="@loctype" class="form-control w-100 my-1" />
<label for="Cognome" class="form-label">Tipo di locazione</label>
</div>
</div>
<div class="text-center mt-5">
@if (currLoc == null)
{
<button class="btn btn-success" @onclick="()=>addNewItem()"><i class="fa-regular fa-circle-check"></i></button>
}
else
{
<button class="btn btn-success" @onclick="()=>ModOpr()"><i class="fa-regular fa-circle-check"></i></button>
}
<button class="btn btn-danger" data-bs-dismiss="modal"><i class="fa-solid fa-ban"></i></button>
</div>
</div>
</div>
</div>
</div>
}
<DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="@totalCount" showLoading="@isLoading" />
+17 -77
View File
@@ -6,96 +6,36 @@ namespace StockMan.CORE.Pages
{
public partial class Posizioni
{
#region Public Properties
public LocationModel? currLoc { get; set; } = null;
public bool isLoading { get; set; } = false;
#endregion Public Properties
#region Protected Fields
protected string _descr = "";
protected string _ID = "";
protected string _loctype = "";
protected List<LocationModel>? listLocAll = null;
#endregion Protected Fields
#region Protected Properties
protected string descr
protected int totalCount { get; set; }
public PosizioniSelectFilter currFilter { get; set; } = new PosizioniSelectFilter();
protected void ForceReload(int newNum)
{
get => _descr;
set { _descr = value; }
numRecord = newNum;
currPage = 1;
}
protected string ID
protected void ForceReloadPage(int newNum)
{
get => _ID;
set { _ID = value; }
currPage = newNum;
}
protected string loctype
protected void UpdateTotCount(int newTotCount)
{
get => _loctype;
set { _loctype = value; }
totalCount = newTotCount;
}
[Inject]
protected NavigationManager NavManager { get; set; } = null!;
[Inject]
protected StockDataService SDService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected async Task addNewItem()
private int currPage
{
LocationModel currRecToMod = new LocationModel()
{
Descr = descr,
LocTypeId = loctype
};
var done = await SDService.LocationAddNew(currRecToMod);
if (done)
{
NavManager.NavigateTo(NavManager.Uri, true);
}
get => currFilter.CurrPage;
set => currFilter.CurrPage = value;
}
protected async Task ModOpr()
private bool isLoading { get; set; } = false;
private int numRecord
{
LocationModel currRecToMod = new LocationModel()
{
Descr = descr,
LocTypeId = loctype
};
var done = await SDService.LocationMod(currRecToMod);
if (done)
{
NavManager.NavigateTo(NavManager.Uri, true);
}
get => currFilter.NumRec;
set => currFilter.NumRec = value;
}
protected override async Task OnInitializedAsync()
{
isLoading = true;
listLocAll = await SDService.LocationGetAll();
isLoading = false;
}
protected async Task setCurrLoc(LocationModel currRecToMod)
{
await Task.Delay(1);
ID = currRecToMod.Id;
descr = currRecToMod.Descr;
loctype = currRecToMod.LocTypeId;
}
#endregion Protected Methods
}
}
+6 -2
View File
@@ -21,9 +21,13 @@ else
}
<div class="row">
<div class="col">
<Location LocId_SX="catchCurrLocId_SX" isSX="true" isChanged="@isChanged" UserName="@currOpr.Id" locSX_ID="@currLocId_SX" locDX_ID="@currLocId_DX" ListLocationByType="@listLocationByType"></Location>
<Location actFilterSX="@currFilterSX" updateRecordCount="UpdateTotCountSX" LocId_SX="catchCurrLocId_SX" isSX="true" isChanged="@isChanged" UserName="@currOpr.Id" locSX_ID="@currLocId_SX" locDX_ID="@currLocId_DX" ListLocationByType="@listLocationByType"></Location>
<DataPager PageSize="@numRecordSX" currPage="@currPageSX" numRecordChanged="ForceReloadSX" numPageChanged="ForceReloadPageSX" totalCount="@totalCountSX" showLoading="@isLoading" />
</div>
<div class="col">
<Location LocId_DX="catchCurrLocId_DX" isSX="false" isChanged="@isChanged" locDX_ID="@currLocId_DX" locSX_ID="@currLocId_SX" ListLocationByType="@listLocationByType"></Location>
<Location actFilterDX="@currFilterDX" updateRecordCount="UpdateTotCountDX" LocId_DX="catchCurrLocId_DX" isSX="false" isChanged="@isChanged" locDX_ID="@currLocId_DX" locSX_ID="@currLocId_SX" ListLocationByType="@listLocationByType"></Location>
<DataPager PageSize="@numRecordDX" currPage="@currPageDX" numRecordChanged="ForceReloadDX" numPageChanged="ForceReloadPageDX" totalCount="@totalCountDX" showLoading="@isLoading" />
</div>
</div>
+58
View File
@@ -53,6 +53,7 @@ namespace StockMan.CORE.Pages
{
await Task.Delay(1);
isChanged = !isChanged;
currPageSX = 1;
}
protected override async Task OnInitializedAsync()
@@ -67,7 +68,64 @@ namespace StockMan.CORE.Pages
currLocId_DX = "";
currLocId_SX = "";
}
public LocSXSelectFilter currFilterSX { get; set; } = new LocSXSelectFilter();
protected void ForceReloadSX(int newNum)
{
numRecordSX = newNum;
currPageSX = 1;
}
protected void ForceReloadPageSX(int newNum)
{
currPageSX = newNum;
}
protected void UpdateTotCountSX(int newTotCount)
{
totalCountSX = newTotCount;
}
public int totalCountSX { get; set; } = 0;
private int currPageSX
{
get => currFilterSX.CurrPage;
set => currFilterSX.CurrPage = value;
}
private bool isLoading { get; set; } = false;
private int numRecordSX
{
get => currFilterSX.NumRec;
set => currFilterSX.NumRec = value;
}
public LocDXSelectFilter currFilterDX { get; set; } = new LocDXSelectFilter();
protected void ForceReloadDX(int newNum)
{
numRecordDX = newNum;
currPageDX = 1;
}
protected void ForceReloadPageDX(int newNum)
{
currPageDX = newNum;
}
protected void UpdateTotCountDX(int newTotCount)
{
totalCountDX = newTotCount;
}
public int totalCountDX { get; set; } = 0;
private int currPageDX
{
get => currFilterDX.CurrPage;
set => currFilterDX.CurrPage = value;
}
private int numRecordDX
{
get => currFilterDX.NumRec;
set => currFilterDX.NumRec = value;
}
#endregion Protected Methods
}
}