mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Update DB to version 17: Machines can have an arbitrary number of sound synthetizers,
so use an interconnection table, `sound_by_machine`.
This commit is contained in:
@@ -49,107 +49,111 @@ namespace Cicm.Database
|
|||||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `admins`");
|
Console.WriteLine("Creating table `admins`");
|
||||||
dbCmd.CommandText = V16.Admins;
|
dbCmd.CommandText = V17.Admins;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `browser_tests`");
|
Console.WriteLine("Creating table `browser_tests`");
|
||||||
dbCmd.CommandText = V16.BrowserTests;
|
dbCmd.CommandText = V17.BrowserTests;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `cicm_db`");
|
Console.WriteLine("Creating table `cicm_db`");
|
||||||
dbCmd.CommandText = V16.CicmDb;
|
dbCmd.CommandText = V17.CicmDb;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `companies`");
|
Console.WriteLine("Creating table `companies`");
|
||||||
dbCmd.CommandText = V16.Companies;
|
dbCmd.CommandText = V17.Companies;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `machines`");
|
Console.WriteLine("Creating table `machines`");
|
||||||
dbCmd.CommandText = V16.Machines;
|
dbCmd.CommandText = V17.Machines;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `disk_formats`");
|
Console.WriteLine("Creating table `disk_formats`");
|
||||||
dbCmd.CommandText = V16.DiskFormats;
|
dbCmd.CommandText = V17.DiskFormats;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `forbidden`");
|
Console.WriteLine("Creating table `forbidden`");
|
||||||
dbCmd.CommandText = V16.Forbidden;
|
dbCmd.CommandText = V17.Forbidden;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `gpus`");
|
Console.WriteLine("Creating table `gpus`");
|
||||||
dbCmd.CommandText = V16.Gpus;
|
dbCmd.CommandText = V17.Gpus;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `log`");
|
Console.WriteLine("Creating table `log`");
|
||||||
dbCmd.CommandText = V16.Logs;
|
dbCmd.CommandText = V17.Logs;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `money_donations`");
|
Console.WriteLine("Creating table `money_donations`");
|
||||||
dbCmd.CommandText = V16.MoneyDonations;
|
dbCmd.CommandText = V17.MoneyDonations;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `news`");
|
Console.WriteLine("Creating table `news`");
|
||||||
dbCmd.CommandText = V16.News;
|
dbCmd.CommandText = V17.News;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `owned_computers`");
|
Console.WriteLine("Creating table `owned_computers`");
|
||||||
dbCmd.CommandText = V16.OwnedComputers;
|
dbCmd.CommandText = V17.OwnedComputers;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `owned_consoles`");
|
Console.WriteLine("Creating table `owned_consoles`");
|
||||||
dbCmd.CommandText = V16.OwnedConsoles;
|
dbCmd.CommandText = V17.OwnedConsoles;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `instruction_sets`");
|
Console.WriteLine("Creating table `instruction_sets`");
|
||||||
dbCmd.CommandText = V16.InstructionSets;
|
dbCmd.CommandText = V17.InstructionSets;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `instruction_set_extensions`");
|
Console.WriteLine("Creating table `instruction_set_extensions`");
|
||||||
dbCmd.CommandText = V16.InstructionSetExtensions;
|
dbCmd.CommandText = V17.InstructionSetExtensions;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `processors`");
|
Console.WriteLine("Creating table `processors`");
|
||||||
dbCmd.CommandText = V16.Processors;
|
dbCmd.CommandText = V17.Processors;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `instruction_set_extensions_by_processor`");
|
Console.WriteLine("Creating table `instruction_set_extensions_by_processor`");
|
||||||
dbCmd.CommandText = V16.InstructionSetExtensionsByProcessor;
|
dbCmd.CommandText = V17.InstructionSetExtensionsByProcessor;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `sound_synths`");
|
Console.WriteLine("Creating table `sound_synths`");
|
||||||
dbCmd.CommandText = V16.SoundSynths;
|
dbCmd.CommandText = V17.SoundSynths;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `iso3166_1_numeric`");
|
Console.WriteLine("Creating table `iso3166_1_numeric`");
|
||||||
dbCmd.CommandText = V16.Iso3166Numeric;
|
dbCmd.CommandText = V17.Iso3166Numeric;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Filling table `iso3166_1_numeric`");
|
Console.WriteLine("Filling table `iso3166_1_numeric`");
|
||||||
dbCmd.CommandText = V16.Iso3166NumericValues;
|
dbCmd.CommandText = V17.Iso3166NumericValues;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating foreign keys for table `companies`");
|
Console.WriteLine("Creating foreign keys for table `companies`");
|
||||||
dbCmd.CommandText = V16.CompaniesForeignKeys;
|
dbCmd.CommandText = V17.CompaniesForeignKeys;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating foreign keys for table `machines`");
|
Console.WriteLine("Creating foreign keys for table `machines`");
|
||||||
dbCmd.CommandText = V16.MachinesForeignKeys;
|
dbCmd.CommandText = V17.MachinesForeignKeys;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `company_logos`");
|
Console.WriteLine("Creating table `company_logos`");
|
||||||
dbCmd.CommandText = V16.CompanyLogos;
|
dbCmd.CommandText = V17.CompanyLogos;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `company_descriptions`");
|
Console.WriteLine("Creating table `company_descriptions`");
|
||||||
dbCmd.CommandText = V16.CompanyDescriptions;
|
dbCmd.CommandText = V17.CompanyDescriptions;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `processors_by_machine`");
|
Console.WriteLine("Creating table `processors_by_machine`");
|
||||||
dbCmd.CommandText = V16.ProcessorsByMachine;
|
dbCmd.CommandText = V17.ProcessorsByMachine;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `gpus_by_machine`");
|
Console.WriteLine("Creating table `gpus_by_machine`");
|
||||||
dbCmd.CommandText = V16.GpusByMachine;
|
dbCmd.CommandText = V17.GpusByMachine;
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("Creating table `sound_by_machine`");
|
||||||
|
dbCmd.CommandText = V17.SoundByMachine;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -214,10 +214,9 @@ namespace Cicm.Database
|
|||||||
dbcmd.Transaction = trans;
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
const string SQL =
|
const string SQL =
|
||||||
"INSERT INTO machines (company, year, model, ram, rom, vram, colors, res, sound_synth, music_synth, " +
|
"INSERT INTO machines (company, year, model, ram, rom, vram, colors, res, hdd1, hdd2, hdd3, disk1, " +
|
||||||
"sound_channels, music_channels, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2, type)" +
|
"cap1, disk2, cap2, type) VALUES (@company, @year, @model, @ram, @rom, @vram, @colors, @res, @hdd1, " +
|
||||||
" VALUES (@company, @year, @model, @ram, @rom, @vram, @colors, @res, @sound_synth, @music_synth, " +
|
"@hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2, @type)";
|
||||||
"@sound_channels, @music_channels, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2, @type)";
|
|
||||||
|
|
||||||
dbcmd.CommandText = SQL;
|
dbcmd.CommandText = SQL;
|
||||||
|
|
||||||
@@ -251,10 +250,8 @@ namespace Cicm.Database
|
|||||||
|
|
||||||
string sql =
|
string sql =
|
||||||
"UPDATE machines SET company = @company, year = @year, model = @model, ram = @ram, rom = @rom, " +
|
"UPDATE machines SET company = @company, year = @year, model = @model, ram = @ram, rom = @rom, " +
|
||||||
"vram = @vram, colors = @colors, res = @res, sound_synth = @sound_synth, " +
|
"vram = @vram, colors = @colors, res = @res, hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, " +
|
||||||
"music_synth = @music_synth, sound_channels = @sound_channels, music_channels = @music_channels, " +
|
"cap1 = @cap1, disk2 = @disk2, cap2 = @cap2, type = @type " +
|
||||||
"hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2, " +
|
|
||||||
"type = @type " +
|
|
||||||
$"WHERE id = {entry.Id}";
|
$"WHERE id = {entry.Id}";
|
||||||
|
|
||||||
dbcmd.CommandText = sql;
|
dbcmd.CommandText = sql;
|
||||||
@@ -304,7 +301,7 @@ namespace Cicm.Database
|
|||||||
IDbDataParameter param6 = dbcmd.CreateParameter();
|
IDbDataParameter param6 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param7 = dbcmd.CreateParameter();
|
IDbDataParameter param7 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param8 = dbcmd.CreateParameter();
|
IDbDataParameter param8 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param9 = dbcmd.CreateParameter();
|
IDbDataParameter param9 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param10 = dbcmd.CreateParameter();
|
IDbDataParameter param10 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param11 = dbcmd.CreateParameter();
|
IDbDataParameter param11 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param12 = dbcmd.CreateParameter();
|
IDbDataParameter param12 = dbcmd.CreateParameter();
|
||||||
@@ -312,10 +309,6 @@ namespace Cicm.Database
|
|||||||
IDbDataParameter param14 = dbcmd.CreateParameter();
|
IDbDataParameter param14 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param15 = dbcmd.CreateParameter();
|
IDbDataParameter param15 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param16 = dbcmd.CreateParameter();
|
IDbDataParameter param16 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param17 = dbcmd.CreateParameter();
|
|
||||||
IDbDataParameter param18 = dbcmd.CreateParameter();
|
|
||||||
IDbDataParameter param19 = dbcmd.CreateParameter();
|
|
||||||
IDbDataParameter param20 = dbcmd.CreateParameter();
|
|
||||||
|
|
||||||
param1.ParameterName = "@company";
|
param1.ParameterName = "@company";
|
||||||
param2.ParameterName = "@year";
|
param2.ParameterName = "@year";
|
||||||
@@ -325,18 +318,14 @@ namespace Cicm.Database
|
|||||||
param6.ParameterName = "@vram";
|
param6.ParameterName = "@vram";
|
||||||
param7.ParameterName = "@colors";
|
param7.ParameterName = "@colors";
|
||||||
param8.ParameterName = "@res";
|
param8.ParameterName = "@res";
|
||||||
param9.ParameterName = "@sound_synth";
|
param9.ParameterName = "@hdd1";
|
||||||
param10.ParameterName = "@music_synth";
|
param10.ParameterName = "@hdd2";
|
||||||
param11.ParameterName = "@sound_channels";
|
param11.ParameterName = "@hdd3";
|
||||||
param12.ParameterName = "@music_channels";
|
param12.ParameterName = "@disk1";
|
||||||
param13.ParameterName = "@hdd1";
|
param13.ParameterName = "@cap1";
|
||||||
param14.ParameterName = "@hdd2";
|
param14.ParameterName = "@disk2";
|
||||||
param15.ParameterName = "@hdd3";
|
param15.ParameterName = "@cap2";
|
||||||
param16.ParameterName = "@disk1";
|
param16.ParameterName = "@type";
|
||||||
param17.ParameterName = "@cap1";
|
|
||||||
param18.ParameterName = "@disk2";
|
|
||||||
param19.ParameterName = "@cap2";
|
|
||||||
param20.ParameterName = "@type";
|
|
||||||
|
|
||||||
param1.DbType = DbType.Int32;
|
param1.DbType = DbType.Int32;
|
||||||
param2.DbType = DbType.Int32;
|
param2.DbType = DbType.Int32;
|
||||||
@@ -346,18 +335,14 @@ namespace Cicm.Database
|
|||||||
param6.DbType = DbType.Int32;
|
param6.DbType = DbType.Int32;
|
||||||
param7.DbType = DbType.Int32;
|
param7.DbType = DbType.Int32;
|
||||||
param8.DbType = DbType.String;
|
param8.DbType = DbType.String;
|
||||||
param9.DbType = DbType.Int32;
|
param9.DbType = DbType.Int32;
|
||||||
param10.DbType = DbType.Int32;
|
param10.DbType = DbType.Int32;
|
||||||
param11.DbType = DbType.Int32;
|
param11.DbType = DbType.Int32;
|
||||||
param12.DbType = DbType.Int32;
|
param12.DbType = DbType.Int32;
|
||||||
param13.DbType = DbType.Int32;
|
param13.DbType = DbType.String;
|
||||||
param14.DbType = DbType.Int32;
|
param14.DbType = DbType.Int32;
|
||||||
param15.DbType = DbType.Int32;
|
param15.DbType = DbType.String;
|
||||||
param16.DbType = DbType.Int32;
|
param16.DbType = DbType.Int32;
|
||||||
param17.DbType = DbType.String;
|
|
||||||
param18.DbType = DbType.Int32;
|
|
||||||
param19.DbType = DbType.String;
|
|
||||||
param20.DbType = DbType.Int32;
|
|
||||||
|
|
||||||
param1.Value = entry.Company;
|
param1.Value = entry.Company;
|
||||||
param2.Value = entry.Year;
|
param2.Value = entry.Year;
|
||||||
@@ -367,18 +352,14 @@ namespace Cicm.Database
|
|||||||
param6.Value = entry.Vram;
|
param6.Value = entry.Vram;
|
||||||
param7.Value = entry.Colors;
|
param7.Value = entry.Colors;
|
||||||
param8.Value = entry.Resolution;
|
param8.Value = entry.Resolution;
|
||||||
param9.Value = entry.SoundSynth;
|
param9.Value = entry.Hdd1;
|
||||||
param10.Value = entry.MusicSynth;
|
param10.Value = entry.Hdd2;
|
||||||
param11.Value = entry.SoundChannels;
|
param11.Value = entry.Hdd3;
|
||||||
param12.Value = entry.MusicChannels;
|
param12.Value = entry.Disk1;
|
||||||
param13.Value = entry.Hdd1;
|
param13.Value = entry.Cap1;
|
||||||
param14.Value = entry.Hdd2;
|
param14.Value = entry.Disk2;
|
||||||
param15.Value = entry.Hdd3;
|
param15.Value = entry.Cap2;
|
||||||
param16.Value = entry.Disk1;
|
param16.Value = entry.Type;
|
||||||
param17.Value = entry.Cap1;
|
|
||||||
param18.Value = entry.Disk2;
|
|
||||||
param19.Value = entry.Cap2;
|
|
||||||
param20.Value = entry.Type;
|
|
||||||
|
|
||||||
dbcmd.Parameters.Add(param1);
|
dbcmd.Parameters.Add(param1);
|
||||||
dbcmd.Parameters.Add(param2);
|
dbcmd.Parameters.Add(param2);
|
||||||
@@ -396,10 +377,6 @@ namespace Cicm.Database
|
|||||||
dbcmd.Parameters.Add(param14);
|
dbcmd.Parameters.Add(param14);
|
||||||
dbcmd.Parameters.Add(param15);
|
dbcmd.Parameters.Add(param15);
|
||||||
dbcmd.Parameters.Add(param16);
|
dbcmd.Parameters.Add(param16);
|
||||||
dbcmd.Parameters.Add(param17);
|
|
||||||
dbcmd.Parameters.Add(param18);
|
|
||||||
dbcmd.Parameters.Add(param19);
|
|
||||||
dbcmd.Parameters.Add(param20);
|
|
||||||
|
|
||||||
return dbcmd;
|
return dbcmd;
|
||||||
}
|
}
|
||||||
@@ -412,27 +389,23 @@ namespace Cicm.Database
|
|||||||
{
|
{
|
||||||
Machine entry = new Machine
|
Machine entry = new Machine
|
||||||
{
|
{
|
||||||
Id = (int)dataRow["id"],
|
Id = (int)dataRow["id"],
|
||||||
Company = (int)dataRow["company"],
|
Company = (int)dataRow["company"],
|
||||||
Year = (int)dataRow["year"],
|
Year = (int)dataRow["year"],
|
||||||
Model = (string)dataRow["model"],
|
Model = (string)dataRow["model"],
|
||||||
Ram = (int)dataRow["ram"],
|
Ram = (int)dataRow["ram"],
|
||||||
Rom = (int)dataRow["rom"],
|
Rom = (int)dataRow["rom"],
|
||||||
Vram = (int)dataRow["vram"],
|
Vram = (int)dataRow["vram"],
|
||||||
Colors = (int)dataRow["colors"],
|
Colors = (int)dataRow["colors"],
|
||||||
Resolution = (string)dataRow["res"],
|
Resolution = (string)dataRow["res"],
|
||||||
SoundSynth = (int)dataRow["sound_synth"],
|
Hdd1 = (int)dataRow["hdd1"],
|
||||||
MusicSynth = (int)dataRow["music_synth"],
|
Hdd2 = dataRow["hdd2"] == DBNull.Value ? 0 : (int)dataRow["hdd2"],
|
||||||
SoundChannels = (int)dataRow["sound_channels"],
|
Hdd3 = dataRow["hdd3"] == DBNull.Value ? 0 : (int)dataRow["hdd3"],
|
||||||
MusicChannels = (int)dataRow["music_channels"],
|
Disk1 = (int)dataRow["disk1"],
|
||||||
Hdd1 = (int)dataRow["hdd1"],
|
Cap1 = (string)dataRow["cap1"],
|
||||||
Hdd2 = dataRow["hdd2"] == DBNull.Value ? 0 : (int)dataRow["hdd2"],
|
Disk2 = dataRow["disk2"] == DBNull.Value ? 0 : (int)dataRow["disk2"],
|
||||||
Hdd3 = dataRow["hdd3"] == DBNull.Value ? 0 : (int)dataRow["hdd3"],
|
Cap2 = dataRow["cap2"] == DBNull.Value ? null : (string)dataRow["cap2"],
|
||||||
Disk1 = (int)dataRow["disk1"],
|
Type = (MachineType)dataRow["type"]
|
||||||
Cap1 = (string)dataRow["cap1"],
|
|
||||||
Disk2 = dataRow["disk2"] == DBNull.Value ? 0 : (int)dataRow["disk2"],
|
|
||||||
Cap2 = dataRow["cap2"] == DBNull.Value ? null : (string)dataRow["cap2"],
|
|
||||||
Type = (MachineType)dataRow["type"]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
entries.Add(entry);
|
entries.Add(entry);
|
||||||
|
|||||||
@@ -35,11 +35,14 @@ namespace Cicm.Database
|
|||||||
public partial class Operations
|
public partial class Operations
|
||||||
{
|
{
|
||||||
/// <summary>Last known database version</summary>
|
/// <summary>Last known database version</summary>
|
||||||
const int DB_VERSION = 16;
|
const int DB_VERSION = 17;
|
||||||
/// <summary>The column with this value indicates there is no item of this type.</summary>
|
/// <summary>The column with this value indicates there is no item of this type.</summary>
|
||||||
public const int DB_NONE = -1;
|
public const int DB_NONE = -1;
|
||||||
/// <summary>This value indicates there's no GPU, but a direct memory->display connection (a framebuffer).</summary>
|
/// <summary>
|
||||||
public const int DB_FRAMEBUFFER = -2;
|
/// This value indicates there's no processing unit, but a direct memory connection (a framebuffer or sound
|
||||||
|
/// buffer).
|
||||||
|
/// </summary>
|
||||||
|
public const int DB_SOFTWARE = -2;
|
||||||
|
|
||||||
readonly IDbConnection dbCon;
|
readonly IDbConnection dbCon;
|
||||||
readonly IDbCore dbCore;
|
readonly IDbCore dbCore;
|
||||||
|
|||||||
149
Cicm.Database/Operations/SoundByMachine.cs
Normal file
149
Cicm.Database/Operations/SoundByMachine.cs
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : SoundByMachine.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Contains operations to manage sound.
|
||||||
|
//
|
||||||
|
// --[ 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 sound 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 GetSoundsByMachines(out List<SoundByMachine> entries, int machineId)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting all sound synths for machine {0}...", machineId);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * FROM sound_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 = SoundByMachinesFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting sound 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 GetMachinesBySound(out List<SoundByMachine> entries, int gpuId)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting all machines with sound synth {0}...", gpuId);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * FROM sound_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 = SoundByMachinesFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting machines by sound synth.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
entries = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IDbCommand GetCommandSoundByMachine(SoundByMachine entry)
|
||||||
|
{
|
||||||
|
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||||
|
|
||||||
|
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param2 = dbcmd.CreateParameter();
|
||||||
|
|
||||||
|
param1.ParameterName = "@sound_synth";
|
||||||
|
param2.ParameterName = "@machine";
|
||||||
|
|
||||||
|
param1.DbType = DbType.Int32;
|
||||||
|
param2.DbType = DbType.Int32;
|
||||||
|
|
||||||
|
param1.Value = entry.SoundSynth;
|
||||||
|
param2.Value = entry.Machine;
|
||||||
|
|
||||||
|
dbcmd.Parameters.Add(param1);
|
||||||
|
|
||||||
|
return dbcmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<SoundByMachine> SoundByMachinesFromDataTable(DataTable dataTable)
|
||||||
|
{
|
||||||
|
List<SoundByMachine> entries = new List<SoundByMachine>();
|
||||||
|
|
||||||
|
foreach(DataRow dataRow in dataTable.Rows)
|
||||||
|
{
|
||||||
|
SoundByMachine entry = new SoundByMachine
|
||||||
|
{
|
||||||
|
Machine = (int)dataRow["machine"],
|
||||||
|
SoundSynth = (int)dataRow["sound_synth"]
|
||||||
|
};
|
||||||
|
|
||||||
|
entries.Add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using Cicm.Database.Schemas;
|
using Cicm.Database.Schemas;
|
||||||
using Console = System.Console;
|
|
||||||
|
|
||||||
namespace Cicm.Database
|
namespace Cicm.Database
|
||||||
{
|
{
|
||||||
@@ -178,7 +177,9 @@ namespace Cicm.Database
|
|||||||
IDbTransaction trans = dbCon.BeginTransaction();
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
dbcmd.Transaction = trans;
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
const string SQL = "INSERT INTO sound_synths (name)" + " VALUES (@name)";
|
const string SQL = "INSERT INTO sound_synths (name, company, model_code, introduced, voices, frequency, " +
|
||||||
|
"depth, square_wave, white_noise, type) VALUES (@name, @company, @model_code, " +
|
||||||
|
"@introduced, @voices, @frequency, @depth, @square_wave, @white_noise, @type)";
|
||||||
|
|
||||||
dbcmd.CommandText = SQL;
|
dbcmd.CommandText = SQL;
|
||||||
|
|
||||||
@@ -210,7 +211,10 @@ namespace Cicm.Database
|
|||||||
IDbTransaction trans = dbCon.BeginTransaction();
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
dbcmd.Transaction = trans;
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
string sql = "UPDATE sound_synths SET name = @name " + $"WHERE id = {entry.Id}";
|
string sql = "UPDATE sound_synths SET name = @name, company = @company, model_code = @model_code, " +
|
||||||
|
"introduced = @introduced, voices = @voices, frequency = @frequency, depth = @depth, " +
|
||||||
|
"square_wave = @square_wave, white_noise = @white_noise, type = @type, " +
|
||||||
|
$"WHERE id = {entry.Id}";
|
||||||
|
|
||||||
dbcmd.CommandText = sql;
|
dbcmd.CommandText = sql;
|
||||||
|
|
||||||
@@ -251,26 +255,86 @@ namespace Cicm.Database
|
|||||||
{
|
{
|
||||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||||
|
|
||||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param2 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param3 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param4 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param5 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param6 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param7 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param8 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param9 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param10 = dbcmd.CreateParameter();
|
||||||
|
|
||||||
param1.ParameterName = "@name";
|
param1.ParameterName = "@name";
|
||||||
|
param2.ParameterName = "@company";
|
||||||
|
param3.ParameterName = "@model_code";
|
||||||
|
param4.ParameterName = "@introduced";
|
||||||
|
param5.ParameterName = "@voices";
|
||||||
|
param6.ParameterName = "@frequency";
|
||||||
|
param7.ParameterName = "@depth";
|
||||||
|
param8.ParameterName = "@square_wave";
|
||||||
|
param9.ParameterName = "@white_noise";
|
||||||
|
param10.ParameterName = "@type";
|
||||||
|
|
||||||
param1.DbType = DbType.String;
|
param1.DbType = DbType.String;
|
||||||
|
param2.DbType = DbType.Int32;
|
||||||
|
param3.DbType = DbType.String;
|
||||||
|
param4.DbType = DbType.DateTime;
|
||||||
|
param5.DbType = DbType.Int32;
|
||||||
|
param6.DbType = DbType.Double;
|
||||||
|
param7.DbType = DbType.Int32;
|
||||||
|
param8.DbType = DbType.Int32;
|
||||||
|
param9.DbType = DbType.Int32;
|
||||||
|
param10.DbType = DbType.Int32;
|
||||||
|
|
||||||
param1.Value = entry.Name;
|
param1.Value = entry.Name;
|
||||||
|
param2.Value = entry.Company?.Id;
|
||||||
|
param3.Value = entry.ModelCode;
|
||||||
|
param4.Value = entry.Introduced == DateTime.MinValue ? (object)null : entry.Introduced;
|
||||||
|
param5.Value = entry.Voices == 0 ? (object)null : entry.Voices;
|
||||||
|
param6.Value = entry.Frequency <= 0 ? (object)null : entry.Frequency;
|
||||||
|
param7.Value = entry.Depth == 0 ? (object)null : entry.Depth;
|
||||||
|
param8.Value = entry.SquareWave == 0 ? (object)null : entry.SquareWave;
|
||||||
|
param9.Value = entry.WhiteNoise == 0 ? (object)null : entry.WhiteNoise;
|
||||||
|
param10.Value = entry.Type == 0 ? (object)null : entry.Type;
|
||||||
|
|
||||||
dbcmd.Parameters.Add(param1);
|
dbcmd.Parameters.Add(param1);
|
||||||
|
dbcmd.Parameters.Add(param2);
|
||||||
|
dbcmd.Parameters.Add(param3);
|
||||||
|
dbcmd.Parameters.Add(param4);
|
||||||
|
dbcmd.Parameters.Add(param5);
|
||||||
|
dbcmd.Parameters.Add(param6);
|
||||||
|
dbcmd.Parameters.Add(param7);
|
||||||
|
dbcmd.Parameters.Add(param8);
|
||||||
|
dbcmd.Parameters.Add(param9);
|
||||||
|
dbcmd.Parameters.Add(param10);
|
||||||
|
|
||||||
return dbcmd;
|
return dbcmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SoundSynth> SoundSynthFromDataTable(DataTable dataTable)
|
List<SoundSynth> SoundSynthFromDataTable(DataTable dataTable)
|
||||||
{
|
{
|
||||||
List<SoundSynth> entries = new List<SoundSynth>();
|
List<SoundSynth> entries = new List<SoundSynth>();
|
||||||
|
|
||||||
foreach(DataRow dataRow in dataTable.Rows)
|
foreach(DataRow dataRow in dataTable.Rows)
|
||||||
{
|
{
|
||||||
SoundSynth entry = new SoundSynth {Id = (int)dataRow["id"], Name = (string)dataRow["name"]};
|
SoundSynth entry = new SoundSynth
|
||||||
|
{
|
||||||
|
Id = (int)dataRow["id"],
|
||||||
|
Name = (string)dataRow["name"],
|
||||||
|
ModelCode = dataRow["model_code"] == DBNull.Value ? null : (string)dataRow["model_code"],
|
||||||
|
Voices = dataRow["voices"] == DBNull.Value ? 0 : (int)dataRow["voices"],
|
||||||
|
Frequency = dataRow["frequency"] == DBNull.Value ? 0 : (double)dataRow["frequency"],
|
||||||
|
Depth = dataRow["depth"] == DBNull.Value ? 0 : (int)dataRow["depth"],
|
||||||
|
SquareWave = dataRow["square_wave"] == DBNull.Value ? 0 : (int)dataRow["square_wave"],
|
||||||
|
WhiteNoise = dataRow["white_noise"] == DBNull.Value ? 0 : (int)dataRow["white_noise"],
|
||||||
|
Type = dataRow["type"] == DBNull.Value ? 0 : (int)dataRow["type"],
|
||||||
|
Company = dataRow["company"] == DBNull.Value ? null : GetCompany((int)dataRow["company"]),
|
||||||
|
Introduced = dataRow["introduced"] == DBNull.Value
|
||||||
|
? DateTime.MinValue
|
||||||
|
: Convert.ToDateTime(dataRow["introduced"])
|
||||||
|
};
|
||||||
|
|
||||||
entries.Add(entry);
|
entries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,6 +149,11 @@ namespace Cicm.Database
|
|||||||
UpdateDatabaseToV16();
|
UpdateDatabaseToV16();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 16:
|
||||||
|
{
|
||||||
|
UpdateDatabaseToV17();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OptimizeDatabase();
|
OptimizeDatabase();
|
||||||
@@ -1063,7 +1068,7 @@ namespace Cicm.Database
|
|||||||
trans = dbCon.BeginTransaction();
|
trans = dbCon.BeginTransaction();
|
||||||
dbCmd.Transaction = trans;
|
dbCmd.Transaction = trans;
|
||||||
dbCmd.CommandText = $"INSERT INTO `gpus` (`id`, `name`) VALUES ({DB_NONE}, 'DB_NONE');\n" +
|
dbCmd.CommandText = $"INSERT INTO `gpus` (`id`, `name`) VALUES ({DB_NONE}, 'DB_NONE');\n" +
|
||||||
$"INSERT INTO `gpus` (`id`, `name`) VALUES ({DB_FRAMEBUFFER}, 'DB_FRAMEBUFFER');";
|
$"INSERT INTO `gpus` (`id`, `name`) VALUES ({DB_SOFTWARE}, 'DB_FRAMEBUFFER');";
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
trans.Commit();
|
trans.Commit();
|
||||||
dbCmd.Dispose();
|
dbCmd.Dispose();
|
||||||
@@ -1074,7 +1079,7 @@ namespace Cicm.Database
|
|||||||
dbCmd.Transaction = trans;
|
dbCmd.Transaction = trans;
|
||||||
dbCmd.CommandText = $"UPDATE `computers` SET `gpu` = {DB_NONE} WHERE `gpu` = 1;\n" +
|
dbCmd.CommandText = $"UPDATE `computers` SET `gpu` = {DB_NONE} WHERE `gpu` = 1;\n" +
|
||||||
"UPDATE `computers` SET `gpu` = NULL WHERE `gpu` = 2;\n" +
|
"UPDATE `computers` SET `gpu` = NULL WHERE `gpu` = 2;\n" +
|
||||||
$"UPDATE `computers` SET `gpu` = {DB_FRAMEBUFFER} WHERE `gpu` = 3;";
|
$"UPDATE `computers` SET `gpu` = {DB_SOFTWARE} WHERE `gpu` = 3;";
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
trans.Commit();
|
trans.Commit();
|
||||||
dbCmd.Dispose();
|
dbCmd.Dispose();
|
||||||
@@ -1085,7 +1090,7 @@ namespace Cicm.Database
|
|||||||
dbCmd.Transaction = trans;
|
dbCmd.Transaction = trans;
|
||||||
dbCmd.CommandText = $"UPDATE `consoles` SET `gpu` = {DB_NONE} WHERE `gpu` = 1;\n" +
|
dbCmd.CommandText = $"UPDATE `consoles` SET `gpu` = {DB_NONE} WHERE `gpu` = 1;\n" +
|
||||||
"UPDATE `consoles` SET `gpu` = NULL WHERE `gpu` = 2;\n" +
|
"UPDATE `consoles` SET `gpu` = NULL WHERE `gpu` = 2;\n" +
|
||||||
$"UPDATE `consoles` SET `gpu` = {DB_FRAMEBUFFER} WHERE `gpu` = 3;";
|
$"UPDATE `consoles` SET `gpu` = {DB_SOFTWARE} WHERE `gpu` = 3;";
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
trans.Commit();
|
trans.Commit();
|
||||||
dbCmd.Dispose();
|
dbCmd.Dispose();
|
||||||
@@ -1694,7 +1699,7 @@ namespace Cicm.Database
|
|||||||
|
|
||||||
void UpdateDatabaseToV16()
|
void UpdateDatabaseToV16()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Updating database to version 15");
|
Console.WriteLine("Updating database to version 16");
|
||||||
|
|
||||||
Console.WriteLine("Creating table `gpus_by_machine`");
|
Console.WriteLine("Creating table `gpus_by_machine`");
|
||||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
@@ -1729,8 +1734,7 @@ namespace Cicm.Database
|
|||||||
|
|
||||||
param1.Value = (int)dataRow["id"];
|
param1.Value = (int)dataRow["id"];
|
||||||
|
|
||||||
const string SQL =
|
const string SQL = "INSERT INTO gpus_by_machine (machine, gpu) VALUES (@machine, @gpu)";
|
||||||
"INSERT INTO gpus_by_machine (machine, gpu) VALUES (@machine, @gpu)";
|
|
||||||
|
|
||||||
dbcmd.Parameters.Add(param1);
|
dbcmd.Parameters.Add(param1);
|
||||||
dbcmd.Parameters.Add(param2);
|
dbcmd.Parameters.Add(param2);
|
||||||
@@ -1770,6 +1774,134 @@ namespace Cicm.Database
|
|||||||
dbCmd.Dispose();
|
dbCmd.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateDatabaseToV17()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Updating database to version 17");
|
||||||
|
|
||||||
|
Console.WriteLine("Creating table `sound_by_machine`");
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = V17.SoundByMachine;
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
|
||||||
|
Console.WriteLine("Adding new special items to table `sound_synths`");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = $"INSERT INTO `sound_synths` (`id`, `name`) VALUES ({DB_SOFTWARE}, 'DB_SOFTWARE');";
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
|
||||||
|
Console.WriteLine("Changing sound and music synths in machine from 27 to {0}", DB_SOFTWARE);
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = $"UPDATE `machines` SET sound_synth = {DB_SOFTWARE} WHERE sound_synth = 27;\n" +
|
||||||
|
$"UPDATE `machines` SET music_synth = {DB_SOFTWARE} WHERE music_synth = 27;";
|
||||||
|
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 = "@sound_synth";
|
||||||
|
|
||||||
|
param1.DbType = DbType.Int32;
|
||||||
|
param2.DbType = DbType.Int32;
|
||||||
|
|
||||||
|
param1.Value = (int)dataRow["id"];
|
||||||
|
|
||||||
|
const string SQL =
|
||||||
|
"INSERT INTO sound_by_machine (machine, sound_synth) VALUES (@machine, @sound_synth)";
|
||||||
|
|
||||||
|
dbcmd.Parameters.Add(param1);
|
||||||
|
dbcmd.Parameters.Add(param2);
|
||||||
|
|
||||||
|
if(dataRow["sound_synth"] != DBNull.Value && (int)dataRow["sound_synth"] != 1 &&
|
||||||
|
(int)dataRow["sound_synth"] != 2)
|
||||||
|
{
|
||||||
|
param2.Value = (int)dataRow["sound_synth"];
|
||||||
|
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
Console.WriteLine("Adding sound {0} to machine {1}", (int)param2.Value, (int)param1.Value);
|
||||||
|
|
||||||
|
dbcmd.CommandText = SQL;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataRow["music_synth"] != DBNull.Value && (int)dataRow["music_synth"] != 1 &&
|
||||||
|
(int)dataRow["music_synth"] != 2)
|
||||||
|
{
|
||||||
|
param2.Value = (int)dataRow["music_synth"];
|
||||||
|
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
Console.WriteLine("Adding sound {0} to machine {1}", (int)param2.Value, (int)param1.Value);
|
||||||
|
|
||||||
|
dbcmd.CommandText = SQL;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
dbcmd.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Removing sound columns from table `machines`");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_sound_synth`;\n" +
|
||||||
|
"ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_music_synth`;\n" +
|
||||||
|
"ALTER TABLE `machines` DROP COLUMN `sound_channels`;\n" +
|
||||||
|
"ALTER TABLE `machines` DROP COLUMN `music_channels`;\n" +
|
||||||
|
"ALTER TABLE `machines` DROP COLUMN `sound_synth`;\n" +
|
||||||
|
"ALTER TABLE `machines` DROP COLUMN `music_synth`;";
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
|
||||||
|
Console.WriteLine("Removing old sound items `sound_synths`");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = "DELETE FROM sound_synths WHERE id = 1;\n" +
|
||||||
|
"DELETE FROM sound_synths WHERE id = 2;\n" + "DELETE FROM sound_synths WHERE id = 27;";
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
|
||||||
|
Console.WriteLine("Setting new database version to 17...");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('17')";
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
void OptimizeDatabase()
|
void OptimizeDatabase()
|
||||||
{
|
{
|
||||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
|||||||
@@ -55,20 +55,12 @@ namespace Cicm.Database.Schemas
|
|||||||
public int Id;
|
public int Id;
|
||||||
/// <summary>Model name</summary>
|
/// <summary>Model name</summary>
|
||||||
public string Model;
|
public string Model;
|
||||||
/// <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>
|
/// <summary>Size in kibibytes of program RAM</summary>
|
||||||
public int Ram;
|
public int Ram;
|
||||||
/// <summary>Resolution in WxH pixels</summary>
|
/// <summary>Resolution in WxH pixels</summary>
|
||||||
public string Resolution;
|
public string Resolution;
|
||||||
/// <summary>Size in kibibytes of firmware</summary>
|
/// <summary>Size in kibibytes of firmware</summary>
|
||||||
public int Rom;
|
public int Rom;
|
||||||
/// <summary>Audio channels supported by the DSP</summary>
|
|
||||||
public int SoundChannels;
|
|
||||||
/// <summary>ID of DSP</summary>
|
|
||||||
public int SoundSynth;
|
|
||||||
/// <summary>Machine type</summary>
|
/// <summary>Machine type</summary>
|
||||||
public MachineType Type;
|
public MachineType Type;
|
||||||
/// <summary>Size in kibibytes for video RAM</summary>
|
/// <summary>Size in kibibytes for video RAM</summary>
|
||||||
|
|||||||
41
Cicm.Database/Schemas/SoundByMachine.cs
Normal file
41
Cicm.Database/Schemas/SoundByMachine.cs
Normal 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 SoundByMachine
|
||||||
|
{
|
||||||
|
/// <summary>Machine ID</summary>
|
||||||
|
public int Machine;
|
||||||
|
/// <summary>Sound synth ID</summary>
|
||||||
|
public int SoundSynth;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,14 +28,34 @@
|
|||||||
// Copyright © 2003-2018 Natalia Portillo
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Cicm.Database.Schemas
|
namespace Cicm.Database.Schemas
|
||||||
{
|
{
|
||||||
/// <summary>Sound synthetizer</summary>
|
/// <summary>Sound synthetizer</summary>
|
||||||
public class SoundSynth
|
public class SoundSynth
|
||||||
{
|
{
|
||||||
|
/// <summary>Company</summary>
|
||||||
|
public Company Company;
|
||||||
|
/// <summary>Sample rate in bits of the generate sound</summary>
|
||||||
|
public int Depth;
|
||||||
|
/// <summary>Frequency in Hz of the generated sound</summary>
|
||||||
|
public double Frequency;
|
||||||
/// <summary>ID</summary>
|
/// <summary>ID</summary>
|
||||||
public int Id;
|
public int Id;
|
||||||
|
/// <summary>Datetime of introduction</summary>
|
||||||
|
public DateTime Introduced;
|
||||||
|
/// <summary>Model/SKU code</summary>
|
||||||
|
public string ModelCode;
|
||||||
/// <summary>Name</summary>
|
/// <summary>Name</summary>
|
||||||
public string Name;
|
public string Name;
|
||||||
|
/// <summary>Simultaneous square wave generators</summary>
|
||||||
|
public int SquareWave;
|
||||||
|
/// <summary>Type of sound synthetizer</summary>
|
||||||
|
public int Type;
|
||||||
|
/// <summary>Simultaneous voices that can be generated</summary>
|
||||||
|
public int Voices;
|
||||||
|
/// <summary>Simultaneous white noise generators</summary>
|
||||||
|
public int WhiteNoise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ namespace Cicm.Database.Schemas.Sql
|
|||||||
public static readonly string Gpus =
|
public static readonly string Gpus =
|
||||||
V11.Gpus + "\n" +
|
V11.Gpus + "\n" +
|
||||||
$"INSERT INTO `gpus` (`id`, `name`) VALUES ({Operations.DB_NONE}, `DB_NONE`);\n" +
|
$"INSERT INTO `gpus` (`id`, `name`) VALUES ({Operations.DB_NONE}, `DB_NONE`);\n" +
|
||||||
$"INSERT INTO `gpus` (`id`, `name`) VALUES ({Operations.DB_FRAMEBUFFER}, `DB_FRAMEBUFFER`);";
|
$"INSERT INTO `gpus` (`id`, `name`) VALUES ({Operations.DB_SOFTWARE}, `DB_FRAMEBUFFER`);";
|
||||||
|
|
||||||
public static readonly string Logs = V11.Logs;
|
public static readonly string Logs = V11.Logs;
|
||||||
|
|
||||||
|
|||||||
135
Cicm.Database/Schemas/Sql/V17.cs
Normal file
135
Cicm.Database/Schemas/Sql/V17.cs
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : V17.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 V17
|
||||||
|
{
|
||||||
|
public static readonly string Admins = V16.Admins;
|
||||||
|
|
||||||
|
public static readonly string BrowserTests = V16.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" +
|
||||||
|
"INSERT INTO cicm_db (version) VALUES ('17');";
|
||||||
|
|
||||||
|
public static readonly string Companies = V16.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" +
|
||||||
|
"`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_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 = V16.DiskFormats;
|
||||||
|
|
||||||
|
public static readonly string Forbidden = V16.Forbidden;
|
||||||
|
|
||||||
|
public static readonly string Gpus = V16.Gpus;
|
||||||
|
|
||||||
|
public static readonly string Logs = V16.Logs;
|
||||||
|
|
||||||
|
public static readonly string MoneyDonations = V16.MoneyDonations;
|
||||||
|
|
||||||
|
public static readonly string News = V16.News;
|
||||||
|
|
||||||
|
public static readonly string OwnedComputers = V16.OwnedComputers;
|
||||||
|
|
||||||
|
public static readonly string OwnedConsoles = V16.OwnedConsoles;
|
||||||
|
|
||||||
|
public static readonly string Processors = V16.Processors;
|
||||||
|
|
||||||
|
public static readonly string SoundSynths = V16.SoundSynths;
|
||||||
|
|
||||||
|
public static readonly string MachinesForeignKeys = V16.MachinesForeignKeys;
|
||||||
|
|
||||||
|
public static readonly string Iso3166Numeric = V16.Iso3166Numeric;
|
||||||
|
|
||||||
|
public static readonly string Iso3166NumericValues = V16.Iso3166NumericValues;
|
||||||
|
|
||||||
|
public static readonly string CompaniesForeignKeys = V16.CompaniesForeignKeys;
|
||||||
|
|
||||||
|
public static readonly string CompanyLogos = V16.CompanyLogos;
|
||||||
|
|
||||||
|
public static readonly string CompanyDescriptions = V16.CompanyDescriptions;
|
||||||
|
|
||||||
|
public static readonly string InstructionSets = V16.InstructionSets;
|
||||||
|
|
||||||
|
public static readonly string InstructionSetExtensions = V16.InstructionSetExtensions;
|
||||||
|
|
||||||
|
public static readonly string InstructionSetExtensionsByProcessor = V16.InstructionSetExtensionsByProcessor;
|
||||||
|
|
||||||
|
public static readonly string ProcessorsByMachine = V16.ProcessorsByMachine;
|
||||||
|
|
||||||
|
public static readonly string GpusByMachine = V16.GpusByMachine;
|
||||||
|
|
||||||
|
public static readonly string SoundByMachine =
|
||||||
|
"CREATE TABLE `sound_by_machine` (\n" +
|
||||||
|
"`sound_synth` INT NOT NULL, \n" +
|
||||||
|
"`machine` INT NOT NULL,\n" +
|
||||||
|
"KEY `idx_sound_by_machine_sound_synth` (`sound_synth`),\n" +
|
||||||
|
"KEY `idx_sound_by_machine_machine` (`machine`),\n" +
|
||||||
|
"CONSTRAINT `fk_sound_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" +
|
||||||
|
"CONSTRAINT `fk_sound_by_machine_sound_synth` FOREIGN KEY (`sound_synth`) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,20 +43,17 @@ namespace cicm_web.Models
|
|||||||
public Company Company;
|
public Company Company;
|
||||||
public DiskFormat Disk1;
|
public DiskFormat Disk1;
|
||||||
public DiskFormat Disk2;
|
public DiskFormat Disk2;
|
||||||
public GpuByMachine[] Gpus;
|
public GpuByMachine[] Gpus;
|
||||||
public DiskFormat Hdd1;
|
public DiskFormat Hdd1;
|
||||||
public DiskFormat Hdd2;
|
public DiskFormat Hdd2;
|
||||||
public DiskFormat Hdd3;
|
public DiskFormat Hdd3;
|
||||||
public int Id;
|
public int Id;
|
||||||
public string Model;
|
public string Model;
|
||||||
public int MusicChannels;
|
|
||||||
public SoundSynth MusicSynth;
|
|
||||||
public ProcessorByMachine[] Processors;
|
public ProcessorByMachine[] Processors;
|
||||||
public int Ram;
|
public int Ram;
|
||||||
public string Resolution;
|
public string Resolution;
|
||||||
public int Rom;
|
public int Rom;
|
||||||
public int SoundChannels;
|
public SoundByMachine[] SoundSynths;
|
||||||
public SoundSynth SoundSynth;
|
|
||||||
public MachineType Type;
|
public MachineType Type;
|
||||||
public int Vram;
|
public int Vram;
|
||||||
public int Year;
|
public int Year;
|
||||||
@@ -92,21 +89,22 @@ namespace cicm_web.Models
|
|||||||
{
|
{
|
||||||
Machine item = new Machine
|
Machine item = new Machine
|
||||||
{
|
{
|
||||||
Colors = dbItem.Colors,
|
Colors = dbItem.Colors,
|
||||||
Company = Company.GetItem(dbItem.Company),
|
Company = Company.GetItem(dbItem.Company),
|
||||||
Gpus = GpuByMachine.GetAllItems(dbItem.Id),
|
Gpus = GpuByMachine.GetAllItems(dbItem.Id),
|
||||||
Hdd1 = DiskFormat.GetItem(dbItem.Hdd1),
|
Hdd1 = DiskFormat.GetItem(dbItem.Hdd1),
|
||||||
Hdd2 = DiskFormat.GetItem(dbItem.Hdd2),
|
Hdd2 = DiskFormat.GetItem(dbItem.Hdd2),
|
||||||
Hdd3 = DiskFormat.GetItem(dbItem.Hdd3),
|
Hdd3 = DiskFormat.GetItem(dbItem.Hdd3),
|
||||||
Id = dbItem.Id,
|
Id = dbItem.Id,
|
||||||
Model = dbItem.Model,
|
Model = dbItem.Model,
|
||||||
Ram = dbItem.Ram,
|
Ram = dbItem.Ram,
|
||||||
Resolution = dbItem.Resolution,
|
Resolution = dbItem.Resolution,
|
||||||
Rom = dbItem.Rom,
|
Rom = dbItem.Rom,
|
||||||
Vram = dbItem.Vram,
|
Vram = dbItem.Vram,
|
||||||
Year = dbItem.Year,
|
Year = dbItem.Year,
|
||||||
Type = dbItem.Type,
|
Type = dbItem.Type,
|
||||||
Processors = ProcessorByMachine.GetAllItems(dbItem.Id)
|
Processors = ProcessorByMachine.GetAllItems(dbItem.Id),
|
||||||
|
SoundSynths = SoundByMachine.GetAllItems(dbItem.Id)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(dbItem.Disk1 > 0)
|
if(dbItem.Disk1 > 0)
|
||||||
@@ -121,18 +119,6 @@ namespace cicm_web.Models
|
|||||||
item.Disk2 = DiskFormat.GetItem(dbItem.Disk2);
|
item.Disk2 = DiskFormat.GetItem(dbItem.Disk2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dbItem.MusicSynth > 0)
|
|
||||||
{
|
|
||||||
item.MusicSynth = SoundSynth.GetItem(dbItem.MusicSynth);
|
|
||||||
item.MusicChannels = dbItem.MusicChannels;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dbItem.SoundSynth > 0)
|
|
||||||
{
|
|
||||||
item.SoundSynth = SoundSynth.GetItem(dbItem.SoundSynth);
|
|
||||||
item.SoundChannels = dbItem.SoundChannels;
|
|
||||||
}
|
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
54
cicm_web/Models/SoundByMachine.cs
Normal file
54
cicm_web/Models/SoundByMachine.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// 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 SoundByMachine
|
||||||
|
{
|
||||||
|
public SoundSynth SoundSynth;
|
||||||
|
|
||||||
|
public static SoundByMachine[] GetAllItems(int machineId)
|
||||||
|
{
|
||||||
|
List<Cicm.Database.Schemas.SoundByMachine> dbItems = null;
|
||||||
|
bool? result =
|
||||||
|
Program.Database?.Operations.GetSoundsByMachines(out dbItems, machineId);
|
||||||
|
if(result == null || result.Value == false || dbItems == null) return null;
|
||||||
|
|
||||||
|
List<SoundByMachine> items = new List<SoundByMachine>();
|
||||||
|
|
||||||
|
foreach(Cicm.Database.Schemas.SoundByMachine dbItem in dbItems)
|
||||||
|
items.Add(new SoundByMachine {SoundSynth = SoundSynth.GetItem(dbItem.SoundSynth)});
|
||||||
|
|
||||||
|
return items.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,19 +28,44 @@
|
|||||||
// Copyright © 2003-2018 Natalia Portillo
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace cicm_web.Models
|
namespace cicm_web.Models
|
||||||
{
|
{
|
||||||
public class SoundSynth
|
public class SoundSynth
|
||||||
{
|
{
|
||||||
public int Id;
|
public Company Company;
|
||||||
public string Name;
|
public int Depth;
|
||||||
|
public double Frequency;
|
||||||
|
public int Id;
|
||||||
|
public DateTime Introduced;
|
||||||
|
public string ModelCode;
|
||||||
|
public string Name;
|
||||||
|
public int SquareWave;
|
||||||
|
public int Type;
|
||||||
|
public int Voices;
|
||||||
|
public int WhiteNoise;
|
||||||
|
|
||||||
public static SoundSynth GetItem(int id)
|
public static SoundSynth GetItem(int id)
|
||||||
{
|
{
|
||||||
Cicm.Database.Schemas.SoundSynth dbItem = Program.Database?.Operations.GetSoundSynth(id);
|
Cicm.Database.Schemas.SoundSynth dbItem = Program.Database?.Operations.GetSoundSynth(id);
|
||||||
return dbItem == null ? null : new SoundSynth {Name = dbItem.Name, Id = dbItem.Id};
|
return dbItem == null
|
||||||
|
? null
|
||||||
|
: new SoundSynth
|
||||||
|
{
|
||||||
|
Name = dbItem.Name,
|
||||||
|
Id = dbItem.Id,
|
||||||
|
Company = dbItem.Company == null ? null : Company.GetItem(dbItem.Company.Id),
|
||||||
|
ModelCode = dbItem.ModelCode,
|
||||||
|
Introduced = dbItem.Introduced,
|
||||||
|
Voices = dbItem.Voices,
|
||||||
|
Frequency = dbItem.Frequency,
|
||||||
|
Depth = dbItem.Depth,
|
||||||
|
SquareWave = dbItem.SquareWave,
|
||||||
|
WhiteNoise = dbItem.WhiteNoise,
|
||||||
|
Type = dbItem.Type
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SoundSynth[] GetAllItems()
|
public static SoundSynth[] GetAllItems()
|
||||||
@@ -52,7 +77,20 @@ namespace cicm_web.Models
|
|||||||
List<SoundSynth> items = new List<SoundSynth>();
|
List<SoundSynth> items = new List<SoundSynth>();
|
||||||
|
|
||||||
foreach(Cicm.Database.Schemas.SoundSynth dbItem in dbItems)
|
foreach(Cicm.Database.Schemas.SoundSynth dbItem in dbItems)
|
||||||
items.Add(new SoundSynth {Id = dbItem.Id, Name = dbItem.Name});
|
items.Add(new SoundSynth
|
||||||
|
{
|
||||||
|
Name = dbItem.Name,
|
||||||
|
Id = dbItem.Id,
|
||||||
|
Company = dbItem.Company == null ? null : Company.GetItem(dbItem.Company.Id),
|
||||||
|
ModelCode = dbItem.ModelCode,
|
||||||
|
Introduced = dbItem.Introduced,
|
||||||
|
Voices = dbItem.Voices,
|
||||||
|
Frequency = dbItem.Frequency,
|
||||||
|
Depth = dbItem.Depth,
|
||||||
|
SquareWave = dbItem.SquareWave,
|
||||||
|
WhiteNoise = dbItem.WhiteNoise,
|
||||||
|
Type = dbItem.Type
|
||||||
|
});
|
||||||
|
|
||||||
return items.ToArray();
|
return items.ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -424,15 +424,15 @@
|
|||||||
{
|
{
|
||||||
<td>
|
<td>
|
||||||
@($"{Model.Gpus[i].Gpu.Name}")
|
@($"{Model.Gpus[i].Gpu.Name}")
|
||||||
<a aria-controls="gpuInfo"
|
<a aria-controls="@($"gpuInfo{i}")"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
class="btn btn-link"
|
class="btn btn-link"
|
||||||
data-toggle="collapse"
|
data-toggle="collapse"
|
||||||
href="#gpuInfo">
|
href="@($"#gpuInfo{i}")">
|
||||||
+info
|
+info
|
||||||
</a>
|
</a>
|
||||||
<div class="collapse"
|
<div class="collapse"
|
||||||
id="gpuInfo">
|
id="@($"gpuInfo{i}")">
|
||||||
<div class="card card-body">
|
<div class="card card-body">
|
||||||
<table>
|
<table>
|
||||||
@if(Model.Gpus[i].Gpu.ModelCode != null && Model.Gpus[i].Gpu.ModelCode != Model.Gpus[i].Gpu.Name)
|
@if(Model.Gpus[i].Gpu.ModelCode != null && Model.Gpus[i].Gpu.ModelCode != Model.Gpus[i].Gpu.Name)
|
||||||
@@ -571,60 +571,160 @@
|
|||||||
<td>Unknown data</td>
|
<td>Unknown data</td>
|
||||||
}
|
}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
@if(Model.SoundSynths != null && Model.SoundSynths.Length > 0)
|
||||||
<th scope=row>
|
{
|
||||||
<div align=right>
|
<tr>
|
||||||
Sound processor
|
<th scope=row>
|
||||||
</div>
|
<div align=right>
|
||||||
</th>
|
Sound synthetizers
|
||||||
@if(Model.SoundSynth.Id > 1)
|
</div>
|
||||||
{
|
</th>
|
||||||
if(Model.SoundSynth.Id > 2)
|
<td>
|
||||||
{
|
<table>
|
||||||
if(Model.SoundChannels > 0)
|
@for(int i = 0; i < Model.SoundSynths.Length; i++)
|
||||||
{
|
{
|
||||||
<td>@Model.SoundSynth.Name (@Model.SoundChannels channels)</td>
|
if(Model.SoundSynths[i] != null)
|
||||||
}
|
{
|
||||||
else
|
if(Model.SoundSynths[i].SoundSynth.Id == -2)
|
||||||
{
|
{
|
||||||
<td>@Model.SoundSynth.Name</td>
|
<td>
|
||||||
}
|
Software
|
||||||
}
|
<a aria-controls="@($"synthInfo{i}")"
|
||||||
else
|
aria-expanded="false"
|
||||||
{
|
class="btn btn-link"
|
||||||
<td>Unknown data</td>
|
data-toggle="collapse"
|
||||||
}
|
href="@($"#synthInfo{i}")">
|
||||||
}
|
+info
|
||||||
else
|
</a>
|
||||||
{ <td>None</td> }
|
<div class="collapse"
|
||||||
</tr>
|
id="@($"synthInfo{i}")">
|
||||||
<tr>
|
<div class="card card-body">
|
||||||
<th scope=row>
|
This computer directly sends data to a <abbr title="Digital to Analog Converter">DAC</abbr> or similar connected to the audio output.
|
||||||
<div align=right>
|
</div>
|
||||||
Music synthetizer
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</th>
|
}
|
||||||
@if(Model.MusicSynth.Id > 1)
|
else
|
||||||
{
|
{
|
||||||
if(Model.MusicSynth.Id > 2)
|
<td>
|
||||||
{
|
@($"{Model.Gpus[i].Gpu.Name}")
|
||||||
if(Model.MusicChannels > 0)
|
<a aria-controls="@($"synthInfo{i}")"
|
||||||
{
|
aria-expanded="false"
|
||||||
<td>@Model.MusicSynth.Name (@Model.MusicChannels channels)</td>
|
class="btn btn-link"
|
||||||
}
|
data-toggle="collapse"
|
||||||
else
|
href="@($"#synthInfo{i}")">
|
||||||
{
|
+info
|
||||||
<td>@Model.MusicSynth.Name</td>
|
</a>
|
||||||
}
|
<div class="collapse"
|
||||||
}
|
id="@($"synthInfo{i}")">
|
||||||
else
|
<div class="card card-body">
|
||||||
{
|
<table>
|
||||||
<td>Unknown data</td>
|
@if(Model.SoundSynths[i].SoundSynth.ModelCode != null && Model.SoundSynths[i].SoundSynth.ModelCode != Model.SoundSynths[i].SoundSynth.Name)
|
||||||
}
|
{
|
||||||
}
|
<tr>
|
||||||
else
|
<td>Model</td>
|
||||||
{ <td>None</td> }
|
<td>@Model.SoundSynths[i].SoundSynth.ModelCode</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
}
|
||||||
|
@if(Model.SoundSynths[i].SoundSynth.Company != null)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>Manufacturer</td>
|
||||||
|
<td>
|
||||||
|
<a asp-controller=Company
|
||||||
|
asp-action=View
|
||||||
|
asp-route-id=@Model.SoundSynths[i].SoundSynth.Company.Id>
|
||||||
|
@Model.SoundSynths[i].SoundSynth.Company.Name</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
@if(Model.SoundSynths[i].SoundSynth.Introduced != DateTime.MinValue)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>Introduction date</td>
|
||||||
|
<td>@($"{Model.Gpus[i].Gpu.Introduced:yyyy}")</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
@if(Model.SoundSynths[i].SoundSynth.Voices != 0 || Model.SoundSynths[i].SoundSynth.SquareWave != 0 || Model.SoundSynths[i].SoundSynth.WhiteNoise != 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>Generators</td>
|
||||||
|
<td>
|
||||||
|
<table>
|
||||||
|
@if(Model.SoundSynths[i].SoundSynth.Voices != 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@Model.SoundSynths[i].SoundSynth.Voices voices</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
@if(Model.SoundSynths[i].SoundSynth.SquareWave != 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@Model.SoundSynths[i].SoundSynth.SquareWave square wave</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
@if(Model.SoundSynths[i].SoundSynth.WhiteNoise != 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@Model.SoundSynths[i].SoundSynth.WhiteNoise white noise</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
@if(Model.SoundSynths[i].SoundSynth.Depth != 0 || Model.SoundSynths[i].SoundSynth.Frequency > 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>Sample rate</td>
|
||||||
|
<td>
|
||||||
|
<table>
|
||||||
|
@if(Model.SoundSynths[i].SoundSynth.Depth != 0 && Model.SoundSynths[i].SoundSynth.Frequency > 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@Model.SoundSynths[i].SoundSynth.Depth bits at @(Model.SoundSynths[i].SoundSynth.Frequency > 1000 ? $"{Model.SoundSynths[i].SoundSynth.Frequency / 1000}KHz" : $"{Model.SoundSynths[i].SoundSynth.Frequency}Hz")</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
else if(Model.SoundSynths[i].SoundSynth.Depth != 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@Model.SoundSynths[i].SoundSynth.Depth bits</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@(Model.SoundSynths[i].SoundSynth.Frequency > 1000 ? $"{Model.SoundSynths[i].SoundSynth.Frequency / 1000}KHz" : $"{Model.SoundSynths[i].SoundSynth.Frequency}Hz")</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
@if(Model.SoundSynths[i].SoundSynth.Type != 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>Synthetizer type</td>
|
||||||
|
<td>
|
||||||
|
@Model.SoundSynths[i].SoundSynth.Type
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<td>Unknown data</td>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
@if(Model.Hdd1 != null && Model.Hdd1.Id > 0 && Model.Hdd1.Id != 30)
|
@if(Model.Hdd1 != null && Model.Hdd1.Id > 0 && Model.Hdd1.Id != 30)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
<Version>3.0.99.207</Version>
|
<Version>3.0.99.209</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user