/// <summary>
		/// Get the first ValueLiteral of an attribute node.
		/// </summary>
		/// <param name="ast"></param>
		/// <param name="attributeID"></param>
		/// <returns></returns>
		public static string GetValueLiteral(AttributeSetType ast, int attributeID)
		{
			AttributeType attr = FindAttribute(ast, attributeID);
			if( attr != null && attr.Value != null && attr.Value.Count > 0 )
			{
				return attr.Value[0].ValueLiteral;
			}
			return null;
		}
		/// <summary>
		/// Find an attribute node.
		/// </summary>
		/// <param name="ast"></param>
		/// <param name="attributeID"></param>
		/// <returns></returns>
		public static AttributeType FindAttribute(AttributeSetType ast, int attributeID)
		{
			foreach(AttributeType attr in ast.Attribute)
			{
				if( attr.attributeID == attributeID )
					return attr;
			}
			return null;
		}
Example #3
0
 /// <summary>
 /// Get the first ValueID of an attribute node.
 /// </summary>
 /// <param name="ast"></param>
 /// <param name="attributeID"></param>
 /// <returns></returns>
 public static int GetValueID(AttributeSetType ast, int attributeID)
 {
     AttributeType attr = FindAttribute(ast, attributeID);
     if( attr != null && attr.Value != null && attr.Value.Count > 0 )
     {
         return attr.Value[0].ValueID;
     }
     return 0;
 }
Example #4
0
        /// <summary>
        /// Get the first ValueID of an attribute node.
        /// </summary>
        /// <param name="ast"></param>
        /// <param name="attributeID"></param>
        /// <returns></returns>
        public static int GetValueID(AttributeSetType ast, int attributeID)
        {
            AttributeType attr = FindAttribute(ast, attributeID);

            if (attr != null && attr.Value != null && attr.Value.Count > 0)
            {
                return(attr.Value[0].ValueID);
            }
            return(0);
        }
Example #5
0
        /// <summary>
        /// Get the first ValueLiteral of an attribute node.
        /// </summary>
        /// <param name="ast"></param>
        /// <param name="attributeID"></param>
        /// <returns></returns>
        public static string GetValueLiteral(AttributeSetType ast, int attributeID)
        {
            AttributeType attr = FindAttribute(ast, attributeID);

            if (attr != null && attr.Value != null && attr.Value.Count > 0)
            {
                return(attr.Value[0].ValueLiteral);
            }
            return(null);
        }
Example #6
0
 /// <summary>
 /// Find an attribute node.
 /// </summary>
 /// <param name="ast"></param>
 /// <param name="attributeID"></param>
 /// <returns></returns>
 public static AttributeType FindAttribute(AttributeSetType ast, int attributeID)
 {
     foreach (AttributeType attr in ast.Attribute)
     {
         if (attr.attributeID == attributeID)
         {
             return(attr);
         }
     }
     return(null);
 }
Example #7
0
        /// <summary>
        /// Remove an attribute from the AttributeSetType object.
        /// </summary>
        /// <param name="ast"></param>
        /// <param name="attributeID"></param>
        /// <returns>True means the attribute has been found and removed.</returns>
        public static bool RemoveAttribute(AttributeSetType ast, int attributeID)
        {
            AttributeType attr = FindAttribute(ast, attributeID);

            if (attr != null)
            {
                ast.Attribute.Remove(attr);
                return(true);
            }
            return(false);
        }
		/// <summary>
		/// Insert an attribute node to AttributeSetType or update the existing attribute node.
		/// </summary>
		/// <param name="ast"></param>
		/// <param name="attributeID"></param>
		/// <param name="valueID"></param>
		/// <param name="valStr"></param>
		public static void InsertToAttributeSet(AttributeSetType ast, int attributeID, int valueID, string valStr)
		{
			AttributeType attr = FindAttribute(ast, attributeID);
			if( attr == null )
			{
				attr = new AttributeType();
				attr.attributeID = attributeID;
				ast.Attribute.Add(attr);
			}

			ValType v = new ValType();
			v.ValueID = valueID;
			v.ValueLiteral = valStr;

			attr.Value = new ValTypeCollection();
			attr.Value.Add(v);
		}
