예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(GetType());

            Master.DisabledSidePanel = true;

            Title = HeaderStringHelper.GetPageTitle(Resource.Search);

            var productID = !String.IsNullOrEmpty(Request["productID"]) ? new Guid(Request["productID"]) : Guid.Empty;
            var moduleID  = !String.IsNullOrEmpty(Request["moduleID"]) ? new Guid(Request["moduleID"]) : Guid.Empty;

            SearchText = Request["search"] ?? "";

            var searchResultsData = new List <SearchResult>();

            if (!string.IsNullOrEmpty(SearchText))
            {
                List <ISearchHandlerEx> handlers = null;

                var products = !String.IsNullOrEmpty(Request["products"]) ? Request["products"] : string.Empty;
                if (!string.IsNullOrEmpty(products))
                {
                    try
                    {
                        var productsStr  = products.Split(new[] { ',' });
                        var productsGuid = productsStr.Select(p => new Guid(p)).ToArray();

                        handlers = SearchHandlerManager.GetHandlersExForProductModule(productsGuid);
                    }
                    catch
                    {
                    }
                }

                if (handlers == null)
                {
                    handlers = SearchHandlerManager.GetHandlersExForProductModule(productID, moduleID);
                }

                searchResultsData = GetSearchresultByHandlers(handlers, SearchText);
            }

            if (searchResultsData.Count <= 0)
            {
                var emptyScreenControl = new EmptyScreenControl
                {
                    ImgSrc   = WebImageSupplier.GetAbsoluteWebPath("empty_search.png"),
                    Header   = Resource.SearchNotFoundMessage,
                    Describe = Resource.SearchNotFoundDescript
                };
                SearchContent.Controls.Add(emptyScreenControl);
            }
            else
            {
                searchResultsData = GroupSearchresult(productID, searchResultsData);
                var oSearchView = (SearchResults)LoadControl(SearchResults.Location);
                oSearchView.SearchResultsData = searchResultsData;
                SearchContent.Controls.Add(oSearchView);
            }
        }
예제 #2
0
        public string GetAllData(string product, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(string.Empty);
            }

            var productID = new Guid(product);

            var handlers          = SearchHandlerManager.GetHandlersExForProductModule(productID, Guid.Empty);
            var searchResultsData = GetSearchresultByHandlers(handlers, text);

            searchResultsData = GroupSearchresult(productID, searchResultsData);
            if (searchResultsData.Count <= 0)
            {
                return(string.Empty);
            }

            var control = searchResultsData[0].PresentationControl ?? new CommonResultsView();

            control.Items = new List <SearchResultItem>();
            foreach (var searchResult in searchResultsData)
            {
                control.Items.AddRange(searchResult.Items);
            }
            control.MaxCount = int.MaxValue;
            control.Text     = control.Text ?? text;
            var stringWriter = new StringWriter();
            var htmlWriter   = new HtmlTextWriter(stringWriter);

            control.RenderControl(htmlWriter);

            return(stringWriter.ToString());
        }