From 01ed3143199147980ccbed2f98f64b0334cffb56 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 21 Sep 2021 16:18:11 +0200 Subject: [PATCH] Ricerca cartellini (fixed) --- MP.AppAuth/Controllers/AppAuthController.cs | 40 ++++++----- MP.Land/Components/DataPager.razor | 6 +- MP.Land/Components/DataPager.razor.cs | 2 +- MP.Land/Components/SearchMod.razor | 6 +- MP.Land/Components/UserCard.razor | 21 +++--- MP.Land/Data/AppAuthService.cs | 4 +- MP.Land/Data/MessageService.cs | 28 ++++---- MP.Land/Data/SelectData.cs | 2 +- MP.Land/MP.Land.csproj | 2 +- MP.Land/Pages/UserQr.razor | 3 + MP.Land/Pages/UserQr.razor.cs | 75 ++++++++++++++++++--- MP.Land/Pages/_Host.cshtml | 16 +++-- MP.Land/Resources/ChangeLog.html | 2 +- MP.Land/Resources/VersNum.txt | 2 +- MP.Land/Resources/manifest.xml | 2 +- 15 files changed, 141 insertions(+), 70 deletions(-) diff --git a/MP.AppAuth/Controllers/AppAuthController.cs b/MP.AppAuth/Controllers/AppAuthController.cs index 316d3743..69f0fd1f 100644 --- a/MP.AppAuth/Controllers/AppAuthController.cs +++ b/MP.AppAuth/Controllers/AppAuthController.cs @@ -34,19 +34,21 @@ namespace MP.AppAuth.Controllers public List AnagOpGetAll(string searchVal) { List dbResult = new List(); - - if (!string.IsNullOrEmpty(searchVal)) + using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) { - dbResult = dbCtx - .DbSetAnagOpr - .Where(x => x.Cognome.Contains(searchVal) || x.Nome.Contains(searchVal)) - .ToList(); - } - else - { - dbResult = dbCtx - .DbSetAnagOpr - .ToList(); + if (!string.IsNullOrEmpty(searchVal)) + { + dbResult = localDbCtx + .DbSetAnagOpr + .Where(x => x.Cognome.Contains(searchVal) || x.Nome.Contains(searchVal)) + .ToList(); + } + else + { + dbResult = localDbCtx + .DbSetAnagOpr + .ToList(); + } } // ritorno return dbResult; @@ -93,11 +95,12 @@ namespace MP.AppAuth.Controllers public List UpdManGetAll() { List dbResult = new List(); - - dbResult = dbCtx + using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) + { + dbResult = localDbCtx .DbSetUpdMan .ToList(); - + } return dbResult; } @@ -108,11 +111,12 @@ namespace MP.AppAuth.Controllers public List VocabolarioGetAll() { List dbResult = new List(); - - dbResult = dbCtx + using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) + { + dbResult = localDbCtx .DbSetVocabolario .ToList(); - + } return dbResult; } diff --git a/MP.Land/Components/DataPager.razor b/MP.Land/Components/DataPager.razor index 3d577d19..111f1ae0 100644 --- a/MP.Land/Components/DataPager.razor +++ b/MP.Land/Components/DataPager.razor @@ -42,11 +42,9 @@ {
} diff --git a/MP.Land/Components/DataPager.razor.cs b/MP.Land/Components/DataPager.razor.cs index 4ba7dcee..3b6266a8 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; } = 10; + protected int _numRecord { get; set; } = 4; protected int percLoading { get; set; } = 0; diff --git a/MP.Land/Components/SearchMod.razor b/MP.Land/Components/SearchMod.razor index b20dc6a1..1eba65ea 100644 --- a/MP.Land/Components/SearchMod.razor +++ b/MP.Land/Components/SearchMod.razor @@ -5,7 +5,7 @@ @inject MessageService MessageService
- +
@@ -14,8 +14,8 @@ @code { private string _searchVal = ""; - private int _debMsec = 200; - private int _minChar = 2; + private int _debMsec = 300; + private int _minChar = 0; private DebounceInput debInput; [Parameter] diff --git a/MP.Land/Components/UserCard.razor b/MP.Land/Components/UserCard.razor index 247d9bbf..e5dffaa3 100644 --- a/MP.Land/Components/UserCard.razor +++ b/MP.Land/Components/UserCard.razor @@ -2,18 +2,17 @@ @inject IJSRuntime JSRuntime -
-
+
+
-
+
EgalWare
- @* EgalWare*@
-
+

@Environment

@@ -29,9 +28,9 @@
- + @**@
@code { @@ -41,7 +40,11 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { - await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{CurrItem.MatrOpr}", rawCode); + if (!firstRender) + { + await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{CurrItem.MatrOpr}"); + await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{CurrItem.MatrOpr}", rawCode); + } } [Parameter] diff --git a/MP.Land/Data/AppAuthService.cs b/MP.Land/Data/AppAuthService.cs index fb255c02..2d9b5d23 100644 --- a/MP.Land/Data/AppAuthService.cs +++ b/MP.Land/Data/AppAuthService.cs @@ -127,12 +127,12 @@ namespace MP.Land.Data #region Public Methods - public async Task> AnagOperList() + public async Task> AnagOperList(string searchVal) { List dbResult = new List(); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - dbResult = dbController.AnagOpGetAll(""); + dbResult = dbController.AnagOpGetAll(searchVal); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Log.Trace($"Effettuata lettura da DB per AnagOperList: {ts.TotalMilliseconds} ms"); diff --git a/MP.Land/Data/MessageService.cs b/MP.Land/Data/MessageService.cs index ce03b7b2..4f03d7ae 100644 --- a/MP.Land/Data/MessageService.cs +++ b/MP.Land/Data/MessageService.cs @@ -10,10 +10,10 @@ namespace MP.Land.Data { #region Private Fields - private SelectData _fileFilter = SelectData.Init(5, 15); private string _pageIcon; private string _pageName; private string _searchVal = ""; + private SelectData _selFilter = SelectData.Init(4, 15); private bool showSearch; #endregion Private Fields @@ -34,19 +34,6 @@ namespace MP.Land.Data #region Public Properties - public SelectData File_Filter - { - get => _fileFilter; - set - { - if (_fileFilter != value) - { - _fileFilter = value; - ReportFilter(); - } - } - } - public string PageIcon { get => _pageIcon; @@ -86,6 +73,19 @@ namespace MP.Land.Data } } + public SelectData SelFilter + { + get => _selFilter; + set + { + if (_selFilter != value) + { + _selFilter = value; + ReportFilter(); + } + } + } + public bool ShowSearch { get => showSearch; diff --git a/MP.Land/Data/SelectData.cs b/MP.Land/Data/SelectData.cs index c771a85f..a54fd4a3 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; } = 10; + public int PageSize { get; set; } = 4; 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 183a0ab4..0b71cd86 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net5.0 MP.Land - 1.1.2109.2114 + 1.1.2109.2116 diff --git a/MP.Land/Pages/UserQr.razor b/MP.Land/Pages/UserQr.razor index caf322d9..26899bab 100644 --- a/MP.Land/Pages/UserQr.razor +++ b/MP.Land/Pages/UserQr.razor @@ -25,4 +25,7 @@
}
+
\ No newline at end of file diff --git a/MP.Land/Pages/UserQr.razor.cs b/MP.Land/Pages/UserQr.razor.cs index 5253d1f4..9f88e4e6 100644 --- a/MP.Land/Pages/UserQr.razor.cs +++ b/MP.Land/Pages/UserQr.razor.cs @@ -9,11 +9,12 @@ using System.Threading.Tasks; namespace MP.Land.Pages { - public partial class UserQr + public partial class UserQr : IDisposable { #region Private Fields private List ListRecords; + private List SearchRecords; #endregion Private Fields @@ -29,8 +30,32 @@ namespace MP.Land.Pages [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 @@ -53,6 +78,18 @@ 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() @@ -60,16 +97,24 @@ namespace MP.Land.Pages AppMService.ShowSearch = true; AppMService.PageName = "User Card"; AppMService.PageIcon = "fas fa-qrcode pr-2"; - await ReloadAllData(); - //AppMService.EA_SearchUpdated += OnSeachUpdated; - //AppMService.EA_FilterUpdated += OnFilterUpdated; + await ReloadData(); + AppMService.EA_SearchUpdated += OnSeachUpdated; } - protected async Task ReloadAllData() + protected async Task PagerReloadNum(int newNum) { - isLoading = true; - //MacList = await DataService.MacchineGetAll(); + ListRecords = null; + numRecord = newNum; await ReloadData(); + isLoading = false; + } + + protected async Task PagerReloadPage(int newNum) + { + ListRecords = null; + currPage = newNum; + await ReloadData(); + isLoading = false; } protected async Task ReloadData() @@ -77,9 +122,12 @@ namespace MP.Land.Pages isLoading = true; // importante altrimenti NON mostra update UI await Task.Delay(1); - ListRecords = await DataService.AnagOperList(); - totalCount = ListRecords.Count(); + 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) @@ -93,5 +141,14 @@ namespace MP.Land.Pages } #endregion Protected Methods + + #region Public Methods + + public void Dispose() + { + AppMService.EA_SearchUpdated -= OnSeachUpdated; + } + + #endregion Public Methods } } \ No newline at end of file diff --git a/MP.Land/Pages/_Host.cshtml b/MP.Land/Pages/_Host.cshtml index 51a0d53f..c7cb0e9b 100644 --- a/MP.Land/Pages/_Host.cshtml +++ b/MP.Land/Pages/_Host.cshtml @@ -23,7 +23,7 @@ - +
@@ -46,18 +46,24 @@