Example #9
0
        public void GetItemRecommendationsFull()
        {
            bool   isTherePropertyNull;
            int    nullPropertyNums;
            string nullPropertyNames;

            Assert.IsNotNull(TestData.NewItem2, "Failed because no item available -- requires successful AddItem test");
            //
            GetItemRecommendationsCall                       api  = new GetItemRecommendationsCall(this.apiContext);
            GetRecommendationsRequestContainerType           req  = new GetRecommendationsRequestContainerType();
            GetRecommendationsRequestContainerTypeCollection reqc = new GetRecommendationsRequestContainerTypeCollection();

            reqc.Add(req);
            req.Item                 = TestData.NewItem2;
            req.ListingFlow          = ListingFlowCodeType.AddItem;
            req.RecommendationEngine = new RecommendationEngineCodeTypeCollection();
            req.RecommendationEngine.Add(RecommendationEngineCodeType.ListingAnalyzer);
            req.RecommendationEngine.Add(RecommendationEngineCodeType.SuggestedAttributes);
            req.RecommendationEngine.Add(RecommendationEngineCodeType.ProductPricing);
            req.Query = "shoe";
            GetRecommendationsResponseContainerTypeCollection resps = api.GetItemRecommendations(reqc);

            //check whether the call is success.
            Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "do not success!");
            Assert.IsNotNull(resps);
            Assert.IsTrue(resps.Count > 0);
            if (resps[0].AttributeRecommendations != null &&
                resps[0].AttributeRecommendations.AttributeSetArray != null &&
                resps[0].AttributeRecommendations.AttributeSetArray.Count > 0)
            {
                AttributeSetType attributeSet = resps[0].AttributeRecommendations.AttributeSetArray[0];

                isTherePropertyNull = ReflectHelper.IsProperteValueNotNull(attributeSet, out nullPropertyNums, out nullPropertyNames);
                Assert.IsTrue(isTherePropertyNull, "there are" + nullPropertyNums.ToString() + " properties value is null. (" + nullPropertyNames + ")");

                if (attributeSet.Attribute != null && attributeSet.Attribute.Count > 0)
                {
                    AttributeType attribute = attributeSet.Attribute[0];

                    isTherePropertyNull = ReflectHelper.IsProperteValueNotNull(attribute, out nullPropertyNums, out nullPropertyNames);
                    Assert.IsTrue(isTherePropertyNull, "there are" + nullPropertyNums.ToString() + " properties value is null. (" + nullPropertyNames + ")");
                }
            }
        }
Example #10
0
        /// <summary>
        /// Convert attribute set array to the format of ItemType for AddItemCall.
        /// </summary>
        /// <param name="attrSets">The attribute set list generated by AttributeMaster.</param>
        /// <returns>The converted array that is compatible with ItemType in AddItemCall.</returns>
        public AttributeSetTypeCollection ConvertAttributeSetArray(IAttributeSetCollection attrSets)
        {
            AttributeSetTypeCollection toSets = new AttributeSetTypeCollection();

            foreach (AttributeSetType from in attrSets)
            {
                AttributeSetType toAst = new AttributeSetType();

                toAst.Any                     = from.Any;
                toAst.attributeSetID          = from.attributeSetID;
                toAst.attributeSetIDSpecified = from.attributeSetIDSpecified;
                toAst.attributeSetVersion     = from.attributeSetVersion;
                toAst.Attribute               = ConvertAttributeArray(from.Attribute);

                toSets.Add(toAst);
            }

            return(toSets);
        }
Example #11
0
        /// <summary>
        /// Insert an attribute node to AttributeSetType or update the existing attribute node.
        /// </summary>
        /// <param name="ast"></param>
        /// <param name="attributeID"></param>
        /// <param name="valueID"></param>
        /// <param name="valStr"></param>
        public static void InsertToAttributeSet(AttributeSetType ast, int attributeID, int valueID, string valStr)
        {
            AttributeType attr = FindAttribute(ast, attributeID);

            if (attr == null)
            {
                attr             = new AttributeType();
                attr.attributeID = attributeID;
                ast.Attribute.Add(attr);
            }

            ValType v = new ValType();

            v.ValueID      = valueID;
            v.ValueLiteral = valStr;

            attr.Value = new ValTypeCollection();
            attr.Value.Add(v);
        }
