diff --git a/MP.FileData/Controllers/FileController.cs b/MP.FileData/Controllers/FileController.cs
index 84b7a312..ac190761 100644
--- a/MP.FileData/Controllers/FileController.cs
+++ b/MP.FileData/Controllers/FileController.cs
@@ -34,44 +34,6 @@ namespace MP.FileData.Controllers
#region Public Methods
- ///
- /// Elenco tabella Articoli (FILTRATO!!!)
- ///
- ///
- ///
- ///
- public List ArtGetFilt(string searchVal, int maxNum = 100)
- {
- maxNum = maxNum <= 0 ? 100 : maxNum;
- List dbResult = new List();
- 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;
- }
-
///
/// Effettua la comparazione tra i file in archivio ed i file attuali e segna info LastCheck e Changed (se cambiati)
///
@@ -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 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;
}
+ ///
+ /// Elenco tabella Macchine
+ ///
+ ///
+ public List MacchineGetAll()
+ {
+ List dbResult = new List();
+ 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");
+ }
+
+ ///
+ /// Annulla modifiche su una specifica entity (cancel update)
+ ///
+ ///
+ ///
+ 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;
+ }
+
+ ///
+ /// Elenco TAGS (FILTRATO!!!)
+ ///
+ ///
+ ///
+ ///
+ public List TagGetFilt(string searchVal, int maxNum = 100)
+ {
+ maxNum = maxNum <= 0 ? 100 : maxNum;
+ List dbResult = new List();
+ 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
///
/// Elenco Azioni (decodifica)
@@ -500,54 +546,6 @@ namespace MP.FileData.Controllers
return dbResult;
}
#endif
-
- ///
- /// Elenco tabella Macchine
- ///
- ///
- public List MacchineGetAll()
- {
- List dbResult = new List();
- 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");
- }
-
- ///
- /// Annulla modifiche su una specifica entity (cancel update)
- ///
- ///
- ///
- 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
///
/// Elenco tabella controlli da filtro
diff --git a/MP.FileData/DatabaseModels/ArticoloModel.cs b/MP.FileData/DatabaseModels/ArticoloModel.cs
deleted file mode 100644
index c1e6e739..00000000
--- a/MP.FileData/DatabaseModels/ArticoloModel.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-//
-// This is here so CodeMaid doesn't reorganize this document
-//
-namespace MP.FileData.DatabaseModels
-{
- [Table("Articoli")]
- public partial class ArticoloModel
- {
- #region Public Properties
-
- [Key]
- public string CodArticolo { get; set; }
- public string DescArticolo { get; set; }
- public string Disegno { get; set; }
- public string Tipo { get; set; }
-
- #endregion Public Properties
- }
-}
diff --git a/MP.FileData/DatabaseModels/FileModel.cs b/MP.FileData/DatabaseModels/FileModel.cs
index af9953b5..021998d8 100644
--- a/MP.FileData/DatabaseModels/FileModel.cs
+++ b/MP.FileData/DatabaseModels/FileModel.cs
@@ -22,7 +22,6 @@ namespace MP.FileData.DatabaseModels
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int FileId { get; set; }
public bool Active { get; set; } = true;
- public string CodArticolo { get; set; }
public string IdxMacchina { get; set; } = "";
public string Name { get; set; } = "";
public int Rev { get; set; } = 0;
@@ -51,8 +50,6 @@ namespace MP.FileData.DatabaseModels
}
}
- [ForeignKey("CodArticolo")]
- public virtual ArticoloModel Articolo { get; set; }
[ForeignKey("IdxMacchina")]
public virtual MacchinaModel Macchina { get; set; }
diff --git a/MP.FileData/ModelBuilderExtensions.cs b/MP.FileData/ModelBuilderExtensions.cs
index 74beddde..b3415b80 100644
--- a/MP.FileData/ModelBuilderExtensions.cs
+++ b/MP.FileData/ModelBuilderExtensions.cs
@@ -18,15 +18,10 @@ namespace MP.FileData
///
public static void Seed(this ModelBuilder modelBuilder)
{
- // inizializzazione dei valori di default x USER
+ // inizializzazione dei valori di default x MACCHINA
modelBuilder.Entity().HasData(
new MacchinaModel { IdxMacchina = "0", CodMacchina = "0", Descrizione = "--- Tutte ---", Nome = "--- Tutte ---", BasePath = "", ImgUrl = "", Note = "", ShowOrder = 0 }
);
-
- // inizializzazione dei valori di default x Plant
- modelBuilder.Entity().HasData(
- new ArticoloModel { CodArticolo = "ND", DescArticolo = "--- Tutti ---", Disegno = "", Tipo = "ND" }
- );
}
#endregion Public Methods
diff --git a/MP.FileData/MoonPro_ProgContext.cs b/MP.FileData/MoonPro_ProgContext.cs
index 441c0b86..4b31796c 100644
--- a/MP.FileData/MoonPro_ProgContext.cs
+++ b/MP.FileData/MoonPro_ProgContext.cs
@@ -59,9 +59,9 @@ namespace MP.FileData
#region Public Properties
- public virtual DbSet DbSetArticoli { get; set; }
public virtual DbSet DbSetMacchine { get; set; }
public virtual DbSet DbSetProgFile { get; set; }
+ public virtual DbSet DbSetTags { get; set; }
#endregion Public Properties