// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IIdentitySeed storageSeed, IMasterDataCacheOperations masterDataCacheOperations, ILogDataOperations logDataOperations, INavigationCacheOperations navigationCacheOperations) { loggerFactory.AddConsole(); // Configure Azure Logger to log all events except the one which are generated by default by ASP.NET Core. loggerFactory.AddAzureTableStorageLog(logDataOperations, (categoryName, logLevel) => !categoryName.Contains("Microsoft") && logLevel >= LogLevel.Information); if (env.IsDevelopment()) { // app.UseDeveloperExceptionPage(); // app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { // app.UseExceptionHandler("/Home/Error"); } var options = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(options.Value); app.UseStatusCodePagesWithRedirects("/Home/Error/{0}"); app.UseSession(); app.UseStaticFiles(); app.UseIdentity(); app.UseGoogleAuthentication(new GoogleOptions() { ClientId = Configuration["Google:Identity:ClientId"], ClientSecret = Configuration["Google:Identity:ClientSecret"] }); app.UseMvc(routes => { routes.MapRoute(name: "areaRoute", template: "{area:exists}/{controller=Home}/{action=Index}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseWebSockets(); app.UseSignalR(); await storageSeed.Seed(app.ApplicationServices.GetService <UserManager <ApplicationUser> >(), app.ApplicationServices.GetService <RoleManager <IdentityRole> >(), app.ApplicationServices.GetService <IOptions <ApplicationSettings> >()); await masterDataCacheOperations.CreateMasterDataCacheAsync(); await navigationCacheOperations.CreateNavigationCacheAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env, IUnitOfWork unitOfWork, IMasterDataCacheOperations masterDataCacheOperations, ILogDataOperations logDataOperations) { // Configure Azure Logger to log all events except the ones that are generated by default by ASP.NET Core loggerFactory.AddAzureTableStorageLog(logDataOperations, (categoryName, logLevel) => !categoryName.Contains("Microsoft") && logLevel >= LogLevel.Information); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { //app.UseExceptionHandler("/Home/Error"); } app.UseStatusCodePagesWithRedirects("~/Home/Error/{0}"); app.UseStaticFiles(); app.UseAuthentication(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); var models = Assembly.Load(new AssemblyName("ASC.Models")).GetTypes().Where(type => type.Namespace == "ASC.Models.Models"); foreach (var model in models) { var repository = Activator.CreateInstance(typeof(Repository <>).MakeGenericType(model), unitOfWork); MethodInfo method = typeof(Repository <>).MakeGenericType(model).GetMethod("CreateTableAsync"); method.Invoke(repository, null); } await masterDataCacheOperations.CreateMasterDataCache(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IIdentitySeed storageSeed, IMasterDataCacheOperations masterDataCacheOperations, ILogDataOperations logDataOperations, INavigationCacheOperations navigationCacheOperations, IUnitOfWork unitOfWork) { loggerFactory.AddConsole(); // Configure Azure Logger to log all events except the one which are generated by default by ASP.NET Core. loggerFactory.AddAzureTableStorageLog(logDataOperations, (categoryName, logLevel) => !categoryName.Contains("Microsoft") && logLevel >= LogLevel.Information); if (env.IsDevelopment()) { // app.UseDeveloperExceptionPage(); // app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { // app.UseExceptionHandler("/Home/Error"); } var options = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(options.Value); app.UseStatusCodePagesWithRedirects("/Home/Error/{0}"); app.UseSession(); app.UseStaticFiles(); app.UseIdentity(); app.UseGoogleAuthentication(new GoogleOptions() { ClientId = Configuration["Google:Identity:ClientId"], ClientSecret = Configuration["Google:Identity:ClientSecret"] }); app.UseMvc(routes => { routes.MapRoute(name: "areaRoute", template: "{area:exists}/{controller=Home}/{action=Index}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseWebSockets(); app.UseSignalR(); await storageSeed.Seed(app.ApplicationServices.GetService <UserManager <ApplicationUser> >(), app.ApplicationServices.GetService <RoleManager <IdentityRole> >(), app.ApplicationServices.GetService <IOptions <ApplicationSettings> >()); var models = Assembly.Load(new AssemblyName("ASC.Models")).GetTypes().Where(type => type.Namespace == "ASC.Models.Models"); foreach (var model in models) { var repositoryInstance = Activator.CreateInstance(typeof(Repository <>).MakeGenericType(model), unitOfWork); MethodInfo method = typeof(Repository <>).MakeGenericType(model).GetMethod("CreateTableAsync"); method.Invoke(repositoryInstance, new object[0]); } await masterDataCacheOperations.CreateMasterDataCacheAsync(); await navigationCacheOperations.CreateNavigationCacheAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IIdentitySeed storageSeed, ILogDataOperations logDataOperations, IUnitOfWork unitOfWork, INavigationCacheOperations navigationCacheOperations ) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); // Configure Azure Logger to log all events except the ones that are generated by default by ASP.NET Core. loggerFactory.AddAzureTableStorageLog(logDataOperations, (categoryName, logLevel) => !categoryName.Contains("Microsoft") && logLevel >= LogLevel.Information); if (env.IsDevelopment()) { //app.UseDeveloperExceptionPage(); //app.UseDatabaseErrorPage(); //app.UseBrowserLink(); } else { //app.UseExceptionHandler("/Home/Error"); } app.UseStatusCodePagesWithRedirects("/Home/Error/{0}"); app.UseSession(); app.UseStaticFiles(); app.UseAuthentication(); app.UseCors(builder => { builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().AllowCredentials(); }); app.UseMvc(routes => { routes.MapRoute(name: "areaRoute", template: "{area:exists}/{controller=Home}/{action=Index}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); using (var scope = app.ApplicationServices.CreateScope()) { //Resolve ASP .NET Core Identity with DI help var userManager = (UserManager <ApplicationUser>)scope.ServiceProvider.GetService(typeof(UserManager <ApplicationUser>)); var roleManager = (RoleManager <ApplicationRole>)scope.ServiceProvider.GetService(typeof(RoleManager <ApplicationRole>)); var options = (IOptions <ApplicationSettings>)scope.ServiceProvider.GetService(typeof(IOptions <ApplicationSettings>)); await storageSeed.Seed(userManager, roleManager, options); // do you things here } var models = Assembly.Load(new AssemblyName("ASC.Models")).GetTypes().Where(type => type.Namespace == "ASC.Models.Models"); foreach (var model in models) { var repositoryInstance = Activator.CreateInstance(typeof(Repository <>).MakeGenericType(model), unitOfWork); MethodInfo method = typeof(Repository <>).MakeGenericType(model).GetMethod("CreateTableAsync"); method.Invoke(repositoryInstance, new object[0]); } //await masterDataCacheOperations.CreateMasterDataCacheAsync(); await navigationCacheOperations.CreateNavigationCacheAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IUnitOfWork unitOfWork, ILoggerFactory loggerFactory, IMasterDataCacheOperations masterDataCacheOperations, ILogDataOperations logDataOperations, INavigationCacheOperations navigationCacheOperations) { var configBuilder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", false, true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", false, true); configBuilder.AddEnvironmentVariables(); Configuration = configBuilder.Build(); loggerFactory.AddAzureTableStorageLog(logDataOperations, (categoryName, logLevel) => !categoryName.Contains("Microsoft") && logLevel >= LogLevel.Information); if (env.IsDevelopment()) { /*Handle exceptions using Global Exception filter*/ //app.UseDeveloperExceptionPage(); //app.UseDatabaseErrorPage(); } else { //app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseSession(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); //app.UseEndpoints(endpoints => //{ // endpoints.MapAreaControllerRoute(name: "areas", areaName: "areas", "{area:exists}/{controller=Home}/{action=Index}"); // endpoints.MapControllerRoute( // name: "default", // pattern: "{controller=Home}/{action=Index}/{id?}"); // endpoints.MapRazorPages(); //}); app.UseMvc(routes => { routes.MapRoute(name: "areaRoute", template: "{area:exists}/{controller=Home}/{action=Index}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseWebSockets(); app.UseSignalR(routes => { routes.MapHub <ServiceMessagesHub>("/ServiceMessagesHub"); }); var models = Assembly.Load(new AssemblyName("ASC.Models")).GetTypes().Where(t => t.Namespace.Equals("ASC.Models.Models")); foreach (var model in models) { var repositoryInstance = Activator.CreateInstance(typeof(Repository <>).MakeGenericType(model), unitOfWork); MethodInfo methodInfo = typeof(Repository <>).MakeGenericType(model).GetMethod("CreateTableAsync"); methodInfo.Invoke(repositoryInstance, new object[0]); } masterDataCacheOperations.CreateMasterDataCacheAsync(); navigationCacheOperations.CreateNavigationMenuCacheAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure( IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, IIdentitySeed storageSeed, IMasterDataCacheOperations masterDataCacheOperations, ILogDataOperations logDataOperations, INavigationCacheOperations navigationCacheOperations, IUnitOfWork unitOfWork) { // Configure Azure Logger to log all events except the ones that are generated by default by ASP.NET Core. loggerFactory.AddAzureTableStorageLog(logDataOperations, (categoryName, logLevel) => !categoryName.Contains("Microsoft") && logLevel >= LogLevel.Information); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseStatusCodePagesWithRedirects("/Home/Error/{0}"); app.UseSession(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "areaRoute", pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"); endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); //Create a scope to resolve dependencies registered as scoped using (var scope = app.ApplicationServices.CreateScope()) { //Resolve ASP .NET Core Identity with DI help var userManager = (UserManager <ApplicationUser>)scope.ServiceProvider.GetService(typeof(UserManager <ApplicationUser>)); var roleManager = (RoleManager <IdentityRole>)scope.ServiceProvider.GetService(typeof(RoleManager <IdentityRole>)); var options = (IOptions <ApplicationSettings>)scope.ServiceProvider.GetService(typeof(IOptions <ApplicationSettings>)); // do you things here await storageSeed.Seed(userManager, roleManager, options); } var models = Assembly.Load(new AssemblyName("ASC.Models")).GetTypes().Where(type => type.Namespace == "ASC.Models.Models"); foreach (var model in models) { var repositoryInstance = Activator.CreateInstance(typeof(Repository <>). MakeGenericType(model), unitOfWork); MethodInfo method = typeof(Repository <>).MakeGenericType(model).GetMethod("CreateTableAsync"); method.Invoke(repositoryInstance, new object[0]); } await masterDataCacheOperations.CreateMasterDataCacheAsync(); await navigationCacheOperations.CreateNavigationCacheAsync(); }