Пример #1
0
        /// <summary>
        /// Reads the HTML controls required for the website template. The result is cached for the lifetime of this instance.
        /// </summary>
        /// <returns></returns>
        public async Task <TemplateHtml> RequestTemplateHtmlAsync()
        {
            if (_templateHtml != null)
            {
                return(_templateHtml);
            }

            var textSize = _textSize?.CurrentTextSize();

            if (textSize == null)
            {
                textSize = 1;
            }
            var isLibraryCatalogueRequest = _libraryContext?.RequestIsFromLibraryCatalogueMachine() ?? false;

            _templateHtml = new TemplateHtml();
            var applicationId = String.IsNullOrEmpty(_request.PathBase.ToString()) ? "/" : _request.PathBase.ToString();

            if (_esccWebsiteView == EsccWebsiteView.Desktop)
            {
                var htmlTagTask     = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "HtmlTag", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);
                var metadataTask    = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "MetadataDesktop", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);
                var aboveHeaderTask = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "AboveHeaderDesktop", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);
                var headerTask      = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "HeaderDesktop", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);
                var footerTask      = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "FooterDesktop", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);
                var scriptsTask     = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "ScriptsDesktop", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);

                var results = await Task.WhenAll(htmlTagTask, metadataTask, aboveHeaderTask, headerTask, footerTask, scriptsTask).ConfigureAwait(false);

                _templateHtml.HtmlTag     = new HtmlString(results[0]);
                _templateHtml.Metadata    = new HtmlString(results[1]);
                _templateHtml.AboveHeader = new HtmlString(results[2]);
                _templateHtml.Header      = new HtmlString(results[3]);
                _templateHtml.Footer      = new HtmlString(results[4]);
                _templateHtml.Scripts     = new HtmlString(results[5]);
            }
            else if (_esccWebsiteView == EsccWebsiteView.FullScreen)
            {
                var htmlTagTask  = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "HtmlTag", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);
                var metadataTask = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "MetadataFullScreen", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);
                var headerTask   = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "HeaderFullScreen", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);
                var scriptsTask  = _htmlProvider.FetchHtmlForControl(applicationId, _requestUrl, "ScriptsFullScreen", _breadcrumbProvider, textSize.Value, isLibraryCatalogueRequest);

                var results = await Task.WhenAll(htmlTagTask, metadataTask, headerTask, scriptsTask).ConfigureAwait(false);

                _templateHtml.HtmlTag  = new HtmlString(results[0]);
                _templateHtml.Metadata = new HtmlString(results[1]);
                _templateHtml.Header   = new HtmlString(results[2]);
                _templateHtml.Scripts  = new HtmlString(results[3]);
            }
            return(_templateHtml);
        }
        /// <summary>
        /// Reads the HTML controls required for the website template. The result is cached for the lifetime of this instance.
        /// </summary>
        /// <returns></returns>
        public async Task <TemplateHtml> RequestTemplateHtmlAsync()
        {
            if (_templateHtml != null)
            {
                return(_templateHtml);
            }

            var textSize = _textSize.CurrentTextSize();
            var isLibraryCatalogueRequest = _libraryContext.RequestIsFromLibraryCatalogueMachine();

            _templateHtml = new TemplateHtml();
            if (_esccWebsiteView == EsccWebsiteView.Desktop)
            {
                var htmlTagTask     = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "HtmlTag", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);
                var metadataTask    = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "MetadataDesktop", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);
                var aboveHeaderTask = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "AboveHeaderDesktop", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);
                var headerTask      = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "HeaderDesktop", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);
                var footerTask      = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "FooterDesktop", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);
                var scriptsTask     = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "ScriptsDesktop", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);

                var results = await Task.WhenAll(htmlTagTask, metadataTask, aboveHeaderTask, headerTask, footerTask, scriptsTask).ConfigureAwait(false);

                _templateHtml.HtmlTag     = new HtmlString(results[0]);
                _templateHtml.Metadata    = new HtmlString(results[1]);
                _templateHtml.AboveHeader = new HtmlString(results[2]);
                _templateHtml.Header      = new HtmlString(results[3]);
                _templateHtml.Footer      = new HtmlString(results[4]);
                _templateHtml.Scripts     = new HtmlString(results[5]);
            }
            else if (_esccWebsiteView == EsccWebsiteView.FullScreen)
            {
                var htmlTagTask  = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "HtmlTag", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);
                var metadataTask = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "MetadataFullScreen", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);
                var headerTask   = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "HeaderFullScreen", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);
                var scriptsTask  = _htmlProvider.FetchHtmlForControl(HttpRuntime.AppDomainAppVirtualPath, _request.Url, "ScriptsFullScreen", _breadcrumbProvider, textSize, isLibraryCatalogueRequest);

                var results = await Task.WhenAll(htmlTagTask, metadataTask, headerTask, scriptsTask).ConfigureAwait(false);

                _templateHtml.HtmlTag  = new HtmlString(results[0]);
                _templateHtml.Metadata = new HtmlString(results[1]);
                _templateHtml.Header   = new HtmlString(results[2]);
                _templateHtml.Scripts  = new HtmlString(results[3]);
            }
            return(_templateHtml);
        }