Example #1
0
        // 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();
        }
 public ServiceRequestController(IServiceRequestOperations serviceRequestOperations,
                                 IMapper mapper, IMasterDataCacheOperations masterData, UserManager <ApplicationUser> userManager)
 {
     _serviceRequestOperations = serviceRequestOperations;
     _mapper      = mapper;
     _masterData  = masterData;
     _userManager = userManager;
 }
 public DashboardController(IOptions <ApplicationSettings> settings,
                            IServiceRequestOperations serviceRequestOperations,
                            IMasterDataCacheOperations masterData)
 {
     _settings = settings;
     _serviceRequestOperations = serviceRequestOperations;
     _masterData = masterData;
 }
Example #4
0
 public PromotionsController(IPromotionOperations promotionOperations,
                             IMapper mapper,
                             IMasterDataCacheOperations masterData,
                             IConnectionManager signalRConnectionManager)
 {
     _promotionOperations = promotionOperations;
     _mapper     = mapper;
     _masterData = masterData;
     _signalRConnectionManager = signalRConnectionManager;
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              IMasterDataCacheOperations masterDataCacheOperations,
                              ILoggerFactory loggerFactory,
                              ILogDataOperations logDataOperations,
                              INavigationCacheOperations navigationCacheOperations)
        {
            // Configure MongoDb Logger to log all events except the ones that are generated by
            // default by ASP.NET Core.
            loggerFactory.AddAzureTableStorageMongoDbLog(logDataOperations,
                                                         (categoryName, logLevel) => !categoryName.Contains("Microsoft") &&
                                                         logLevel >= LogLevel.Information);

            if (env.IsDevelopment())
            {
                //app.UseDeveloperExceptionPage();
                //app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            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.UseHttpsRedirection();
            app.UseSession();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

            // Redis Cache
            masterDataCacheOperations.CreateMasterDataCacheAsync();

            // Menu to Cache
            navigationCacheOperations.CreateNavigationCacheAsync();
        }
 public ServiceRequestController(IServiceRequestOperations operations,
                                 IMapper mapper,
                                 IMasterDataCacheOperations masterData,
                                 UserManager <ApplicationUser> userManager,
                                 IEmailSender emailSender, IServiceRequestMessageOperations serviceRequestMessageOperations, IConnectionManager signalRConnectionManager, IOptions <ApplicationSettings> options, IOnlineUsersOperations onlineUsersOperations)
 {
     _serviceRequestOperations = operations;
     _mapper      = mapper;
     _masterData  = masterData;
     _userManager = userManager;
     _emailSender = emailSender;
     _serviceRequestMessageOperations = serviceRequestMessageOperations;
     _signalRConnectionManager        = signalRConnectionManager;
     _options = options;
     _onlineUsersOperations = onlineUsersOperations;
 }
        // 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();
        }
Example #8
0
 public MasterDataController(IMasterDataOperations masterData, IMapper mapper, IMasterDataCacheOperations masterDataCache)
 {
     _masterData      = masterData;
     _mapper          = mapper;
     _masterDataCache = masterDataCache;
 }
Example #9
0
 public DashboardController(IServiceRequestOperations operations, IMasterDataCacheOperations masterData)
 {
     _serviceRequestOperations = operations;
     _masterData = masterData;
 }
Example #10
0
        // 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();
        }
 public DashboardController(IServiceRequestOperations serviceRequestOperations, IMasterDataCacheOperations masterDataCacheOperations)
 {
     this._serviceRequestOperations  = serviceRequestOperations;
     this._masterDataCacheOperations = masterDataCacheOperations;
 }
        // 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();
        }