Eliminaizone articolo da struttura DB
This commit is contained in:
@@ -34,44 +34,6 @@ namespace MP.FileData.Controllers
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli (FILTRATO!!!)
|
||||
/// </summary>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <param name="maxNum"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.ArticoloModel> ArtGetFilt(string searchVal, int maxNum = 100)
|
||||
{
|
||||
maxNum = maxNum <= 0 ? 100 : maxNum;
|
||||
List<DatabaseModels.ArticoloModel> dbResult = new List<DatabaseModels.ArticoloModel>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
int totRecord = localDbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal))
|
||||
.Count();
|
||||
if (totRecord > maxNum)
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal))
|
||||
.OrderBy(x => x.DescArticolo)
|
||||
.Take(maxNum)
|
||||
.ToList();
|
||||
dbResult.Add(new DatabaseModels.ArticoloModel() { CodArticolo = "#####", DescArticolo = $"... +{totRecord - maxNum} rec ..." });
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal))
|
||||
.OrderBy(x => x.DescArticolo)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua la comparazione tra i file in archivio ed i file attuali e segna info LastCheck e Changed (se cambiati)
|
||||
/// </summary>
|
||||
@@ -176,7 +138,7 @@ namespace MP.FileData.Controllers
|
||||
// se ce ne fosse un altro precedente --> lo (ri)attiva
|
||||
var file2open = localDbCtx
|
||||
.DbSetProgFile
|
||||
.Where(x => x.Articolo == currItem.Articolo && x.IdxMacchina == currItem.IdxMacchina)
|
||||
.Where(x => x.Name == currItem.Name && x.IdxMacchina == currItem.IdxMacchina)
|
||||
.OrderByDescending(y => y.Rev)
|
||||
.FirstOrDefault();
|
||||
if (file2open != null)
|
||||
@@ -242,7 +204,7 @@ namespace MP.FileData.Controllers
|
||||
dbResult = localDbCtx
|
||||
.DbSetProgFile
|
||||
.Include(m => m.Macchina)
|
||||
.Include(a => a.Articolo)
|
||||
.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)
|
||||
.ToList();
|
||||
@@ -270,7 +232,6 @@ namespace MP.FileData.Controllers
|
||||
List<DatabaseModels.FileModel> newRec = newFiles.Select(o => new DatabaseModels.FileModel()
|
||||
{
|
||||
Active = true,
|
||||
CodArticolo = "ND",
|
||||
DiskStatus = FileState.Ok,
|
||||
IdxMacchina = idxMacchina,
|
||||
LastCheck = adesso,
|
||||
@@ -444,6 +405,91 @@ namespace MP.FileData.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <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);
|
||||
Log.Info("Effettuato reset FileController");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Annulla modifiche su una specifica entity (cancel update)
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public bool RollBackEntity(object item)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
if (dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Deleted || dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Modified)
|
||||
{
|
||||
dbCtx.Entry(item).Reload();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco TAGS (FILTRATO!!!)
|
||||
/// </summary>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <param name="maxNum"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.TagModel> TagGetFilt(string searchVal, int maxNum = 100)
|
||||
{
|
||||
maxNum = maxNum <= 0 ? 100 : maxNum;
|
||||
List<DatabaseModels.TagModel> dbResult = new List<DatabaseModels.TagModel>();
|
||||
using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration))
|
||||
{
|
||||
int totRecord = localDbCtx
|
||||
.DbSetTags
|
||||
.Where(x => x.TagId.Contains(searchVal))
|
||||
.Count();
|
||||
if (totRecord > maxNum)
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetTags
|
||||
.Where(x => x.TagId.Contains(searchVal))
|
||||
.OrderBy(x => x.TagId)
|
||||
.Take(maxNum)
|
||||
.ToList();
|
||||
dbResult.Add(new DatabaseModels.TagModel() { TagId = $"... +{totRecord - maxNum} rec ..." });
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetTags
|
||||
.Where(x => x.TagId.Contains(searchVal))
|
||||
.OrderBy(x => x.TagId)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco Azioni (decodifica)
|
||||
@@ -500,54 +546,6 @@ namespace MP.FileData.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <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);
|
||||
Log.Info("Effettuato reset FileController");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Annulla modifiche su una specifica entity (cancel update)
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public bool RollBackEntity(object item)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
if (dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Deleted || dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Modified)
|
||||
{
|
||||
dbCtx.Entry(item).Reload();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco tabella controlli da filtro
|
||||
|
||||
Reference in New Issue
Block a user