Ejemplo n.º 1
0
 public AttributeTypeCollection Read(EntityType entityType, IEntityTypeRepository entityTypeRepository)
 {
     var attributes = new AttributeTypeCollection();
     using (SqlConnection sqlConnection = _connectionProvider.GetConnection())
     {
         using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
         {
             sqlCommand.CommandText = string.Format("SELECT * FROM hsck.AttributeTypes WHERE EntityTypeId='{0}'", entityType.Id);
             using (SqlDataReader reader = sqlCommand.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     var dataType = (DataType) Enum.Parse(typeof (DataType), (string) reader["DataType"]);
                     var attributeType = new AttributeType
                                             {
                                                 Id = (int) reader["Id"],
                                                 Name = (string) reader["Name"],
                                                 DataType = dataType
                                             };
                     attributes.Add(attributeType);
                 }
             }
         }
     }
     attributes.Add(_entityAttributeTypeRepository.Read(entityType, entityTypeRepository));
     return attributes;
 }
 public AttributeTypeCollection Read(EntityType entityType, IEntityTypeRepository entityTypeRepository)
 {
     var attributes = new AttributeTypeCollection();
     using (SqlConnection sqlConnection = _connectionProvider.GetConnection())
     {
         using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
         {
             sqlCommand.CommandText =
                 string.Format(
                     "SELECT * FROM hsck.EntityAttributeTypes WHERE ParentEntityTypeName='{0}'",
                     entityType.Name);
             using (SqlDataReader reader = sqlCommand.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     var entityTypeName = (string) reader["ChildEntityTypeName"];
                     var attributeName = (string) reader["Name"];
                     EntityType ofType = entityTypeName == entityType.Name
                                             ? entityType
                                             : entityTypeRepository.Read(entityTypeName);
                     var entityAttributeType =
                         new EntityAttributeType
                             {
                                 Id = (int) reader["Id"],
                                 Name = attributeName,
                                 OfType = ofType
                             };
                     attributes.Add(entityAttributeType);
                 }
             }
         }
     }
     return attributes;
 }
 public AttributeTypeCollection FetchAll()
 {
     AttributeTypeCollection coll = new AttributeTypeCollection();
     Query qry = new Query(AttributeType.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
Ejemplo n.º 4
0
 public void AddAttributes(AttributeTypeCollection collection)
 {
     foreach (AttributeType attributeType in collection)
     {
         Attributes.Add(attributeType);
     }
 }
 public void Create(AttributeTypeCollection attributeTypeCollection, EntityType onEntity)
 {
     foreach (AttributeType attributeType in attributeTypeCollection)
     {
         if (attributeType is EntityAttributeType)
         {
             Create(attributeType as EntityAttributeType, onEntity);
         }
     }
 }
Ejemplo n.º 6
0
        public ValueList GetColumn(string column)
        {
            if (column.StartsWith("&"))
            {
                throw new NoSuchAttributeException(column);
            }

            if (!_headersMap.TryGetValue(column, out var position))
            {
                throw new NoSuchAttributeException(column);
            }

            var result      = _rows.Select(row => row[position]).ToList();
            var elementType = AttributeTypeCollection.ComputeElementType(result);

            return(new ValueList(result, elementType));
        }
Ejemplo n.º 7
0
        private static AttributeTypeCollection ConvertAttributeArray(AttributeTypeCollection from)
        {
            AttributeTypeCollection toAttrs = new AttributeTypeCollection();

            foreach (AttributeType fromA in from)
            {
                AttributeType toA = new AttributeType();

                toA.Any                  = fromA.Any;
                toA.attributeID          = fromA.attributeID;
                toA.attributeIDSpecified = fromA.attributeIDSpecified;
                toA.Value                = ConvertValTypeCollection(fromA.Value);

                toAttrs.Add(toA);
            }

            return(toAttrs);
        }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
0
 public void Create(AttributeTypeCollection attributeTypeCollection, EntityType entityType)
 {
     foreach (AttributeType attributeType in attributeTypeCollection)
     {
         Create(attributeType, entityType);
     }
 }
Ejemplo n.º 10
0
		private static AttributeTypeCollection ConvertAttributeArray(AttributeTypeCollection from)
		{
			AttributeTypeCollection toAttrs = new AttributeTypeCollection();

			foreach(AttributeType fromA in from)
			{
				AttributeType toA = new AttributeType();

				toA.Any = fromA.Any;
				toA.attributeID = fromA.attributeID;
				toA.attributeIDSpecified = fromA.attributeIDSpecified;
				toA.Value = ConvertValTypeCollection(fromA.Value);

				toAttrs.Add(toA);
			}

			return toAttrs;
		}
 public AttributeTypeCollection FetchByQuery(Query qry)
 {
     AttributeTypeCollection coll = new AttributeTypeCollection();
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
 public AttributeTypeCollection FetchByID(object AttributeTypeId)
 {
     AttributeTypeCollection coll = new AttributeTypeCollection().Where("AttributeTypeId", AttributeTypeId).Load();
     return coll;
 }
Ejemplo n.º 13
0
 public EntityType()
 {
     Attributes = new AttributeTypeCollection();
 }