Example #1
0
        private void getCategoryFeatures()
        {
            GetCategoryFeaturesCall       api          = new GetCategoryFeaturesCall(_apiContext);
            DetailLevelCodeTypeCollection detailLevels = new DetailLevelCodeTypeCollection(new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll });

            api.DetailLevelList = detailLevels;

            // Make API call.
            api.GetCategoryFeatures(_categoryID, _levelLimit, _viewAllNodes, _featureIDs, _allFeaturesForCategory);
            _categoryFeatures = api.CategoryList;
            _categoryVersion  = api.CategoryVersion;
            _siteDefaults     = api.SiteDefaults;
            _siteFeatures     = api.FeatureDefinitions;
        }
		public static void GetAllCategoriesFeatures(ApiContext context)
		{
			FeaturesDownloader downloader = new FeaturesDownloader(context);
			GetCategoryFeaturesResponseType resp = downloader.GetCategoryFeatures();
			CategoryFeatureTypeCollection cfCol = resp.Category;
				
			//cache the features in hashtable	
			foreach(CategoryFeatureType cf in cfCol)
			{
				cfsTable.Add(cf.CategoryID, cf);
			}
			
			//cache site defaults
			siteDefaults = resp.SiteDefaults;
			//cahce feature definitions
			featureDefinition = resp.FeatureDefinitions;
		}
        public static void GetAllCategoriesFeatures(ApiContext context)
        {
            FeaturesDownloader downloader         = new FeaturesDownloader(context);
            GetCategoryFeaturesResponseType resp  = downloader.GetCategoryFeatures();
            CategoryFeatureTypeCollection   cfCol = resp.Category;

            //cache the features in hashtable
            foreach (CategoryFeatureType cf in cfCol)
            {
                cfsTable.Add(cf.CategoryID, cf);
            }

            //cache site defaults
            siteDefaults = resp.SiteDefaults;
            //cahce feature definitions
            featureDefinition = resp.FeatureDefinitions;
        }
Example #4
0
        private void populateCategoryList()
        {
            this.categoryListBox.Items.Clear();

            Hashtable        allCategories = controller.SiteFacade.GetAllCategoriesTable();
            Hashtable        cfsTable      = this.controller.SiteFacade.SiteCategoriesFeaturesTable[this.controller.ApiContext.Site] as Hashtable;
            SiteDefaultsType siteDefaults  = this.controller.SiteFacade.SiteFeatureDefaultTable[this.controller.ApiContext.Site] as SiteDefaultsType;

            for (int i = 0; i < sortedLeafCategories.Count; i++)
            {
                CategoryType cat        = (CategoryType)sortedLeafCategories.GetByIndex(i);
                string       categoryId = cat.CategoryID;
                String       catName    = cat.CategoryName;
                //check if category id is provided on SiteList form, if provided,
                //just list the provided category
                if (this.isCategoryIdProvided() && categoryId != catId)
                {
                    continue;
                }

                // Walk up the category hierarchy to see if itemspecifics is enabled for this category
                ItemSpecificsEnabledCodeType itemSpecificsEnabled = (siteDefaults.ItemSpecificsEnabledSpecified == true) ?
                                                                    siteDefaults.ItemSpecificsEnabled : ItemSpecificsEnabledCodeType.Disabled;
                while (true)
                {
                    CategoryFeatureType cft        = cfsTable[categoryId] as CategoryFeatureType;
                    CategoryType        currentCat = (CategoryType)allCategories[categoryId];
                    if (cft != null && cft.ItemSpecificsEnabledSpecified == true)
                    {
                        itemSpecificsEnabled = cft.ItemSpecificsEnabled;
                        break;
                    }
                    if (currentCat.CategoryLevelSpecified == true && currentCat.CategoryLevel == 1)
                    {
                        break;
                    }
                    categoryId = currentCat.CategoryParentID.ItemAt(0);
                }


                //ignore category which has no attributes or item specifics
                if (itemSpecificsEnabled.Equals(ItemSpecificsEnabledCodeType.Disabled))
                {
                    continue;
                }

                string name;
                string value;
                if (catName != null && catName.Length > 1)
                {
                    name  = cat.CategoryName + "(" + cat.CategoryID + ")";
                    value = cat.CategoryID;
                }
                else
                {
                    name  = cat.CharacteristicsSets[0].Name + "[" + cat.CategoryID + "]";
                    value = cat.CategoryID;
                }
                categoryListBox.Items.Add(new ListItem(name, value));
            }
        }
	 private void getCategoryFeatures() {
		 GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(_apiContext);
		 DetailLevelCodeTypeCollection detailLevels = new DetailLevelCodeTypeCollection( new DetailLevelCodeType[] {DetailLevelCodeType.ReturnAll});
		 api.DetailLevelList = detailLevels;

		 // Make API call.
         api.GetCategoryFeatures(_categoryID, _levelLimit, _viewAllNodes, _featureIDs, _allFeaturesForCategory);
		 _categoryFeatures = api.CategoryList;
		 _categoryVersion = api.CategoryVersion;
		 _siteDefaults = api.SiteDefaults;
		 _siteFeatures = api.FeatureDefinitions;
	 }
