public static List <AttributeValue> GetAttributesForType(TypeID typeId)
        {
            var query = @"
SELECT ta.attributeID, valueInt, valueFloat, attributeName, at.description, at.displayName, at.categoryID, u.unitID, u.unitName, u.displayName, u.description
FROM dgmTypeAttributes AS ta
INNER JOIN dgmAttributeTypes AS at ON ta.attributeID = at.attributeID
INNER JOIN eveUnits AS u ON at.unitID = u.unitID
WHERE ta.typeID = " + typeId.ToInt() + @"
LIMIT 100
";

            using (var cnn = new SQLiteConnection(DefaultDatabase.dbConnection))
            {
                cnn.Open();

                var reader  = DefaultDatabase.RunSQLTableQuery(query, cnn);
                var results = new List <AttributeValue>();
                while (reader.Read())
                {
                    // todo: referencing columns by name doesn't seem to support names like at.description. There must be a better workaround for that
                    var unitDesc     = reader[10];
                    var unitDispName = reader[9];
                    var unit         = Unit.Get(new UnitID((byte)reader[7]),
                                                (string)reader[8],
                                                unitDispName is DBNull ? "" : (string)unitDispName,
                                                unitDesc     is DBNull ? "" : (string)unitDesc);
                    var attrDispName = reader[5];
                    var attribute    = new Attribute(new AttributeID((short)reader[0]),
                                                     (string)reader[3],
                                                     attrDispName is DBNull ? "" : (string)attrDispName,
                                                     (string)reader[4],
                                                     unit,
                                                     AttributeCategory.Get((byte)reader[6]));

                    AttributeValue value;
                    if (reader["valueFloat"] is DBNull)
                    {
                        value = new AttributeValue(attribute, (int)reader[1]);
                    }
                    else
                    {
                        value = new AttributeValue(attribute, (float)(double)reader[2]);
                    }
                    results.Add(value);
                }
                return(results);
            }
        }
Exemple #2
0
 public Attribute(AttributeID id, string name, string dName, string desc, Unit unit, AttributeCategory cat)
 {
     ID            = id;
     AttributeName = name;
     DisplayName   = dName;
     Description   = desc;
     Unit          = unit;
     Category      = cat;
 }