scrematura iniziale

This commit is contained in:
Marco Audiffredi 2025-03-24 17:08:15 +01:00
parent 3f6efcbc7f
commit d826d275fb
7 changed files with 452 additions and 2923 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
using ApiPolo.Interfaces;
using ApiPolo.Models;
using ApiPolo.Models.Security_dbcontext;
using Microsoft.EntityFrameworkCore;
namespace ApiPolo.Data
@ -55,6 +55,10 @@ namespace ApiPolo.Data
public DbSet<Timbratura>? Timbr { get; set; }
public DbSet<Commessa>? Commesse { get; set; }
public DbSet<Prog2>? Prog { get; set; }
public DbSet<Prog>? Progressivi { get; set; }
public DbSet<Compo_Impia>? Compo { get; set; }
#endregion
/// <summary></summary>

View File

@ -3,6 +3,7 @@ using ApiPolo.Models;
namespace ApiPolo.Interfaces
{
/// <summary></summary>
public interface ITenantDbContext
{
DbSet<Caus_Rapp>? Causali { get; set; }
@ -28,5 +29,13 @@ namespace ApiPolo.Interfaces
DbSet<Tecnici>? Tecnici { get; set; }
DbSet<Timbratura>? Timbr { get; set; }
DbSet<Sto_Imp>? StoImp { get; set; }
DbSet<Prog2>? Prog { get; set; }
DbSet<Prog>? Progressivi { get; set; }
DbSet<Compo_Impia>? Compo { get; set; }
void UpdateRapps(Rapp_New obj);
}
}

View File

