public void SortPrice() { var page = new SortProduct(_webDriver); page.SelectItemByVisibleText("Name (Z to A)"); WebDriverHelper.Wait(_webDriver); page.SelectItemByIndex(3); WebDriverHelper.Wait(_webDriver); }
/// <summary> /// 产品加入排序池的运算方法 /// </summary> /// <param name="OcsCategoryNo">OCS分类编号</param> /// <param name="ProductNo">产品编号</param> /// <returns>0为失败,1为成功</returns> public int AddProductToSort(string OcsCategoryNo, string OcsCategoryName, string CateGoryType, SortProduct Product) { int result = 0; if (IsExitProduct(OcsCategoryNo, Product.ProductNo)) //判断产品是否存在 { #region SWfsSortOcsCategory CateDtos = IsRuleCategory(OcsCategoryNo); //该系列没有加入排序 if (CateDtos == null) { //添加ocs分类 SWfsSortOcsCategory SDto = new SWfsSortOcsCategory { IsApplyRule = false, CategoryName = OcsCategoryName, CategoryNo = OcsCategoryNo, AutoLastFlag = 0, DateUpdate = Convert.ToDateTime("1900-01-01"), DateCreate = DateTime.Now, CategoryType = Convert.ToInt16(CateGoryType) }; AddOcsCategory(SDto); SWfsSortProduct pDto = new SWfsSortProduct() { OcsCategoryNo = OcsCategoryNo, ProductNo = Product.ProductNo, Sort = 1, RuleId = 0, DateCreate = DateTime.Now }; AddProductToSortSingle(pDto); result = 1; } //该分类已经加入排序 else { //已经执行规则 if (CateDtos.IsApplyRule) { List <SWfsSortRule> NDto = GetRuleByCategoryNo(OcsCategoryNo); //查找分类下的规则 SWfsSortRule RuleDto = GetSmallRuleFromListByProduct(NDto, Product); //查找分类最小规则 SWfsSortProduct NproductDto = new SWfsSortProduct(); int RuleId = 0; if (RuleDto == null || RuleDto.RuleId + "" == "") { NproductDto = GetMinProductByCategory(OcsCategoryNo);//查询未匹配上的最小产品 RuleId = -1; } else { NproductDto = GetRuleMinProduct(RuleDto.RuleId + "", OcsCategoryNo);//根据最小规则查找最小产品 RuleId = RuleDto.RuleId; } int SortId = NproductDto.Sort; SWfsSortProduct pDto = new SWfsSortProduct() { OcsCategoryNo = OcsCategoryNo, ProductNo = Product.ProductNo, Sort = SortId, RuleId = RuleId, DateCreate = DateTime.Now }; AddProductToSortSingle(pDto); } //未执行规则 else { SWfsSortProduct NDto = GetCategoryMaxProduct(OcsCategoryNo); int sortId = NDto.Sort + 1; SWfsSortProduct pDto = new SWfsSortProduct() { OcsCategoryNo = OcsCategoryNo, ProductNo = Product.ProductNo, Sort = sortId, RuleId = 0, DateCreate = DateTime.Now }; AddProductToSortSingle(pDto); } result = 1; } #endregion } return(result); }
/// <summary> /// 查找产品对应的最小的规则表 /// </summary> /// <param name="list"></param> /// <param name="Product"></param> /// <returns></returns> public SWfsSortRule GetSmallRuleFromListByProduct(List <SWfsSortRule> list, SortProduct Product) { SWfsSortRule result = new SWfsSortRule(); SWfsSortRule resultBese = new SWfsSortRule(); SWfsSortRule resultChriden = new SWfsSortRule(); foreach (SWfsSortRule item in list) { switch (item.RuleType) { case 1: //分类 if (Product.CategoryNo == item.RuleObjectNo) { if (item.ParentId == 0) { resultBese = item; } else { resultChriden = item; } } break; case 2: //品牌 if (Product.BrandNo == item.RuleObjectNo) { if (item.ParentId == 0) { resultBese = item; } else { resultChriden = item; } } break; case 3: //色系 if (Product.ProductPrimaryColorNO == item.RuleObjectNo) { if (item.ParentId == 0) { resultBese = item; } else { resultChriden = item; } } break; case 4: //价格 if (Product.PriceNo + "" == item.RuleObjectNo) { if (item.ParentId == 0) { resultBese = item; } else { resultChriden = item; } } break; case 6: //其他 foreach (SWfsSortRule itemOther in list) { if (itemOther.ParentId == item.RuleId) { switch (itemOther.RuleType) { case 1: //分类 if (Product.CategoryNo == itemOther.RuleObjectNo) { resultChriden = itemOther; } break; case 2: //品牌 if (Product.BrandNo == itemOther.RuleObjectNo) { resultChriden = itemOther; } break; case 3: //色系 if (Product.ProductPrimaryColorNO == itemOther.RuleObjectNo) { resultChriden = itemOther; } break; case 4: //价格 if (Product.PriceNo + "" == itemOther.RuleObjectNo) { resultChriden = itemOther; } break; default: resultChriden = item; break; } } } if (resultBese.RuleId < 1 && resultChriden.RuleId < 1) { resultChriden = item; } break; } } if (resultChriden.RuleObjectNo != "") { result = resultChriden; } else if (resultBese.RuleObjectNo != "") { result = resultBese; } else { result = null; } return(result); }