Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              ILoggerFactory loggerFactory,
                              ISiteInstallationService siteInstallationService,
                              IAppInstallationService appInstallationService,
                              IMembershipInstallationService membershipInstallationService,
                              ISiteRepository siteRepository,
                              ILanguageFacade languageFacade,
                              IPageFacade pageFacade)
        {
            appInstallationService.VerifyAppInstallation();
            siteInstallationService.VerifySiteInstallation();
            membershipInstallationService.VerifyUserCreation();

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseStatusCodePagesWithRedirects("~/error/{0}");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/error/500");
            }

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715

            var site            = siteRepository.GetByName("Default");
            var activeLanguages = languageFacade.GetAllActive(site.Id);
            var pages           = pageFacade.GetAllForAdminAsync(site.Id).Result;

            app.AddRoutes(site, activeLanguages, pages);
            app.AddLocalisation(activeLanguages);
        }
Beispiel #2
0
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment hostingEnvironment,
                              ILoggerFactory loggerFactory,
                              ISiteInstallationService siteInstallationService,
                              IThemeInstallationService themeInstallationService,
                              ISiteRepository siteRepository,
                              IQueryDispatcher queryDispatcher)
        {
            app.EnsureDbCreated();
            app.EnsureIdentityCreatedAsync();

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseStatusCodePagesWithRedirects("~/error/{0}");

            if (hostingEnvironment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/error/500");
            }

            app.UseTheme();

            app.UseStaticFiles();

            foreach (var theme in queryDispatcher.DispatchAsync <GetActiveThemes, IEnumerable <ThemeInfo> >(new GetActiveThemes()).Result)
            {
                var contentPath = Path.Combine(hostingEnvironment.ContentRootPath, "Themes", theme.Folder, "wwwroot");
                if (Directory.Exists(contentPath))
                {
                    app.UseStaticFiles(new StaticFileOptions {
                        RequestPath  = "/Themes/" + theme.Folder,
                        FileProvider = new PhysicalFileProvider(contentPath)
                    });
                }
            }

            foreach (var appDescriptor in AppLoader.Instance(hostingEnvironment).AppDescriptors)
            {
                var contentPath = Path.Combine(hostingEnvironment.ContentRootPath, "Apps", appDescriptor.Folder, "wwwroot");
                if (Directory.Exists(contentPath))
                {
                    app.UseStaticFiles(new StaticFileOptions {
                        RequestPath  = "/" + appDescriptor.Folder,
                        FileProvider = new PhysicalFileProvider(contentPath)
                    });
                }
            }

            foreach (var startup in AppLoader.Instance(hostingEnvironment).AppAssemblies.GetImplementationsOf <Mvc.Apps.IStartup>())
            {
                startup.Configure(app);
            }

            var applicationPartManager = app.ApplicationServices.GetRequiredService <ApplicationPartManager>();

            Parallel.ForEach(AppLoader.Instance(hostingEnvironment).AppAssemblies, assembly => {
                applicationPartManager.ApplicationParts.Add(new AssemblyPart(assembly));
            });

            app.UseIdentity();

            themeInstallationService.EnsureThemeInstalled(new CreateTheme {
                Name = "Default", Description = "Default Theme", Folder = "Default"
            });
            siteInstallationService.VerifySiteInstallation();

            var site            = siteRepository.GetByName("Default");
            var activeLanguages = queryDispatcher.DispatchAsync <GetAllActive, IEnumerable <LanguageInfo> >(new GetAllActive {
                SiteId = site.Id
            }).Result;

            app.AddRoutes();
            app.AddLocalisation(activeLanguages);
        }
Beispiel #3
0
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment hostingEnvironment,
                              ILoggerFactory loggerFactory,
                              ISiteInstallationService siteInstallationService,
                              IAppInstallationService appInstallationService,
                              IMembershipInstallationService membershipInstallationService,
                              ISiteRepository siteRepository,
                              ILanguageFacade languageFacade,
                              IPageFacade pageFacade)
        {
            membershipInstallationService.VerifyUserCreation();
            appInstallationService.VerifyAppInstallation();
            siteInstallationService.VerifySiteInstallation();

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseStatusCodePagesWithRedirects("~/error/{0}");

            if (hostingEnvironment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/error/500");
            }

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            foreach (var appDescriptor in AppLoader.Instance(hostingEnvironment).AppDescriptors)
            {
                var contentPath = Path.Combine(hostingEnvironment.ContentRootPath, "Apps", appDescriptor.Folder, "wwwroot");
                if (Directory.Exists(contentPath))
                {
                    app.UseStaticFiles(new StaticFileOptions
                    {
                        RequestPath  = "/" + appDescriptor.Folder,
                        FileProvider = new PhysicalFileProvider(contentPath)
                    });
                }
            }

            foreach (var startup in AppLoader.Instance(hostingEnvironment).AppAssemblies.GetTypes <Mvc.Apps.IStartup>())
            {
                startup.Configure(app);
            }

            var applicationPartManager = app.ApplicationServices.GetRequiredService <ApplicationPartManager>();

            Parallel.ForEach(AppLoader.Instance(hostingEnvironment).AppAssemblies, assembly =>
            {
                applicationPartManager.ApplicationParts.Add(new AssemblyPart(assembly));
            });

            app.UseIdentity();

            var site            = siteRepository.GetByName("Default");
            var activeLanguages = languageFacade.GetAllActiveAsync(site.Id).Result;

            app.AddRoutes();
            app.AddLocalisation(activeLanguages);
        }