Merge branch 'feature/FilterUpdate' into develop

This commit is contained in:
Samuele Locatelli
2021-09-14 13:15:23 +02:00
15 changed files with 573 additions and 238 deletions
+116 -38
View File
@@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using MP.FileData.DatabaseModels;
using Newtonsoft.Json;
using MP.FileData.DTO;
namespace MP.FileData.Controllers
{
@@ -35,6 +36,11 @@ namespace MP.FileData.Controllers
#region Public Methods
public static string rulePath(string ruleName)
{
return string.Format($"Conf/{ruleName}");
}
/// <summary>
/// Effettua la comparazione tra i file in archivio ed i file attuali e segna info LastCheck e Changed (se cambiati)
/// </summary>
@@ -44,10 +50,10 @@ namespace MP.FileData.Controllers
/// <param name="searchPattern">pattern di ricerca (*.*)</param>
/// <param name="SearchRules">Regole di ricerca applicate</param>
/// <returns></returns>
public bool CheckFileArchived(string idxMacchina, string path, int numDayPre, string searchPattern, SearchRules currRule)
public int CheckFileArchived(string idxMacchina, string path, int numDayPre, string searchPattern, SearchRules currRule)
{
Log.Info($"CheckFileArchived S00 | macchina: {idxMacchina} | path: {path} | pattern: {searchPattern} | # ExcludedFileExt: {currRule.ExcludedFileExt.Count()}");
bool answ = false;
int checkDone = 0;
DirectoryInfo dirInfo = new DirectoryInfo(path);
FileInfo[] fileListRaw = dirInfo.GetFiles(searchPattern, SearchOption.AllDirectories);
List<FileInfo> fileList = new List<FileInfo>();
@@ -86,6 +92,7 @@ namespace MP.FileData.Controllers
}
else
{
checkDone++;
// cerca nel DB...
FileModel currRecord = archivedFile
.Where(x => x.Active && x.Path == file.FullName)
@@ -139,9 +146,10 @@ namespace MP.FileData.Controllers
if (fileChecked != null && fileChecked.Count > 0)
{
FileSetChecked(fileChecked);
Log.Info($"CheckFileArchived S05 | refreshed {fileChecked.Count} files");
}
return answ;
return checkDone;
}
public void Dispose()
@@ -150,6 +158,19 @@ namespace MP.FileData.Controllers
dbCtx.Dispose();
}
public int FileCountFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, 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) && (!OnlyMod || x.DiskStatus != FileState.Ok) && (x.Name.Contains(SearchVal) || string.IsNullOrEmpty(SearchVal)))
.Count();
}
return answ;
}
/// <summary>
/// ELiminazione file da tabella
/// </summary>
@@ -230,7 +251,7 @@ namespace MP.FileData.Controllers
return dbResult;
}
public List<DatabaseModels.FileModel> FileGetFilt(string IdxMacchina, string CodArticolo, bool OnlyActive, bool OnlyMod, string SearchVal = "")
public List<DatabaseModels.FileModel> FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, int numStart, int numRecords, string SearchVal = "")
{
List<DatabaseModels.FileModel> dbResult = new List<DatabaseModels.FileModel>();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
@@ -241,6 +262,8 @@ namespace MP.FileData.Controllers
.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)))
.OrderByDescending(x => x.LastMod)
.Skip(numStart)
.Take(numRecords)
.ToList();
}
return dbResult;
@@ -280,7 +303,7 @@ namespace MP.FileData.Controllers
FileContent = File.ReadAllBytes(o.FullName)
}).ToList();
// gestione Tags (da migliorare...)
// elenco Tags
List<TagModel> currTags = localDbCtx.DbSetTags.ToList();
// calcolo MD5 e tags
@@ -346,6 +369,8 @@ namespace MP.FileData.Controllers
public bool FileModApprove(FileModel currFile)
{
bool done = false;
// recupero file regole json da macchina..
List<FileInfo> listUpdate = new List<FileInfo>();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
@@ -353,40 +378,39 @@ namespace MP.FileData.Controllers
var newFileInfo = new FileInfo(currFile.Path);
listUpdate.Add(newFileInfo);
// fixme todo !!! fix da conf file
Dictionary<string, string> confReplace = new Dictionary<string, string>();
confReplace.Add("(", " ");
confReplace.Add(")", " ");
Dictionary<string, string> fileExtReplace = new Dictionary<string, string>();
fileExtReplace.Add(".P-2", "");
// hard coded + salvataggio conf x creare json
SearchRules currRule = new SearchRules()
var currMacchina = localDbCtx
.DbSetMacchine
.Where(x => x.IdxMacchina == currFile.IdxMacchina)
.SingleOrDefault();
if (currMacchina != null)
{
Name = "Commento Filename",
Mode = SearchMode.StringOnFile,
MaxChar2Search = 100,
ReplaceCR = true,
RegExPattern = "\\b{{fileName}}" + @".{0,2}\([\w\d\s.]+\)",
RegExRepFileName = true,
ExcludedTags = new List<string>() { "M4", "M5", "M4+A", "M4+B", "M5+A", "M5+B" },
FileNameExtReplace = fileExtReplace,
OutReplace = confReplace,
OutExcludeFileName = true
};
// gestione confRule...
SearchRules currRule = new SearchRules();
try
{
string rawData = File.ReadAllText(rulePath(currMacchina.RuleName));
currRule = JsonConvert.DeserializeObject<SearchRules>(rawData);
}
catch (Exception exc)
{
Log.Error($"Eccezione in deserializzazione conf rule{Environment.NewLine}{exc}");
}
// se ho letto conf
if (currRule.Name != "ND")
{
// inserisco come REVISIONE
FileInsert(currFile.IdxMacchina, listUpdate, currFile.Rev + 1, currRule);
// inserisco come REVISIONE
FileInsert(currFile.IdxMacchina, listUpdate, currFile.Rev + 1, currRule);
// archivio vecchio file
currFile.Active = false;
currFile.DiskStatus = FileState.Ok;
localDbCtx.Entry(currFile).State = EntityState.Modified;
// salvo DB
localDbCtx.SaveChanges();
// archivio vecchio file
currFile.Active = false;
currFile.DiskStatus = FileState.Ok;
localDbCtx.Entry(currFile).State = EntityState.Modified;
// salvo DB
localDbCtx.SaveChanges();
done = true;
done = true;
}
}
}
return done;
}
@@ -441,7 +465,7 @@ namespace MP.FileData.Controllers
}
/// <summary>
/// Effettua update di un record in archivio da lista (SOLO STATUS)
/// Effettua update di un record in archivio da lista (solo status, da approvare)
/// </summary>
/// <param name="updFiles"></param>
/// <returns></returns>
@@ -468,7 +492,7 @@ namespace MP.FileData.Controllers
}
/// <summary>
/// Aggiorna un Ordine
/// Aggiorna un record FILE rileggendo e ricalcolando...
/// </summary>
/// <param name="updItem"></param>
/// <returns></returns>
@@ -479,11 +503,16 @@ namespace MP.FileData.Controllers
{
try
{
// elenco Tags
List<TagModel> currTags = localDbCtx.DbSetTags.ToList();
// file
FileModel currData = null;
currData = dbCtx
.DbSetProgFile
.Where(x => x.FileId == updItem.FileId)
.FirstOrDefault();
if (currData != null)
{
updItem.DiskStatus = FileState.Changed;
@@ -507,6 +536,55 @@ namespace MP.FileData.Controllers
return done;
}
public List<ArchiveStatusDTO> GetArchiveStatus()
{
List<ArchiveStatusDTO> ArchiveList = new List<ArchiveStatusDTO>();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
ArchiveList = localDbCtx
.DbSetMacchine
.Select(x => new ArchiveStatusDTO()
{
IdxMacchina = x.IdxMacchina,
Nome = x.Nome,
Descrizione = x.Descrizione,
BasePath = x.BasePath
})
.ToList();
// ora ciclo a cercare i file...
foreach (var item in ArchiveList)
{
item.TotFile = localDbCtx
.DbSetProgFile
.Where(x => x.IdxMacchina == item.IdxMacchina && x.Active)
.Count();
item.NumChanged = localDbCtx
.DbSetProgFile
.Where(x => x.IdxMacchina == item.IdxMacchina && x.Active && x.DiskStatus == FileState.Changed)
.Count();
}
}
return ArchiveList;
}
/// <summary>
/// Recupera singola macchina
/// </summary>
/// <returns></returns>
public MacchinaModel MacchinaGetByKey(string idxMacchina)
{
MacchinaModel dbResult = new MacchinaModel();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
dbResult = localDbCtx
.DbSetMacchine
.Where(x => x.IdxMacchina == idxMacchina)
.SingleOrDefault();
}
return dbResult;
}
/// <summary>
/// Elenco tabella Macchine
/// </summary>
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MP.FileData.DTO
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
public class ArchiveStatusDTO
{
public string IdxMacchina { get; set; } = "";
public string Nome { get; set; } = "";
public string Descrizione { get; set; } = "";
public string BasePath { get; set; } = "";
public int TotFile { get; set; } = 0;
public int NumChanged { get; set; } = 0;
}
}
+3 -1
View File
@@ -1,4 +1,5 @@
using System;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -15,6 +16,7 @@ namespace MP.FileData.DatabaseModels
/// Tabella archivio dei File Programma
/// </summary>
[Table("Files")]
[Index(nameof(IdxMacchina), nameof(Active), nameof(DiskStatus))]
public partial class FileModel
{
#region Public Properties
@@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace MP.FileData.Migrations
{
[DbContext(typeof(MoonPro_ProgContext))]
[Migration("20210908125127_InitDb")]
[Migration("20210913153816_InitDb")]
partial class InitDb
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -82,7 +82,7 @@ namespace MP.FileData.Migrations
b.HasKey("FileId");
b.HasIndex("IdxMacchina");
b.HasIndex("IdxMacchina", "Active", "DiskStatus");
b.ToTable("Files");
});
@@ -101,9 +101,9 @@ namespace MP.FileData.Migrations
column: "TagsTagId");
migrationBuilder.CreateIndex(
name: "IX_Files_IdxMacchina",
name: "IX_Files_IdxMacchina_Active_DiskStatus",
table: "Files",
column: "IdxMacchina");
columns: new[] { "IdxMacchina", "Active", "DiskStatus" });
}
protected override void Down(MigrationBuilder migrationBuilder)
@@ -80,7 +80,7 @@ namespace MP.FileData.Migrations
b.HasKey("FileId");
b.HasIndex("IdxMacchina");
b.HasIndex("IdxMacchina", "Active", "DiskStatus");
b.ToTable("Files");
});
+82
View File
@@ -0,0 +1,82 @@
<div class="row">
<div class="col-4">
<button id="btnForceCheck" class="btn btn-danger btn-sm btn-block" @onclick="() => ForceCheck(0)" title="Forza verifica archivio (totale)">
<i class="fas fa-sync-alt"></i> Update Completo Archivio <i class="far fa-folder-open"></i>
</button>
</div>
<div class="col-8 py-2">
@if (showProgress)
{
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:@percLoading%;"></div>
</div>
}
</div>
<div class="col-12 mt-2">
@if (ListRecords == null)
{
<div class="row">
<div class="col-4">
@if (showProgress)
{
<div class="col-12 mt-2">
<div class="alert alert-primary">
@if (setupMessages.Count > 0)
{
<ul>
@foreach (var item in setupMessages)
{
<li>@item</li>
}
</ul>
}
</div>
</div>
}
</div>
<div class="col-8">
<LoadingData></LoadingData>
</div>
</div>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<table class="table table-sm table-striped table-responsive-lg">
<thead>
<tr>
<th>Macchina</th>
<th>Path</th>
<th class="text-right">Modificati</th>
<th class="text-right">Tot File</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr>
<td>
@record.Nome
</td>
<td>
<div class="small">@record.BasePath</div>
</td>
<td class="text-right">
@record.NumChanged
</td>
<td class="text-right">
<b>
@record.TotFile
</b>
</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
+106
View File
@@ -0,0 +1,106 @@
using Microsoft.AspNetCore.Components;
using MP.FileData.DTO;
using MP.Prog.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MP.Prog.Components
{
public partial class ArchiveStatus
{
#region Private Fields
private List<ArchiveStatusDTO> ListRecords;
private int numChecks = 0;
private int totalCount = 0;
#endregion Private Fields
#region Private Properties
private List<string> setupMessages { get; set; } = new List<string>();
#endregion Private Properties
#region Protected Properties
[Inject]
protected FileArchDataService DataService { get; set; }
protected int percLoading { get; set; } = 0;
protected bool showProgress { get; set; } = false;
#endregion Protected Properties
#region Private Methods
private async Task verificaTutte(int maxHour)
{
// recupero elenco macchine
var listaMacchine = await DataService.MacchineGetAll();
int numMacchine = listaMacchine.Count();
foreach (var item in listaMacchine.Where(x => !string.IsNullOrEmpty(x.BasePath)).ToList())
{
percLoading += 100 / numMacchine;
numChecks += await DataService.updateMachineArchive(item.IdxMacchina, maxHour, false);
setupMessages.Add($"{item.IdxMacchina}: {numChecks} files");
StateHasChanged();
await Task.Delay(1);
}
}
#endregion Private Methods
#region Protected Methods
protected async Task ArchiveCheck(int maxHour)
{
showProgress = true;
percLoading = 0;
await verificaTutte(maxHour);
setupMessages.Add($"Effettuata verifica e rilettura di {numChecks} files!");
await ReloadData();
}
protected async Task ClearMessage()
{
await Task.Delay(100);
setupMessages = new List<string>();
}
protected async Task ForceCheck(int maxHour)
{
setupMessages.Add("Inizio Analisi Archivio...");
ListRecords = null;
await ArchiveCheck(maxHour);
await ReloadData();
await ClearMessage();
}
protected override async Task OnInitializedAsync()
{
ListRecords = null;
await ReloadData();
}
protected async Task ReloadData()
{
await Task.Delay(1);
numChecks = 0;
ListRecords = await DataService.GetArchiveStatus();
totalCount = ListRecords.Count;
await Task.Delay(1);
setupMessages = new List<string>();
showProgress = false;
percLoading = 0;
}
#endregion Protected Methods
}
}
+2 -1
View File
@@ -1,4 +1,5 @@
<div class="row p-5 m-5">
@*<h1 class="alert alert-info">Working</h1>*@
<div class="row p-3 m-3">
<div class="col-12 text-center mt-5 py-5 alert alert-primary">
<h3>loading data</h3>
<i class="fas fa-spinner fa-spin fa-5x"></i>
+109 -61
View File
@@ -12,6 +12,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using MP.FileData.Controllers;
using MP.FileData.DTO;
namespace MP.Prog.Data
{
@@ -104,15 +106,6 @@ namespace MP.Prog.Data
#endregion Private Properties
#region Protected Methods
protected string rulePath(string ruleName)
{
return string.Format($"Conf/{ruleName}");
}
#endregion Protected Methods
#region Internal Methods
internal Task FileApprove(FileData.DatabaseModels.FileModel currItem)
@@ -224,23 +217,53 @@ namespace MP.Prog.Data
dbController.Dispose();
}
public async Task<int> FileCountFilt(SelectData CurrFilter)
{
int numCount = 0;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
numCount = dbController.FileCountFilt(CurrFilter.IdxMacchina, CurrFilter.OnlyActive, CurrFilter.OnlyMod, CurrFilter.SearchVal);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per FileCountFilt: {ts.TotalMilliseconds} ms");
return await Task.FromResult(numCount);
}
public Task<FileData.DatabaseModels.FileModel> FileGetByKey(int FileId)
{
return Task.FromResult(dbController.FileGetByKey(FileId));
}
public async Task<List<FileData.DatabaseModels.FileModel>> FileGetFilt(string IdxMacchina, string CodArticolo, bool OnlyActive, bool OnlyMod, string SearchVal)
public async Task<List<FileData.DatabaseModels.FileModel>> FileGetFilt(SelectData CurrFilter)
{
List<FileData.DatabaseModels.FileModel> dbResult = new List<FileData.DatabaseModels.FileModel>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.FileGetFilt(IdxMacchina, CodArticolo, OnlyActive, OnlyMod, SearchVal).ToList();
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.FirstRecord, CurrFilter.PageSize * 10, CurrFilter.SearchVal).ToList();
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per FileGetFilt: {ts.TotalMilliseconds} ms");
return await Task.FromResult(dbResult);
}
public async Task<List<ArchiveStatusDTO>> GetArchiveStatus()
{
List<ArchiveStatusDTO> dbResult = new List<ArchiveStatusDTO>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetArchiveStatus();
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per GetArchiveStatus: {ts.TotalMilliseconds} ms");
return await Task.FromResult(dbResult);
}
public Task<FileData.DatabaseModels.MacchinaModel> MacchinaGetByKey(string idxMacchina)
{
return Task.FromResult(dbController.MacchinaGetByKey(idxMacchina));
}
public Task<List<FileData.DatabaseModels.MacchinaModel>> MacchineGetAll()
{
return Task.FromResult(dbController.MacchineGetAll().ToList());
@@ -269,72 +292,97 @@ namespace MP.Prog.Data
/// </summary>
/// <param name="numDayPre">Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite</param>
/// <returns></returns>
public async Task<bool> updateAllArchive(int numDayPre)
public async Task<int> updateAllArchive(int numDayPre)
{
bool done = false;
int checkDone = 0;
var listaMacchine = await MacchineGetAll();
foreach (var item in listaMacchine.Where(x => !string.IsNullOrEmpty(x.BasePath)).ToList())
{
checkDone += await updateMachineArchive(item.IdxMacchina, numDayPre, false);
}
return await Task.FromResult(checkDone);
}
/// <summary>
/// Aggiorna archivio di una amcchina scansionando path relativo
/// </summary>
/// <param name="idxMacchina">Codice macchina</param>
/// <param name="numDayPre">Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite</param>
/// <returns></returns>
public async Task<int> updateMachineArchive(string idxMacchina, int numDayPre, bool fullLog)
{
int checkDone = 0;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string ruleName = "Rule01.json";
try
{
var listaMacchine = await MacchineGetAll();
foreach (var item in listaMacchine.Where(x => !string.IsNullOrEmpty(x.BasePath)).ToList())
var macchina = MacchinaGetByKey(idxMacchina).Result;
if (macchina != null && !string.IsNullOrEmpty(macchina.BasePath))
{
if (!string.IsNullOrEmpty(item.RuleName))
{ }
// gestione confRule...
SearchRules currRule = new SearchRules();
try
if (!string.IsNullOrEmpty(macchina.RuleName))
{
string rawData = File.ReadAllText(rulePath(ruleName));
currRule = JsonConvert.DeserializeObject<SearchRules>(rawData);
Log.Info($"Conf rule acquisito da file {ruleName}:{Environment.NewLine}{rawData}");
}
catch (Exception exc)
{
Log.Error($"Eccezione in deserializzazione conf rule{Environment.NewLine}{exc}");
}
// se NON deserializzato inizializzo hard-coded
if (currRule.Name == "ND")
{
// fare: lettura conf rule x recupero tag x singola macchina
//$"\\b{fileName}" + @".{0,2}\([\w\d\s.]+\)";
Dictionary<string, string> confReplace = new Dictionary<string, string>();
confReplace.Add("(", " ");
confReplace.Add(")", " ");
Dictionary<string, string> fileExtReplace = new Dictionary<string, string>();
fileExtReplace.Add(".P-2", "");
// hard coded + salvataggio conf x creare json
currRule = new SearchRules()
ruleName = macchina.RuleName;
// gestione confRule...
SearchRules currRule = new SearchRules();
try
{
Name = "Commento Filename",
Mode = SearchMode.StringOnFile,
MaxChar2Search = 100,
ReplaceCR = true,
RegExPattern = "\\b{{fileName}}" + @".{0,2}\([\w\d\s./]+\)",
RegExRepFileName = true,
FileNameExtReplace = fileExtReplace,
ExcludedTags = new List<string>() { "M4", "M5", "M4+A", "M4+B", "M5+A", "M5+B" },
OutReplace = confReplace,
OutExcludeFileName = true
};
string rawData = File.ReadAllText(FileController.rulePath(ruleName));
currRule = JsonConvert.DeserializeObject<SearchRules>(rawData);
//Log.Info($"Conf rule acquisito da file {ruleName}:{Environment.NewLine}{rawData}");
}
catch (Exception exc)
{
Log.Error($"Eccezione in deserializzazione conf rule{Environment.NewLine}{exc}");
}
// serializzo
// se NON deserializzato inizializzo hard-coded
if (currRule.Name == "ND")
{
// fare: lettura conf rule x recupero tag x singola macchina
//$"\\b{fileName}" + @".{0,2}\([\w\d\s.]+\)";
string rawRule = JsonConvert.SerializeObject(currRule, Formatting.Indented);
Log.Info($"Conf rule generato:{Environment.NewLine}{rawRule}");
Dictionary<string, string> confReplace = new Dictionary<string, string>();
confReplace.Add("(", " ");
confReplace.Add(")", " ");
Dictionary<string, string> fileExtReplace = new Dictionary<string, string>();
fileExtReplace.Add(".P-2", "");
// hard coded + salvataggio conf x creare json
currRule = new SearchRules()
{
Name = "Commento Filename",
Mode = SearchMode.StringOnFile,
MaxChar2Search = 100,
ReplaceCR = true,
RegExPattern = "\\b{{fileName}}" + @".{0,2}\([\w\d\s./]+\)",
RegExRepFileName = true,
FileNameExtReplace = fileExtReplace,
ExcludedTags = new List<string>() { "M4", "M5", "M4+A", "M4+B", "M5+A", "M5+B" },
OutReplace = confReplace,
OutExcludeFileName = true
};
if (fullLog)
{
// serializzo
string rawRule = JsonConvert.SerializeObject(currRule, Formatting.Indented);
Log.Info($"Conf rule generato:{Environment.NewLine}{rawRule}");
}
}
checkDone = dbController.CheckFileArchived(macchina.IdxMacchina, macchina.BasePath, numDayPre, "*.*", currRule);
}
done = dbController.CheckFileArchived(item.IdxMacchina, item.BasePath, numDayPre, "*.*", currRule);
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in updateAllArchive{Environment.NewLine}{exc}{Environment.NewLine}{exc.InnerException}");
Log.Error($"Eccezione in updateMachineArchive{Environment.NewLine}{exc}{Environment.NewLine}{exc.InnerException}");
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuato update archivio file MACCHINA | last {numDayPre} days | {checkDone} checked | {ts.TotalMilliseconds} ms");
return await Task.FromResult(done);
return await Task.FromResult(checkDone);
}
#endregion Public Methods
+14 -2
View File
@@ -9,7 +9,6 @@ namespace MP.Prog.Data
{
#region Public Properties
public string CodArticolo { get; set; } = "";
public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1);
public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7);
@@ -27,11 +26,24 @@ namespace MP.Prog.Data
}
public string IdxMacchina { get; set; } = "";
/// <summary>
/// Recorda da saltare x arrivare alla pagina corrente
/// </summary>
public int NumSkip
{
get
{
return PageSize * (PageNum - 1);
}
}
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; } = "";
#endregion Public Properties
@@ -69,7 +81,7 @@ namespace MP.Prog.Data
return false;
if (OnlyMod != item.OnlyMod)
return false;
if (CodArticolo != item.CodArticolo)
if (SearchVal != item.SearchVal)
return false;
if (IdxMacchina != item.IdxMacchina)
return false;
+36 -40
View File
@@ -5,46 +5,28 @@
<div class="card">
<div class="card-header table-primary h3">
<div class="row">
<div class="col-12 col-md-3 col-lg-4 h3">
Elenco Programmi
<div class="col-12 col-lg-6">
<div class="d-flex">
<div class="px-2">
<h3>Elenco Programmi</h3>
</div>
<div class="px-2">
<div class="form-group mb-0">
<button id="btnForceCheck" class="btn btn-warning btn-sm" @onclick="() => ForceCheck(30)" title="Analisi Modifiche ultimi 30gg">
<i class="fas fa-sync-alt"></i> Update (30gg) <i class="far fa-folder-open"></i>
</button>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-9 col-lg-8 text-right">
<div class="form-row">
<div class="col-1">
<div class="col-12 col-lg-6 text-right">
<div class="d-flex flex-row-reverse">
<div class="px-2">
<div class="form-group mb-0">
<button id="btnForceCheck" class="btn btn-danger btn-sm btn-block" @onclick="() => ForceCheck(0)" title="Forza verifica archivio (totale)">
<i class="far fa-folder-open"></i>&nbsp;<i class="fas fa-sync-alt"></i>
</button>
<button id="btnReset" class="btn btn-info btn-sm" @onclick="() => ResetFilter()" title="Reset Filter"><span class="oi oi-loop-circular"></span></button>
</div>
</div>
<div class="col-1">
<div class="form-group mb-0">
<button id="btnForceCheck" class="btn btn-warning btn-sm btn-block" @onclick="() => TestLoading()" title="Ultime modifiche (last 48h)">
<i class="far fa-folder-open"></i>&nbsp;<i class="fas fa-sync-alt"></i>
</button>
</div>
</div>
<div class="col-1">
<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>
</div>
</div>
</div>
<div class="col-1">
<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>
</div>
</div>
</div>
<div class="col-7">
<div class="px-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
@@ -62,9 +44,24 @@
</select>
</div>
</div>
<div class="col-1">
<div class="form-group mb-0">
<button id="btnReset" class="btn btn-info btn-sm btn-block" @onclick="() => ResetFilter()" title="Reset Filter"><span class="oi oi-loop-circular"></span></button>
<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>
</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>
</div>
</div>
</div>
</div>
@@ -78,7 +75,6 @@
}
@if (ListRecords == null)
{
<h1 class="alert alert-info">Working</h1>
<LoadingData></LoadingData>
}
else if (totalCount == 0)
+48 -83
View File
@@ -2,6 +2,7 @@
using Microsoft.JSInterop;
using MP.FileData.DatabaseModels;
using MP.Prog.Data;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -14,10 +15,10 @@ namespace MP.Prog.Pages
{
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private FileModel currRecord = null;
private List<FileModel> ListRecords;
private List<MacchinaModel> MacList;
private List<FileModel> SearchRecords;
private List<TagModel> TagList;
#endregion Private Fields
@@ -28,28 +29,10 @@ namespace MP.Prog.Pages
protected string defTag = "";
protected int totalCount = 0;
#endregion Protected Fields
#if false
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
private int currPage
{
get => _currPage;
set
{
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
#endif
#region Private Properties
private int currPage
@@ -78,22 +61,6 @@ namespace MP.Prog.Pages
}
}
#if false
private int numRecord
{
get => _numRecord;
set
{
if (_numRecord != value)
{
_numRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
#endif
private bool OnlyActive
{
get
@@ -110,7 +77,10 @@ namespace MP.Prog.Pages
if (!AppMService.File_Filter.OnlyActive.Equals(value))
{
AppMService.File_Filter.OnlyActive = value;
var pUpd = Task.Run(async () => await ReloadData());
var pUpd = Task.Run(async () =>
{
await AsyncReload();
});
pUpd.Wait();
}
}
@@ -132,7 +102,10 @@ namespace MP.Prog.Pages
if (!AppMService.File_Filter.OnlyMod.Equals(value))
{
AppMService.File_Filter.OnlyMod = value;
var pUpd = Task.Run(async () => await ReloadData());
var pUpd = Task.Run(async () =>
{
await AsyncReload();
});
pUpd.Wait();
}
}
@@ -154,7 +127,10 @@ namespace MP.Prog.Pages
if (!AppMService.File_Filter.IdxMacchina.Equals(value))
{
AppMService.File_Filter.IdxMacchina = value;
var pUpd = Task.Run(async () => await ReloadData());
var pUpd = Task.Run(async () =>
{
await AsyncReload();
});
pUpd.Wait();
}
}
@@ -202,19 +178,6 @@ namespace MP.Prog.Pages
}
}
protected int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
#endregion Protected Properties
#region Private Methods
@@ -254,6 +217,15 @@ namespace MP.Prog.Pages
#region Protected Methods
protected async Task AsyncReload()
{
isLoading = true;
currRecord = null;
ListRecords = null;
await ReloadData();
isLoading = false;
}
protected void Edit(FileModel selRecord)
{
// rileggo dal DB il record corrente...
@@ -261,24 +233,21 @@ namespace MP.Prog.Pages
pUpd.Wait();
}
protected void ForceCheck(int maxHour)
protected async Task ForceCheck(int numDays)
{
var pUpd = Task.Run(async () =>
{
currRecord = null;
SearchRecords = null;
ListRecords = null;
await DataService.updateAllArchive(maxHour);
AppMService.File_Filter = SelectData.Init(5, 10);
await ReloadAllData();
isLoading = false;
});
pUpd.Wait();
currRecord = null;
ListRecords = null;
// importante altrimenti NON mostra update UI
await Task.Delay(1);
//AppMService.File_Filter = SelectData.Init(5, 10);
var numCheck = await DataService.updateAllArchive(numDays);
await ReloadAllData();
await Task.Delay(1);
await RefreshDisplayLoading();
}
protected override async Task OnInitializedAsync()
{
DataService.ResetController();
SearchTag = defTag;
AppMService.ShowSearch = false;
AppMService.PageName = "Archivio File Programmi";
@@ -302,6 +271,12 @@ namespace MP.Prog.Pages
isLoading = false;
}
protected async Task RefreshDisplayLoading()
{
await Task.Delay(1);
isLoading = false;
}
protected async Task ReloadAllData()
{
isLoading = true;
@@ -315,10 +290,14 @@ namespace MP.Prog.Pages
protected async Task ReloadData()
{
isLoading = true;
// importante altrimenti NON mostra update UI
await Task.Delay(1);
SearchRecords = await DataService.FileGetFilt(AppMService.File_Filter.IdxMacchina, AppMService.File_Filter.CodArticolo, AppMService.File_Filter.OnlyActive, AppMService.File_Filter.OnlyMod, AppMService.SearchVal);
// faccio paginazione SOLO NELLA DECINA attuale... (quindi non tutte le pagine ma solo subset)
ListRecords = SearchRecords.Skip(numRecord * (currPage % 10 - 1)).Take(numRecord).ToList();
totalCount = await DataService.FileCountFilt(AppMService.File_Filter);
//SearchRecords = await DataService.FileGetFilt(AppMService.File_Filter);
//// faccio paginazione SOLO NELLA DECINA attuale... (quindi non tutte le pagine ma solo subset)
//ListRecords = SearchRecords.Skip(numRecord * (currPage % 10 - 1)).Take(numRecord).ToList();
ListRecords = await DataService.FileGetFilt(AppMService.File_Filter);
}
protected void ResetData()
@@ -330,7 +309,6 @@ namespace MP.Prog.Pages
protected async Task ResetFilter()
{
currRecord = null;
SearchRecords = null;
ListRecords = null;
AppMService.File_Filter = SelectData.Init(5, 10);
SearchTag = defTag;
@@ -349,19 +327,6 @@ namespace MP.Prog.Pages
currRecord = selRecord;
}
protected async Task TestLoading()
{
//isLoading = !isLoading;
await TestLoadingCloseTest();
isLoading = false;
}
protected async Task TestLoadingCloseTest()
{
isLoading = true;
await Task.Delay(1000);
}
protected async Task UpdateData()
{
currRecord = null;
+9 -7
View File
@@ -6,10 +6,12 @@
@inject MessageService AppMService
<h3>Setup</h3>
<MP.Prog.Components.Test></MP.Prog.Components.Test>
@code {
}
<div class="card">
<div class="card-header">
<h4>Setup</h4>
</div>
<div class="card-body">
<MP.Prog.Components.ArchiveStatus></MP.Prog.Components.ArchiveStatus>
</div>
@*<div class="card-footer">Footer</div>*@
</div>
+21
View File
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Components;
using MP.Prog.Data;
using System;
using System.Threading.Tasks;
namespace MP.Prog.Pages
{
public partial class Setup : ComponentBase
{
#region Protected Methods
protected override void OnInitialized()
{
AppMService.ShowSearch = false;
AppMService.PageName = "Setup";
AppMService.PageIcon = "fas fa-wrench pr-2";
}
#endregion Protected Methods
}
}