Update DB to version 16: Machines can have an arbitrary number of gpus,

so use an interconnection table, `gpus_by_machine`.
This commit is contained in:
2018-04-28 14:39:21 +01:00
parent 02b9981681
commit fdcefed085
12 changed files with 655 additions and 184 deletions

View File

@@ -0,0 +1,149 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : GpuByMachine.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Contains operations to manage gpus.
//
// --[ 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;
namespace Cicm.Database
{
public partial class Operations
{
/// <summary>
/// Gets all gpus in machine
/// </summary>
/// <param name="entries">All CPUs</param>
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
public bool GetGpusByMachines(out List<GpuByMachine> entries, int machineId)
{
#if DEBUG
Console.WriteLine("Getting all gpus for machine {0}...", machineId);
#endif
try
{
string sql = $"SELECT * FROM gpus_by_machine WHERE machine = {machineId}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
dbCmd.CommandText = sql;
DataSet dataSet = new DataSet();
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
entries = GpuByMachinesFromDataTable(dataSet.Tables[0]);
return true;
}
catch(Exception ex)
{
Console.WriteLine("Error getting gpus by machine.");
Console.WriteLine(ex);
entries = null;
return false;
}
}
/// <summary>
/// Gets all machines with specified gpu
/// </summary>
/// <param name="entries">All CPUs</param>
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
public bool GetMachinesByGpu(out List<GpuByMachine> entries, int gpuId)
{
#if DEBUG
Console.WriteLine("Getting all machines with gpu {0}...", gpuId);
#endif
try
{
string sql = $"SELECT * FROM gpus_by_machine WHERE gpu = {gpuId}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
dbCmd.CommandText = sql;
DataSet dataSet = new DataSet();
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
entries = GpuByMachinesFromDataTable(dataSet.Tables[0]);
return true;
}
catch(Exception ex)
{
Console.WriteLine("Error getting machines by gpu.");
Console.WriteLine(ex);
entries = null;
return false;
}
}
IDbCommand GetCommandGpuByMachine(GpuByMachine entry)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataParameter param1 = dbcmd.CreateParameter();
IDbDataParameter param2 = dbcmd.CreateParameter();
param1.ParameterName = "@gpu";
param2.ParameterName = "@machine";
param1.DbType = DbType.Int32;
param2.DbType = DbType.Int32;
param1.Value = entry.Gpu;
param2.Value = entry.Machine;
dbcmd.Parameters.Add(param1);
return dbcmd;
}
static List<GpuByMachine> GpuByMachinesFromDataTable(DataTable dataTable)
{
List<GpuByMachine> entries = new List<GpuByMachine>();
foreach(DataRow dataRow in dataTable.Rows)
{
GpuByMachine entry = new GpuByMachine
{
Machine = (int)dataRow["machine"],
Gpu = (int)dataRow["gpu"]
};
entries.Add(entry);
}
return entries;
}
}
}

View File

