/// <summary> /// Returns collection of Site Wide AttributeSet objects for a given array category Ids. /// Each element of the array contains a VCS Id, if it exists for a given category Id. /// </summary> /// <param name="catIds">int[]</param> /// <returns>Collection of site wide AttributeSet objects</returns> public IAttributeSetCollection GetSiteWideAttributeSetsForCategories(Int32Collection catIds) { IAttributeSetCollection attrSetsList = new AttributeSetCollection(); int i = 0; foreach (int catId in catIds) { SiteWideCharacteristicsTypeCollection swAttrs = mCategoryCSProvider.GetSiteWideCharacteristics(catId.ToString()); foreach (SiteWideCharacteristicsType swChar in swAttrs) { AttributeSet swAst = new AttributeSet(); swAst.attributeSetID = swChar.CharacteristicsSet.AttributeSetID; swAst.CategoryID = catId; swAst.CategoryOrdinal = i++; swAst.Name = swChar.CharacteristicsSet.Name; attrSetsList.Add(swAst); } } return(attrSetsList); }
/// <summary> /// Get CharacteristicSet(CS) xml. This implementation does not support /// catalog, i.e., csInfo.ProductId will be ignored. /// </summary> /// <param name="csInfo">Identification information about the CS for which /// you want to get CSXml. You only need to set CS.CSId and, optionally, you can /// set CS.ProductId if you want to get the CSXml that is associated with /// specific product information. /// Set CS.CSId to 0 to get entire CharacteristicSet xml for all CSs.</param> /// <returns>The xml text of the CS.</returns> public string GetCSXmlText(AttributeSet csInfo) { if (csInfo == null) { return(null); } Int32Collection csIds = new Int32Collection(); csIds.Add(csInfo.attributeSetID); ATTR_XML_FILE_NAME_PREFIX = createXmlFilePrefix(csIds.ToArray()); if (!validateCurrentVersion()) { init(); } XmlDocument xml = ExtractCSFromXml(this.mXml, csInfo.attributeSetID, true); return(xml.InnerXml); }
/// <summary> /// Returns collection of item specific AttributeSet objects for an array category Ids. /// Each element of the array contains a VCS Id, if it exists for a given category Id. /// </summary> /// <param name="catIds">int[]</param> /// <returns>Collection of item specific AttributeSet objects</returns> public IAttributeSetCollection GetItemSpecificAttributeSetsForCategories(Int32Collection catIds) { IAttributeSetCollection sets = new AttributeSetCollection(); int i = 0; foreach (int catId in catIds) { AttributeSet ast = new AttributeSet(); int csId = mCategoryCSProvider.GetVCSId(catId); if (csId == 0) { return(null); //throw new SdkException("Unable to get CSID by category Id"); } ast.attributeSetID = csId; ast.CategoryID = catId; ast.CategoryOrdinal = i++; sets.Add(ast); } return(sets); }
/// <summary> /// Returns collection of item specific AttributeSet objects for an array category Ids. /// Each element of the array contains a VCS Id, if it exists for a given category Id. /// </summary> /// <param name="catIds">int[]</param> /// <returns>Collection of item specific AttributeSet objects</returns> public IAttributeSetCollection GetItemSpecificAttributeSetsForCategories(Int32Collection catIds) { IAttributeSetCollection sets = new AttributeSetCollection(); int i = 0; foreach(int catId in catIds) { AttributeSet ast = new AttributeSet(); int csId = mCategoryCSProvider.GetVCSId(catId); if (csId == 0) { return null; //throw new SdkException("Unable to get CSID by category Id"); } ast.attributeSetID = csId; ast.CategoryID = catId; ast.CategoryOrdinal = i++; sets.Add(ast); } return sets; }
/// <summary> /// Remove element from list. /// </summary> /// <param name="value"></param> public void Remove(AttributeSet value) { InnerList.Remove(value); }
/// <summary> /// Insert element to list. /// </summary> /// <param name="index"></param> /// <param name="value"></param> public void Insert(int index, AttributeSet value) { InnerList.Insert(index, value); }
/// <summary> /// Indicates whether a specified object is contained in the list. /// </summary> /// <param name="value"></param> /// <returns></returns> public bool Contains(AttributeSet value) { return(InnerList.Contains(value)); }
private XmlNode GetSelectedAttributesXml(XmlDocument doc, AttributeSet attrSet) { XmlNode attrSetNode = doc.CreateElement(ATTRIBUTE_SET); XmlUtility.AddAttributeNode(doc, attrSetNode, ID, attrSet.attributeSetID.ToString()); if (attrSet.Attribute != null) { foreach (Attribute attr in attrSet.Attribute) { XmlNode attrNode = XmlUtility.AddChild(doc, attrSetNode, ATTRIBUTE); XmlUtility.AddAttributeNode(doc, attrNode, ID, attr.attributeID.ToString()); XmlNode valueElement; Value val; if (attr.Type == AttributeTypes.ATTR_ID) { CheckSingleValueListItem(attr); val = (Value)attr.Value[0]; valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddAttributeNode(doc, valueElement, ID, val.ValueID); if (val.ValueID == (int)ValueIds.OTHER && val.ValueLiteral != null) { // Add one more Attribute node with the same id. XmlNode attrOther = XmlUtility.AddChild(doc, attrSetNode, ATTRIBUTE); XmlUtility.AddAttributeNode(doc, attrOther, ID, attr.attributeID.ToString()); XmlNode v_e = XmlUtility.AddChild(doc, attrOther, VALUE); XmlUtility.AddChild(doc, v_e, NAME, val.ValueLiteral); } } else if (attr.Type == AttributeTypes.ATTR_IDS) { foreach (Value v_s in attr.Value) { valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddAttributeNode(doc, valueElement, ID, v_s.ValueID); } } else if (attr.Type == AttributeTypes.ATTR_TEXT) { CheckSingleValueListItem(attr); val = (Value)attr.Value[0]; valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddChild(doc, valueElement, NAME, val.ValueLiteral); /* * if( val.ValueId == (int)ValueIds.OTHER ) * { * // Add another attribute node with the same attribute Id * XmlNode attrOther = XmlUtility.AddChild(doc, attrSetNode, ATTRIBUTE); * XmlUtility.AddAttributeNode(doc, attrOther, ID, attr.AttributeId.ToString()); * * valueElement = XmlUtility.AddChild(doc, attrOther, VALUE); * XmlUtility.AddAttributeNode(doc, valueElement, ID, val.ValueId.ToString()); * } */ } else if (attr.Type == AttributeTypes.ATTR_TEXT_DATE) { CheckSingleValueListItem(attr); val = (Value)attr.Value[0]; valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddAttributeNode(doc, valueElement, ID, val.ValueID); AddDateToValueNode(valueElement, val.ValueLiteral); } else { // Unsupported attribute type. foreach (Value v_o in attr.Value) { valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddChild(doc, valueElement, NAME, v_o.ValueLiteral); if (v_o.ValueID != 0) { XmlUtility.AddAttributeNode(doc, valueElement, ID, v_o.ValueID.ToString()); } } } } } return(attrSetNode); }
/// <summary> /// Get CharacteristicSet(CS) xml. This implementation does not support /// catalog, i.e., csInfo.ProductId will be ignored. /// </summary> /// <param name="csInfo">Identification information about the CS for which /// you want to get CSXml. You only need to set CS.CSId and, optionally, you can /// set CS.ProductId if you want to get the CSXml that is associated with /// specific product information. /// Set CS.CSId to 0 to get entire CharacteristicSet xml for all CSs.</param> /// <returns>The xml text of the CS.</returns> public string GetCSXmlText(AttributeSet csInfo) { if(csInfo == null) { return null; } Int32Collection csIds = new Int32Collection(); csIds.Add(csInfo.attributeSetID); ATTR_XML_FILE_NAME_PREFIX = createXmlFilePrefix(csIds.ToArray()); if(!validateCurrentVersion()) { init(); } XmlDocument xml = ExtractCSFromXml(this.mXml, csInfo.attributeSetID, true); return xml.InnerXml; }
private IErrorSet ValidateOneSet(AttributeSet attrSet) { IErrorSet errSet = null; XmlDocument xml = new XmlDocument(); xml.LoadXml(this.XmlProvider.GetCSXmlText(attrSet)); foreach(Attribute attr in attrSet.Attribute ) { string select = getRuleSelectString(attrSet.attributeSetID, attr.attributeID); XmlNodeList rules = xml.SelectNodes(select); int rCnt = rules.Count; for (int r = 0; r < rCnt; r++) { IError err = ValidateAttr(attr, rules.Item(r)); if (err != null) { if (errSet == null) errSet = new ErrorSet(attrSet.attributeSetID); errSet.Add(err); } } } return errSet; }
/// <summary> /// Add element. /// </summary> /// <param name="value"></param> /// <returns></returns> public int Add(AttributeSet value) { return InnerList.Add(value); }
/// <summary> /// Initializes a new instance containing the specified array /// of AttributeSet objects /// </summary> /// <param name="value"></param> public AttributeSetCollection( AttributeSet[] value ) { AddRange(value); }
/// <summary> /// Get index of an element. /// </summary> /// <param name="value"></param> /// <returns></returns> public int IndexOf(AttributeSet value) { return(InnerList.IndexOf(value)); }
/// <summary> /// Returns collection of Site Wide AttributeSet objects for a given array category Ids. /// Each element of the array contains a VCS Id, if it exists for a given category Id. /// </summary> /// <param name="catIds">int[]</param> /// <returns>Collection of site wide AttributeSet objects</returns> public IAttributeSetCollection GetSiteWideAttributeSetsForCategories(Int32Collection catIds) { IAttributeSetCollection attrSetsList = new AttributeSetCollection(); int i = 0; foreach(int catId in catIds) { SiteWideCharacteristicsTypeCollection swAttrs = mCategoryCSProvider.GetSiteWideCharacteristics(catId.ToString()); foreach(SiteWideCharacteristicsType swChar in swAttrs) { AttributeSet swAst = new AttributeSet(); swAst.attributeSetID = swChar.CharacteristicsSet.AttributeSetID; swAst.CategoryID = catId; swAst.CategoryOrdinal = i++; swAst.Name = swChar.CharacteristicsSet.Name; attrSetsList.Add(swAst); } } return attrSetsList; }
private XmlNode GetSelectedAttributesXml(XmlDocument doc, AttributeSet attrSet) { XmlNode attrSetNode = doc.CreateElement(ATTRIBUTE_SET); XmlUtility.AddAttributeNode(doc, attrSetNode, ID, attrSet.attributeSetID.ToString()); if( attrSet.Attribute != null ) { foreach(Attribute attr in attrSet.Attribute) { XmlNode attrNode = XmlUtility.AddChild(doc, attrSetNode, ATTRIBUTE); XmlUtility.AddAttributeNode(doc, attrNode, ID, attr.attributeID.ToString()); XmlNode valueElement; Value val; if( attr.Type == AttributeTypes.ATTR_ID ) { CheckSingleValueListItem(attr); val = (Value)attr.Value[0]; valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddAttributeNode(doc, valueElement, ID, val.ValueID); if( val.ValueID == (int)ValueIds.OTHER && val.ValueLiteral != null ) { // Add one more Attribute node with the same id. XmlNode attrOther = XmlUtility.AddChild(doc, attrSetNode, ATTRIBUTE); XmlUtility.AddAttributeNode(doc, attrOther, ID, attr.attributeID.ToString()); XmlNode v_e = XmlUtility.AddChild(doc, attrOther, VALUE); XmlUtility.AddChild(doc, v_e, NAME, val.ValueLiteral); } } else if( attr.Type == AttributeTypes.ATTR_IDS ) { foreach(Value v_s in attr.Value ) { valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddAttributeNode(doc, valueElement, ID, v_s.ValueID); } } else if( attr.Type == AttributeTypes.ATTR_TEXT ) { CheckSingleValueListItem(attr); val = (Value)attr.Value[0]; valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddChild(doc, valueElement, NAME, val.ValueLiteral); /* if( val.ValueId == (int)ValueIds.OTHER ) { // Add another attribute node with the same attribute Id XmlNode attrOther = XmlUtility.AddChild(doc, attrSetNode, ATTRIBUTE); XmlUtility.AddAttributeNode(doc, attrOther, ID, attr.AttributeId.ToString()); valueElement = XmlUtility.AddChild(doc, attrOther, VALUE); XmlUtility.AddAttributeNode(doc, valueElement, ID, val.ValueId.ToString()); } */ } else if( attr.Type == AttributeTypes.ATTR_TEXT_DATE ) { CheckSingleValueListItem(attr); val = (Value)attr.Value[0]; valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddAttributeNode(doc, valueElement, ID, val.ValueID); AddDateToValueNode(valueElement, val.ValueLiteral); } else { // Unsupported attribute type. foreach(Value v_o in attr.Value ) { valueElement = XmlUtility.AddChild(doc, attrNode, VALUE); XmlUtility.AddChild(doc, valueElement, NAME, v_o.ValueLiteral); if( v_o.ValueID != 0 ) XmlUtility.AddAttributeNode(doc, valueElement, ID, v_o.ValueID.ToString()); } } } } return attrSetNode; }
/// <summary> /// Add an array of AttributeSet. /// </summary> /// <param name="items"></param> public void AddRange(AttributeSet[] items) { InnerList.AddRange(items); }
private static AttributeSet Compile(Hashtable ht, string vcsid) { AttributeSet attrSet = new AttributeSet(); attrSet.attributeSetID = int.Parse(vcsid); attrSet.Attribute = new AttributeTypeCollection(); int cnt = ht.Count; ICollection coll = ht.Keys; IEnumerator iter = coll.GetEnumerator(); string key; object val; AttrInfo info; ArrayList al; Attribute attr = null; while (iter.MoveNext()) { key = iter.Current.ToString(); val = ht[key]; if (val is ArrayList) { al = (ArrayList)val; cnt = al.Count; // Option Other if (cnt == 2) { AttrInfo info0 = (AttrInfo)al[0]; AttrInfo info1 = (AttrInfo)al[1]; if (info0.typeId == AttributeTypes.ATTR_ID) { attr = ExtractAttr2(info0, info1); attrSet.Attribute.Add(attr); } else if (info1.typeId == AttributeTypes.ATTR_ID) { attr = ExtractAttr2(info1, info0); attrSet.Attribute.Add(attr); } else { //Unknow type. } } // DateTime else if (cnt == 3) { string day = null, month = null, year = null; for (int i = 0; i < cnt; i++) { info = (AttrInfo)al[i]; switch (info.typeId) { case AttributeTypes.ATTR_DATE_D: day = info.val; break; case AttributeTypes.ATTR_DATE_M: month = info.val; break; case AttributeTypes.ATTR_DATE_Y: year = info.val; break; } } FixYMD(ref year, ref month, ref day); if (day != null && month != null && year != null) { info = (AttrInfo)al[0]; al.RemoveRange(0, cnt); info.typeId = AttributeTypes.ATTR_TEXT_DATE; info.val = year + month + day; al.Add(info); attr = ExtractAttr(info); attr.Value[0].ValueID = (int)ValueIds.COMPLETE_TEXT_DATE; attrSet.Attribute.Add(attr); } } } else { info = (AttrInfo)val; // Only year field. if (info.typeId == AttributeTypes.ATTR_DATE_Y) { string year = info.val, month = "0", day = "0"; FixYMD(ref year, ref month, ref day); info.typeId = AttributeTypes.ATTR_TEXT_DATE; info.val = year + month + day; attr = ExtractAttr(info); attr.Value[0].ValueID = (int)ValueIds.COMPLETE_TEXT_DATE; attrSet.Attribute.Add(attr); } else { attr = ExtractAttr(info); if (attr.Type == AttributeTypes.ATTR_TEXT) { attr.Value[0].ValueID = (int)ValueIds.TEXT; } attrSet.Attribute.Add(attr); } } } return(attrSet); }
/// <summary> /// Indicates whether a specified object is contained in the list. /// </summary> /// <param name="value"></param> /// <returns></returns> public bool Contains(AttributeSet value) { return InnerList.Contains(value); }
/// <summary> /// Copies the collection objects to a one-dimensional Array /// instance beginning at the specified index. /// </summary> /// <param name="array"></param> /// <param name="index"></param> public void CopyTo( AttributeSet[] array, int index ) { InnerList.CopyTo(array, index); }
/// <summary> /// Get index of an element. /// </summary> /// <param name="value"></param> /// <returns></returns> public int IndexOf(AttributeSet value) { return InnerList.IndexOf(value); }
private static AttributeSet Compile(Hashtable ht, string vcsid) { AttributeSet attrSet = new AttributeSet(); attrSet.attributeSetID = int.Parse(vcsid); attrSet.Attribute = new AttributeTypeCollection(); int cnt = ht.Count; ICollection coll = ht.Keys; IEnumerator iter = coll.GetEnumerator(); string key; object val; AttrInfo info; ArrayList al; Attribute attr = null; while(iter.MoveNext()) { key = iter.Current.ToString(); val = ht[key]; if (val is ArrayList) { al = (ArrayList)val; cnt = al.Count; // Option Other if (cnt == 2) { AttrInfo info0 = (AttrInfo)al[0]; AttrInfo info1 = (AttrInfo)al[1]; if (info0.typeId == AttributeTypes.ATTR_ID) { attr = ExtractAttr2(info0, info1); attrSet.Attribute.Add(attr); } else if (info1.typeId == AttributeTypes.ATTR_ID) { attr = ExtractAttr2(info1, info0); attrSet.Attribute.Add(attr); } else { //Unknow type. } } // DateTime else if (cnt == 3) { string day = null, month = null, year = null; for (int i = 0; i < cnt; i ++) { info = (AttrInfo)al[i]; switch(info.typeId) { case AttributeTypes.ATTR_DATE_D: day = info.val; break; case AttributeTypes.ATTR_DATE_M: month = info.val; break; case AttributeTypes.ATTR_DATE_Y: year = info.val; break; } } FixYMD(ref year, ref month, ref day); if (day != null && month!= null && year != null) { info = (AttrInfo)al[0]; al.RemoveRange(0, cnt); info.typeId = AttributeTypes.ATTR_TEXT_DATE; info.val = year + month + day; al.Add(info); attr = ExtractAttr(info); attr.Value[0].ValueID = (int)ValueIds.COMPLETE_TEXT_DATE; attrSet.Attribute.Add(attr); } } } else { info = (AttrInfo) val; // Only year field. if( info.typeId == AttributeTypes.ATTR_DATE_Y ) { string year = info.val, month = "0", day = "0"; FixYMD(ref year, ref month, ref day); info.typeId = AttributeTypes.ATTR_TEXT_DATE; info.val = year + month + day; attr = ExtractAttr(info); attr.Value[0].ValueID = (int)ValueIds.COMPLETE_TEXT_DATE; attrSet.Attribute.Add(attr); } else { attr = ExtractAttr(info); if( attr.Type == AttributeTypes.ATTR_TEXT ) attr.Value[0].ValueID = (int)ValueIds.TEXT; attrSet.Attribute.Add(attr); } } } return attrSet; }
/// <summary> /// Add element. /// </summary> /// <param name="value"></param> /// <returns></returns> public int Add(AttributeSet value) { return(InnerList.Add(value)); }