Ricerca x nome file
This commit is contained in:
@@ -161,14 +161,14 @@ namespace MP.FileData.Controllers
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
|
||||
public int FileCountFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, string SearchVal = "")
|
||||
public int FileCountFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, string FileName)
|
||||
{
|
||||
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) && (!OnlyMod || x.DiskStatus != FileState.Ok) && (x.Name.Contains(SearchVal) || string.IsNullOrEmpty(SearchVal)))
|
||||
.Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "0") && (x.Active == OnlyActive || !OnlyActive) && (!OnlyMod || x.DiskStatus != FileState.Ok) && (x.Path.Equals(FileName) || string.IsNullOrEmpty(FileName)))
|
||||
.Count();
|
||||
}
|
||||
return answ;
|
||||
@@ -254,7 +254,7 @@ namespace MP.FileData.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public List<DatabaseModels.FileModel> FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, int numStart, int numRecords, string SearchVal = "")
|
||||
public List<DatabaseModels.FileModel> FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, int numStart, int numRecords, string fileName)
|
||||
{
|
||||
List<DatabaseModels.FileModel> dbResult = new List<DatabaseModels.FileModel>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
@@ -263,7 +263,7 @@ namespace MP.FileData.Controllers
|
||||
.DbSetProgFile
|
||||
.Include(m => m.Macchina)
|
||||
.Include(t => t.Tags)
|
||||
.Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "0") && (x.Active == OnlyActive || !OnlyActive) && (!OnlyMod || x.DiskStatus != FileState.Ok) && (x.Name.Contains(SearchVal) || string.IsNullOrEmpty(SearchVal)))
|
||||
.Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "0") && (x.Active == OnlyActive || !OnlyActive) && (!OnlyMod || x.DiskStatus != FileState.Ok) && (x.Path.Equals(fileName) || string.IsNullOrEmpty(fileName)))
|
||||
.OrderByDescending(x => x.LastMod)
|
||||
.Skip(numStart)
|
||||
.Take(numRecords)
|
||||
@@ -636,15 +636,25 @@ namespace MP.FileData.Controllers
|
||||
// ora ciclo a cercare i file...
|
||||
foreach (var item in ArchiveList)
|
||||
{
|
||||
item.TotFile = localDbCtx
|
||||
var activeRecords = localDbCtx
|
||||
.DbSetProgFile
|
||||
.Where(x => x.IdxMacchina == item.IdxMacchina && x.Active)
|
||||
.Include(p => p.Tags)
|
||||
.ToList();
|
||||
|
||||
item.TotFile = activeRecords
|
||||
.Count();
|
||||
|
||||
item.NumChanged = localDbCtx
|
||||
.DbSetProgFile
|
||||
.Where(x => x.IdxMacchina == item.IdxMacchina && x.Active && x.DiskStatus == FileState.Changed)
|
||||
item.NumChanged = activeRecords
|
||||
.Where(x => x.DiskStatus == FileState.Changed)
|
||||
.Count();
|
||||
|
||||
item.NoTags = activeRecords
|
||||
.Where(x => x.Tags.Count == 0)
|
||||
.Count();
|
||||
|
||||
item.TotalTags = activeRecords
|
||||
.Sum(x => x.Tags.Count);
|
||||
}
|
||||
}
|
||||
return ArchiveList;
|
||||
|
||||
@@ -11,12 +11,37 @@ namespace MP.FileData.DTO
|
||||
// </Auto-Generated>
|
||||
public class ArchiveStatusDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Idx macchina
|
||||
/// </summary>
|
||||
public string IdxMacchina { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Nome macchina
|
||||
/// </summary>
|
||||
public string Nome { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Descrizione macchina
|
||||
/// </summary>
|
||||
public string Descrizione { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Percorso base x macchina
|
||||
/// </summary>
|
||||
public string BasePath { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Totale file della amcchina
|
||||
/// </summary>
|
||||
public int TotFile { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// NBumero file modificati da confermare/rifiutare
|
||||
/// </summary>
|
||||
public int NumChanged { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// Conteggio totale tags x macchina
|
||||
/// </summary>
|
||||
public int TotalTags { get; set; }
|
||||
/// <summary>
|
||||
/// Numero di file SENZA tag
|
||||
/// </summary>
|
||||
public int NoTags { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
<th></th>
|
||||
<th>Macchina</th>
|
||||
<th>Path</th>
|
||||
<th class="text-right">Tags</th>
|
||||
<th class="text-right">Senza Tag</th>
|
||||
<th class="text-right">Modificati</th>
|
||||
<th class="text-right">Tot File</th>
|
||||
</tr>
|
||||
@@ -74,6 +76,12 @@
|
||||
<td>
|
||||
<div class="small">@record.BasePath</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@record.TotalTags
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@record.NoTags
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@record.NumChanged
|
||||
</td>
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace MP.Prog.Data
|
||||
int numCount = 0;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
numCount = dbController.FileCountFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.SearchVal);
|
||||
numCount = dbController.FileCountFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.FileName);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Info($"Effettuata lettura da DB + caching per FileCountFilt: {ts.TotalMilliseconds} ms");
|
||||
@@ -239,7 +239,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.NumSkip, CurrFilter.PageSize, CurrFilter.SearchVal).ToList();
|
||||
dbResult = dbController.FileGetFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.NumSkip, CurrFilter.PageSize, CurrFilter.FileName).ToList();
|
||||
//dbResult = dbController.FileGetFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.FirstRecord, CurrFilter.PageSize * 10, CurrFilter.SearchVal).ToList();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MP.Prog.Data
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private SelectData _detailFilter = SelectData.Init(5, 15);
|
||||
private SelectData _fileFilter = SelectData.Init(5, 15);
|
||||
private string _pageIcon;
|
||||
private string _pageName;
|
||||
private string _searchVal;
|
||||
@@ -33,14 +33,14 @@ namespace MP.Prog.Data
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public SelectData DetailFilter
|
||||
public SelectData File_Filter
|
||||
{
|
||||
get => _detailFilter;
|
||||
get => _fileFilter;
|
||||
set
|
||||
{
|
||||
if (_detailFilter != value)
|
||||
if (_fileFilter != value)
|
||||
{
|
||||
_detailFilter = value;
|
||||
_fileFilter = value;
|
||||
|
||||
if (EA_FilterUpdated != null)
|
||||
{
|
||||
@@ -50,8 +50,6 @@ namespace MP.Prog.Data
|
||||
}
|
||||
}
|
||||
|
||||
public SelectData File_Filter { get; set; } = SelectData.Init(5, 30);
|
||||
|
||||
public string PageIcon
|
||||
{
|
||||
get => _pageIcon;
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace MP.Prog.Data
|
||||
public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1);
|
||||
public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7);
|
||||
|
||||
public string FileName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Primo record x selezione paginata, tipicamente primo della "decina" della pagina corrente
|
||||
/// </summary>
|
||||
@@ -40,10 +42,10 @@ namespace MP.Prog.Data
|
||||
|
||||
public bool OnlyActive { get; set; } = true;
|
||||
public bool OnlyMod { get; set; } = false;
|
||||
|
||||
public int PageNum { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 10;
|
||||
public string SearchVal { get; set; } = "";
|
||||
public string Tag { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -83,6 +85,8 @@ namespace MP.Prog.Data
|
||||
return false;
|
||||
if (SearchVal != item.SearchVal)
|
||||
return false;
|
||||
if (FileName != item.FileName)
|
||||
return false;
|
||||
if (IdxMacchina != item.IdxMacchina)
|
||||
return false;
|
||||
if (DateEnd != item.DateEnd)
|
||||
|
||||
+21
-13
@@ -3,7 +3,7 @@
|
||||
@using MP.Prog.Components
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header table-primary h3">
|
||||
<div class="card-header table-primary">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="d-flex">
|
||||
@@ -46,24 +46,32 @@
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
</div>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="togModificati" title="Solo Aperti / Mostra tutti" @bind-value="@OnlyMod" checked="@OnlyMod" />
|
||||
<label class="custom-control-label small" for="togModificati"><sub>Mod</sub></label>
|
||||
<label class="custom-control-label" for="togModificati"><sub>Mod</sub></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
</div>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="togAttivi" title="Solo Attivi / Mostra tutti" @bind-value="@OnlyActive" checked="@OnlyActive" />
|
||||
<label class="custom-control-label small" for="togAttivi"><sub>Attivi</sub></label>
|
||||
<label class="custom-control-label" for="togAttivi"><sub>Attivi</sub></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
@if (!string.IsNullOrEmpty(SelFileName))
|
||||
{
|
||||
<span class="badge badge-secondary">@SelFileName</span>
|
||||
}
|
||||
</div>
|
||||
<div class="px-2">
|
||||
@if (!string.IsNullOrEmpty(SelTag))
|
||||
{
|
||||
<span class="badge badge-info">@SelTag</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -120,7 +128,9 @@
|
||||
<td>
|
||||
<div class="@(cssActive(record.Active))">
|
||||
<div>@record.Name</div>
|
||||
<div class="small">@record.Path</div>
|
||||
<button class="btn btn-sm btn-outline-secondary px-1 py-0" @onclick="() => FilterPath(record.Path)" title="Filtra per FilePath">
|
||||
<div class="small">@record.Path</div>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@@ -143,17 +153,15 @@
|
||||
<td>
|
||||
@foreach (var item in record.Tags)
|
||||
{
|
||||
<span class="badge badge-info small">@item.TagId</span>
|
||||
<button class="btn btn-sm btn-outline-info px-1 py-0 mr-1" @onclick="() => FilterTag(item.TagId)" title="Filtra Tag">
|
||||
<div class="small">@item.TagId</div>
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div>@record.LastMod.ToString("yyyy.MM.dd")</div>
|
||||
<div class="small">@record.LastMod.ToString("ddd HH:mm.ss")</div>
|
||||
</td>
|
||||
@*<td>
|
||||
<div>@record.LastCheck.ToString("yyyy.MM.dd")</div>
|
||||
<div class="small">@record.LastCheck.ToString("ddd HH:mm.ss")</div>
|
||||
</td>*@
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
@@ -111,6 +111,31 @@ namespace MP.Prog.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private string SelFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.FileName;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.FileName.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.FileName = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string SelIdxMacc
|
||||
{
|
||||
get
|
||||
@@ -136,6 +161,31 @@ namespace MP.Prog.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private string SelTag
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.Tag;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.Tag.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.Tag = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
@@ -233,6 +283,21 @@ namespace MP.Prog.Pages
|
||||
pUpd.Wait();
|
||||
}
|
||||
|
||||
protected async Task FilterPath(string searchVal)
|
||||
{
|
||||
SelFileName = searchVal;
|
||||
OnlyActive = false;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task FilterTag(string searchVal)
|
||||
{
|
||||
SelTag = searchVal;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task ForceCheck(int numDays)
|
||||
{
|
||||
currRecord = null;
|
||||
@@ -253,6 +318,7 @@ namespace MP.Prog.Pages
|
||||
AppMService.PageName = "Archivio File Programmi";
|
||||
AppMService.PageIcon = "fas fa-folder pr-2";
|
||||
AppMService.EA_SearchUpdated += OnSeachUpdated;
|
||||
AppMService.EA_FilterUpdated += OnSeachUpdated;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
@@ -298,6 +364,7 @@ namespace MP.Prog.Pages
|
||||
//ListRecords = SearchRecords.Skip(numRecord * (currPage % 10 - 1)).Take(numRecord).ToList();
|
||||
|
||||
ListRecords = await DataService.FileGetFilt(AppMService.File_Filter);
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
@@ -330,8 +397,11 @@ namespace MP.Prog.Pages
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
currRecord = null;
|
||||
ListRecords = null;
|
||||
DataService.ResetController();
|
||||
await ReloadData();
|
||||
await Task.Delay(1);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
@@ -356,6 +426,7 @@ namespace MP.Prog.Pages
|
||||
public void Dispose()
|
||||
{
|
||||
AppMService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
AppMService.EA_FilterUpdated -= OnSeachUpdated;
|
||||
}
|
||||
|
||||
public async void OnSeachUpdated()
|
||||
|
||||
Reference in New Issue
Block a user