@ -1,11 +1,14 @@
using ApiPolo.Data;
using ApiPolo.Interfaces;
using Microsoft.EntityFrameworkCore;
using static ApiPolo.Controllers.PoloController;
/// <summary></summary>
public class TenantDbContextFactory : ITenantDbContextFactory
{
private readonly IServiceProvider _serviceProvider;
/// <summary></summary>
public TenantDbContextFactory(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
@ -19,7 +22,7 @@ public class TenantDbContextFactory : ITenantDbContextFactory
return tenant switch
{
Clienti.Maras => scope.ServiceProvider.GetRequiredService<Maras_DbContext>(),
Clienti.Marrocco => scope.ServiceProvider.GetRequiredService<Marro_DbContext>(),
// Add other tenants as needed
// Clienti.AnotherTenant => scope.ServiceProvider.GetRequiredService<AnotherTenant_DbContext>(),
_ => throw new KeyNotFoundException($"No DbContext found for tenant: {tenant}")

View File

@ -1,27 +0,0 @@
using ApiPolo.Models.VT_dbcontext;
using Microsoft.EntityFrameworkCore;
namespace ApiPolo.Models
{
/// <summary></summary>
public class VT_Buoni_DbContext : DbContext
{
/// <summary></summary>
public DbSet<Buoni>? buoni { get; set; }
/// <summary></summary>
public VT_Buoni_DbContext(DbContextOptions<VT_Buoni_DbContext> options) : base(options)
{
}
/// <summary></summary>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Buoni>().ToTable("BUONI");
modelBuilder.Entity<Buoni>().HasKey(table => new
{
table.azienda,
table.ser_buono
});
}
}
}

View File

@ -4,7 +4,7 @@ using Google.Apis.Auth.OAuth2;
using static ApiPolo.Controllers.PoloController;
using static Google.Apis.Requests.BatchRequest;
using System.Text;
using ApiPolo.Models.Marrocco_dbcontext;
using ApiPolo.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@ -102,18 +102,18 @@ namespace ApiPolo.Services
{
List<Notifiche> lst = new List<Notifiche>();
#region Marrocco
var optionsBuilder = new DbContextOptionsBuilder<MARRO_NOTIFICHEDbContext>();
optionsBuilder.UseSqlServer(Configuration.GetConnectionString("MARRO"));
//var optionsBuilder = new DbContextOptionsBuilder<MARRO_NOTIFICHEDbContext>();
//optionsBuilder.UseSqlServer(Configuration.GetConnectionString("MARRO"));
using (var dbContext = new MARRO_NOTIFICHEDbContext(optionsBuilder.Options))
{
var listaNot = dbContext.Notif.Where(t => t.pidattim == null&& t.picodazi!=null && t.picodazi.Equals("MARRO") && t.picodtec!=null && t.picodtec.Equals("ZZZ")).OrderBy(t=>t.piserial).Take(1).ToList();
//using (var dbContext = new MARRO_NOTIFICHEDbContext(optionsBuilder.Options))
//{
// var listaNot = dbContext.Notif.Where(t => t.pidattim == null&& t.picodazi!=null && t.picodazi.Equals("MARRO") && t.picodtec!=null && t.picodtec.Equals("ZZZ")).OrderBy(t=>t.piserial).Take(1).ToList();
foreach(Notifiche n in listaNot)
{
lst.Add(n);
}
}
// foreach(Notifiche n in listaNot)
// {
// lst.Add(n);
// }
//}
#endregion
return lst;
@ -122,37 +122,37 @@ namespace ApiPolo.Services
private void markNotify(List<MexPush> lst)
{
#region MARRO
var optionsBuilder = new DbContextOptionsBuilder<MARRO_NOTIFICHEDbContext>();
optionsBuilder.UseSqlServer(Configuration.GetConnectionString("MARRO"));
using (var dbContext = new MARRO_NOTIFICHEDbContext(optionsBuilder.Options))
{
foreach (MexPush n in lst)
{
Notifiche r = n.notifi;
r.pidattim = DateTime.Now;
dbContext.Entry(r).State = EntityState.Modified;
dbContext.SaveChanges();
//var optionsBuilder = new DbContextOptionsBuilder<MARRO_NOTIFICHEDbContext>();
//optionsBuilder.UseSqlServer(Configuration.GetConnectionString("MARRO"));
//using (var dbContext = new MARRO_NOTIFICHEDbContext(optionsBuilder.Options))
//{
// foreach (MexPush n in lst)
// {
// Notifiche r = n.notifi;
// r.pidattim = DateTime.Now;
// dbContext.Entry(r).State = EntityState.Modified;
// dbContext.SaveChanges();
}
}
// }
//}
#endregion
}
private void markNotify2(List<Notifiche> lst)
{
#region MARRO
var optionsBuilder = new DbContextOptionsBuilder<MARRO_NOTIFICHEDbContext>();
optionsBuilder.UseSqlServer(Configuration.GetConnectionString("MARRO"));
using (var dbContext = new MARRO_NOTIFICHEDbContext(optionsBuilder.Options))
{
foreach (Notifiche n in lst)
{
Notifiche r = n;
r.pidattim = DateTime.Now;
dbContext.Entry(r).State = EntityState.Modified;
dbContext.SaveChanges();
//var optionsBuilder = new DbContextOptionsBuilder<MARRO_NOTIFICHEDbContext>();
//optionsBuilder.UseSqlServer(Configuration.GetConnectionString("MARRO"));
//using (var dbContext = new MARRO_NOTIFICHEDbContext(optionsBuilder.Options))
//{
// foreach (Notifiche n in lst)
// {
// Notifiche r = n;
// r.pidattim = DateTime.Now;
// dbContext.Entry(r).State = EntityState.Modified;
// dbContext.SaveChanges();
}
}
// }
//}
#endregion
}

View File

@ -1,21 +1,7 @@
using ApiPolo.Models;
using ApiPolo.Models.Discovery_dbcontext;
using ApiPolo.Models.Ferrari_dbcontext;
using ApiPolo.Models.Marrocco_dbcontext;
using ApiPolo.Models.Sicilia_dbcontext;
using ApiPolo.Models.Sarom_dbcontext;
using ApiPolo.Models.Gitoga_dbcontext;
using ApiPolo.Models.Lifta_dbcontext;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
using ApiPolo.Models.Sinergo_dbcontext;
using ApiPolo.Services;
using ApiPolo.Models.Siet_dbcontext;
using ApiPolo.Models.PMS_dbcontext;
using ApiPolo.Models.VT_dbcontext;
using ApiPolo.Models.Tedesco_dbcontext;
using ApiPolo.Models.Lift_web_dbcontext;
using ApiPolo.Models.Security_dbcontext;
using ApiPolo.Interfaces;
using ApiPolo.Data;
@ -40,7 +26,7 @@ namespace ApiPolo
services.AddControllers();
services.AddDbContext<ConfigurazioniDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ApiStr")));
services.AddDbContext<TokenDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ApiStr")));
/*
#region FERRARI
services.AddDbContext<FERRA_CHIAMATEDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("FERRA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
@ -1015,15 +1001,12 @@ namespace ApiPolo
));
#endregion
//TEST
*/
services.AddDbContext<Maras_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MARAS")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext<Marro_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MARRO")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
// FACTORY MUTI-TENANT