//services.AddMvc().AddXmlSerializerFormatters(); // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); IConfigurationSection jwtAppSettings = Configuration.GetSection("Jwt"); services.Configure <JwtSetting>(jwtAppSettings); services.AddCors(options => { options.AddPolicy("CorsPolicy", p => p.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddDistributedMemoryCache(); services.AddSession(); #region Swagger Configuration SwaggerHandler.SwaggerConfig(services); services.AddApiVersioning(); #endregion Swagger Configuration //#region Jwt Configuration //JwtConfigurationHandler.ConfigureJwtAuthentication(services, jwtAppSettings); //#endregion Jwt Configuration #region Context SQL Server services.AddDbContext <Infraestructure.Core.Context.SQLServer.ContextSql>(options => options.UseSqlServer(Configuration.GetConnectionString("ConnectionStringSQLServer"), providerOptions => providerOptions.EnableRetryOnFailure())); #endregion Context SQL Server #region Register (dependency injection) DependencyInyectionHandler.DependencyInyectionConfig(services); #endregion Register (dependency injection) #region Job #endregion }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); IConfigurationSection jwtAppSettings = Configuration.GetSection("Jwt"); services.Configure <JwtSetting>(jwtAppSettings); services.AddCors(options => { options.AddPolicy("CorsPolicy", p => p.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddDistributedMemoryCache(); services.AddSession(); #region Swagger Configuration SwaggerHandler.SwaggerConfig(services); #endregion #region Jwt Configuration JwtConfigurationHandler.ConfigureJwtAuthentication(services, jwtAppSettings); #endregion #region Context #region Oracle services.AddDbContext <Infraestructure.Core.Context.Context>(options => options.UseOracle(Configuration.GetConnectionString("ConnectionStringOracle"))); #endregion //#region SQL //services.AddEntityFrameworkSqlServer() // .AddDbContext<Infraestructure.Core.Context.Context>(options => // { // options.UseSqlServer(Configuration.GetConnectionString("ConnectionStringSQLServer"), // sqlOptions => sqlOptions.MigrationsAssembly(typeof(Startup) // .GetTypeInfo() // .Assembly.GetName().Name)); // }, // ServiceLifetime.Scoped); //#endregion #endregion #region Register (dependency injection) DependencyInyectionHandler.DependencyInyectionConfig(services); #endregion ////#region Job ////// Add Quartz services singleton //services.AddSingleton<IJobFactory, JobFactory>(); //services.AddSingleton<ISchedulerFactory, StdSchedulerFactory>(); //// Add our job //// services.AddSingleton<Job>(); //services.AddSingleton<Job>(); //services.AddSingleton(new JobScheduleModel( // jobType: typeof(Job), // cronExpression: "0/20 * * * * ?")); // run every 5 seconds // // 0/10 * * * * ? * run every 10 seconds //// Configure job actions //services.AddHostedService<HostedService>(); ////#endregion }