update x step gestione conf serializzata json
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MP.FileData.DatabaseModels;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP.FileData.Controllers
|
||||
{
|
||||
@@ -112,6 +113,9 @@ namespace MP.FileData.Controllers
|
||||
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()
|
||||
{
|
||||
@@ -119,13 +123,19 @@ namespace MP.FileData.Controllers
|
||||
Mode = SearchMode.StringOnFile,
|
||||
MaxChar2Search = 100,
|
||||
ReplaceCR = true,
|
||||
RegExPattern = "\\b{{fileName}}" + @".{0,2}\([\w\d\s.]+\)",
|
||||
RegExPattern = "\\b{{fileName}}" + @".{0,2}\([\w\d\s./]+\)",
|
||||
RegExRepFileName = true,
|
||||
ExcludedTags = ".xls .xlsx",
|
||||
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)
|
||||
{
|
||||
@@ -284,7 +294,6 @@ namespace MP.FileData.Controllers
|
||||
}).ToList();
|
||||
|
||||
// gestione Tags (da migliorare...)
|
||||
List<string> excludeTags = new List<string>() { "M4", "M5", "M4+A", "M4+B", "M5+A", "M5+B" };
|
||||
List<TagModel> currTags = TagGetAll();
|
||||
|
||||
// calcolo MD5 e tags
|
||||
@@ -295,18 +304,17 @@ namespace MP.FileData.Controllers
|
||||
|
||||
List<string> Tags = new List<string>();
|
||||
List<TagModel> Tag4File = new List<TagModel>();
|
||||
// cerco codice tag come nome file(TAG) nei primi 100 char
|
||||
int maxChar = 100;
|
||||
string code2search = "";
|
||||
if (item.FileStringContent.Length > maxChar)
|
||||
// se necessario bonifico filename...
|
||||
string fileName = item.Name;
|
||||
if (currRule.FileNameExtReplace.Count > 0)
|
||||
{
|
||||
code2search = item.FileStringContent.Substring(0, maxChar);
|
||||
foreach (var fReplace in currRule.FileNameExtReplace)
|
||||
{
|
||||
fileName = fileName.Replace(fReplace.Key, fReplace.Value).Trim();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
code2search = item.FileStringContent;
|
||||
}
|
||||
Tags = TagsUtils.searchProgComment(item.Name, code2search, currRule);
|
||||
// cerco codice tag da configurazione
|
||||
Tags = TagsUtils.searchProgComment(fileName, item.FileStringContent, currRule);
|
||||
|
||||
foreach (var tag in Tags)
|
||||
{
|
||||
@@ -366,6 +374,10 @@ namespace MP.FileData.Controllers
|
||||
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()
|
||||
{
|
||||
@@ -375,7 +387,8 @@ namespace MP.FileData.Controllers
|
||||
ReplaceCR = true,
|
||||
RegExPattern = "\\b{{fileName}}" + @".{0,2}\([\w\d\s.]+\)",
|
||||
RegExRepFileName = true,
|
||||
ExcludedTags = ".xls .xlsx",
|
||||
ExcludedTags = new List<string>() { "M4", "M5", "M4+A", "M4+B", "M5+A", "M5+B" },
|
||||
FileNameExtReplace = fileExtReplace,
|
||||
OutReplace = confReplace,
|
||||
OutExcludeFileName = true
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user