diff --git a/MP.AppAuth/AppAuthContext.cs b/MP.AppAuth/AppAuthContext.cs index 306cc5c2..16c3cabe 100644 --- a/MP.AppAuth/AppAuthContext.cs +++ b/MP.AppAuth/AppAuthContext.cs @@ -54,7 +54,9 @@ namespace MP.AppAuth #region Public Properties + public virtual DbSet DbSetAnagraficaGruppi { get; set; } public virtual DbSet DbSetAnagOpr { get; set; } + public virtual DbSet DbSetGruppi2Oper { get; set; } public virtual DbSet DbSetUpdMan { get; set; } public virtual DbSet DbSetVocabolario { get; set; } @@ -103,6 +105,37 @@ namespace MP.AppAuth .HasMaxLength(500); }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.CodGruppo); + + entity.ToTable("AnagraficaGruppi"); + + entity.Property(e => e.CodGruppo).HasMaxLength(50); + + entity.Property(e => e.DescrGruppo) + .IsRequired() + .HasMaxLength(250) + .HasDefaultValueSql("('')"); + + entity.Property(e => e.SelEnabled).HasComment("Indica se sia selezionabile a livello di tendina x inserimento BCode"); + + entity.Property(e => e.TipoGruppo) + .IsRequired() + .HasMaxLength(50) + .HasDefaultValueSql("('REPARTO')") + .HasComment("tipo gruppo: reparto (es x gestione operatori assegnati), GRUPPO FASE (es macchien che fanno lo stesso tipo di lavoro), ..."); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.MatrOpr, e.CodGruppo }); + + entity.ToTable("Gruppi2Operatori"); + + entity.Property(e => e.CodGruppo).HasMaxLength(50); + }); + // modelBuilder.Seed(); diff --git a/MP.AppAuth/Controllers/AppAuthController.cs b/MP.AppAuth/Controllers/AppAuthController.cs index e441149a..d11119dc 100644 --- a/MP.AppAuth/Controllers/AppAuthController.cs +++ b/MP.AppAuth/Controllers/AppAuthController.cs @@ -31,6 +31,38 @@ namespace MP.AppAuth.Controllers #region Public Methods + /// + /// Elenco Record x Gruppi + /// + /// + public List AnagGruppiFilt(string codTipo) + { + List dbResult = new List(); + using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) + { + dbResult = localDbCtx + .DbSetAnagraficaGruppi + .Where(x => x.TipoGruppo == codTipo || x.SelEnabled) + .ToList(); + } + return dbResult; + } + /// + /// Elenco Record x Gruppi + /// + /// + public List AnagGruppiGetAll() + { + List dbResult = new List(); + using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) + { + dbResult = localDbCtx + .DbSetAnagraficaGruppi + .ToList(); + } + return dbResult; + } + public List AnagOpGetAll(string searchVal) { List dbResult = new List(); @@ -53,6 +85,41 @@ namespace MP.AppAuth.Controllers // ritorno return dbResult; } + public List AnagOpByGruppoGetFilt(string codGruppo, string searchVal) + { + List dbResult = new List(); + using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) + { + if (!string.IsNullOrEmpty(searchVal)) + { + dbResult = localDbCtx + .DbSetGruppi2Oper + .Where(x => x.CodGruppo == codGruppo || string.IsNullOrEmpty(codGruppo)) + .Join( + localDbCtx.DbSetAnagOpr.Where(x => x.Cognome.Contains(searchVal) || x.Nome.Contains(searchVal)), + gruppo => gruppo.MatrOpr, + operatore => operatore.MatrOpr, + (gruppo, operatore) => operatore + ) + .ToList(); + } + else + { + dbResult = localDbCtx + .DbSetGruppi2Oper + .Where(x => x.CodGruppo == codGruppo || string.IsNullOrEmpty(codGruppo)) + .Join( + localDbCtx.DbSetAnagOpr, + gruppo => gruppo.MatrOpr, + operatore => operatore.MatrOpr, + (gruppo, operatore) => operatore + ) + .ToList(); + } + } + // ritorno + return dbResult; + } public void Dispose() { diff --git a/MP.AppAuth/Controllers/MPController .cs b/MP.AppAuth/Controllers/MPController .cs index 794b7d64..77cd4940 100644 --- a/MP.AppAuth/Controllers/MPController .cs +++ b/MP.AppAuth/Controllers/MPController .cs @@ -2,22 +2,17 @@ using NLog; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MP.AppAuth.Controllers { public class MPController : IDisposable { - #region Private Fields + #region Public Fields - private static IConfiguration _configuration; - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); public static AppAuth.Controllers.MPController dbController; - #endregion Private Fields + #endregion Public Fields #region Public Constructors @@ -31,12 +26,6 @@ namespace MP.AppAuth.Controllers #region Public Methods - public void Dispose() - { - // Clear database controller - dbController.Dispose(); - } - /// /// Elenco Record x AnagKeyValue @@ -54,7 +43,19 @@ namespace MP.AppAuth.Controllers return dbResult; } + public void Dispose() + { + // Clear database controller + dbController.Dispose(); + } #endregion Public Methods + + #region Private Fields + + private static IConfiguration _configuration; + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields } } \ No newline at end of file diff --git a/MP.AppAuth/Models/AnagraficaGruppi.cs b/MP.AppAuth/Models/AnagraficaGruppi.cs new file mode 100644 index 00000000..ce30e084 --- /dev/null +++ b/MP.AppAuth/Models/AnagraficaGruppi.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace MP.AppAuth.Models +{ + public partial class AnagraficaGruppi + { + public string CodGruppo { get; set; } + public string TipoGruppo { get; set; } + public string DescrGruppo { get; set; } + public bool SelEnabled { get; set; } + } +} diff --git a/MP.AppAuth/Models/Gruppi2Operatori.cs b/MP.AppAuth/Models/Gruppi2Operatori.cs new file mode 100644 index 00000000..207ca2c1 --- /dev/null +++ b/MP.AppAuth/Models/Gruppi2Operatori.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace MP.AppAuth.Models +{ + public partial class Gruppi2Operatori + { + public int MatrOpr { get; set; } + public string CodGruppo { get; set; } + } +} diff --git a/MP.AppAuth/MoonProContext.cs b/MP.AppAuth/MoonProContext.cs index 09f1d31c..d8bb56a6 100644 --- a/MP.AppAuth/MoonProContext.cs +++ b/MP.AppAuth/MoonProContext.cs @@ -71,7 +71,7 @@ namespace MP.AppAuth public virtual DbSet ListValues { get; set; } public virtual DbSet Macchines { get; set; } public virtual DbSet UpdMan { get; set; } - public virtual DbSet Vocabolario { get; set; } + public virtual DbSet DbSetVocabolario { get; set; } #endregion Public Properties @@ -503,6 +503,8 @@ namespace MP.AppAuth .HasMaxLength(500); }); + + OnModelCreatingPartial(modelBuilder); } diff --git a/MP.Land/Components/CmpGroupFilt.razor b/MP.Land/Components/CmpGroupFilt.razor new file mode 100644 index 00000000..d23cc8af --- /dev/null +++ b/MP.Land/Components/CmpGroupFilt.razor @@ -0,0 +1,20 @@ + +
+
+ Gruppi +
+
+ +
+
+ + diff --git a/MP.Land/Components/CmpGroupFilt.razor.cs b/MP.Land/Components/CmpGroupFilt.razor.cs new file mode 100644 index 00000000..800f3548 --- /dev/null +++ b/MP.Land/Components/CmpGroupFilt.razor.cs @@ -0,0 +1,54 @@ +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 MP.Land; +using MP.Land.Shared; +using MP.AppAuth.Models; +using MP.Land.Data; + +namespace MP.Land.Components +{ + public partial class CmpGroupFilt + { + + [Inject] + protected MessageService AppMService { get; set; } + + [Inject] + protected AppAuthService DataService { get; set; } + + private List ListGroups; + private string groupName + { + get + { + return AppMService.CodGruppo; + } + set + { + AppMService.CodGruppo = value; + } + } + + protected override async Task OnInitializedAsync() + { + await ReloadData(); + } + + private async Task ReloadData() + { + // carico i gruppi + ListGroups = await DataService.AnagGruppiFilt("REPARTO"); + } + } +} \ No newline at end of file diff --git a/MP.Land/Components/DataPager.razor b/MP.Land/Components/DataPager.razor index 111f1ae0..7c046b68 100644 --- a/MP.Land/Components/DataPager.razor +++ b/MP.Land/Components/DataPager.razor @@ -42,9 +42,9 @@ {
} diff --git a/MP.Land/Components/DataPager.razor.cs b/MP.Land/Components/DataPager.razor.cs index 3b6266a8..62cd969c 100644 --- a/MP.Land/Components/DataPager.razor.cs +++ b/MP.Land/Components/DataPager.razor.cs @@ -71,7 +71,7 @@ namespace MP.Land.Components protected int _numPage { get; set; } = 1; - protected int _numRecord { get; set; } = 4; + protected int _numRecord { get; set; } = 6; protected int percLoading { get; set; } = 0; diff --git a/MP.Land/Components/UserCard.razor b/MP.Land/Components/UserCard.razor index 38770524..0077a896 100644 --- a/MP.Land/Components/UserCard.razor +++ b/MP.Land/Components/UserCard.razor @@ -31,7 +31,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { - if (!firstRender) + if (firstRender) { await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{CurrItem.MatrOpr}"); await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{CurrItem.MatrOpr}", rawCode); diff --git a/MP.Land/Data/AppAuthService.cs b/MP.Land/Data/AppAuthService.cs index 55ac68a1..85391a37 100644 --- a/MP.Land/Data/AppAuthService.cs +++ b/MP.Land/Data/AppAuthService.cs @@ -129,6 +129,46 @@ namespace MP.Land.Data #region Public Methods + public async Task> AnagGruppiAll() + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.AnagGruppiGetAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per AnagGruppiAll: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + + public async Task> AnagGruppiFilt(string codTipo) + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.AnagGruppiFilt(codTipo); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per AnagGruppiFilt: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + public async Task> AnagOperByGroupList(string codGruppo, string searchVal) + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + var rawData = dbController + .AnagOpByGruppoGetFilt(codGruppo, searchVal); + dbResult = rawData + .GroupBy(user => user.MatrOpr) + .Select(grp => grp.First()) + .ToList(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per AnagOperByGroupList: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + public async Task> AnagOperList(string searchVal) { List dbResult = new List(); diff --git a/MP.Land/Data/MessageService.cs b/MP.Land/Data/MessageService.cs index 4f03d7ae..77ad39cc 100644 --- a/MP.Land/Data/MessageService.cs +++ b/MP.Land/Data/MessageService.cs @@ -106,6 +106,21 @@ namespace MP.Land.Data } } + protected string _groupName { get; set; } = ""; + public string CodGruppo + { + get => _groupName; + set + { + if (_groupName != value) + { + _groupName = value; + ReportFilter(); + } + } + } + + #endregion Public Properties #region Private Methods diff --git a/MP.Land/Data/SelectData.cs b/MP.Land/Data/SelectData.cs index a54fd4a3..30ec5baa 100644 --- a/MP.Land/Data/SelectData.cs +++ b/MP.Land/Data/SelectData.cs @@ -44,7 +44,7 @@ namespace MP.Land.Data public bool OnlyMod { get; set; } = false; public bool OnlyNoTag { get; set; } = false; public int PageNum { get; set; } = 1; - public int PageSize { get; set; } = 4; + public int PageSize { get; set; } = 6; public string SearchVal { get; set; } = ""; public string Tag { get; set; } = ""; diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 1258a56a..96bb841d 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net6.0 MP.Land - 6.15.2204.2612 + 6.15.2207.0419 diff --git a/MP.Land/Pages/UserQr.razor b/MP.Land/Pages/UserQr.razor index e790b7b6..9f46b8c4 100644 --- a/MP.Land/Pages/UserQr.razor +++ b/MP.Land/Pages/UserQr.razor @@ -5,6 +5,7 @@
+ @if (ListRecords == null) { @@ -15,6 +16,7 @@ } else { +
@foreach (var item in ListRecords) { diff --git a/MP.Land/Pages/UserQr.razor.cs b/MP.Land/Pages/UserQr.razor.cs index 29c1f08b..8d6fa48a 100644 --- a/MP.Land/Pages/UserQr.razor.cs +++ b/MP.Land/Pages/UserQr.razor.cs @@ -11,12 +11,14 @@ namespace MP.Land.Pages { public partial class UserQr : IDisposable { - #region Private Fields + #region Public Methods - private List ListRecords; - private List SearchRecords; + public void Dispose() + { + AppMService.EA_SearchUpdated -= OnSeachUpdated; + } - #endregion Private Fields + #endregion Public Methods #region Protected Fields @@ -25,39 +27,6 @@ namespace MP.Land.Pages #endregion Protected Fields - #region Private Properties - - [Inject] - private IConfiguration Configuration { get; set; } - - private int currPage - { - get - { - return AppMService.SelFilter.PageNum; - } - set - { - AppMService.SelFilter.PageNum = value; - } - } - - private bool isLoading { get; set; } = false; - - private int numRecord - { - get - { - return AppMService.SelFilter.PageSize; - } - set - { - AppMService.SelFilter.PageSize = value; - } - } - - #endregion Private Properties - #region Protected Properties [Inject] @@ -78,18 +47,6 @@ namespace MP.Land.Pages #endregion Protected Properties - #region Private Methods - - private async void OnSeachUpdated() - { - ListRecords = null; - currPage = 1; - await Task.Delay(1); - await ReloadData(); - } - - #endregion Private Methods - #region Protected Methods protected override async Task OnInitializedAsync() @@ -99,6 +56,7 @@ namespace MP.Land.Pages AppMService.PageIcon = "fas fa-qrcode pr-2"; await ReloadData(); AppMService.EA_SearchUpdated += OnSeachUpdated; + AppMService.EA_FilterUpdated += OnFilterUpdated; } protected async Task PagerReloadNum(int newNum) @@ -117,19 +75,6 @@ namespace MP.Land.Pages isLoading = false; } - protected async Task ReloadData() - { - isLoading = true; - // importante altrimenti NON mostra update UI - await Task.Delay(1); - SearchRecords = await DataService.AnagOperList(AppMService.SearchVal); - ListRecords = SearchRecords.Skip((currPage - 1) * numRecord).Take(numRecord).ToList(); - totalCount = SearchRecords.Count(); - await Task.Delay(1); - isLoading = false; - StateHasChanged(); - } - protected MarkupString traduci(string lemma) { MarkupString answ; @@ -142,13 +87,95 @@ namespace MP.Land.Pages #endregion Protected Methods - #region Public Methods + #region Private Fields - public void Dispose() + private List ListRecords; + + private List SearchRecords; + + #endregion Private Fields + + #region Private Properties + + [Inject] + private IConfiguration Configuration { get; set; } + + private int currPage { - AppMService.EA_SearchUpdated -= OnSeachUpdated; + get + { + return AppMService.SelFilter.PageNum; + } + set + { + AppMService.SelFilter.PageNum = value; + } } - #endregion Public Methods + private string groupName + { + get + { + return AppMService.CodGruppo; + } + } + + private bool isLoading { get; set; } = false; + + private int numRecord + { + get + { + return AppMService.SelFilter.PageSize; + } + set + { + AppMService.SelFilter.PageSize = value; + } + } + + #endregion Private Properties + + #region Private Methods + + private async void OnFilterUpdated() + { + ListRecords = null; + currPage = 1; + await Task.Delay(1); + await ReloadData(); + } + + private async void OnSeachUpdated() + { + ListRecords = null; + currPage = 1; + await Task.Delay(1); + await ReloadData(); + } + + private async Task ReloadData() + { + isLoading = true; + // importante altrimenti NON mostra update UI + await Task.Delay(1); + // se ho selezionato qualcosa cerco x gruppo + //if (groupName != "") + //{ + SearchRecords = await DataService.AnagOperByGroupList(groupName, AppMService.SearchVal); + //} + //else + //{ + // //altrimenti TUTTI + // SearchRecords = await DataService.AnagOperList(AppMService.SearchVal); + //} + ListRecords = SearchRecords.Skip((currPage - 1) * numRecord).Take(numRecord).ToList(); + totalCount = SearchRecords.Count(); + await Task.Delay(1); + isLoading = false; + StateHasChanged(); + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.Land/Pages/_Host.cshtml b/MP.Land/Pages/_Host.cshtml index f259d5d7..3f885c73 100644 --- a/MP.Land/Pages/_Host.cshtml +++ b/MP.Land/Pages/_Host.cshtml @@ -50,33 +50,8 @@ - + - + \ No newline at end of file diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index d50e830c..5abaaa2a 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

Versione: 6.15.2204.2612

+

Versione: 6.15.2207.0419


Note di rilascio:
    diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index b7394df7..21dd9517 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -6.15.2204.2612 +6.15.2207.0419 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index 1aa276ce..fd1cc5ed 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.15.2204.2612 + 6.15.2207.0419 https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html false diff --git a/MP.Land/wwwroot/lib/qrHelper.js b/MP.Land/wwwroot/lib/qrHelper.js new file mode 100644 index 00000000..5ddd7ceb --- /dev/null +++ b/MP.Land/wwwroot/lib/qrHelper.js @@ -0,0 +1,24 @@ +function clearContent(elementID) { + console.log("Remove " + elementID); + document.getElementById(elementID).innerHTML = ""; +} +// gestione qrcode... da https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity-enable-qrcodes?view=aspnetcore-5.0 +//var qrcode = new QRCode("qrCodeImg"); +function displayQr(elementName, rawData) { + console.log("Add " + elementName); + try { + if (elementName != "" && rawData != "") { + qrcode = new QRCode(document.getElementById(elementName), + { + text: rawData, + width: 200, + height: 200 + }); + //qrcode = new QRCode(document.getElementById(elementName)); + //qrcode.clear(); + //qrcode.makeCode(rawData); + } + } + catch + { } +} \ No newline at end of file