Beispiel #1
0
        void SendPage(String rsrcHtml, String rsrcScript, String serverInfo = null, String errorMessage = null)
        {
            try
            {
                AntiForgery.GetTokens(null, out String cookieToken, out String formToken);

                AppTitleModel appTitle = _dbContext.Load <AppTitleModel>(_host.CatalogDataSource, "a2ui.[AppTitle.Load]");

                var layoutHtml = _host.Mobile ? ResourceHelper.InitLayoutMobileHtml : ResourceHelper.InitLayoutHtml;

                StringBuilder layout = new StringBuilder(_localizer.Localize(null, GetRedirectedPage("layout", layoutHtml)));
                layout.Replace("$(Lang)", _userLocale.Language);
                StringBuilder html = new StringBuilder(rsrcHtml);
                layout.Replace("$(Partial)", html.ToString());
                layout.Replace("$(Title)", appTitle?.AppTitle);
                layout.Replace("$(ErrorMessage)", _localizer.Localize(null, errorMessage));
                layout.Replace("$(SiteMeta)", Request.GetSiteMetaTags(_host));
                _host.ReplaceMacros(layout, "applink");

                String mtMode  = _host.IsMultiTenant.ToString().ToLowerInvariant();
                String regMode = _host.IsRegistrationEnabled.ToString().ToLowerInvariant();

                StringBuilder script = new StringBuilder(rsrcScript);
                script.Replace("$(Utils)", ResourceHelper.PageUtils);
                script.Replace("$(Locale)", ResourceHelper.LocaleLibrary(_userLocale.Language));
                script.Replace("$(Mask)", ResourceHelper.Mask);
                script.Replace("$(AvailableLocales)", AvalableLocales());
                script.Replace("$(UserEmail)", Session[USERNAME_SESSIONKEY]?.ToString());

                script.Replace("$(PageData)", $"{{ version: '{_host.AppVersion}', title: '{appTitle?.AppTitle}', subtitle: '{appTitle?.AppSubTitle}', multiTenant: {mtMode}, registration: {regMode} }}");
                script.Replace("$(AppLinks)", _localizer.Localize(null, _host.AppLinks()));
                script.Replace("$(AppData)", _host.GetAppData(_localizer, _userLocale));
                script.Replace("$(ServerInfo)", serverInfo ?? "null");
                script.Replace("$(Token)", formToken);
                layout.Replace("$(PageScript)", script.ToString());

                Response.Cookies.Add(new HttpCookie(AntiForgeryConfig.CookieName, cookieToken));

                Response.Write(layout.ToString());
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Beispiel #2
0
        async Task SendPage(String pageContent)
        {
            AppTitleModel appTitle = await _dbContext.LoadAsync <AppTitleModel>(_host.CatalogDataSource, "a2ui.[AppTitle.Load]");

            StringBuilder layout = new StringBuilder(_localizer.Localize(null, ResourceHelper.InitLayoutHtml));

            layout.Replace("$(Lang)", CurrentLang);
            layout.Replace("$(LayoutScripts)", _host.CustomAppScripts());
            layout.Replace("$(Partial)", pageContent);
            layout.Replace("$(Title)", appTitle.AppTitle);
            layout.Replace("$(SiteMeta)", Request.GetSiteMetaTags(_host));
            _host.ReplaceMacros(layout, "applink");

            StringBuilder script = new StringBuilder(ResourceHelper.AppLinksScript);

            script.Replace("$(PageData)", $"{{ version: '{_host.AppVersion}', title: '{appTitle?.AppTitle}', subtitle: '{appTitle?.AppSubTitle}', multiTenant: false, registation: false }}");
            script.Replace("$(Locale)", ResourceHelper.LocaleLibrary(_userLocale.Language));
            script.Replace("$(Utils)", ResourceHelper.PageUtils);
            script.Replace("$(AppLinks)", _localizer.Localize(null, _host.AppLinks()));
            script.Replace("$(AppData)", _host.GetAppData(_localizer, _userLocale));
            layout.Replace("$(PageScript)", script.ToString());

            Response.Write(layout.ToString());
        }