コード例 #1
0
 public HttpResponseBase GetProCateBanList()
 {
     string json = string.Empty;
     List<ProductCategoryBannerQuery> store = new List<ProductCategoryBannerQuery>();
     ProductCategoryBannerQuery query = new ProductCategoryBannerQuery();
     try
     {
         query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
         query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "20");
         if (!string.IsNullOrEmpty(Request.Params["banner_id"]))
         {
             query.banner_cateid = Convert.ToUInt32(Request.Params["banner_id"]);
         }
         int totalCount = 0;
         _IProductCategoryBannerMgr = new ProductCategoryBannerMgr(mySqlConnectionString);
         store = _IProductCategoryBannerMgr.GetProCateBanList(query, out totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
     }
     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 = "{success:false,totalCount:0,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
コード例 #2
0
        public HttpResponseBase GetProductCatagory()
        {
            //吉甲地美安
            string resultStr = "";
            try
            {
                List<Parametersrc> Market = new List<Parametersrc>();
                _ptersrc = new ParameterMgr(mySqlConnectionString);
                Market = _ptersrc.GetAllKindType("market_category");//物流業者
               

                if (Market.Count > 0)
                {
                    ProductCategory category = new ProductCategory();
                    category.category_name = "新館";
                    List<ProductCategory> categoryStore = new List<ProductCategory>();//-------取新館的id用來獲取product_category_banner的子節點
                   // List<ProductCategory> categoryList = new List<ProductCategory>();
                    List<ProductCategoryCustom> cateList = new List<ProductCategoryCustom>();
                  
                    _procateMgr = new ProductCategoryMgr(mySqlConnectionString);
                   
                    categoryStore = _procateMgr.QueryAll(category);//
                    if (categoryStore.Count > 0)//取father_id;//在product_category表查詢新館的編號
                    {
                        category = categoryStore[0];
                    }
                    else 
                    {
                        category.category_id = 754;
                    }
                    ProductCategoryBannerQuery bannerquery = new ProductCategoryBannerQuery();//查詢裡面屬於新錧裡面美安的父元素和子元素
                    bannerquery.banner_cateid = uint.Parse(Market[0].ParameterCode);
                    bannerquery.IsPage = false;
                    _bannerMgr = new ProductCategoryBannerMgr(mySqlConnectionString);
                    List<ProductCategoryBannerQuery> bannerList = new List<ProductCategoryBannerQuery>();
                    int total = 0;
                    bannerList = _bannerMgr.GetProCateBanList(bannerquery, out total);
                   // categoryList = _procateMgr.GetProductCate(new ProductCategory { });

                    //cateList = getCate(categoryList, "2", Market[0].ParameterCode.ToString());
                    cateList = getCate(bannerList,category.category_id.ToString());
                    GetCategoryList(bannerList, ref cateList);
                   // GetCategoryList(categoryList, ref cateList);
                    resultStr = JsonConvert.SerializeObject(cateList);
                }


            }
            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);
            }

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