diff --git a/MP.FileData/Controllers/FileController.cs b/MP.FileData/Controllers/FileController.cs index e2a87abd..20053510 100644 --- a/MP.FileData/Controllers/FileController.cs +++ b/MP.FileData/Controllers/FileController.cs @@ -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 FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, int numStart, int numRecords, string SearchVal = "") + public List FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, int numStart, int numRecords, string fileName) { List dbResult = new List(); 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; diff --git a/MP.FileData/DTO/ArchiveStatusDTO.cs b/MP.FileData/DTO/ArchiveStatusDTO.cs index bf70e51e..224bf0d7 100644 --- a/MP.FileData/DTO/ArchiveStatusDTO.cs +++ b/MP.FileData/DTO/ArchiveStatusDTO.cs @@ -11,12 +11,37 @@ namespace MP.FileData.DTO // public class ArchiveStatusDTO { + /// + /// Idx macchina + /// public string IdxMacchina { get; set; } = ""; + /// + /// Nome macchina + /// public string Nome { get; set; } = ""; + /// + /// Descrizione macchina + /// public string Descrizione { get; set; } = ""; + /// + /// Percorso base x macchina + /// public string BasePath { get; set; } = ""; - + /// + /// Totale file della amcchina + /// public int TotFile { get; set; } = 0; + /// + /// NBumero file modificati da confermare/rifiutare + /// public int NumChanged { get; set; } = 0; + /// + /// Conteggio totale tags x macchina + /// + public int TotalTags { get; set; } + /// + /// Numero di file SENZA tag + /// + public int NoTags { get; set; } } } diff --git a/MP.Prog/Components/ArchiveStatus.razor b/MP.Prog/Components/ArchiveStatus.razor index f9dee5a1..8fa1a2f8 100644 --- a/MP.Prog/Components/ArchiveStatus.razor +++ b/MP.Prog/Components/ArchiveStatus.razor @@ -52,6 +52,8 @@ Macchina Path + Tags + Senza Tag Modificati Tot File @@ -74,6 +76,12 @@
@record.BasePath
+ + @record.TotalTags + + + @record.NoTags + @record.NumChanged diff --git a/MP.Prog/Data/FileArchDataService.cs b/MP.Prog/Data/FileArchDataService.cs index 9c5ef331..2fd3aa1c 100644 --- a/MP.Prog/Data/FileArchDataService.cs +++ b/MP.Prog/Data/FileArchDataService.cs @@ -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 dbResult = new List(); 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; diff --git a/MP.Prog/Data/MessageService.cs b/MP.Prog/Data/MessageService.cs index 57585ff0..00556f11 100644 --- a/MP.Prog/Data/MessageService.cs +++ b/MP.Prog/Data/MessageService.cs @@ -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; diff --git a/MP.Prog/Data/SelectData.cs b/MP.Prog/Data/SelectData.cs index f1b36f0e..fc3bdc50 100644 --- a/MP.Prog/Data/SelectData.cs +++ b/MP.Prog/Data/SelectData.cs @@ -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; } = ""; + /// /// Primo record x selezione paginata, tipicamente primo della "decina" della pagina corrente /// @@ -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) diff --git a/MP.Prog/Pages/Archive.razor b/MP.Prog/Pages/Archive.razor index 16edd386..650f40c0 100644 --- a/MP.Prog/Pages/Archive.razor +++ b/MP.Prog/Pages/Archive.razor @@ -3,7 +3,7 @@ @using MP.Prog.Components
-
+
@@ -46,24 +46,32 @@
-
-
- +
-
-
- +
+
+ @if (!string.IsNullOrEmpty(SelFileName)) + { + @SelFileName + } +
+
+ @if (!string.IsNullOrEmpty(SelTag)) + { + @SelTag + } +
@@ -120,7 +128,9 @@
@record.Name
-
@record.Path
+
@@ -143,17 +153,15 @@ @foreach (var item in record.Tags) { - @item.TagId + }
@record.LastMod.ToString("yyyy.MM.dd")
@record.LastMod.ToString("ddd HH:mm.ss")
- @* -
@record.LastCheck.ToString("yyyy.MM.dd")
-
@record.LastCheck.ToString("ddd HH:mm.ss")
- *@ } diff --git a/MP.Prog/Pages/Archive.razor.cs b/MP.Prog/Pages/Archive.razor.cs index 390f6e1d..e6e25e6d 100644 --- a/MP.Prog/Pages/Archive.razor.cs +++ b/MP.Prog/Pages/Archive.razor.cs @@ -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()