Example #12
0
        /// <summary>
        /// get all attributes from the charactersic with which the specific category is mapping
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="apiContext"></param>
        /// <returns></returns>
        private static AttributeSetTypeCollection GetAttributeSetCol(int categoryId,ApiContext apiContext)
        {
            IAttributesMaster attributesMaster=new AttributesMaster();
            AttributeSetTypeCollection attributeSTC=new AttributeSetTypeCollection();

            attributesMaster.CategoryCSProvider=new CategoryCSDownloader(apiContext);
            attributesMaster.XmlProvider=new AttributesXmlDownloader(apiContext);
            //get the characteristic set id of the specified category
            IAttributeSetCollection attributeSetCol=attributesMaster.GetItemSpecificAttributeSetsForCategories(new Int32Collection(new int[]{categoryId}));

            Assert.IsNotNull(attributeSetCol);

            IAttributesXmlProvider iaxp=attributesMaster.XmlProvider;
            //download all attributes from ebay
            XmlDocument document=iaxp.DownloadXml();
            //write the memory xml to disk
            WriteXMLToDisk(document);
            AttributeSetTypeCollection attributeSetTypeCol=new AttributeSetTypeCollection();
            //get Required Item specifics by call getAttributesCS
            foreach(AttributeSet attributeSet in attributeSetCol)
            {
                AttributeSetType attributeST=new AttributeSetType();
                attributeST.attributeSetID=attributeSet.attributeSetID;
                String xpath="//Characteristics/CharacteristicsSet[@id='"+attributeSet.attributeSetID.ToString()+"']//CharacteristicsList//Initial//Attribute";
                XmlNodeList nodeList;
                XmlNode root = document.DocumentElement;
                nodeList=root.SelectNodes(xpath);
                AttributeTypeCollection attributeTypeCol=new AttributeTypeCollection();
                foreach (XmlNode node in nodeList)
                {
                    AttributeType attributeT=new AttributeType();
                    XmlAttributeCollection attributes=node.Attributes;
                    Assert.IsNotNull(attributes);
                 	XmlNode idNode = attributes.GetNamedItem("id");
                    attributeT.attributeID=int.Parse(idNode.Value);
                    ValTypeCollection valTypeCol=getValue(node);
                    if(valTypeCol==null)
                    {
                        System.Console.WriteLine("can not find any specific value!");
                    }
                    attributeT.Value=valTypeCol;
                    attributeTypeCol.Add(attributeT);
                }

                attributeST.Attribute=attributeTypeCol;
                attributeSTC.Add(attributeST);
            }
            return attributeSTC;
        }
		/// <summary>
		/// Remove an attribute from the AttributeSetType object.
		/// </summary>
		/// <param name="ast"></param>
		/// <param name="attributeID"></param>
		/// <returns>True means the attribute has been found and removed.</returns>
		public static bool RemoveAttribute(AttributeSetType ast, int attributeID)
		{
			AttributeType attr = FindAttribute(ast, attributeID);
			if( attr != null )
			{
				ast.Attribute.Remove(attr);
				return true;
			}
			return false;
		}
		/// <summary>
		/// Convert attribute set array to the format of ItemType for AddItemCall.
		/// </summary>
		/// <param name="attrSets">The attribute set list generated by AttributeMaster.</param>
		/// <returns>The converted array that is compatible with ItemType in AddItemCall.</returns>
		public AttributeSetTypeCollection ConvertAttributeSetArray(IAttributeSetCollection attrSets)
		{
			AttributeSetTypeCollection toSets = new AttributeSetTypeCollection();

			foreach(AttributeSetType from in attrSets)
			{
				AttributeSetType toAst = new AttributeSetType();

				toAst.Any = from.Any;
				toAst.attributeSetID = from.attributeSetID;
				toAst.attributeSetIDSpecified = from.attributeSetIDSpecified;
				toAst.attributeSetVersion = from.attributeSetVersion;
				toAst.Attribute = ConvertAttributeArray(from.Attribute);

				toSets.Add(toAst);
			}

			return toSets;
		}
Example #15
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="ast">The object that contains the motor attributes that you want to access.</param>
 public MotorAttributeHelper(AttributeSetType ast)
 {
     this.mSet = ast;
 }
Example #16
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="ast">The object that contains the motor attributes that you want to access.</param>
 public MotorAttributeHelper(AttributeSetType ast)
 {
     this.mSet = ast;
 }