private void BindProducts()
        {
            LoadParameters();
            ProductQuery entity = new ProductQuery();

            entity.Keywords      = productName;
            entity.ProductCode   = productCode;
            entity.CategoryId    = categoryId;
            entity.ProductLineId = lineId;
            entity.PublishStatus = publishStatus;
            entity.PageSize      = pager.PageSize;
            entity.PageIndex     = pager.PageIndex;
            entity.SortOrder     = SortAction.Desc;
            entity.SortBy        = "DisplaySequence";
            entity.StartDate     = startDate;
            entity.EndDate       = endDate;
            if (categoryId.HasValue)
            {
                entity.MaiCategoryPath = SubsiteCatalogHelper.GetCategory(categoryId.Value).Path;
            }
            Globals.EntityCoding(entity, true);
            DbQueryResult toTaobaoProducts = SubSiteProducthelper.GetToTaobaoProducts(entity);

            grdProducts.DataSource = toTaobaoProducts.Data;
            grdProducts.DataBind();
            txtSearchText.Text           = entity.Keywords;
            txtSKU.Text                  = entity.ProductCode;
            dropCategories.SelectedValue = entity.CategoryId;
            dropLines.SelectedValue      = entity.ProductLineId;
            pager1.TotalRecords          = pager.TotalRecords = toTaobaoProducts.TotalRecords;
        }
        private void ProcessProductSearch(System.Web.HttpContext context)
        {
            string       str          = "http://" + System.Web.HttpContext.Current.Request.Url.Host + ((System.Web.HttpContext.Current.Request.Url.Port == 80) ? "" : (":" + System.Web.HttpContext.Current.Request.Url.Port));
            ProductQuery productQuery = new ProductQuery();

            productQuery.UserId      = new int?(int.Parse(context.Request["distributorUserId"]));
            productQuery.PageIndex   = int.Parse(context.Request["pageIndex"]);
            productQuery.PageSize    = int.Parse(context.Request["pageSize"]);
            productQuery.Keywords    = context.Request["productName"];
            productQuery.ProductCode = context.Request["productCode"];
            if (!string.IsNullOrEmpty(context.Request["publishStatus"]))
            {
                productQuery.PublishStatus = (PublishStatus)int.Parse(context.Request["publishStatus"]);
            }
            if (!string.IsNullOrEmpty(context.Request["startDate"]))
            {
                productQuery.StartDate = new System.DateTime?(System.DateTime.Parse(context.Request["startDate"]));
            }
            if (!string.IsNullOrEmpty(context.Request["endDate"]))
            {
                productQuery.EndDate = new System.DateTime?(System.DateTime.Parse(context.Request["endDate"]));
            }
            Globals.EntityCoding(productQuery, true);
            DbQueryResult toTaobaoProducts = SubSiteProducthelper.GetToTaobaoProducts(productQuery);

            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            stringBuilder.Append("{");
            stringBuilder.Append("\"Products\":[");
            System.Data.DataTable dataTable = (System.Data.DataTable)toTaobaoProducts.Data;
            if (dataTable.Rows.Count > 0)
            {
                foreach (System.Data.DataRow dataRow in dataTable.Rows)
                {
                    stringBuilder.Append("{");
                    stringBuilder.AppendFormat("\"ProductId\":{0},", dataRow["ProductId"]);
                    stringBuilder.AppendFormat("\"ProductDetailLink\":\"{0}\",", str + Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[]
                    {
                        dataRow["ProductId"]
                    }));
                    stringBuilder.AppendFormat("\"DisplaySequence\":{0},", dataRow["DisplaySequence"]);
                    stringBuilder.AppendFormat("\"ThumbnailUrl40\":\"{0}\",", (dataRow["ThumbnailUrl40"] != System.DBNull.Value) ? (str + Globals.ApplicationPath + (string)dataRow["ThumbnailUrl40"]) : "");
                    stringBuilder.AppendFormat("\"ProductName\":\"{0}\",", dataRow["ProductName"]);
                    stringBuilder.AppendFormat("\"ProductCode\":\"{0}\",", dataRow["ProductCode"]);
                    stringBuilder.AppendFormat("\"Stock\":{0},", dataRow["Stock"]);
                    stringBuilder.AppendFormat("\"MarketPrice\":{0},", (dataRow["MarketPrice"] != System.DBNull.Value) ? ((decimal)dataRow["MarketPrice"]).ToString("F2") : "0");
                    stringBuilder.AppendFormat("\"SalePrice\":{0},", (dataRow["SalePrice"] != System.DBNull.Value) ? ((decimal)dataRow["SalePrice"]).ToString("F2") : "0");
                    stringBuilder.AppendFormat("\"PurchasePrice\":{0},", (dataRow["PurchasePrice"] != System.DBNull.Value) ? ((decimal)dataRow["PurchasePrice"]).ToString("F2") : "0");
                    stringBuilder.AppendFormat("\"IsPublish\":{0}", (dataRow["IsPublish"] != System.DBNull.Value) ? ((int)dataRow["IsPublish"]) : -1);
                    stringBuilder.Append("},");
                }
                stringBuilder.Remove(stringBuilder.Length - 1, 1);
            }
            stringBuilder.Append("],");
            stringBuilder.AppendFormat("\"TotalResults\":{0}", toTaobaoProducts.TotalRecords);
            stringBuilder.Append("}");
            context.Response.Write(stringBuilder.ToString());
        }