Completato fix setup page + cache redis

This commit is contained in:
Samuele Locatelli
2024-10-21 12:05:23 +02:00
parent ea2f942f94
commit 60f983df9b
17 changed files with 264 additions and 107 deletions
+86 -48
View File
@@ -15,14 +15,6 @@ namespace MP.FileData.Controllers
{
public class FileController : IDisposable
{
#region Private Fields
private static IConfiguration _configuration;
private static MoonPro_ProgContext dbCtx;
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Public Constructors
public FileController(IConfiguration configuration)
@@ -42,11 +34,83 @@ namespace MP.FileData.Controllers
}
/// <summary>
/// Effettua la comparazione tra i file in archivio ed i file attuali e segna info LastCheck e Changed (se cambiati)
/// Elenco tabella Macchine
/// </summary>
/// <returns></returns>
public List<DatabaseModels.ArchMaccModel> ArchMaccGetAll()
{
List<DatabaseModels.ArchMaccModel> dbResult = new List<DatabaseModels.ArchMaccModel>();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
dbResult = localDbCtx
.DbSetArchMacc
.OrderBy(x => x.IdxMacchina)
.ToList();
}
return dbResult;
}
/// <summary>
/// Recupera singola macchina
/// </summary>
/// <returns></returns>
public ArchMaccModel ArchMaccGetByKey(string idxMacchina)
{
ArchMaccModel dbResult = new ArchMaccModel();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
dbResult = localDbCtx
.DbSetArchMacc
.Where(x => x.IdxMacchina == idxMacchina)
.SingleOrDefault();
}
return dbResult;
}
/// <summary>
/// Elenco tabella Macchine
/// </summary>
/// <returns></returns>
public async Task<bool> ArchMaccUpsert(ArchMaccModel upsRec)
{
bool fatto = false;
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
var currRec = localDbCtx
.DbSetArchMacc
.Where(x => x.IdxMacchina == upsRec.IdxMacchina)
.FirstOrDefault();
if (currRec != null)
{
currRec.BasePath = upsRec.BasePath;
currRec.Descrizione = upsRec.Descrizione;
currRec.RuleName = upsRec.RuleName;
currRec.ShowOrder = upsRec.ShowOrder;
currRec.ImgUrl = upsRec.ImgUrl;
currRec.Nome = upsRec.Nome;
currRec.Note = upsRec.Note;
// segno modificato
localDbCtx.Entry(currRec).State = EntityState.Modified;
}
else
{
localDbCtx.DbSetArchMacc.Add(upsRec);
}
int numDone = await localDbCtx.SaveChangesAsync();
fatto = numDone != 0;
}
return fatto;
}
/// <summary>
/// Effettua la comparazione tra i file in archivio ed i file attuali e segna info LastCheck
/// e Changed (se cambiati)
/// </summary>
/// <param name="idxMacchina">cod macchina</param>
/// <param name="path">path ricerca x macchina</param>
/// <param name="numDayPre">Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite</param>
/// <param name="numDayPre">
/// Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite
/// </param>
/// <param name="searchPattern">pattern di ricerca (*.*)</param>
/// <param name="forceTag">Forza il controllo dei Tags</param>
/// <param name="currRule">Regole di ricerca applicate</param>
@@ -428,7 +492,7 @@ namespace MP.FileData.Controllers
listUpdate.Add(newFileInfo);
var currMacchina = localDbCtx
.DbSetMacchine
.DbSetArchMacc
.Where(x => x.IdxMacchina == currFile.IdxMacchina)
.SingleOrDefault();
if (currMacchina != null)
@@ -505,7 +569,7 @@ namespace MP.FileData.Controllers
if (forceTag)
{
// elenco Tags
List <TagModel> currTags = localDbCtx.DbSetTags.ToList();
List<TagModel> currTags = localDbCtx.DbSetTags.ToList();
FileModel currItem = null;
foreach (var item in updFiles)
{
@@ -586,7 +650,7 @@ namespace MP.FileData.Controllers
// salvo update file
item.LastCheck = adesso;
localDbCtx.Entry(item).State = EntityState.Modified;
}
}
#endif
answ = true;
@@ -673,7 +737,7 @@ namespace MP.FileData.Controllers
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
ArchiveList = localDbCtx
.DbSetMacchine
.DbSetArchMacc
.Select(x => new ArchiveStatusDTO()
{
IdxMacchina = x.IdxMacchina,
@@ -709,40 +773,6 @@ namespace MP.FileData.Controllers
return ArchiveList;
}
/// <summary>
/// Recupera singola macchina
/// </summary>
/// <returns></returns>
public MacchinaModel MacchinaGetByKey(string idxMacchina)
{
MacchinaModel dbResult = new MacchinaModel();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
dbResult = localDbCtx
.DbSetMacchine
.Where(x => x.IdxMacchina == idxMacchina)
.SingleOrDefault();
}
return dbResult;
}
/// <summary>
/// Elenco tabella Macchine
/// </summary>
/// <returns></returns>
public List<DatabaseModels.MacchinaModel> MacchineGetAll()
{
List<DatabaseModels.MacchinaModel> dbResult = new List<DatabaseModels.MacchinaModel>();
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
{
dbResult = localDbCtx
.DbSetMacchine
.OrderBy(x => x.IdxMacchina)
.ToList();
}
return dbResult;
}
public void ResetController()
{
dbCtx = new MoonPro_ProgContext(_configuration);
@@ -871,6 +901,14 @@ namespace MP.FileData.Controllers
#endregion Public Methods
#region Private Fields
private static IConfiguration _configuration;
private static MoonPro_ProgContext dbCtx;
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#if false
/// <summary>
/// Elenco Azioni (decodifica)
@@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace MP.FileData.DatabaseModels
{
[Table("Macchine")]
public partial class MacchinaModel
public partial class ArchMaccModel
{
#region Public Properties
+1 -1
View File
@@ -53,7 +53,7 @@ namespace MP.FileData.DatabaseModels
}
[ForeignKey("IdxMacchina")]
public virtual MacchinaModel Macchina { get; set; }
public virtual ArchMaccModel Macchina { get; set; }
#endregion Public Properties
}
+2 -2
View File
@@ -19,8 +19,8 @@ namespace MP.FileData
public static void Seed(this ModelBuilder modelBuilder)
{
// inizializzazione dei valori di default x MACCHINA
modelBuilder.Entity<MacchinaModel>().HasData(
new MacchinaModel { IdxMacchina = "0", RuleName = "0", Descrizione = "--- Tutte ---", Nome = "--- Tutte ---", BasePath = "", ImgUrl = "", Note = "", ShowOrder = 0 }
modelBuilder.Entity<ArchMaccModel>().HasData(
new ArchMaccModel { IdxMacchina = "0", RuleName = "0", Descrizione = "--- Tutte ---", Nome = "--- Tutte ---", BasePath = "", ImgUrl = "", Note = "", ShowOrder = 0 }
);
}
+1 -1
View File
@@ -59,7 +59,7 @@ namespace MP.FileData
#region Public Properties
public virtual DbSet<MacchinaModel> DbSetMacchine { get; set; }
public virtual DbSet<ArchMaccModel> DbSetArchMacc { get; set; }
public virtual DbSet<FileModel> DbSetProgFile { get; set; }
public virtual DbSet<TagModel> DbSetTags { get; set; }