Testata movib_m
This commit is contained in:
parent
78882b77ed
commit
ebe47444bf
@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Runtime.InteropServices;
|
||||
@ -29,6 +30,7 @@ namespace ApiSoftway.Controllers
|
||||
private readonly GESA_AUTOMEZZI_DbContext _automezzi_context;
|
||||
private readonly IConfiguration? _configuration;
|
||||
private readonly GESA_GIRICONSEGNEDACREARE_DbContext _daCreare_context;
|
||||
private readonly GESA_CONSEGNE_M_DbContext _consegne_m_context;
|
||||
|
||||
private DbSet<Giri>? _giri;
|
||||
private DbSet<GiriConsegna>? _giriCons;
|
||||
@ -41,7 +43,8 @@ namespace ApiSoftway.Controllers
|
||||
private DbSet<GiriConsegnaDaCreare>? _GiriDaCreare;
|
||||
public GiriController(ILogger<LoginController> logger, IConfiguration? configuration, GESA_GIRI_DbContext giri_context, GESA_DESTINAZIONI_DbContext destinazioni_context
|
||||
, GESA_CONSEGNE_DbContext consegne_context, GESA_GIRICONSEGNE_DbContext giricons_context, GESA_GIRICONSEGNEVISTA_DbContext consegnevista_context, GESA_SBR_ORD_DbContext sbrord_context
|
||||
, GESA_PERSONALE_DbContext personale_context, GESA_AUTOMEZZI_DbContext automezzi_context, GESA_GIRICONSEGNEDACREARE_DbContext daCreare_context)
|
||||
, GESA_PERSONALE_DbContext personale_context, GESA_AUTOMEZZI_DbContext automezzi_context, GESA_GIRICONSEGNEDACREARE_DbContext daCreare_context
|
||||
, GESA_CONSEGNE_M_DbContext consegne_m_context)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
@ -54,6 +57,7 @@ namespace ApiSoftway.Controllers
|
||||
_personale_context= personale_context;
|
||||
_automezzi_context = automezzi_context;
|
||||
_daCreare_context = daCreare_context;
|
||||
_consegne_m_context = consegne_m_context;
|
||||
}
|
||||
|
||||
[HttpGet("listaGiri")]
|
||||
@ -668,7 +672,22 @@ namespace ApiSoftway.Controllers
|
||||
//string tecnico = getClaimValueByToken(token, "tccodice");
|
||||
if (await checkConsegnaPresente(token, model) == 0)
|
||||
{
|
||||
Consegna t = fillConsegna(model, token);
|
||||
|
||||
DateTime dateTime = DateTime.Now;
|
||||
Consegna t = fillConsegna(model, token, dateTime);
|
||||
//Step 1 : testata
|
||||
Consegna_m m = new Consegna_m();
|
||||
m.Pisergir = t.Pisergir;
|
||||
m.Data = dateTime;
|
||||
m.Cpccchk = getCpccchk(10);
|
||||
using (var transactionM = _consegne_m_context.Database.BeginTransaction())
|
||||
{
|
||||
await _consegne_m_context.Cons.AddAsync(m);
|
||||
await _consegne_m_context.SaveChangesAsync();
|
||||
transactionM.Commit();
|
||||
}
|
||||
|
||||
//step 2 : riga (è sempre e solo una)
|
||||
using (var transaction = _consegne_context.Database.BeginTransaction())
|
||||
{
|
||||
await _consegne_context.Cons.AddAsync(t);
|
||||
@ -739,11 +758,12 @@ namespace ApiSoftway.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task<int> checkConsegnaPresente(string token, Consegna model)
|
||||
{
|
||||
int trovati = 0;
|
||||
_consegne = _consegne_context.Cons;
|
||||
var ti = await _consegne.Where(t => t.Serial.Equals(model.Serial) && t.Cprownum == model.Cprownum ).ToListAsync();
|
||||
var ti = await _consegne.Where(t => t.Pisergir.Equals(model.Pisergir) && t.Cprownum == model.Cprownum ).ToListAsync();
|
||||
if (ti.Any())
|
||||
{
|
||||
trovati = ti.Count();
|
||||
@ -841,7 +861,7 @@ namespace ApiSoftway.Controllers
|
||||
|
||||
return item;
|
||||
}
|
||||
private Consegna fillConsegna(Consegna i, string token)
|
||||
private Consegna fillConsegna(Consegna i, string token, DateTime d)
|
||||
{
|
||||
Consegna r = new Consegna();
|
||||
|
||||
@ -858,7 +878,7 @@ namespace ApiSoftway.Controllers
|
||||
r.Ccadd = i.Ccadd;
|
||||
r.Ccda = i.Ccda;
|
||||
r.Ccddd=i.Ccddd;
|
||||
r.Datdoc= DateTime.Now;
|
||||
r.Datdoc= d;
|
||||
r.Dcda=i.Dcda;
|
||||
r.Descb=i.Descb;
|
||||
r.Nbanc = i.Nbanc;
|
||||
@ -870,7 +890,7 @@ namespace ApiSoftway.Controllers
|
||||
r.Tipob2 = i.Tipob2;
|
||||
r.Tipob =i.Tipob;
|
||||
r.Sdoc = i.Sdoc;
|
||||
r.Serial = i.Serial;
|
||||
r.Pisergir = i.Pisergir;
|
||||
//r.Tcda=i.Tcda;
|
||||
r.Tcda = "S";
|
||||
r.Tca = i.Tca;
|
||||
@ -912,7 +932,7 @@ namespace ApiSoftway.Controllers
|
||||
r.Tipob2 = i.Tipob2;
|
||||
r.Tipob = i.Tipob;
|
||||
r.Sdoc = i.Sdoc;
|
||||
r.Serial = i.Serial;
|
||||
r.Pisergir = i.Pisergir;
|
||||
//r.Tcda=i.Tcda;
|
||||
r.Tcda = "N";
|
||||
r.Tca = i.Tca;
|
||||
@ -955,7 +975,7 @@ namespace ApiSoftway.Controllers
|
||||
r.Tipob2 = i.Tipob2;
|
||||
r.Tipob = i.Tipob;
|
||||
r.Sdoc = i.Sdoc;
|
||||
r.Serial = i.Serial;
|
||||
r.Pisergir = i.Pisergir;
|
||||
r.Tcda = i.Tcda;
|
||||
r.Tca = i.Tca;
|
||||
r.Cca = i.Cca;
|
||||
@ -983,6 +1003,14 @@ namespace ApiSoftway.Controllers
|
||||
|
||||
return newSer;
|
||||
}
|
||||
|
||||
private static Random random = new Random();
|
||||
/// <summary>crea un cpccchk</summary>
|
||||
public static string getCpccchk(int length)
|
||||
{
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ namespace ApiSoftway.Models
|
||||
public class Consegna
|
||||
{
|
||||
[Key]
|
||||
public string? Serial { get; set; }
|
||||
public string? Pisergir { get; set; }
|
||||
|
||||
[Key]
|
||||
public int? Cprownum { get; set; }
|
||||
|
||||
26
Models/Consegna_m.cs
Normal file
26
Models/Consegna_m.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ApiSoftway.Models
|
||||
{
|
||||
public class Consegna_m
|
||||
{
|
||||
[Key]
|
||||
public string? Pisergir { get; set; }
|
||||
public string? Esercizio { get; set; }
|
||||
public int? Numero { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(10, 0)")]
|
||||
public int? Posseriale { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(10, 0)")]
|
||||
public int? Posnum { get; set; }
|
||||
|
||||
public string? Posese { get; set; }
|
||||
|
||||
public DateTime? Data { get; set; }
|
||||
|
||||
public string? Descmov { get; set; }
|
||||
|
||||
public string? Cpccchk { get; set; }
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ namespace ApiSoftway.Models
|
||||
{
|
||||
public class Consegna_out
|
||||
{
|
||||
public string? Serial { get; set; }
|
||||
public string? Pisergir { get; set; }
|
||||
public int? Cprownum { get; set; }
|
||||
public string? Tcda { get; set; }
|
||||
public string? Ccda { get; set; }
|
||||
|
||||
@ -17,7 +17,7 @@ namespace ApiSoftway.Models.Gesa_DbContext
|
||||
{
|
||||
modelBuilder.Entity<Consegna>().ToTable("GESASMOVIB");
|
||||
modelBuilder.Entity<Consegna>().HasKey(table => new {
|
||||
table.Serial,
|
||||
table.Pisergir,
|
||||
table.Cprownum
|
||||
});
|
||||
}
|
||||
|
||||
25
Models/Gesa_DbContext/GESA_CONSEGNE_M_DbContext.cs
Normal file
25
Models/Gesa_DbContext/GESA_CONSEGNE_M_DbContext.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ApiSoftway.Models.Gesa_DbContext
|
||||
{
|
||||
public class GESA_CONSEGNE_M_DbContext : DbContext
|
||||
{
|
||||
/// <summary></summary>
|
||||
public DbSet<Consegna_m>? Cons { get; set; }
|
||||
|
||||
/// <summary></summary>
|
||||
public GESA_CONSEGNE_M_DbContext(DbContextOptions<GESA_CONSEGNE_M_DbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary></summary>
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Consegna_m>().ToTable("GESASMOVIB_m");
|
||||
modelBuilder.Entity<Consegna_m>().HasKey(table => new {
|
||||
table.Pisergir
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -33,6 +33,7 @@ namespace ApiSoftway.Models
|
||||
public int? DestinazioniFatte { get; set; }
|
||||
public int? DestinazioniTutte { get; set; }
|
||||
public int? DestinazioniModificate { get; set; }
|
||||
public int? parzialeBanSca { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,9 @@ builder.Services.AddDbContext<GESA_MODGIR_DbContext>(options => options.UseSqlSe
|
||||
builder.Services.AddDbContext<GESA_AUTOMEZZI_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||
));
|
||||
builder.Services.AddDbContext<GESA_CONSEGNE_M_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||
));
|
||||
|
||||
#endregion
|
||||
|
||||
@ -71,5 +74,5 @@ app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
//app.Run("http://localhost:6000");
|
||||
//app.Run();
|
||||
app.Run("http://localhost:6000");
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
"ConnectionStrings": {
|
||||
|
||||
"GESA": "Data Source=10.0.0.10;Initial Catalog=AHRGESA;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
|
||||
//"GESA": "Data Source=10.0.0.10;Initial Catalog=AHR80_GESA;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
|
||||
"ApiStr": "Data Source=10.0.0.10;Initial Catalog=API_POLO;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
|
||||
},
|
||||
"JWT": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user