gestione immagini buono
This commit is contained in:
parent
ad5122b1ca
commit
a5eee0b6cf
@ -1384,7 +1384,11 @@ namespace ApiPolo.Controllers
|
|||||||
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
||||||
return dbContext.ChiamateTables; // Use Set<T>() to handle different DbContexts
|
return dbContext.ChiamateTables; // Use Set<T>() to handle different DbContexts
|
||||||
}
|
}
|
||||||
|
private DbSet<BuoniLW> getBuoniByTenant(string tenant)
|
||||||
|
{
|
||||||
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
||||||
|
return dbContext.Buoni; // Use Set<T>() to handle different DbContexts
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Utility
|
#region Utility
|
||||||
@ -7334,63 +7338,13 @@ namespace ApiPolo.Controllers
|
|||||||
{
|
{
|
||||||
ten = tenConf;
|
ten = tenConf;
|
||||||
}
|
}
|
||||||
string fileName = string.Empty;
|
//string fileName = string.Empty;
|
||||||
|
//_confLette = await readConf(tenConf);
|
||||||
Console.WriteLine(string.Format("*********** {2} INIZIO Chiamata al metodo upload: tenant:{0} tenant2: {3} tenantConf: {4} file: {1} tecnico:{5}", ten, nomefile, DateTime.Now.ToString(),ten2,tenConf, tecnico));
|
|
||||||
_confLette = await readConf(tenConf);
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
long size = files.Length;
|
long size = files.Length;
|
||||||
if(string.IsNullOrEmpty(nomefile))
|
|
||||||
{
|
|
||||||
fileName = Path.GetFileName(files.FileName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fileName = nomefile;
|
|
||||||
}
|
|
||||||
|
|
||||||
string url = string.Empty;
|
|
||||||
string usr = string.Empty;
|
|
||||||
string pwd = string.Empty;
|
|
||||||
string ip = string.Empty;
|
|
||||||
int? port = 0;
|
|
||||||
|
|
||||||
switch (ten)
|
|
||||||
{
|
|
||||||
case Clienti.LW:
|
|
||||||
|
|
||||||
#region inserimento tabella
|
|
||||||
BuoniLW model2 = new BuoniLW();
|
|
||||||
model2.azienda = ten;
|
|
||||||
if (nomefile.Length > 8)
|
|
||||||
nomefile = nomefile.Substring(0, 8);
|
|
||||||
model2.ser_buono = nomefile;
|
|
||||||
model2.dt_ins = DateTime.Now;
|
|
||||||
using (MemoryStream ms = new MemoryStream())
|
|
||||||
{
|
|
||||||
files.CopyTo(ms);
|
|
||||||
byte[] byteArray = ms.GetBuffer();
|
|
||||||
string base64String = Convert.ToBase64String(byteArray);
|
|
||||||
model2.immagine = base64String;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
using (var transaction = _LW_Buoni.Database.BeginTransaction())
|
|
||||||
{
|
|
||||||
await _LW_Buoni.buoni.AddAsync(model2);
|
|
||||||
await _LW_Buoni.SaveChangesAsync();
|
|
||||||
transaction.Commit();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
break;
|
|
||||||
case Clienti.Syscom:
|
|
||||||
|
|
||||||
#region inserimento tabella
|
|
||||||
BuoniLW modelsys = new BuoniLW();
|
BuoniLW modelsys = new BuoniLW();
|
||||||
modelsys.azienda = ten;
|
modelsys.azienda = ten;
|
||||||
if (nomefile.Length > 8)
|
if (nomefile.Length > 8)
|
||||||
@ -7405,21 +7359,9 @@ namespace ApiPolo.Controllers
|
|||||||
modelsys.immagine = base64String;
|
modelsys.immagine = base64String;
|
||||||
}
|
}
|
||||||
//scrittura
|
//scrittura
|
||||||
/*
|
await _service.AddBuonoToDbAsync(ten,modelsys);
|
||||||
using (var transaction = _Sys_Buoni.Database.BeginTransaction())
|
System.Threading.Thread.Sleep(1000);
|
||||||
{
|
|
||||||
await _Sys_Buoni.buoni.AddAsync(modelsys);
|
|
||||||
await _Sys_Buoni.SaveChangesAsync();
|
|
||||||
transaction.Commit();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine(string.Format("*********** {2} FINE Chiamata al metodo upload: tenant:{0} tenant2: {3} tenantConf: {4} file: {1} tecnico:{5}", ten, nomefile, DateTime.Now.ToString(), ten2, tenConf, tecnico));
|
|
||||||
return Ok(new { count = 1, size });
|
return Ok(new { count = 1, size });
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -12052,8 +11994,6 @@ namespace ApiPolo.Controllers
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Logging
|
#region Logging
|
||||||
/// <summary>Upload return:ActionResult</summary>
|
/// <summary>Upload return:ActionResult</summary>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
@ -63,6 +63,8 @@ namespace ApiPolo.Data
|
|||||||
public DbSet<Compo_Impia>? Compo { get; set; }
|
public DbSet<Compo_Impia>? Compo { get; set; }
|
||||||
|
|
||||||
public DbSet<ChiamateTable>? ChiamateTables { get; set; }
|
public DbSet<ChiamateTable>? ChiamateTables { get; set; }
|
||||||
|
|
||||||
|
public DbSet<BuoniLW>? Buoni { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public TenantDbContext(DbContextOptions<TenantDbContext> options, IConfiguration configuration, string tenant)
|
public TenantDbContext(DbContextOptions<TenantDbContext> options, IConfiguration configuration, string tenant)
|
||||||
@ -208,6 +210,18 @@ namespace ApiPolo.Data
|
|||||||
table.chserial
|
table.chserial
|
||||||
});
|
});
|
||||||
}, "CHIAMATE");
|
}, "CHIAMATE");
|
||||||
|
|
||||||
|
TryConfigureEntity(mb =>
|
||||||
|
{
|
||||||
|
mb.Entity<BuoniLW>().ToTable("BUONI");
|
||||||
|
mb.Entity<BuoniLW>().HasKey(table => new
|
||||||
|
{
|
||||||
|
table.azienda,
|
||||||
|
table.ser_buono
|
||||||
|
});
|
||||||
|
}, "BUONI");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -175,5 +175,27 @@ namespace ApiPolo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Scrive su BUONI: upload immagine buono in metodo chiudi</summary>
|
||||||
|
public async Task AddBuonoToDbAsync(string tenant, BuoniLW model)
|
||||||
|
{
|
||||||
|
|
||||||
|
var dbContext = _dbContextFactory.GetDbContext(tenant);
|
||||||
|
|
||||||
|
string mex = string.Empty;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var transaction = await dbContext.Database.BeginTransactionAsync())
|
||||||
|
{
|
||||||
|
await dbContext.Buoni.AddAsync(model);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
await transaction.CommitAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
mex = ex.Message;
|
||||||
|
throw new InvalidOperationException("Error in Service - AddRappNewToDbAsync: " + mex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user