Exemplo n.º 1
0
 void ResourceManagement_BasicSearch_LoadComplete(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(SearchText.Text) && !this.ContentSearchCheckBox.Checked)
     {
         SearchResourceListView.EnableFeed(SearchText.Text);
     }
 }
Exemplo n.º 2
0
    protected void GoButton_Click(object sender, EventArgs e)
    {
        string searchText = (SearchText.Text == null) ? null : SearchText.Text.Trim();

        if (IsPostBack)
        {
            string queryStringSearchText = (Request.QueryString[_SearchText] == null) ? string.Empty :
                                           Request.QueryString[_SearchText].Trim();
            string queryStringPageSize = (Request.QueryString[Constants.PageSizeQueryStringParameter] == null) ? string.Empty :
                                         Request.QueryString[Constants.PageSizeQueryStringParameter].ToString().Trim();
            string queryStringContent = (Request.QueryString[Constants.ContentSearchQueryStringParameter] == null) ? string.Empty :
                                        Request.QueryString[Constants.ContentSearchQueryStringParameter].ToString().Trim();

            if (!string.IsNullOrEmpty(searchText) &&
                (searchText != queryStringSearchText || !PageSizeDropDownList.SelectedValue.Equals(queryStringPageSize) ||
                 !ContentSearchCheckBox.Checked.Equals(queryStringContent)))
            {
                string urlToRedirect = string.Format(CultureInfo.CurrentCulture, Constants.UriBasicSearchPage,
                                                     Server.UrlEncode(searchText), PageSizeDropDownList.SelectedValue, ContentSearchCheckBox.Checked);
                Response.Redirect(urlToRedirect, true);
            }
        }

        SearchResourceListView.DataSource.Clear();
        SearchResourceListView.DataBind();

        if (!string.IsNullOrEmpty(searchText))
        {
            SearchResourceListView.PageSize      = Convert.ToInt32(PageSizeDropDownList.SelectedValue);
            SearchResourceListView.SortDirection = System.Web.UI.WebControls.SortDirection.Descending;
            RefreshDataSource(0);
        }
    }
Exemplo n.º 3
0
    private void RefreshDataSource(int pageIndex)
    {
        int    totalPages = 0;
        string searchText = SearchText.Text;

        if (!string.IsNullOrEmpty(searchText))
        {
            LabelErrorMessage.Text = string.Empty;
            try
            {
                searchText      = SearchText.Text.Trim();
                SearchText.Text = searchText;
                int             totalRecords       = 0;
                int             pageSize           = SearchResourceListView.PageSize;
                int             totalParsedRecords = totalParsedRecords = pageSize * pageIndex;
                List <Resource> foundRestResource  = null;
                Dictionary <Guid, IEnumerable <string> > userPermissions = null;

                SortProperty sortProp = null;
                if (SearchResourceListView.SortDirection == System.Web.UI.WebControls.SortDirection.Ascending)
                {
                    sortProp = new SortProperty(SearchResourceListView.SortExpression, Zentity.Platform.SortDirection.Ascending);
                }
                else
                {
                    sortProp = new SortProperty(SearchResourceListView.SortExpression, Zentity.Platform.SortDirection.Descending);
                }

                //search resources and user permissions on the searched resources.
                using (ResourceDataAccess dataAccess = new ResourceDataAccess())
                {
                    AuthenticatedToken token = this.Session[Constants.AuthenticationTokenKey] as AuthenticatedToken;
                    if (token != null)
                    {
                        foundRestResource = dataAccess.SearchResources(token, searchText, pageSize, sortProp, totalParsedRecords,
                                                                       ContentSearchCheckBox.Checked, out totalRecords).ToList();
                        userPermissions = GetPermissions(token, foundRestResource);
                    }
                }

                //Calculate total pages
                if (totalRecords > 0)
                {
                    //this.DisplayMatchedResourcesCount(totalRecords);
                    totalPages = Convert.ToInt32(Math.Ceiling((double)totalRecords / pageSize));
                }

                // Update empty resource's title with default value.
                if (foundRestResource != null && foundRestResource.Count() > 0)
                {
                    Utility.UpdateResourcesEmptyTitle(foundRestResource);
                }

                //Bind data to GridView
                SearchResourceListView.TotalRecords = totalRecords;

                SearchResourceListView.DataSource.Clear();
                foreach (Resource resource in foundRestResource)
                {
                    SearchResourceListView.DataSource.Add(resource);
                }

                SearchResourceListView.UserPermissions = userPermissions;
                SearchResourceListView.DataBind();
                if (!this.ContentSearchCheckBox.Checked)
                {
                    SearchResourceListView.EnableFeed(searchText);
                }
            }
            catch (SearchException ex)
            {
                LabelErrorMessage.Text = ex.Message;
            }
        }
        SearchText.Focus();
    }