Beispiel #1
0
        public static DataSet GetExportProducts(AdvancedProductQuery query, bool includeCostPrice, bool includeStock, string removeProductIds)
        {
            DataSet set = ProductProvider.Instance().GetExportProducts(query, includeCostPrice, includeStock, removeProductIds);

            set.Tables[0].TableName = "types";
            set.Tables[1].TableName = "attributes";
            set.Tables[2].TableName = "values";
            set.Tables[3].TableName = "products";
            set.Tables[4].TableName = "skus";
            set.Tables[5].TableName = "skuItems";
            set.Tables[6].TableName = "productAttributes";
            return(set);
        }
Beispiel #2
0
        private void BindProducts()
        {
            if (!this._includeUnSales && !this._includeOnSales && !this._includeInStock)
            {
                this.ShowMsg("至少要选择包含一个商品状态", false);
                return;
            }
            AdvancedProductQuery query          = this.GetQuery();
            DbQueryResult        exportProducts = ProductHelper.GetExportProducts(query, (string)this.ViewState["RemoveProductIds"]);

            this.grdProducts.DataSource = exportProducts.Data;
            this.grdProducts.DataBind();
            this.pager.TotalRecords = exportProducts.TotalRecords;
            this.lblTotals.Text     = exportProducts.TotalRecords.ToString(System.Globalization.CultureInfo.InvariantCulture);
        }
Beispiel #3
0
        private void btnExport_Click(object sender, System.EventArgs e)
        {
            //修改1;
            string arg_6B_0            = Globals.ApplicationPath;
            AdvancedProductQuery query = this.GetQuery();

            System.Data.DataTable dataTable = ProductHelper.GetExportProducts(query, true, true, (string)this.ViewState["RemoveProductIds"]).Tables[3];
            System.Collections.Generic.List <ExportToLocal.ProductDetail> list = new System.Collections.Generic.List <ExportToLocal.ProductDetail>();
            foreach (System.Data.DataRow dataRow in dataTable.Rows)
            {
                int productId = System.Convert.ToInt32(dataRow["ProductId"]);
                System.Collections.Generic.IList <int> tagIds = null;
                System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > attrs;
                ProductInfo productDetails = ProductHelper.GetProductDetails(productId, out attrs, out tagIds);
                list.Add(new ExportToLocal.ProductDetail
                {
                    pi     = productDetails,
                    attrs  = attrs,
                    tagIds = tagIds
                });
            }
            string strflag;

            if (!(this.calendarStartDate.SelectedDate.HasValue && this.calendarEndDate.SelectedDate.HasValue))
            {
                strflag = "";
            }
            else
            {
                strflag = "_" +
                          DateTime.Parse(this.calendarStartDate.SelectedDate.ToString()).ToString("yyyyMMdd") + "-" + DateTime.Parse(this.calendarEndDate.SelectedDate.ToString()).ToString("yyyyMMdd");
            }
            //this._workDir = this._baseDir.CreateSubdirectory(this._flag);
            //string text = this._workDir.FullName + string.Format("\\local{0}.csv", this._flag);
            this._workDir = this._baseDir.CreateSubdirectory(this._flag);
            string text = this._workDir.FullName + string.Format("\\本地商品数据包{0}.csv", strflag);

            string text2 = text.Replace(".csv", "");

            if (!System.IO.Directory.Exists(text2))
            {
                System.IO.Directory.CreateDirectory(text2);
            }
            this.DoExportForHishop(text, text2, list);
        }
Beispiel #4
0
        private AdvancedProductQuery GetQuery()
        {
            AdvancedProductQuery query2 = new AdvancedProductQuery();

            query2.Keywords      = this._productName;
            query2.ProductCode   = this._productCode;
            query2.ProductLineId = this._lineId;
            query2.PageSize      = this.pager.PageSize;
            query2.PageIndex     = this.pager.PageIndex;
            query2.SaleStatus    = ProductSaleStatus.OnSale;
            query2.SortOrder     = SortAction.Desc;
            query2.SortBy        = "DisplaySequence";
            query2.StartDate     = this._startDate;
            query2.EndDate       = this._endDate;
            AdvancedProductQuery entity = query2;

            Globals.EntityCoding(entity, true);
            return(entity);
        }