@@ -49,103 +49,107 @@ namespace Cicm.Database
IDbCommand dbCmd = dbCon.CreateCommand();
Console.WriteLine("Creating table `admins`");
dbCmd.CommandText = V15.Admins;
dbCmd.CommandText = V16.Admins;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `browser_tests`");
dbCmd.CommandText = V15.BrowserTests;
dbCmd.CommandText = V16.BrowserTests;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `cicm_db`");
dbCmd.CommandText = V15.CicmDb;
dbCmd.CommandText = V16.CicmDb;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `companies`");
dbCmd.CommandText = V15.Companies;
dbCmd.CommandText = V16.Companies;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `machines`");
dbCmd.CommandText = V15.Machines;
dbCmd.CommandText = V16.Machines;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `disk_formats`");
dbCmd.CommandText = V15.DiskFormats;
dbCmd.CommandText = V16.DiskFormats;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `forbidden`");
dbCmd.CommandText = V15.Forbidden;
dbCmd.CommandText = V16.Forbidden;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `gpus`");
dbCmd.CommandText = V15.Gpus;
dbCmd.CommandText = V16.Gpus;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `log`");
dbCmd.CommandText = V15.Logs;
dbCmd.CommandText = V16.Logs;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `money_donations`");
dbCmd.CommandText = V15.MoneyDonations;
dbCmd.CommandText = V16.MoneyDonations;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `news`");
dbCmd.CommandText = V15.News;
dbCmd.CommandText = V16.News;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `owned_computers`");
dbCmd.CommandText = V15.OwnedComputers;
dbCmd.CommandText = V16.OwnedComputers;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `owned_consoles`");
dbCmd.CommandText = V15.OwnedConsoles;
dbCmd.CommandText = V16.OwnedConsoles;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `instruction_sets`");
dbCmd.CommandText = V15.InstructionSets;
dbCmd.CommandText = V16.InstructionSets;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `instruction_set_extensions`");
dbCmd.CommandText = V15.InstructionSetExtensions;
dbCmd.CommandText = V16.InstructionSetExtensions;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `processors`");
dbCmd.CommandText = V15.Processors;
dbCmd.CommandText = V16.Processors;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `instruction_set_extensions_by_processor`");
dbCmd.CommandText = V15.InstructionSetExtensionsByProcessor;
dbCmd.CommandText = V16.InstructionSetExtensionsByProcessor;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `sound_synths`");
dbCmd.CommandText = V15.SoundSynths;
dbCmd.CommandText = V16.SoundSynths;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `iso3166_1_numeric`");
dbCmd.CommandText = V15.Iso3166Numeric;
dbCmd.CommandText = V16.Iso3166Numeric;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Filling table `iso3166_1_numeric`");
dbCmd.CommandText = V15.Iso3166NumericValues;
dbCmd.CommandText = V16.Iso3166NumericValues;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating foreign keys for table `companies`");
dbCmd.CommandText = V15.CompaniesForeignKeys;
dbCmd.CommandText = V16.CompaniesForeignKeys;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating foreign keys for table `machines`");
dbCmd.CommandText = V15.MachinesForeignKeys;
dbCmd.CommandText = V16.MachinesForeignKeys;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `company_logos`");
dbCmd.CommandText = V15.CompanyLogos;
dbCmd.CommandText = V16.CompanyLogos;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `company_descriptions`");
dbCmd.CommandText = V15.CompanyDescriptions;
dbCmd.CommandText = V16.CompanyDescriptions;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `processors_by_machine`");
dbCmd.CommandText = V15.ProcessorsByMachine;
dbCmd.CommandText = V16.ProcessorsByMachine;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `gpus_by_machine`");
dbCmd.CommandText = V16.GpusByMachine;
dbCmd.ExecuteNonQuery();
return true;

View File

