loading data
diff --git a/MP.Prog/Data/FileArchDataService.cs b/MP.Prog/Data/FileArchDataService.cs
index a4d32bcb..5335a42e 100644
--- a/MP.Prog/Data/FileArchDataService.cs
+++ b/MP.Prog/Data/FileArchDataService.cs
@@ -12,6 +12,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
+using MP.FileData.Controllers;
+using MP.FileData.DTO;
namespace MP.Prog.Data
{
@@ -104,15 +106,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,23 +217,53 @@ 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.NumSkip, CurrFilter.PageSize, CurrFilter.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");
return await Task.FromResult(dbResult);
}
+ public async Task> GetArchiveStatus()
+ {
+ List dbResult = new List();
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = dbController.GetArchiveStatus();
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Info($"Effettuata lettura da DB + caching per GetArchiveStatus: {ts.TotalMilliseconds} ms");
+ return await Task.FromResult(dbResult);
+ }
+
+ public Task MacchinaGetByKey(string idxMacchina)
+ {
+ return Task.FromResult(dbController.MacchinaGetByKey(idxMacchina));
+ }
+
public Task> MacchineGetAll()
{
return Task.FromResult(dbController.MacchineGetAll().ToList());
@@ -269,72 +292,97 @@ namespace MP.Prog.Data
///
/// Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite
///
- public async Task updateAllArchive(int numDayPre)
+ public async Task updateAllArchive(int numDayPre)
{
- bool done = false;
+ 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);
+ }
+
+ return await Task.FromResult(checkDone);
+ }
+
+ ///
+ /// Aggiorna archivio di una amcchina scansionando path relativo
+ ///
+ /// Codice macchina
+ /// Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite
+ ///
+ public async Task updateMachineArchive(string idxMacchina, int numDayPre, bool fullLog)
+ {
+ int checkDone = 0;
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
string ruleName = "Rule01.json";
try
{
- var listaMacchine = await MacchineGetAll();
- foreach (var item in listaMacchine.Where(x => !string.IsNullOrEmpty(x.BasePath)).ToList())
+ var macchina = MacchinaGetByKey(idxMacchina).Result;
+ if (macchina != null && !string.IsNullOrEmpty(macchina.BasePath))
{
- if (!string.IsNullOrEmpty(item.RuleName))
- { }
- // gestione confRule...
- SearchRules currRule = new SearchRules();
- try
+ if (!string.IsNullOrEmpty(macchina.RuleName))
{
- 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 = macchina.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
+ };
+ if (fullLog)
+ {
+ // serializzo
+ string rawRule = JsonConvert.SerializeObject(currRule, Formatting.Indented);
+ Log.Info($"Conf rule generato:{Environment.NewLine}{rawRule}");
+ }
+ }
+ checkDone = dbController.CheckFileArchived(macchina.IdxMacchina, macchina.BasePath, numDayPre, "*.*", currRule);
}
-
- done = dbController.CheckFileArchived(item.IdxMacchina, item.BasePath, numDayPre, "*.*", currRule);
}
}
catch (Exception exc)
{
- Log.Error($"Eccezione in updateAllArchive{Environment.NewLine}{exc}{Environment.NewLine}{exc.InnerException}");
+ Log.Error($"Eccezione in updateMachineArchive{Environment.NewLine}{exc}{Environment.NewLine}{exc.InnerException}");
}
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Info($"Effettuato update archivio file MACCHINA | last {numDayPre} days | {checkDone} checked | {ts.TotalMilliseconds} ms");
- return await Task.FromResult(done);
+ return await Task.FromResult(checkDone);
}
#endregion Public Methods
diff --git a/MP.Prog/Data/SelectData.cs b/MP.Prog/Data/SelectData.cs
index c8e92923..f1b36f0e 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);
@@ -27,11 +26,24 @@ namespace MP.Prog.Data
}
public string IdxMacchina { get; set; } = "";
+
+ ///
+ /// Recorda da saltare x arrivare alla pagina corrente
+ ///
+ public int NumSkip
+ {
+ get
+ {
+ return PageSize * (PageNum - 1);
+ }
+ }
+
public bool OnlyActive { get; set; } = true;
public bool OnlyMod { get; set; } = false;
public int PageNum { get; set; } = 1;
public int PageSize { get; set; } = 10;
+ public string SearchVal { get; set; } = "";
#endregion Public Properties
@@ -69,7 +81,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 cbe96c1c..16edd386 100644
--- a/MP.Prog/Pages/Archive.razor
+++ b/MP.Prog/Pages/Archive.razor
@@ -5,46 +5,28 @@