Beispiel #5
0
        private AdvancedProductQuery GetQuery()
        {
            AdvancedProductQuery advancedProductQuery = new AdvancedProductQuery
            {
                Keywords      = this._productName,
                ProductCode   = this._productCode,
                ProductLineId = this._lineId,
                PageSize      = this.pager.PageSize,
                PageIndex     = this.pager.PageIndex,
                SaleStatus    = ProductSaleStatus.OnSale,
                SortOrder     = SortAction.Desc,
                SortBy        = "DisplaySequence",
                StartDate     = this._startDate,
                EndDate       = this._endDate
            };

            Globals.EntityCoding(advancedProductQuery, true);
            return(advancedProductQuery);
        }
        private DataGridViewModel <Dictionary <string, object> > GetProducts(AdvancedProductQuery query, HttpContext context)
        {
            string empty = string.Empty;
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                empty = (string.IsNullOrEmpty(context.Request["RemoveProductId"]) ? "" : context.Request["RemoveProductId"]);
                DbQueryResult exportProducts = ProductHelper.GetExportProducts(query, empty);
                dataGridViewModel.rows = DataHelper.DataTableToDictionary(exportProducts.Data);
                foreach (Dictionary <string, object> row in dataGridViewModel.rows)
                {
                    if (string.IsNullOrEmpty(row["ThumbnailUrl40"].ToNullString()))
                    {
                        row["ThumbnailUrl40"] = HiContext.Current.SiteSettings.DefaultProductImage;
                    }
                }
                dataGridViewModel.total = exportProducts.TotalRecords;
            }
            return(dataGridViewModel);
        }
        private void Export(HttpContext context)
        {
            this._baseDir     = new DirectoryInfo(HttpContext.Current.Request.MapPath("~/storage/data/local"));
            this._flag        = DateTime.Now.ToString("yyyyMMddHHmmss");
            this._zipFilename = $"local{this._flag}.zip";
            string removeProductIds = string.Empty;

            if (!string.IsNullOrEmpty(context.Request["RemoveProductId"]))
            {
                removeProductIds = context.Request["RemoveProductId"];
            }
            string text  = "http://" + HttpContext.Current.Request.Url.Host;
            string empty = string.Empty;
            AdvancedProductQuery query     = this.GetQuery(context);
            DataTable            dataTable = ProductHelper.GetExportProducts(query, true, true, removeProductIds).Tables[3];
            List <ProductDetail> list      = new List <ProductDetail>();

            foreach (DataRow row in dataTable.Rows)
            {
                int         productId = Convert.ToInt32(row["ProductId"]);
                IList <int> tagIds    = null;
                Dictionary <int, IList <int> > attrs = default(Dictionary <int, IList <int> >);
                ProductInfo   productDetails         = ProductHelper.GetProductDetails(productId, out attrs, out tagIds);
                ProductDetail productDetail          = new ProductDetail();
                productDetail.pi     = productDetails;
                productDetail.attrs  = attrs;
                productDetail.tagIds = tagIds;
                list.Add(productDetail);
            }
            this._workDir = this._baseDir.CreateSubdirectory(this._flag);
            string empty2 = string.Empty;
            string text2  = this._workDir.FullName + $"\\local{this._flag}.csv";

            empty2 = text2.Replace(".csv", "");
            if (!Directory.Exists(empty2))
            {
                Directory.CreateDirectory(empty2);
            }
            this.DoExportForHishop(text2, empty2, list, context);
        }
        private AdvancedProductQuery GetQuery(HttpContext context)
        {
            AdvancedProductQuery advancedProductQuery = new AdvancedProductQuery();
            int    num   = 1;
            int    num2  = 10;
            int    num3  = 0;
            string empty = string.Empty;
            bool   flag  = false;
            bool   flag2 = false;
            bool   flag3 = false;

            advancedProductQuery.Keywords    = context.Request["productName"];
            advancedProductQuery.ProductCode = context.Request["productCode"];
            advancedProductQuery.CategoryId  = base.GetIntParam(context, "categoryId", true);
            advancedProductQuery.SaleStatus  = ProductSaleStatus.OnSale;
            if (advancedProductQuery.CategoryId.HasValue)
            {
                advancedProductQuery.MaiCategoryPath = CatalogHelper.GetCategory(advancedProductQuery.CategoryId.Value).Path;
            }
            advancedProductQuery.IncludeInStock = base.GetBoolParam(context, "IncludeInStock", false).Value;
            advancedProductQuery.IncludeOnSales = base.GetBoolParam(context, "IncludeOnSales", false).Value;
            advancedProductQuery.IncludeUnSales = base.GetBoolParam(context, "IncludeUnSales", false).Value;
            if (!advancedProductQuery.IncludeInStock && !advancedProductQuery.IncludeOnSales && !advancedProductQuery.IncludeUnSales)
            {
                throw new HidistroAshxException("至少要选择包含一个商品状态");
            }
            advancedProductQuery.IsMakeTaobao = base.GetIntParam(context, "IsMakeTaobao", true);
            advancedProductQuery.StartDate    = base.GetDateTimeParam(context, "StartDate");
            advancedProductQuery.EndDate      = base.GetDateTimeParam(context, "EndDate");
            advancedProductQuery.PageSize     = base.CurrentPageSize;
            advancedProductQuery.PageIndex    = base.CurrentPageIndex;
            advancedProductQuery.SortOrder    = SortAction.Desc;
            advancedProductQuery.SortBy       = "DisplaySequence";
            Globals.EntityCoding(advancedProductQuery, true);
            return(advancedProductQuery);
        }
 public abstract DataSet GetExportProducts(AdvancedProductQuery query, bool includeCostPrice, bool includeStock, string removeProductIds);
 public abstract DbQueryResult GetExportProducts(AdvancedProductQuery query, string removeProductIds);