@@ -214,9 +214,9 @@ namespace Cicm.Database
dbcmd.Transaction = trans;
const string SQL =
"INSERT INTO machines (company, year, model, ram, rom, gpu, vram, colors, res, sound_synth, music_synth, " +
"INSERT INTO machines (company, year, model, ram, rom, vram, colors, res, sound_synth, music_synth, " +
"sound_channels, music_channels, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2, type)" +
" VALUES (@company, @year, @model, @ram, @rom, @gpu, @vram, @colors, @res, @sound_synth, @music_synth, " +
" VALUES (@company, @year, @model, @ram, @rom, @vram, @colors, @res, @sound_synth, @music_synth, " +
"@sound_channels, @music_channels, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2, @type)";
dbcmd.CommandText = SQL;
@@ -251,7 +251,7 @@ namespace Cicm.Database
string sql =
"UPDATE machines SET company = @company, year = @year, model = @model, ram = @ram, rom = @rom, " +
"gpu = @gpu, vram = @vram, colors = @colors, res = @res, sound_synth = @sound_synth, " +
"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, " +
"type = @type " +
@@ -316,29 +316,27 @@ namespace Cicm.Database
IDbDataParameter param18 = dbcmd.CreateParameter();
IDbDataParameter param19 = dbcmd.CreateParameter();
IDbDataParameter param20 = dbcmd.CreateParameter();
IDbDataParameter param21 = dbcmd.CreateParameter();
param1.ParameterName = "@company";
param2.ParameterName = "@year";
param3.ParameterName = "@model";
param4.ParameterName = "@ram";
param5.ParameterName = "@rom";
param6.ParameterName = "@gpu";
param7.ParameterName = "@vram";
param8.ParameterName = "@colors";
param9.ParameterName = "@res";
param10.ParameterName = "@sound_synth";
param11.ParameterName = "@music_synth";
param12.ParameterName = "@sound_channels";
param13.ParameterName = "@music_channels";
param14.ParameterName = "@hdd1";
param15.ParameterName = "@hdd2";
param16.ParameterName = "@hdd3";
param17.ParameterName = "@disk1";
param6.ParameterName = "@vram";
param7.ParameterName = "@colors";
param8.ParameterName = "@res";
param9.ParameterName = "@sound_synth";
param10.ParameterName = "@music_synth";
param11.ParameterName = "@sound_channels";
param12.ParameterName = "@music_channels";
param13.ParameterName = "@hdd1";
param14.ParameterName = "@hdd2";
param15.ParameterName = "@hdd3";
param16.ParameterName = "@disk1";
param17.ParameterName = "@cap1";
param19.ParameterName = "@disk2";
param20.ParameterName = "@cap2";
param21.ParameterName = "@type";
param18.ParameterName = "@disk2";
param19.ParameterName = "@cap2";
param20.ParameterName = "@type";
param1.DbType = DbType.Int32;
param2.DbType = DbType.Int32;
@@ -347,8 +345,8 @@ namespace Cicm.Database
param5.DbType = DbType.Int32;
param6.DbType = DbType.Int32;
param7.DbType = DbType.Int32;
param8.DbType = DbType.Int32;
param9.DbType = DbType.String;
param8.DbType = DbType.String;
param9.DbType = DbType.Int32;
param10.DbType = DbType.Int32;
param11.DbType = DbType.Int32;
param12.DbType = DbType.Int32;
@@ -356,33 +354,31 @@ namespace Cicm.Database
param14.DbType = DbType.Int32;
param15.DbType = DbType.Int32;
param16.DbType = DbType.Int32;
param17.DbType = DbType.Int32;
param18.DbType = DbType.String;
param19.DbType = DbType.Int32;
param20.DbType = DbType.String;
param21.DbType = DbType.Int32;
param17.DbType = DbType.String;
param18.DbType = DbType.Int32;
param19.DbType = DbType.String;
param20.DbType = DbType.Int32;
param1.Value = entry.Company;
param2.Value = entry.Year;
param3.Value = entry.Model;
param4.Value = entry.Ram;
param5.Value = entry.Rom;
param6.Value = entry.Gpu;
param7.Value = entry.Vram;
param8.Value = entry.Colors;
param9.Value = entry.Resolution;
param10.Value = entry.SoundSynth;
param11.Value = entry.MusicSynth;
param12.Value = entry.SoundChannels;
param13.Value = entry.MusicChannels;
param14.Value = entry.Hdd1;
param15.Value = entry.Hdd2;
param16.Value = entry.Hdd3;
param17.Value = entry.Disk1;
param18.Value = entry.Cap1;
param19.Value = entry.Disk2;
param20.Value = entry.Cap2;
param21.Value = entry.Type;
param6.Value = entry.Vram;
param7.Value = entry.Colors;
param8.Value = entry.Resolution;
param9.Value = entry.SoundSynth;
param10.Value = entry.MusicSynth;
param11.Value = entry.SoundChannels;
param12.Value = entry.MusicChannels;
param13.Value = entry.Hdd1;
param14.Value = entry.Hdd2;
param15.Value = entry.Hdd3;
param16.Value = entry.Disk1;
param17.Value = entry.Cap1;
param18.Value = entry.Disk2;
param19.Value = entry.Cap2;
param20.Value = entry.Type;
dbcmd.Parameters.Add(param1);
dbcmd.Parameters.Add(param2);
@@ -404,7 +400,6 @@ namespace Cicm.Database
dbcmd.Parameters.Add(param18);
dbcmd.Parameters.Add(param19);
dbcmd.Parameters.Add(param20);
dbcmd.Parameters.Add(param21);
return dbcmd;
}
@@ -423,7 +418,6 @@ namespace Cicm.Database
Model = (string)dataRow["model"],
Ram = (int)dataRow["ram"],
Rom = (int)dataRow["rom"],
Gpu = dataRow["gpu"] == DBNull.Value ? 0 : (int)dataRow["gpu"],
Vram = (int)dataRow["vram"],
Colors = (int)dataRow["colors"],
Resolution = (string)dataRow["res"],

