protected void Page_PreRender()
    {
        PopulateQueryWithControlValues(query);

        if (!string.IsNullOrEmpty(query.queryTerm.getValue())) {
            try {
                pnlResultsHeader.Visible = pnlResultsRightBar.Visible = pnlPager.Visible = true;

                GSALib.GSA.ClientAccess ca = new GSALib.GSA.ClientAccess(Server);
                GSALib.GSA.Response res = default(GSALib.GSA.Response);
                res = ca.getGSAResponse(query, null);

                totalResults = res.getNumResults();
                pnlResultsRightBar.Visible = totalResults > 0;

                // determine whether to display the panel
                // allowing users to re-submit search
                // with omitted results included
                int currentStartIndex = Convert.ToInt32(query.ScrollAhead);
                if (currentStartIndex > totalResults) {
                    pnlRepeatSearch.Visible = true;
                    litRepeatSearch_NumResults.Text = totalResults.ToString();

                    // get the url for the unfiltered query
                    char initialFilter = query.Filter;
                    query.Filter = GSALib.Constants.Filtering.NO_FILTER.getValue();

                    litRepeatSearch_URL.Text = "<a href=\"?" + query.getValue() + "\">repeat the search with the omitted results included</a>";

                    // reset query
                    query.Filter = initialFilter;

                    // reset the current index
                    currentStartIndex = (int)totalResults;
                }

                // calculate current page
                currentPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(currentStartIndex + 1) / ResultsPerPage));

                // update header
                litStartIndex.Text = res.getStartIndex().ToString();
                litEndIndex.Text = res.getEndIndex().ToString();
                litTotalResults.Text = res.getNumResults().ToString();
                litQuery.Text = res.getQuery();
                litSearchTime.Text = res.getSearchTime().ToString("0.00");

                var results = res.getResults();

                // GSA will, on rare occassions return results with null titles
                // strip these out.
                results = results.Where(r => !string.IsNullOrEmpty(r.Title)).ToList();

                rptResults.DataSource = results;
                rptResults.DataBind();
            } catch (GSALib.Exceptions.GSANeedNetworkCredentailsException ex) {
                Response.Write(ex.Message);
            }
        }
    }
예제 #2
0
    protected void Page_PreRender()
    {
        PopulateQueryWithControlValues(query);

        if (!string.IsNullOrEmpty(query.queryTerm.getValue()))
        {
            try {
                pnlResultsHeader.Visible = pnlResultsRightBar.Visible = pnlPager.Visible = true;

                GSALib.GSA.ClientAccess ca  = new GSALib.GSA.ClientAccess(Server);
                GSALib.GSA.Response     res = default(GSALib.GSA.Response);
                res = ca.getGSAResponse(query, null);

                totalResults = res.getNumResults();
                pnlResultsRightBar.Visible = totalResults > 0;

                // determine whether to display the panel
                // allowing users to re-submit search
                // with omitted results included
                int currentStartIndex = Convert.ToInt32(query.ScrollAhead);
                if (currentStartIndex > totalResults)
                {
                    pnlRepeatSearch.Visible         = true;
                    litRepeatSearch_NumResults.Text = totalResults.ToString();

                    // get the url for the unfiltered query
                    char initialFilter = query.Filter;
                    query.Filter = GSALib.Constants.Filtering.NO_FILTER.getValue();

                    litRepeatSearch_URL.Text = "<a href=\"?" + query.getValue() + "\">repeat the search with the omitted results included</a>";

                    // reset query
                    query.Filter = initialFilter;

                    // reset the current index
                    currentStartIndex = (int)totalResults;
                }

                // calculate current page
                currentPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(currentStartIndex + 1) / ResultsPerPage));

                // update header
                litStartIndex.Text   = res.getStartIndex().ToString();
                litEndIndex.Text     = res.getEndIndex().ToString();
                litTotalResults.Text = res.getNumResults().ToString();
                litQuery.Text        = res.getQuery();
                litSearchTime.Text   = res.getSearchTime().ToString("0.00");

                var results = res.getResults();

                // GSA will, on rare occassions return results with null titles
                // strip these out.
                results = results.Where(r => !string.IsNullOrEmpty(r.Title)).ToList();

                rptResults.DataSource = results;
                rptResults.DataBind();
            } catch (GSALib.Exceptions.GSANeedNetworkCredentailsException ex) {
                Response.Write(ex.Message);
            }
        }
    }