udpate paginazione dati solo decina apgine correnti

This commit is contained in:
Samuele Locatelli
2021-09-13 18:05:43 +02:00
parent 48ee4dcdae
commit 6940a68c0c
5 changed files with 184 additions and 132 deletions
+60 -34
View File
@@ -35,6 +35,11 @@ namespace MP.FileData.Controllers
#region Public Methods
public static string rulePath(string ruleName)
{
return string.Format($"Conf/{ruleName}");
}
/// <summary>
/// Effettua la comparazione tra i file in archivio ed i file attuali e segna info LastCheck e Changed (se cambiati)
/// </summary>
@@ -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;
}
/// <summary>
/// ELiminazione file da tabella
/// </summary>
@@ -232,7 +250,7 @@ namespace MP.FileData.Controllers
return dbResult;
}
public List<DatabaseModels.FileModel> FileGetFilt(string IdxMacchina, string CodArticolo, bool OnlyActive, bool OnlyMod, string SearchVal = "")
public List<DatabaseModels.FileModel> FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, int numStart, int numRecords, string SearchVal = "")
{
List<DatabaseModels.FileModel> dbResult = new List<DatabaseModels.FileModel>();
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<FileInfo> listUpdate = new List<FileInfo>();
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<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()
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<string>() { "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<SearchRules>(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
}
/// <summary>
/// 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)
/// </summary>
/// <param name="updFiles"></param>
/// <returns></returns>
@@ -470,7 +491,7 @@ namespace MP.FileData.Controllers
}
/// <summary>
/// Aggiorna un record FILE
/// Aggiorna un record FILE rileggendo e ricalcolando...
/// </summary>
/// <param name="updItem"></param>
/// <returns></returns>
@@ -481,11 +502,16 @@ namespace MP.FileData.Controllers
{
try
{
// elenco Tags
List<TagModel> 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;