Blueprint loading works
This commit is contained in:
51
EveCalc.Shared/StaticData/StaticDataProvider.cs
Normal file
51
EveCalc.Shared/StaticData/StaticDataProvider.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using EveCalc.Shared.ObjectModel;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EveCalc.Shared.StaticData
|
||||
{
|
||||
public class StaticDataProvider
|
||||
{
|
||||
public StaticDataProvider()
|
||||
{
|
||||
}
|
||||
public List<BlueprintMaterial> GetMaterialsForBlueprint(long id)
|
||||
{
|
||||
var result = new List<BlueprintMaterial>();
|
||||
|
||||
using (var connection = new SqliteConnection("Data Source=StaticData\\staticdata.sqlite"))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @"select materialTypeID, invTypes.typename, quantity "
|
||||
+ "from industryActivityMaterials "
|
||||
+ "inner join invTypes on invTypes.typeID=industryActivityMaterials.materialTypeID "
|
||||
+ "where blueprintTypeID=$id";
|
||||
command.Parameters.AddWithValue("id", id);
|
||||
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
var material = new BlueprintMaterial();
|
||||
material.MaterialTypeId = reader.GetInt64(0);
|
||||
material.MaterialTypeName = reader.GetString(1);
|
||||
material.Quantity = reader.GetInt64(2);
|
||||
result.Add(material);
|
||||
}
|
||||
}
|
||||
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user