Completata search libera (senza debounce da sistemare)
This commit is contained in:
@@ -162,15 +162,21 @@ namespace MP.FileData.Controllers
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
|
||||
public int FileCountFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, bool OnlyNoTag, string FileName, string Tag)
|
||||
public int FileCountFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, bool OnlyNoTag, string FileName, string Tag, string SearchVal)
|
||||
{
|
||||
int answ = 0;
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
answ = localDbCtx
|
||||
.DbSetProgFile
|
||||
.Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "0") && (x.Active == OnlyActive || !OnlyActive) && (x.Tags.Count() == 0 || !OnlyNoTag) && (!OnlyMod || x.DiskStatus != FileState.Ok) && (x.Path.Equals(FileName) || string.IsNullOrEmpty(FileName)) && (x.Tags.Where(t => t.TagId == Tag).Count() > 0 || string.IsNullOrEmpty(Tag)))
|
||||
.Count();
|
||||
.Where(x =>
|
||||
(x.IdxMacchina == IdxMacchina || IdxMacchina == "0")
|
||||
&& (x.Active == OnlyActive || !OnlyActive) && (x.Tags.Count() == 0 || !OnlyNoTag)
|
||||
&& (!OnlyMod || x.DiskStatus != FileState.Ok)
|
||||
&& (x.Path.Equals(FileName) || string.IsNullOrEmpty(FileName))
|
||||
&& (x.Tags.Where(t => t.TagId == Tag).Count() > 0 || string.IsNullOrEmpty(Tag))
|
||||
&& ((!string.IsNullOrEmpty(SearchVal) && (x.Path.Contains(SearchVal) || x.Tags.Where(t => t.TagId.Contains(SearchVal)).Count() > 0)) || string.IsNullOrEmpty(SearchVal))
|
||||
).Count();
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -255,7 +261,7 @@ namespace MP.FileData.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public List<DatabaseModels.FileModel> FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, bool OnlyNoTag, string FileName, string Tag, int NumStart, int NumRecords)
|
||||
public List<DatabaseModels.FileModel> FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, bool OnlyNoTag, string FileName, string Tag, string SearchVal, int NumStart, int NumRecords)
|
||||
{
|
||||
List<DatabaseModels.FileModel> dbResult = new List<DatabaseModels.FileModel>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
@@ -264,8 +270,14 @@ namespace MP.FileData.Controllers
|
||||
.DbSetProgFile
|
||||
.Include(m => m.Macchina)
|
||||
.Include(t => t.Tags)
|
||||
.Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "0") && (x.Active == OnlyActive || !OnlyActive) && (x.Tags.Count() == 0 || !OnlyNoTag) && (!OnlyMod || x.DiskStatus != FileState.Ok) && (x.Path.Equals(FileName) || string.IsNullOrEmpty(FileName)) && (x.Tags.Where(t => t.TagId == Tag).Count() > 0 || string.IsNullOrEmpty(Tag)))
|
||||
.OrderByDescending(x => x.LastMod)
|
||||
.Where(x =>
|
||||
(x.IdxMacchina == IdxMacchina || IdxMacchina == "0")
|
||||
&& (x.Active == OnlyActive || !OnlyActive) && (x.Tags.Count() == 0 || !OnlyNoTag)
|
||||
&& (!OnlyMod || x.DiskStatus != FileState.Ok)
|
||||
&& (x.Path.Equals(FileName) || string.IsNullOrEmpty(FileName))
|
||||
&& (x.Tags.Where(t => t.TagId == Tag).Count() > 0 || string.IsNullOrEmpty(Tag))
|
||||
&& ((!string.IsNullOrEmpty(SearchVal) && (x.Path.Contains(SearchVal) || x.Tags.Where(t => t.TagId.Contains(SearchVal)).Count() > 0)) || string.IsNullOrEmpty(SearchVal))
|
||||
).OrderByDescending(x => x.LastMod)
|
||||
.Skip(NumStart)
|
||||
.Take(NumRecords)
|
||||
.ToList();
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> searchUpdated { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string searchVal
|
||||
{
|
||||
@@ -23,20 +20,13 @@
|
||||
}
|
||||
set
|
||||
{
|
||||
MessageService.SearchVal = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
if (!MessageService.SearchVal.Equals(value))
|
||||
{
|
||||
await reportChange();
|
||||
});
|
||||
pUpd.Wait();
|
||||
MessageService.SearchVal = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task reportChange()
|
||||
{
|
||||
await searchUpdated.InvokeAsync(searchVal);
|
||||
}
|
||||
|
||||
private void reset()
|
||||
{
|
||||
searchVal = "";
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace MP.Prog.Data
|
||||
int numCount = 0;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
numCount = dbController.FileCountFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.OnlyNoTag, CurrFilter.FileName, CurrFilter.Tag);
|
||||
numCount = dbController.FileCountFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.OnlyNoTag, CurrFilter.FileName, CurrFilter.Tag, CurrFilter.SearchVal);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per FileCountFilt: {ts.TotalMilliseconds} ms");
|
||||
@@ -163,7 +163,7 @@ namespace MP.Prog.Data
|
||||
List<FileData.DatabaseModels.FileModel> dbResult = new List<FileData.DatabaseModels.FileModel>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.FileGetFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.OnlyNoTag, CurrFilter.FileName, CurrFilter.Tag, CurrFilter.NumSkip, CurrFilter.PageSize).ToList();
|
||||
dbResult = dbController.FileGetFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.OnlyNoTag, CurrFilter.FileName, CurrFilter.Tag, CurrFilter.SearchVal, CurrFilter.NumSkip, CurrFilter.PageSize).ToList();
|
||||
//dbResult = dbController.FileGetFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.FirstRecord, CurrFilter.PageSize * 10, CurrFilter.SearchVal).ToList();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
|
||||
namespace MP.Prog.Data
|
||||
{
|
||||
@@ -12,11 +13,17 @@ namespace MP.Prog.Data
|
||||
private SelectData _fileFilter = SelectData.Init(5, 15);
|
||||
private string _pageIcon;
|
||||
private string _pageName;
|
||||
private string _searchVal;
|
||||
private string _searchVal = "";
|
||||
private bool showSearch;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected Timer SearchTimer;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Events
|
||||
|
||||
public event Action EA_FilterUpdated;
|
||||
@@ -41,11 +48,7 @@ namespace MP.Prog.Data
|
||||
if (_fileFilter != value)
|
||||
{
|
||||
_fileFilter = value;
|
||||
|
||||
if (EA_FilterUpdated != null)
|
||||
{
|
||||
EA_FilterUpdated?.Invoke();
|
||||
}
|
||||
ReportFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,11 +87,8 @@ namespace MP.Prog.Data
|
||||
if (_searchVal != value)
|
||||
{
|
||||
_searchVal = value;
|
||||
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
}
|
||||
//TriggerSearch();
|
||||
ReportSearch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,17 +103,11 @@ namespace MP.Prog.Data
|
||||
showSearch = value;
|
||||
if (showSearch)
|
||||
{
|
||||
if (EA_ShowSearch != null)
|
||||
{
|
||||
EA_ShowSearch?.Invoke();
|
||||
}
|
||||
ReportShowSearch();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EA_HideSearch != null)
|
||||
{
|
||||
EA_HideSearch?.Invoke();
|
||||
}
|
||||
ReportHideSearch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,6 +117,22 @@ namespace MP.Prog.Data
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void ReportFilter()
|
||||
{
|
||||
if (EA_FilterUpdated != null)
|
||||
{
|
||||
EA_FilterUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportHideSearch()
|
||||
{
|
||||
if (EA_HideSearch != null)
|
||||
{
|
||||
EA_HideSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportPageUpd()
|
||||
{
|
||||
if (EA_PageUpdated != null)
|
||||
@@ -139,6 +149,38 @@ namespace MP.Prog.Data
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportShowSearch()
|
||||
{
|
||||
if (EA_ShowSearch != null)
|
||||
{
|
||||
EA_ShowSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchTimerElapsed_TickAsync(object sender, EventArgs e)
|
||||
{
|
||||
DisposeSearchTimer();
|
||||
ReportSearch();
|
||||
}
|
||||
|
||||
private void TriggerSearch()
|
||||
{
|
||||
DisposeSearchTimer();
|
||||
SearchTimer = new Timer(150);
|
||||
SearchTimer.Elapsed += SearchTimerElapsed_TickAsync;
|
||||
SearchTimer.Enabled = true;
|
||||
SearchTimer.Start();
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void DisposeSearchTimer()
|
||||
{
|
||||
SearchTimer.Dispose();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,8 @@ namespace MP.Prog.Data
|
||||
SelectData answ = new SelectData()
|
||||
{
|
||||
DateEnd = endRounded,
|
||||
DateStart = endRounded.AddDays(-numDayPrev)
|
||||
DateStart = endRounded.AddDays(-numDayPrev),
|
||||
SearchVal = ""
|
||||
};
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>MP.Prog</RootNamespace>
|
||||
<Version>1.1.2109.1609</Version>
|
||||
<Version>1.1.2109.1610</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -136,6 +136,31 @@ namespace MP.Prog.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private string SearchVal
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.SearchVal;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.SearchVal.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.SearchVal = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string SelFileName
|
||||
{
|
||||
get
|
||||
@@ -359,11 +384,11 @@ namespace MP.Prog.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
SearchTag = defTag;
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.ShowSearch = true;
|
||||
AppMService.PageName = "Archivio File Programmi";
|
||||
AppMService.PageIcon = "fas fa-folder pr-2";
|
||||
AppMService.EA_SearchUpdated += OnSeachUpdated;
|
||||
AppMService.EA_FilterUpdated += OnSeachUpdated;
|
||||
AppMService.EA_FilterUpdated += OnFilterUpdated;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
@@ -423,6 +448,7 @@ namespace MP.Prog.Pages
|
||||
currRecord = null;
|
||||
ListRecords = null;
|
||||
AppMService.File_Filter = SelectData.Init(5, 10);
|
||||
AppMService.SearchVal = "";
|
||||
SearchTag = defTag;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
@@ -471,16 +497,20 @@ namespace MP.Prog.Pages
|
||||
public void Dispose()
|
||||
{
|
||||
AppMService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
AppMService.EA_FilterUpdated -= OnSeachUpdated;
|
||||
AppMService.EA_FilterUpdated -= OnFilterUpdated;
|
||||
}
|
||||
|
||||
public async void OnFilterUpdated()
|
||||
{
|
||||
await ReloadData();
|
||||
//StateHasChanged();
|
||||
}
|
||||
|
||||
public async void OnSeachUpdated()
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
Task task = UpdateData();
|
||||
StateHasChanged();
|
||||
});
|
||||
SearchVal = AppMService.SearchVal;
|
||||
//await ReloadData();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void ResetTag()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo gestione Programmi MAPO</i>
|
||||
<h4>Versione: 1.1.2109.1609</h4>
|
||||
<h4>Versione: 1.1.2109.1610</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.1.2109.1609
|
||||
1.1.2109.1610
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.1.2109.1609</version>
|
||||
<version>1.1.2109.1610</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MP-PROG/stable/0/MP.Prog.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MP-PROG/stable/0/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user