View File

@@ -35,7 +35,7 @@ namespace Cicm.Database
public partial class Operations
{
/// <summary>Last known database version</summary>
const int DB_VERSION = 15;
const int DB_VERSION = 16;
/// <summary>The column with this value indicates there is no item of this type.</summary>
public const int DB_NONE = -1;
/// <summary>This value indicates there's no GPU, but a direct memory->display connection (a framebuffer).</summary>

View File

@@ -144,6 +144,11 @@ namespace Cicm.Database
UpdateDatabaseToV15();
break;
}
case 15:
{
UpdateDatabaseToV16();
break;
}
}
OptimizeDatabase();
@@ -1687,6 +1692,84 @@ namespace Cicm.Database
dbCmd.Dispose();
}
void UpdateDatabaseToV16()
{
Console.WriteLine("Updating database to version 15");
Console.WriteLine("Creating table `gpus_by_machine`");
IDbCommand dbCmd = dbCon.CreateCommand();
IDbTransaction trans = dbCon.BeginTransaction();
dbCmd.Transaction = trans;
dbCmd.CommandText = V16.GpusByMachine;
dbCmd.ExecuteNonQuery();
trans.Commit();
dbCmd.Dispose();
Console.WriteLine("Getting all items from `machines`");
dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
dbCmd.CommandText = "SELECT * from machines";
DataSet dataSet = new DataSet();
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
foreach(DataRow dataRow in dataSet.Tables[0].Rows)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataParameter param1 = dbcmd.CreateParameter();
IDbDataParameter param2 = dbcmd.CreateParameter();
param1.ParameterName = "@machine";
param2.ParameterName = "@gpu";
param1.DbType = DbType.Int32;
param2.DbType = DbType.Int32;
param1.Value = (int)dataRow["id"];
const string SQL =
"INSERT INTO gpus_by_machine (machine, gpu) VALUES (@machine, @gpu)";
dbcmd.Parameters.Add(param1);
dbcmd.Parameters.Add(param2);
if(dataRow["gpu"] != DBNull.Value)
{
param2.Value = (int)dataRow["gpu"];
trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
Console.WriteLine("Adding gpu {0} to machine {1}", (int)param2.Value, (int)param1.Value);
dbcmd.CommandText = SQL;
dbcmd.ExecuteNonQuery();
trans.Commit();
}
dbcmd.Dispose();
}
Console.WriteLine("Removing processor columns from table `machines`");
dbCmd = dbCon.CreateCommand();
trans = dbCon.BeginTransaction();
dbCmd.Transaction = trans;
dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_gpu`;\n" +
"ALTER TABLE `machines` DROP COLUMN `gpu`;";
dbCmd.ExecuteNonQuery();
trans.Commit();
dbCmd.Dispose();
Console.WriteLine("Setting new database version to 16...");
dbCmd = dbCon.CreateCommand();
dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('16')";
dbCmd.ExecuteNonQuery();
dbCmd.Dispose();
}
void OptimizeDatabase()
{
IDbCommand dbCmd = dbCon.CreateCommand();

View File

@@ -0,0 +1,41 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Computer.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// High level representation of a computer.
//
// --[ 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>Computer</summary>
public class GpuByMachine
{
/// <summary>Machine ID</summary>
public int Machine;
/// <summary>GPU ID</summary>
public int Gpu;
}
}

View File

@@ -45,8 +45,6 @@ namespace Cicm.Database.Schemas
public int Disk1;
/// <summary>ID of second removable disk format</summary>
public int Disk2;
/// <summary>ID of GPU</summary>
public int Gpu;
/// <summary>ID of first hard disk format</summary>
public int Hdd1;
/// <summary>ID of second hard disk format</summary>

View File

@@ -0,0 +1,139 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : V16.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Contains SQL queries to create the database version 7.
//
// --[ 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 V16
{
public static readonly string Admins = V15.Admins;
public static readonly string BrowserTests = V15.BrowserTests;
public static readonly string CicmDb = "CREATE TABLE `cicm_db` (\n" +
"`id` int(11) NOT NULL AUTO_INCREMENT,\n" +
"`version` int(11) NOT NULL,\n" +
"`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" +
"PRIMARY KEY (`id`)\n" + ");\n" +
"INSERT INTO cicm_db (version) VALUES ('16');";
public static readonly string Companies = V15.Companies;
public static readonly string Machines = "CREATE TABLE `machines` (;\n" +
"`id` int(11) NOT NULL AUTO_INCREMENT,;\n" +
"`company` int(11) NOT NULL DEFAULT '0',;\n" +
"`year` int(11) NOT NULL DEFAULT '0',;\n" +
"`model` char(50) NOT NULL DEFAULT '',;\n" +
"`ram` int(11) NOT NULL DEFAULT '0',;\n" +
"`rom` int(11) NOT NULL DEFAULT '0',;\n" +
"`vram` int(11) NOT NULL DEFAULT '0',;\n" +
"`colors` int(11) NOT NULL DEFAULT '0',;\n" +
"`res` char(10) NOT NULL DEFAULT '',;\n" +
"`sound_synth` int(11) NOT NULL DEFAULT '0',;\n" +
"`music_synth` int(11) NOT NULL DEFAULT '0',;\n" +
"`sound_channels` int(11) NOT NULL DEFAULT '0',;\n" +
"`music_channels` int(11) NOT NULL DEFAULT '0',;\n" +
"`hdd1` int(11) NOT NULL DEFAULT '0',;\n" +
"`hdd2` int(11) DEFAULT NULL,;\n" +
"`hdd3` int(11) DEFAULT NULL,;\n" +
"`disk1` int(11) NOT NULL DEFAULT '0',;\n" +
"`cap1` char(25) NOT NULL DEFAULT '0',;\n" +
"`disk2` int(11) DEFAULT NULL,;\n" +
"`cap2` char(25) DEFAULT NULL,;\n" +
"`type` int(11) NOT NULL DEFAULT '0',;\n" +
"PRIMARY KEY (`id`),;\n" +
"KEY `idx_machines_company` (`company`),;\n" +
"KEY `idx_machines_year` (`year`),;\n" +
"KEY `idx_machines_model` (`model`),;\n" +
"KEY `idx_machines_ram` (`ram`),;\n" +
"KEY `idx_machines_rom` (`rom`),;\n" +
"KEY `idx_machines_vram` (`vram`),;\n" +
"KEY `idx_machines_colors` (`colors`),;\n" +
"KEY `idx_machines_res` (`res`),;\n" +
"KEY `idx_machines_sound_synth` (`sound_synth`),;\n" +
"KEY `idx_machines_music_synth` (`music_synth`),;\n" +
"KEY `idx_machines_hdd1` (`hdd1`),;\n" +
"KEY `idx_machines_hdd2` (`hdd2`),;\n" +
"KEY `idx_machines_hdd3` (`hdd3`),;\n" +
"KEY `idx_machines_disk1` (`disk1`),;\n" +
"KEY `idx_machines_disk2` (`disk2`),;\n" +
"KEY `idx_machines_cap1` (`cap1`),;\n" +
"KEY `idx_machines_cap2` (`cap2`),;\n" +
"KEY `idx_machines_type` (`type`));";
public static readonly string DiskFormats = V15.DiskFormats;
public static readonly string Forbidden = V15.Forbidden;
public static readonly string Gpus = V15.Gpus;
public static readonly string Logs = V15.Logs;
public static readonly string MoneyDonations = V15.MoneyDonations;
public static readonly string News = V15.News;
public static readonly string OwnedComputers = V15.OwnedComputers;
public static readonly string OwnedConsoles = V15.OwnedConsoles;
public static readonly string Processors = V15.Processors;
public static readonly string SoundSynths = V15.SoundSynths;
public static readonly string MachinesForeignKeys = V15.MachinesForeignKeys;
public static readonly string Iso3166Numeric = V15.Iso3166Numeric;
public static readonly string Iso3166NumericValues = V15.Iso3166NumericValues;
public static readonly string CompaniesForeignKeys = V15.CompaniesForeignKeys;
public static readonly string CompanyLogos = V15.CompanyLogos;
public static readonly string CompanyDescriptions = V15.CompanyDescriptions;
public static readonly string InstructionSets = V15.InstructionSets;
public static readonly string InstructionSetExtensions = V15.InstructionSetExtensions;
public static readonly string InstructionSetExtensionsByProcessor = V15.InstructionSetExtensionsByProcessor;
public static readonly string ProcessorsByMachine = V15.ProcessorsByMachine;
public static readonly string GpusByMachine =
"CREATE TABLE `gpus_by_machine` (\n" +
"`gpu` INT NOT NULL, \n" +
"`machine` INT NOT NULL,\n" +
"KEY `idx_gpus_by_machine_gpus` (`gpu`),\n" +
"KEY `idx_gpus_by_machine_machine` (`machine`),\n" +
"CONSTRAINT `fk_gpus_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" +
"CONSTRAINT `fk_gpus_by_machine_gpu` FOREIGN KEY (`gpu`) REFERENCES `gpus` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);";
}
}

