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();
            }
        }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
        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();
            }
        }
Esempio n. 5
0
        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();
            }
        }