public HttpResponseBase QueryProList()
        {
            string json = string.Empty;
            string _classid = String.Empty;
            PromotionsMaintainDao pmDao = new PromotionsMaintainDao(connectionString);
            try
            {
                QueryVerifyCondition query = new QueryVerifyCondition();
                #region 查询条件填充
                query.IsPage = true;
                query.Start = int.Parse(Request.Params["start"] ?? "0");
                query.Limit = int.Parse(Request.Params["limit"] ?? "25");
                if (!string.IsNullOrEmpty(Request.Params["ProCatid"]))//活動的category_id
                {
                    query.cate_id = Request.Form["ProCatid"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["key"]))//變動1支持商品編號的批次查詢
                {
                    query.product_name = Request.Params["key"].Replace(',', ',').Replace('|', ',').Replace(' ', ','); //在這裡product_id用,分割拼接的字符串用product_name 存放
                }

                if (!string.IsNullOrEmpty(Request.Params["site_id"]))//支持多站台查詢
                {
                    query.site_ids = Request.Params["site_id"].ToString();
                }

                if (!string.IsNullOrEmpty(Request.Params["comboFrontCage_hide"]))//支持類別查詢商品
                {
                    query.category_id = Convert.ToUInt32(Request.Params["comboFrontCage_hide"].ToString());
                }

                #endregion
                query.combination = 1;//只顯示單一商品
                int totalCount = 0;
                if (!string.IsNullOrEmpty(Request.Params["brand_id"]))//支持品牌查詢
                {
                    query.brand_id = uint.Parse(Request.Params["brand_id"]);
                }
                else
                {
                    if (!string.IsNullOrEmpty(Request.Params["class_id"]))//支持館別查詢
                    {
                        VendorBrandSetMgr vbsMgr = new VendorBrandSetMgr(connectionString);
                        VendorBrandSet vbs = new VendorBrandSet();
                        vbs.class_id = Convert.ToUInt32(Request.Params["class_id"]);
                        List<VendorBrandSet> vbsList = vbsMgr.Query(vbs);
                        foreach (VendorBrandSet item in vbsList)
                        {
                            query.brand_ids += item.brand_id + ",";
                        }
                        query.brand_ids = query.brand_ids.TrimEnd(',');
                    }
                }
                List<QueryandVerifyCustom> pros = pmDao.GetProList(query, out totalCount);
                json = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(pros) + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{succes:true,totalCount:0,item:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
예제 #2
0
        public HttpResponseBase GetProductByCategorySet()
        {
            string resultStr = "{success:false}";
            try
            {
                _productMgr = new ProductMgr(connectionString);
                ProductQuery query = new ProductQuery();
                query.isjoincate = true;
                query.IsPage = true;
                query.Start = int.Parse(Request.Form["start"] ?? "0");
                if (!string.IsNullOrEmpty(Request.Form["limit"]))
                {
                    query.Limit = Convert.ToInt32(Request.Form["limit"].ToString());
                }
                else
                {
                    query.Limit = 500;
                }
                uint isTryUint = 0;
                if (uint.TryParse(Request.Params["status"].ToString(), out isTryUint))
                {
                    query.Product_Status = Convert.ToUInt32(Request.Params["status"].ToString());
                }
                if (uint.TryParse(Request.Params["brand_id"].ToString(), out isTryUint))
                {
                    query.Brand_Id = Convert.ToUInt32(Request.Params["brand_id"].ToString());
                }
                else
                {
                    if (!string.IsNullOrEmpty(Request.Params["class_id"]))
                    {
                        VendorBrandSetMgr vbsMgr = new VendorBrandSetMgr(connectionString);
                        VendorBrandSet vbs = new VendorBrandSet();
                        vbs.class_id = Convert.ToUInt32(Request.Form["class_id"]);
                        List<VendorBrandSet> vbsList = vbsMgr.Query(vbs);
                        foreach (VendorBrandSet item in vbsList)
                        {
                            query.brandArry += item.brand_id;
                            query.brandArry += ",";
                        }
                        query.brandArry = query.brandArry.Substring(0, query.brandArry.Length - 1);
                    }

                }
                if (!string.IsNullOrEmpty(Request.Params["keyCode"].ToString()))
                {

                    string keyCode = Request.Params["keyCode"].ToString();
                    keyCode = keyCode.Replace(",", ",");
                    keyCode = Regex.Replace(keyCode, @"\s+", ",");
                    if (keyCode.Substring(keyCode.Length - 1).Equals(","))
                    {
                        keyCode = keyCode.Substring(0, keyCode.Length - 1);
                    }
                    string[] ProductID = keyCode.Split(',');
                    try
                    {
                        for (int i = 0; i < ProductID.Length; i++)
                        {
                            int ID = int.Parse(ProductID[i]);
                        }
                        query.Product_Id = 0;
                        query.Product_Id_In = keyCode;
                    }
                    catch (Exception)
                    {
                        query.Product_Name = Request.Params["keyCode"].ToString();
                    }
                }
                //if (!string.IsNullOrEmpty(Request.Params["keyCode"].ToString()))
                //{
                //    if (uint.TryParse(Request.Params["keyCode"].ToString(), out isTryUint))
                //    {
                //        query.Product_Id = Convert.ToUInt32(Request.Params["keyCode"].ToString());
                //    }
                //    else
                //    {
                //        query.Product_Name = Request.Params["keyCode"].ToString();
                //    }
                //}

                if (string.IsNullOrEmpty(Request.Params["category_id"].ToString()))
                {
                    if (uint.TryParse(Request.Params["comboFrontCage_hide"].ToString(), out isTryUint))
                    {
                        query.category_id = Convert.ToUInt32(Request.Params["comboFrontCage_hide"].ToString());

                    }
                }
                else
                {
                    if (uint.TryParse(Request.Params["category_id"].ToString(), out isTryUint))
                    {
                        query.category_id = Convert.ToUInt32(Request.Params["category_id"].ToString());
                    }
                }
                int totalCount = 0;
                List<ProductDetailsCustom> prods = _productMgr.GetAllProList(query, out totalCount);
                resultStr = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(prods) + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                resultStr = "{succes:false,totalCount:0,item:[]}";
            }


            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }
예제 #3
0
        public HttpResponseBase GetProductByCategorySet()
        {
            string resultStr = "{success:false}";
            string str = string.Empty;
            try
            {
                _productMgr = new ProductMgr(mySqlConnectionString);
                ProductQuery query = new ProductQuery();
                query.isjoincate = true;
                query.IsPage = true;
                query.Start = int.Parse(Request.Form["start"] ?? "0");
                if (!string.IsNullOrEmpty(Request.Form["limit"]))
                {
                    query.Limit = Convert.ToInt32(Request.Form["limit"].ToString());
                }
                else
                {
                    query.Limit = 500;
                }
                uint isTryUint = 0;
                if (uint.TryParse(Request.Params["status"].ToString(), out isTryUint))
                {
                    query.Product_Status = Convert.ToUInt32(Request.Params["status"].ToString());
                }
                if (uint.TryParse(Request.Params["brand_id"].ToString(), out isTryUint))
                {
                    query.Brand_Id = Convert.ToUInt32(Request.Params["brand_id"].ToString());
                }
                else
                {
                    if (!string.IsNullOrEmpty(Request.Params["class_id"]))
                    {
                        VendorBrandSetMgr vbsMgr = new VendorBrandSetMgr(mySqlConnectionString);
                        VendorBrandSet vbs = new VendorBrandSet();
                        vbs.class_id = Convert.ToUInt32(Request.Form["class_id"]);
                        List<VendorBrandSet> vbsList = vbsMgr.Query(vbs);
                        foreach (VendorBrandSet item in vbsList)
                        {
                            query.brandArry += item.brand_id;
                            query.brandArry += ",";
                        }
                        query.brandArry = query.brandArry.Substring(0, query.brandArry.Length - 1);
                    }

                }
                if (!string.IsNullOrEmpty(Request.Params["keyCode"].ToString()))
                {
                    if (uint.TryParse(Request.Params["keyCode"].ToString(), out isTryUint))
                    {
                        query.Product_Id = Convert.ToUInt32(Request.Params["keyCode"].ToString());
                    }
                    else
                    {
                        query.Product_Name = Request.Params["keyCode"].ToString();
                    }
                }

                if (!string.IsNullOrEmpty(Request.Params["category_id"].ToString()))
                {
                    if (uint.TryParse(Request.Params["category_id"].ToString(), out isTryUint))
                    {
                        //判斷是否是父節點,若是則獲取所有的category_id
                        prodCateMgr = new ProductCategoryMgr(mySqlConnectionString);
                        List<ProductCategory> category = prodCateMgr.QueryAll(new ProductCategory());
                        GetAllCategory_id(category, Convert.ToUInt32(Request.Params["category_id"].ToString()), ref str);
                        query.categoryArry = str;
                    }
                }
                int totalCount = 0;
                List<ProductDetailsCustom> prods = _productMgr.GetAllProList(query, out totalCount);
                resultStr = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(prods) + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                resultStr = "{succes:false,totalCount:0,item:[]}";
            }


            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }