init
This commit is contained in:
parent
8c7ea525f0
commit
ce4f694960
19
ApiSoftway.csproj
Normal file
19
ApiSoftway.csproj
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="FirebaseAdmin" Version="3.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.31" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.31">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
25
ApiSoftway.sln
Normal file
25
ApiSoftway.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.6.33723.286
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiSoftway", "ApiSoftway.csproj", "{56487A04-3FAD-4F88-B3EE-DF1C6CA8D246}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{56487A04-3FAD-4F88-B3EE-DF1C6CA8D246}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{56487A04-3FAD-4F88-B3EE-DF1C6CA8D246}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{56487A04-3FAD-4F88-B3EE-DF1C6CA8D246}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{56487A04-3FAD-4F88-B3EE-DF1C6CA8D246}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {8410D81F-DE3A-4944-A62C-0CBF17FDD6F9}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
329
Controllers/GiriController.cs
Normal file
329
Controllers/GiriController.cs
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
using ApiSoftway.Models;
|
||||||
|
using ApiSoftway.Models.Gesa_DbContext;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class GiriController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<LoginController> _logger;
|
||||||
|
private readonly GESA_GIRI_DbContext _giri_context;
|
||||||
|
private readonly GESA_DESTINAZIONI_DbContext _destinazioni_context;
|
||||||
|
private readonly GESA_CONSEGNE_DbContext _consegne_context;
|
||||||
|
private readonly IConfiguration? _configuration;
|
||||||
|
private DbSet<Giri>? _giri;
|
||||||
|
private DbSet<Destinazioni>? _destinazioni;
|
||||||
|
private DbSet<Consegna>? _consegne;
|
||||||
|
public GiriController(ILogger<LoginController> logger, IConfiguration? configuration, GESA_GIRI_DbContext giri_context, GESA_DESTINAZIONI_DbContext destinazioni_context
|
||||||
|
, GESA_CONSEGNE_DbContext consegne_context)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_configuration = configuration;
|
||||||
|
_giri_context = giri_context;
|
||||||
|
_destinazioni_context = destinazioni_context;
|
||||||
|
_consegne_context = consegne_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
//[HttpGet("listaGiri")]
|
||||||
|
//public async Task<ActionResult<IEnumerable<Giri_out>>> listaGiri(string token)
|
||||||
|
//{
|
||||||
|
|
||||||
|
// List<Giri_out> lst = new List<Giri_out>();
|
||||||
|
// string usr = getClaimValueByToken(token, "codice");
|
||||||
|
// _giri = _giri_context.Giri;
|
||||||
|
// var r= await _giri.Where(t => t.Brautist != null && t.Brautist.Equals(usr)).OrderByDescending(t=>t.Brdatcar).Take(1).ToListAsync();
|
||||||
|
// foreach(Giri giri in r)
|
||||||
|
// {
|
||||||
|
// Giri_out o=new Giri_out();
|
||||||
|
// o.Autista = giri.Autista;
|
||||||
|
// o.Brdatcar = giri.Brdatcar;
|
||||||
|
// o.Brautist = giri.Brautist;
|
||||||
|
// o.num_dest=giri.num_dest;
|
||||||
|
// o.ItemList = formattaGiro(giri);
|
||||||
|
// lst.Add(o);
|
||||||
|
// }
|
||||||
|
// return lst;
|
||||||
|
//}
|
||||||
|
//[HttpGet("listaDestinazioni")]
|
||||||
|
//public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioni(string token, DateTime data)
|
||||||
|
//{
|
||||||
|
|
||||||
|
// List<Destinazioni_out> lst = new List<Destinazioni_out>();
|
||||||
|
// string usr = getClaimValueByToken(token, "codice");
|
||||||
|
// _destinazioni = _destinazioni_context.Destinazioni;
|
||||||
|
// var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(usr)&& t.DataCarico != null && t.DataCarico == data).OrderByDescending(t => t.DataCarico).ToListAsync();
|
||||||
|
// foreach(Destinazioni d in r)
|
||||||
|
// {
|
||||||
|
// Destinazioni_out o = new Destinazioni_out();
|
||||||
|
// o.Autista = d.Autista;
|
||||||
|
// o.CodAutista = d.CodAutista;
|
||||||
|
// o.DescAutomezzo = d.DescAutomezzo;
|
||||||
|
// o.CodAutomezzo=d.CodAutomezzo;
|
||||||
|
// o.DataCarico = d.DataCarico;
|
||||||
|
// o.Brserial=d.Brserial;
|
||||||
|
// o.Brmerce=d.Brmerce;
|
||||||
|
// o.Brnote=d.Brnote;
|
||||||
|
// o.Cproword=d.Cproword;
|
||||||
|
// o.IndirizzoSede=d.IndirizzoSede;
|
||||||
|
// o.Sede=d.Sede;
|
||||||
|
// o.ItemList = formattaDestinazione(d);
|
||||||
|
// lst.Add(o);
|
||||||
|
// }
|
||||||
|
// return lst;
|
||||||
|
//}
|
||||||
|
|
||||||
|
[HttpGet("listaDestinazioni")]
|
||||||
|
public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioni2(string token)
|
||||||
|
{
|
||||||
|
//step 1: ricavo la data a partire dal login
|
||||||
|
string usr = getClaimValueByToken(token, "codice");
|
||||||
|
_giri = _giri_context.Giri;
|
||||||
|
var g = await _giri.Where(t => t.Brautist != null && t.Brautist.Equals(usr)).OrderByDescending(t => t.Brdatcar).Take(1).ToListAsync();
|
||||||
|
DateTime? data = g.First().Brdatcar;
|
||||||
|
|
||||||
|
|
||||||
|
List<Destinazioni_out> lst = new List<Destinazioni_out>();
|
||||||
|
_destinazioni = _destinazioni_context.Destinazioni;
|
||||||
|
var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(usr) && t.DataCarico != null && t.DataCarico == data).OrderByDescending(t => t.DataCarico).ToListAsync();
|
||||||
|
foreach (Destinazioni d in r)
|
||||||
|
{
|
||||||
|
Destinazioni_out o = new Destinazioni_out();
|
||||||
|
o.Autista = d.Autista;
|
||||||
|
o.CodAutista = d.CodAutista;
|
||||||
|
o.DescAutomezzo = d.DescAutomezzo;
|
||||||
|
o.CodAutomezzo = d.CodAutomezzo;
|
||||||
|
o.DataCarico = d.DataCarico;
|
||||||
|
o.Brserial = d.Brserial;
|
||||||
|
o.Brmerce = d.Brmerce;
|
||||||
|
o.Brnote = d.Brnote;
|
||||||
|
o.Cproword = d.Cproword;
|
||||||
|
o.IndirizzoSede = d.IndirizzoSede;
|
||||||
|
o.Sede = d.Sede;
|
||||||
|
o.CodCommittente = d.CodCommittente;
|
||||||
|
o.Committente = d.Committente;
|
||||||
|
o.CodSede = d.CodSede;
|
||||||
|
o.ItemList = formattaDestinazione(d);
|
||||||
|
if(!string.IsNullOrEmpty(d.consFattaSerial))
|
||||||
|
{
|
||||||
|
ConsegnaFatta cf=new ConsegnaFatta();
|
||||||
|
cf.consFattaSerial= d.consFattaSerial;
|
||||||
|
cf.consFattaRow= d.consFattaRow;
|
||||||
|
cf.consFattaAut= d.consFattaAut;
|
||||||
|
cf.consFattaBanSca = d.consFattaBanSca;
|
||||||
|
cf.consFattaBanCar= d.consFattaBanCar;
|
||||||
|
string nota = !string.IsNullOrEmpty(d.consFattaNotBan) ? d.consFattaNotBan.Trim() : string.Empty;
|
||||||
|
cf.consFattaNotBan= nota;
|
||||||
|
cf.consFattaImpor=d.consFattaImpor;
|
||||||
|
cf.consFattaMezzo= d.consFattaMezzo;
|
||||||
|
string nota2 = !string.IsNullOrEmpty(d.consFattaNotImp) ? d.consFattaNotImp.Trim() : string.Empty;
|
||||||
|
cf.consFattaNotImp=nota2;
|
||||||
|
|
||||||
|
o.ConsFatta=cf;
|
||||||
|
}
|
||||||
|
|
||||||
|
lst.Add(o);
|
||||||
|
}
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Salva i dati della consegna</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("destinazione/salva")]
|
||||||
|
public async Task<ActionResult<Consegna_out>> timbrature_salva([FromBody] Consegna model, string token)
|
||||||
|
{
|
||||||
|
Consegna_out tOut = new Consegna_out();
|
||||||
|
string usr = getClaimValueByToken(token, "codice");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
//string tecnico = getClaimValueByToken(token, "tccodice");
|
||||||
|
if (await checkConsegnaPresente(token, model) == 0)
|
||||||
|
{
|
||||||
|
Consegna t = fillConsegna(model, token);
|
||||||
|
using (var transaction = _consegne_context.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
await _consegne_context.Cons.AddAsync(t);
|
||||||
|
await _consegne_context.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
tOut = fillConsegna_out(model, token);
|
||||||
|
tOut.err_status_code = "200";
|
||||||
|
return StatusCode(StatusCodes.Status200OK, tOut);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "timbratura presente.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//return tOut;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||||
|
tOut.err_title = ex.Message;
|
||||||
|
tOut.err_detail = errmsg;
|
||||||
|
tOut.err_status_code = "500";
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, tOut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
if (ti.Any())
|
||||||
|
{
|
||||||
|
trovati = ti.Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
return trovati;
|
||||||
|
}
|
||||||
|
private string getClaimValueByToken(string token, string claimName)
|
||||||
|
{
|
||||||
|
string t = string.Empty;
|
||||||
|
|
||||||
|
var handler = new JwtSecurityTokenHandler();
|
||||||
|
var jwtSecurityToken = handler.ReadJwtToken(token);
|
||||||
|
if (jwtSecurityToken != null)
|
||||||
|
{
|
||||||
|
var id = jwtSecurityToken.Claims.First(claim => claim.Type == claimName).Value;
|
||||||
|
t = id;
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
private string formattaGiro(Giri g)
|
||||||
|
{
|
||||||
|
string item = string.Empty;
|
||||||
|
if (g != null)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
var dateString1 = g.Brdatcar.Value.ToString("dd-MM-yyyy");
|
||||||
|
sb.AppendLine("Giro del "+dateString1);
|
||||||
|
sb.AppendLine("Assegnato a "+g.Autista);
|
||||||
|
sb.AppendLine("Numero consegne " + g.num_dest.ToString());
|
||||||
|
item=sb.ToString();
|
||||||
|
sb = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
private string formattaDestinazione(Destinazioni d)
|
||||||
|
{
|
||||||
|
string item = string.Empty;
|
||||||
|
if (d != null)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
//var dateString1 = d.DataCarico.Value.ToString("dd-MM-yyyy");
|
||||||
|
string comm = !string.IsNullOrEmpty(d.Committente) ? d.Committente.Trim() : string.Empty;
|
||||||
|
|
||||||
|
sb.Append("<b>Committente</b> " + comm);
|
||||||
|
sb.Append("<br> ");
|
||||||
|
string sed = !string.IsNullOrEmpty(d.Sede) ? d.Sede.Trim() : string.Empty;
|
||||||
|
sb.Append("<b>Sede Consegna</b> " + sed);
|
||||||
|
sb.Append("<br> ");
|
||||||
|
string ind = !string.IsNullOrEmpty(d.IndirizzoSede) ? d.IndirizzoSede.Trim() : string.Empty;
|
||||||
|
sb.Append("<b>Indirizzo</b> " + ind);
|
||||||
|
sb.Append("<br> ");
|
||||||
|
item = sb.ToString();
|
||||||
|
sb = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
private Consegna fillConsegna(Consegna i, string token)
|
||||||
|
{
|
||||||
|
Consegna r = new Consegna();
|
||||||
|
|
||||||
|
string usr = getClaimValueByToken(token, "codice");
|
||||||
|
|
||||||
|
r.Piautist = usr;
|
||||||
|
r.Cprownum = i.Cprownum;
|
||||||
|
r.Ccddd = i.Ccddd;
|
||||||
|
r.cpccchk = i.cpccchk;
|
||||||
|
r.Ccda = i.Ccda;
|
||||||
|
r.Dcda = i.Dcda;
|
||||||
|
r.Pinotban = i.Pinotban;
|
||||||
|
r.Ccadd = i.Ccadd;
|
||||||
|
r.Ccda = i.Ccda;
|
||||||
|
r.Ccddd=i.Ccddd;
|
||||||
|
r.Datdoc= i.Datdoc;
|
||||||
|
r.Dcda=i.Dcda;
|
||||||
|
r.Descb=i.Descb;
|
||||||
|
r.Nbanc = i.Nbanc;
|
||||||
|
r.Ndoc = i.Ndoc;
|
||||||
|
r.Pibansca = i.Pibansca;
|
||||||
|
r.Pinotban = i.Pinotban;
|
||||||
|
r.Pinotimp = i.Pinotimp;
|
||||||
|
r.Tipob1 = i.Tipob1;
|
||||||
|
r.Tipob2 = i.Tipob2;
|
||||||
|
r.Tipob =i.Tipob;
|
||||||
|
r.Sdoc = i.Sdoc;
|
||||||
|
r.Serial = i.Serial;
|
||||||
|
r.Tcda=i.Tcda;
|
||||||
|
r.Tca = i.Tca;
|
||||||
|
r.Cca = i.Cca;
|
||||||
|
r.Dca = i.Dca;
|
||||||
|
r.Piconseg = i.Piconseg;
|
||||||
|
r.Pimezzo = i.Pimezzo;
|
||||||
|
r.Piimport= i.Piimport;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
private Consegna_out fillConsegna_out(Consegna i, string token)
|
||||||
|
{
|
||||||
|
Consegna_out r = new Consegna_out();
|
||||||
|
|
||||||
|
string usr = getClaimValueByToken(token, "codice");
|
||||||
|
|
||||||
|
r.Piautist = usr;
|
||||||
|
r.Cprownum = i.Cprownum;
|
||||||
|
r.Ccddd = i.Ccddd;
|
||||||
|
r.cpccchk = i.cpccchk;
|
||||||
|
r.Ccda = i.Ccda;
|
||||||
|
r.Dcda = i.Dcda;
|
||||||
|
r.Pinotban = i.Pinotban;
|
||||||
|
r.Ccadd = i.Ccadd;
|
||||||
|
r.Ccda = i.Ccda;
|
||||||
|
r.Ccddd = i.Ccddd;
|
||||||
|
r.Datdoc = i.Datdoc;
|
||||||
|
r.Dcda = i.Dcda;
|
||||||
|
r.Descb = i.Descb;
|
||||||
|
r.Nbanc = i.Nbanc;
|
||||||
|
r.Ndoc = i.Ndoc;
|
||||||
|
r.Pibansca = i.Pibansca;
|
||||||
|
r.Pinotban = i.Pinotban;
|
||||||
|
r.Pinotimp = i.Pinotimp;
|
||||||
|
r.Tipob1 = i.Tipob1;
|
||||||
|
r.Tipob2 = i.Tipob2;
|
||||||
|
r.Tipob = i.Tipob;
|
||||||
|
r.Sdoc = i.Sdoc;
|
||||||
|
r.Serial = i.Serial;
|
||||||
|
r.Tcda = i.Tcda;
|
||||||
|
r.Tca = i.Tca;
|
||||||
|
r.Cca = i.Cca;
|
||||||
|
r.Dca = i.Dca;
|
||||||
|
r.Piconseg = i.Piconseg;
|
||||||
|
r.Pimezzo = i.Pimezzo;
|
||||||
|
r.Piimport = i.Piimport;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
93
Controllers/LoginController.cs
Normal file
93
Controllers/LoginController.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using ApiSoftway.Models;
|
||||||
|
using ApiSoftway.Models.Gesa_DbContext;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class LoginController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<LoginController> _logger;
|
||||||
|
private readonly GESA_PERSONALE_DbContext _personale_context;
|
||||||
|
private DbSet<Personale>? _personale;
|
||||||
|
private readonly IConfiguration? _configuration;
|
||||||
|
public LoginController(ILogger<LoginController> logger, GESA_PERSONALE_DbContext personale_context, IConfiguration? configuration)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_personale_context = personale_context;
|
||||||
|
_configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Login iniziale return:ActionResult</summary>
|
||||||
|
[HttpPost("loginPersonale")]
|
||||||
|
public async Task<ActionResult<Login_out>> loginPersonale([FromBody] Login model)
|
||||||
|
{
|
||||||
|
Login_out o = new Login_out();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Username) || string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
o.err_detail = "Username e Password non possono essere vuoti.";
|
||||||
|
o.err_title = "Username e Password non possono essere vuoti.";
|
||||||
|
o.err_status_code = "200";
|
||||||
|
return StatusCode(StatusCodes.Status200OK, o);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_personale = _personale_context.Personale;
|
||||||
|
var pers=await _personale.Where(t=> t.Tcuser!=null && t.Tcuser.Equals(model.Username)&& t.Tcpwd!=null && t.Tcpwd.Equals(model.Password)).Take(1).ToListAsync();
|
||||||
|
|
||||||
|
if (pers == null || (pers != null && pers.Count == 0))
|
||||||
|
{
|
||||||
|
o.err_detail = "Username o Password non trovati.";
|
||||||
|
o.err_title = "Username o Password non trovati.";
|
||||||
|
o.err_status_code = "404";
|
||||||
|
return StatusCode(StatusCodes.Status404NotFound, o);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var authClaims = new List<Claim>
|
||||||
|
{
|
||||||
|
//new Claim(ClaimTypes.Name, model.Username),
|
||||||
|
new Claim(ClaimTypes.Name,pers.First().Tcuser),
|
||||||
|
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
|
||||||
|
new Claim("user", pers.First().Tcuser),
|
||||||
|
new Claim("codice", pers.First().Catcodice),
|
||||||
|
new Claim("nome", pers.First().Catnome),
|
||||||
|
};
|
||||||
|
var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["JWT:Secret"]));
|
||||||
|
var token = new JwtSecurityToken(
|
||||||
|
issuer: _configuration["JWT:ValidIssuer"],
|
||||||
|
audience: _configuration["JWT:ValidAudience"],
|
||||||
|
expires: DateTime.Now.AddMonths(3),
|
||||||
|
claims: authClaims,
|
||||||
|
signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256)
|
||||||
|
);
|
||||||
|
string tok = new JwtSecurityTokenHandler().WriteToken(token);
|
||||||
|
o.Tok = tok;
|
||||||
|
o.Tccodice = pers.First().Catcodice;
|
||||||
|
o.Tcruolo = pers.First().Tcruolo;
|
||||||
|
o.Tcdescri = pers.First().Catnome;
|
||||||
|
return StatusCode(StatusCodes.Status200OK, o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string err = "Errore: " + ex.Message;
|
||||||
|
o.err_detail = err;
|
||||||
|
o.err_title = err;
|
||||||
|
o.err_status_code = "200";
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, o);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
121
Controllers/TokenController.cs
Normal file
121
Controllers/TokenController.cs
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
using ApiSoftway.Models;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class TokenController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<LoginController> _logger;
|
||||||
|
private readonly IConfiguration? _configuration;
|
||||||
|
private readonly TOKEN_DbContext _token_context;
|
||||||
|
public TokenController(ILogger<LoginController> logger, IConfiguration? configuration, TOKEN_DbContext token_context)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_configuration = configuration;
|
||||||
|
_token_context = token_context;
|
||||||
|
}
|
||||||
|
private Token fillTokenByInput(string tokenDevice, string tokenLogin)
|
||||||
|
{
|
||||||
|
Token r = new Token();
|
||||||
|
|
||||||
|
string ten = "GESA";
|
||||||
|
string tecnico = getClaimValueByToken(tokenLogin, "codice");
|
||||||
|
|
||||||
|
r.tenant = ten;
|
||||||
|
r.usr = tecnico;
|
||||||
|
r.token = tokenDevice;
|
||||||
|
r.ts = DateTime.Now;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
private string getClaimValueByToken(string token, string claimName)
|
||||||
|
{
|
||||||
|
string t = string.Empty;
|
||||||
|
|
||||||
|
var handler = new JwtSecurityTokenHandler();
|
||||||
|
var jwtSecurityToken = handler.ReadJwtToken(token);
|
||||||
|
if (jwtSecurityToken != null)
|
||||||
|
{
|
||||||
|
var id = jwtSecurityToken.Claims.First(claim => claim.Type == claimName).Value;
|
||||||
|
t = id;
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
[Route("add")]
|
||||||
|
public async Task<ActionResult<Token_out>> addToken(string tokenDevice, string token)
|
||||||
|
{
|
||||||
|
Token_out t = new Token_out();
|
||||||
|
bool da_inserire = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Token> co = new List<Token>();
|
||||||
|
if (_token_context is not null && _token_context.tok is not null)
|
||||||
|
{
|
||||||
|
co = await _token_context.tok.Where(c => c.token.Equals(tokenDevice)).ToListAsync();
|
||||||
|
}
|
||||||
|
Token inp = fillTokenByInput(tokenDevice, token);
|
||||||
|
|
||||||
|
if (co.Count == 0)
|
||||||
|
{
|
||||||
|
da_inserire = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//il token c'è. controllo che sia associato all'utente corretto
|
||||||
|
//string ten = getClaimValueByToken(token, "tenant");
|
||||||
|
string ten = "GESA";
|
||||||
|
string tecnico = getClaimValueByToken(token, "tccodice");
|
||||||
|
|
||||||
|
bool token_corretto_presente = false;
|
||||||
|
foreach (Token tt in co)
|
||||||
|
{
|
||||||
|
if (tt.usr is not null && tt.usr.Equals(tecnico) && tt.tenant is not null && tt.tenant.Equals(ten))
|
||||||
|
{
|
||||||
|
token_corretto_presente = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (var transaction = _token_context.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
Token entitasViewModel = _token_context.tok.Where(p => p.Id == tt.Id).FirstOrDefault();
|
||||||
|
_token_context.Entry(entitasViewModel).State = EntityState.Deleted;
|
||||||
|
await _token_context.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!token_corretto_presente)
|
||||||
|
da_inserire = true;
|
||||||
|
}
|
||||||
|
if (da_inserire)
|
||||||
|
{
|
||||||
|
using (var transaction = _token_context.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
await _token_context.tok.AddAsync(inp);
|
||||||
|
await _token_context.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
t.err_status_code = "200";
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, t);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||||
|
t.err_title = ex.Message;
|
||||||
|
t.err_detail = errmsg;
|
||||||
|
t.err_status_code = "500";
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
40
Models/Consegna.cs
Normal file
40
Models/Consegna.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
public class Consegna
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string? Serial { get; set; }
|
||||||
|
|
||||||
|
[Key]
|
||||||
|
public int? Cprownum { get; set; }
|
||||||
|
public string? Tcda { get; set; }
|
||||||
|
public string? Ccda { get; set; }
|
||||||
|
public string? Dcda { get; set; }
|
||||||
|
public string? Tca { get; set; }
|
||||||
|
public string? Cca { get; set; }
|
||||||
|
public string? Dca { get; set; }
|
||||||
|
public string? Tipob { get; set; }
|
||||||
|
public int? Nbanc { get; set; }
|
||||||
|
public string? Descb { get; set; }
|
||||||
|
public string? Tipob1 { get; set; }
|
||||||
|
public string? Tipob2 { get; set; }
|
||||||
|
public string? Ccddd { get; set; }
|
||||||
|
public string? Ccadd { get; set; }
|
||||||
|
public string? Ndoc { get; set; }
|
||||||
|
public string? Sdoc { get; set; }
|
||||||
|
public DateTime? Datdoc { get; set; }
|
||||||
|
public string? cpccchk { get; set; }
|
||||||
|
public string? Piconseg { get; set; }
|
||||||
|
public string? Pimezzo { get; set; }
|
||||||
|
public string? Piautist { get; set; }
|
||||||
|
public int? Pibansca { get; set; }
|
||||||
|
|
||||||
|
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
||||||
|
public decimal? Piimport { get; set; }
|
||||||
|
public string? Pinotimp { get; set; }
|
||||||
|
public string? Pinotban { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
44
Models/Consegna_out.cs
Normal file
44
Models/Consegna_out.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
public class Consegna_out
|
||||||
|
{
|
||||||
|
public string? Serial { get; set; }
|
||||||
|
public int? Cprownum { get; set; }
|
||||||
|
public string? Tcda { get; set; }
|
||||||
|
public string? Ccda { get; set; }
|
||||||
|
public string? Dcda { get; set; }
|
||||||
|
public string? Tca { get; set; }
|
||||||
|
public string? Cca { get; set; }
|
||||||
|
public string? Dca { get; set; }
|
||||||
|
public string? Tipob { get; set; }
|
||||||
|
public int? Nbanc { get; set; }
|
||||||
|
public string? Descb { get; set; }
|
||||||
|
public string? Tipob1 { get; set; }
|
||||||
|
public string? Tipob2 { get; set; }
|
||||||
|
public string? Ccddd { get; set; }
|
||||||
|
public string? Ccadd { get; set; }
|
||||||
|
public string? Ndoc { get; set; }
|
||||||
|
public string? Sdoc { get; set; }
|
||||||
|
public DateTime? Datdoc { get; set; }
|
||||||
|
public string? cpccchk { get; set; }
|
||||||
|
public string? Piconseg { get; set; }
|
||||||
|
public string? Pimezzo { get; set; }
|
||||||
|
public string? Piautist { get; set; }
|
||||||
|
public int? Pibansca { get; set; }
|
||||||
|
|
||||||
|
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
||||||
|
public decimal? Piimport { get; set; }
|
||||||
|
public string? Pinotimp { get; set; }
|
||||||
|
public string? Pinotban { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>errore titolo</summary>
|
||||||
|
public string? err_title { get; set; }
|
||||||
|
/// <summary>errore dettaglio</summary>
|
||||||
|
public string? err_detail { get; set; }
|
||||||
|
/// <summary>errore status code (200, 500)</summary>
|
||||||
|
public string? err_status_code { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Models/Destinazioni.cs
Normal file
36
Models/Destinazioni.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
[Keyless]
|
||||||
|
public class Destinazioni
|
||||||
|
{
|
||||||
|
public string? CodAutomezzo { get; set; }
|
||||||
|
public string? DescAutomezzo { get; set; }
|
||||||
|
public string? Brserial { get; set; }
|
||||||
|
public DateTime? DataCarico { get; set; }
|
||||||
|
public string? CodCommittente { get; set; }
|
||||||
|
public string? Committente { get; set; }
|
||||||
|
public string? CodAutista { get; set; }
|
||||||
|
public string? Autista { get; set; }
|
||||||
|
public string? CodSede { get; set; }
|
||||||
|
public string? Sede { get; set; }
|
||||||
|
public string? IndirizzoSede { get; set; }
|
||||||
|
public int? Cproword { get; set; }
|
||||||
|
public string? Brmerce { get; set; }
|
||||||
|
public string? Brnote { get; set; }
|
||||||
|
|
||||||
|
public string? consFattaSerial { get; set; }
|
||||||
|
public int? consFattaRow { get; set; }
|
||||||
|
public int? consFattaBanCar { get; set; }
|
||||||
|
public int? consFattaBanSca { get; set; }
|
||||||
|
public string? consFattaMezzo { get; set; }
|
||||||
|
public string? consFattaAut { get; set; }
|
||||||
|
|
||||||
|
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
||||||
|
public decimal? consFattaImpor { get; set; }
|
||||||
|
public string? consFattaNotImp { get; set; }
|
||||||
|
public string? consFattaNotBan { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
39
Models/Destinazioni_out.cs
Normal file
39
Models/Destinazioni_out.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
[Keyless]
|
||||||
|
public class Destinazioni_out
|
||||||
|
{
|
||||||
|
public string? CodAutomezzo { get; set; }
|
||||||
|
public string? DescAutomezzo { get; set; }
|
||||||
|
public string? Brserial { get; set; }
|
||||||
|
public DateTime? DataCarico { get; set; }
|
||||||
|
public string? CodCommittente { get; set; }
|
||||||
|
public string? Committente { get; set; }
|
||||||
|
public string? CodAutista { get; set; }
|
||||||
|
public string? Autista { get; set; }
|
||||||
|
public string? CodSede { get; set; }
|
||||||
|
public string? Sede { get; set; }
|
||||||
|
public string? IndirizzoSede { get; set; }
|
||||||
|
public int? Cproword { get; set; }
|
||||||
|
public string? Brmerce { get; set; }
|
||||||
|
public string? Brnote { get; set; }
|
||||||
|
public string? ItemList { get; set; }
|
||||||
|
public ConsegnaFatta? ConsFatta { get; set; }
|
||||||
|
}
|
||||||
|
public class ConsegnaFatta
|
||||||
|
{
|
||||||
|
public string? consFattaSerial { get; set; }
|
||||||
|
public int? consFattaRow { get; set; }
|
||||||
|
public int? consFattaBanCar { get; set; }
|
||||||
|
public int? consFattaBanSca { get; set; }
|
||||||
|
public string? consFattaMezzo { get; set; }
|
||||||
|
public string? consFattaAut { get; set; }
|
||||||
|
|
||||||
|
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 5)")]
|
||||||
|
public decimal? consFattaImpor { get; set; }
|
||||||
|
public string? consFattaNotImp { get; set; }
|
||||||
|
public string? consFattaNotBan { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Models/Gesa_DbContext/GESA_CONSEGNE_DbContext.cs
Normal file
25
Models/Gesa_DbContext/GESA_CONSEGNE_DbContext.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models.Gesa_DbContext
|
||||||
|
{
|
||||||
|
public class GESA_CONSEGNE_DbContext : DbContext
|
||||||
|
{
|
||||||
|
/// <summary></summary>
|
||||||
|
public DbSet<Consegna>? Cons { get; set; }
|
||||||
|
|
||||||
|
/// <summary></summary>
|
||||||
|
public GESA_CONSEGNE_DbContext(DbContextOptions<GESA_CONSEGNE_DbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary></summary>
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<Consegna>().ToTable("GESASMOVIB");
|
||||||
|
modelBuilder.Entity<Consegna>().HasKey(table => new {
|
||||||
|
table.Serial,
|
||||||
|
table.Cprownum
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Models/Gesa_DbContext/GESA_DESTINAZIONI_DbContext.cs
Normal file
17
Models/Gesa_DbContext/GESA_DESTINAZIONI_DbContext.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models.Gesa_DbContext
|
||||||
|
{
|
||||||
|
public class GESA_DESTINAZIONI_DbContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<Destinazioni>? Destinazioni { get; set; }
|
||||||
|
public GESA_DESTINAZIONI_DbContext(DbContextOptions<GESA_DESTINAZIONI_DbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<Destinazioni>().ToView("API_DESTINAZIONI");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
16
Models/Gesa_DbContext/GESA_GIRI_DbContext.cs
Normal file
16
Models/Gesa_DbContext/GESA_GIRI_DbContext.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models.Gesa_DbContext
|
||||||
|
{
|
||||||
|
public class GESA_GIRI_DbContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<Giri>? Giri { get; set; }
|
||||||
|
public GESA_GIRI_DbContext(DbContextOptions<GESA_GIRI_DbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<Giri>().ToView("API_GIRI");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Models/Gesa_DbContext/GESA_PERSONALE_DbContext.cs
Normal file
16
Models/Gesa_DbContext/GESA_PERSONALE_DbContext.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models.Gesa_DbContext
|
||||||
|
{
|
||||||
|
public class GESA_PERSONALE_DbContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<Personale>? Personale { get; set; }
|
||||||
|
public GESA_PERSONALE_DbContext(DbContextOptions<GESA_PERSONALE_DbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<Personale>().ToView("API_PERSONALE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Models/Giri.cs
Normal file
14
Models/Giri.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
[Keyless]
|
||||||
|
public class Giri
|
||||||
|
{
|
||||||
|
public DateTime? Brdatcar { get; set; }
|
||||||
|
public string? Brautist { get; set; }
|
||||||
|
public string? Autista { get; set; }
|
||||||
|
public int? num_dest { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Models/Giri_out.cs
Normal file
12
Models/Giri_out.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
public class Giri_out
|
||||||
|
{
|
||||||
|
public DateTime? Brdatcar { get; set; }
|
||||||
|
public string? Brautist { get; set; }
|
||||||
|
public string? Autista { get; set; }
|
||||||
|
public int? num_dest { get; set; }
|
||||||
|
|
||||||
|
public string? ItemList { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Models/Login.cs
Normal file
12
Models/Login.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
public class Login
|
||||||
|
{
|
||||||
|
/// <summary>Username</summary>
|
||||||
|
public string? Username { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Password</summary>
|
||||||
|
public string? Password { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Models/Login_out.cs
Normal file
26
Models/Login_out.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
public class Login_out
|
||||||
|
{
|
||||||
|
/// <summary>token</summary>
|
||||||
|
public string? Tok { get; set; }
|
||||||
|
|
||||||
|
/// <summary>token</summary>
|
||||||
|
public string? Tccodice { get; set; }
|
||||||
|
|
||||||
|
/// <summary>token</summary>
|
||||||
|
public string? Tcdescri { get; set; }
|
||||||
|
|
||||||
|
/// <summary>ruolo</summary>
|
||||||
|
public string? Tcruolo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Error Message</summary>
|
||||||
|
public string? err_title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Error Message detail</summary>
|
||||||
|
public string? err_detail { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Status</summary>
|
||||||
|
public string? err_status_code { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Models/Personale.cs
Normal file
17
Models/Personale.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
[Keyless]
|
||||||
|
public class Personale
|
||||||
|
{
|
||||||
|
public string? Catcodice { get; set; } = null;
|
||||||
|
public string? Catnome { get; set; } = null;
|
||||||
|
public string? Cattelefono { get; set; } = null;
|
||||||
|
public string? Catcellulare { get; set; } = null;
|
||||||
|
public string? Tcuser { get; set; } = null;
|
||||||
|
public string? Tcpwd { get; set; } = null;
|
||||||
|
public string? Tcruolo { get; set; } = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Models/TOKEN_DbContext.cs
Normal file
20
Models/TOKEN_DbContext.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
public class TOKEN_DbContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<Token>? tok { get; set; }
|
||||||
|
|
||||||
|
/// <summary>ConfigurazioniDbContext</summary>
|
||||||
|
public TOKEN_DbContext(DbContextOptions<TOKEN_DbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/// <summary>OnModelCreating</summary>
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<Token>().ToTable("Token");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Models/Token.cs
Normal file
25
Models/Token.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
public class Token
|
||||||
|
{
|
||||||
|
/// <summary>id</summary>
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>tenant azienda</summary>
|
||||||
|
public string? tenant { get; set; }
|
||||||
|
|
||||||
|
/// <summary>utente login</summary>
|
||||||
|
public string? usr { get; set; }
|
||||||
|
|
||||||
|
/// <summary>token device</summary>
|
||||||
|
public string? token { get; set; }
|
||||||
|
|
||||||
|
/// <summary>timestamp inserimento</summary>
|
||||||
|
public DateTime? ts { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Models/Token_out.cs
Normal file
29
Models/Token_out.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
namespace ApiSoftway.Models
|
||||||
|
{
|
||||||
|
public class Token_out
|
||||||
|
{
|
||||||
|
/// <summary>tenant azienda</summary>
|
||||||
|
public string? tenant { get; set; }
|
||||||
|
|
||||||
|
/// <summary>utente login</summary>
|
||||||
|
public string? usr { get; set; }
|
||||||
|
|
||||||
|
/// <summary>token device</summary>
|
||||||
|
public string? token { get; set; }
|
||||||
|
|
||||||
|
/// <summary>timestamp inserimento</summary>
|
||||||
|
public DateTime? ts { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Error Message </summary>
|
||||||
|
public string? err_title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Error Message detail</summary>
|
||||||
|
public string? err_detail { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Status</summary>
|
||||||
|
public string? err_status_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>response</summary>
|
||||||
|
public string? response { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
53
Program.cs
Normal file
53
Program.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using ApiSoftway.Models.Gesa_DbContext;
|
||||||
|
using ApiSoftway.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
const int commandTimeoutInSeconds = 300;
|
||||||
|
|
||||||
|
#region Istaze Dbcontext
|
||||||
|
builder.Services.AddDbContext<TOKEN_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("ApiStr")
|
||||||
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
|
));
|
||||||
|
|
||||||
|
builder.Services.AddDbContext<GESA_PERSONALE_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||||
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
|
));
|
||||||
|
builder.Services.AddDbContext<GESA_GIRI_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||||
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
|
));
|
||||||
|
builder.Services.AddDbContext<GESA_DESTINAZIONI_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||||
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
|
));
|
||||||
|
builder.Services.AddDbContext<GESA_CONSEGNE_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||||
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
|
));
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (app.Environment.IsDevelopment() || app.Environment.IsProduction())
|
||||||
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
//app.Run();
|
||||||
|
app.Run("http://localhost:6000");
|
||||||
31
Properties/launchSettings.json
Normal file
31
Properties/launchSettings.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:58993",
|
||||||
|
"sslPort": 44389
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"ApiSoftway": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "https://localhost:7126;http://localhost:5127",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
appsettings.Development.json
Normal file
20
appsettings.Development.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//,
|
||||||
|
//"AllowedHosts": "*",
|
||||||
|
//"Kestrel": {
|
||||||
|
// "Endpoints": {
|
||||||
|
// "Http": {
|
||||||
|
// "Url": "http://localhost:5400"
|
||||||
|
// },
|
||||||
|
// "Https": {
|
||||||
|
// "Url": "https://localhost:5401"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
19
appsettings.json
Normal file
19
appsettings.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
|
||||||
|
"GESA": "Data Source=10.0.0.10;Initial Catalog=AHRGESA;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": {
|
||||||
|
"ValidAudience": "http://localhost:4200",
|
||||||
|
"ValidIssuer": "http://localhost:61955",
|
||||||
|
"Secret": "ByYM000OLlMQG6VVVp1OH7Xzyr7gHuw1qvUC5dcGt3SNM"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user