ApiSoftway/Program.cs
2025-03-21 14:51:34 +01:00

116 lines
6.0 KiB
C#

using ApiSoftway.Models.Gesa_DbContext;
using ApiSoftway.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.OpenApi.Models;
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); }
));
builder.Services.AddDbContext<GESA_CLIENTI_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_GIRICONSEGNE_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_GIRICONSEGNEVISTA_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_SBR_ORD_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_GIRICONSEGNEDACREARE_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_MODGIR_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
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); }
));
builder.Services.AddDbContext<GESA_SEDECONSEGNA_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_PI_GIRI_SERIALI_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_DESTINAZIONI_WEB_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_GIRI_TESTATE_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_SBR_ORD_TABLE_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(gen =>
{
gen.ResolveConflictingActions(apiDescription => apiDescription.First());
//gen.SwaggerDoc("v1", new OpenApiInfo { Title = "POLO API WS2016", Version = "v3.3" });
DateTime oggi = DateTime.Now;
string dt = oggi.ToString();
gen.SwaggerDoc("v1", new OpenApiInfo { Title = "GESA API - v.app 1.1", Version = dt });
});
builder.Services.AddLogging(opt =>
{
opt.AddConsole(c =>
{
c.TimestampFormat = "[yyyy-MM-dd HH:mm:ss] ";
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment() || app.Environment.IsProduction())
{
app.UseSwagger();
app.UseSwaggerUI();
}
//app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.MapControllers();
app.Run();
//app.Run("http://localhost:6000");