Example #1
0
        public void DisplayAttributes(IAttributeSetCollection joinedAttrSets)
        {
            webBrowser.Document.OpenNew(true);

            AddHtmlHeaders();

            string tableText = this.controller.SiteFacade.AttributesMaster.RenderHtml(joinedAttrSets, null);
            webBrowser.Document.Write(tableText);

            AddHtmlTails();
        }
		/// <summary>
		/// Get xml that contains multiple CSs. Only set AttributeSet.CSId
		/// and AttributeSet.ProductId (optional).
		/// </summary>
		/// <param name="asList">List of <c>AttributeSet</c> objects for which
		/// you want to get CSXml.</param>
		/// <returns>The CS xml for specified CSs.</returns>
		public XmlDocument GetMultipleCSXml(IAttributeSetCollection asList)
		{
			bool validVersion = validateCurrentVersion();
			Int32Collection csIds = new Int32Collection();
			if(asList != null) 
			{
				foreach(AttributeSet ast in asList) 
				{
					if(ast == null) 
					{
						continue;
					}
					csIds.Add(ast.attributeSetID);
				}
			}
			ATTR_XML_FILE_NAME_PREFIX = createXmlFilePrefix(csIds.ToArray());
			DownloadXml();
			if(!validateCurrentVersion()) 
			{
				init();
			}

			XmlDocument xml = ExtractMultiCSFromXml(mXml, csIds, true);
			
			return xml;
		}
		/// <summary>
		/// Get xml that contains multiple CSs. Only set AttributeSet.CSId
		/// and AttributeSet.ProductId (optional).
		/// </summary>
		/// <param name="asList">List of <c>AttributeSet</c> objects for which
		/// you want to get CSXml.</param>
		/// <returns>The CS xml text for specified CSs.</returns>
		public string GetMultipleCSXmlText(IAttributeSetCollection asList)
		{
			XmlDocument xml = GetMultipleCSXml(asList);
			return xml.InnerXml;

		}
		private IAttributeSetCollection ExcludeReturnPolicyFromSiteWideAttributes(IAttributeSetCollection siteWideAttributeSet) 
		{
			if(siteWideAttributeSet == null) 
			{
				return null;
			}
			AttributeSet retPolicyAttrSet = GetReturnPolicyAttributeSet(siteWideAttributeSet);
			if(retPolicyAttrSet == null) 
			{
				return siteWideAttributeSet;
			}
			int retPolicyAttrId = retPolicyAttrSet.attributeSetID;
			IAttributeSetCollection attrList = new AttributeSetCollection();
			foreach(AttributeSet swAttrSet in siteWideAttributeSet) 
			{
				if(swAttrSet.attributeSetID == retPolicyAttrId) 
				{
					continue;
				} 
				else 
				{
					attrList.Add(swAttrSet);
				}
			}
			return attrList;
		}
		/// <summary>
		/// Validate <c>IAttributeSetCollection</c> object against eBay Attributes rules.
		/// IErrorSetCollection.Count == 0 means validation succeeded. Otherwise means failure and you
		/// have to call the above RenderHtml... methods and pass in the <c>IErrorSetCollection</c> object
		/// to re-generate Attributes HTML text that contains all the error messages.
		/// </summary>
		/// <param name="attrSets">The <c>IAttributeSetCollection</c> object which you want to validate.</param>
		/// <returns>The returned <c>IAttributeSetCollection</c> object. IAttributeSetCollection == 0 means 
		/// validation succeeded.</returns>
		public IErrorSetCollection Validate(IAttributeSetCollection attrSets)
		{
			IErrorSetCollection errList = new ErrorSetCollection();

			foreach(AttributeSet attrSet in attrSets)
			{
				IErrorSet errSet = ValidateOneSet(attrSet);
				if (errSet != null) 
					errList.Add(errSet);
			}

			return errList;
		}
		/// <summary>
		/// Extracts AttributeSet object for Return Policy from site wide attribute sets.
		/// </summary>
		/// <param name="siteWideAttrSets">IAttributeSetCollection</param>
		/// <returns>Return Policy AttributeSet object</returns>
		public AttributeSet GetReturnPolicyAttributeSet(IAttributeSetCollection siteWideAttrSets) 
		{
			AttributeSet retVal = null;
			foreach(AttributeSet attrSet in siteWideAttrSets)
			{
				if(attrSet.Name.Equals(RETURN_POLICY)) 
				{
					retVal = attrSet;
					break;
				}
			}	
	    
			return retVal;
		}
		/// <summary>
		/// Creates an array AttributeSet objects which contains item specific attribute sets and
		/// site wide attribute sets with the exception of the attribute set for return policy. 
		/// </summary>
		/// <param name="itemSpecAttrSets">IAttributeSetCollection</param>
		/// <param name="swAttrSets">IAttributeSetCollection</param>
		/// <returns>Joined collection of of item specific attributes sets and site wide attribute sets, except Return Policy</returns>
		public IAttributeSetCollection JoinItemSpecificAndSiteWideAttributeSets(IAttributeSetCollection itemSpecAttrSets, IAttributeSetCollection swAttrSets) 
		{
			if(swAttrSets == null || swAttrSets.Count == 0) 
			{
				if(itemSpecAttrSets == null || itemSpecAttrSets.Count == 0) 
				{
					return null;
				} 
				else 
				{
					return itemSpecAttrSets;
				}
			}
	  
			// Exclude Return Policy:
			IAttributeSetCollection swAttrNoRetPolicySets = ExcludeReturnPolicyFromSiteWideAttributes(swAttrSets);
			if(swAttrNoRetPolicySets == null || swAttrNoRetPolicySets.Count == 0) 
			{
				return itemSpecAttrSets;
			}

			// Append Site Wide attributes to the Site Specific attributes:
			IAttributeSetCollection joinedAttrSet = new AttributeSetCollection();
			if(itemSpecAttrSets!=null)
			{
				foreach(AttributeSet itemSpecAttrSet in itemSpecAttrSets) 
				{
					joinedAttrSet.Add(itemSpecAttrSet);
				}
			}
			foreach(AttributeSet swAttrNoRetPolicySet in swAttrNoRetPolicySets) 
			{
				joinedAttrSet.Add(swAttrNoRetPolicySet);
			}
	  
			return joinedAttrSet;
		}
		/// <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;
		}
		/// <summary>
		/// Render HTML text by specifying list of AttributeSet and xsl Document. 
		/// </summary>
		/// <param name="attrSets">List of AttributeSet objects.</param>
		/// <param name="xslDoc">Xsl Document</param>
		/// <param name="errorList">The <c>IErrorSetCollection</c> object returned by <c>Validate</c> method.
		/// Set null if you don't have one.</param>
		/// <returns>The generated HTML text that is encapsulated in HTML table element.</returns>
		public string RenderHtml(IAttributeSetCollection attrSets, DOMDocument30 xslDoc, IErrorSetCollection errorList) 
		{
			mXslDoc = xslDoc;
			return RenderHtml(attrSets, errorList);
		}
		/// <summary>
		/// Render HTML text by specifying list of AttributeSet.
		/// </summary>
		/// <param name="attrSets">List of AttributeSet objects.</param>
		/// <param name="errorList">The <c>IErrorSetCollection</c> object returned by <c>Validate</c> method.
		/// Set null if you don't have one.</param>
		/// <returns>The generated HTML text that is encapsulated in HTML table element.</returns>
		public string RenderHtml(IAttributeSetCollection attrSets, IErrorSetCollection errorList)
		{
			StringBuilder sb = new StringBuilder();

			// Add identification information for parsing.
			int ordinal = 0;
			foreach(AttributeSet attrSet in attrSets)
			{
				string goodProdId = (attrSet.ProductID != null && attrSet.ProductID.Length > 0) ? attrSet.ProductID : "";
				AddHiddenInputTag(sb, CAT_CS_ID + ordinal.ToString(), 
					attrSet.CategoryID.ToString() + "_" + attrSet.attributeSetID.ToString() + "_" + goodProdId);
				ordinal ++;
			}

			XmlDocument xmlDoc = mXmlProvider.GetMultipleCSXml(attrSets);

			// Add SelectedAttributes node.
			XmlNode selectedAttributes = xmlDoc.CreateElement(SELECTED_ATTRIBUTES);
			XmlNode eBayNode = xmlDoc.SelectSingleNode("//eBay");
			eBayNode.AppendChild(selectedAttributes);
			foreach(AttributeSet attrSet in attrSets) 
			{
				string attrSetName = attrSet.Name;
				if(attrSetName != null && attrSetName.Equals(RETURN_POLICY)) 
				{
					XmlAttribute retPolicyAttr = xmlDoc.CreateAttribute(PAGE_ID);
					retPolicyAttr.Value = RETURN_POLICY_PAGE_ID;
					selectedAttributes.Attributes.Append(retPolicyAttr);
				} 
				selectedAttributes.AppendChild(GetSelectedAttributesXml(xmlDoc, attrSet));
			}

			// Add error node.
			XmlNode errNode = null;
			if( errorList != null && errorList.Count != 0 ) 
			{
				errNode = AddErrorElements(xmlDoc, eBayNode, errorList);
			}
			// Generate html text.
			DOMDocument30 doc = new DOMDocument30();
			doc.loadXML(xmlDoc.InnerXml);
			mXmlToRender = doc;
			string table = doc.transformNode(this.mXslDoc);
			sb.Append(table);

			// Cleanup.
			if( errNode != null ) 
			{
				eBayNode.RemoveChild(errNode);
			}
			eBayNode.RemoveChild(selectedAttributes);

			return sb.ToString();
		}
Example #11
0
 /// <summary>
 /// Adds the contents of the specified IAttributeSetCollection 
 /// to the end of the collection.
 /// </summary>
 /// <param name="items"></param>
 public void AddRange(IAttributeSetCollection items)
 {
     InnerList.AddRange(items);
 }
Example #12
0
        /// <summary>
        /// Initializes a new instance containing the elements of 
        /// the specified source collection.
        /// </summary>
        /// <param name="value"></param>
        public AttributeSetCollection(
			IAttributeSetCollection value
			)
        {
            AddRange(value);
        }
Example #13
0
        private void SyncJoinedAttrSets()
        {
            Int32Collection ids = new Int32Collection();
            int catId = Int32.Parse(this.CategoryID);
            ids.Add(catId);

            IAttributeSetCollection itemSpecAttrSets = this.attrMaster.GetItemSpecificAttributeSetsForCategories(ids);
            IAttributeSetCollection siteWideAttrSets = this.attrMaster.GetSiteWideAttributeSetsForCategories(ids);
            IAttributeSetCollection joinedAttrSets = this.attrMaster.JoinItemSpecificAndSiteWideAttributeSets(itemSpecAttrSets, siteWideAttrSets);

            this.joinedAttrSets = joinedAttrSets;
        }