Example #6
0
        /// <summary>
        /// just support custom item specific. it would be enchance later.
        /// </summary>
        /// <param name="categoryID"></param>
        /// <param name="ids"></param>
        /// <returns></returns>
        private static bool isSupportFeature(int categoryID, FeatureIDCodeTypeCollection features, ApiContext apiContext, out bool isSupport, out string message)
        {
            isSupport = true;
            message   = string.Empty;

            GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(apiContext);

            setBasicInfo(ref api);
            //spcify category id
            api.CategoryID    = categoryID.ToString();
            api.FeatureIDList = features;
            try
            {
                //call
                CategoryFeatureTypeCollection featureTypes = api.GetCategoryFeatures();

                SiteDefaultsType siteDefaultsType = api.SiteDefaults;

                if (featureTypes != null && featureTypes.Count > 0)
                {
                    foreach (FeatureIDCodeType feature in features)
                    {
                        if (feature.ToString() == "ItemSpecificsEnabled")
                        {
                            // Check if the specified category is ItemspecificEnabled,
                            // Check for ItemspecificEnabled element in the features level
                            // If the tag does not occur then fetch it from site defaults
                            if (!featureTypes[0].ItemSpecificsEnabledSpecified)
                            {
                                if (siteDefaultsType.ItemSpecificsEnabledSpecified)
                                {
                                    if (siteDefaultsType.ItemSpecificsEnabled != ItemSpecificsEnabledCodeType.Enabled)
                                    {
                                        isSupport = false;
                                        message   = "ItemSpecificsEnabled is not supported!";
                                        break;
                                    }
                                }
                            }
                            else if (featureTypes[0].ItemSpecificsEnabled != ItemSpecificsEnabledCodeType.Enabled)
                            {
                                isSupport = false;
                                message   = "ItemSpecificsEnabled is not supported!";
                                break;
                            }
                        }

                        if (feature.ToString() == "AdFormatEnabled")
                        {
                            if (featureTypes[0].AdFormatEnabled != AdFormatEnabledCodeType.Enabled)
                            {
                                isSupport = false;
                                message   = "AdFormatEnabled is not supported!";
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                message = e.Message;
                return(false);
            }

            return(true);
        }
Example #7
0
        //
        //sync category features
        //
        private void SyncCategoryFeatures()
        {
            Hashtable catsTable = this.siteFacade.GetAllCategoriesTable();

            Hashtable              cfsTable          = this.siteFacade.SiteCategoriesFeaturesTable[this.apiContext.Site] as Hashtable;
            SiteDefaultsType       siteDefaults      = this.siteFacade.SiteFeatureDefaultTable[this.apiContext.Site] as SiteDefaultsType;
            FeatureDefinitionsType featureDefinition = this.siteFacade.SiteFeatureDefinitionsTable[this.apiContext.Site] as FeatureDefinitionsType;


            CategoryFeatureType cf = cfsTable[this.CategoryID] as CategoryFeatureType;

            //get item SpecificsEnabled feature
            //workaround, if no CategoryFeature found, just use site defaults
            this.ItemSpecificEnabled = (cf == null) ? siteDefaults.ItemSpecificsEnabled : cf.ItemSpecificsEnabled;

            //get item ConditionEnabled feature
            //workaround, if Disabled, just check parent
            CategoryFeatureType conditionEnabledCategoryFeature = this.getConditionEnabledCategoryFeature(this.CategoryID, catsTable, cfsTable);

            if (conditionEnabledCategoryFeature != null)
            {
                this.conditionEnabled = conditionEnabledCategoryFeature.ConditionEnabled;
                this.conditionValues  = conditionEnabledCategoryFeature.ConditionValues;
            }
            else
            {
                this.conditionEnabled = siteDefaults.ConditionEnabled;
                this.conditionValues  = siteDefaults.ConditionValues;
            }
            if (cf != null && cf.ConditionValues != null)
            {
                this.conditionValues = cf.ConditionValues;
            }
            //this.conditionValues = (cf == null || cf.ConditionValues == null) ? siteDefaults.ConditionValues : cf.ConditionValues;

            //get returnPolicyEnabled feature
            //workaround, just use siteDefaults now
            //bool retPolicyEnabled = (cf == null)?siteDefaults.ReturnPolicyEnabled:cf.ReturnPolicyEnabled;
            this.ReturnPolicyEnabled = siteDefaults.ReturnPolicyEnabled;

            //listing types, recursively search
            ListingDurationReferenceTypeCollection listingTypes = getListingTypes(this.CategoryID, catsTable, cfsTable);

            if (listingTypes == null || listingTypes.Count == 0)//get site defaults
            {
                listingTypes = siteDefaults.ListingDuration;
            }
            //listing duration definitions
            ListingDurationDefinitionsType listingDurations = featureDefinition.ListingDurations;

            //get a mapping from listing type to duration
            this.ListingType2DurationMap = constructListingTypeDurationMapping(listingTypes, listingDurations);

            //payment methods
            BuyerPaymentMethodCodeTypeCollection paymentMethods = getPaymentMethods(this.CategoryID, catsTable, cfsTable);

            if (paymentMethods == null || paymentMethods.Count == 0)//get site defautls
            {
                paymentMethods = siteDefaults.PaymentMethod;
            }
            this.PaymentMethod = paymentMethods;
        }