using ApiPolo.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
using ApiPolo.Services;
using ApiPolo.Models.VT_dbcontext;
using ApiPolo.Interfaces;
namespace ApiPolo
{
/// Startup
public class Startup
{
/// Configuration
public IConfiguration Configuration { get; }
/// Startup
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
/// ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
try
{
const int commandTimeoutInSeconds = 300;
services.AddControllers();
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("ApiStr")));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("ApiStr")));
#region VIRTUAL TASK
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
#endregion
//TEST
//services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("MARAS")
// , options => { options.CommandTimeout(commandTimeoutInSeconds); }
// ));
//services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("MARRO")
// , options => { options.CommandTimeout(commandTimeoutInSeconds); }
// ));
// FACTORY MUTI-TENANT
services.AddScoped();
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(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);
}
}
/// Configure:This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
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();
}
}
}