mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Update DB to version 18: Machines can have an arbitrary number of memories,
so use an interconnection table, `memory_by_machine`.
This commit is contained in:
@@ -49,111 +49,115 @@ namespace Cicm.Database
|
|||||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `admins`");
|
Console.WriteLine("Creating table `admins`");
|
||||||
dbCmd.CommandText = V17.Admins;
|
dbCmd.CommandText = V18.Admins;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `browser_tests`");
|
Console.WriteLine("Creating table `browser_tests`");
|
||||||
dbCmd.CommandText = V17.BrowserTests;
|
dbCmd.CommandText = V18.BrowserTests;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `cicm_db`");
|
Console.WriteLine("Creating table `cicm_db`");
|
||||||
dbCmd.CommandText = V17.CicmDb;
|
dbCmd.CommandText = V18.CicmDb;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `companies`");
|
Console.WriteLine("Creating table `companies`");
|
||||||
dbCmd.CommandText = V17.Companies;
|
dbCmd.CommandText = V18.Companies;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `machines`");
|
Console.WriteLine("Creating table `machines`");
|
||||||
dbCmd.CommandText = V17.Machines;
|
dbCmd.CommandText = V18.Machines;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `disk_formats`");
|
Console.WriteLine("Creating table `disk_formats`");
|
||||||
dbCmd.CommandText = V17.DiskFormats;
|
dbCmd.CommandText = V18.DiskFormats;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `forbidden`");
|
Console.WriteLine("Creating table `forbidden`");
|
||||||
dbCmd.CommandText = V17.Forbidden;
|
dbCmd.CommandText = V18.Forbidden;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `gpus`");
|
Console.WriteLine("Creating table `gpus`");
|
||||||
dbCmd.CommandText = V17.Gpus;
|
dbCmd.CommandText = V18.Gpus;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `log`");
|
Console.WriteLine("Creating table `log`");
|
||||||
dbCmd.CommandText = V17.Logs;
|
dbCmd.CommandText = V18.Logs;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `money_donations`");
|
Console.WriteLine("Creating table `money_donations`");
|
||||||
dbCmd.CommandText = V17.MoneyDonations;
|
dbCmd.CommandText = V18.MoneyDonations;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `news`");
|
Console.WriteLine("Creating table `news`");
|
||||||
dbCmd.CommandText = V17.News;
|
dbCmd.CommandText = V18.News;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `owned_computers`");
|
Console.WriteLine("Creating table `owned_computers`");
|
||||||
dbCmd.CommandText = V17.OwnedComputers;
|
dbCmd.CommandText = V18.OwnedComputers;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `owned_consoles`");
|
Console.WriteLine("Creating table `owned_consoles`");
|
||||||
dbCmd.CommandText = V17.OwnedConsoles;
|
dbCmd.CommandText = V18.OwnedConsoles;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `instruction_sets`");
|
Console.WriteLine("Creating table `instruction_sets`");
|
||||||
dbCmd.CommandText = V17.InstructionSets;
|
dbCmd.CommandText = V18.InstructionSets;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `instruction_set_extensions`");
|
Console.WriteLine("Creating table `instruction_set_extensions`");
|
||||||
dbCmd.CommandText = V17.InstructionSetExtensions;
|
dbCmd.CommandText = V18.InstructionSetExtensions;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `processors`");
|
Console.WriteLine("Creating table `processors`");
|
||||||
dbCmd.CommandText = V17.Processors;
|
dbCmd.CommandText = V18.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 = V17.InstructionSetExtensionsByProcessor;
|
dbCmd.CommandText = V18.InstructionSetExtensionsByProcessor;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `sound_synths`");
|
Console.WriteLine("Creating table `sound_synths`");
|
||||||
dbCmd.CommandText = V17.SoundSynths;
|
dbCmd.CommandText = V18.SoundSynths;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `iso3166_1_numeric`");
|
Console.WriteLine("Creating table `iso3166_1_numeric`");
|
||||||
dbCmd.CommandText = V17.Iso3166Numeric;
|
dbCmd.CommandText = V18.Iso3166Numeric;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Filling table `iso3166_1_numeric`");
|
Console.WriteLine("Filling table `iso3166_1_numeric`");
|
||||||
dbCmd.CommandText = V17.Iso3166NumericValues;
|
dbCmd.CommandText = V18.Iso3166NumericValues;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating foreign keys for table `companies`");
|
Console.WriteLine("Creating foreign keys for table `companies`");
|
||||||
dbCmd.CommandText = V17.CompaniesForeignKeys;
|
dbCmd.CommandText = V18.CompaniesForeignKeys;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating foreign keys for table `machines`");
|
Console.WriteLine("Creating foreign keys for table `machines`");
|
||||||
dbCmd.CommandText = V17.MachinesForeignKeys;
|
dbCmd.CommandText = V18.MachinesForeignKeys;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `company_logos`");
|
Console.WriteLine("Creating table `company_logos`");
|
||||||
dbCmd.CommandText = V17.CompanyLogos;
|
dbCmd.CommandText = V18.CompanyLogos;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `company_descriptions`");
|
Console.WriteLine("Creating table `company_descriptions`");
|
||||||
dbCmd.CommandText = V17.CompanyDescriptions;
|
dbCmd.CommandText = V18.CompanyDescriptions;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `processors_by_machine`");
|
Console.WriteLine("Creating table `processors_by_machine`");
|
||||||
dbCmd.CommandText = V17.ProcessorsByMachine;
|
dbCmd.CommandText = V18.ProcessorsByMachine;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `gpus_by_machine`");
|
Console.WriteLine("Creating table `gpus_by_machine`");
|
||||||
dbCmd.CommandText = V17.GpusByMachine;
|
dbCmd.CommandText = V18.GpusByMachine;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `sound_by_machine`");
|
Console.WriteLine("Creating table `sound_by_machine`");
|
||||||
dbCmd.CommandText = V17.SoundByMachine;
|
dbCmd.CommandText = V18.SoundByMachine;
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("Creating table `memory_by_machine`");
|
||||||
|
dbCmd.CommandText = V18.MemoryByMachine;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -214,9 +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, hdd1, hdd2, hdd3, disk1, " +
|
"INSERT INTO machines (company, year, model, colors, res, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2, " +
|
||||||
"cap1, disk2, cap2, type) VALUES (@company, @year, @model, @ram, @rom, @vram, @colors, @res, @hdd1, " +
|
"type) VALUES (@company, @year, @model, @colors, @res, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, " +
|
||||||
"@hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2, @type)";
|
"@cap2, @type)";
|
||||||
|
|
||||||
dbcmd.CommandText = SQL;
|
dbcmd.CommandText = SQL;
|
||||||
|
|
||||||
@@ -249,9 +249,9 @@ namespace Cicm.Database
|
|||||||
dbcmd.Transaction = trans;
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
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, colors = @colors, res = @res, " +
|
||||||
"vram = @vram, colors = @colors, res = @res, hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, " +
|
"hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2, " +
|
||||||
"cap1 = @cap1, disk2 = @disk2, cap2 = @cap2, type = @type " +
|
"type = @type " +
|
||||||
$"WHERE id = {entry.Id}";
|
$"WHERE id = {entry.Id}";
|
||||||
|
|
||||||
dbcmd.CommandText = sql;
|
dbcmd.CommandText = sql;
|
||||||
@@ -306,60 +306,48 @@ namespace Cicm.Database
|
|||||||
IDbDataParameter param11 = dbcmd.CreateParameter();
|
IDbDataParameter param11 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param12 = dbcmd.CreateParameter();
|
IDbDataParameter param12 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param13 = dbcmd.CreateParameter();
|
IDbDataParameter param13 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param14 = dbcmd.CreateParameter();
|
|
||||||
IDbDataParameter param15 = dbcmd.CreateParameter();
|
|
||||||
IDbDataParameter param16 = dbcmd.CreateParameter();
|
|
||||||
|
|
||||||
param1.ParameterName = "@company";
|
param1.ParameterName = "@company";
|
||||||
param2.ParameterName = "@year";
|
param2.ParameterName = "@year";
|
||||||
param3.ParameterName = "@model";
|
param3.ParameterName = "@model";
|
||||||
param4.ParameterName = "@ram";
|
param4.ParameterName = "@colors";
|
||||||
param5.ParameterName = "@rom";
|
param5.ParameterName = "@res";
|
||||||
param6.ParameterName = "@vram";
|
param6.ParameterName = "@hdd1";
|
||||||
param7.ParameterName = "@colors";
|
param7.ParameterName = "@hdd2";
|
||||||
param8.ParameterName = "@res";
|
param8.ParameterName = "@hdd3";
|
||||||
param9.ParameterName = "@hdd1";
|
param9.ParameterName = "@disk1";
|
||||||
param10.ParameterName = "@hdd2";
|
param10.ParameterName = "@cap1";
|
||||||
param11.ParameterName = "@hdd3";
|
param11.ParameterName = "@disk2";
|
||||||
param12.ParameterName = "@disk1";
|
param12.ParameterName = "@cap2";
|
||||||
param13.ParameterName = "@cap1";
|
param13.ParameterName = "@type";
|
||||||
param14.ParameterName = "@disk2";
|
|
||||||
param15.ParameterName = "@cap2";
|
|
||||||
param16.ParameterName = "@type";
|
|
||||||
|
|
||||||
param1.DbType = DbType.Int32;
|
param1.DbType = DbType.Int32;
|
||||||
param2.DbType = DbType.Int32;
|
param2.DbType = DbType.Int32;
|
||||||
param3.DbType = DbType.String;
|
param3.DbType = DbType.String;
|
||||||
param4.DbType = DbType.Int32;
|
param4.DbType = DbType.Int32;
|
||||||
param5.DbType = DbType.Int32;
|
param5.DbType = DbType.String;
|
||||||
param6.DbType = DbType.Int32;
|
param6.DbType = DbType.Int32;
|
||||||
param7.DbType = DbType.Int32;
|
param7.DbType = DbType.Int32;
|
||||||
param8.DbType = DbType.String;
|
param8.DbType = DbType.Int32;
|
||||||
param9.DbType = DbType.Int32;
|
param9.DbType = DbType.Int32;
|
||||||
param10.DbType = DbType.Int32;
|
param10.DbType = DbType.String;
|
||||||
param11.DbType = DbType.Int32;
|
param11.DbType = DbType.Int32;
|
||||||
param12.DbType = DbType.Int32;
|
param12.DbType = DbType.String;
|
||||||
param13.DbType = DbType.String;
|
param13.DbType = DbType.Int32;
|
||||||
param14.DbType = DbType.Int32;
|
|
||||||
param15.DbType = DbType.String;
|
|
||||||
param16.DbType = DbType.Int32;
|
|
||||||
|
|
||||||
param1.Value = entry.Company;
|
param1.Value = entry.Company;
|
||||||
param2.Value = entry.Year;
|
param2.Value = entry.Year;
|
||||||
param3.Value = entry.Model;
|
param3.Value = entry.Model;
|
||||||
param4.Value = entry.Ram;
|
param4.Value = entry.Colors;
|
||||||
param5.Value = entry.Rom;
|
param5.Value = entry.Resolution;
|
||||||
param6.Value = entry.Vram;
|
param6.Value = entry.Hdd1;
|
||||||
param7.Value = entry.Colors;
|
param7.Value = entry.Hdd2;
|
||||||
param8.Value = entry.Resolution;
|
param8.Value = entry.Hdd3;
|
||||||
param9.Value = entry.Hdd1;
|
param9.Value = entry.Disk1;
|
||||||
param10.Value = entry.Hdd2;
|
param10.Value = entry.Cap1;
|
||||||
param11.Value = entry.Hdd3;
|
param11.Value = entry.Disk2;
|
||||||
param12.Value = entry.Disk1;
|
param12.Value = entry.Cap2;
|
||||||
param13.Value = entry.Cap1;
|
param13.Value = entry.Type;
|
||||||
param14.Value = entry.Disk2;
|
|
||||||
param15.Value = entry.Cap2;
|
|
||||||
param16.Value = entry.Type;
|
|
||||||
|
|
||||||
dbcmd.Parameters.Add(param1);
|
dbcmd.Parameters.Add(param1);
|
||||||
dbcmd.Parameters.Add(param2);
|
dbcmd.Parameters.Add(param2);
|
||||||
@@ -374,9 +362,6 @@ namespace Cicm.Database
|
|||||||
dbcmd.Parameters.Add(param11);
|
dbcmd.Parameters.Add(param11);
|
||||||
dbcmd.Parameters.Add(param12);
|
dbcmd.Parameters.Add(param12);
|
||||||
dbcmd.Parameters.Add(param13);
|
dbcmd.Parameters.Add(param13);
|
||||||
dbcmd.Parameters.Add(param14);
|
|
||||||
dbcmd.Parameters.Add(param15);
|
|
||||||
dbcmd.Parameters.Add(param16);
|
|
||||||
|
|
||||||
return dbcmd;
|
return dbcmd;
|
||||||
}
|
}
|
||||||
@@ -393,9 +378,6 @@ namespace Cicm.Database
|
|||||||
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"],
|
|
||||||
Rom = (int)dataRow["rom"],
|
|
||||||
Vram = (int)dataRow["vram"],
|
|
||||||
Colors = (int)dataRow["colors"],
|
Colors = (int)dataRow["colors"],
|
||||||
Resolution = (string)dataRow["res"],
|
Resolution = (string)dataRow["res"],
|
||||||
Hdd1 = (int)dataRow["hdd1"],
|
Hdd1 = (int)dataRow["hdd1"],
|
||||||
|
|||||||
168
Cicm.Database/Operations/MemoryByMachine.cs
Normal file
168
Cicm.Database/Operations/MemoryByMachine.cs
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : MemoryByMachine.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Contains operations to manage memory.
|
||||||
|
//
|
||||||
|
// --[ 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 memory 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 GetMemoryByMachine(out List<MemoryByMachine> entries, int machineId)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting all memory synths for machine {0}...", machineId);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * FROM memory_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 = MemoryByMachinesFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting memory 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 GetMachinesByMemory(out List<MemoryByMachine> entries, int gpuId)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting all machines with memory synth {0}...", gpuId);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * FROM memory_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 = MemoryByMachinesFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting machines by memory synth.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
entries = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IDbCommand GetCommandMemoryByMachine(MemoryByMachine entry)
|
||||||
|
{
|
||||||
|
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||||
|
|
||||||
|
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param2 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param3 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param4 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param5 = dbcmd.CreateParameter();
|
||||||
|
|
||||||
|
param1.ParameterName = "@machine";
|
||||||
|
param2.ParameterName = "@type";
|
||||||
|
param3.ParameterName = "@usage";
|
||||||
|
param4.ParameterName = "@size";
|
||||||
|
param5.ParameterName = "@speed";
|
||||||
|
|
||||||
|
param1.DbType = DbType.Int32;
|
||||||
|
param2.DbType = DbType.Int32;
|
||||||
|
param3.DbType = DbType.Int32;
|
||||||
|
param4.DbType = DbType.Int64;
|
||||||
|
param5.DbType = DbType.Double;
|
||||||
|
|
||||||
|
param1.Value = entry.Machine;
|
||||||
|
param2.Value = entry.Type;
|
||||||
|
param3.Value = entry.Usage;
|
||||||
|
param4.Value = entry.Size == 0 ? (object)null : entry.Size;
|
||||||
|
param5.Value = entry.Speed <= 0 ? (object)null : entry.Speed;
|
||||||
|
|
||||||
|
dbcmd.Parameters.Add(param1);
|
||||||
|
dbcmd.Parameters.Add(param2);
|
||||||
|
dbcmd.Parameters.Add(param3);
|
||||||
|
dbcmd.Parameters.Add(param4);
|
||||||
|
dbcmd.Parameters.Add(param5);
|
||||||
|
|
||||||
|
return dbcmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<MemoryByMachine> MemoryByMachinesFromDataTable(DataTable dataTable)
|
||||||
|
{
|
||||||
|
List<MemoryByMachine> entries = new List<MemoryByMachine>();
|
||||||
|
|
||||||
|
foreach(DataRow dataRow in dataTable.Rows)
|
||||||
|
{
|
||||||
|
MemoryByMachine entry = new MemoryByMachine
|
||||||
|
{
|
||||||
|
Machine = (int)dataRow["machine"],
|
||||||
|
Type = (MemoryType)dataRow["type"],
|
||||||
|
Usage = (MemoryUsage)dataRow["usage"],
|
||||||
|
Size = dataRow["size"] == DBNull.Value ? 0 : (long)dataRow["size"],
|
||||||
|
Speed = dataRow["speed"] == DBNull.Value ? 0 : (double)dataRow["speed"],
|
||||||
|
};
|
||||||
|
|
||||||
|
entries.Add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ 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 = 17;
|
const int DB_VERSION = 18;
|
||||||
/// <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>
|
/// <summary>
|
||||||
|
|||||||
@@ -154,6 +154,11 @@ namespace Cicm.Database
|
|||||||
UpdateDatabaseToV17();
|
UpdateDatabaseToV17();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 17:
|
||||||
|
{
|
||||||
|
UpdateDatabaseToV18();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OptimizeDatabase();
|
OptimizeDatabase();
|
||||||
@@ -1902,6 +1907,125 @@ namespace Cicm.Database
|
|||||||
dbCmd.Dispose();
|
dbCmd.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateDatabaseToV18()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Updating database to version 18");
|
||||||
|
|
||||||
|
Console.WriteLine("Creating table `memory_by_machine`");
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = V18.MemoryByMachine;
|
||||||
|
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();
|
||||||
|
IDbDataParameter param3 = dbcmd.CreateParameter();
|
||||||
|
|
||||||
|
param1.ParameterName = "@machine";
|
||||||
|
param2.ParameterName = "@usage";
|
||||||
|
param3.ParameterName = "@size";
|
||||||
|
|
||||||
|
param1.DbType = DbType.Int32;
|
||||||
|
param2.DbType = DbType.Int32;
|
||||||
|
param3.DbType = DbType.Int64;
|
||||||
|
|
||||||
|
param1.Value = (int)dataRow["id"];
|
||||||
|
|
||||||
|
const string SQL =
|
||||||
|
"INSERT INTO `memory_by_machine` (`machine`, `usage`, `size`) VALUES (@machine, @usage, @size)";
|
||||||
|
|
||||||
|
dbcmd.Parameters.Add(param1);
|
||||||
|
dbcmd.Parameters.Add(param2);
|
||||||
|
dbcmd.Parameters.Add(param3);
|
||||||
|
|
||||||
|
if(dataRow["ram"] != DBNull.Value && (int)dataRow["ram"] > 0)
|
||||||
|
{
|
||||||
|
param2.Value = MemoryUsage.Work;
|
||||||
|
param3.Value = (int)dataRow["ram"] * 1024;
|
||||||
|
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
Console.WriteLine("Adding {0} bytes of {1} memory to machine {2}", (int)param3.Value,
|
||||||
|
MemoryUsage.Work, (int)param1.Value);
|
||||||
|
|
||||||
|
dbcmd.CommandText = SQL;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataRow["rom"] != DBNull.Value && (int)dataRow["rom"] > 0)
|
||||||
|
{
|
||||||
|
param2.Value = MemoryUsage.Firmware;
|
||||||
|
param3.Value = (int)dataRow["rom"] * 1024;
|
||||||
|
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
Console.WriteLine("Adding {0} bytes of {1} memory to machine {2}", (int)param3.Value,
|
||||||
|
MemoryUsage.Firmware, (int)param1.Value);
|
||||||
|
|
||||||
|
dbcmd.CommandText = SQL;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataRow["vram"] != DBNull.Value && (int)dataRow["vram"] > 0)
|
||||||
|
{
|
||||||
|
param2.Value = MemoryUsage.Video;
|
||||||
|
param3.Value = (int)dataRow["vram"] * 1024;
|
||||||
|
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
Console.WriteLine("Adding {0} bytes of {1} memory to machine {2}", (int)param3.Value,
|
||||||
|
MemoryUsage.Video, (int)param1.Value);
|
||||||
|
|
||||||
|
dbcmd.CommandText = SQL;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
dbcmd.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Removing memory columns from table `machines`");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `ram`;\n" +
|
||||||
|
"ALTER TABLE `machines` DROP COLUMN `rom`;\n" +
|
||||||
|
"ALTER TABLE `machines` DROP COLUMN `vram`;";
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
|
||||||
|
Console.WriteLine("Setting new database version to 18...");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('18')";
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
void OptimizeDatabase()
|
void OptimizeDatabase()
|
||||||
{
|
{
|
||||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
|||||||
@@ -77,4 +77,111 @@ namespace Cicm.Database.Schemas
|
|||||||
/// <summary>Videogame console</summary>
|
/// <summary>Videogame console</summary>
|
||||||
Console = 2
|
Console = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum MemoryType
|
||||||
|
{
|
||||||
|
/// <summary>Unknown memory type</summary>
|
||||||
|
Unknown = 0,
|
||||||
|
/// <summary>Dynamic RAM</summary>
|
||||||
|
DRAM = 1,
|
||||||
|
/// <summary>Fast page mode DRAM</summary>
|
||||||
|
FPM = 2,
|
||||||
|
/// <summary>Extended data out DRAM</summary>
|
||||||
|
EDO = 3,
|
||||||
|
/// <summary>Dual-ported video DRAM</summary>
|
||||||
|
VRAM = 4,
|
||||||
|
/// <summary>Synchronous DRAM</summary>
|
||||||
|
SDRAM = 5,
|
||||||
|
/// <summary>Double data rate SDRAM</summary>
|
||||||
|
DDR = 6,
|
||||||
|
/// <summary>Double data rate SDRAM v2</summary>
|
||||||
|
DDR2 = 7,
|
||||||
|
/// <summary>Double data rate SDRAM v3</summary>
|
||||||
|
DDR3 = 8,
|
||||||
|
/// <summary>Double data rate SDRAM v4</summary>
|
||||||
|
DDR4 = 9,
|
||||||
|
/// <summary>Rambus DRAM</summary>
|
||||||
|
RDRAM = 10,
|
||||||
|
/// <summary>Synchronous graphics RAM</summary>
|
||||||
|
SGRAM = 11,
|
||||||
|
/// <summary>Pseudostatic RAM</summary>
|
||||||
|
PSRAM = 12,
|
||||||
|
/// <summary>Static RAM</summary>
|
||||||
|
SRAM = 13,
|
||||||
|
/// <summary>Read-only memory</summary>
|
||||||
|
ROM = 14,
|
||||||
|
/// <summary>Programmable ROM</summary>
|
||||||
|
PROM = 15,
|
||||||
|
/// <summary>Erasable programmable ROM</summary>
|
||||||
|
EPROM = 16,
|
||||||
|
/// <summary>Electronically-erasable programmable ROM</summary>
|
||||||
|
EEPROM = 17,
|
||||||
|
/// <summary>NAND flash</summary>
|
||||||
|
NAND = 18,
|
||||||
|
/// <summary>NOR flash</summary>
|
||||||
|
NOR = 19,
|
||||||
|
/// <summary>Resistive RAM</summary>
|
||||||
|
ReRAM = 20,
|
||||||
|
/// <summary>Conductive-bridging RAM</summary>
|
||||||
|
CBRAM = 21,
|
||||||
|
/// <summary>Domain-wall memory</summary>
|
||||||
|
DWM = 22,
|
||||||
|
/// <summary>Nano-RAM</summary>
|
||||||
|
NanoRAM = 23,
|
||||||
|
/// <summary>Millipede memory</summary>
|
||||||
|
Millipede = 24,
|
||||||
|
/// <summary>Floating Junction Gate RAM</summary>
|
||||||
|
FJG = 25,
|
||||||
|
/// <summary>Punched paper</summary>
|
||||||
|
PunchedPaper = 26,
|
||||||
|
/// <summary>Drum memory</summary>
|
||||||
|
DrumMemory = 27,
|
||||||
|
/// <summary>Magnetic-core</summary>
|
||||||
|
MagneticCore = 28,
|
||||||
|
/// <summary>Plated wire memory</summary>
|
||||||
|
PlatedWire = 29,
|
||||||
|
/// <summary>Core rope memory</summary>
|
||||||
|
CoreRope = 30,
|
||||||
|
/// <summary>Thin-film memory</summary>
|
||||||
|
ThinFilm = 31,
|
||||||
|
/// <summary>Twistor memory</summary>
|
||||||
|
Twistor = 32,
|
||||||
|
/// <summary>Bubble memory</summary>
|
||||||
|
Bubble = 33
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MemoryUsage
|
||||||
|
{
|
||||||
|
/// <summary>Unknown usage</summary>
|
||||||
|
Unknown = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Contains a boot loader (usually read-only) whose only function is to load the next memory (firmware or
|
||||||
|
/// cartridge)
|
||||||
|
/// </summary>
|
||||||
|
Bootloader = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Contains hardware initializing, some (or many) low level calls and code to load software from secondary
|
||||||
|
/// storage
|
||||||
|
/// </summary>
|
||||||
|
Firmware = 2,
|
||||||
|
/// <summary>Memory used by software running on the machine</summary>
|
||||||
|
Work = 3,
|
||||||
|
/// <summary>Memory used by the graphics processing units</summary>
|
||||||
|
Video = 4,
|
||||||
|
/// <summary>Memory used by the sound synthetizers</summary>
|
||||||
|
Sound = 5,
|
||||||
|
/// <summary>Memory used to store wave tables</summary>
|
||||||
|
Wavetable = 6,
|
||||||
|
/// <summary>Memory used as a buffer from secondary storage</summary>
|
||||||
|
StorageBuffer = 7,
|
||||||
|
/// <summary>Memory used to save arbitrary data and possible also configuration</summary>
|
||||||
|
Save = 8,
|
||||||
|
/// <summary>Memory used to save only configuration</summary>
|
||||||
|
Configuration = 9,
|
||||||
|
/// <summary>
|
||||||
|
/// Memory accessible directly to any of the processors in the machine, including graphics processors and sound
|
||||||
|
/// synthetizers
|
||||||
|
/// </summary>
|
||||||
|
Unified = 10
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -55,16 +55,10 @@ 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>Size in kibibytes of program RAM</summary>
|
|
||||||
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>
|
|
||||||
public int Rom;
|
|
||||||
/// <summary>Machine type</summary>
|
/// <summary>Machine type</summary>
|
||||||
public MachineType Type;
|
public MachineType Type;
|
||||||
/// <summary>Size in kibibytes for video RAM</summary>
|
|
||||||
public int Vram;
|
|
||||||
/// <summary>Introduction date, 0 if unknown, 1000 if prototype</summary>
|
/// <summary>Introduction date, 0 if unknown, 1000 if prototype</summary>
|
||||||
public int Year;
|
public int Year;
|
||||||
}
|
}
|
||||||
|
|||||||
47
Cicm.Database/Schemas/MemoryByMachine.cs
Normal file
47
Cicm.Database/Schemas/MemoryByMachine.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : MemoryByMachine.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 MemoryByMachine
|
||||||
|
{
|
||||||
|
/// <summary>Machine ID</summary>
|
||||||
|
public int Machine;
|
||||||
|
/// <summary>Memory type</summary>
|
||||||
|
public MemoryType Type;
|
||||||
|
/// <summary>Memory usage</summary>
|
||||||
|
public MemoryUsage Usage;
|
||||||
|
/// <summary>Memory size in bytes</summary>
|
||||||
|
public long Size;
|
||||||
|
/// <summary>Memory speed in Hz</summary>
|
||||||
|
public double Speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
135
Cicm.Database/Schemas/Sql/V18.cs
Normal file
135
Cicm.Database/Schemas/Sql/V18.cs
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : V18.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 V18
|
||||||
|
{
|
||||||
|
public static readonly string Admins = V17.Admins;
|
||||||
|
|
||||||
|
public static readonly string BrowserTests = V17.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 ('18');";
|
||||||
|
|
||||||
|
public static readonly string Companies = V17.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" +
|
||||||
|
"`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_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 = V17.DiskFormats;
|
||||||
|
|
||||||
|
public static readonly string Forbidden = V17.Forbidden;
|
||||||
|
|
||||||
|
public static readonly string Gpus = V17.Gpus;
|
||||||
|
|
||||||
|
public static readonly string Logs = V17.Logs;
|
||||||
|
|
||||||
|
public static readonly string MoneyDonations = V17.MoneyDonations;
|
||||||
|
|
||||||
|
public static readonly string News = V17.News;
|
||||||
|
|
||||||
|
public static readonly string OwnedComputers = V17.OwnedComputers;
|
||||||
|
|
||||||
|
public static readonly string OwnedConsoles = V17.OwnedConsoles;
|
||||||
|
|
||||||
|
public static readonly string Processors = V17.Processors;
|
||||||
|
|
||||||
|
public static readonly string SoundSynths = V17.SoundSynths;
|
||||||
|
|
||||||
|
public static readonly string MachinesForeignKeys = V17.MachinesForeignKeys;
|
||||||
|
|
||||||
|
public static readonly string Iso3166Numeric = V17.Iso3166Numeric;
|
||||||
|
|
||||||
|
public static readonly string Iso3166NumericValues = V17.Iso3166NumericValues;
|
||||||
|
|
||||||
|
public static readonly string CompaniesForeignKeys = V17.CompaniesForeignKeys;
|
||||||
|
|
||||||
|
public static readonly string CompanyLogos = V17.CompanyLogos;
|
||||||
|
|
||||||
|
public static readonly string CompanyDescriptions = V17.CompanyDescriptions;
|
||||||
|
|
||||||
|
public static readonly string InstructionSets = V17.InstructionSets;
|
||||||
|
|
||||||
|
public static readonly string InstructionSetExtensions = V17.InstructionSetExtensions;
|
||||||
|
|
||||||
|
public static readonly string InstructionSetExtensionsByProcessor = V17.InstructionSetExtensionsByProcessor;
|
||||||
|
|
||||||
|
public static readonly string ProcessorsByMachine = V17.ProcessorsByMachine;
|
||||||
|
|
||||||
|
public static readonly string GpusByMachine = V17.GpusByMachine;
|
||||||
|
|
||||||
|
public static readonly string SoundByMachine = V17.SoundByMachine;
|
||||||
|
|
||||||
|
public static readonly string MemoryByMachine = "CREATE TABLE `memory_by_machine` (\n" +
|
||||||
|
"`machine` INT NOT NULL,\n" +
|
||||||
|
"`type` INT NOT NULL DEFAULT 0,\n" +
|
||||||
|
"`usage` INT NOT NULL DEFAULT 0,\n" +
|
||||||
|
"`size` BIGINT DEFAULT NULL,\n" +
|
||||||
|
"`speed` DOUBLE DEFAULT NULL,\n" +
|
||||||
|
"KEY `idx_memory_by_machine_machine` (`machine`),\n" +
|
||||||
|
"KEY `idx_memory_by_machine_type` (`type`),\n" +
|
||||||
|
"KEY `idx_memory_by_machine_usage` (`usage`),\n" +
|
||||||
|
"KEY `idx_memory_by_machine_size` (`size`),\n" +
|
||||||
|
"KEY `idx_memory_by_machine_speed` (`speed`),\n" +
|
||||||
|
"CONSTRAINT `fk_memory_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,14 +48,12 @@ namespace cicm_web.Models
|
|||||||
public DiskFormat Hdd2;
|
public DiskFormat Hdd2;
|
||||||
public DiskFormat Hdd3;
|
public DiskFormat Hdd3;
|
||||||
public int Id;
|
public int Id;
|
||||||
|
public MemoryByMachine[] Memories;
|
||||||
public string Model;
|
public string Model;
|
||||||
public ProcessorByMachine[] Processors;
|
public ProcessorByMachine[] Processors;
|
||||||
public int Ram;
|
|
||||||
public string Resolution;
|
public string Resolution;
|
||||||
public int Rom;
|
|
||||||
public SoundByMachine[] SoundSynths;
|
public SoundByMachine[] SoundSynths;
|
||||||
public MachineType Type;
|
public MachineType Type;
|
||||||
public int Vram;
|
|
||||||
public int Year;
|
public int Year;
|
||||||
|
|
||||||
public static Machine[] GetAllItems()
|
public static Machine[] GetAllItems()
|
||||||
@@ -97,14 +95,12 @@ namespace cicm_web.Models
|
|||||||
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,
|
|
||||||
Resolution = dbItem.Resolution,
|
Resolution = dbItem.Resolution,
|
||||||
Rom = dbItem.Rom,
|
|
||||||
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)
|
SoundSynths = SoundByMachine.GetAllItems(dbItem.Id),
|
||||||
|
Memories = MemoryByMachine.GetAllItems(dbItem.Id)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(dbItem.Disk1 > 0)
|
if(dbItem.Disk1 > 0)
|
||||||
|
|||||||
64
cicm_web/Models/MemoryByMachine.cs
Normal file
64
cicm_web/Models/MemoryByMachine.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// 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;
|
||||||
|
using Cicm.Database.Schemas;
|
||||||
|
|
||||||
|
namespace cicm_web.Models
|
||||||
|
{
|
||||||
|
public class MemoryByMachine
|
||||||
|
{
|
||||||
|
public MemoryType Type;
|
||||||
|
public MemoryUsage Usage;
|
||||||
|
public long Size;
|
||||||
|
public double Speed;
|
||||||
|
|
||||||
|
public static MemoryByMachine[] GetAllItems(int machineId)
|
||||||
|
{
|
||||||
|
List<Cicm.Database.Schemas.MemoryByMachine> dbItems = null;
|
||||||
|
bool? result =
|
||||||
|
Program.Database?.Operations.GetMemoryByMachine(out dbItems, machineId);
|
||||||
|
if(result == null || result.Value == false || dbItems == null) return null;
|
||||||
|
|
||||||
|
List<MemoryByMachine> items = new List<MemoryByMachine>();
|
||||||
|
|
||||||
|
foreach(Cicm.Database.Schemas.MemoryByMachine dbItem in dbItems)
|
||||||
|
items.Add(new MemoryByMachine
|
||||||
|
{
|
||||||
|
Type =dbItem.Type,
|
||||||
|
Usage =dbItem.Usage,
|
||||||
|
Size =dbItem.Size,
|
||||||
|
Speed =dbItem.Speed
|
||||||
|
});
|
||||||
|
|
||||||
|
return items.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -329,64 +329,42 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
<tr>
|
@if(Model.Memories != null && Model.Memories.Length > 0)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
<th scope=row>
|
<th scope=row>
|
||||||
<div align=right>
|
<div align=right>
|
||||||
Base RAM memory
|
Memory
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
@if(Model.Ram > 1024)
|
<td>
|
||||||
|
<table>
|
||||||
|
@foreach(MemoryByMachine memory in Model.Memories)
|
||||||
{
|
{
|
||||||
if(Model.Ram > 1048576)
|
string memValue;
|
||||||
{
|
if(memory.Size > 1073741824) { memValue = $"{memory.Size / 1073741824} GiB"; }
|
||||||
<td>@($"{Model.Ram / 1048576}") Gbytes</td>
|
else if(memory.Size > 1048576) { memValue = $"{memory.Size / 1048576} MiB"; }
|
||||||
}
|
else if(memory.Size > 1024) { memValue = $"{memory.Size / 1024} KiB"; }
|
||||||
|
else if(memory.Size > 0) { memValue = $"{memory.Size} bytes"; }
|
||||||
else
|
else
|
||||||
{
|
{ memValue = "Unknown size"; }
|
||||||
<td>@($"{Model.Ram / 1024}") Mbytes</td>
|
|
||||||
}
|
string speedValue;
|
||||||
}
|
if(memory.Speed > 1000000000) { speedValue = $"{memory.Speed / 1000000000} GHz"; }
|
||||||
|
else if(memory.Speed > 1000000) { speedValue = $"{memory.Speed / 1000000} MHz"; }
|
||||||
|
else if(memory.Speed > 1000) { speedValue = $"{memory.Speed / 1000} KHz"; }
|
||||||
|
else if(memory.Speed > 0) { speedValue = $"{memory.Speed} Hz"; }
|
||||||
else
|
else
|
||||||
{
|
{ speedValue = "unknown speed"; }
|
||||||
if(Model.Ram == 0)
|
|
||||||
{
|
<tr>
|
||||||
<td>Unknown data</td>
|
<td>@memValue of @memory.Usage memory (@memory.Type at @speedValue)</td>
|
||||||
|
</tr>
|
||||||
}
|
}
|
||||||
else
|
</table>
|
||||||
{
|
</td>
|
||||||
<td>@Model.Ram Kbytes</td>
|
</tr>
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope=row>
|
|
||||||
<div align=right>
|
|
||||||
ROM
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
@if(Model.Rom > 1024)
|
|
||||||
{
|
|
||||||
if(Model.Rom > 1048576)
|
|
||||||
{
|
|
||||||
<td>@($"{Model.Rom / 1048576}") Gbytes</td>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<td>@($"{Model.Rom / 1024}") Mbytes</td>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(Model.Rom == 0)
|
|
||||||
{
|
|
||||||
<td>Unknown data</td>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<td>@Model.Rom Kbytes</td>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</tr>
|
|
||||||
@if(Model.Gpus != null && Model.Gpus.Length > 0)
|
@if(Model.Gpus != null && Model.Gpus.Length > 0)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
@@ -511,35 +489,6 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
<tr>
|
|
||||||
<th scope=row>
|
|
||||||
<div align=right>
|
|
||||||
Video memory
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
@if(Model.Vram > 1024)
|
|
||||||
{
|
|
||||||
if(Model.Vram > 1048576)
|
|
||||||
{
|
|
||||||
<td>@($"{Model.Vram / 1048576}") Gbytes</td>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<td>@($"{Model.Vram / 1024}") Mbytes</td>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(Model.Vram == 0)
|
|
||||||
{
|
|
||||||
<td>Unknown data</td>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<td>@Model.Vram Kbytes</td>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th scope=row>
|
<th scope=row>
|
||||||
<div align=right>
|
<div align=right>
|
||||||
|
|||||||
@@ -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.209</Version>
|
<Version>3.0.99.215</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