private Station GetConquerableStationByID(int stationID) { System.Net.WebClient webClient = new System.Net.WebClient(); webClient.Headers.Add("user-agent", "LogisticiansTools: - Contact Natalie Cruella"); string URL = string.Format("{0}/eve/ConquerableStationList.xml.aspx", _baseEveApi); System.IO.Stream dataStream = webClient.OpenRead(URL); string XMLData = new System.IO.StreamReader(dataStream).ReadToEnd(); XmlDocument doc = new XmlDocument(); doc.LoadXml(XMLData); XmlNodeList nodes = doc.GetElementsByTagName("row"); Station station = new Station(); foreach (XmlNode node in nodes) { if (Convert.ToInt32(node.Attributes["stationID"].Value) == stationID) { station = new Station() { StationID = stationID, SolarSystemID = Convert.ToInt32(node.Attributes["solarSystemID"].Value), StationName = node.Attributes["stationName"].Value.ToString() }; _connectionObject.Close(); station.SolarSystem = GetSolarSystemByID(station.SolarSystemID); return station; } } return station; }
public Station GetStationByID(int stationID) { SQLiteCommand _cmd = _connectionObject.CreateCommand(); _cmd.CommandText = "SELECT * FROM staStations WHERE stationID = '" + stationID + "'"; _connectionObject.Open(); SQLiteDataReader reader = _cmd.ExecuteReader(); Station station = new Station(); if (reader.Read()) { station = DataAccess.BuildObjects.BuildStation(ref reader); _connectionObject.Close(); station.SolarSystem = GetSolarSystemByID(station.SolarSystemID); } else station = GetConquerableStationByID(stationID); _connectionObject.Close(); return station; }