208 lines
12 KiB
C#
208 lines
12 KiB
C#
using ApiPolo.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.OpenApi.Models;
|
|
using ApiPolo.Services;
|
|
using ApiPolo.Models.VT_dbcontext;
|
|
using ApiPolo.Interfaces;
|
|
|
|
namespace ApiPolo
|
|
{
|
|
/// <summary>Startup</summary>
|
|
public class Startup
|
|
{
|
|
/// <summary>Configuration</summary>
|
|
public IConfiguration Configuration { get; }
|
|
/// <summary>Startup</summary>
|
|
public Startup(IConfiguration configuration)
|
|
{
|
|
Configuration = configuration;
|
|
}
|
|
/// <summary>ConfigureServices</summary>
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
try
|
|
{
|
|
const int commandTimeoutInSeconds = 300;
|
|
services.AddControllers();
|
|
services.AddDbContext<ConfigurazioniDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ApiStr")));
|
|
services.AddDbContext<TokenDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ApiStr")));
|
|
|
|
#region VIRTUAL TASK
|
|
services.AddDbContext<VT_TECNICI_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_TECNICI_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_CHIUSURE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_CHIUSURE_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_CONTI_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_CONTI_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_RAPP_NEW_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_RAPP_NEW_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_IMPIANTI_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_IMPIANTI_MANAGER_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_IMPIANTI_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_CHIAMATE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_CHIAMATE_MANAGER_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_CHIAMATE_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_PROGRESSIVI_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_AZIENDA_RIF_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_REGISTRAZIONE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_AZIENDE_PRESENTI_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_COMMESSE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_COMMESSE_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_DATI_AZIENDA_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_RAPPORTINI_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_Buoni_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_STO_RAPP_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_TIMBRATURE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_TIMBRATURE_VW_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_COMMESSE_APP_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_ARTICOLI_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_MAG_NEW_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_SALDIART_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_MAGAZZINI_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
services.AddDbContext<VT_CODICE_SEGNALAZIONE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
|
));
|
|
|
|
#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
|
|
services.AddScoped<ITenantDbContextFactory, TenantDbContextFactory>();
|
|
|
|
|
|
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 = "API VIRTUAL TASK - v.app 1.34", Version = dt });
|
|
|
|
var filePath = Path.Combine(System.AppContext.BaseDirectory, "ApiPolo.xml");
|
|
gen.IncludeXmlComments(filePath);
|
|
});
|
|
|
|
//services.AddCronJob<MyCronJob1>(c =>
|
|
//{
|
|
// c.TimeZoneInfo = TimeZoneInfo.Local;
|
|
// //c.CronExpression = @"*/10 * * * *";
|
|
|
|
// c.CronExpression = @"* * * * *";
|
|
//});
|
|
|
|
services.AddLogging(opt =>
|
|
{
|
|
opt.AddConsole(c =>
|
|
{
|
|
c.TimestampFormat = "[yyyy-MM-dd HH:mm:ss] ";
|
|
});
|
|
});
|
|
|
|
}
|
|
catch (Exception ex) {
|
|
Console.WriteLine(ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>Configure:This method gets called by the runtime. Use this method to configure the HTTP request pipeline. </summary>
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
if (env.IsDevelopment() || env.IsProduction())
|
|
{
|
|
//app.UseDeveloperExceptionPage();
|
|
app.UseSwagger();
|
|
//app.UseSwaggerUI();
|
|
app.UseSwaggerUI(c =>
|
|
{
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "POLO API virtualtask");
|
|
|
|
});
|
|
//app.UseHttpsRedirection();
|
|
}
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapControllers();
|
|
});
|
|
app.UseStaticFiles();
|
|
}
|
|
}
|
|
}
|