Beispiel #1
0
        private void ClearPageCache(Guid siteId, Guid pageId)
        {
            foreach (var language in _languageFacade.GetAllActiveAsync(siteId).Result)
            {
                _cacheManager.Remove(string.Format(CacheKeys.PageInfoCacheKey, siteId, pageId, language.Id));
            }

            _cacheManager.Remove(string.Format(CacheKeys.PageInfoCacheKey, siteId, pageId, Guid.Empty));
        }
Beispiel #2
0
        private void ClearCache(Guid siteId, Guid moduleId)
        {
            foreach (var language in _languageFacade.GetAllActiveAsync(siteId).Result)
            {
                _cacheManager.Remove(string.Format(CacheKeys.TextModuleCacheKey, moduleId, language.Id));
            }

            _cacheManager.Remove(string.Format(CacheKeys.TextModuleCacheKey, moduleId, Guid.Empty));
        }
Beispiel #3
0
        private void ClearCache(Guid siteId, string name)
        {
            foreach (var language in _languageFacade.GetAllActiveAsync(siteId).Result)
            {
                _cacheManager.Remove(string.Format(CacheKeys.MenuCacheKey, siteId, name, language.Id));
            }

            _cacheManager.Remove(string.Format(CacheKeys.MenuCacheKey, siteId, name, Guid.Empty));
        }
Beispiel #4
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)
        {
            membershipInstallationService.VerifyUserCreation();
            appInstallationService.VerifyAppInstallation();
            siteInstallationService.VerifySiteInstallation();

            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.GetAllActiveAsync(site.Id).Result;

            app.AddRoutes();
            app.AddLocalisation(activeLanguages);
        }
Beispiel #5
0
        public LanguageInfo GetCurrentLanguageInfo()
        {
            return(GetInfo(LanguageInfoKey, () =>
            {
                var languages = _languageFacade.GetAllActiveAsync(GetCurrentSiteInfo().Id).Result;
                var userCoockie = _httpContextAccessor.HttpContext.Request.Cookies[CookieRequestCultureProvider.DefaultCookieName];

                if (!string.IsNullOrEmpty(userCoockie))
                {
                    var userCulture = userCoockie.Split('|')[0].Split('=')[1];

                    var userLanguage = languages.FirstOrDefault(x => x.CultureName == userCulture);

                    if (userLanguage != null)
                    {
                        return userLanguage;
                    }
                }

                return languages.Any() ? languages.FirstOrDefault() : new LanguageInfo();
            }));
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public async Task <IActionResult> Get()
        {
            var languages = await _languageFacade.GetAllActiveAsync(SiteId);

            return(Ok(languages));
        }
Beispiel #8
0
        public async Task <IViewComponentResult> InvokeAsync(string viewName = "Default")
        {
            var languages = await Task.Run(() => _languageFacade.GetAllActiveAsync(SiteId));

            return(View(viewName, languages));
        }