41 lines
999 B
C#
41 lines
999 B
C#
using MySqlConnector;
|
|
using skyscraper5.Skyscraper.Scraper.Storage.Split;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace skyscraper5.Data.MySql
|
|
{
|
|
public partial class MySqlDataStorage : DataStorage
|
|
{
|
|
private bool _askedForLocation;
|
|
private int? _cachedLocation;
|
|
|
|
public int? GetCurrentLocationId()
|
|
{
|
|
if (_askedForLocation)
|
|
return _cachedLocation;
|
|
|
|
|
|
int? result = null;
|
|
using (MySqlConnection connection = new MySqlConnection(_mcsb.ToString()))
|
|
{
|
|
connection.Open();
|
|
MySqlCommand command = connection.CreateCommand();
|
|
command.CommandText = "SELECT id FROM skyscraper_locations WHERE current = TRUE";
|
|
MySqlDataReader dataReader = command.ExecuteReader();
|
|
if (dataReader.Read())
|
|
result = dataReader.GetInt32(0);
|
|
dataReader.Close();
|
|
connection.Close();
|
|
}
|
|
|
|
_askedForLocation = true;
|
|
_cachedLocation = result;
|
|
return result;
|
|
}
|
|
}
|
|
}
|