Ejemplo n.º 1
0
        public void Setup()
        {
            // These were the actual URLs specified in the initial implemenatation of web chat
            var chatInclude = new [] {
                "/contactus/",
                "/roadsandtransport/roads/default.htm",
                "/roadsandtransport/roads/roadworks/",
                "/roadsandtransport/roads/maintenance/",
                "/roadsandtransport/roads/contactus/",
                "/roadsandtransport/roads/roadadoption/",
                "/roadsandtransport/roads/roadsafety/",
                "/roadsandtransport/bexhillhastingslinkroad/",
                "/roadsandtransport/roads/roadschemes/uckfieldtransport/",
                "/community/emergencyplanningandcommunitysafety/emergencyplanning/advice/flooding/",
                "/leisureandtourism/countryside/rightsofway/",
                "/leisureandtourism/localandfamilyhistory/",
                "/libraries/activities-and-events/library-volunteers/",
                "/libraries/elibrary/howtouse/",
                "/libraries/find/",
                "/libraries/reference/",
                "/environment/rubbishandrecycling/recyclingsites/",
                "/environment/woodlands/dutchelms/",
                "/socialcare/aboutus/contact.htm",
                "/socialcare/aboutus/complaints/default.htm",
                "/socialcare/gettinghelp/default.htm",
                "/socialcare/gettinghelp/apply/",
                "/socialcare/gettinghelp/eligibility/",
                "/socialcare/disability/learning/contacts/socialcaredirect.htm"
            };

            var chatExclude = new[] {
                "/contactus/apply/default.htm",
                "/contactus/pay/",
                "/contactus/languages.htm",
                "/contactus/interpreting.htm",
                "/libraries/find/northiam/default.htm",
                "/libraries/find/rotherfield/default.htm",
                "/libraries/find/sedlescombe/default.htm"
            };

            _model = new WebChatSettings();
            foreach (var url in chatInclude)
            {
                _model.WebChatUrls.Add(new Uri(url, UriKind.Relative));
            }
            foreach (var url in chatExclude)
            {
                _model.ExcludedUrls.Add(new Uri(url, UriKind.Relative));
            }
        }
        /// <summary>
        /// Reads web chat configuration from the provided or default <see cref="IWebChatSettingsService"/>. The result is cached for the lifetime of this instance.
        /// </summary>
        /// <returns>Web chat settings, or <c>null</c> if the <see cref="IWebChatSettingsService"/> was not configured</returns>
        public async Task <WebChatSettings> RequestWebChatSettingsAsync()
        {
            if (_webChatSettings != null)
            {
                return(_webChatSettings);
            }

            if (_webChatSettingsService != null)
            {
                _webChatSettings = await _webChatSettingsService.ReadWebChatSettings().ConfigureAwait(false);

                _webChatSettings.PageUrl = new Uri(_request.Url.AbsolutePath, UriKind.Relative);
                return(_webChatSettings);
            }
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads the web chat settings
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">content</exception>
        public Task <WebChatSettings> ReadWebChatSettings()
        {
            if (_content == null)
            {
                throw new ArgumentNullException("content");
            }

            var model = new WebChatSettings
            {
                PageUrl = new Uri(_content.Url, UriKind.RelativeOrAbsolute)
            };

            var webChatSettings = _content.AncestorOrSelf(1).Siblings().FirstOrDefault(sibling => sibling.DocumentTypeAlias == "WebChat");

            if (webChatSettings == null)
            {
                return(System.Threading.Tasks.Task.FromResult(model));
            }

            ((List <Uri>)model.WebChatUrls).AddRange(_targetUrlReader.ReadUrls(webChatSettings, "whereToDisplayIt_Content", "whereElseToDisplayIt_Content"));
            ((List <Uri>)model.ExcludedUrls).AddRange(_targetUrlReader.ReadUrls(webChatSettings, "whereToExclude_Content", "whereElseToExclude_Content"));
            return(System.Threading.Tasks.Task.FromResult(model));
        }