protected void Page_Load(object sender, EventArgs e) { SetupCanonicalUrls(DictionaryURL, DictionaryURL); GetDefinitionTerm(); ValidateCDRID(); DictionaryURL = this.DictionaryRouter.GetBaseURL(); DictionaryLanguage = PageAssemblyContext.Current.PageAssemblyInstruction.Language; DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); DictionaryTerm dataItem = _dictionaryAppManager.GetTerm(Convert.ToInt32(CdrID), NCI.Web.Dictionary.DictionaryType.term, DictionaryLanguage, "v1"); if (dataItem != null && dataItem.Term != null) { ActivateDefinitionView(dataItem); currentItem = dataItem; // Web Analytics ************************************************* if (WebAnalyticsOptions.IsEnabled) { // Set analytics for definition view page load SetAnalytics(); } } else { termDictionaryDefinitionView.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { SetupCanonicalUrl(this.DictionaryRouter.GetBaseURL()); GetDefinitionTerm(); ValidateCDRID(); //For Genetics dictionary language is always English DictionaryLanguage = "en"; DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); DictionaryTerm dataItem = _dictionaryAppManager.GetTerm(Convert.ToInt32(CdrID), NCI.Web.Dictionary.DictionaryType.genetic, DictionaryLanguage, "v1"); if (dataItem != null && dataItem.Term != null) { ActivateDefinitionView(dataItem); currentItem = dataItem; // Web Analytics ************************************************* if (WebAnalyticsOptions.IsEnabled) { // Set analytics for definition view page load SetAnalytics(); } PageInstruction.AddFieldFilter("browser_title", (name, data) => { data.Value = "Definition of " + dataItem.Term + " - NCI Dictionary of Genetics Terms"; }); } else { termDictionaryDefinitionView.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); // Check if dictionary terms list size is cached; if so, set to TotalCount if (HttpContext.Current.Cache.Get("totalcount") != null) { TotalCount = (string)HttpContext.Current.Cache.Get("totalcount"); } // If it isn't, get the current size, save that in the cache, and set to TotalCount else { DictionarySearchResultCollection resultCollection = _dictionaryAppManager.Search("%", SearchType.Begins, 0, int.MaxValue, NCI.Web.Dictionary.DictionaryType.term, PageAssemblyContext.Current.PageAssemblyInstruction.Language); if (resultCollection != null) { TotalCount = resultCollection.ResultsCount.ToString("N0"); } HttpContext.Current.Cache.Add("totalcount", TotalCount, null, DateTime.Now.AddMinutes(60), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null); } //set visibilty for the English versus Spanish text if (PageAssemblyContext.Current.PageAssemblyInstruction.Language == "es") { pnlIntroEnglish.Visible = false; pnlIntroSpanish.Visible = true; } else { pnlIntroEnglish.Visible = true; pnlIntroSpanish.Visible = false; } }
private void LoadData() { DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); SearchType searchType = SearchType.Begins; if (BContains) searchType = SearchType.Contains; DictionarySearchResultCollection resultCollection = null; // Translate page number into offset. // One less than the current page number (with sanity check), times the page size // translates from a "first page is 1" page number to a "first record is zero" offset into the // list of results. int offset = ((CurrentPageIndex > 0 ? CurrentPageIndex : 1) - 1) * PageSize; if (!String.IsNullOrEmpty(SearchStr)) // SearchString provided, do a term search { SearchStr = Sanitizer.GetSafeHtmlFragment(SearchStr); resultCollection = _dictionaryAppManager.Search(SearchStr, searchType, offset, PageSize, NCI.Web.Dictionary.DictionaryType.drug, PageAssemblyContext.Current.PageAssemblyInstruction.Language); } if (resultCollection != null && resultCollection.Count() > 0) { //if there is only 1 record - go directly to definition view //check if expand equals "A", as this is the default value if (resultCollection.ResultsCount == 1) { // Get the first (only) item so we can redirect to it specifically IEnumerator<DictionarySearchResult> itemPtr = resultCollection.GetEnumerator(); itemPtr.MoveNext(); string urlItem = GetFriendlyName(itemPtr.Current.ID.ToString()); string itemDefinitionUrl = this.DictionaryRouter.GetDefinitionUrl() + urlItem; Page.Response.Redirect(itemDefinitionUrl); } else { resultListView.DataSource = resultCollection; resultListView.DataBind(); NumResults = resultCollection.ResultsCount; lblWord.Text = SearchStr.Replace("[[]", "["); lblNumResults.Text = NumResults.ToString(); if (NumResults == 0) { RenderNoResults(); } } } else { RenderNoResults(); } }
private void LoadData() { DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); SearchType searchType = SearchType.Begins; if (BContains) { searchType = SearchType.Contains; } DictionarySearchResultCollection resultCollection = null; if (!String.IsNullOrEmpty(SearchStr)) // SearchString provided, do a term search { SearchStr = Sanitizer.GetSafeHtmlFragment(SearchStr); resultCollection = _dictionaryAppManager.Search(SearchStr, searchType, 0, int.MaxValue, NCI.Web.Dictionary.DictionaryType.term, PageAssemblyContext.Current.PageAssemblyInstruction.Language); } if (resultCollection != null && resultCollection.Count() > 0) { //if there is only 1 record - go directly to definition view if (resultCollection.ResultsCount == 1) { // Get the first (only) item so we can redirect to it specifically IEnumerator <DictionarySearchResult> itemPtr = resultCollection.GetEnumerator(); itemPtr.MoveNext(); string urlItem = GetFriendlyName(itemPtr.Current.ID.ToString()); string itemDefinitionUrl = this.DictionaryRouter.GetDefinitionUrl() + urlItem; Page.Response.Redirect(itemDefinitionUrl); } else { resultListView.DataSource = resultCollection; resultListView.DataBind(); NumResults = resultCollection.ResultsCount; lblWord.Text = SearchStr.Replace("[[]", "["); lblNumResults.Text = NumResults.ToString(); if (NumResults == 0) { RenderNoResults(); } } } else { RenderNoResults(); } }
protected void Page_Load(object sender, EventArgs e) { string input_term; if (PageAssemblyContext.Current.DisplayVersion == DisplayVersions.Web) { urlArgs = Request.Url.Query.Substring(1); input_term = Strings.Clean(Request.Params["term"]); CdrID = Strings.IfNull(Strings.Clean(Request.Params["id"]), Strings.Clean(Request.Params["cdrid"])); AudienceType audience = GetAudienceType(Strings.Clean(Request.Params["version"])); DictionaryType dictionary = GetDictionaryType(Strings.Clean(Request.Params["dictionary"])); //load the definition DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); DictionaryTerm dataItem = null; if (!string.IsNullOrEmpty(CdrID)) { CdrID = Regex.Replace(CdrID, "^CDR0+", "", RegexOptions.Compiled); // call appropriate method if dictionary type is known // the language is set to English = en by default if (dictionary == DictionaryType.Unknown) { dataItem = _dictionaryAppManager.GetTermForAudience(Convert.ToInt32(CdrID), dictionaryLanguage, "v1", audience); } else { dataItem = _dictionaryAppManager.GetTerm(Convert.ToInt32(CdrID), dictionary, dictionaryLanguage, "v1", audience); } } if (dataItem != null && dataItem.Term != null) { ActivateDefinitionView(dataItem); } else { phDefinition.Visible = false; phNoResult.Visible = true; } // Web Analytics ************************************************* WebAnalyticsPageLoad webAnalyticsPageLoad = new WebAnalyticsPageLoad(); webAnalyticsPageLoad.SetChannel("Dictionary of Cancer Terms"); webAnalyticsPageLoad.SetLanguage("en"); webAnalyticsPageLoad.AddEvent(WebAnalyticsOptions.Events.event11); // Dictionary Term view (event11) litOmniturePageLoad.Text = webAnalyticsPageLoad.Tag(); // Load page load script // End Web Analytics ********************************************* } }
private void LoadData() { DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); SearchType searchType = SearchType.Begins; if (BContains) { searchType = SearchType.Contains; } DictionarySearchResultCollection resultCollection = null; // Translate page number into offset. // One less than the current page number (with sanity check), times the page size // translates from a "first page is 1" page number to a "first record is zero" offset into the // list of results. int offset = ((CurrentPageIndex > 0 ? CurrentPageIndex : 1) - 1) * PageSize; if (!String.IsNullOrEmpty(Expand)) // A-Z expand provided - do an A-Z search { string searchText; if (Expand.ToLower() == "all") { searchText = "%"; } else { searchText = Expand; } string filter = GetDrugDictionaryFilter(); resultCollection = _dictionaryAppManager.Expand(searchText, filter, offset, PageSize, NCI.Web.Dictionary.DictionaryType.drug, PageAssemblyContext.Current.PageAssemblyInstruction.Language, "v1"); } if (resultCollection != null && resultCollection.Count() > 0) { resultListView.DataSource = resultCollection; resultListView.DataBind(); NumResults = resultCollection.ResultsCount; lblWord.Text = Expand.Replace("[[]", "["); lblNumResults.Text = NumResults.ToString(); if (NumResults == 0) { RenderNoResults(); } } else { RenderNoResults(); } }
private void LoadData() { DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); SearchType searchType = SearchType.Begins; if (BContains) { searchType = SearchType.Contains; } DictionarySearchResultCollection resultCollection = null; if (!String.IsNullOrEmpty(Expand)) // A-Z expand provided - do an A-Z search { if (Expand.ToLower() == "all") { resultCollection = _dictionaryAppManager.Search("%", searchType, 0, int.MaxValue, NCI.Web.Dictionary.DictionaryType.term, PageAssemblyContext.Current.PageAssemblyInstruction.Language); } else { resultCollection = _dictionaryAppManager.Search(Expand, searchType, 0, int.MaxValue, NCI.Web.Dictionary.DictionaryType.term, PageAssemblyContext.Current.PageAssemblyInstruction.Language); } } if (resultCollection != null && resultCollection.Count() > 0) { resultListView.DataSource = resultCollection; resultListView.DataBind(); NumResults = resultCollection.ResultsCount; lblWord.Text = Expand.Replace("[[]", "["); lblNumResults.Text = NumResults.ToString(); if (NumResults == 0) { RenderNoResults(); } } else { RenderNoResults(); } }
/// <summary> /// Create a collection of URL elements from a CSV file of dictionary entries /// </summary> /// <returns>SitemapUrlSet</returns> public override SitemapUrlSet GetSitemapUrls(string sitemapName) { List <SitemapUrl> sitemapUrls = new List <SitemapUrl>(); try { _info = GetDictionariesInfo(); } catch (Exception ex) { log.Error("Error deserializing DictionariesConfig.xml file."); throw ex; } string path = _info.SitemapStore; if (path != null) { String file = HttpContext.Current.Server.MapPath(path); List <DictionaryEntryMetadata> entries = new List <DictionaryEntryMetadata>(); try { using (StreamReader sr = new StreamReader(file)) { string currentLine; // currentLine will be null when the StreamReader reaches the end of file while ((currentLine = sr.ReadLine()) != null) { string[] values = currentLine.Split(','); if (values.Length == 3) { try { DictionaryEntryMetadata entry = new DictionaryEntryMetadata(); int cdrid; bool validCDRID = int.TryParse(values[0], out cdrid); if (validCDRID) { entry.CDRID = cdrid; entry.Dictionary = (NCI.Services.Dictionary.DictionaryType)System.Enum.Parse(typeof(NCI.Services.Dictionary.DictionaryType), values[1]); entry.Language = (Language)System.Enum.Parse(typeof(Language), values[2]); entries.Add(entry); } else { log.ErrorFormat("Error in dictionary sitemap file for line {0} : invalid CDRID.", currentLine); continue; } } catch { log.ErrorFormat("Error in dictionary sitemap file {0} for line {1} : could not create dictionary entry metadata.", file, currentLine); continue; } } else { log.ErrorFormat("Error in dictionary sitemap file {0} for line {1} : invalid syntax.", file, currentLine); continue; } } // Check if these entries are valid in the DB. Returns a list of only the valid entries to be included in the sitemap. DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); entries = _dictionaryAppManager.DoDictionaryEntriesExist(entries); } } catch (Exception e) { log.ErrorFormat("Error in DictionarySitemapUrlStore: unable to read dictionary sitemap file located at {0}.", file); return(new SitemapUrlSet()); } foreach (DictionaryEntryMetadata entry in entries) { string dic = entry.Dictionary.ToString(); string lang = entry.Language.ToString(); DictionaryInfo entryInfo = _info.DictionaryInfos.First(i => i.Name == entry.Dictionary.ToString() && i.Language == entry.Language.ToString()); string entryUrl = GetSitemapUrl(entryInfo, entry.CDRID.ToString()); double priority = 0.5; sitemapUrls.Add(new SitemapUrl(entryUrl, sitemapChangeFreq.weekly, priority)); } return(new SitemapUrlSet(sitemapUrls)); } else { log.ErrorFormat("Could not load dictionary provider file located at {0}.", path); return(new SitemapUrlSet()); } }
protected void Page_Load(object sender, EventArgs e) { string input_term; if (PageAssemblyContext.Current.DisplayVersion == DisplayVersions.Web) { urlArgs = Request.Url.Query.Substring(1); input_term = Strings.Clean(Request.Params["term"]); CdrID = Strings.IfNull(Strings.Clean(Request.Params["id"]), Strings.Clean(Request.Params["cdrid"])); AudienceType audience = GetAudienceType(Strings.Clean(Request.Params["version"])); DictionaryType dictionary = GetDictionaryType(Strings.Clean(Request.Params["dictionary"])); if (Request.QueryString["language"] == "Spanish") { dictionaryLanguage = "es"; logoAnchor.HRef = "/espanol"; logoImage.Alt = "Instituto Nacional Del Cáncer"; logoImage.Src = "/publishedcontent/images/images/design-elements/logos/nci-logo-full-es.svg"; closeWindowText.InnerText = "Cerrar"; definitionLabel.Text = "Definición:"; } else { logoAnchor.HRef = "/"; logoImage.Alt = "National Cancer Institute"; logoImage.Src = "/publishedcontent/images/images/design-elements/logos/nci-logo-full.svg"; closeWindowText.InnerText = "Close Window"; definitionLabel.Text = "Definition:"; } //load the definition DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); DictionaryTerm dataItem = null; if (!string.IsNullOrEmpty(CdrID)) { CdrID = Regex.Replace(CdrID, "^CDR0+", "", RegexOptions.Compiled); // call appropriate method if dictionary type is known if (dictionary == DictionaryType.Unknown) { dataItem = _dictionaryAppManager.GetTermForAudience(Convert.ToInt32(CdrID), dictionaryLanguage, "v1", audience); } else { dataItem = _dictionaryAppManager.GetTerm(Convert.ToInt32(CdrID), dictionary, dictionaryLanguage, "v1", audience); } } if (dataItem != null && dataItem.Term != null) { ActivateDefinitionView(dataItem); } else { phDefinition.Visible = false; phNoResult.Visible = true; } // Web Analytics ************************************************* WebAnalyticsPageLoad webAnalyticsPageLoad = new WebAnalyticsPageLoad(); if (dictionaryLanguage == "es") { webAnalyticsPageLoad.SetChannel("Diccionario de cancer (Dictionary of Cancer Terms)"); webAnalyticsPageLoad.SetLanguage("es"); } else { webAnalyticsPageLoad.SetChannel("Dictionary of Cancer Terms"); webAnalyticsPageLoad.SetLanguage("en"); } webAnalyticsPageLoad.AddEvent(WebAnalyticsOptions.Events.event11); // Dictionary Term view (event11) litOmniturePageLoad.Text = webAnalyticsPageLoad.Tag(); // Load page load script // End Web Analytics ********************************************* } }
protected void Page_Load(object sender, EventArgs e) { GetQueryParams(); SetupCanonicalUrl(this.DictionaryRouter.GetBaseURL()); SetDoNotIndex(); if (!string.IsNullOrEmpty(SrcGroup)) { BContains = Convert.ToBoolean(SrcGroup); } this.dictionarySearchBlock.SearchBoxInputVal = HttpUtility.HtmlEncode(SearchStr); if (BContains == true) { this.dictionarySearchBlock.CheckRadioStarts = ""; this.dictionarySearchBlock.CheckRadioContains = "checked=\"checked\""; } //For Genetics dictionary language is always English DictionaryLanguage = "en"; DictionarySearchResultCollection resultCollection = null; DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); SearchType searchType = SearchType.Begins; if (BContains) { searchType = SearchType.Contains; } if (!String.IsNullOrEmpty(SearchStr)) // SearchString provided, do a term search { SearchStr = Sanitizer.GetSafeHtmlFragment(SearchStr); resultCollection = _dictionaryAppManager.Search(SearchStr, searchType, 0, int.MaxValue, NCI.Web.Dictionary.DictionaryType.genetic, DictionaryLanguage); } if (resultCollection != null && resultCollection.Count() > 0) { //if there is only 1 record - go directly to definition view if (resultCollection.ResultsCount == 1) { // Get the first (only) item so we can redirect to it specifically IEnumerator <DictionarySearchResult> itemPtr = resultCollection.GetEnumerator(); itemPtr.MoveNext(); string urlItem = GetFriendlyName(itemPtr.Current.ID.ToString()); string itemDefinitionUrl = this.DictionaryRouter.GetDefinitionUrl() + urlItem; Page.Response.Redirect(itemDefinitionUrl); } else { resultListView.DataSource = resultCollection; resultListView.DataBind(); NumResults = resultCollection.ResultsCount; if (!string.IsNullOrEmpty(SearchStr)) { lblWord.Text = SearchStr.Replace("[[]", "["); } lblNumResults.Text = NumResults.ToString(); if (NumResults == 0) { RenderNoResults(); } } } else { RenderNoResults(); } }
protected void Page_Load(object sender, EventArgs e) { GetQueryParams(); SetupCanonicalUrl(this.DictionaryRouter.GetBaseURL()); //For Genetics dictionary language is always English DictionaryLanguage = "en"; DictionarySearchResultCollection resultCollection = null; DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager(); if (!string.IsNullOrEmpty(SrcGroup)) { BContains = Convert.ToBoolean(SrcGroup); } if (!string.IsNullOrEmpty(Expand)) { if (Expand.Trim() == "#") { Expand = "[0-9]"; } else { if (!Expand.Trim().ToUpper().Equals("ALL")) { Expand = Expand.Trim().ToUpper(); } } } SearchType searchType = SearchType.Begins; if (BContains) { searchType = SearchType.Contains; } if (!String.IsNullOrEmpty(Expand)) // A-Z expand provided - do an A-Z search { if (Expand.ToLower() == "all") { resultCollection = _dictionaryAppManager.Search("%", searchType, 0, int.MaxValue, NCI.Web.Dictionary.DictionaryType.genetic, DictionaryLanguage); } else { resultCollection = _dictionaryAppManager.Search(Expand, searchType, 0, int.MaxValue, NCI.Web.Dictionary.DictionaryType.genetic, DictionaryLanguage); } } if (resultCollection != null && resultCollection.Count() > 0) { resultListView.DataSource = resultCollection; resultListView.DataBind(); NumResults = resultCollection.ResultsCount; lblWord.Text = Expand.Replace("[[]", "["); lblNumResults.Text = NumResults.ToString(); if (NumResults == 0) { RenderNoResults(); } } else { RenderNoResults(); } }