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`)
|
||||
);";
|
||||
}
|
||||
}
|
||||
@@ -52,8 +52,7 @@ namespace cicm_web.Controllers
|
||||
|
||||
ViewBag.Letter = id;
|
||||
|
||||
Company[] companies =
|
||||
id == '\0' ? Company.GetAllItems() : Company.GetItemsStartingWithLetter(id);
|
||||
Company[] companies = id == '\0' ? Company.GetAllItems() : Company.GetItemsStartingWithLetter(id);
|
||||
|
||||
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
|
||||
return View(companies);
|
||||
@@ -61,12 +60,10 @@ namespace cicm_web.Controllers
|
||||
|
||||
public IActionResult View(int id)
|
||||
{
|
||||
Company company = Company.GetItem(id);
|
||||
ViewBag.Company = company;
|
||||
Computer[] computers = Computer.GetItemsFromCompany(id);
|
||||
CompanyWithItems company = CompanyWithItems.GetItem(id);
|
||||
|
||||
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
|
||||
return View(computers);
|
||||
return View(company);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ConsoleCompanyController.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Console company controller
|
||||
//
|
||||
// --[ 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 cicm_web.Models;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace cicm_web.Controllers
|
||||
{
|
||||
public class ConsoleCompanyController : Controller
|
||||
{
|
||||
readonly IHostingEnvironment hostingEnvironment;
|
||||
|
||||
public ConsoleCompanyController(IHostingEnvironment env)
|
||||
{
|
||||
hostingEnvironment = env;
|
||||
}
|
||||
|
||||
public IActionResult ByLetter(char id)
|
||||
{
|
||||
// ToUpper()
|
||||
if(id >= 'a' && id <= 'z') id -= (char)32;
|
||||
// Check if not letter
|
||||
if(id < 'A' || id > 'Z') id = '\0';
|
||||
|
||||
ViewBag.Letter = id;
|
||||
|
||||
ConsoleCompany[] companies =
|
||||
id == '\0' ? ConsoleCompany.GetAllItems() : ConsoleCompany.GetItemsStartingWithLetter(id);
|
||||
|
||||
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
|
||||
return View(companies);
|
||||
}
|
||||
|
||||
public IActionResult View(int id)
|
||||
{
|
||||
ConsoleCompany company = ConsoleCompany.GetItem(id);
|
||||
ViewBag.Company = company;
|
||||
Console[] consoles = Console.GetItemsFromCompany(id);
|
||||
|
||||
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
|
||||
return View(consoles);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,49 @@ using System.Linq;
|
||||
|
||||
namespace cicm_web.Models
|
||||
{
|
||||
public class CompanyWithItems
|
||||
{
|
||||
public ComputerMini[] Computers;
|
||||
public ConsoleMini[] Consoles;
|
||||
public int Id;
|
||||
public string Name;
|
||||
|
||||
public static CompanyWithItems GetItem(int id)
|
||||
{
|
||||
Cicm.Database.Schemas.Company dbItem = Program.Database?.Operations.GetCompany(id);
|
||||
|
||||
return dbItem == null
|
||||
? null
|
||||
: new CompanyWithItems
|
||||
{
|
||||
Name = dbItem.Name,
|
||||
Id = dbItem.Id,
|
||||
Computers = ComputerMini.GetItemsWithCompany(id, dbItem.Name),
|
||||
Consoles = ConsoleMini.GetItemsWithCompany(id, dbItem.Name)
|
||||
};
|
||||
}
|
||||
|
||||
public static CompanyWithItems[] GetAllItems()
|
||||
{
|
||||
List<Cicm.Database.Schemas.Company> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetCompanies(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
return dbItems.Select(t => new CompanyWithItems {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
|
||||
}
|
||||
|
||||
public static CompanyWithItems[] GetItemsStartingWithLetter(char letter)
|
||||
{
|
||||
List<Cicm.Database.Schemas.Company> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetCompanies(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
return dbItems
|
||||
.Where(t => t.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
|
||||
.Select(t => new CompanyWithItems {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public class Company
|
||||
{
|
||||
public int Id;
|
||||
@@ -42,6 +85,7 @@ namespace cicm_web.Models
|
||||
public static Company GetItem(int id)
|
||||
{
|
||||
Cicm.Database.Schemas.Company dbItem = Program.Database?.Operations.GetCompany(id);
|
||||
|
||||
return dbItem == null ? null : new Company {Name = dbItem.Name, Id = dbItem.Id};
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,9 @@ namespace cicm_web.Models
|
||||
public string Cap1;
|
||||
public string Cap2;
|
||||
public int Colors;
|
||||
public string Comment;
|
||||
public Company Company;
|
||||
public Cpu Cpu1;
|
||||
public Cpu Cpu2;
|
||||
public Processor Cpu1;
|
||||
public Processor Cpu2;
|
||||
public DiskFormat Disk1;
|
||||
public DiskFormat Disk2;
|
||||
public Gpu Gpu;
|
||||
@@ -54,13 +53,13 @@ namespace cicm_web.Models
|
||||
public float Mhz1;
|
||||
public float Mhz2;
|
||||
public string Model;
|
||||
public Mpu Mpu;
|
||||
public int MusicChannels;
|
||||
public MusicSynth MusicSynth;
|
||||
public int Ram;
|
||||
public string Resolution;
|
||||
public int Rom;
|
||||
public int SoundChannels;
|
||||
public Dsp Spu;
|
||||
public SoundSynth SoundSynth;
|
||||
public int Vram;
|
||||
public int Year;
|
||||
|
||||
@@ -97,7 +96,6 @@ namespace cicm_web.Models
|
||||
{
|
||||
Bits = dbItem.Bits,
|
||||
Colors = dbItem.Colors,
|
||||
Comment = dbItem.Comment,
|
||||
Company = Company.GetItem(dbItem.Company),
|
||||
Gpu = Gpu.GetItem(dbItem.Gpu),
|
||||
Hdd1 = DiskFormat.GetItem(dbItem.Hdd1),
|
||||
@@ -126,25 +124,25 @@ namespace cicm_web.Models
|
||||
|
||||
if(dbItem.Cpu1 > 0)
|
||||
{
|
||||
item.Cpu1 = Cpu.GetItem(dbItem.Cpu1);
|
||||
item.Cpu1 = Processor.GetItem(dbItem.Cpu1);
|
||||
item.Mhz1 = dbItem.Mhz1;
|
||||
}
|
||||
|
||||
if(dbItem.Cpu2 > 0)
|
||||
{
|
||||
item.Cpu2 = Cpu.GetItem(dbItem.Cpu2);
|
||||
item.Cpu2 = Processor.GetItem(dbItem.Cpu2);
|
||||
item.Mhz2 = dbItem.Mhz2;
|
||||
}
|
||||
|
||||
if(dbItem.Mpu > 0)
|
||||
if(dbItem.MusicSynth > 0)
|
||||
{
|
||||
item.Mpu = Mpu.GetItem(dbItem.Mpu);
|
||||
item.MusicSynth = MusicSynth.GetItem(dbItem.MusicSynth);
|
||||
item.MusicChannels = dbItem.MusicChannels;
|
||||
}
|
||||
|
||||
if(dbItem.Spu > 0)
|
||||
if(dbItem.SoundSynth > 0)
|
||||
{
|
||||
item.Spu = Dsp.GetItem(dbItem.Spu);
|
||||
item.SoundSynth = SoundSynth.GetItem(dbItem.SoundSynth);
|
||||
item.SoundChannels = dbItem.SoundChannels;
|
||||
}
|
||||
|
||||
@@ -199,6 +197,32 @@ namespace cicm_web.Models
|
||||
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
|
||||
}
|
||||
|
||||
public static ComputerMini[] GetItemsWithCompany(int id, string companyName)
|
||||
{
|
||||
List<Cicm.Database.Schemas.Computer> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetComputers(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
// TODO: Company chosen by DB
|
||||
return dbItems.Where(t => t.Company == id)
|
||||
.Select(t => new ComputerMini
|
||||
{
|
||||
Company = new Company {Id = id, Name = companyName},
|
||||
Id = t.Id,
|
||||
Model = t.Model
|
||||
}).OrderBy(t => t.Model).ToArray();
|
||||
}
|
||||
|
||||
public static ComputerMini[] GetItemsFromCompany(int id)
|
||||
{
|
||||
List<Cicm.Database.Schemas.Computer> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetComputers(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
// TODO: Company chosen by DB
|
||||
return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Model).ToArray();
|
||||
}
|
||||
|
||||
static ComputerMini TransformItem(Cicm.Database.Schemas.Computer dbItem)
|
||||
{
|
||||
return new ComputerMini {Company = Company.GetItem(dbItem.Company), Id = dbItem.Id, Model = dbItem.Model};
|
||||
|
||||
@@ -36,29 +36,28 @@ namespace cicm_web.Models
|
||||
{
|
||||
public class Console
|
||||
{
|
||||
public int Bits;
|
||||
public int Cap;
|
||||
public int Colors;
|
||||
public string Comments;
|
||||
public ConsoleCompany Company;
|
||||
public Cpu Cpu1;
|
||||
public Cpu Cpu2;
|
||||
public DiskFormat Format;
|
||||
public Gpu Gpu;
|
||||
public int Id;
|
||||
public float Mhz1;
|
||||
public float Mhz2;
|
||||
public Mpu Mpu;
|
||||
public int MusicChannels;
|
||||
public string Name;
|
||||
public int Palette;
|
||||
public int Ram;
|
||||
public string Resolution;
|
||||
public int Rom;
|
||||
public int SoundChannels;
|
||||
public Dsp Spu;
|
||||
public int Vram;
|
||||
public int Year;
|
||||
public int Bits;
|
||||
public int Cap;
|
||||
public int Colors;
|
||||
public Company Company;
|
||||
public Processor Cpu1;
|
||||
public Processor Cpu2;
|
||||
public DiskFormat Format;
|
||||
public Gpu Gpu;
|
||||
public int Id;
|
||||
public float Mhz1;
|
||||
public float Mhz2;
|
||||
public string Model;
|
||||
public int MusicChannels;
|
||||
public MusicSynth MusicSynth;
|
||||
public int Palette;
|
||||
public int Ram;
|
||||
public string Resolution;
|
||||
public int Rom;
|
||||
public int SoundChannels;
|
||||
public SoundSynth SoundSynth;
|
||||
public int Vram;
|
||||
public int Year;
|
||||
|
||||
public static Console[] GetAllItems()
|
||||
{
|
||||
@@ -72,11 +71,11 @@ namespace cicm_web.Models
|
||||
public static Console[] GetItemsFromCompany(int id)
|
||||
{
|
||||
List<Cicm.Database.Schemas.Console> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
// TODO: Company chosen by DB
|
||||
return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Name).ToArray();
|
||||
return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Model).ToArray();
|
||||
}
|
||||
|
||||
public static Console GetItem(int id)
|
||||
@@ -91,11 +90,10 @@ namespace cicm_web.Models
|
||||
{
|
||||
Bits = dbItem.Bits,
|
||||
Colors = dbItem.Colors,
|
||||
Comments = dbItem.Comments,
|
||||
Company = ConsoleCompany.GetItem(dbItem.Company),
|
||||
Company = Company.GetItem(dbItem.Company),
|
||||
Gpu = Gpu.GetItem(dbItem.Gpu),
|
||||
Id = dbItem.Id,
|
||||
Name = dbItem.Name,
|
||||
Model = dbItem.Model,
|
||||
Palette = dbItem.Palette,
|
||||
Ram = dbItem.Ram,
|
||||
Resolution = dbItem.Resolution,
|
||||
@@ -112,25 +110,25 @@ namespace cicm_web.Models
|
||||
|
||||
if(dbItem.Cpu1 > 0)
|
||||
{
|
||||
item.Cpu1 = Cpu.GetItem(dbItem.Cpu1);
|
||||
item.Cpu1 = Processor.GetItem(dbItem.Cpu1);
|
||||
item.Mhz1 = dbItem.Mhz1;
|
||||
}
|
||||
|
||||
if(dbItem.Cpu2 > 0)
|
||||
{
|
||||
item.Cpu2 = Cpu.GetItem(dbItem.Cpu2);
|
||||
item.Cpu2 = Processor.GetItem(dbItem.Cpu2);
|
||||
item.Mhz2 = dbItem.Mhz2;
|
||||
}
|
||||
|
||||
if(dbItem.Mpu > 0)
|
||||
if(dbItem.MusicSynth > 0)
|
||||
{
|
||||
item.Mpu = Mpu.GetItem(dbItem.Mpu);
|
||||
item.MusicSynth = MusicSynth.GetItem(dbItem.MusicSynth);
|
||||
item.MusicChannels = dbItem.MusicChannels;
|
||||
}
|
||||
|
||||
if(dbItem.Spu > 0)
|
||||
if(dbItem.SoundSynth > 0)
|
||||
{
|
||||
item.Spu = Dsp.GetItem(dbItem.Spu);
|
||||
item.SoundSynth = SoundSynth.GetItem(dbItem.SoundSynth);
|
||||
item.SoundChannels = dbItem.SoundChannels;
|
||||
}
|
||||
|
||||
@@ -140,41 +138,41 @@ namespace cicm_web.Models
|
||||
|
||||
public class ConsoleMini
|
||||
{
|
||||
public ConsoleCompany Company;
|
||||
public Company Company;
|
||||
public int Id;
|
||||
public string Name;
|
||||
public string Model;
|
||||
|
||||
public static ConsoleMini[] GetAllItems()
|
||||
{
|
||||
List<Cicm.Database.Schemas.Console> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<ConsoleMini> items = new List<ConsoleMini>();
|
||||
foreach(Cicm.Database.Schemas.Console dbItem in dbItems) items.Add(TransformItem(dbItem));
|
||||
|
||||
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray();
|
||||
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
|
||||
}
|
||||
|
||||
public static ConsoleMini[] GetItemsStartingWithLetter(char letter)
|
||||
{
|
||||
List<Cicm.Database.Schemas.Console> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<ConsoleMini> items = new List<ConsoleMini>();
|
||||
foreach(Cicm.Database.Schemas.Console dbItem in dbItems)
|
||||
if(dbItem.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
|
||||
if(dbItem.Model.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
|
||||
items.Add(TransformItem(dbItem));
|
||||
|
||||
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray();
|
||||
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
|
||||
}
|
||||
|
||||
public static ConsoleMini[] GetItemsFromYear(int year)
|
||||
{
|
||||
List<Cicm.Database.Schemas.Console> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<ConsoleMini> items = new List<ConsoleMini>();
|
||||
@@ -182,12 +180,38 @@ namespace cicm_web.Models
|
||||
if(dbItem.Year == year)
|
||||
items.Add(TransformItem(dbItem));
|
||||
|
||||
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray();
|
||||
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
|
||||
}
|
||||
|
||||
public static ConsoleMini[] GetItemsWithCompany(int id, string companyName)
|
||||
{
|
||||
List<Cicm.Database.Schemas.Console> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
// TODO: Company chosen by DB
|
||||
return dbItems.Where(t => t.Company == id)
|
||||
.Select(t => new ConsoleMini
|
||||
{
|
||||
Company = new Company {Id = id, Name = companyName},
|
||||
Id = t.Id,
|
||||
Model = t.Model
|
||||
}).OrderBy(t => t.Model).ToArray();
|
||||
}
|
||||
|
||||
public static ConsoleMini[] GetItemsFromCompany(int id)
|
||||
{
|
||||
List<Cicm.Database.Schemas.Console> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
// TODO: Company chosen by DB
|
||||
return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Model).ToArray();
|
||||
}
|
||||
|
||||
static ConsoleMini TransformItem(Cicm.Database.Schemas.Console dbItem)
|
||||
{
|
||||
return new ConsoleMini {Company = ConsoleCompany.GetItem(dbItem.Company), Id = dbItem.Id, Name = dbItem.Name};
|
||||
return new ConsoleMini {Company = Company.GetItem(dbItem.Company), Id = dbItem.Id, Model = dbItem.Model};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ConsoleCompany.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Videogame console company model
|
||||
//
|
||||
// --[ 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.Linq;
|
||||
|
||||
namespace cicm_web.Models
|
||||
{
|
||||
public class ConsoleCompany
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
|
||||
public static ConsoleCompany GetItem(int id)
|
||||
{
|
||||
Cicm.Database.Schemas.ConsoleCompany dbItem = Program.Database?.Operations.GetConsoleCompany(id);
|
||||
return dbItem == null ? null : new ConsoleCompany {Name = dbItem.Name, Id = dbItem.Id};
|
||||
}
|
||||
|
||||
public static ConsoleCompany[] GetAllItems()
|
||||
{
|
||||
List<Cicm.Database.Schemas.ConsoleCompany> dbItems = null;
|
||||
bool? result =
|
||||
Program.Database?.Operations.GetConsoleCompanies(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
return dbItems.Select(t => new ConsoleCompany {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
|
||||
}
|
||||
|
||||
public static ConsoleCompany[] GetItemsStartingWithLetter(char letter)
|
||||
{
|
||||
List<Cicm.Database.Schemas.ConsoleCompany> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetConsoleCompanies(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
return dbItems
|
||||
.Where(t => t.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
|
||||
.Select(t => new ConsoleCompany {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Dsp.cs
|
||||
// Filename : MusicSynth.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Digital Sound Processor model
|
||||
// Music Synthetizer model
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -32,27 +32,27 @@ using System.Collections.Generic;
|
||||
|
||||
namespace cicm_web.Models
|
||||
{
|
||||
public class Dsp
|
||||
public class MusicSynth
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
|
||||
public static Dsp GetItem(int id)
|
||||
public static MusicSynth GetItem(int id)
|
||||
{
|
||||
Cicm.Database.Schemas.Dsp dbItem = Program.Database?.Operations.GetDsp(id);
|
||||
return dbItem == null ? null : new Dsp {Name = dbItem.Name, Id = dbItem.Id};
|
||||
Cicm.Database.Schemas.MusicSynth dbItem = Program.Database?.Operations.GetMusicSynth(id);
|
||||
return dbItem == null ? null : new MusicSynth {Name = dbItem.Name, Id = dbItem.Id};
|
||||
}
|
||||
|
||||
public static Dsp[] GetAllItems()
|
||||
public static MusicSynth[] GetAllItems()
|
||||
{
|
||||
List<Cicm.Database.Schemas.Dsp> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetDsps(out dbItems);
|
||||
List<Cicm.Database.Schemas.MusicSynth> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetMusicSynths(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<Dsp> items = new List<Dsp>();
|
||||
List<MusicSynth> items = new List<MusicSynth>();
|
||||
|
||||
foreach(Cicm.Database.Schemas.Dsp dbItem in dbItems)
|
||||
items.Add(new Dsp {Id = dbItem.Id, Name = dbItem.Name});
|
||||
foreach(Cicm.Database.Schemas.MusicSynth dbItem in dbItems)
|
||||
items.Add(new MusicSynth {Id = dbItem.Id, Name = dbItem.Name});
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
@@ -76,9 +76,9 @@ namespace cicm_web.Models
|
||||
string targetView;
|
||||
string subtext;
|
||||
Computer computer;
|
||||
OwnComputer owncomputer;
|
||||
OwnedComputer owncomputer;
|
||||
Console console;
|
||||
OwnConsole ownconsole;
|
||||
OwnedConsole ownconsole;
|
||||
|
||||
switch(dbItem.Type)
|
||||
{
|
||||
@@ -92,51 +92,51 @@ namespace cicm_web.Models
|
||||
case NewsType.NewConsoleInDb:
|
||||
text = "New videoconsole added to the database.";
|
||||
imageUrl = "assets/photos/consoles/";
|
||||
targetView = "console";
|
||||
targetView = "Console";
|
||||
console = Console.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{console.Company.Name} - {console.Name}";
|
||||
subtext = $"{console.Company.Name} - {console.Model}";
|
||||
break;
|
||||
case NewsType.NewComputerInCollection:
|
||||
text = "New computer added to the museum's collection.";
|
||||
imageUrl = "assets/photos/computers/";
|
||||
targetView = "collection_computer";
|
||||
owncomputer = OwnComputer.GetItem(dbItem.AffectedId);
|
||||
targetView = "CollectionComputer";
|
||||
owncomputer = OwnedComputer.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Model}";
|
||||
break;
|
||||
case NewsType.NewConsoleInCollection:
|
||||
text = "New videoconsole added to the museum's collection.";
|
||||
imageUrl = "assets/photos/consoles/";
|
||||
targetView = "collection_console";
|
||||
ownconsole = OwnConsole.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Name}";
|
||||
targetView = "CollectionConsole";
|
||||
ownconsole = OwnedConsole.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Model}";
|
||||
break;
|
||||
case NewsType.UpdatedComputerInDb:
|
||||
text = "Updated computer from the database.";
|
||||
imageUrl = "assets/photos/computers/";
|
||||
targetView = "computer";
|
||||
targetView = "Computer";
|
||||
computer = Computer.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{computer.Company.Name} - {computer.Model}";
|
||||
break;
|
||||
case NewsType.UpdatedConsoleInDb:
|
||||
text = "Updated videoconsole from the database.";
|
||||
imageUrl = "assets/photos/consoles/";
|
||||
targetView = "console";
|
||||
targetView = "Console";
|
||||
console = Console.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{console.Company.Name} - {console.Name}";
|
||||
subtext = $"{console.Company.Name} - {console.Model}";
|
||||
break;
|
||||
case NewsType.UpdatedComputerInCollection:
|
||||
text = "Updated computer from museum's collection.";
|
||||
imageUrl = "assets/photos/computers/";
|
||||
targetView = "collection_computer";
|
||||
owncomputer = OwnComputer.GetItem(dbItem.AffectedId);
|
||||
targetView = "CollectionComputer";
|
||||
owncomputer = OwnedComputer.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Model}";
|
||||
break;
|
||||
case NewsType.UpdatedConsoleInCollection:
|
||||
text = "Updated videoconsole from museum's collection.";
|
||||
imageUrl = "assets/photos/consoles/";
|
||||
targetView = "collection_console";
|
||||
ownconsole = OwnConsole.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Name}";
|
||||
targetView = "CollectionConsole";
|
||||
ownconsole = OwnedConsole.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Model}";
|
||||
break;
|
||||
case NewsType.NewMoneyDonation:
|
||||
text = "New money donation.";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : OwnComputer.cs
|
||||
// Filename : OwnedComputer.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
@@ -36,15 +36,15 @@ using Cicm.Database.Schemas;
|
||||
|
||||
namespace cicm_web.Models
|
||||
{
|
||||
public class OwnComputer
|
||||
public class OwnedComputer
|
||||
{
|
||||
public DateTime Acquired;
|
||||
public bool Boxed;
|
||||
public int Cap1;
|
||||
public int Cap2;
|
||||
public Computer Computer;
|
||||
public Cpu Cpu1;
|
||||
public Cpu Cpu2;
|
||||
public Processor Cpu1;
|
||||
public Processor Cpu2;
|
||||
public DiskFormat Disk1;
|
||||
public DiskFormat Disk2;
|
||||
public int Id;
|
||||
@@ -57,26 +57,27 @@ namespace cicm_web.Models
|
||||
public bool Trade;
|
||||
public int Vram;
|
||||
|
||||
public static OwnComputer[] GetAllItems()
|
||||
public static OwnedComputer[] GetAllItems()
|
||||
{
|
||||
List<Cicm.Database.Schemas.OwnComputer> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetOwnComputers(out dbItems);
|
||||
List<Cicm.Database.Schemas.OwnedComputer> dbItems = null;
|
||||
bool? result =
|
||||
Program.Database?.Operations.GetOwnedComputers(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnComputer[];
|
||||
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnedComputer[];
|
||||
}
|
||||
|
||||
public static OwnComputer GetItem(int id)
|
||||
public static OwnedComputer GetItem(int id)
|
||||
{
|
||||
Cicm.Database.Schemas.OwnComputer dbItem = Program.Database?.Operations.GetOwnComputer(id);
|
||||
Cicm.Database.Schemas.OwnedComputer dbItem = Program.Database?.Operations.GetOwnedComputer(id);
|
||||
return dbItem == null ? null : TransformItem(dbItem);
|
||||
}
|
||||
|
||||
static OwnComputer TransformItem(Cicm.Database.Schemas.OwnComputer dbItem)
|
||||
static OwnedComputer TransformItem(Cicm.Database.Schemas.OwnedComputer dbItem)
|
||||
{
|
||||
Computer computer = Computer.GetItem(dbItem.ComputerId);
|
||||
|
||||
OwnComputer item = new OwnComputer
|
||||
OwnedComputer item = new OwnedComputer
|
||||
{
|
||||
Acquired = DateTime.ParseExact(dbItem.Acquired, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||||
Boxed = dbItem.Boxed,
|
||||
@@ -104,13 +105,13 @@ namespace cicm_web.Models
|
||||
|
||||
if(dbItem.Cpu1 > 0)
|
||||
{
|
||||
item.Cpu1 = Cpu.GetItem(dbItem.Cpu1);
|
||||
item.Cpu1 = Processor.GetItem(dbItem.Cpu1);
|
||||
item.Mhz1 = dbItem.Mhz1;
|
||||
}
|
||||
|
||||
if(dbItem.Cpu2 > 0)
|
||||
{
|
||||
item.Cpu2 = Cpu.GetItem(dbItem.Cpu2);
|
||||
item.Cpu2 = Processor.GetItem(dbItem.Cpu2);
|
||||
item.Mhz2 = dbItem.Mhz2;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : OwnConsole.cs
|
||||
// Filename : OwnedConsole.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
@@ -36,7 +36,7 @@ using Cicm.Database.Schemas;
|
||||
|
||||
namespace cicm_web.Models
|
||||
{
|
||||
public class OwnConsole
|
||||
public class OwnedConsole
|
||||
{
|
||||
public DateTime Acquired;
|
||||
public bool Boxed;
|
||||
@@ -46,28 +46,29 @@ namespace cicm_web.Models
|
||||
public StatusType Status;
|
||||
public bool Trade;
|
||||
|
||||
public static OwnConsole[] GetAllItems()
|
||||
public static OwnedConsole[] GetAllItems()
|
||||
{
|
||||
List<Cicm.Database.Schemas.OwnConsole> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetOwnConsoles(out dbItems);
|
||||
List<Cicm.Database.Schemas.OwnedConsole> dbItems = null;
|
||||
bool? result =
|
||||
Program.Database?.Operations.GetOwnedConsoles(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnConsole[];
|
||||
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnedConsole[];
|
||||
}
|
||||
|
||||
public static OwnConsole GetItem(int id)
|
||||
public static OwnedConsole GetItem(int id)
|
||||
{
|
||||
Cicm.Database.Schemas.OwnConsole dbItem = Program.Database?.Operations.GetOwnConsole(id);
|
||||
Cicm.Database.Schemas.OwnedConsole dbItem = Program.Database?.Operations.GetOwnedConsole(id);
|
||||
return dbItem == null ? null : TransformItem(dbItem);
|
||||
}
|
||||
|
||||
static OwnConsole TransformItem(Cicm.Database.Schemas.OwnConsole dbItem)
|
||||
static OwnedConsole TransformItem(Cicm.Database.Schemas.OwnedConsole dbItem)
|
||||
{
|
||||
Console console = Console.GetItem(dbItem.ConsoleId);
|
||||
|
||||
return console == null
|
||||
? null
|
||||
: new OwnConsole
|
||||
: new OwnedConsole
|
||||
{
|
||||
Acquired =
|
||||
DateTime.ParseExact(dbItem.Acquired, "yyyy/MM/dd HH:mm:ss",
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Cpu.cs
|
||||
// Filename : Processor.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Central Processing Unit model
|
||||
// Processor model
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -32,27 +32,27 @@ using System.Collections.Generic;
|
||||
|
||||
namespace cicm_web.Models
|
||||
{
|
||||
public class Cpu
|
||||
public class Processor
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
|
||||
public static Cpu GetItem(int id)
|
||||
public static Processor GetItem(int id)
|
||||
{
|
||||
Cicm.Database.Schemas.Cpu dbItem = Program.Database?.Operations.GetCpu(id);
|
||||
return dbItem == null ? null : new Cpu {Name = dbItem.Name, Id = dbItem.Id};
|
||||
Cicm.Database.Schemas.Processor dbItem = Program.Database?.Operations.GetProcessor(id);
|
||||
return dbItem == null ? null : new Processor {Name = dbItem.Name, Id = dbItem.Id};
|
||||
}
|
||||
|
||||
public static Cpu[] GetAllItems()
|
||||
public static Processor[] GetAllItems()
|
||||
{
|
||||
List<Cicm.Database.Schemas.Cpu> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetCpus(out dbItems);
|
||||
List<Cicm.Database.Schemas.Processor> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetProcessors(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<Cpu> items = new List<Cpu>();
|
||||
List<Processor> items = new List<Processor>();
|
||||
|
||||
foreach(Cicm.Database.Schemas.Cpu dbItem in dbItems)
|
||||
items.Add(new Cpu {Id = dbItem.Id, Name = dbItem.Name});
|
||||
foreach(Cicm.Database.Schemas.Processor dbItem in dbItems)
|
||||
items.Add(new Processor {Id = dbItem.Id, Name = dbItem.Name});
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Mpu.cs
|
||||
// Filename : SoundSynth.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Music Processing Unit model
|
||||
// Digital Sound Synthetizer model
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -32,27 +32,27 @@ using System.Collections.Generic;
|
||||
|
||||
namespace cicm_web.Models
|
||||
{
|
||||
public class Mpu
|
||||
public class SoundSynth
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
|
||||
public static Mpu GetItem(int id)
|
||||
public static SoundSynth GetItem(int id)
|
||||
{
|
||||
Cicm.Database.Schemas.Mpu dbItem = Program.Database?.Operations.GetMpu(id);
|
||||
return dbItem == null ? null : new Mpu {Name = dbItem.Name, Id = dbItem.Id};
|
||||
Cicm.Database.Schemas.SoundSynth dbItem = Program.Database?.Operations.GetSoundSynth(id);
|
||||
return dbItem == null ? null : new SoundSynth {Name = dbItem.Name, Id = dbItem.Id};
|
||||
}
|
||||
|
||||
public static Mpu[] GetAllItems()
|
||||
public static SoundSynth[] GetAllItems()
|
||||
{
|
||||
List<Cicm.Database.Schemas.Mpu> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetMpus(out dbItems);
|
||||
List<Cicm.Database.Schemas.SoundSynth> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetSoundSynths(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<Mpu> items = new List<Mpu>();
|
||||
List<SoundSynth> items = new List<SoundSynth>();
|
||||
|
||||
foreach(Cicm.Database.Schemas.Mpu dbItem in dbItems)
|
||||
items.Add(new Mpu {Id = dbItem.Id, Name = dbItem.Name});
|
||||
foreach(Cicm.Database.Schemas.SoundSynth dbItem in dbItems)
|
||||
items.Add(new SoundSynth {Id = dbItem.Id, Name = dbItem.Name});
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
@@ -48,21 +48,21 @@
|
||||
@Model.Count() companies found in the database.<br />
|
||||
@foreach(Company company in Model)
|
||||
{
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", company.Id + ".gif")))
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.Id + ".gif")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/computers", company.Id + ".gif"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", company.Id + ".gif"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", company.Id + ".jpg")))
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.Id + ".jpg")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/computers", company.Id + ".jpg"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", company.Id + ".jpg"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", company.Id + ".png")))
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.Id + ".png")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/computers", company.Id + ".png"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", company.Id + ".png"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
|
||||
@@ -32,49 +32,72 @@
|
||||
ViewData["Title"] = "Companies";
|
||||
}
|
||||
@using System.IO
|
||||
@model IEnumerable<Computer>
|
||||
@model CompanyWithItems
|
||||
|
||||
<p>Search results:</p>
|
||||
<p align=center>
|
||||
@if(ViewBag.Company != null)
|
||||
@if(Model != null)
|
||||
{
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", ViewBag.Company.Id + ".gif")))
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".gif")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/computers", ViewBag.Company.Id + ".gif"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", Model.Id + ".gif"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", ViewBag.Company.Id + ".jpg")))
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".jpg")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/computers", ViewBag.Company.Id + ".jpg"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", Model.Id + ".jpg"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", ViewBag.Company.Id + ".png")))
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".png")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/computers", ViewBag.Company.Id + ".png"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", Model.Id + ".png"))"
|
||||
alt="">
|
||||
}
|
||||
<b>@ViewBag.Company.Name</b>
|
||||
<b>@Model.Name</b>
|
||||
<br />
|
||||
}
|
||||
|
||||
@if(Model.Any())
|
||||
{
|
||||
<p>
|
||||
@Model.Count() computers found in the database.<br />
|
||||
@foreach(Computer computer in Model)
|
||||
{
|
||||
<a asp-controller="Computer"
|
||||
asp-action="View"
|
||||
asp-route-id="@computer.Id">
|
||||
@computer.Model</a>
|
||||
<br />
|
||||
}
|
||||
</p>
|
||||
if(Model.Computers.Any())
|
||||
{
|
||||
<p>
|
||||
@Model.Computers.Count() computers found in the database.<br />
|
||||
@foreach(ComputerMini computer in Model.Computers)
|
||||
{
|
||||
<a asp-controller="Computer"
|
||||
asp-action="View"
|
||||
asp-route-id="@computer.Id">
|
||||
@computer.Model</a>
|
||||
<br />
|
||||
}
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>There are no computers found in the database that belong to that company.</p>
|
||||
}
|
||||
|
||||
if(Model.Consoles.Any())
|
||||
{
|
||||
<p>
|
||||
@Model.Consoles.Count() videoconsoles found in the database.<br />
|
||||
@foreach(ConsoleMini console in Model.Consoles)
|
||||
{
|
||||
<a asp-controller="Console"
|
||||
asp-action="View"
|
||||
asp-route-id="@console.Id">
|
||||
@console.Model</a>
|
||||
<br />
|
||||
}
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>There are no videoconsoles found in the database that belong to that company.</p>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>There are no computers found in the database that belong to that company.</p>
|
||||
<p>Company not found!</p>
|
||||
}
|
||||
</p>
|
||||
@@ -34,21 +34,21 @@
|
||||
@using System.IO
|
||||
@model Computer
|
||||
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", Model.Company.Id + ".gif")))
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".gif")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/computers", Model.Company.Id + ".gif"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", Model.Company.Id + ".gif"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", Model.Company.Id + ".jpg")))
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".jpg")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/computers", Model.Company.Id + ".jpg"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", Model.Company.Id + ".jpg"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", Model.Company.Id + ".png")))
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".png")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/computers", Model.Company.Id + ".png"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", Model.Company.Id + ".png"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
@@ -294,17 +294,17 @@
|
||||
Sound processor
|
||||
</div>
|
||||
</th>
|
||||
@if(Model.Spu.Id > 1)
|
||||
@if(Model.SoundSynth.Id > 1)
|
||||
{
|
||||
if(Model.Spu.Id > 2)
|
||||
if(Model.SoundSynth.Id > 2)
|
||||
{
|
||||
if(Model.SoundChannels > 0)
|
||||
{
|
||||
<td>@Model.Spu.Name (@Model.SoundChannels channels)</td>
|
||||
<td>@Model.SoundSynth.Name (@Model.SoundChannels channels)</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>@Model.Spu.Name</td>
|
||||
<td>@Model.SoundSynth.Name</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -321,17 +321,17 @@
|
||||
Music synthetizer
|
||||
</div>
|
||||
</th>
|
||||
@if(Model.Mpu.Id > 1)
|
||||
@if(Model.MusicSynth.Id > 1)
|
||||
{
|
||||
if(Model.Mpu.Id > 2)
|
||||
if(Model.MusicSynth.Id > 2)
|
||||
{
|
||||
if(Model.MusicChannels > 0)
|
||||
{
|
||||
<td>@Model.Mpu.Name (@Model.MusicChannels channels)</td>
|
||||
<td>@Model.MusicSynth.Name (@Model.MusicChannels channels)</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>@Model.Mpu.Name</td>
|
||||
<td>@Model.MusicSynth.Name</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
@@ -35,19 +35,25 @@
|
||||
@model IEnumerable<ConsoleMini>
|
||||
|
||||
<p>Search results:</p>
|
||||
<p align="center">
|
||||
<p align=center>
|
||||
@if(ViewBag.Letter != '\0')
|
||||
{
|
||||
<b>@ViewBag.Letter</b><br/>
|
||||
<b>@ViewBag.Letter</b>
|
||||
<br />
|
||||
}
|
||||
|
||||
@if(Model.Any())
|
||||
{
|
||||
<p>@Model.Count() computers found in the database.<br />
|
||||
@foreach(ConsoleMini console in @Model)
|
||||
{
|
||||
<a asp-controller="Console" asp-action="View" asp-route-id="@console.Id">@console.Company.Name @console.Name</a><br/>
|
||||
}
|
||||
<p>
|
||||
@Model.Count() computers found in the database.<br />
|
||||
@foreach(ConsoleMini console in Model)
|
||||
{
|
||||
<a asp-controller="Console"
|
||||
asp-action="View"
|
||||
asp-route-id="@console.Id">
|
||||
@console.Company.Name @console.Model</a>
|
||||
<br />
|
||||
}
|
||||
</p>
|
||||
}
|
||||
else
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<a asp-controller="Console"
|
||||
asp-action="View"
|
||||
asp-route-id="@console.Id">
|
||||
@console.Company.Name @console.Name</a>
|
||||
@console.Company.Name @console.Model</a>
|
||||
<br />
|
||||
}
|
||||
</p>
|
||||
|
||||
@@ -44,140 +44,140 @@
|
||||
Search by companies
|
||||
<br>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=Q>
|
||||
Q
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=W>
|
||||
W
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=E>
|
||||
E
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=R>
|
||||
R
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=T>
|
||||
T
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=Y>
|
||||
Y
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=U>
|
||||
U
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=I>
|
||||
I
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=O>
|
||||
O
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=P>
|
||||
P
|
||||
</a>
|
||||
<br>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=A>
|
||||
A
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=S>
|
||||
S
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=D>
|
||||
D
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=F>
|
||||
F
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=G>
|
||||
G
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=H>
|
||||
H
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=J>
|
||||
J
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=K>
|
||||
K
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=L>
|
||||
L
|
||||
</a>
|
||||
<br>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=Z>
|
||||
Z
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=X>
|
||||
X
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=C>
|
||||
C
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=V>
|
||||
V
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=B>
|
||||
B
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=N>
|
||||
N
|
||||
</a>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany
|
||||
asp-controller=Company
|
||||
asp-route-id=M>
|
||||
M
|
||||
</a>
|
||||
<br>
|
||||
<a asp-action=ByLetter
|
||||
asp-controller=ConsoleCompany>
|
||||
asp-controller=Company>
|
||||
All companies
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@@ -34,21 +34,21 @@
|
||||
@using System.IO
|
||||
@model cicm_web.Models.Console
|
||||
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", Model.Company.Id + ".gif")))
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".gif")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", Model.Company.Id + ".gif"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", Model.Company.Id + ".gif"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", Model.Company.Id + ".jpg")))
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".jpg")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", Model.Company.Id + ".jpg"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", Model.Company.Id + ".jpg"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", Model.Company.Id + ".png")))
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".png")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", Model.Company.Id + ".png"))"
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos", Model.Company.Id + ".png"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
</b>
|
||||
}
|
||||
|
||||
<b>@Model.Company.Name @Model.Name</b>
|
||||
<b>@Model.Company.Name @Model.Model</b>
|
||||
<table border=0
|
||||
width=100%>
|
||||
@if(Model.Year != 1000)
|
||||
@@ -300,17 +300,17 @@
|
||||
Sound processor
|
||||
</div>
|
||||
</th>
|
||||
@if(Model.Spu.Id > 1)
|
||||
@if(Model.SoundSynth.Id > 1)
|
||||
{
|
||||
if(Model.Spu.Id > 2)
|
||||
if(Model.SoundSynth.Id > 2)
|
||||
{
|
||||
if(Model.SoundChannels > 0)
|
||||
{
|
||||
<td>@Model.Spu.Name (@Model.SoundChannels channels)</td>
|
||||
<td>@Model.SoundSynth.Name (@Model.SoundChannels channels)</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>@Model.Spu.Name</td>
|
||||
<td>@Model.SoundSynth.Name</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -327,17 +327,17 @@
|
||||
Music synthetizer
|
||||
</div>
|
||||
</th>
|
||||
@if(Model.Mpu.Id > 1)
|
||||
@if(Model.MusicSynth.Id > 1)
|
||||
{
|
||||
if(Model.Mpu.Id > 2)
|
||||
if(Model.MusicSynth.Id > 2)
|
||||
{
|
||||
if(Model.MusicChannels > 0)
|
||||
{
|
||||
<td>@Model.Mpu.Name (@Model.MusicChannels channels)</td>
|
||||
<td>@Model.MusicSynth.Name (@Model.MusicChannels channels)</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>@Model.Mpu.Name</td>
|
||||
<td>@Model.MusicSynth.Name</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ByLetter.cshtml
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Lists companies by letter (or all)
|
||||
//
|
||||
// --[ 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
|
||||
*******************************************************************************/
|
||||
|
||||
ViewData["Title"] = "Console companies";
|
||||
}
|
||||
@using System.IO
|
||||
@model IEnumerable<ConsoleCompany>
|
||||
|
||||
<p>Search results:</p>
|
||||
<p align=center>
|
||||
@if(ViewBag.Letter != '\0')
|
||||
{
|
||||
<b>@ViewBag.Letter</b>
|
||||
<br />
|
||||
}
|
||||
|
||||
@if(Model.Any())
|
||||
{
|
||||
<p>
|
||||
@Model.Count() companies found in the database.<br />
|
||||
@foreach(ConsoleCompany company in Model)
|
||||
{
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", company.Id + ".gif")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", company.Id + ".gif"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", company.Id + ".jpg")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", company.Id + ".jpg"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", company.Id + ".png")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", company.Id + ".png"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
<a asp-controller="ConsoleCompany"
|
||||
asp-action="View"
|
||||
asp-route-id="@company.Id">
|
||||
@company.Name</a>
|
||||
<br />
|
||||
}
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>There are no console companies found in the database that start with this letter.</p>
|
||||
}
|
||||
</p>
|
||||
@@ -1,80 +0,0 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ByLetter.cshtml
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Lists computers by company
|
||||
//
|
||||
// --[ 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
|
||||
*******************************************************************************/
|
||||
|
||||
ViewData["Title"] = "Companies";
|
||||
}
|
||||
@using System.IO
|
||||
@model IEnumerable<cicm_web.Models.Console>
|
||||
|
||||
<p>Search results:</p>
|
||||
<p align=center>
|
||||
@if(ViewBag.Company != null)
|
||||
{
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", ViewBag.Company.Id + ".gif")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", ViewBag.Company.Id + ".gif"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", ViewBag.Company.Id + ".jpg")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", ViewBag.Company.Id + ".jpg"))"
|
||||
alt="">
|
||||
}
|
||||
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", ViewBag.Company.Id + ".png")))
|
||||
{
|
||||
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", ViewBag.Company.Id + ".png"))"
|
||||
alt="">
|
||||
}
|
||||
<b>@ViewBag.Company.Name</b>
|
||||
<br />
|
||||
}
|
||||
|
||||
@if(Model.Any())
|
||||
{
|
||||
<p>
|
||||
@Model.Count() computers found in the database.<br />
|
||||
@foreach(cicm_web.Models.Console console in Model)
|
||||
{
|
||||
<a asp-controller="Console"
|
||||
asp-action="View"
|
||||
asp-route-id="@console.Id">
|
||||
@console.Name</a>
|
||||
<br />
|
||||
}
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>There are no videoconsoles found in the database that belong to that company.</p>
|
||||
}
|
||||
</p>
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<Version>3.0.99.86</Version>
|
||||
<Version>3.0.99.100</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user