Ancora fix procedura decodifica tags
This commit is contained in:
@@ -48,9 +48,10 @@ namespace MP.FileData.Controllers
|
||||
/// <param name="path">path ricerca x macchina</param>
|
||||
/// <param name="numDayPre">Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite</param>
|
||||
/// <param name="searchPattern">pattern di ricerca (*.*)</param>
|
||||
/// <param name="forceTag">Forza il controllo dei Tags</param>
|
||||
/// <param name="SearchRules">Regole di ricerca applicate</param>
|
||||
/// <returns></returns>
|
||||
public int CheckFileArchived(string idxMacchina, string path, int numDayPre, string searchPattern, SearchRules currRule)
|
||||
public int CheckFileArchived(string idxMacchina, string path, int numDayPre, string searchPattern, bool forceTag, SearchRules currRule)
|
||||
{
|
||||
Log.Info($"CheckFileArchived S00 | macchina: {idxMacchina} | path: {path} | pattern: {searchPattern} | # ExcludedFileExt: {currRule.ExcludedFileExt.Count()}");
|
||||
int checkDone = 0;
|
||||
@@ -92,7 +93,6 @@ namespace MP.FileData.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
checkDone++;
|
||||
// cerca nel DB...
|
||||
FileModel currRecord = archivedFile
|
||||
.Where(x => x.Active && x.Path == file.FullName)
|
||||
@@ -133,19 +133,22 @@ namespace MP.FileData.Controllers
|
||||
// salvo i NUOVI file
|
||||
if (fileNew != null && fileNew.Count > 0)
|
||||
{
|
||||
checkDone += fileNew.Count;
|
||||
FileInsert(idxMacchina, path, fileNew, 0, currRule);
|
||||
Log.Info($"CheckFileArchived S03 | insert {fileNew.Count} files");
|
||||
}
|
||||
// aggiorno i file modificati
|
||||
if (fileMod != null && fileMod.Count > 0)
|
||||
{
|
||||
checkDone += fileMod.Count;
|
||||
FileSetUpdated(fileMod);
|
||||
Log.Info($"CheckFileArchived S04 | update {fileMod.Count} files");
|
||||
}
|
||||
// segno data-ora ultimo controllo x file invariati
|
||||
if (fileChecked != null && fileChecked.Count > 0)
|
||||
{
|
||||
FileSetChecked(fileChecked);
|
||||
checkDone += fileChecked.Count;
|
||||
FileSetChecked(fileChecked, path, currRule, forceTag);
|
||||
Log.Info($"CheckFileArchived S05 | refreshed {fileChecked.Count} files");
|
||||
}
|
||||
|
||||
@@ -272,9 +275,11 @@ namespace MP.FileData.Controllers
|
||||
/// <summary>
|
||||
/// Effettua inserimento di un elenco di record in archivio come NUOVO documento tracciato
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="newFiles"></param>
|
||||
/// <param name="rev"></param>
|
||||
/// <param name="idxMacchina">Macchina</param>
|
||||
/// <param name="basePath">Path base macchina</param>
|
||||
/// <param name="newFiles">Elenco files</param>
|
||||
/// <param name="rev">rev da usare x creazione</param>
|
||||
/// <param name="currRule">Configuraizone ricerca</param>
|
||||
/// <returns></returns>
|
||||
public bool FileInsert(string idxMacchina, string basePath, List<FileInfo> newFiles, int rev, SearchRules currRule)
|
||||
{
|
||||
@@ -330,7 +335,7 @@ namespace MP.FileData.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
Tags = TagsUtils.searchPathName(fileName, basePath, currRule);
|
||||
Tags = TagsUtils.searchPathName(item.Path, basePath, currRule);
|
||||
}
|
||||
|
||||
foreach (var tag in Tags)
|
||||
@@ -448,23 +453,93 @@ namespace MP.FileData.Controllers
|
||||
/// <summary>
|
||||
/// Effettua update di un record in archivio da lista (SOLO STATUS)
|
||||
/// </summary>
|
||||
/// <param name="updFiles"></param>
|
||||
/// <param name="updFiles">Elenco file controllati</param>
|
||||
/// <param name="basePath">Path base macchina</param>
|
||||
/// <param name="currRule">Configuraizone ricerca</param>
|
||||
/// <param name="forceTag">Indica se fare COMUNQUE verifica del TAG</param>
|
||||
/// <returns></returns>
|
||||
public bool FileSetChecked(List<FileModel> updFiles)
|
||||
public bool FileSetChecked(List<FileModel> updFiles, string basePath, SearchRules currRule, bool forceTag)
|
||||
{
|
||||
bool answ = false;
|
||||
DateTime adesso = DateTime.Now;
|
||||
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
// SOLO SE richiesto forzatura tags
|
||||
if (forceTag)
|
||||
{
|
||||
// elenco Tags
|
||||
List<TagModel> currTags = localDbCtx.DbSetTags.ToList();
|
||||
foreach (var item in updFiles)
|
||||
{
|
||||
// rimuovo tags vecchi
|
||||
if (item.Tags != null)
|
||||
{
|
||||
item.Tags.Clear();
|
||||
localDbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
List<string> Tags = new List<string>();
|
||||
List<TagModel> Tag4File = new List<TagModel>();
|
||||
// se necessario bonifico filename...
|
||||
string fileName = item.Name;
|
||||
if (currRule.FileNameExtReplace.Count > 0)
|
||||
{
|
||||
foreach (var fReplace in currRule.FileNameExtReplace)
|
||||
{
|
||||
fileName = fileName.Replace(fReplace.Key, fReplace.Value).Trim();
|
||||
}
|
||||
}
|
||||
// cerco codice tag da configurazione
|
||||
if (currRule.Mode == SearchMode.StringOnFile)
|
||||
{
|
||||
Tags = TagsUtils.searchProgComment(fileName, item.FileStringContent, currRule);
|
||||
}
|
||||
else
|
||||
{
|
||||
Tags = TagsUtils.searchPathName(item.Path, basePath, currRule);
|
||||
}
|
||||
|
||||
foreach (var tag in Tags)
|
||||
{
|
||||
var foundTag = currTags.SingleOrDefault(x => x.TagId == tag);
|
||||
// aggiungo i tags SE non ci fossero
|
||||
if (foundTag == null)
|
||||
{
|
||||
var newTag = new TagModel() { TagId = tag };
|
||||
currTags.Add(newTag);
|
||||
Tag4File.Add(newTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
// al file aggiungo comunque
|
||||
Tag4File.Add(foundTag);
|
||||
}
|
||||
}
|
||||
// aggiungo ai file
|
||||
if (Tag4File.Count > 0)
|
||||
{
|
||||
// salvo i tags relativi ai files
|
||||
item.Tags = Tag4File;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
// salvo
|
||||
localDbCtx.SaveChanges();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in salvataggio FileSetChecked{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
// update comunque data-ora
|
||||
foreach (var item in updFiles)
|
||||
{
|
||||
// salvo update file
|
||||
item.LastCheck = adesso;
|
||||
localDbCtx.Entry(item).State = EntityState.Modified;
|
||||
}
|
||||
|
||||
// salvo
|
||||
localDbCtx.SaveChanges();
|
||||
answ = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace MP.FileData
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
#if false
|
||||
// dal nome se richeisto estraggo...
|
||||
if (!currRule.OutExcludeFileName)
|
||||
{
|
||||
@@ -51,20 +52,23 @@ namespace MP.FileData
|
||||
// aggiungo fileName
|
||||
answ.Add(fileName);
|
||||
}
|
||||
#endif
|
||||
// ora da path... escludo base e file...
|
||||
string dirPath = filePath.Replace(fileName, "").Replace(basePath, "");
|
||||
string dirPath = filePath.Replace(basePath, "");
|
||||
// bonifico
|
||||
foreach (var item in currRule.OutReplace)
|
||||
{
|
||||
dirPath = dirPath.Replace(item.Key, item.Value);
|
||||
}
|
||||
// splitto per "/"
|
||||
var pathTags = dirPath.Split(@"\");
|
||||
foreach (var segmenti in pathTags)
|
||||
foreach (var item in pathTags)
|
||||
{
|
||||
string rawData = segmenti;
|
||||
// bonifico
|
||||
foreach (var item in currRule.OutReplace)
|
||||
if (!string.IsNullOrWhiteSpace(item))
|
||||
{
|
||||
rawData = rawData.Replace(item.Key, item.Value);
|
||||
// fix replace filtro
|
||||
answ.Add(item);
|
||||
}
|
||||
// fix replace filtro
|
||||
answ.Add(rawData);
|
||||
}
|
||||
|
||||
// se nullo --> segnalo!
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<table class="table table-sm table-striped table-responsive-lg">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Macchina</th>
|
||||
<th>Path</th>
|
||||
<th class="text-right">Modificati</th>
|
||||
@@ -59,6 +60,14 @@
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@if (!string.IsNullOrEmpty(record.BasePath))
|
||||
{
|
||||
<button id="btnForceCheck" class="btn btn-warning btn-sm" @onclick="() => ForceCheckMacchina(record.IdxMacchina)" title="Forza verifica Archivio singola macchina">
|
||||
<i class="fas fa-sync-alt"></i>
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@record.Nome
|
||||
</td>
|
||||
|
||||
@@ -38,19 +38,25 @@ namespace MP.Prog.Components
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task verificaTutte(int maxHour)
|
||||
private async Task verificaSingola(string idxMacchina, int numDays, int numMacchine)
|
||||
{
|
||||
// recupero elenco macchine
|
||||
percLoading += 100 / numMacchine;
|
||||
numChecks = await DataService.updateMachineArchive(idxMacchina, numDays, true, false);
|
||||
await Task.Delay(1);
|
||||
setupMessages.Add($"{idxMacchina}: {numChecks} files");
|
||||
StateHasChanged();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
private async Task verificaTutte(int numDays)
|
||||
{
|
||||
// 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);
|
||||
await verificaSingola(item.IdxMacchina, numDays, numMacchine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +74,16 @@ namespace MP.Prog.Components
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ArchiveSingleCheck(string idxMacchina, int maxHour)
|
||||
{
|
||||
showProgress = true;
|
||||
percLoading = 0;
|
||||
await verificaSingola(idxMacchina, maxHour, 2);
|
||||
|
||||
setupMessages.Add($"Effettuata verifica e rilettura di {numChecks} files!");
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ClearMessage()
|
||||
{
|
||||
await Task.Delay(500);
|
||||
@@ -84,6 +100,16 @@ namespace MP.Prog.Components
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ForceCheckMacchina(string idxMacchina)
|
||||
{
|
||||
setupMessages.Add("Inizio Analisi Archivio...");
|
||||
ListRecords = null;
|
||||
await Task.Delay(1);
|
||||
await ArchiveSingleCheck(idxMacchina, 0);
|
||||
await ClearMessage();
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
ListRecords = null;
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
"M4+A",
|
||||
"M4+B",
|
||||
"M5+A",
|
||||
"M5+B"
|
||||
"M5+B",
|
||||
"M6+A",
|
||||
"M6+B",
|
||||
"+A"
|
||||
],
|
||||
"ExcludedFileExt": [
|
||||
".xls",
|
||||
@@ -13,7 +16,8 @@
|
||||
".xlsx"
|
||||
],
|
||||
"FileNameExtReplace": {
|
||||
".P-2": ""
|
||||
".P-2": "",
|
||||
".tim": ""
|
||||
},
|
||||
"MaxChar2Search": 100,
|
||||
"Mode": 0,
|
||||
@@ -25,7 +29,7 @@
|
||||
"<": " ",
|
||||
">": " "
|
||||
},
|
||||
"RegExPattern": "\\b{{fileName}}.{0,2}\\([\\w\\d\\s./\\-=]+\\)",
|
||||
"RegExPattern": "\\b{{fileName}}.{0,2}\\([\\<\\w\\d\\s./\\-=\\+\\>]+\\)",
|
||||
"RegExRepFileName": true,
|
||||
"ReplaceCR": true
|
||||
}
|
||||
@@ -292,13 +292,13 @@ 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<int> updateAllArchive(int numDayPre)
|
||||
public async Task<int> updateAllArchive(int numDayPre, bool forceTag)
|
||||
{
|
||||
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);
|
||||
checkDone += await updateMachineArchive(item.IdxMacchina, numDayPre, forceTag, false);
|
||||
}
|
||||
|
||||
return await Task.FromResult(checkDone);
|
||||
@@ -309,13 +309,15 @@ namespace MP.Prog.Data
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina">Codice macchina</param>
|
||||
/// <param name="numDayPre">Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite</param>
|
||||
/// <param name="forceTag">Forza la riverifica dei tags (x update da setup)</param>
|
||||
/// <param name="fullLog">Scrittura log verboso macchina</param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> updateMachineArchive(string idxMacchina, int numDayPre, bool fullLog)
|
||||
public async Task<int> updateMachineArchive(string idxMacchina, int numDayPre, bool forceTag, bool fullLog)
|
||||
{
|
||||
int checkDone = 0;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string ruleName = "Rule01.json";
|
||||
string ruleName = "Rule00.json";
|
||||
try
|
||||
{
|
||||
var macchina = MacchinaGetByKey(idxMacchina).Result;
|
||||
@@ -370,7 +372,7 @@ namespace MP.Prog.Data
|
||||
Log.Info($"Conf rule generato:{Environment.NewLine}{rawRule}");
|
||||
}
|
||||
}
|
||||
checkDone = dbController.CheckFileArchived(macchina.IdxMacchina, macchina.BasePath, numDayPre, "*.*", currRule);
|
||||
checkDone = dbController.CheckFileArchived(macchina.IdxMacchina, macchina.BasePath, numDayPre, "*.*", forceTag, currRule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace MP.Prog.Pages
|
||||
// importante altrimenti NON mostra update UI
|
||||
await Task.Delay(1);
|
||||
//AppMService.File_Filter = SelectData.Init(5, 10);
|
||||
var numCheck = await DataService.updateAllArchive(numDays);
|
||||
var numCheck = await DataService.updateAllArchive(numDays, false);
|
||||
await ReloadAllData();
|
||||
await Task.Delay(1);
|
||||
await RefreshDisplayLoading();
|
||||
|
||||
Reference in New Issue
Block a user