Beispiel #11
0
 public static DbQueryResult GetExportProducts(AdvancedProductQuery query, string removeProductIds)
 {
     return(new ProductDao().GetExportProducts(query, removeProductIds));
 }
Beispiel #12
0
        public DataSet GetExportProducts(AdvancedProductQuery query, bool includeCostPrice, bool includeStock, string removeProductIds)
        {
            int?          nullable;
            StringBuilder builder = new StringBuilder();

            builder.Append("SELECT a.[ProductId], [TypeId], [ProductName], [ProductCode], [ShortDescription], [Unit], [Description], ").Append("[SaleStatus], [ImageUrl1], [ImageUrl2], [ImageUrl3], ").Append("[ImageUrl4], [ImageUrl5], [MarketPrice], [HasSKU] ").Append("FROM Hishop_Products a  left join Taobao_Products b on a.productid=b.productid WHERE ");
            builder.Append("(");
            if (query.IncludeOnSales)
            {
                builder.AppendFormat("SaleStatus = {0} OR ", 1);
            }
            if (query.IncludeUnSales)
            {
                builder.AppendFormat("SaleStatus = {0} OR ", 2);
            }
            if (query.IncludeInStock)
            {
                builder.AppendFormat("SaleStatus = {0} OR ", 3);
            }
            builder.Remove(builder.Length - 4, 4);
            builder.Append(")");
            if (query.IsMakeTaobao.HasValue && (((nullable = query.IsMakeTaobao).GetValueOrDefault() != -1) || !nullable.HasValue))
            {
                if (query.IsMakeTaobao == 1)
                {
                    builder.AppendFormat(" AND a.ProductId IN (SELECT ProductId FROM Taobao_Products)", new object[0]);
                }
                else
                {
                    builder.AppendFormat(" AND a.ProductId NOT IN (SELECT ProductId FROM Taobao_Products)", new object[0]);
                }
            }
            if (query.BrandId.HasValue)
            {
                builder.AppendFormat(" AND BrandId = {0}", query.BrandId.Value);
            }
            if (!string.IsNullOrEmpty(query.Keywords))
            {
                query.Keywords = DataHelper.CleanSearchString(query.Keywords);
                string[] strArray = Regex.Split(query.Keywords.Trim(), @"\s+");
                builder.AppendFormat(" AND ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[0]));
                for (int i = 1; (i < strArray.Length) && (i <= 4); i++)
                {
                    builder.AppendFormat("AND ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[i]));
                }
            }
            if (!string.IsNullOrEmpty(query.ProductCode))
            {
                builder.AppendFormat(" AND ProductCode LIKE '%{0}%'", DataHelper.CleanSearchString(query.ProductCode));
            }
            if (query.CategoryId.HasValue && (query.CategoryId.Value > 0))
            {
                builder.AppendFormat(" AND ( MainCategoryPath LIKE '{0}|%'  OR ExtendCategoryPath LIKE '{0}|%' )", query.MaiCategoryPath);
            }
            if (query.StartDate.HasValue)
            {
                builder.AppendFormat(" AND AddedDate >='{0}'", DataHelper.GetSafeDateTimeFormat(query.StartDate.Value));
            }
            if (query.EndDate.HasValue)
            {
                builder.AppendFormat(" AND AddedDate <='{0}'", DataHelper.GetSafeDateTimeFormat(query.EndDate.Value));
            }
            if (!string.IsNullOrEmpty(removeProductIds))
            {
                builder.AppendFormat(" AND a.ProductId NOT IN ({0})", removeProductIds);
            }
            builder.AppendFormat(" ORDER BY {0} {1}", query.SortBy, query.SortOrder);
            DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_Product_GetExportList");

            this.database.AddInParameter(storedProcCommand, "sqlPopulate", DbType.String, builder.ToString());
            return(this.database.ExecuteDataSet(storedProcCommand));
        }
Beispiel #13
0
        public DbQueryResult GetExportProducts(AdvancedProductQuery query, string removeProductIds)
        {
            int?          nullable;
            StringBuilder builder = new StringBuilder();

            builder.Append("(");
            if (query.IncludeOnSales)
            {
                builder.AppendFormat("SaleStatus = {0} OR ", 1);
            }
            if (query.IncludeUnSales)
            {
                builder.AppendFormat("SaleStatus = {0} OR ", 2);
            }
            if (query.IncludeInStock)
            {
                builder.AppendFormat("SaleStatus = {0} OR ", 3);
            }
            builder.Remove(builder.Length - 4, 4);
            builder.Append(")");
            if (query.BrandId.HasValue)
            {
                builder.AppendFormat(" AND BrandId = {0}", query.BrandId.Value);
            }
            if (query.IsMakeTaobao.HasValue && (((nullable = query.IsMakeTaobao).GetValueOrDefault() != -1) || !nullable.HasValue))
            {
                builder.AppendFormat(" AND IsMakeTaobao={0}  ", query.IsMakeTaobao);
            }
            if (!string.IsNullOrEmpty(query.Keywords))
            {
                query.Keywords = DataHelper.CleanSearchString(query.Keywords);
                string[] strArray = Regex.Split(query.Keywords.Trim(), @"\s+");
                builder.AppendFormat(" AND ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[0]));
                for (int i = 1; (i < strArray.Length) && (i <= 4); i++)
                {
                    builder.AppendFormat("AND ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[i]));
                }
            }
            if (!string.IsNullOrEmpty(query.ProductCode))
            {
                builder.AppendFormat(" AND ProductCode LIKE '%{0}%'", DataHelper.CleanSearchString(query.ProductCode));
            }
            if (query.CategoryId.HasValue && (query.CategoryId.Value > 0))
            {
                builder.AppendFormat(" AND ( MainCategoryPath LIKE '{0}|%'  OR ExtendCategoryPath LIKE '{0}|%' )", query.MaiCategoryPath);
            }
            if (query.StartDate.HasValue)
            {
                builder.AppendFormat(" AND AddedDate >='{0}'", DataHelper.GetSafeDateTimeFormat(query.StartDate.Value));
            }
            if (query.EndDate.HasValue)
            {
                builder.AppendFormat(" AND AddedDate <='{0}'", DataHelper.GetSafeDateTimeFormat(query.EndDate.Value));
            }
            if (!string.IsNullOrEmpty(removeProductIds))
            {
                builder.AppendFormat(" AND ProductId NOT IN ({0})", removeProductIds);
            }
            string selectFields = "ProductId, ProductCode, ProductName, ThumbnailUrl40, MarketPrice, SalePrice, (SELECT CostPrice FROM Hishop_SKUs WHERE SkuId = p.SkuId) AS  CostPrice,  Stock, DisplaySequence";

            return(DataHelper.PagingByRownumber(query.PageIndex, query.PageSize, query.SortBy, query.SortOrder, query.IsCount, "vw_Hishop_BrowseProductList p", "ProductId", builder.ToString(), selectFields));
        }
 public static DbQueryResult GetExportProducts(AdvancedProductQuery query, string removeProductIds)
 {
     return(SubsiteProductProvider.Instance().GetExportProducts(query, removeProductIds));
 }