Esempio n. 1
0
        //获取排序字段
        public void GetOrderByField(ListView ListView, string FieldName, List <ListOrderField> OrderByFields, out List <ListOrderField> orderByFields)
        {
            orderByFields = OrderByFields;
            var OrderByButton = (HtmlButton)ListView.FindControl(FieldName);

            if (OrderByButton == null)
            {
                return;
            }
            ;
            var         OrderByValue = (HiddenField)OrderByButton.FindControl(OrderByButton.ID + "Value");
            OrderByMode OrderByMode  = OrderByMode.None;

            if (!string.IsNullOrWhiteSpace(OrderByValue.Value))
            {
                OrderByMode = (OrderByMode)Enum.Parse(typeof(OrderByMode), OrderByValue.Value);
            }
            if (OrderByMode != OrderByMode.None)
            {
                orderByFields.Add(new ListOrderField
                {
                    Name = FieldName.Replace("ListOrderBy", ""),
                    Mode = OrderByMode
                });
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 实例化一个内容分页器(SQL 2000 及 Microsoft Access分页兼容,其它数据库不必使用此方法)。
 /// </summary>
 /// <param name="page_size">每页条目数量。</param>
 /// <param name="current_page">当前页。</param>
 /// <param name="helpField">分页的辅助字段信息。</param>
 /// <param name="helpSort">分页辅助字段的排序模式。</param>
 public PageContext(int page_size, int current_page, FieldDescription helpField, OrderByMode helpSort)
 {
     _PageSize    = page_size;
     _CurrentPage = current_page;
     _HelpField   = helpField;
     _HelpSort    = helpSort;
 }
Esempio n. 3
0
        /// <summary>
        /// 获取或设置 SELECT 的 ORDER BY 子句。
        /// </summary>
        /// <param name="field">排序字段。</param>
        /// <param name="sort">排序模式。</param>
        /// <returns></returns>
        public SelectBlock OrderBy(FieldDescription field, OrderByMode sort)
        {
            OrderByBlock ob = new OrderByBlock();

            ob.Field = field;
            ob.Sort  = sort;
            Blocks.Add(ob);
            return(this);
        }
Esempio n. 4
0
        //设置排序标记
        public void SetOrderByFlag(object sender)
        {
            var         titleButton = (HtmlButton)sender;
            var         valueButton = (HiddenField)titleButton.FindControl(titleButton.ID + "Value");
            OrderByMode OrderByMode = OrderByMode.None;

            if (!string.IsNullOrWhiteSpace(valueButton.Value))
            {
                OrderByMode = (OrderByMode)Enum.Parse(typeof(OrderByMode), valueButton.Value);
            }
            OrderByMode = OrderByMode == OrderByMode.Asc ? OrderByMode.None : OrderByMode == OrderByMode.None ? OrderByMode.Desc : OrderByMode.Asc;
            ((HtmlGenericControl)titleButton.FindControl(titleButton.ID + "Desc")).Attributes["class"] = OrderByMode == OrderByMode.Desc ? "list-orderby-active" : "list-orderby-none";
            ((HtmlGenericControl)titleButton.FindControl(titleButton.ID + "Asc")).Attributes["class"]  = OrderByMode == OrderByMode.Asc ? "list-orderby-active" : "list-orderby-none";
            valueButton.Value = OrderByMode.ToString();
        }
Esempio n. 5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="propertyName">属性名称</param>
 /// <param name="orderByMode">排序方式</param>
 internal OrderBy(string propertyName, OrderByMode orderByMode = OrderByMode.ASC)
 {
     PropertyName = propertyName;
     OrderByMode  = orderByMode;
 }
Esempio n. 6
0
 /// <summary>
 /// 添加排序条件
 /// </summary>
 /// <param name="propertyName">属性名称</param>
 /// <param name="orderByMode">排序条件</param>
 /// <returns></returns>
 public OrderByGroup Add(string propertyName, OrderByMode orderByMode)
 {
     orderByList.Add(new OrderBy(propertyName, orderByMode));
     return(this);
 }
Esempio n. 7
0
 /// <summary>
 /// 在多表查询中增加 ORDER BY 排序子句.
 /// </summary>
 /// <param name="func">用于返回排序字段.</param>
 /// <param name="sort">排序方式.</param>
 /// <returns></returns>
 public MultiQuerySelector OrderBy(Func <AgentBufferItem[], FieldDescription> func, OrderByMode sort)
 {
     sBlock.OrderBy(func(Agents.ToArray()), sort);
     return(this);
 }
Esempio n. 8
0
 public IResponseQuery <T> OrderBy(OrderByMode orderByMode)
 {
     OrderByMode = orderByMode;
     return(this);
 }
Esempio n. 9
0
 public static string GetSearchUrl(string query, string storeId, string categoryFilter, OrderByMode orderBy, int resultsPerPage, int page)
 {
     return($"https://www.microcenter.com/search/search_results.aspx?Ntt={query}&storeid={storeId}&myStore=false&Ntk=all&N={categoryFilter}&sortby={orderBy}&rpp={resultsPerPage}&page={page}");
 }
Esempio n. 10
0
 /// <summary>
 /// 为查询设置分页信息(SQL 2000 及 Microsoft Access分页兼容,其它数据库不必使用此方法)。
 /// </summary>
 /// <param name="page_size">每页的条目数量。</param>
 /// <param name="current_page">当前页(从第一页开始)。</param>
 /// <param name="helpField">用于辅助分页的字段(某些数据库需要字段来辅助分页,将使排序设置失效)。</param>
 /// <param name="helpSort">辅助分页字段的排序模式。</param>
 /// <returns></returns>
 public SelectBlock Paging(int page_size, int current_page, FieldDescription helpField, OrderByMode helpSort = OrderByMode.DESC)
 {
     _Pager = new PageContext(page_size, current_page, helpField, helpSort);
     return(this);
 }
Esempio n. 11
0
        public static async Task <SearchResults> LoadQuery(string searchQuery, string storeID, string categoryFilter, OrderByMode orderBy, int page, CancellationToken?token = null, IProgress <ProgressInfo> progress = null)
        {
            token?.Register(() =>
            {
                client?.CancelPendingRequests();
            });

            progress?.Report(new ProgressInfo($"Loading query {searchQuery}", .3));

            var url      = GetSearchUrl(searchQuery, storeID, categoryFilter, orderBy, RESULTS_PER_PAGE, page);
            var response = await(token != null ? client.GetAsync(url, token.Value) :  client.GetAsync(url));

            token?.ThrowIfCancellationRequested();
            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                progress?.Report(new ProgressInfo($"Parsing query {searchQuery}", .5));

                var body = await response.Content.ReadAsStringAsync();

                var result = await ParseBody(body, token);

                result.Page = page;
                token?.ThrowIfCancellationRequested();
                return(result);
            }

            return(new SearchResults());
        }
Esempio n. 12
0
        public static async Task <SearchResults> LoadAll(string searchQuery, string storeID, string categoryFilter, OrderByMode orderBy, CancellationToken?token = null)
        {
            int page   = 1;
            var result = new SearchResults()
            {
                TotalResults = 1
            };

            while (result.Items.Count < result.TotalResults)
            {
                if (token != null && token.Value.IsCancellationRequested)
                {
                    return(new SearchResults()
                    {
                    });
                }

                var addResult = await LoadQuery(searchQuery, storeID, categoryFilter, orderBy, page, token);

                result.Items.AddRange(addResult.Items);
                result.TotalResults = addResult.TotalResults;
                page++;
            }

            token?.ThrowIfCancellationRequested();
            return(result);
        }