View File

@@ -0,0 +1,57 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : GpuByMachine.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Gpu by machine 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.Collections.Generic;
namespace cicm_web.Models
{
public class GpuByMachine
{
public Gpu Gpu;
public static GpuByMachine[] GetAllItems(int machineId)
{
List<Cicm.Database.Schemas.GpuByMachine> dbItems = null;
bool? result =
Program.Database?.Operations.GetGpusByMachines(out dbItems, machineId);
if(result == null || result.Value == false || dbItems == null) return null;
List<GpuByMachine> items = new List<GpuByMachine>();
foreach(Cicm.Database.Schemas.GpuByMachine dbItem in dbItems)
items.Add(new GpuByMachine
{
Gpu = Gpu.GetItem(dbItem.Gpu)
});
return items.ToArray();
}
}
}

View File

@@ -43,7 +43,7 @@ namespace cicm_web.Models
public Company Company;
public DiskFormat Disk1;
public DiskFormat Disk2;
public Gpu Gpu;
public GpuByMachine[] Gpus;
public DiskFormat Hdd1;
public DiskFormat Hdd2;
public DiskFormat Hdd3;
@@ -94,7 +94,7 @@ namespace cicm_web.Models
{
Colors = dbItem.Colors,
Company = Company.GetItem(dbItem.Company),
Gpu = Gpu.GetItem(dbItem.Gpu),
Gpus = GpuByMachine.GetAllItems(dbItem.Id),
Hdd1 = DiskFormat.GetItem(dbItem.Hdd1),
Hdd2 = DiskFormat.GetItem(dbItem.Hdd2),
Hdd3 = DiskFormat.GetItem(dbItem.Hdd3),

View File

@@ -387,30 +387,33 @@
}
}
</tr>
@if(Model.Gpu == null || Model.Gpu != null && Model.Gpu.Id != -1)
@if(Model.Gpus != null && Model.Gpus.Length > 0)
{
<tr>
<th scope=row>
<div align=right>
Graphics processor
Graphics processing units
</div>
</th>
@if(Model.Gpu != null)
<td>
<table>
@for(int i = 0; i < Model.Gpus.Length; i++)
{
if(Model.Gpu.Id == -2)
if(Model.Gpus[i] != null)
{
if(Model.Gpus[i].Gpu.Id == -2)
{
<td>
Framebuffer
<a aria-controls="gpuInfo"
<a aria-controls="@($"gpuInfo{i}")"
aria-expanded="false"
class="btn btn-link"
data-toggle="collapse"
href="#gpuInfo">
href="@($"#gpuInfo{i}")">
+info
</a>
<div class="collapse"
id="gpuInfo">
id="@($"gpuInfo{i}")">
<div class="card card-body">
This computer directly draws pixels from software to a memory region that's converted to video output by a <abbr title="Digital to Analog Converter">DAC</abbr> or similar without using any specific graphics processing unit.
</div>
@@ -420,7 +423,7 @@
else
{
<td>
@($"{Model.Gpu.Name}")
@($"{Model.Gpus[i].Gpu.Name}")
<a aria-controls="gpuInfo"
aria-expanded="false"
class="btn btn-link"
@@ -432,11 +435,11 @@
id="gpuInfo">
<div class="card card-body">
<table>
@if(Model.Gpu.ModelCode != null && Model.Gpu.ModelCode != Model.Gpu.Name)
@if(Model.Gpus[i].Gpu.ModelCode != null && Model.Gpus[i].Gpu.ModelCode != Model.Gpus[i].Gpu.Name)
{
<tr>
<td>Model</td>
<td>@Model.Gpu.ModelCode</td>
<td>@Model.Gpus[i].Gpu.ModelCode</td>
</tr>
}
<tr>
@@ -444,53 +447,53 @@
<td>
<a asp-controller=Company
asp-action=View
asp-route-id=@Model.Gpu.Company.Id>
@Model.Gpu.Company.Name</a>
asp-route-id=@Model.Gpus[i].Gpu.Company.Id>
@Model.Gpus[i].Gpu.Company.Name</a>
</td>
</tr>
@if(Model.Gpu.Introduced != DateTime.MinValue)
@if(Model.Gpus[i].Gpu.Introduced != DateTime.MinValue)
{
<tr>
<td>Introduction date</td>
<td>@($"{Model.Gpu.Introduced:yyyy}")</td>
<td>@($"{Model.Gpus[i].Gpu.Introduced:yyyy}")</td>
</tr>
}
@if(Model.Gpu.Package != null)
@if(Model.Gpus[i].Gpu.Package != null)
{
<tr>
<td>Package</td>
<td>@Model.Gpu.Package</td>
<td>@Model.Gpus[i].Gpu.Package</td>
</tr>
}
@if(Model.Gpu.Process != null || Model.Gpu.ProcessNm > 0)
@if(Model.Gpus[i].Gpu.Process != null || Model.Gpus[i].Gpu.ProcessNm > 0)
{
<tr>
<td>Manufacturing process</td>
<td>
@if(Model.Gpu.Process != null && Model.Gpu.ProcessNm > 0)
@if(Model.Gpus[i].Gpu.Process != null && Model.Gpus[i].Gpu.ProcessNm > 0)
{
@Model.Gpu.Process
@Model.Gpus[i].Gpu.Process
@("@")
@(Model.Gpu.ProcessNm > 100 ? $"{Model.Gpu.ProcessNm / 100}µm" : $"{Model.Gpu.ProcessNm}nm")
@(Model.Gpus[i].Gpu.ProcessNm > 100 ? $"{Model.Gpus[i].Gpu.ProcessNm / 100}µm" : $"{Model.Gpus[i].Gpu.ProcessNm}nm")
}
else if(Model.Gpu.ProcessNm > 0) { @(Model.Gpu.ProcessNm > 100 ? $"{Model.Gpu.ProcessNm / 100}µm" : $"{Model.Gpu.ProcessNm}nm") }
else if(Model.Gpus[i].Gpu.ProcessNm > 0) { @(Model.Gpus[i].Gpu.ProcessNm > 100 ? $"{Model.Gpus[i].Gpu.ProcessNm / 100}µm" : $"{Model.Gpus[i].Gpu.ProcessNm}nm") }
else
{ @Model.Gpu.Process }
{ @Model.Gpus[i].Gpu.Process }
</td>
</tr>
}
@if(Model.Gpu.DieSize > 0)
@if(Model.Gpus[i].Gpu.DieSize > 0)
{
<tr>
<td>Die size</td>
<td>@Model.Gpu.DieSize mm&sup2;</td>
<td>@Model.Gpus[i].Gpu.DieSize mm&sup2;</td>
</tr>
}
@if(Model.Gpu.Transistors > 0)
@if(Model.Gpus[i].Gpu.Transistors > 0)
{
<tr>
<td>Transistors</td>
<td>@Model.Gpu.Transistors</td>
<td>@Model.Gpus[i].Gpu.Transistors</td>
</tr>
}
</table>
@@ -503,6 +506,9 @@
{
<td>Unknown data</td>
}
}
</table>
</td>
</tr>
}
<tr>

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<Version>3.0.99.206</Version>
<Version>3.0.99.207</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>