diff --git a/MP.FileData/Controllers/FileController.cs b/MP.FileData/Controllers/FileController.cs
index 8e09165d..9f3e2050 100644
--- a/MP.FileData/Controllers/FileController.cs
+++ b/MP.FileData/Controllers/FileController.cs
@@ -49,7 +49,7 @@ namespace MP.FileData.Controllers
/// Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite
/// pattern di ricerca (*.*)
/// Forza il controllo dei Tags
- /// Regole di ricerca applicate
+ /// Regole di ricerca applicate
///
public int CheckFileArchived(string idxMacchina, string path, int numDayPre, string searchPattern, bool forceTag, SearchRules currRule)
{
@@ -358,6 +358,10 @@ namespace MP.FileData.Controllers
{
Tags = TagsUtils.searchProgComment(fileName, item.FileStringContent, currRule);
}
+ else if (currRule.Mode == SearchMode.TagListed)
+ {
+ Tags = TagsUtils.searchTagListed(fileName, item.FileStringContent, currRule);
+ }
else
{
Tags = TagsUtils.searchPathName(item.Path, basePath, currRule);
@@ -389,8 +393,8 @@ namespace MP.FileData.Controllers
// aggiungo in blocco
localDbCtx
- .DbSetProgFile
- .AddRange(newRec);
+ .DbSetProgFile
+ .AddRange(newRec);
Log.Trace($"FileInsert S02 per macchina {idxMacchina}: {newRec.Count} files da aggiungere EFCore");
@@ -519,6 +523,10 @@ namespace MP.FileData.Controllers
{
Tags = TagsUtils.searchProgComment(fileName, item.FileStringContent, currRule);
}
+ else if (currRule.Mode == SearchMode.TagListed)
+ {
+ Tags = TagsUtils.searchTagListed(fileName, item.FileStringContent, currRule);
+ }
else
{
Tags = TagsUtils.searchPathName(item.Path, basePath, currRule);
diff --git a/MP.FileData/SearchRules.cs b/MP.FileData/SearchRules.cs
index bcf3c818..0f8ee9e3 100644
--- a/MP.FileData/SearchRules.cs
+++ b/MP.FileData/SearchRules.cs
@@ -16,7 +16,12 @@ namespace MP.FileData
///
/// Cerca da path relativo + nome file
///
- PathAndName
+ PathAndName,
+
+ ///
+ /// Ricerca di espliciti TAG nel file
+ ///
+ TagListed
}
public class SearchRules
@@ -78,6 +83,16 @@ namespace MP.FileData
///
public bool ReplaceCR { get; set; } = true;
+
+ ///
+ /// Tag da collezionare, come elenco di stringhe
+ /// es: {"Customer", "Model"}
+ /// selezionerà
+ /// Customer=Steamware
+ /// MODEL=DEMO_SIMULATOR
+ ///
+ public List Tag2Collect { get; set; } = new List();
+
#endregion Public Properties
}
}
\ No newline at end of file
diff --git a/MP.FileData/TagsUtils.cs b/MP.FileData/TagsUtils.cs
index ec9f5817..b8c392c7 100644
--- a/MP.FileData/TagsUtils.cs
+++ b/MP.FileData/TagsUtils.cs
@@ -29,7 +29,7 @@ namespace MP.FileData
#region Public Methods
///
- /// Cerca tag a aprtire da directory + nome file, ignorando delle stopword
+ /// Cerca tag a partire da directory + nome file, ignorando delle stopword
///
/// es: ...\BUSSOLE.WPD\172L_EST8.MPF --> "BUSSOLE", "172L_EST8"
///
@@ -153,6 +153,52 @@ namespace MP.FileData
return answ;
}
+ ///
+ /// Cerca tag di commento dalla lista esplicita Tag2Collect
+ /// tag=VALORE
+ ///
+ /// es: HostAddr=10.74.82.76 --> estrae HostAddr=10.74.82.76
+ ///
+ /// Nome del file (da cercare per contenuto)
+ /// Contenuto del file da analizzare
+ /// Parametri analisi
+ ///
+ public static List searchTagListed(string fileName, string fileContent, SearchRules currRule)
+ {
+ // verifico se trimmare contenuto file
+ if (fileContent.Length > currRule.MaxChar2Search && currRule.MaxChar2Search > 0)
+ {
+ fileContent = fileContent.Substring(0, currRule.MaxChar2Search);
+ }
+ //verifico i tag siano indicati
+ List answ = new List();
+ if (currRule.Tag2Collect.Count > 0)
+ {
+ if (fileContent.Length > 0)
+ {
+ // splitto tutte le righe...
+ var fileRows = fileContent.Split(Environment.NewLine);
+ foreach (var tag2check in currRule.Tag2Collect)
+ {
+ foreach (var row in fileRows)
+ {
+ if (row.StartsWith(tag2check))
+ {
+ answ.Add(row.Trim());
+ break;
+ }
+ }
+ }
+ }
+ }
+ // se nullo --> segnalo!
+ if (answ.Count == 0)
+ {
+ Log.Warn($"searchProgComment Attenzione Tag non trovati | {fileName} | num tags: : {currRule.Tag2Collect.Count}{Environment.NewLine}{fileContent}");
+ }
+ return answ;
+ }
+
#endregion Public Methods
}
}
\ No newline at end of file