/// <summary> /// check an category whether it is catalog-enabled. /// </summary> /// <param name="apiContext"></param> /// <param name="categorid"></param> /// <param name="isCatalogEnable"></param> /// <param name="message"></param> /// <returns></returns> private static bool isCatagoryEnabled(ApiContext apiContext,string categorid,CategoryEnableCodeType enableType,out bool isEnable,out string message) { CategoryTypeCollection categories; isEnable=false; message=string.Empty; GetCategory2CSCall api =new GetCategory2CSCall(apiContext); DetailLevelCodeType detaillevel= DetailLevelCodeType.ReturnAll; api.DetailLevelList=new DetailLevelCodeTypeCollection(new DetailLevelCodeType[]{detaillevel}); api.CategoryID=categorid; try { categories = api.GetCategory2CS(); foreach(CategoryType category in categories) { if(string.Compare(category.CategoryID,categorid,false)==0) { if(enableType==CategoryEnableCodeType.CatalogEnabled) { isEnable=category.CatalogEnabled; break; } else if(enableType==CategoryEnableCodeType.ProductSearchPageAvailable) { isEnable=category.ProductSearchPageAvailable; break; } } } } catch(Exception e) { message=e.Message; return false; } return true; }
/// <summary> /// check whether the specified category is enable for its specific property. /// </summary> /// <param name="apiContext"></param> /// <param name="categorid"></param> /// <param name="isCatalogEnable"></param> /// <param name="message"></param> /// <returns></returns> public static bool IsCatagoryEnabled(ApiContext apiContext,string categorid,CategoryEnableCodeType enableType,out bool isCatalogEnable,out string message) { return isCatagoryEnabled(apiContext,categorid,enableType,out isCatalogEnable,out message); }
/// <summary> /// get a number of CatalogEnabled Categories. /// </summary> /// <param name="number"></param> /// <param name="apiContext"></param> /// <param name="categories"></param> /// <param name="message"></param> /// <returns></returns> private static bool getCatagoryEnabledCategory(int number,ApiContext apiContext,CategoryEnableCodeType enableType,out CategoryTypeCollection categories,out string message) { CategoryTypeCollection categoryTypeCollection; categories=new CategoryTypeCollection(); bool isSuccess,isCatalogEnable; if(number<=0) { number=1; } if(getAllCategories(apiContext,out categoryTypeCollection,out message)) { foreach(CategoryType category in categoryTypeCollection) { if(category.LeafCategory) { isSuccess = isCatagoryEnabled(apiContext,category.CategoryID,enableType,out isCatalogEnable,out message); if(isSuccess) { if(isCatalogEnable) { categories.Add(category); } if(categories.Count>=number) { return true; } } else { message=message+";get features failure!"; return false; } } }//end foreach return true; } return false; }
/// <summary> /// get a number of CatalogEnabled Categories. /// </summary> /// <param name="number">specify the number of categories that you want.</param> /// <param name="apiContext"></param> /// <param name="categories"></param> /// <param name="message"></param> /// <returns></returns> public static bool GetCatalogEnabledCategory(int number,ApiContext apiContext,CategoryEnableCodeType enableType,out CategoryTypeCollection categories,out string message) { return getCatagoryEnabledCategory(number,apiContext,enableType,out categories,out message); }