OK decode biglia 445 (tranne nomi file sbagliati) + fix 446 tags
This commit is contained in:
@@ -43,12 +43,13 @@ namespace MP.FileData.Controllers
|
||||
/// <param name="searchPattern">pattern di ricerca (*.*)</param>
|
||||
/// <param name="excludePattern">pattern esclusione (separato da spazi</param>
|
||||
/// <returns></returns>
|
||||
public bool CheckFileArchived(string idxMacchina, string path, string searchPattern, string excludePattern)
|
||||
public bool CheckFileArchived(string idxMacchina, string path, string searchPattern, SearchRules currRule)
|
||||
{
|
||||
Log.Info($"CheckFileArchived S01 | macchina: {idxMacchina} | path: {path} | pattern: {searchPattern} | excludePattern: {excludePattern}");
|
||||
Log.Info($"CheckFileArchived S00 | macchina: {idxMacchina} | path: {path} | pattern: {searchPattern} | # ExcludedFileExt: {currRule.ExcludedFileExt.Count()}");
|
||||
bool answ = false;
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(path);
|
||||
FileInfo[] fileList = dirInfo.GetFiles(searchPattern);
|
||||
Log.Info($"CheckFileArchived S01 | file trovati: {fileList.Count()}");
|
||||
List<FileInfo> fileNew = new List<FileInfo>();
|
||||
List<FileModel> fileChecked = new List<FileModel>();
|
||||
List<FileModel> fileMod = new List<FileModel>();
|
||||
@@ -62,7 +63,7 @@ namespace MP.FileData.Controllers
|
||||
foreach (var file in fileList)
|
||||
{
|
||||
// escludo i file con desinenza da escludere...
|
||||
if (excludePattern.Contains(file.Extension) && !string.IsNullOrEmpty(file.Extension))
|
||||
if (!string.IsNullOrEmpty(file.Extension) && currRule.ExcludedFileExt.Contains(file.Extension))
|
||||
{
|
||||
Log.Info($"CheckFileArchived S02: escluso {file.Name} | estensione {file.Extension}");
|
||||
}
|
||||
@@ -105,37 +106,6 @@ namespace MP.FileData.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
// fixme todo !!! fix da conf file
|
||||
|
||||
// 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
|
||||
SearchRules 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
|
||||
};
|
||||
|
||||
// serializzo
|
||||
|
||||
string rawRule = JsonConvert.SerializeObject(currRule, Formatting.Indented);
|
||||
Log.Info($"Conf rule:{Environment.NewLine}{rawRule}");
|
||||
|
||||
// salvo i NUOVI file
|
||||
if (fileNew != null && fileNew.Count > 0)
|
||||
{
|
||||
@@ -294,7 +264,8 @@ namespace MP.FileData.Controllers
|
||||
}).ToList();
|
||||
|
||||
// gestione Tags (da migliorare...)
|
||||
List<TagModel> currTags = TagGetAll();
|
||||
List<TagModel> currTags = localDbCtx.DbSetTags.ToList();
|
||||
//List<TagModel> currTags = TagGetAll();
|
||||
|
||||
// calcolo MD5 e tags
|
||||
foreach (var item in newRec)
|
||||
@@ -318,7 +289,7 @@ namespace MP.FileData.Controllers
|
||||
|
||||
foreach (var tag in Tags)
|
||||
{
|
||||
var foundTag = currTags.Where(x => x.TagId == tag).FirstOrDefault();
|
||||
var foundTag = currTags.SingleOrDefault(x => x.TagId == tag);
|
||||
// aggiungo i tags SE non ci fossero
|
||||
if (foundTag == null)
|
||||
{
|
||||
@@ -340,9 +311,9 @@ namespace MP.FileData.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
localDbCtx
|
||||
.DbSetTags
|
||||
.AddRange(currTags);
|
||||
//localDbCtx
|
||||
//.DbSetTags
|
||||
//.AddRange(newTags);
|
||||
|
||||
// aggiungo in blocco
|
||||
localDbCtx
|
||||
|
||||
Reference in New Issue
Block a user