public HttpResponseBase GetFrontCatagory() { List<ProductCategory> categoryList = new List<ProductCategory>(); List<ProductCategoryCustom> cateList = new List<ProductCategoryCustom>(); string resultStr = ""; try { _procateMgr = new ProductCategoryMgr(connectionString); categoryList = _procateMgr.QueryAll(new ProductCategory { }); cateList = getCate(categoryList, 0); GetFrontCateList(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; }
public HttpResponseBase GetCatagory(string id = "true") { List<ProductCategory> categoryList = new List<ProductCategory>(); List<ProductCategoryCustom> cateList = new List<ProductCategoryCustom>(); string resultStr = ""; try { _procateMgr = new ProductCategoryMgr(connectionString); categoryList = _procateMgr.QueryAll(new ProductCategory { }); cateList = getCate(categoryList, "5"); List<ProductCategorySetTemp> TempresultList = new List<ProductCategorySetTemp>(); List<ProductCategorySet> resultList = new List<ProductCategorySet>(); ProductCategorySetTemp query = new ProductCategorySetTemp(); if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { uint product_id = 0; if (uint.TryParse(Request.Form["ProductId"], out product_id)) //正式表數據 { _categorySetMgr = new ProductCategorySetMgr(connectionString); resultList = _categorySetMgr.Query(new ProductCategorySet { Product_Id = uint.Parse(Request.Params["ProductId"]) }); } else { query.Product_Id = Request.Params["ProductId"]; } } //query.Writer_Id = (int)vendorModel.vendor_id; //query.Combo_Type = COMBO_TYPE; _categoryTempSetMgr = new ProductCategorySetTempMgr(connectionString); TempresultList = (from c in _categoryTempSetMgr.QueryByVendor(query) select new { Id = c.Id, Product_Id = c.Product_Id, Category_Id = c.Category_Id, Brand_Id = c.Brand_Id }).ToList().ConvertAll<ProductCategorySetTemp>(m => new ProductCategorySetTemp { Id = m.Id, Product_Id = m.Product_Id, Category_Id = m.Category_Id, Brand_Id = m.Brand_Id }); GetCategoryList(categoryList, ref cateList, TempresultList, resultList); List<ProductCategoryCustom> cateListResult = new List<ProductCategoryCustom>(); cateListResult = getCate(categoryList, "0"); cateListResult[0].children = getCate(categoryList, cateListResult[0].id.ToString()); int cateLen = cateListResult[0].children.Count; int i = 0; while (cateLen > 0) { if (cateListResult[0].children[i].id == "5") { i++; } else { cateListResult[0].children.Remove(cateListResult[0].children[i]); } cateLen--; } cateListResult[0].children[0].children = cateList; resultStr = JsonConvert.SerializeObject(cateListResult); resultStr = resultStr.Replace("Checked", "checked"); } 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; }