示例#1
0
        /// <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());
        }
示例#2
0
        private static XmlNode AddErrorElements(XmlDocument doc, XmlNode eBayNode, IErrorSetCollection errList)
        {
            XmlNode errors = doc.CreateElement("Errors");

            eBayNode.AppendChild(errors);
            foreach (ErrorSet errSet in errList)
            {
                XmlNode err = errSet.toXml(doc);
                errors.AppendChild(err);
            }

            return(errors);
        }
示例#3
0
        public void DisplayAttributesWithValidationError(NameValueCollection request, IErrorSetCollection errList)
        {
            webBrowser.Document.OpenNew(true);

            AddHtmlHeaders();

            AttributesMaster attrMaster = this.controller.SiteFacade.AttributesMaster;

            string tableText = attrMaster.RenderHtmlForPostback(AttributesHelper.ConvertFromNameValues(request), errList);

            webBrowser.Document.Write(tableText);

            AddHtmlTails();
        }
示例#4
0
		/// <summary>
		/// Adds the contents of the specified IErrorSetCollection 
		/// to the end of the collection.
		/// </summary>
		/// <param name="items"></param>
		public void AddRange(IErrorSetCollection items)
		{
			InnerList.AddRange(items);
		}
示例#5
0
		/// <summary>
		/// Initializes a new instance containing the elements of 
		/// the specified source collection.
		/// </summary>
		/// <param name="value"></param>
		public ErrorSetCollection(
			IErrorSetCollection value
			)
		{
			AddRange(value);
		}
示例#6
0
        /// <summary>
        /// Render HTML text by raw name-value pairs that you got during HTML submit.
        /// </summary>
        /// <param name="nameValues">List of name-value pairs from submit of attributes HTML form
        /// generated by all these RenderHtml methods.</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 RenderHtmlForPostback(IKeyValueCollection nameValues, IErrorSetCollection errorList)
        {
            IAttributeSetCollection attrSets = NameValuesToAttributeSets(nameValues);

            return(RenderHtml(attrSets, errorList));
        }
示例#7
0
 /// <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));
 }
		private static XmlNode AddErrorElements(XmlDocument doc, XmlNode eBayNode, IErrorSetCollection errList)
		{
			XmlNode errors = doc.CreateElement("Errors");
			eBayNode.AppendChild(errors);
			foreach (ErrorSet errSet in errList) 
			{
				XmlNode err = errSet.toXml(doc);
				errors.AppendChild(err);
			}

			return errors;
		}
		/// <summary>
		/// Render HTML text by raw name-value pairs that you got during HTML submit. 
		/// </summary>
		/// <param name="nameValues">List of name-value pairs from submit of attributes HTML form
		/// generated by all these RenderHtml methods.</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 RenderHtmlForPostback(IKeyValueCollection nameValues, IErrorSetCollection errorList)
		{
			IAttributeSetCollection attrSets = NameValuesToAttributeSets(nameValues);
			return RenderHtml(attrSets, errorList);
		}
		/// <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();
		}
示例#12
0
 /// <summary>
 /// Adds the contents of the specified IErrorSetCollection
 /// to the end of the collection.
 /// </summary>
 /// <param name="items"></param>
 public void AddRange(IErrorSetCollection items)
 {
     InnerList.AddRange(items);
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance containing the elements of
 /// the specified source collection.
 /// </summary>
 /// <param name="value"></param>
 public ErrorSetCollection(
     IErrorSetCollection value
     )
 {
     AddRange(value);
 }
示例#14
0
        private void DisplayAttributes(NameValueCollection request, IErrorSetCollection errList)
        {
            AttributesMaster attrMaster = (AttributesMaster)Session[Global.ATTRIBUTES_MASTER];

            AddHtmlHeaders();

            string tableText=string.Empty;

            // For the first time we have only categoryId and categoryId2 but we don't
            // have any attributes request data so we have to use RenderHtmlForCategories to generate the html text.
            string strCatId = request[CategoryList.CAT_ID];
            if( strCatId != null && strCatId.Length != 0 )
            {
                Int32Collection ids = new Int32Collection();
                int catId = Int32.Parse(strCatId);
                ids.Add(catId);

                Session["CategoryId"] = catId;
                Session["Category2Id"] = 0;

                strCatId = request[CategoryList.CAT_ID2];
                if( strCatId != null && strCatId.Length != 0 )
                {
                    catId = Int32.Parse(strCatId);
                    ids.Add(catId);

                    Session["Category2Id"] = catId;
             				}
                IAttributeSetCollection itemSpecAttrSets = attrMaster.GetItemSpecificAttributeSetsForCategories(ids);
                IAttributeSetCollection siteWideAttrSets = attrMaster.GetSiteWideAttributeSetsForCategories(ids);
                Session[Global.ITEM_SITE_WIDE_ATTR_SETS] = siteWideAttrSets;
                IAttributeSetCollection joinedAttrSets = attrMaster.JoinItemSpecificAndSiteWideAttributeSets(itemSpecAttrSets, siteWideAttrSets);
                Session[Global.JOINED_ATTR_SETS] = joinedAttrSets;
                if(joinedAttrSets!=null)
                {
                    tableText = attrMaster.RenderHtml(joinedAttrSets, errList);
                }
            }
            else
            {
                tableText = attrMaster.RenderHtmlForPostback(AttributesHelper.ConvertFromNameValues(request), errList);
            }

            IAttributeSetCollection attrSets = Session[Global.JOINED_ATTR_SETS] as IAttributeSetCollection;
            if (attrSets != null && attrSets.Count > 0)
            {
                hasAttributes = true;
            }
            else
            {
                hasAttributes = false;
            }

            Response.Write(tableText);

            AddCustomItemSpecificsHtml();

            AddHtmlTails();
        }