@@ -20,8 +21,11 @@
@code {
- [CascadingParameter(Name ="ShowSearch")]
- protected bool ShowSearch { get; set; }
+ protected bool ShowSearch
+ {
+ get => MService.ShowSearch;
+ set => MService.ShowSearch = value;
+ }
private string userName = "";
diff --git a/MP.SPEC/Components/DataPager.razor b/MP.SPEC/Components/DataPager.razor
new file mode 100644
index 00000000..54e6c829
--- /dev/null
+++ b/MP.SPEC/Components/DataPager.razor
@@ -0,0 +1,56 @@
+
+
+
+
+ @if (totalCount > 0)
+ {
+
+ }
+
+
+
+
+ @if (showLoading)
+ {
+
+ }
+
+
+
+
+
+
+ @if (!showLoading)
+ {
+ @totalCount records
+ }
+
+
+ @if (totalCount > 0)
+ {
+
+
+
+ }
+
+
+
+
diff --git a/MP.SPEC/Components/DataPager.razor.cs b/MP.SPEC/Components/DataPager.razor.cs
new file mode 100644
index 00000000..af42ed54
--- /dev/null
+++ b/MP.SPEC/Components/DataPager.razor.cs
@@ -0,0 +1,187 @@
+using Microsoft.AspNetCore.Components;
+
+namespace MP.SPEC.Components
+{
+ public partial class DataPager : ComponentBase
+ {
+ #region Public Properties
+
+ [Parameter]
+ public int currPage
+ {
+ get
+ {
+ return _numPage;
+ }
+ set
+ {
+ bool doReport = !_numPage.Equals(value);
+ if (doReport)
+ {
+ _numPage = value;
+ reportChangePage();
+ }
+ }
+ }
+
+ [Parameter]
+ public EventCallback
numPageChanged { get; set; }
+
+ [Parameter]
+ public EventCallback numRecordChanged { get; set; }
+
+ [Parameter]
+ public int PageSize
+ {
+ get
+ {
+ return _numRecord;
+ }
+ set
+ {
+ bool doReport = !_numRecord.Equals(value);
+ if (doReport)
+ {
+ _numRecord = value;
+ reportChange();
+ }
+ }
+ }
+
+ [Parameter]
+ public bool showLoading
+ {
+ get
+ {
+ return _showLoading;
+ }
+ set
+ {
+ if (value)
+ {
+ Random random = new Random();
+ percLoading = random.Next(30, 90);
+ }
+ else
+ {
+ percLoading = 5;
+ }
+ _showLoading = value;
+ }
+ }
+
+ [Parameter]
+ public int totalCount { get; set; } = 0;
+
+ #endregion Public Properties
+
+ #region Protected Fields
+
+ protected bool _showLoading = false;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ protected int _numPage { get; set; } = 1;
+
+ protected int _numRecord { get; set; } = 10;
+
+ protected int percLoading { get; set; } = 0;
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ protected string cssActive(int numPage)
+ {
+ string answ = "";
+ if (numPage == currPage)
+ {
+ answ = "active";
+ }
+ return answ;
+ }
+
+ protected override async Task OnInitializedAsync()
+ {
+ await Task.Run(() => showLoading = false);
+ }
+
+ protected void PaginationItemClick(int page)
+ {
+ currPage = page;
+ }
+
+ #endregion Protected Methods
+
+ #region Private Properties
+
+ private int endPage
+ {
+ get
+ {
+ int answ = (int)(currPage / numPages) * numPages + numPages;
+ answ = answ < LastPage ? answ : LastPage;
+ return answ;
+ }
+ }
+
+ private int LastPage
+ {
+ get
+ {
+ return Math.Max((int)Math.Ceiling(totalCount / (double)PageSize), 1);
+ }
+ }
+
+ private int nextBlock
+ {
+ get
+ {
+ int answ = currPage + numPages;
+ answ = answ < LastPage ? answ : LastPage;
+ return answ;
+ }
+ }
+
+ private int numPages { get; set; } = 10;
+
+ private int prevBlock
+ {
+ get
+ {
+ int answ = currPage - numPages;
+ answ = answ > 0 ? answ : 1;
+ return answ;
+ }
+ }
+
+ // calcola un set 1 .. numPages centrato sulla pagina corrente...
+ private int startPage
+ {
+ get
+ {
+ int answ = (int)(currPage / numPages) * numPages;
+ answ = answ > 0 ? answ : 1;
+ return answ;
+ }
+ }
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ private void reportChange()
+ {
+ numRecordChanged.InvokeAsync(PageSize);
+ }
+
+ private void reportChangePage()
+ {
+ numPageChanged.InvokeAsync(currPage);
+ }
+
+ #endregion Private Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.SPEC/Data/MessageService.cs b/MP.SPEC/Data/MessageService.cs
index 94ec9332..809b5f53 100644
--- a/MP.SPEC/Data/MessageService.cs
+++ b/MP.SPEC/Data/MessageService.cs
@@ -4,7 +4,7 @@
{
#region Private Fields
- private string searchVal;
+ private string searchVal = "";
private bool showSearch;
#endregion Private Fields
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs
index ead6f768..376cf359 100644
--- a/MP.SPEC/Data/MpDataService.cs
+++ b/MP.SPEC/Data/MpDataService.cs
@@ -44,7 +44,7 @@ namespace MP.SPEC.Data
#if false
// avvio timers...
- startTimers();
+ startTimers();
#endif
}
@@ -67,23 +67,6 @@ namespace MP.SPEC.Data
#region Public Methods
- public Task> ConfigGetAll()
- {
- return Task.FromResult(dbController.ConfigGetAll().ToList());
- }
-
- ///
- /// Restitusice elenco articoli cercati
- ///
- ///
- ///
- ///
- public async Task> ArticoliGetSearch(int numRecord, string azienda, string searchVal)
- {
- return await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal));
- }
-
-
public async Task> AnagTipoArtLV()
{
return await Task.FromResult(dbController.AnagTipoArtLV());
@@ -98,6 +81,18 @@ namespace MP.SPEC.Data
{
return await dbController.ArticoliDeleteRecord(currRec);
}
+
+ ///
+ /// Restitusice elenco articoli cercati
+ ///
+ ///
+ ///
+ ///
+ public async Task> ArticoliGetSearch(int numRecord, string azienda, string searchVal)
+ {
+ return await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal));
+ }
+
///
/// Aggiornamento record selezionato
///
@@ -108,12 +103,9 @@ namespace MP.SPEC.Data
return await dbController.ArticoliUpdateRecord(currRec);
}
- ///
- /// Restitusice elenco aziende
- ///
- public Task> ElencoAziende()
+ public Task> ConfigGetAll()
{
- return Task.FromResult(dbController.AnagGruppiAziende());
+ return Task.FromResult(dbController.ConfigGetAll().ToList());
}
public void Dispose()
@@ -130,6 +122,12 @@ namespace MP.SPEC.Data
fastLimit = DateTime.Now.AddMinutes(1);
}
+ /// Restitusice elenco aziende
+ public Task> ElencoAziende()
+ {
+ return Task.FromResult(dbController.AnagGruppiAziende());
+ }
+
///
/// Elenco setup dei tag conf correnti
///
@@ -161,6 +159,72 @@ namespace MP.SPEC.Data
return Task.FromResult(dbController.MacchineGetAll());
}
+ ///
+ /// Verifica se sia possiubile cancellare articolo dato suo CodArt cercando su redis o su tab veto da DB
+ ///
+ ///
+ ///
+ public bool ArticoloDelEnabled(object CodArt)
+ {
+ bool answ = false;
+ string codArticolo = $"{CodArt}";
+ int cacheCheckArtUsato = 1;
+ int.TryParse(_configuration.GetValue("ServerConf:cacheCheckArtUsato"), out cacheCheckArtUsato);
+ TimeSpan TTLCache = TimeSpan.FromMinutes(cacheCheckArtUsato);
+ // cerco in cache redis...
+ string redKeyArtUsed = $"{Utils.redKeyArtUsed}:{codArticolo}";
+ string redKeyTabCheckArt = Utils.redKeyTabCheckArt;
+ string rawData = redisDb.StringGet(redKeyArtUsed);
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ bool.TryParse(rawData, out answ);
+ }
+ else
+ {
+ // controllo non sia stato mai prodotto sennò non posso cancellare...
+ try
+ {
+ // cerco in cache se ci sia la tabella con gli articoli impiegati...
+ string rawTable = redisDb.StringGet(redKeyTabCheckArt);
+ List artList = new List();
+ if (!string.IsNullOrEmpty(rawTable))
+ {
+ artList = JsonConvert.DeserializeObject>(rawTable);
+ }
+ // rileggo...
+ if (artList == null || artList.Count == 0)
+ {
+ artList = new List();
+ var tabArticoli = dbController.ArticoliGetUsed();
+ var codList = tabArticoli.Select(x => x.CodArticolo);
+ foreach (string cod in codList)
+ {
+ artList.Add(cod);
+ }
+ // SE fosse vuoto aggiungo comunque il cado "ND"...
+ if (artList.Count == 0)
+ {
+ artList.Add("ND");
+ }
+ // salvo
+ rawTable = JsonConvert.SerializeObject(artList);
+ redisDb.StringSet(redKeyTabCheckArt, rawTable, TTLCache);
+ }
+ // cerco nella tabella: se ci fosse --> disabilitato delete
+ bool usato = false;
+ if (artList != null && artList.Count > 0)
+ {
+ usato = artList.Contains(codArticolo);
+ }
+ answ = !usato;
+ redisDb.StringSet(redKeyArtUsed, $"{answ}", TTLCache);
+ }
+ catch
+ { }
+ }
+ return answ;
+ }
+
public async Task> MseGetAll()
{
int maxAge = 2000;
diff --git a/MP.SPEC/Pages/Articoli.razor b/MP.SPEC/Pages/Articoli.razor
index d2772860..2bad5e47 100644
--- a/MP.SPEC/Pages/Articoli.razor
+++ b/MP.SPEC/Pages/Articoli.razor
@@ -1,10 +1,10 @@
@page "/ART"
@using MP.SPEC.Components
+@using MP.SPEC.Data