//根据单品,楼层,特约商户,查询品牌列表 public List <t_brand> GetBrandListByProductAndFloor(String productText, String floorText, bool VipFlag) { List <t_brand> brandList = new List <t_brand>(); //品牌列表 List <String> code_list = new List <String>(); //楼层 String floor_code = String.Empty; //判断单品是否为空 if (!String.IsNullOrWhiteSpace(productText)) { t_word p_word = getWordBySynonym(productText); //判断业态是否可以查询到 if (null != p_word) { //查询到则获得bp列表 List <t_brand_product> bp_list = bpDao.getproductByBrandAndProduct(null, p_word.code); //t_brand_product有把brand_code存起来 if (bp_list.Count > 0) { foreach (t_brand_product brand_product in bp_list) { code_list.Add(brand_product.brand_code); } } //t_brand_businessformat没有就返回空列表 else { return(brandList); } } //业态查询不到就返回空列表 else { return(brandList); } } //判断楼层是否为空 if (!String.IsNullOrWhiteSpace(floorText)) { t_word f_word = getWordBySynonym(floorText); //判断楼层是否可以查询到 if (null != f_word) { floor_code = f_word.code; } //楼层查询不到就返回空列表 else { return(brandList); } } brandList = brandDao.getBrandByCondition(code_list.ToArray(), floor_code, VipFlag); if (brandList.Count >= 5) { brandList = brandList.Take(5).ToList(); } return(brandList); }
public void test1Test() { try { BaseInfo bi = new BaseInfo(); bi.init(); SearchService ss = new SearchService(); BrandProductDao bpDao = new BrandProductDao(); ReadProduct rf = new ReadProduct(); if (null != ReadProduct.list) { int i = 0; foreach (string s in ReadProduct.list) { Debug.WriteLine(s); string brand = s.Split(',')[0]; string product = s.Split(',')[1]; string brand_code = string.Empty; string product_word_code = string.Empty; brand_code = String.IsNullOrWhiteSpace(brand) ? "" : (null == ss.getWordBySynonym(brand)) ? "" : ss.getWordBySynonym(brand).code; if (String.IsNullOrWhiteSpace(brand_code)) { Debug.WriteLine("没查出brand_code" + brand); i++; Debug.WriteLine(i); continue; } product_word_code = String.IsNullOrWhiteSpace(product) ? "" : ss.getWordBySynonym(product).code; if (String.IsNullOrWhiteSpace(product_word_code)) { Debug.WriteLine("brand_code = " + brand + " ; product_word_code = " + product + " 无值"); } else { //判断是否重复 List <t_brand_product> list = bpDao.getproductByBrandAndProduct(brand_code, product_word_code); if (list.Count > 0) { Debug.WriteLine("brand_code = " + brand + " ; product_word_code = " + product + " 重复"); } else { t_brand_product bp = new t_brand_product() { brand_code = brand_code, product_word_code = product_word_code }; bpDao.add(bp); Debug.WriteLine("brand_code = " + brand + " ; product_word_code = " + product + " 可以写入"); } } i++; Debug.WriteLine(i); } } else { Debug.WriteLine("list = null" + " ; path = " + ReadProduct.path); } } catch (DbEntityValidationException ex) { Debug.WriteLine(ex.ToString()); StringBuilder errors = new StringBuilder(); IEnumerable <DbEntityValidationResult> validationResult = ex.EntityValidationErrors; foreach (DbEntityValidationResult result in validationResult) { ICollection <DbValidationError> validationError = result.ValidationErrors; foreach (DbValidationError err in validationError) { errors.Append(err.PropertyName + ":" + err.ErrorMessage + "\r\n"); } } Debug.WriteLine(errors.ToString()); //简写 //var validerr = ex.EntityValidationErrors.First().ValidationErrors.First(); //Console.WriteLine(validerr.PropertyName + ":" + validerr.ErrorMessage); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }