diff --git a/MP.FileData/Controllers/FileController.cs b/MP.FileData/Controllers/FileController.cs
index 0fa8db6d..16835ae9 100644
--- a/MP.FileData/Controllers/FileController.cs
+++ b/MP.FileData/Controllers/FileController.cs
@@ -35,6 +35,11 @@ namespace MP.FileData.Controllers
#region Public Methods
+ public static string rulePath(string ruleName)
+ {
+ return string.Format($"Conf/{ruleName}");
+ }
+
///
/// Effettua la comparazione tra i file in archivio ed i file attuali e segna info LastCheck e Changed (se cambiati)
///
@@ -152,6 +157,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;
+ }
+
///
/// ELiminazione file da tabella
///
@@ -232,7 +250,7 @@ namespace MP.FileData.Controllers
return dbResult;
}
- public List FileGetFilt(string IdxMacchina, string CodArticolo, bool OnlyActive, bool OnlyMod, string SearchVal = "")
+ public List FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, int numStart, int numRecords, string SearchVal = "")
{
List dbResult = new List();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
@@ -243,6 +261,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;
@@ -348,6 +368,8 @@ namespace MP.FileData.Controllers
public bool FileModApprove(FileModel currFile)
{
bool done = false;
+ // recupero file regole json da macchina..
+
List listUpdate = new List();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
@@ -355,40 +377,39 @@ namespace MP.FileData.Controllers
var newFileInfo = new FileInfo(currFile.Path);
listUpdate.Add(newFileInfo);
- // fixme todo !!! fix da conf file
- Dictionary confReplace = new Dictionary();
- confReplace.Add("(", " ");
- confReplace.Add(")", " ");
-
- Dictionary fileExtReplace = new Dictionary();
- 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() { "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(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;
}
@@ -443,7 +464,7 @@ namespace MP.FileData.Controllers
}
///
- /// Effettua update di un record in archivio da lista (solo status, da
+ /// Effettua update di un record in archivio da lista (solo status, da approvare)
///
///
///
@@ -470,7 +491,7 @@ namespace MP.FileData.Controllers
}
///
- /// Aggiorna un record FILE
+ /// Aggiorna un record FILE rileggendo e ricalcolando...
///
///
///
@@ -481,11 +502,16 @@ namespace MP.FileData.Controllers
{
try
{
+ // elenco Tags
+ List 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;
diff --git a/MP.Prog/Data/FileArchDataService.cs b/MP.Prog/Data/FileArchDataService.cs
index fde4e15f..c7248b9a 100644
--- a/MP.Prog/Data/FileArchDataService.cs
+++ b/MP.Prog/Data/FileArchDataService.cs
@@ -12,6 +12,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
+using MP.FileData.Controllers;
namespace MP.Prog.Data
{
@@ -104,15 +105,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,17 +216,29 @@ namespace MP.Prog.Data
dbController.Dispose();
}
+ public async Task 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 FileGetByKey(int FileId)
{
return Task.FromResult(dbController.FileGetByKey(FileId));
}
- public async Task> FileGetFilt(string IdxMacchina, string CodArticolo, bool OnlyActive, bool OnlyMod, string SearchVal)
+ public async Task> FileGetFilt(SelectData CurrFilter)
{
List dbResult = new List();
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.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");
@@ -281,54 +285,56 @@ namespace MP.Prog.Data
foreach (var item in listaMacchine.Where(x => !string.IsNullOrEmpty(x.BasePath)).ToList())
{
if (!string.IsNullOrEmpty(item.RuleName))
- { }
- // gestione confRule...
- SearchRules currRule = new SearchRules();
- try
{
- string rawData = File.ReadAllText(rulePath(ruleName));
- currRule = JsonConvert.DeserializeObject(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 confReplace = new Dictionary();
- confReplace.Add("(", " ");
- confReplace.Add(")", " ");
-
- Dictionary fileExtReplace = new Dictionary();
- fileExtReplace.Add(".P-2", "");
- // hard coded + salvataggio conf x creare json
- currRule = new SearchRules()
+ ruleName = item.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() { "M4", "M5", "M4+A", "M4+B", "M5+A", "M5+B" },
- OutReplace = confReplace,
- OutExcludeFileName = true
- };
+ string rawData = File.ReadAllText(FileController.rulePath(ruleName));
+ currRule = JsonConvert.DeserializeObject(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 confReplace = new Dictionary();
+ confReplace.Add("(", " ");
+ confReplace.Add(")", " ");
+
+ Dictionary fileExtReplace = new Dictionary();
+ 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() { "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 generato:{Environment.NewLine}{rawRule}");
+ }
+
+ checkDone += dbController.CheckFileArchived(item.IdxMacchina, item.BasePath, numDayPre, "*.*", currRule);
}
-
- checkDone += dbController.CheckFileArchived(item.IdxMacchina, item.BasePath, numDayPre, "*.*", currRule);
}
}
catch (Exception exc)
diff --git a/MP.Prog/Data/SelectData.cs b/MP.Prog/Data/SelectData.cs
index c8e92923..01db4a56 100644
--- a/MP.Prog/Data/SelectData.cs
+++ b/MP.Prog/Data/SelectData.cs
@@ -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);
@@ -32,6 +31,7 @@ namespace MP.Prog.Data
public int PageNum { get; set; } = 1;
public int PageSize { get; set; } = 10;
+ public string SearchVal { get; set; } = "";
#endregion Public Properties
@@ -69,7 +69,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;
diff --git a/MP.Prog/Pages/Archive.razor b/MP.Prog/Pages/Archive.razor
index 72067d12..16edd386 100644
--- a/MP.Prog/Pages/Archive.razor
+++ b/MP.Prog/Pages/Archive.razor
@@ -5,46 +5,28 @@