mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Update to database version 3.
This commit is contained in:
@@ -5,7 +5,4 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MySql.Data" Version="6.10.6" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Schemas\Create" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -73,5 +73,7 @@ namespace Cicm.Database
|
||||
/// </summary>
|
||||
/// <returns>Data adapter</returns>
|
||||
IDbDataAdapter GetNewDataAdapter();
|
||||
|
||||
bool TableExists(string tableName);
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@ namespace Cicm.Database
|
||||
$"server={server};user={user};database={database};port={port};password={password}";
|
||||
|
||||
connection = new MySqlConnection(connectionString);
|
||||
connection.Open();
|
||||
|
||||
Operations = new Operations(connection, this);
|
||||
|
||||
@@ -120,6 +121,7 @@ namespace Cicm.Database
|
||||
$"server={server};user={user};database={database};port={port};password={password}";
|
||||
|
||||
connection = new MySqlConnection(connectionString);
|
||||
connection.Open();
|
||||
|
||||
IDbCommand command = connection.CreateCommand();
|
||||
command.CommandText = $"CREATE DATABASE `{database}`;";
|
||||
@@ -154,6 +156,21 @@ namespace Cicm.Database
|
||||
return new MySqlDataAdapter();
|
||||
}
|
||||
|
||||
public bool TableExists(string tableName)
|
||||
{
|
||||
MySqlCommand cmd = connection.CreateCommand();
|
||||
cmd.CommandText =
|
||||
$"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{connection.Database}' AND table_name = '{tableName}'";
|
||||
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
|
||||
reader.Read();
|
||||
|
||||
int count = reader.GetInt32(0);
|
||||
reader.Close();
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
~Mysql()
|
||||
{
|
||||
CloseDb();
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from admin";
|
||||
const string SQL = "SELECT * from admins";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -88,7 +88,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM admin LIMIT {start}, {count}";
|
||||
string sql = $"SELECT * FROM admins LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -123,7 +123,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from admin WHERE id = '{id}'";
|
||||
string sql = $"SELECT * from admins WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -155,7 +155,7 @@ namespace Cicm.Database
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM admin";
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM admins";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
@@ -178,7 +178,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO admin (user, password)" + " VALUES (@user, @password)";
|
||||
const string SQL = "INSERT INTO admins (user, password)" + " VALUES (@user, @password)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE admin SET user = @user, password = @password " + $"WHERE id = {entry.Id}";
|
||||
string sql = "UPDATE admins SET user = @user, password = @password " + $"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM admin WHERE id = '{id}';";
|
||||
string sql = $"DELETE FROM admins WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
|
||||
@@ -179,8 +179,8 @@ namespace Cicm.Database
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL =
|
||||
"INSERT INTO browser_test (idstring, browser, version, os, platform, gif87, gif89, jpeg, png, pngt, agif, table, colors, js, frames, flash)" +
|
||||
" VALUES (@idstring, @browser, @version, @os, @platform, @gif87, @gif89, @jpeg, @png, @pngt, @agif, @table, @colors, @js, @frames, @flash)";
|
||||
"INSERT INTO browser_test (user_agent, browser, version, os, platform, gif87, gif89, jpeg, png, pngt, agif, table, colors, js, frames, flash)" +
|
||||
" VALUES (@user_agent, @browser, @version, @os, @platform, @gif87, @gif89, @jpeg, @png, @pngt, @agif, @table, @colors, @js, @frames, @flash)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace Cicm.Database
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql =
|
||||
"UPDATE browser_test SET idstring = @idstring, browser = @browser, version = @version, os = @os, platform = @platform, gif87 = @gif87, " +
|
||||
"UPDATE browser_test SET user_agent = @user_agent, browser = @browser, version = @version, os = @os, platform = @platform, gif87 = @gif87, " +
|
||||
"gif89 = @gif89, jpeg = @jpeg, png = @png, pngt = @pngt, agif = @agif, table = @table, colors = @colors, js = @js, frames = @frames, flash = @flash " +
|
||||
$"WHERE id = {entry.Id}";
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace Cicm.Database
|
||||
IDbDataParameter param15 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param16 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@idstring";
|
||||
param1.ParameterName = "@user_agent";
|
||||
param2.ParameterName = "@browser";
|
||||
param3.ParameterName = "@version";
|
||||
param4.ParameterName = "@os";
|
||||
@@ -353,22 +353,22 @@ namespace Cicm.Database
|
||||
BrowserTest entry = new BrowserTest
|
||||
{
|
||||
Id = ushort.Parse(dataRow["id"].ToString()),
|
||||
UserAgent = dataRow["idstring"].ToString(),
|
||||
UserAgent = dataRow["user_agent"].ToString(),
|
||||
Name = dataRow["browser"].ToString(),
|
||||
Version = dataRow["version"].ToString(),
|
||||
OperatingSystem = dataRow["os"].ToString(),
|
||||
Architecture = dataRow["platform"].ToString(),
|
||||
Gif87 = int.Parse(dataRow["gif87"].ToString()) > 0,
|
||||
Gif89 = int.Parse(dataRow["gif89"].ToString()) > 0,
|
||||
Jpeg = int.Parse(dataRow["jpeg"].ToString()) > 0,
|
||||
Png = int.Parse(dataRow["png"].ToString()) > 0,
|
||||
AlphaPng = int.Parse(dataRow["pngt"].ToString()) > 0,
|
||||
AnimatedGif = int.Parse(dataRow["agif"].ToString()) > 0,
|
||||
Tables = int.Parse(dataRow["table"].ToString()) > 0,
|
||||
Gif87 = int.Parse(dataRow["gif87"].ToString()) > 0,
|
||||
Gif89 = int.Parse(dataRow["gif89"].ToString()) > 0,
|
||||
Jpeg = int.Parse(dataRow["jpeg"].ToString()) > 0,
|
||||
Png = int.Parse(dataRow["png"].ToString()) > 0,
|
||||
AlphaPng = int.Parse(dataRow["pngt"].ToString()) > 0,
|
||||
AnimatedGif = int.Parse(dataRow["agif"].ToString()) > 0,
|
||||
Tables = int.Parse(dataRow["table"].ToString()) > 0,
|
||||
Color = int.Parse(dataRow["colors"].ToString()) > 0,
|
||||
Js = int.Parse(dataRow["js"].ToString()) > 0,
|
||||
Js = int.Parse(dataRow["js"].ToString()) > 0,
|
||||
Frames = int.Parse(dataRow["frames"].ToString()) > 0,
|
||||
Flash = int.Parse(dataRow["flash"].ToString()) > 0
|
||||
Flash = int.Parse(dataRow["flash"].ToString()) > 0
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from Companias";
|
||||
const string SQL = "SELECT * from companies";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -88,7 +88,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM Companias LIMIT {start}, {count}";
|
||||
string sql = $"SELECT * FROM companies LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -123,7 +123,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from Companias WHERE id = '{id}'";
|
||||
string sql = $"SELECT * from companies WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -155,7 +155,7 @@ namespace Cicm.Database
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM Companias";
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM companies";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
@@ -178,7 +178,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO Companias (Compania)" + " VALUES (@Compania)";
|
||||
const string SQL = "INSERT INTO companies (name)" + " VALUES (@name)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE Companias SET Compania = @Compania " + $"WHERE id = {entry.Id}";
|
||||
string sql = "UPDATE companies SET name = @name " + $"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM Companias WHERE id = '{id}';";
|
||||
string sql = $"DELETE FROM companies WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace Cicm.Database
|
||||
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@Compania";
|
||||
param1.ParameterName = "@name";
|
||||
|
||||
param1.DbType = DbType.String;
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace Cicm.Database
|
||||
Company entry = new Company
|
||||
{
|
||||
Id = int.Parse(dataRow["id"].ToString()),
|
||||
Name = dataRow["Compania"].ToString()
|
||||
Name = dataRow["name"].ToString()
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
|
||||
@@ -215,8 +215,8 @@ namespace Cicm.Database
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL =
|
||||
"INSERT INTO computers (company, year, model, cpu1, mhz1, cpu2, mhz2, bits, ram, rom, gpu, vram, colors, res, spu, mpu, sound_channels, music_channels, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2, comment)" +
|
||||
" VALUES (@company, @year, @model, @cpu1, @mhz1, @cpu2, @mhz2, @bits, @ram, @rom, @gpu, @vram, @colors, @res, @spu, @mpu, @sound_channels, @music_channels, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2, @comment)";
|
||||
"INSERT INTO computers (company, year, model, cpu1, mhz1, cpu2, mhz2, bits, ram, rom, gpu, vram, colors, res, sound_synth, music_synth, sound_channels, music_channels, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2)" +
|
||||
" VALUES (@company, @year, @model, @cpu1, @mhz1, @cpu2, @mhz2, @bits, @ram, @rom, @gpu, @vram, @colors, @res, @sound_synth, @music_synth, @sound_channels, @music_channels, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -249,9 +249,9 @@ namespace Cicm.Database
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql =
|
||||
"UPDATE computers SET company = @company, year = @year, model = @model, cpu1 = @cpu1, mhz1 = @mhz1, cpu2 = @cpu2, " +
|
||||
"mhz2 = @mhz2, bits = @bits, ram = @ram, rom = @rom, gpu = @gpu, vram = @vram, colors = @colors, res = @res, spu = @spu, mpu = @mpu " +
|
||||
"sound_channels = @sound_channels, music_channels = @music_channels, hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2, comment = @comment " +
|
||||
"UPDATE computers SET company = @company, year = @year, model = @model, cpu1 = @cpu1, mhz1 = @mhz1, cpu2 = @cpu2, " +
|
||||
"mhz2 = @mhz2, bits = @bits, ram = @ram, rom = @rom, gpu = @gpu, vram = @vram, colors = @colors, res = @res, sound_synth = @sound_synth, music_synth = @music_synth " +
|
||||
"sound_channels = @sound_channels, music_channels = @music_channels, hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2 " +
|
||||
$"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
@@ -318,7 +318,6 @@ namespace Cicm.Database
|
||||
IDbDataParameter param23 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param24 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param25 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param26 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@company";
|
||||
param2.ParameterName = "@year";
|
||||
@@ -334,8 +333,8 @@ namespace Cicm.Database
|
||||
param12.ParameterName = "@vram";
|
||||
param13.ParameterName = "@colors";
|
||||
param14.ParameterName = "@res";
|
||||
param15.ParameterName = "@spu";
|
||||
param16.ParameterName = "@mpu";
|
||||
param15.ParameterName = "@sound_synth";
|
||||
param16.ParameterName = "@music_synth";
|
||||
param17.ParameterName = "@sound_channels";
|
||||
param18.ParameterName = "@music_channels";
|
||||
param19.ParameterName = "@hdd1";
|
||||
@@ -345,7 +344,6 @@ namespace Cicm.Database
|
||||
param23.ParameterName = "@cap1";
|
||||
param24.ParameterName = "@disk2";
|
||||
param25.ParameterName = "@cap2";
|
||||
param26.ParameterName = "@comment";
|
||||
|
||||
param1.DbType = DbType.Int32;
|
||||
param2.DbType = DbType.Int32;
|
||||
@@ -372,7 +370,6 @@ namespace Cicm.Database
|
||||
param23.DbType = DbType.String;
|
||||
param24.DbType = DbType.Int32;
|
||||
param25.DbType = DbType.String;
|
||||
param26.DbType = DbType.String;
|
||||
|
||||
param1.Value = entry.Company;
|
||||
param2.Value = entry.Year;
|
||||
@@ -388,8 +385,8 @@ namespace Cicm.Database
|
||||
param12.Value = entry.Vram;
|
||||
param13.Value = entry.Colors;
|
||||
param14.Value = entry.Resolution;
|
||||
param15.Value = entry.Spu;
|
||||
param16.Value = entry.Mpu;
|
||||
param15.Value = entry.SoundSynth;
|
||||
param16.Value = entry.MusicSynth;
|
||||
param17.Value = entry.SoundChannels;
|
||||
param18.Value = entry.MusicChannels;
|
||||
param19.Value = entry.Hdd1;
|
||||
@@ -399,7 +396,6 @@ namespace Cicm.Database
|
||||
param23.Value = entry.Cap1;
|
||||
param24.Value = entry.Disk2;
|
||||
param25.Value = entry.Cap2;
|
||||
param26.Value = entry.Comment;
|
||||
|
||||
dbcmd.Parameters.Add(param1);
|
||||
dbcmd.Parameters.Add(param2);
|
||||
@@ -426,7 +422,6 @@ namespace Cicm.Database
|
||||
dbcmd.Parameters.Add(param23);
|
||||
dbcmd.Parameters.Add(param24);
|
||||
dbcmd.Parameters.Add(param25);
|
||||
dbcmd.Parameters.Add(param26);
|
||||
|
||||
return dbcmd;
|
||||
}
|
||||
@@ -457,8 +452,8 @@ namespace Cicm.Database
|
||||
Vram = int.Parse(dataRow["vram"].ToString()),
|
||||
Colors = int.Parse(dataRow["colors"].ToString()),
|
||||
Resolution = dataRow["res"].ToString(),
|
||||
Spu = int.Parse(dataRow["spu"].ToString()),
|
||||
Mpu = int.Parse(dataRow["mpu"].ToString()),
|
||||
SoundSynth = int.Parse(dataRow["sound_synth"].ToString()),
|
||||
MusicSynth = int.Parse(dataRow["music_synth"].ToString()),
|
||||
SoundChannels = int.Parse(dataRow["sound_channels"].ToString()),
|
||||
MusicChannels = int.Parse(dataRow["music_channels"].ToString()),
|
||||
Hdd1 = int.Parse(dataRow["hdd1"].ToString()),
|
||||
@@ -473,8 +468,7 @@ namespace Cicm.Database
|
||||
Disk2 = string.IsNullOrEmpty(dataRow["disk2"].ToString())
|
||||
? 0
|
||||
: int.Parse(dataRow["disk2"].ToString()),
|
||||
Cap2 = dataRow["cap2"].ToString(),
|
||||
Comment = dataRow["comment"].ToString()
|
||||
Cap2 = dataRow["cap2"].ToString()
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace Cicm.Database
|
||||
public bool AddConsole(Console entry, out long id)
|
||||
{
|
||||
#if DEBUG
|
||||
System.Console.Write("Adding console `{0}`...", entry.Name);
|
||||
System.Console.Write("Adding console `{0}`...", entry.Model);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandConsole(entry);
|
||||
@@ -214,8 +214,8 @@ namespace Cicm.Database
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL =
|
||||
"INSERT INTO consoles (company, year, name, cpu1, mhz1, cpu2, mhz2, bits, ram, rom, gpu, vram, colors, res, spu, mpu, schannels, mchannels, palette, format, cap, comments)" +
|
||||
" VALUES (@company, @year, @name, @cpu1, @mhz1, @cpu2, @mhz2, @bits, @ram, @rom, @gpu, @vram, @colors, @res, @spu, @mpu, @schannels, @mchannels, @palette, @format, @cap, @comments)";
|
||||
"INSERT INTO consoles (company, year, model, cpu1, mhz1, cpu2, mhz2, bits, ram, rom, gpu, vram, colors, res, sound_synth, music_synth, schannels, mchannels, palette, format, cap)" +
|
||||
" VALUES (@company, @year, @model, @cpu1, @mhz1, @cpu2, @mhz2, @bits, @ram, @rom, @gpu, @vram, @colors, @res, @sound_synth, @music_synth, @schannels, @mchannels, @palette, @format, @cap)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace Cicm.Database
|
||||
public bool UpdateConsole(Console entry)
|
||||
{
|
||||
#if DEBUG
|
||||
System.Console.WriteLine("Updating console `{0}`...", entry.Name);
|
||||
System.Console.WriteLine("Updating console `{0}`...", entry.Model);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandConsole(entry);
|
||||
@@ -248,9 +248,9 @@ namespace Cicm.Database
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql =
|
||||
"UPDATE consoles SET company = @company, year = @year, name = @name, cpu1 = @cpu1, mhz1 = @mhz1, cpu2 = @cpu2, " +
|
||||
"mhz2 = @mhz2, bits = @bits, ram = @ram, rom = @rom, gpu = @gpu, vram = @vram, colors = @colors, res = @res, spu = @spu, mpu = @mpu " +
|
||||
"schannels = @schannels, mchannels = @mchannels, palette = @palette, format = @format, cap = @cap, comments = @comments " +
|
||||
"UPDATE consoles SET company = @company, year = @year, model = @model, cpu1 = @cpu1, mhz1 = @mhz1, cpu2 = @cpu2, " +
|
||||
"mhz2 = @mhz2, bits = @bits, ram = @ram, rom = @rom, gpu = @gpu, vram = @vram, colors = @colors, res = @res, sound_synth = @sound_synth, music_synth = @music_synth " +
|
||||
"schannels = @schannels, mchannels = @mchannels, palette = @palette, format = @format, cap = @cap " +
|
||||
$"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
@@ -313,11 +313,10 @@ namespace Cicm.Database
|
||||
IDbDataParameter param19 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param20 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param21 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param22 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@company";
|
||||
param2.ParameterName = "@year";
|
||||
param3.ParameterName = "@name";
|
||||
param3.ParameterName = "@model";
|
||||
param4.ParameterName = "@cpu1";
|
||||
param5.ParameterName = "@mhz1";
|
||||
param6.ParameterName = "@cpu2";
|
||||
@@ -329,14 +328,13 @@ namespace Cicm.Database
|
||||
param12.ParameterName = "@vram";
|
||||
param13.ParameterName = "@colors";
|
||||
param14.ParameterName = "@res";
|
||||
param15.ParameterName = "@spu";
|
||||
param16.ParameterName = "@mpu";
|
||||
param15.ParameterName = "@sound_synth";
|
||||
param16.ParameterName = "@music_synth";
|
||||
param17.ParameterName = "@schannels";
|
||||
param18.ParameterName = "@mchannels";
|
||||
param19.ParameterName = "@palette";
|
||||
param20.ParameterName = "@format";
|
||||
param21.ParameterName = "@cap";
|
||||
param22.ParameterName = "@comments";
|
||||
|
||||
param1.DbType = DbType.Int32;
|
||||
param2.DbType = DbType.Int32;
|
||||
@@ -359,11 +357,10 @@ namespace Cicm.Database
|
||||
param19.DbType = DbType.Int32;
|
||||
param20.DbType = DbType.Int32;
|
||||
param21.DbType = DbType.Int32;
|
||||
param22.DbType = DbType.String;
|
||||
|
||||
param1.Value = entry.Company;
|
||||
param2.Value = entry.Year;
|
||||
param3.Value = entry.Name;
|
||||
param3.Value = entry.Model;
|
||||
param4.Value = entry.Cpu1;
|
||||
param5.Value = entry.Mhz1;
|
||||
param6.Value = entry.Cpu2;
|
||||
@@ -375,14 +372,13 @@ namespace Cicm.Database
|
||||
param12.Value = entry.Vram;
|
||||
param13.Value = entry.Colors;
|
||||
param14.Value = entry.Resolution;
|
||||
param15.Value = entry.Spu;
|
||||
param16.Value = entry.Mpu;
|
||||
param15.Value = entry.SoundSynth;
|
||||
param16.Value = entry.MusicSynth;
|
||||
param17.Value = entry.SoundChannels;
|
||||
param18.Value = entry.MusicChannels;
|
||||
param19.Value = entry.Palette;
|
||||
param20.Value = entry.Format;
|
||||
param21.Value = entry.Cap;
|
||||
param22.Value = entry.Comments;
|
||||
|
||||
dbcmd.Parameters.Add(param1);
|
||||
dbcmd.Parameters.Add(param2);
|
||||
@@ -405,7 +401,6 @@ namespace Cicm.Database
|
||||
dbcmd.Parameters.Add(param19);
|
||||
dbcmd.Parameters.Add(param20);
|
||||
dbcmd.Parameters.Add(param21);
|
||||
dbcmd.Parameters.Add(param22);
|
||||
|
||||
return dbcmd;
|
||||
}
|
||||
@@ -421,7 +416,7 @@ namespace Cicm.Database
|
||||
Id = int.Parse(dataRow["id"].ToString()),
|
||||
Company = int.Parse(dataRow["company"].ToString()),
|
||||
Year = int.Parse(dataRow["year"].ToString()),
|
||||
Name = dataRow["name"].ToString(),
|
||||
Model = dataRow["model"].ToString(),
|
||||
Cpu1 = int.Parse(dataRow["cpu1"].ToString()),
|
||||
Mhz1 = float.Parse(dataRow["mhz1"].ToString()),
|
||||
Cpu2 = string.IsNullOrEmpty(dataRow["cpu2"].ToString())
|
||||
@@ -436,14 +431,13 @@ namespace Cicm.Database
|
||||
Vram = int.Parse(dataRow["vram"].ToString()),
|
||||
Colors = int.Parse(dataRow["colors"].ToString()),
|
||||
Resolution = dataRow["res"].ToString(),
|
||||
Spu = int.Parse(dataRow["spu"].ToString()),
|
||||
Mpu = int.Parse(dataRow["mpu"].ToString()),
|
||||
SoundSynth = int.Parse(dataRow["sound_synth"].ToString()),
|
||||
MusicSynth = int.Parse(dataRow["music_synth"].ToString()),
|
||||
SoundChannels = int.Parse(dataRow["schannels"].ToString()),
|
||||
MusicChannels = int.Parse(dataRow["mchannels"].ToString()),
|
||||
Palette = int.Parse(dataRow["palette"].ToString()),
|
||||
Format = int.Parse(dataRow["format"].ToString()),
|
||||
Cap = int.Parse(dataRow["cap"].ToString()),
|
||||
Comments = dataRow["comments"].ToString()
|
||||
Cap = int.Parse(dataRow["cap"].ToString())
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from Formatos_de_disco";
|
||||
const string SQL = "SELECT * from disk_formats";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -88,7 +88,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM Formatos_de_disco LIMIT {start}, {count}";
|
||||
string sql = $"SELECT * FROM disk_formats LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -123,7 +123,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from Formatos_de_disco WHERE id = '{id}'";
|
||||
string sql = $"SELECT * from disk_formats WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -155,7 +155,7 @@ namespace Cicm.Database
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM Formatos_de_disco";
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM disk_formats";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
@@ -178,7 +178,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO Formatos_de_disco (Format)" + " VALUES (@Format)";
|
||||
const string SQL = "INSERT INTO disk_formats (description)" + " VALUES (@description)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE Formatos_de_disco SET Format = @Format " + $"WHERE id = {entry.Id}";
|
||||
string sql = "UPDATE disk_formats SET description = @description " + $"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM Formatos_de_disco WHERE id = '{id}';";
|
||||
string sql = $"DELETE FROM disk_formats WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace Cicm.Database
|
||||
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@Format";
|
||||
param1.ParameterName = "@description";
|
||||
|
||||
param1.DbType = DbType.String;
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace Cicm.Database
|
||||
DiskFormat entry = new DiskFormat
|
||||
{
|
||||
Id = int.Parse(dataRow["id"].ToString()),
|
||||
Description = dataRow["Format"].ToString()
|
||||
Description = dataRow["description"].ToString()
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
|
||||
@@ -1,281 +0,0 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Dsp.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains operations to manage DSPs.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
public partial class Operations
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all DSPs
|
||||
/// </summary>
|
||||
/// <param name="entries">All DSPs</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetDsps(out List<Dsp> entries)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting all DSPs...");
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from DSPs";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = SQL;
|
||||
DataSet dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = DspsFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting DSPs.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified number of DSPs since the specified start
|
||||
/// </summary>
|
||||
/// <param name="entries">List of DSPs</param>
|
||||
/// <param name="start">Start of query</param>
|
||||
/// <param name="count">How many entries to retrieve</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetDsps(out List<Dsp> entries, ulong start, ulong count)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting {0} DSPs from {1}...", count, start);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM DSPs LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = sql;
|
||||
DataSet dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = DspsFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting DSPs.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets DSP by specified id
|
||||
/// </summary>
|
||||
/// <param name="id">Id</param>
|
||||
/// <returns>DSP with specified id, <c>null</c> if not found or error</returns>
|
||||
public Dsp GetDsp(int id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting DSP with id {0}...", id);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from DSPs WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = sql;
|
||||
DataSet dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
List<Dsp> entries = DspsFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting DSP.");
|
||||
Console.WriteLine(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counts the number of DSPs in the database
|
||||
/// </summary>
|
||||
/// <returns>Entries in database</returns>
|
||||
public long CountDsps()
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Counting DSPs...");
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM DSPs";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new DSP to the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Entry to add</param>
|
||||
/// <param name="id">ID of added entry</param>
|
||||
/// <returns><c>true</c> if added correctly, <c>false</c> otherwise</returns>
|
||||
public bool AddDsp(Dsp entry, out long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.Write("Adding DSP `{0}`...", entry.Name);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandDsp(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO DSPs (DSP)" + " VALUES (@DSP)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
dbcmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbcmd.Dispose();
|
||||
|
||||
id = dbCore.LastInsertRowId;
|
||||
|
||||
#if DEBUG
|
||||
Console.WriteLine(" id {0}", id);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updated a DSP in the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Updated entry</param>
|
||||
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||
public bool UpdateDsp(Dsp entry)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Updating DSP `{0}`...", entry.Name);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandDsp(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE DSPs SET DSP = @DSP " + $"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
dbcmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbcmd.Dispose();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a DSP from the database
|
||||
/// </summary>
|
||||
/// <param name="id">ID of entry to remove</param>
|
||||
/// <returns><c>true</c> if removed correctly, <c>false</c> otherwise</returns>
|
||||
public bool RemoveDsp(long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Removing DSP widh id `{0}`...", id);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM DSPs WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
dbcmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbcmd.Dispose();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetCommandDsp(Dsp entry)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@DSP";
|
||||
|
||||
param1.DbType = DbType.String;
|
||||
|
||||
param1.Value = entry.Name;
|
||||
|
||||
dbcmd.Parameters.Add(param1);
|
||||
|
||||
return dbcmd;
|
||||
}
|
||||
|
||||
static List<Dsp> DspsFromDataTable(DataTable dataTable)
|
||||
{
|
||||
List<Dsp> entries = new List<Dsp>();
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
Dsp entry = new Dsp {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["DSP"].ToString()};
|
||||
|
||||
entries.Add(entry);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO gpus (GPU)" + " VALUES (@GPU)";
|
||||
const string SQL = "INSERT INTO gpus (name)" + " VALUES (@name)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE gpus SET GPU = @GPU " + $"WHERE id = {entry.Id}";
|
||||
string sql = "UPDATE gpus SET name = @name " + $"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace Cicm.Database
|
||||
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@GPU";
|
||||
param1.ParameterName = "@name";
|
||||
|
||||
param1.DbType = DbType.String;
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace Cicm.Database
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
Gpu entry = new Gpu {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["GPU"].ToString()};
|
||||
Gpu entry = new Gpu {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["name"].ToString()};
|
||||
|
||||
entries.Add(entry);
|
||||
}
|
||||
|
||||
@@ -49,79 +49,71 @@ namespace Cicm.Database
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
|
||||
Console.WriteLine("Creating table `admins`");
|
||||
dbCmd.CommandText = V2.Admins;
|
||||
dbCmd.CommandText = V3.Admins;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `browser_test`");
|
||||
dbCmd.CommandText = V2.BrowserTests;
|
||||
Console.WriteLine("Creating table `browser_tests`");
|
||||
dbCmd.CommandText = V3.BrowserTests;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `Companias`");
|
||||
dbCmd.CommandText = V2.Companies;
|
||||
Console.WriteLine("Creating table `cicm_db`");
|
||||
dbCmd.CommandText = V3.CicmDb;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `companies`");
|
||||
dbCmd.CommandText = V3.Companies;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `computers`");
|
||||
dbCmd.CommandText = V2.Computers;
|
||||
dbCmd.CommandText = V3.Computers;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `consoles`");
|
||||
dbCmd.CommandText = V2.Consoles;
|
||||
dbCmd.CommandText = V3.Consoles;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `console_company`");
|
||||
dbCmd.CommandText = V2.ConsoleCompanies;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `cpu`");
|
||||
dbCmd.CommandText = V2.Cpus;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `admins`");
|
||||
dbCmd.CommandText = V2.Admins;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `DSPs`");
|
||||
dbCmd.CommandText = V2.Dsps;
|
||||
Console.WriteLine("Creating table `disk_formats`");
|
||||
dbCmd.CommandText = V3.DiskFormats;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `forbidden`");
|
||||
dbCmd.CommandText = V2.Forbidden;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `Formatos_de_disco`");
|
||||
dbCmd.CommandText = V2.DiskFormats;
|
||||
dbCmd.CommandText = V3.Forbidden;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `gpus`");
|
||||
dbCmd.CommandText = V2.Gpus;
|
||||
dbCmd.CommandText = V3.Gpus;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `log`");
|
||||
dbCmd.CommandText = V2.Logs;
|
||||
dbCmd.CommandText = V3.Logs;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `money_donation`");
|
||||
dbCmd.CommandText = V2.MoneyDonations;
|
||||
Console.WriteLine("Creating table `money_donations`");
|
||||
dbCmd.CommandText = V3.MoneyDonations;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `mpus`");
|
||||
dbCmd.CommandText = V2.Mpus;
|
||||
Console.WriteLine("Creating table `music_synths`");
|
||||
dbCmd.CommandText = V3.MusicSynths;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `news`");
|
||||
dbCmd.CommandText = V2.News;
|
||||
dbCmd.CommandText = V3.News;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `own_computer`");
|
||||
dbCmd.CommandText = V2.OwnComputers;
|
||||
Console.WriteLine("Creating table `owned_computers`");
|
||||
dbCmd.CommandText = V3.OwnedComputers;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `own_consoles`");
|
||||
dbCmd.CommandText = V2.OwnConsoles;
|
||||
Console.WriteLine("Creating table `owned_consoles`");
|
||||
dbCmd.CommandText = V3.OwnedConsoles;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `procesadores_principales`");
|
||||
dbCmd.CommandText = V2.ProcesadoresPrincipales;
|
||||
Console.WriteLine("Creating table `processors`");
|
||||
dbCmd.CommandText = V3.Processors;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `sound_synths`");
|
||||
dbCmd.CommandText = V3.SoundSynths;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from money_donation";
|
||||
const string SQL = "SELECT * from money_donations";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -88,7 +88,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM money_donation LIMIT {start}, {count}";
|
||||
string sql = $"SELECT * FROM money_donations LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -123,7 +123,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from money_donation WHERE id = '{id}'";
|
||||
string sql = $"SELECT * from money_donations WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -155,7 +155,7 @@ namespace Cicm.Database
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM money_donation";
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM money_donations";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
@@ -178,7 +178,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO money_donation (donator, quantity)" + " VALUES (@donator, @quantity)";
|
||||
const string SQL = "INSERT INTO money_donations (donator, quantity)" + " VALUES (@donator, @quantity)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE money_donation SET donator = @donator, quantity = @quantity " +
|
||||
string sql = "UPDATE money_donations SET donator = @donator, quantity = @quantity " +
|
||||
$"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
@@ -230,14 +230,14 @@ namespace Cicm.Database
|
||||
public bool RemoveMoneyDonation(long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Removing money_donation widh id `{0}`...", id);
|
||||
Console.WriteLine("Removing money donation widh id `{0}`...", id);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM money_donation WHERE id = '{id}';";
|
||||
string sql = $"DELETE FROM money_donations WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Mpu.cs
|
||||
// Filename : MusicSynth.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains operations to manage MPUs.
|
||||
// Contains operations to manage music synthetizer.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -39,19 +39,19 @@ namespace Cicm.Database
|
||||
public partial class Operations
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all MPUs
|
||||
/// Gets all music synthetizers
|
||||
/// </summary>
|
||||
/// <param name="entries">All MPUs</param>
|
||||
/// <param name="entries">All music synthetizers</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetMpus(out List<Mpu> entries)
|
||||
public bool GetMusicSynths(out List<MusicSynth> entries)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting all MPUs...");
|
||||
Console.WriteLine("Getting all music synthetizers...");
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from mpus";
|
||||
const string SQL = "SELECT * from music_synths";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -60,13 +60,13 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = MpusFromDataTable(dataSet.Tables[0]);
|
||||
entries = MusicSynthFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting MPUs.");
|
||||
Console.WriteLine("Error getting music synthetizers.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
@@ -74,21 +74,21 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified number of MPUs since the specified start
|
||||
/// Gets the specified number of music synthetizers since the specified start
|
||||
/// </summary>
|
||||
/// <param name="entries">List of MPUs</param>
|
||||
/// <param name="entries">List of music synthetizers</param>
|
||||
/// <param name="start">Start of query</param>
|
||||
/// <param name="count">How many entries to retrieve</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetMpus(out List<Mpu> entries, ulong start, ulong count)
|
||||
public bool GetMusicSynths(out List<MusicSynth> entries, ulong start, ulong count)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting {0} MPUs from {1}...", count, start);
|
||||
Console.WriteLine("Getting {0} music synthetizers from {1}...", count, start);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM mpus LIMIT {start}, {count}";
|
||||
string sql = $"SELECT * FROM music_synths LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -97,13 +97,13 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = MpusFromDataTable(dataSet.Tables[0]);
|
||||
entries = MusicSynthFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting MPUs.");
|
||||
Console.WriteLine("Error getting music synthetizers.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
@@ -111,19 +111,19 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets MPU by specified id
|
||||
/// Gets music synthetizer by specified id
|
||||
/// </summary>
|
||||
/// <param name="id">Id</param>
|
||||
/// <returns>MPU with specified id, <c>null</c> if not found or error</returns>
|
||||
public Mpu GetMpu(int id)
|
||||
/// <returns>music synthetizer with specified id, <c>null</c> if not found or error</returns>
|
||||
public MusicSynth GetMusicSynth(int id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting MPU with id {0}...", id);
|
||||
Console.WriteLine("Getting music synthetizer with id {0}...", id);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from mpus WHERE id = '{id}'";
|
||||
string sql = $"SELECT * from music_synths WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -132,30 +132,30 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
List<Mpu> entries = MpusFromDataTable(dataSet.Tables[0]);
|
||||
List<MusicSynth> entries = MusicSynthFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting MPU.");
|
||||
Console.WriteLine("Error getting music synthetizer.");
|
||||
Console.WriteLine(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counts the number of MPUs in the database
|
||||
/// Counts the number of music synthetizers in the database
|
||||
/// </summary>
|
||||
/// <returns>Entries in database</returns>
|
||||
public long CountMpus()
|
||||
public long CountMusicSynths()
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Counting mpus...");
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM mpus";
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM music_synths";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
@@ -163,22 +163,22 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new MPU to the database
|
||||
/// Adds a new music synthetizer to the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Entry to add</param>
|
||||
/// <param name="id">ID of added entry</param>
|
||||
/// <returns><c>true</c> if added correctly, <c>false</c> otherwise</returns>
|
||||
public bool AddMpu(Mpu entry, out long id)
|
||||
public bool AddMusicSynth(MusicSynth entry, out long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.Write("Adding MPU `{0}`...", entry.Name);
|
||||
Console.Write("Adding music synthetizer `{0}`...", entry.Name);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandMpu(entry);
|
||||
IDbCommand dbcmd = GetCommandMusicSynth(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO mpus (MPU)" + " VALUES (@MPU)";
|
||||
const string SQL = "INSERT INTO music_synths (name)" + " VALUES (@name)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -196,21 +196,21 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updated an MPU in the database
|
||||
/// Updated an music synthetizer in the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Updated entry</param>
|
||||
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||
public bool UpdateMpu(Mpu entry)
|
||||
public bool UpdateMusicSynth(MusicSynth entry)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Updating MPU `{0}`...", entry.Name);
|
||||
Console.WriteLine("Updating music synthetizer `{0}`...", entry.Name);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandMpu(entry);
|
||||
IDbCommand dbcmd = GetCommandMusicSynth(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE mpus SET MPU = @MPU " + $"WHERE id = {entry.Id}";
|
||||
string sql = "UPDATE music_synths SET name = @name " + $"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -221,17 +221,17 @@ namespace Cicm.Database
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveMpu(long id)
|
||||
public bool RemoveMusicSynth(long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Removing MPU widh id `{0}`...", id);
|
||||
Console.WriteLine("Removing music synthetizer widh id `{0}`...", id);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM mpus WHERE id = '{id}';";
|
||||
string sql = $"DELETE FROM music_synths WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -242,13 +242,13 @@ namespace Cicm.Database
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetCommandMpu(Mpu entry)
|
||||
IDbCommand GetCommandMusicSynth(MusicSynth entry)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@MPU";
|
||||
param1.ParameterName = "@name";
|
||||
|
||||
param1.DbType = DbType.String;
|
||||
|
||||
@@ -259,13 +259,17 @@ namespace Cicm.Database
|
||||
return dbcmd;
|
||||
}
|
||||
|
||||
static List<Mpu> MpusFromDataTable(DataTable dataTable)
|
||||
static List<MusicSynth> MusicSynthFromDataTable(DataTable dataTable)
|
||||
{
|
||||
List<Mpu> entries = new List<Mpu>();
|
||||
List<MusicSynth> entries = new List<MusicSynth>();
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
Mpu entry = new Mpu {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["MPU"].ToString()};
|
||||
MusicSynth entry = new MusicSynth
|
||||
{
|
||||
Id = int.Parse(dataRow["id"].ToString()),
|
||||
Name = dataRow["name"].ToString()
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace Cicm.Database
|
||||
public partial class Operations
|
||||
{
|
||||
/// <summary>Last known database version</summary>
|
||||
const int DB_VERSION = 2;
|
||||
const int DB_VERSION = 3;
|
||||
|
||||
readonly IDbConnection dbCon;
|
||||
readonly IDbCore dbCore;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : OwnConsole.cs
|
||||
// Filename : OwnedConsole.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
@@ -43,7 +43,7 @@ namespace Cicm.Database
|
||||
/// </summary>
|
||||
/// <param name="entries">All owned computers</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetOwnComputers(out List<OwnComputer> entries)
|
||||
public bool GetOwnedComputers(out List<OwnedComputer> entries)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting all owned computers...");
|
||||
@@ -51,7 +51,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from own_computer";
|
||||
const string SQL = "SELECT * from owned_computers";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -60,7 +60,7 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = OwnComputersFromDataTable(dataSet.Tables[0]);
|
||||
entries = OwnedComputersFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace Cicm.Database
|
||||
/// <param name="start">Start of query</param>
|
||||
/// <param name="count">How many entries to retrieve</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetOwnComputers(out List<OwnComputer> entries, ulong start, ulong count)
|
||||
public bool GetOwnedComputers(out List<OwnedComputer> entries, ulong start, ulong count)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting {0} owned computers from {1}...", count, start);
|
||||
@@ -88,7 +88,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM own_computer LIMIT {start}, {count}";
|
||||
string sql = $"SELECT * FROM owned_computers LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -97,7 +97,7 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = OwnComputersFromDataTable(dataSet.Tables[0]);
|
||||
entries = OwnedComputersFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ namespace Cicm.Database
|
||||
/// </summary>
|
||||
/// <param name="id">Id</param>
|
||||
/// <returns>Owned computer with specified id, <c>null</c> if not found or error</returns>
|
||||
public OwnComputer GetOwnComputer(int id)
|
||||
public OwnedComputer GetOwnedComputer(int id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting owned computer with id {0}...", id);
|
||||
@@ -123,7 +123,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from own_computer WHERE id = '{id}'";
|
||||
string sql = $"SELECT * from owned_computers WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -132,7 +132,7 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
List<OwnComputer> entries = OwnComputersFromDataTable(dataSet.Tables[0]);
|
||||
List<OwnedComputer> entries = OwnedComputersFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||
}
|
||||
@@ -148,14 +148,14 @@ namespace Cicm.Database
|
||||
/// Counts the number of owned computers in the database
|
||||
/// </summary>
|
||||
/// <returns>Entries in database</returns>
|
||||
public long CountOwnComputers()
|
||||
public long CountOwnedComputers()
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Counting owned computers...");
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM own_computer";
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM owned_computers";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
@@ -168,18 +168,18 @@ namespace Cicm.Database
|
||||
/// <param name="entry">Entry to add</param>
|
||||
/// <param name="id">ID of added entry</param>
|
||||
/// <returns><c>true</c> if added correctly, <c>false</c> otherwise</returns>
|
||||
public bool AddOwnComputer(OwnComputer entry, out long id)
|
||||
public bool AddOwnedComputer(OwnedComputer entry, out long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.Write("Adding owned computer `{0}`...", entry.ComputerId);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandOwnComputer(entry);
|
||||
IDbCommand dbcmd = GetCommandOwnedComputer(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL =
|
||||
"INSERT INTO own_computer (db_id, date, status, trade, boxed, manuals, cpu1, mhz1, cpu2, mhz2, ram, vram, rigid, disk1, cap1, disk2, cap2)" +
|
||||
"INSERT INTO owned_computers (db_id, date, status, trade, boxed, manuals, cpu1, mhz1, cpu2, mhz2, ram, vram, rigid, disk1, cap1, disk2, cap2)" +
|
||||
" VALUES (@db_id, @date, @status, @trade, @boxed, @manuals, @cpu1, @mhz1, @cpu2, @mhz2, @ram, @vram, @rigid, @disk1, @cap1, @disk2, @cap2)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
@@ -202,18 +202,18 @@ namespace Cicm.Database
|
||||
/// </summary>
|
||||
/// <param name="entry">Updated entry</param>
|
||||
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||
public bool UpdateOwnComputer(OwnComputer entry)
|
||||
public bool UpdateOwnedComputer(OwnedComputer entry)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Updating computer `{0}`...", entry.ComputerId);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandOwnComputer(entry);
|
||||
IDbCommand dbcmd = GetCommandOwnedComputer(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql =
|
||||
"UPDATE own_computer SET db_id = @db_id, date = @date, status = @status, trade = @trade, boxed = @boxed, manuals = @manuals, cpu1 = @cpu1" +
|
||||
"UPDATE owned_computers SET db_id = @db_id, date = @date, status = @status, trade = @trade, boxed = @boxed, manuals = @manuals, cpu1 = @cpu1" +
|
||||
"mhz1 = @mhz1, cpu2 = @cpu2, mhz2 = @mhz2, ram = @ram, vram = @vram, rigid = @rigid, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2 " +
|
||||
$"WHERE id = {entry.Id}";
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace Cicm.Database
|
||||
/// </summary>
|
||||
/// <param name="id">ID of entry to remove</param>
|
||||
/// <returns><c>true</c> if removed correctly, <c>false</c> otherwise</returns>
|
||||
public bool RemoveOwnComputer(long id)
|
||||
public bool RemoveOwnedComputer(long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Removing owned computer widh id `{0}`...", id);
|
||||
@@ -241,7 +241,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM own_computer WHERE id = '{id}';";
|
||||
string sql = $"DELETE FROM owned_computers WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace Cicm.Database
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetCommandOwnComputer(OwnComputer entry)
|
||||
IDbCommand GetCommandOwnedComputer(OwnedComputer entry)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
@@ -349,20 +349,20 @@ namespace Cicm.Database
|
||||
return dbcmd;
|
||||
}
|
||||
|
||||
static List<OwnComputer> OwnComputersFromDataTable(DataTable dataTable)
|
||||
static List<OwnedComputer> OwnedComputersFromDataTable(DataTable dataTable)
|
||||
{
|
||||
List<OwnComputer> entries = new List<OwnComputer>();
|
||||
List<OwnedComputer> entries = new List<OwnedComputer>();
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
OwnComputer entry = new OwnComputer
|
||||
OwnedComputer entry = new OwnedComputer
|
||||
{
|
||||
Id = int.Parse(dataRow["id"].ToString()),
|
||||
ComputerId = int.Parse(dataRow["db_id"].ToString()),
|
||||
Acquired = dataRow["date"].ToString(),
|
||||
Status = (StatusType)int.Parse(dataRow["status"].ToString()),
|
||||
Trade = int.Parse(dataRow["trade"].ToString()) > 0,
|
||||
Boxed = int.Parse(dataRow["boxed"].ToString()) > 0,
|
||||
Trade = int.Parse(dataRow["trade"].ToString()) > 0,
|
||||
Boxed = int.Parse(dataRow["boxed"].ToString()) > 0,
|
||||
Manuals = int.Parse(dataRow["manuals"].ToString()) > 0,
|
||||
Cpu1 = int.Parse(dataRow["cpu1"].ToString()),
|
||||
Mhz1 = float.Parse(dataRow["mhz1"].ToString()),
|
||||
@@ -43,7 +43,7 @@ namespace Cicm.Database
|
||||
/// </summary>
|
||||
/// <param name="entries">All owned consoles</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetOwnConsoles(out List<OwnConsole> entries)
|
||||
public bool GetOwnedConsoles(out List<OwnedConsole> entries)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting all owned consoles...");
|
||||
@@ -51,7 +51,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from own_consoles";
|
||||
const string SQL = "SELECT * from owned_consoles";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -60,7 +60,7 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = OwnConsolesFromDataTable(dataSet.Tables[0]);
|
||||
entries = OwnedConsolesFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace Cicm.Database
|
||||
/// <param name="start">Start of query</param>
|
||||
/// <param name="count">How many entries to retrieve</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetOwnConsoles(out List<OwnConsole> entries, ulong start, ulong count)
|
||||
public bool GetOwnedConsoles(out List<OwnedConsole> entries, ulong start, ulong count)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting {0} owned consoles from {1}...", count, start);
|
||||
@@ -88,7 +88,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM own_consoles LIMIT {start}, {count}";
|
||||
string sql = $"SELECT * FROM owned_consoles LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -97,7 +97,7 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = OwnConsolesFromDataTable(dataSet.Tables[0]);
|
||||
entries = OwnedConsolesFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ namespace Cicm.Database
|
||||
/// </summary>
|
||||
/// <param name="id">Id</param>
|
||||
/// <returns>Owned console with specified id, <c>null</c> if not found or error</returns>
|
||||
public OwnConsole GetOwnConsole(int id)
|
||||
public OwnedConsole GetOwnedConsole(int id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting owned console with id {0}...", id);
|
||||
@@ -123,7 +123,7 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from own_consoles WHERE id = '{id}'";
|
||||
string sql = $"SELECT * from owned_consoles WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -132,7 +132,7 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
List<OwnConsole> entries = OwnConsolesFromDataTable(dataSet.Tables[0]);
|
||||
List<OwnedConsole> entries = OwnedConsolesFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||
}
|
||||
@@ -148,14 +148,14 @@ namespace Cicm.Database
|
||||
/// Counts the number of owned consoles in the database
|
||||
/// </summary>
|
||||
/// <returns>Entries in database</returns>
|
||||
public long CountOwnConsoles()
|
||||
public long CountOwnedConsoles()
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Counting owned consoles...");
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM own_consoles";
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM owned_consoles";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
@@ -168,17 +168,17 @@ namespace Cicm.Database
|
||||
/// <param name="entry">Entry to add</param>
|
||||
/// <param name="id">ID of added entry</param>
|
||||
/// <returns><c>true</c> if added correctly, <c>false</c> otherwise</returns>
|
||||
public bool AddOwnConsole(OwnConsole entry, out long id)
|
||||
public bool AddOwnedConsole(OwnedConsole entry, out long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.Write("Adding owned console `{0}`...", entry.ConsoleId);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandOwnConsole(entry);
|
||||
IDbCommand dbcmd = GetCommandOwnedConsole(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO own_consoles (db_id, date, status, trade, boxed, manuals)" +
|
||||
const string SQL = "INSERT INTO owned_consoles (db_id, date, status, trade, boxed, manuals)" +
|
||||
" VALUES (@db_id, @date, @status, @trade, @boxed, @manuals)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
@@ -201,18 +201,18 @@ namespace Cicm.Database
|
||||
/// </summary>
|
||||
/// <param name="entry">Updated entry</param>
|
||||
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||
public bool UpdateOwnConsole(OwnConsole entry)
|
||||
public bool UpdateOwnedConsole(OwnedConsole entry)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Updating console `{0}`...", entry.ConsoleId);
|
||||
Console.WriteLine("Updating owned console `{0}`...", entry.ConsoleId);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandOwnConsole(entry);
|
||||
IDbCommand dbcmd = GetCommandOwnedConsole(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql =
|
||||
"UPDATE own_consoles SET db_id = @db_id, date = @date, status = @status, trade = @trade, boxed = @boxed, manuals = @manuals " +
|
||||
"UPDATE owned_consoles SET db_id = @db_id, date = @date, status = @status, trade = @trade, boxed = @boxed, manuals = @manuals " +
|
||||
$"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
@@ -229,7 +229,7 @@ namespace Cicm.Database
|
||||
/// </summary>
|
||||
/// <param name="id">ID of entry to remove</param>
|
||||
/// <returns><c>true</c> if removed correctly, <c>false</c> otherwise</returns>
|
||||
public bool RemoveOwnConsole(long id)
|
||||
public bool RemoveOwnedConsole(long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Removing owned console widh id `{0}`...", id);
|
||||
@@ -239,7 +239,7 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM own_consoles WHERE id = '{id}';";
|
||||
string sql = $"DELETE FROM owned_consoles WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace Cicm.Database
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetCommandOwnConsole(OwnConsole entry)
|
||||
IDbCommand GetCommandOwnedConsole(OwnedConsole entry)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
@@ -292,20 +292,20 @@ namespace Cicm.Database
|
||||
return dbcmd;
|
||||
}
|
||||
|
||||
static List<OwnConsole> OwnConsolesFromDataTable(DataTable dataTable)
|
||||
static List<OwnedConsole> OwnedConsolesFromDataTable(DataTable dataTable)
|
||||
{
|
||||
List<OwnConsole> entries = new List<OwnConsole>();
|
||||
List<OwnedConsole> entries = new List<OwnedConsole>();
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
OwnConsole entry = new OwnConsole
|
||||
OwnedConsole entry = new OwnedConsole
|
||||
{
|
||||
Id = int.Parse(dataRow["id"].ToString()),
|
||||
ConsoleId = int.Parse(dataRow["db_id"].ToString()),
|
||||
Acquired = dataRow["date"].ToString(),
|
||||
Status = (StatusType)int.Parse(dataRow["status"].ToString()),
|
||||
Trade = int.Parse(dataRow["trade"].ToString()) > 0,
|
||||
Boxed = int.Parse(dataRow["boxed"].ToString()) > 0,
|
||||
Trade = int.Parse(dataRow["trade"].ToString()) > 0,
|
||||
Boxed = int.Parse(dataRow["boxed"].ToString()) > 0,
|
||||
Manuals = int.Parse(dataRow["manuals"].ToString()) > 0
|
||||
};
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Cpu.cs
|
||||
// Filename : Processor.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains operations to manage CPUs.
|
||||
// Contains operations to manage processors.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -39,19 +39,19 @@ namespace Cicm.Database
|
||||
public partial class Operations
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all CPUs
|
||||
/// Gets all processors
|
||||
/// </summary>
|
||||
/// <param name="entries">All CPUs</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetCpus(out List<Cpu> entries)
|
||||
public bool GetProcessors(out List<Processor> entries)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting all CPUs...");
|
||||
Console.WriteLine("Getting all processors...");
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from cpu";
|
||||
const string SQL = "SELECT * from processors";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -60,13 +60,13 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = CpusFromDataTable(dataSet.Tables[0]);
|
||||
entries = ProcessorsFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting CPUs.");
|
||||
Console.WriteLine("Error getting processors.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
@@ -74,21 +74,21 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified number of CPUs since the specified start
|
||||
/// Gets the specified number of processors since the specified start
|
||||
/// </summary>
|
||||
/// <param name="entries">List of CPUs</param>
|
||||
/// <param name="entries">List of processors</param>
|
||||
/// <param name="start">Start of query</param>
|
||||
/// <param name="count">How many entries to retrieve</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetCpus(out List<Cpu> entries, ulong start, ulong count)
|
||||
public bool GetProcessors(out List<Processor> entries, ulong start, ulong count)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting {0} CPUs from {1}...", count, start);
|
||||
Console.WriteLine("Getting {0} processors from {1}...", count, start);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM cpu LIMIT {start}, {count}";
|
||||
string sql = $"SELECT * FROM processors LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -97,13 +97,13 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = CpusFromDataTable(dataSet.Tables[0]);
|
||||
entries = ProcessorsFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting CPUs.");
|
||||
Console.WriteLine("Error getting processors.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
@@ -111,19 +111,19 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets CPU by specified id
|
||||
/// Gets processor by specified id
|
||||
/// </summary>
|
||||
/// <param name="id">Id</param>
|
||||
/// <returns>CPU with specified id, <c>null</c> if not found or error</returns>
|
||||
public Cpu GetCpu(int id)
|
||||
/// <returns>Processor with specified id, <c>null</c> if not found or error</returns>
|
||||
public Processor GetProcessor(int id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting CPU with id {0}...", id);
|
||||
Console.WriteLine("Getting processor with id {0}...", id);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from cpu WHERE id = '{id}'";
|
||||
string sql = $"SELECT * from processors WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -132,30 +132,30 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
List<Cpu> entries = CpusFromDataTable(dataSet.Tables[0]);
|
||||
List<Processor> entries = ProcessorsFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting CPU.");
|
||||
Console.WriteLine("Error getting processor.");
|
||||
Console.WriteLine(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counts the number of CPUs in the database
|
||||
/// Counts the number of processors in the database
|
||||
/// </summary>
|
||||
/// <returns>Entries in database</returns>
|
||||
public long CountCpus()
|
||||
public long CountProcessors()
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Counting CPUs...");
|
||||
Console.WriteLine("Counting processors...");
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM cpu";
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM processors";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
@@ -163,22 +163,22 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new CPU to the database
|
||||
/// Adds a new processor to the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Entry to add</param>
|
||||
/// <param name="id">ID of added entry</param>
|
||||
/// <returns><c>true</c> if added correctly, <c>false</c> otherwise</returns>
|
||||
public bool AddCpu(Cpu entry, out long id)
|
||||
public bool AddProcessor(Processor entry, out long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.Write("Adding CPU `{0}`...", entry.Name);
|
||||
Console.Write("Adding processor `{0}`...", entry.Name);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandCpu(entry);
|
||||
IDbCommand dbcmd = GetCommandProcessor(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO cpu (cpu)" + " VALUES (@cpu)";
|
||||
const string SQL = "INSERT INTO processors (name)" + " VALUES (@name)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -196,21 +196,21 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updated a CPU in the database
|
||||
/// Updated a processor in the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Updated entry</param>
|
||||
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||
public bool UpdateCpu(Cpu entry)
|
||||
public bool UpdateProcessor(Processor entry)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Updating CPU `{0}`...", entry.Name);
|
||||
Console.WriteLine("Updating processor `{0}`...", entry.Name);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandCpu(entry);
|
||||
IDbCommand dbcmd = GetCommandProcessor(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE cpu SET cpu = @cpu " + $"WHERE id = {entry.Id}";
|
||||
string sql = "UPDATE processors SET name = @name " + $"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -222,21 +222,21 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a CPU from the database
|
||||
/// Removes a processor from the database
|
||||
/// </summary>
|
||||
/// <param name="id">ID of entry to remove</param>
|
||||
/// <returns><c>true</c> if removed correctly, <c>false</c> otherwise</returns>
|
||||
public bool RemoveCpu(long id)
|
||||
public bool RemoveProcessor(long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Removing CPU widh id `{0}`...", id);
|
||||
Console.WriteLine("Removing processor widh id `{0}`...", id);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM cpu WHERE id = '{id}';";
|
||||
string sql = $"DELETE FROM processors WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -247,13 +247,13 @@ namespace Cicm.Database
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetCommandCpu(Cpu entry)
|
||||
IDbCommand GetCommandProcessor(Processor entry)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@cpu";
|
||||
param1.ParameterName = "@name";
|
||||
|
||||
param1.DbType = DbType.String;
|
||||
|
||||
@@ -264,13 +264,17 @@ namespace Cicm.Database
|
||||
return dbcmd;
|
||||
}
|
||||
|
||||
static List<Cpu> CpusFromDataTable(DataTable dataTable)
|
||||
static List<Processor> ProcessorsFromDataTable(DataTable dataTable)
|
||||
{
|
||||
List<Cpu> entries = new List<Cpu>();
|
||||
List<Processor> entries = new List<Processor>();
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
Cpu entry = new Cpu {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["cpu"].ToString()};
|
||||
Processor entry = new Processor
|
||||
{
|
||||
Id = int.Parse(dataRow["id"].ToString()),
|
||||
Name = dataRow["name"].ToString()
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ConsoleCompany.cs
|
||||
// Filename : SoundSynth.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains operations to manage console manufacturers.
|
||||
// Contains operations to manage sound synthetizers.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -39,19 +39,19 @@ namespace Cicm.Database
|
||||
public partial class Operations
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all console companies
|
||||
/// Gets all sound synthetizers
|
||||
/// </summary>
|
||||
/// <param name="entries">All console companies</param>
|
||||
/// <param name="entries">All sound synthetizers</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetConsoleCompanies(out List<ConsoleCompany> entries)
|
||||
public bool GetSoundSynths(out List<SoundSynth> entries)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting all console companies...");
|
||||
Console.WriteLine("Getting all sound synthetizers...");
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from console_company";
|
||||
const string SQL = "SELECT * from sound_synths";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -60,13 +60,13 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = ConsoleCompaniesFromDataTable(dataSet.Tables[0]);
|
||||
entries = SoundSynthFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting console companies.");
|
||||
Console.WriteLine("Error getting sound synthetizers.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
@@ -74,21 +74,21 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified number of console companies since the specified start
|
||||
/// Gets the specified number of sound synthetizers since the specified start
|
||||
/// </summary>
|
||||
/// <param name="entries">List of console companies</param>
|
||||
/// <param name="entries">List of sound synthetizers</param>
|
||||
/// <param name="start">Start of query</param>
|
||||
/// <param name="count">How many entries to retrieve</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetConsoleCompanies(out List<ConsoleCompany> entries, ulong start, ulong count)
|
||||
public bool GetSoundSynths(out List<SoundSynth> entries, ulong start, ulong count)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting {0} console companies from {1}...", count, start);
|
||||
Console.WriteLine("Getting {0} sound synthetizers from {1}...", count, start);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM console_company LIMIT {start}, {count}";
|
||||
string sql = $"SELECT * FROM sound_synths LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -97,13 +97,13 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = ConsoleCompaniesFromDataTable(dataSet.Tables[0]);
|
||||
entries = SoundSynthFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting console companies.");
|
||||
Console.WriteLine("Error getting sound synthetizers.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
@@ -111,19 +111,19 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets console company by specified id
|
||||
/// Gets sound synthetizer by specified id
|
||||
/// </summary>
|
||||
/// <param name="id">Id</param>
|
||||
/// <returns>Console company with specified id, <c>null</c> if not found or error</returns>
|
||||
public ConsoleCompany GetConsoleCompany(int id)
|
||||
/// <returns>Sound synthetizer with specified id, <c>null</c> if not found or error</returns>
|
||||
public SoundSynth GetSoundSynth(int id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting console company with id {0}...", id);
|
||||
Console.WriteLine("Getting sound synthetizer with id {0}...", id);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from console_company WHERE id = '{id}'";
|
||||
string sql = $"SELECT * from sound_synths WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -132,30 +132,30 @@ namespace Cicm.Database
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
List<ConsoleCompany> entries = ConsoleCompaniesFromDataTable(dataSet.Tables[0]);
|
||||
List<SoundSynth> entries = SoundSynthFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting console company.");
|
||||
Console.WriteLine("Error getting sound synthetizer.");
|
||||
Console.WriteLine(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counts the number of console companies in the database
|
||||
/// Counts the number of sound synthetizers in the database
|
||||
/// </summary>
|
||||
/// <returns>Entries in database</returns>
|
||||
public long CountConsoleCompanies()
|
||||
public long CountSoundSynths()
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Counting console companies...");
|
||||
Console.WriteLine("Counting sound synthetizers...");
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM console_company";
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM sound_synths";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
@@ -163,22 +163,22 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new console company to the database
|
||||
/// Adds a new sound synthetizer to the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Entry to add</param>
|
||||
/// <param name="id">ID of added entry</param>
|
||||
/// <returns><c>true</c> if added correctly, <c>false</c> otherwise</returns>
|
||||
public bool AddConsoleCompany(ConsoleCompany entry, out long id)
|
||||
public bool AddSoundSynth(SoundSynth entry, out long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.Write("Adding console company `{0}`...", entry.Name);
|
||||
Console.Write("Adding sound synthetizer `{0}`...", entry.Name);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandConsoleCompany(entry);
|
||||
IDbCommand dbcmd = GetCommandSoundSynth(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO console_company (company)" + " VALUES (@company)";
|
||||
const string SQL = "INSERT INTO sound_synths (name)" + " VALUES (@name)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -196,21 +196,21 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updated a console company in the database
|
||||
/// Updated a sound synthetizer in the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Updated entry</param>
|
||||
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||
public bool UpdateConsoleCompany(ConsoleCompany entry)
|
||||
public bool UpdateSoundSynth(SoundSynth entry)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Updating console company `{0}`...", entry.Name);
|
||||
Console.WriteLine("Updating sound synthetizer `{0}`...", entry.Name);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandConsoleCompany(entry);
|
||||
IDbCommand dbcmd = GetCommandSoundSynth(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE console_company SET company = @company " + $"WHERE id = {entry.Id}";
|
||||
string sql = "UPDATE sound_synths SET name = @name " + $"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -222,21 +222,21 @@ namespace Cicm.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a console company from the database
|
||||
/// Removes a sound synthetizer from the database
|
||||
/// </summary>
|
||||
/// <param name="id">ID of entry to remove</param>
|
||||
/// <returns><c>true</c> if removed correctly, <c>false</c> otherwise</returns>
|
||||
public bool RemoveConsoleCompany(long id)
|
||||
public bool RemoveSoundSynth(long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Removing console company widh id `{0}`...", id);
|
||||
Console.WriteLine("Removing sound synthetizer widh id `{0}`...", id);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM console_company WHERE id = '{id}';";
|
||||
string sql = $"DELETE FROM sound_synths WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -247,13 +247,13 @@ namespace Cicm.Database
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetCommandConsoleCompany(ConsoleCompany entry)
|
||||
IDbCommand GetCommandSoundSynth(SoundSynth entry)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@company";
|
||||
param1.ParameterName = "@name";
|
||||
|
||||
param1.DbType = DbType.String;
|
||||
|
||||
@@ -264,16 +264,16 @@ namespace Cicm.Database
|
||||
return dbcmd;
|
||||
}
|
||||
|
||||
static List<ConsoleCompany> ConsoleCompaniesFromDataTable(DataTable dataTable)
|
||||
static List<SoundSynth> SoundSynthFromDataTable(DataTable dataTable)
|
||||
{
|
||||
List<ConsoleCompany> entries = new List<ConsoleCompany>();
|
||||
List<SoundSynth> entries = new List<SoundSynth>();
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
ConsoleCompany entry = new ConsoleCompany
|
||||
SoundSynth entry = new SoundSynth
|
||||
{
|
||||
Id = int.Parse(dataRow["id"].ToString()),
|
||||
Name = dataRow["company"].ToString()
|
||||
Name = dataRow["name"].ToString()
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
@@ -28,6 +28,11 @@
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
public partial class Operations
|
||||
@@ -38,8 +43,342 @@ namespace Cicm.Database
|
||||
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||
public bool UpdateDatabase()
|
||||
{
|
||||
// Do nothing
|
||||
bool dbV2 = !dbCore.TableExists("cicm_db");
|
||||
int currentDbVersion = 2;
|
||||
|
||||
if(!dbV2)
|
||||
{
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = "SELECT * FROM cicm_db";
|
||||
DataSet dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
foreach(DataRow dataRow in dataSet.Tables[0].Rows)
|
||||
{
|
||||
int newId = int.Parse(dataRow["version"].ToString());
|
||||
|
||||
if(newId > currentDbVersion) currentDbVersion = newId;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Database version: {0}", currentDbVersion);
|
||||
|
||||
if(currentDbVersion > DB_VERSION)
|
||||
{
|
||||
Console.WriteLine("Current database version is higher than last supported version {0}, cannot continue...",
|
||||
DB_VERSION);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(currentDbVersion == DB_VERSION) return true;
|
||||
|
||||
for(int i = currentDbVersion; i < DB_VERSION; i++)
|
||||
switch(i)
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
UpdateDatabaseV2ToV3();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OptimizeDatabase();
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateDatabaseV2ToV3()
|
||||
{
|
||||
Console.WriteLine("Updating database to version 3");
|
||||
|
||||
Console.WriteLine("Creating versioning table");
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"CREATE TABLE `cicm_db` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`version` INT NOT NULL,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`) )";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming table `admin` to `admins`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `admin` RENAME TO `admins`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming column `browser_test.idstring` to `browser_test.user_agent`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText =
|
||||
@"ALTER TABLE `browser_test` CHANGE COLUMN `idstring` `user_agent` varchar(128) NOT NULL DEFAULT '';";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Renaming table `browser_test` to `browser_tests`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `browser_test` RENAME TO `browser_tests`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming column `Companias.Compania` to `Companias.name`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText =
|
||||
@"ALTER TABLE `Companias` CHANGE COLUMN `Compania` `name` varchar(128) NOT NULL DEFAULT '';";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Renaming table `Companias` to `companies`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `Companias` RENAME TO `companies`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming column `computers.spu` to `computers.sound_synth`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText =
|
||||
@"ALTER TABLE `computers` CHANGE COLUMN `spu` `sound_synth` int(11) NOT NULL DEFAULT '0'";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Renaming column `computers.mpu` to `music_synth.name`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText =
|
||||
@"ALTER TABLE `computers` CHANGE COLUMN `mpu` `music_synth` int(11) NOT NULL DEFAULT '0'";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Dropping column `computers.comment`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `computers` DROP COLUMN `comment`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming column `consoles.name` to `consoles.model`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `consoles` CHANGE COLUMN `name` `model` char(50) NOT NULL DEFAULT ''";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Renaming column `consoles.spu` to `consoles.sound_synth`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText =
|
||||
@"ALTER TABLE `consoles` CHANGE COLUMN `spu` `sound_synth` int(11) NOT NULL DEFAULT '0'";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Renaming column `consoles.mpu` to `consoles.music_synth`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText =
|
||||
@"ALTER TABLE `consoles` CHANGE COLUMN `mpu` `music_synth` int(11) NOT NULL DEFAULT '0'";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Dropping column `consoles.comments`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `consoles` DROP COLUMN `comments`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming column `cpu.cpu` to `cpu.name`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `cpu` CHANGE COLUMN `cpu` `name` char(50) NOT NULL DEFAULT ''";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Renaming table `cpu` to `processors`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `cpu` RENAME TO `processors`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming column `DSPs.DSP` to `DSPs.name`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `DSPs` CHANGE COLUMN `DSP` `name` char(50) NOT NULL DEFAULT ''";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Renaming table `DSPs` to `sound_synths`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `DSPs` RENAME TO `sound_synths`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming column `Formatos_de_disco.Format` to `Formatos_de_disco.description`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText =
|
||||
@"ALTER TABLE `Formatos_de_disco` CHANGE COLUMN `Format` `description` char(50) NOT NULL DEFAULT ''";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Renaming table `Formatos_de_disco` to `disk_formats`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `Formatos_de_disco` RENAME TO `disk_formats`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming column `gpus.gpu` to `gpus.name`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `gpus` CHANGE COLUMN `gpu` `name` char(128) NOT NULL DEFAULT ''";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming table `money_donation` to `money_donations`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `money_donation` RENAME TO `money_donations`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming column `mpus.mpu` to `mpus.name`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `mpus` CHANGE COLUMN `mpu` `name` char(50) NOT NULL DEFAULT ''";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
Console.WriteLine("Renaming table `mpus` to `music_synths`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `mpus` RENAME TO `music_synths`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming table `own_computer` to `owned_computers`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `own_computer` RENAME TO `owned_computers`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Renaming table `own_consoles` to `owned_consoles`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"ALTER TABLE `own_consoles` RENAME TO `owned_consoles`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Dropping table `procesadores_principales`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"DROP TABLE `procesadores_principales`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Getting all items from `console_company`");
|
||||
|
||||
Dictionary<int, string> consoleCompanies = new Dictionary<int, string>();
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = "SELECT * from console_company";
|
||||
DataSet dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
foreach(DataRow dataRow in dataSet.Tables[0].Rows)
|
||||
consoleCompanies.Add(int.Parse(dataRow["id"].ToString()), dataRow["company"].ToString());
|
||||
|
||||
Dictionary<int, int> conversionEquivalents = new Dictionary<int, int>();
|
||||
IDbTransaction trans;
|
||||
|
||||
Console.WriteLine("Converting all items from `console_company` to `companies`");
|
||||
foreach(KeyValuePair<int, string> consoleCompany in consoleCompanies)
|
||||
{
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = $"SELECT * from companies WHERE name LIKE '{consoleCompany.Value}'";
|
||||
dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
if(dataSet.Tables[0].Rows.Count == 1)
|
||||
{
|
||||
Console.WriteLine("Converting console company `{0}` to company `{1}`", consoleCompany.Value,
|
||||
dataSet.Tables[0].Rows[0]["name"]);
|
||||
conversionEquivalents.Add(consoleCompany.Key,
|
||||
int.Parse(dataSet.Tables[0].Rows[0]["id"].ToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write("Adding new company `{0}`... ", consoleCompany.Value);
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
trans = dbCon.BeginTransaction();
|
||||
dbCmd.Transaction = trans;
|
||||
dbCmd.CommandText = $"INSERT INTO companies (name) VALUES ('{consoleCompany.Value}')";
|
||||
|
||||
dbCmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbCmd.Dispose();
|
||||
|
||||
long id = dbCore.LastInsertRowId;
|
||||
Console.WriteLine("got id {0}", id);
|
||||
conversionEquivalents.Add(consoleCompany.Key, (int)id);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Getting all items from `consoles`");
|
||||
Dictionary<int, int> consoleIdAndCompanyId = new Dictionary<int, int>();
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = "SELECT id,company from consoles";
|
||||
dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
foreach(DataRow dataRow in dataSet.Tables[0].Rows)
|
||||
consoleIdAndCompanyId.Add(int.Parse(dataRow["id"].ToString()),
|
||||
int.Parse(dataRow["company"].ToString()));
|
||||
|
||||
trans = dbCon.BeginTransaction();
|
||||
foreach(KeyValuePair<int, int> keyValuePair in consoleIdAndCompanyId)
|
||||
{
|
||||
conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId);
|
||||
Console.WriteLine("Converting console company {0} to company {1} for console {2}... ",
|
||||
keyValuePair.Value, newId, keyValuePair.Key);
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.Transaction = trans;
|
||||
dbCmd.CommandText = $"UPDATE consoles SET company = {newId} WHERE id = {keyValuePair.Key}";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
dbCmd.Dispose();
|
||||
}
|
||||
|
||||
Console.WriteLine("Comitting changes...");
|
||||
trans.Commit();
|
||||
|
||||
Console.WriteLine("Moving company logos...");
|
||||
foreach(string file in Directory.GetFiles("wwwroot/assets/logos/computers/", "*",
|
||||
SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
string newPath = Path.Combine("wwwroot/assets/logos/", Path.GetFileName(file));
|
||||
Console.WriteLine("Moving {0} to {1}...", file, newPath);
|
||||
File.Move(file, newPath);
|
||||
}
|
||||
|
||||
Console.WriteLine("Removing old computer company logos directory...");
|
||||
Directory.Delete("wwwroot/assets/logos/computers");
|
||||
|
||||
Console.WriteLine("Moving console company logos...");
|
||||
foreach(string file in Directory.GetFiles("wwwroot/assets/logos/consoles/", "*",
|
||||
SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
string oldNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
|
||||
if(!int.TryParse(oldNameWithoutExtension, out int oldId))
|
||||
{
|
||||
Console.WriteLine("Removing stray file {0}...", file);
|
||||
File.Delete(file);
|
||||
continue;
|
||||
}
|
||||
|
||||
conversionEquivalents.TryGetValue(oldId, out int newId);
|
||||
string extension = Path.GetExtension(file);
|
||||
|
||||
string newPath = Path.Combine("wwwroot/assets/logos/", $"{newId}{extension}");
|
||||
if(File.Exists(newPath))
|
||||
{
|
||||
Console.WriteLine("Removing duplicate file {0}...", file);
|
||||
File.Delete(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Moving {0} to {1}...", file, newPath);
|
||||
File.Move(file, newPath);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Removing old console company logos directory...");
|
||||
Directory.Delete("wwwroot/assets/logos/consoles");
|
||||
|
||||
Console.WriteLine("Dropping table `console_company`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = @"DROP TABLE `console_company`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Setting new database version to 3...");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
trans = dbCon.BeginTransaction();
|
||||
dbCmd.Transaction = trans;
|
||||
dbCmd.CommandText = $"INSERT INTO cicm_db (version) VALUES ('3')";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbCmd.Dispose();
|
||||
|
||||
Console.WriteLine("Finished update version to 3...");
|
||||
}
|
||||
|
||||
void OptimizeDatabase()
|
||||
{
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = "SHOW TABLES";
|
||||
DataSet dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
foreach(DataRow dataRow in dataSet.Tables[0].Rows)
|
||||
{
|
||||
string tableName = dataRow[0].ToString();
|
||||
|
||||
Console.WriteLine("Optimizing table `{0}`", tableName);
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = $"OPTIMIZE TABLE '{tableName}'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,6 @@ namespace Cicm.Database.Schemas
|
||||
public string Cap2;
|
||||
/// <summary>Maximum colors on screen</summary>
|
||||
public int Colors;
|
||||
/// <summary>Free-form comments</summary>
|
||||
public string Comment;
|
||||
/// <summary>Manufacturer's company ID</summary>
|
||||
public int Company;
|
||||
/// <summary>Primary CPU</summary>
|
||||
@@ -69,10 +67,10 @@ namespace Cicm.Database.Schemas
|
||||
public float Mhz2;
|
||||
/// <summary>Model name</summary>
|
||||
public string Model;
|
||||
/// <summary>ID of MPU</summary>
|
||||
public int Mpu;
|
||||
/// <summary>Audio channels supported by the MPU</summary>
|
||||
public int MusicChannels;
|
||||
/// <summary>ID of MPU</summary>
|
||||
public int MusicSynth;
|
||||
/// <summary>Size in kibibytes of program RAM</summary>
|
||||
public int Ram;
|
||||
/// <summary>Resolution in WxH pixels</summary>
|
||||
@@ -82,7 +80,7 @@ namespace Cicm.Database.Schemas
|
||||
/// <summary>Audio channels supported by the DSP</summary>
|
||||
public int SoundChannels;
|
||||
/// <summary>ID of DSP</summary>
|
||||
public int Spu;
|
||||
public int SoundSynth;
|
||||
/// <summary>Size in kibibytes for video RAM</summary>
|
||||
public int Vram;
|
||||
/// <summary>Introduction date, 0 if unknown, 1000 if prototype</summary>
|
||||
|
||||
@@ -38,8 +38,6 @@ namespace Cicm.Database.Schemas
|
||||
public int Cap;
|
||||
/// <summary>Maximum colors on screen</summary>
|
||||
public int Colors;
|
||||
/// <summary>Free-form comments</summary>
|
||||
public string Comments;
|
||||
/// <summary>Manufacturer's company ID</summary>
|
||||
public int Company;
|
||||
/// <summary>Primary CPU</summary>
|
||||
@@ -56,12 +54,12 @@ namespace Cicm.Database.Schemas
|
||||
public float Mhz1;
|
||||
/// <summary>Frequency in MHz of secondary CPU</summary>
|
||||
public float Mhz2;
|
||||
/// <summary>ID of MPU</summary>
|
||||
public int Mpu;
|
||||
/// <summary>Model name</summary>
|
||||
public string Model;
|
||||
/// <summary>Audio channels supported by the MPU</summary>
|
||||
public int MusicChannels;
|
||||
/// <summary>Model name</summary>
|
||||
public string Name;
|
||||
/// <summary>ID of MPU</summary>
|
||||
public int MusicSynth;
|
||||
/// <summary>Colors on palette</summary>
|
||||
public int Palette;
|
||||
/// <summary>Size in kibibytes of program RAM</summary>
|
||||
@@ -73,7 +71,7 @@ namespace Cicm.Database.Schemas
|
||||
/// <summary>Audio channels supported by the DSP</summary>
|
||||
public int SoundChannels;
|
||||
/// <summary>ID of DSP</summary>
|
||||
public int Spu;
|
||||
public int SoundSynth;
|
||||
/// <summary>Size in kibibytes for video RAM</summary>
|
||||
public int Vram;
|
||||
/// <summary>Introduction date, 0 if unknown, 1000 if prototype</summary>
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ConsoleCompany.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// High level representation of a console manufacturer.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
namespace Cicm.Database.Schemas
|
||||
{
|
||||
/// <summary>
|
||||
/// Videogame console manufacturing company
|
||||
/// </summary>
|
||||
public class ConsoleCompany
|
||||
{
|
||||
/// <summary>ID</summary>
|
||||
public int Id;
|
||||
/// <summary>Name</summary>
|
||||
public string Name;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Mpu.cs
|
||||
// Filename : MusicSynth.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// High level representation of a MPU (Music Processing Unit).
|
||||
// High level representation of a music synthetizer.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
namespace Cicm.Database.Schemas
|
||||
{
|
||||
/// <summary>Music Processing Unit</summary>
|
||||
public class Mpu
|
||||
/// <summary>Music synthetizer</summary>
|
||||
public class MusicSynth
|
||||
{
|
||||
/// <summary>ID</summary>
|
||||
public int Id;
|
||||
@@ -31,7 +31,7 @@
|
||||
namespace Cicm.Database.Schemas
|
||||
{
|
||||
/// <summary>Owned computer</summary>
|
||||
public class OwnComputer
|
||||
public class OwnedComputer
|
||||
{
|
||||
/// <summary>Acquired date</summary>
|
||||
public string Acquired;
|
||||
@@ -31,7 +31,7 @@
|
||||
namespace Cicm.Database.Schemas
|
||||
{
|
||||
/// <summary>Owned videogame console</summary>
|
||||
public class OwnConsole
|
||||
public class OwnedConsole
|
||||
{
|
||||
/// <summary>Acquired date</summary>
|
||||
public string Acquired;
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Cpu.cs
|
||||
// Filename : Processor.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// High level representation of a CPU (Central Processing Unit).
|
||||
// High level representation of a processor .
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
namespace Cicm.Database.Schemas
|
||||
{
|
||||
/// <summary>Central Processing Unit</summary>
|
||||
public class Cpu
|
||||
/// <summary>Processor</summary>
|
||||
public class Processor
|
||||
{
|
||||
/// <summary>ID</summary>
|
||||
public int Id;
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Dsp.cs
|
||||
// Filename : SoundSynth.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// High level representation of a DSP (Digital Sound Processor).
|
||||
// High level representation of a sound synthetizer.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
namespace Cicm.Database.Schemas
|
||||
{
|
||||
/// <summary>Digital Sound Processor</summary>
|
||||
public class Dsp
|
||||
/// <summary>Sound synthetizer</summary>
|
||||
public class SoundSynth
|
||||
{
|
||||
/// <summary>ID</summary>
|
||||
public int Id;
|
||||
231
Cicm.Database/Schemas/Sql/V3.cs
Normal file
231
Cicm.Database/Schemas/Sql/V3.cs
Normal file
@@ -0,0 +1,231 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : V3.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains SQL queries to create the database version 3.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
namespace Cicm.Database.Schemas.Sql
|
||||
{
|
||||
public static class V3
|
||||
{
|
||||
public static readonly string Admins = @"CREATE TABLE `admins` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user` char(50) NOT NULL DEFAULT '',
|
||||
`password` char(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string BrowserTests = @"CREATE TABLE IF NOT EXISTS `browser_tests` (
|
||||
`id` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT,
|
||||
`user_agent` varchar(128) NOT NULL DEFAULT '',
|
||||
`browser` varchar(64) NOT NULL DEFAULT '',
|
||||
`version` varchar(16) NOT NULL DEFAULT '',
|
||||
`os` varchar(32) NOT NULL DEFAULT '',
|
||||
`platform` varchar(8) NOT NULL DEFAULT '',
|
||||
`gif87` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`gif89` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`jpeg` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`png` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pngt` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`agif` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`table` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`colors` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`js` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`frames` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`flash` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string CicmDb = @"CREATE TABLE `cicm_db` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`version` int(11) NOT NULL,
|
||||
`updated` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
INSERT INTO cicm_db (version) VALUES ('3');";
|
||||
|
||||
public static readonly string Companies = @"CREATE TABLE IF NOT EXISTS `companies` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` char(128) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string Computers = @"CREATE TABLE IF NOT EXISTS `computers` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`company` int(11) NOT NULL DEFAULT '0',
|
||||
`year` int(11) NOT NULL DEFAULT '0',
|
||||
`model` char(50) NOT NULL DEFAULT '',
|
||||
`cpu1` int(11) NOT NULL DEFAULT '0',
|
||||
`mhz1` decimal(11,2) NOT NULL DEFAULT '0.00',
|
||||
`cpu2` int(11) DEFAULT NULL,
|
||||
`mhz2` decimal(11,2) DEFAULT NULL,
|
||||
`bits` int(11) NOT NULL DEFAULT '0',
|
||||
`ram` int(11) NOT NULL DEFAULT '0',
|
||||
`rom` int(11) NOT NULL DEFAULT '0',
|
||||
`gpu` int(11) NOT NULL DEFAULT '0',
|
||||
`vram` int(11) NOT NULL DEFAULT '0',
|
||||
`colors` int(11) NOT NULL DEFAULT '0',
|
||||
`res` char(10) NOT NULL DEFAULT '',
|
||||
`sound_synth` int(11) NOT NULL DEFAULT '0',
|
||||
`music_synth` int(11) NOT NULL DEFAULT '0',
|
||||
`sound_channels` int(11) NOT NULL DEFAULT '0',
|
||||
`music_channels` int(11) NOT NULL DEFAULT '0',
|
||||
`hdd1` int(11) NOT NULL DEFAULT '0',
|
||||
`hdd2` int(11) DEFAULT NULL,
|
||||
`hdd3` int(11) DEFAULT NULL,
|
||||
`disk1` int(11) NOT NULL DEFAULT '0',
|
||||
`cap1` char(25) NOT NULL DEFAULT '0',
|
||||
`disk2` int(11) DEFAULT NULL,
|
||||
`cap2` char(25) DEFAULT NULL,
|
||||
`comment` char(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string Consoles = @"CREATE TABLE IF NOT EXISTS `consoles` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`company` int(11) NOT NULL DEFAULT '0',
|
||||
`model` char(50) NOT NULL DEFAULT '',
|
||||
`year` int(11) NOT NULL DEFAULT '0',
|
||||
`cpu1` int(11) NOT NULL DEFAULT '0',
|
||||
`mhz1` decimal(11,2) NOT NULL DEFAULT '0.00',
|
||||
`cpu2` int(11) DEFAULT NULL,
|
||||
`mhz2` decimal(11,2) DEFAULT NULL,
|
||||
`bits` int(11) NOT NULL DEFAULT '0',
|
||||
`ram` int(11) NOT NULL DEFAULT '0',
|
||||
`rom` int(11) NOT NULL DEFAULT '0',
|
||||
`gpu` int(11) NOT NULL DEFAULT '0',
|
||||
`vram` int(11) NOT NULL DEFAULT '0',
|
||||
`res` char(11) NOT NULL DEFAULT '',
|
||||
`colors` int(11) NOT NULL DEFAULT '0',
|
||||
`palette` int(11) NOT NULL DEFAULT '0',
|
||||
`sound_synth` int(11) NOT NULL DEFAULT '0',
|
||||
`schannels` int(11) NOT NULL DEFAULT '0',
|
||||
`music_channels` int(11) NOT NULL DEFAULT '0',
|
||||
`mchannels` int(11) NOT NULL DEFAULT '0',
|
||||
`format` int(11) NOT NULL DEFAULT '0',
|
||||
`cap` int(11) NOT NULL DEFAULT '0',
|
||||
`comments` char(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string DiskFormats = @"CREATE TABLE IF NOT EXISTS `disk_formats` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`description` char(50) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string Forbidden = @"CREATE TABLE IF NOT EXISTS `forbidden` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`browser` char(128) NOT NULL DEFAULT '',
|
||||
`date` char(20) NOT NULL DEFAULT '',
|
||||
`ip` char(16) NOT NULL DEFAULT '',
|
||||
`referer` char(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string Gpus = @"CREATE TABLE IF NOT EXISTS `gpus` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` char(128) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string Logs = @"CREATE TABLE IF NOT EXISTS `log` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`browser` char(128) NOT NULL DEFAULT '',
|
||||
`ip` char(16) NOT NULL DEFAULT '',
|
||||
`date` char(20) NOT NULL DEFAULT '',
|
||||
`referer` char(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string MoneyDonations = @"CREATE TABLE IF NOT EXISTS `money_donation` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`donator` char(128) NOT NULL DEFAULT '',
|
||||
`quantity` decimal(11,2) NOT NULL DEFAULT '0.00',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string MusicSynths = @"CREATE TABLE IF NOT EXISTS `music_synths` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` char(50) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string News = @"CREATE TABLE IF NOT EXISTS `news` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`date` char(20) NOT NULL DEFAULT '',
|
||||
`type` int(11) NOT NULL DEFAULT '0',
|
||||
`added_id` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string OwnedComputers = @"CREATE TABLE IF NOT EXISTS `owned_computers` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`db_id` int(11) NOT NULL DEFAULT '0',
|
||||
`date` varchar(20) NOT NULL DEFAULT '',
|
||||
`status` int(11) NOT NULL DEFAULT '0',
|
||||
`trade` int(11) NOT NULL DEFAULT '0',
|
||||
`boxed` int(11) NOT NULL DEFAULT '0',
|
||||
`manuals` int(11) NOT NULL DEFAULT '0',
|
||||
`cpu1` int(11) NOT NULL DEFAULT '0',
|
||||
`mhz1` decimal(10,0) NOT NULL DEFAULT '0',
|
||||
`cpu2` int(11) NOT NULL DEFAULT '0',
|
||||
`mhz2` decimal(10,0) NOT NULL DEFAULT '0',
|
||||
`ram` int(11) NOT NULL DEFAULT '0',
|
||||
`vram` int(11) NOT NULL DEFAULT '0',
|
||||
`rigid` varchar(64) NOT NULL DEFAULT '',
|
||||
`disk1` int(11) NOT NULL DEFAULT '0',
|
||||
`cap1` int(11) NOT NULL DEFAULT '0',
|
||||
`disk2` int(11) NOT NULL DEFAULT '0',
|
||||
`cap2` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string OwnedConsoles = @"CREATE TABLE IF NOT EXISTS `owned_consoles` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`db_id` int(11) NOT NULL DEFAULT '0',
|
||||
`date` char(20) NOT NULL DEFAULT '',
|
||||
`status` int(11) NOT NULL DEFAULT '0',
|
||||
`trade` int(11) NOT NULL DEFAULT '0',
|
||||
`boxed` int(11) NOT NULL DEFAULT '0',
|
||||
`manuals` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string Processors = @"CREATE TABLE IF NOT EXISTS `processors` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` char(50) NOT NULL DEFAULT '',
|
||||
KEY `id` (`id`)
|
||||
);";
|
||||
|
||||
public static readonly string SoundSynths = @"CREATE TABLE IF NOT EXISTS `sound_synths` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` char(50) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user