mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Update DB to version 20: Machines can have an arbitrary number of storage,
so use an interconnection table, `storage_by_machine`.
This commit is contained in:
@@ -1,282 +0,0 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : DiskFormat.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains operations to manage disk formats.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
public partial class Operations
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all disk formats
|
||||
/// </summary>
|
||||
/// <param name="entries">All disk formats</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetDiskFormats(out List<DiskFormat> entries)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting all disk formats...");
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
const string SQL = "SELECT * from disk_formats";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = SQL;
|
||||
DataSet dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = DiskFormatsFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting disk formats.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified number of disk formats since the specified start
|
||||
/// </summary>
|
||||
/// <param name="entries">List of disk formats</param>
|
||||
/// <param name="start">Start of query</param>
|
||||
/// <param name="count">How many entries to retrieve</param>
|
||||
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||
public bool GetDiskFormats(out List<DiskFormat> entries, ulong start, ulong count)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting {0} disk formats from {1}...", count, start);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM disk_formats LIMIT {start}, {count}";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = sql;
|
||||
DataSet dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
entries = DiskFormatsFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting disk formats.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets disk format by specified id
|
||||
/// </summary>
|
||||
/// <param name="id">Id</param>
|
||||
/// <returns>Disk format with specified id, <c>null</c> if not found or error</returns>
|
||||
public DiskFormat GetDiskFormat(int id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting disk format with id {0}...", id);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * from disk_formats WHERE id = '{id}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dbCmd.CommandText = sql;
|
||||
DataSet dataSet = new DataSet();
|
||||
dataAdapter.SelectCommand = dbCmd;
|
||||
dataAdapter.Fill(dataSet);
|
||||
|
||||
List<DiskFormat> entries = DiskFormatsFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting disk format.");
|
||||
Console.WriteLine(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counts the number of disk formats in the database
|
||||
/// </summary>
|
||||
/// <returns>Entries in database</returns>
|
||||
public long CountDiskFormats()
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Counting disk formats...");
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
dbcmd.CommandText = "SELECT COUNT(*) FROM disk_formats";
|
||||
object count = dbcmd.ExecuteScalar();
|
||||
dbcmd.Dispose();
|
||||
try { return Convert.ToInt64(count); }
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new disk format to the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Entry to add</param>
|
||||
/// <param name="id">ID of added entry</param>
|
||||
/// <returns><c>true</c> if added correctly, <c>false</c> otherwise</returns>
|
||||
public bool AddDiskFormat(DiskFormat entry, out long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.Write("Adding disk format `{0}`...", entry.Description);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandDiskFormat(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL = "INSERT INTO disk_formats (description)" + " VALUES (@description)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
dbcmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbcmd.Dispose();
|
||||
|
||||
id = dbCore.LastInsertRowId;
|
||||
|
||||
#if DEBUG
|
||||
Console.WriteLine(" id {0}", id);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updated a disk format in the database
|
||||
/// </summary>
|
||||
/// <param name="entry">Updated entry</param>
|
||||
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||
public bool UpdateDiskFormat(DiskFormat entry)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Updating disk format `{0}`...", entry.Description);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = GetCommandDiskFormat(entry);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = "UPDATE disk_formats SET description = @description " + $"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
dbcmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbcmd.Dispose();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a disk format from the database
|
||||
/// </summary>
|
||||
/// <param name="id">ID of entry to remove</param>
|
||||
/// <returns><c>true</c> if removed correctly, <c>false</c> otherwise</returns>
|
||||
public bool RemoveDiskFormat(long id)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Removing disk format widh id `{0}`...", id);
|
||||
#endif
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql = $"DELETE FROM disk_formats WHERE id = '{id}';";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
dbcmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbcmd.Dispose();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetCommandDiskFormat(DiskFormat entry)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@description";
|
||||
|
||||
param1.DbType = DbType.String;
|
||||
|
||||
param1.Value = entry.Description;
|
||||
|
||||
dbcmd.Parameters.Add(param1);
|
||||
|
||||
return dbcmd;
|
||||
}
|
||||
|
||||
static List<DiskFormat> DiskFormatsFromDataTable(DataTable dataTable)
|
||||
{
|
||||
List<DiskFormat> entries = new List<DiskFormat>();
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
DiskFormat entry =
|
||||
new DiskFormat {Id = (int)dataRow["id"], Description = (string)dataRow["description"]};
|
||||
|
||||
entries.Add(entry);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,123 +49,123 @@ namespace Cicm.Database
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
|
||||
Console.WriteLine("Creating table `admins`");
|
||||
dbCmd.CommandText = V19.Admins;
|
||||
dbCmd.CommandText = V20.Admins;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `browser_tests`");
|
||||
dbCmd.CommandText = V19.BrowserTests;
|
||||
dbCmd.CommandText = V20.BrowserTests;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `cicm_db`");
|
||||
dbCmd.CommandText = V19.CicmDb;
|
||||
dbCmd.CommandText = V20.CicmDb;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `companies`");
|
||||
dbCmd.CommandText = V19.Companies;
|
||||
dbCmd.CommandText = V20.Companies;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `machines`");
|
||||
dbCmd.CommandText = V19.Machines;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `disk_formats`");
|
||||
dbCmd.CommandText = V19.DiskFormats;
|
||||
dbCmd.CommandText = V20.Machines;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `forbidden`");
|
||||
dbCmd.CommandText = V19.Forbidden;
|
||||
dbCmd.CommandText = V20.Forbidden;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `gpus`");
|
||||
dbCmd.CommandText = V19.Gpus;
|
||||
dbCmd.CommandText = V20.Gpus;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `log`");
|
||||
dbCmd.CommandText = V19.Logs;
|
||||
dbCmd.CommandText = V20.Logs;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `money_donations`");
|
||||
dbCmd.CommandText = V19.MoneyDonations;
|
||||
dbCmd.CommandText = V20.MoneyDonations;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `news`");
|
||||
dbCmd.CommandText = V19.News;
|
||||
dbCmd.CommandText = V20.News;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `owned_computers`");
|
||||
dbCmd.CommandText = V19.OwnedComputers;
|
||||
dbCmd.CommandText = V20.OwnedComputers;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `owned_consoles`");
|
||||
dbCmd.CommandText = V19.OwnedConsoles;
|
||||
dbCmd.CommandText = V20.OwnedConsoles;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `instruction_sets`");
|
||||
dbCmd.CommandText = V19.InstructionSets;
|
||||
dbCmd.CommandText = V20.InstructionSets;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `instruction_set_extensions`");
|
||||
dbCmd.CommandText = V19.InstructionSetExtensions;
|
||||
dbCmd.CommandText = V20.InstructionSetExtensions;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `processors`");
|
||||
dbCmd.CommandText = V19.Processors;
|
||||
dbCmd.CommandText = V20.Processors;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `instruction_set_extensions_by_processor`");
|
||||
dbCmd.CommandText = V19.InstructionSetExtensionsByProcessor;
|
||||
dbCmd.CommandText = V20.InstructionSetExtensionsByProcessor;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `sound_synths`");
|
||||
dbCmd.CommandText = V19.SoundSynths;
|
||||
dbCmd.CommandText = V20.SoundSynths;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `iso3166_1_numeric`");
|
||||
dbCmd.CommandText = V19.Iso3166Numeric;
|
||||
dbCmd.CommandText = V20.Iso3166Numeric;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Filling table `iso3166_1_numeric`");
|
||||
dbCmd.CommandText = V19.Iso3166NumericValues;
|
||||
dbCmd.CommandText = V20.Iso3166NumericValues;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating foreign keys for table `companies`");
|
||||
dbCmd.CommandText = V19.CompaniesForeignKeys;
|
||||
dbCmd.CommandText = V20.CompaniesForeignKeys;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating foreign keys for table `machines`");
|
||||
dbCmd.CommandText = V19.MachinesForeignKeys;
|
||||
dbCmd.CommandText = V20.MachinesForeignKeys;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `company_logos`");
|
||||
dbCmd.CommandText = V19.CompanyLogos;
|
||||
dbCmd.CommandText = V20.CompanyLogos;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `company_descriptions`");
|
||||
dbCmd.CommandText = V19.CompanyDescriptions;
|
||||
dbCmd.CommandText = V20.CompanyDescriptions;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `processors_by_machine`");
|
||||
dbCmd.CommandText = V19.ProcessorsByMachine;
|
||||
dbCmd.CommandText = V20.ProcessorsByMachine;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `gpus_by_machine`");
|
||||
dbCmd.CommandText = V19.GpusByMachine;
|
||||
dbCmd.CommandText = V20.GpusByMachine;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `sound_by_machine`");
|
||||
dbCmd.CommandText = V19.SoundByMachine;
|
||||
dbCmd.CommandText = V20.SoundByMachine;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `memory_by_machine`");
|
||||
dbCmd.CommandText = V19.MemoryByMachine;
|
||||
dbCmd.CommandText = V20.MemoryByMachine;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `resolutions`");
|
||||
dbCmd.CommandText = V19.Resolutions;
|
||||
dbCmd.CommandText = V20.Resolutions;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `resolutions_by_gpu`");
|
||||
dbCmd.CommandText = V19.ResolutionsByGpu;
|
||||
dbCmd.CommandText = V20.ResolutionsByGpu;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine("Creating table `storage_by_machine`");
|
||||
dbCmd.CommandText = V20.StorageByMachine;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -214,9 +214,7 @@ namespace Cicm.Database
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
const string SQL =
|
||||
"INSERT INTO machines (company, year, model, colors, res, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2, " +
|
||||
"type) VALUES (@company, @year, @model, @colors, @res, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, " +
|
||||
"@cap2, @type)";
|
||||
"INSERT INTO machines (company, year, model, type) VALUES (@company, @year, @model, @type)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
|
||||
@@ -248,11 +246,8 @@ namespace Cicm.Database
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql =
|
||||
"UPDATE machines SET company = @company, year = @year, model = @model, colors = @colors, res = @res, " +
|
||||
"hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2, " +
|
||||
"type = @type " +
|
||||
$"WHERE id = {entry.Id}";
|
||||
string sql = "UPDATE machines SET company = @company, year = @year, model = @model, type = @type " +
|
||||
$"WHERE id = {entry.Id}";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
|
||||
@@ -293,65 +288,30 @@ namespace Cicm.Database
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
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();
|
||||
IDbDataParameter param11 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param2 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param3 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param4 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@company";
|
||||
param2.ParameterName = "@year";
|
||||
param3.ParameterName = "@model";
|
||||
param4.ParameterName = "@hdd1";
|
||||
param5.ParameterName = "@hdd2";
|
||||
param6.ParameterName = "@hdd3";
|
||||
param7.ParameterName = "@disk1";
|
||||
param8.ParameterName = "@cap1";
|
||||
param9.ParameterName = "@disk2";
|
||||
param10.ParameterName = "@cap2";
|
||||
param11.ParameterName = "@type";
|
||||
param1.ParameterName = "@company";
|
||||
param2.ParameterName = "@year";
|
||||
param3.ParameterName = "@model";
|
||||
param4.ParameterName = "@type";
|
||||
|
||||
param1.DbType = DbType.Int32;
|
||||
param2.DbType = DbType.Int32;
|
||||
param3.DbType = DbType.String;
|
||||
param4.DbType = DbType.Int32;
|
||||
param5.DbType = DbType.Int32;
|
||||
param6.DbType = DbType.Int32;
|
||||
param7.DbType = DbType.Int32;
|
||||
param8.DbType = DbType.String;
|
||||
param9.DbType = DbType.Int32;
|
||||
param10.DbType = DbType.String;
|
||||
param11.DbType = DbType.Int32;
|
||||
param1.DbType = DbType.Int32;
|
||||
param2.DbType = DbType.Int32;
|
||||
param3.DbType = DbType.String;
|
||||
param4.DbType = DbType.Int32;
|
||||
|
||||
param1.Value = entry.Company;
|
||||
param2.Value = entry.Year;
|
||||
param3.Value = entry.Model;
|
||||
param4.Value = entry.Hdd1;
|
||||
param5.Value = entry.Hdd2;
|
||||
param6.Value = entry.Hdd3;
|
||||
param7.Value = entry.Disk1;
|
||||
param8.Value = entry.Cap1;
|
||||
param9.Value = entry.Disk2;
|
||||
param10.Value = entry.Cap2;
|
||||
param11.Value = entry.Type;
|
||||
param1.Value = entry.Company;
|
||||
param2.Value = entry.Year;
|
||||
param3.Value = entry.Model;
|
||||
param4.Value = entry.Type;
|
||||
|
||||
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);
|
||||
dbcmd.Parameters.Add(param11);
|
||||
|
||||
return dbcmd;
|
||||
}
|
||||
@@ -368,13 +328,6 @@ namespace Cicm.Database
|
||||
Company = (int)dataRow["company"],
|
||||
Year = (int)dataRow["year"],
|
||||
Model = (string)dataRow["model"],
|
||||
Hdd1 = (int)dataRow["hdd1"],
|
||||
Hdd2 = dataRow["hdd2"] == DBNull.Value ? 0 : (int)dataRow["hdd2"],
|
||||
Hdd3 = dataRow["hdd3"] == DBNull.Value ? 0 : (int)dataRow["hdd3"],
|
||||
Disk1 = (int)dataRow["disk1"],
|
||||
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"]
|
||||
};
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Cicm.Database
|
||||
public partial class Operations
|
||||
{
|
||||
/// <summary>Last known database version</summary>
|
||||
const int DB_VERSION = 19;
|
||||
const int DB_VERSION = 20;
|
||||
/// <summary>The column with this value indicates there is no item of this type.</summary>
|
||||
public const int DB_NONE = -1;
|
||||
/// <summary>
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
@@ -269,10 +268,6 @@ namespace Cicm.Database
|
||||
IDbDataParameter param11 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param12 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param13 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param14 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param15 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param16 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param17 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@db_id";
|
||||
param2.ParameterName = "@date";
|
||||
@@ -287,10 +282,6 @@ namespace Cicm.Database
|
||||
param11.ParameterName = "@ram";
|
||||
param12.ParameterName = "@vram";
|
||||
param13.ParameterName = "@rigid";
|
||||
param14.ParameterName = "@disk1";
|
||||
param15.ParameterName = "@cap1";
|
||||
param16.ParameterName = "@disk2";
|
||||
param17.ParameterName = "@cap2";
|
||||
|
||||
param1.DbType = DbType.Int32;
|
||||
param2.DbType = DbType.String;
|
||||
@@ -305,10 +296,6 @@ namespace Cicm.Database
|
||||
param11.DbType = DbType.Int32;
|
||||
param12.DbType = DbType.Int32;
|
||||
param13.DbType = DbType.String;
|
||||
param14.DbType = DbType.Int32;
|
||||
param15.DbType = DbType.Int32;
|
||||
param16.DbType = DbType.Int32;
|
||||
param17.DbType = DbType.Int32;
|
||||
|
||||
param1.Value = entry.ComputerId;
|
||||
param2.Value = entry.Acquired;
|
||||
@@ -323,10 +310,6 @@ namespace Cicm.Database
|
||||
param11.Value = entry.Ram;
|
||||
param12.Value = entry.Vram;
|
||||
param13.Value = entry.Rigid;
|
||||
param14.Value = entry.Disk1;
|
||||
param15.Value = entry.Cap1;
|
||||
param16.Value = entry.Disk2;
|
||||
param17.Value = entry.Cap2;
|
||||
|
||||
dbcmd.Parameters.Add(param1);
|
||||
dbcmd.Parameters.Add(param2);
|
||||
@@ -341,10 +324,6 @@ namespace Cicm.Database
|
||||
dbcmd.Parameters.Add(param11);
|
||||
dbcmd.Parameters.Add(param12);
|
||||
dbcmd.Parameters.Add(param13);
|
||||
dbcmd.Parameters.Add(param14);
|
||||
dbcmd.Parameters.Add(param15);
|
||||
dbcmd.Parameters.Add(param16);
|
||||
dbcmd.Parameters.Add(param17);
|
||||
|
||||
return dbcmd;
|
||||
}
|
||||
@@ -370,11 +349,7 @@ namespace Cicm.Database
|
||||
Mhz2 = (float)dataRow["mhz2"],
|
||||
Ram = (int)dataRow["ram"],
|
||||
Vram = (int)dataRow["vram"],
|
||||
Rigid = (string)dataRow["rigid"],
|
||||
Disk1 = (int)dataRow["disk1"],
|
||||
Cap1 = (int)dataRow["cap1"],
|
||||
Disk2 = (int)dataRow["disk2"],
|
||||
Cap2 = (int)dataRow["cap2"]
|
||||
Rigid = (string)dataRow["rigid"]
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
|
||||
127
Cicm.Database/Operations/StorageByMachine.cs
Normal file
127
Cicm.Database/Operations/StorageByMachine.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : StorageByMachine.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains operations to manage storage.
|
||||
//
|
||||
// --[ 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 storage 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 GetStorageByMachines(out List<StorageByMachine> entries, int machineId)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Getting all storage for machine {0}...", machineId);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM storage_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 = StorageByMachinesFromDataTable(dataSet.Tables[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error getting storage by machine.");
|
||||
Console.WriteLine(ex);
|
||||
entries = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
IDbCommand GetCommandStorageByMachine(StorageByMachine entry)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param2 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param3 = dbcmd.CreateParameter();
|
||||
IDbDataParameter param4 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@machine";
|
||||
param2.ParameterName = "@type";
|
||||
param3.ParameterName = "@interface";
|
||||
param4.ParameterName = "@capacity";
|
||||
|
||||
param1.DbType = DbType.Int32;
|
||||
param2.DbType = DbType.Int32;
|
||||
param3.DbType = DbType.Int32;
|
||||
param4.DbType = DbType.Int64;
|
||||
|
||||
param1.Value = entry.Machine;
|
||||
param2.Value = entry.Type;
|
||||
param3.Value = entry.Interface;
|
||||
param4.Value = entry.Capacity == 0 ? (object)null : entry.Capacity;
|
||||
|
||||
dbcmd.Parameters.Add(param1);
|
||||
dbcmd.Parameters.Add(param2);
|
||||
dbcmd.Parameters.Add(param3);
|
||||
dbcmd.Parameters.Add(param4);
|
||||
|
||||
return dbcmd;
|
||||
}
|
||||
|
||||
static List<StorageByMachine> StorageByMachinesFromDataTable(DataTable dataTable)
|
||||
{
|
||||
List<StorageByMachine> entries = new List<StorageByMachine>();
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
StorageByMachine entry = new StorageByMachine
|
||||
{
|
||||
Machine = (int)dataRow["machine"],
|
||||
Type = (StorageType)dataRow["type"],
|
||||
Interface = (StorageInterface)dataRow["interface"],
|
||||
Capacity = dataRow["capacity"] == DBNull.Value ? 0 : (long)dataRow["capacity"]
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,6 +164,11 @@ namespace Cicm.Database
|
||||
UpdateDatabaseToV19();
|
||||
break;
|
||||
}
|
||||
case 19:
|
||||
{
|
||||
UpdateDatabaseToV20();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OptimizeDatabase();
|
||||
@@ -2172,6 +2177,240 @@ namespace Cicm.Database
|
||||
dbCmd.Dispose();
|
||||
}
|
||||
|
||||
void UpdateDatabaseToV20()
|
||||
{
|
||||
Console.WriteLine("Updating database to version 20");
|
||||
|
||||
Console.WriteLine("Creating table `storage_by_machine`");
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbCmd.Transaction = trans;
|
||||
dbCmd.CommandText = V20.StorageByMachine;
|
||||
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();
|
||||
IDbDataParameter param4 = dbcmd.CreateParameter();
|
||||
|
||||
param1.ParameterName = "@machine";
|
||||
param2.ParameterName = "@type";
|
||||
param3.ParameterName = "@interface";
|
||||
param4.ParameterName = "@capacity";
|
||||
|
||||
param1.DbType = DbType.Int32;
|
||||
param2.DbType = DbType.Int32;
|
||||
param3.DbType = DbType.Int32;
|
||||
param4.DbType = DbType.Int64;
|
||||
|
||||
param1.Value = (int)dataRow["id"];
|
||||
|
||||
const string SQL =
|
||||
"INSERT INTO `storage_by_machine` (`machine`, `type`, `interface`, `capacity`) VALUES (@machine, @type, @interface, @capacity)";
|
||||
|
||||
dbcmd.Parameters.Add(param1);
|
||||
dbcmd.Parameters.Add(param2);
|
||||
dbcmd.Parameters.Add(param3);
|
||||
dbcmd.Parameters.Add(param4);
|
||||
|
||||
foreach(string media in new[] {"hdd1", "hdd2", "hdd3", "disk1", "disk2"})
|
||||
{
|
||||
if(dataRow[media] == DBNull.Value || (int)dataRow[media] == 30) continue;
|
||||
|
||||
param3.Value = StorageInterface.Unknown;
|
||||
|
||||
switch((int)dataRow[media])
|
||||
{
|
||||
case 1:
|
||||
param2.Value = StorageType.CompactFloppy;
|
||||
break;
|
||||
case 3:
|
||||
case 5:
|
||||
param2.Value = StorageType.Microfloppy;
|
||||
break;
|
||||
case 4:
|
||||
param2.Value = StorageType.Minifloppy;
|
||||
break;
|
||||
case 7:
|
||||
param2.Value = StorageType.CompactDisc;
|
||||
break;
|
||||
case 8:
|
||||
param2.Value = StorageType.CompactCassette;
|
||||
break;
|
||||
case 9:
|
||||
param2.Value = StorageType.CompactFlash;
|
||||
break;
|
||||
case 11:
|
||||
param2.Value = StorageType.Dvd;
|
||||
break;
|
||||
case 12:
|
||||
param2.Value = StorageType.GDROM;
|
||||
break;
|
||||
case 13:
|
||||
param2.Value = StorageType.ZIP100;
|
||||
break;
|
||||
case 14:
|
||||
param2.Value = StorageType.LS120;
|
||||
break;
|
||||
case 15:
|
||||
param2.Value = StorageType.MagnetoOptical;
|
||||
break;
|
||||
case 17:
|
||||
param2.Value = StorageType.Microdrive;
|
||||
break;
|
||||
case 18:
|
||||
param2.Value = StorageType.MMC;
|
||||
break;
|
||||
case 20:
|
||||
param2.Value = StorageType.SecureDigital;
|
||||
break;
|
||||
case 21:
|
||||
param2.Value = StorageType.SmartMedia;
|
||||
break;
|
||||
case 23:
|
||||
param2.Value = StorageType.PunchedCard;
|
||||
break;
|
||||
case 24:
|
||||
param2.Value = StorageType.HardDisk;
|
||||
param3.Value = StorageInterface.ACSI;
|
||||
break;
|
||||
case 25:
|
||||
case 29:
|
||||
param2.Value = StorageType.HardDisk;
|
||||
param3.Value = StorageInterface.ATA;
|
||||
break;
|
||||
case 26:
|
||||
param2.Value = StorageType.HardDisk;
|
||||
param3.Value = StorageInterface.ESDI;
|
||||
break;
|
||||
case 27:
|
||||
param2.Value = StorageType.HardDisk;
|
||||
param3.Value = StorageInterface.FireWire;
|
||||
break;
|
||||
case 28:
|
||||
param2.Value = StorageType.CompactFloppy;
|
||||
break;
|
||||
case 32:
|
||||
case 35:
|
||||
param2.Value = StorageType.HardDisk;
|
||||
param3.Value = StorageInterface.ST506;
|
||||
break;
|
||||
case 33:
|
||||
param2.Value = StorageType.HardDisk;
|
||||
param3.Value = StorageInterface.SASI;
|
||||
break;
|
||||
case 34:
|
||||
case 41:
|
||||
param2.Value = StorageType.HardDisk;
|
||||
param3.Value = StorageInterface.SCSI;
|
||||
break;
|
||||
case 40:
|
||||
param2.Value = StorageType.Floppy;
|
||||
break;
|
||||
case 43:
|
||||
param2.Value = StorageType.Bluray;
|
||||
break;
|
||||
case 44:
|
||||
param2.Value = StorageType.GOD;
|
||||
break;
|
||||
case 45:
|
||||
param2.Value = StorageType.WOD;
|
||||
break;
|
||||
default:
|
||||
param2.Value = StorageType.Unknown;
|
||||
break;
|
||||
}
|
||||
|
||||
param4.Value = null;
|
||||
|
||||
switch(media)
|
||||
{
|
||||
case "disk1":
|
||||
if(dataRow["cap1"] != DBNull.Value)
|
||||
if(int.TryParse((string)dataRow["cap1"], out int cap))
|
||||
param4.Value = cap == 0
|
||||
? (object)null
|
||||
: (StorageType)param2.Value == StorageType.CompactCassette
|
||||
? cap
|
||||
: cap * 1024;
|
||||
break;
|
||||
case "disk2":
|
||||
if(dataRow["cap2"] != DBNull.Value)
|
||||
if(int.TryParse((string)dataRow["cap2"], out int cap))
|
||||
param4.Value = cap == 0
|
||||
? (object)null
|
||||
: (StorageType)param2.Value == StorageType.CompactCassette
|
||||
? cap
|
||||
: cap * 1024;
|
||||
break;
|
||||
}
|
||||
|
||||
trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
Console.WriteLine("Adding storage type {0} with interface {1} to machine {2}",
|
||||
(StorageType)param2.Value, (StorageInterface)param3.Value, (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 FOREIGN KEY `fk_machines_disk1`;\n" +
|
||||
"ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_disk2`;\n" +
|
||||
"ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_hdd1`;\n" +
|
||||
"ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_hdd2`;\n" +
|
||||
"ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_hdd3`;\n" +
|
||||
"ALTER TABLE `machines` DROP COLUMN `hdd1`;\n" +
|
||||
"ALTER TABLE `machines` DROP COLUMN `hdd2`;\n" +
|
||||
"ALTER TABLE `machines` DROP COLUMN `hdd3`;\n" +
|
||||
"ALTER TABLE `machines` DROP COLUMN `disk1`;\n" +
|
||||
"ALTER TABLE `machines` DROP COLUMN `cap1`;\n" +
|
||||
"ALTER TABLE `machines` DROP COLUMN `disk2`;\n" +
|
||||
"ALTER TABLE `machines` DROP COLUMN `cap2`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbCmd.Dispose();
|
||||
|
||||
Console.WriteLine("Removing table `disk_formats`");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
trans = dbCon.BeginTransaction();
|
||||
dbCmd.Transaction = trans;
|
||||
dbCmd.CommandText = "DROP TABLE `disk_formats`;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbCmd.Dispose();
|
||||
|
||||
Console.WriteLine("Setting new database version to 20...");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('20')";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
dbCmd.Dispose();
|
||||
}
|
||||
|
||||
void OptimizeDatabase()
|
||||
{
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
|
||||
@@ -184,4 +184,237 @@ namespace Cicm.Database.Schemas
|
||||
/// </summary>
|
||||
Unified = 10
|
||||
}
|
||||
|
||||
public enum StorageType
|
||||
{
|
||||
/// <summary>Contains an empty interface for user connection</summary>
|
||||
Empty = -1,
|
||||
/// <summary>Unknown</summary>
|
||||
Unknown = 0,
|
||||
/// <summary>Unknown magneto-optical</summary>
|
||||
MagnetoOptical = 1,
|
||||
/// <summary>Generic hard disk</summary>
|
||||
HardDisk = 2,
|
||||
/// <summary>Microdrive type hard disk</summary>
|
||||
Microdrive = 3,
|
||||
/// <summary>Zoned hard disk</summary>
|
||||
ZonedHardDisk = 4,
|
||||
/// <summary>USB flash drives</summary>
|
||||
FlashDrive = 5,
|
||||
/// <summary>CompactDisc</summary>
|
||||
CompactDisc = 6,
|
||||
/// <summary>Double-Density CompactDisc (Purple Book)</summary>
|
||||
DDCD = 7,
|
||||
/// <summary>120mm, Phase-Change, 1298496 sectors, 512 bytes/sector, PD650, ECMA-240, ISO 15485</summary>
|
||||
PD650 = 8,
|
||||
/// <summary>DVD</summary>
|
||||
Dvd = 9,
|
||||
/// <summary>DVD-RAM (cartridge only)</summary>
|
||||
DVDRAM = 10,
|
||||
/// <summary>HD DVD</summary>
|
||||
HDDVDROM = 11,
|
||||
/// <summary>Blu-ray Disc</summary>
|
||||
Bluray = 12,
|
||||
/// <summary>Enhanced Versatile Disc</summary>
|
||||
EVD = 13,
|
||||
/// <summary>Forward Versatile Disc</summary>
|
||||
FVD = 14,
|
||||
/// <summary>Holographic Versatile Disc</summary>
|
||||
HVD = 15,
|
||||
/// <summary>China Blue High Definition</summary>
|
||||
CBHD = 16,
|
||||
/// <summary>High Definition Versatile Multilayer Disc</summary>
|
||||
HDVMD = 17,
|
||||
/// <summary>Versatile Compact Disc High Density</summary>
|
||||
VCDHD = 18,
|
||||
/// <summary>Stacked Volumetric Optical Disc</summary>
|
||||
SVOD = 19,
|
||||
/// <summary>Five Dimensional disc</summary>
|
||||
FDDVD = 20,
|
||||
/// <summary>Pioneer LaserDisc</summary>
|
||||
LD = 21,
|
||||
/// <summary>Pioneer LaserDisc data</summary>
|
||||
LDROM = 22,
|
||||
LDROM2 = 23,
|
||||
LVROM = 24,
|
||||
MegaLD = 254,
|
||||
/// <summary>Sony Hi-MD</summary>
|
||||
HiMD = 26,
|
||||
/// <summary>Sony MiniDisc</summary>
|
||||
MD = 27,
|
||||
MDData = 28,
|
||||
MDData2 = 29,
|
||||
/// <summary>5.25", Phase-Change, 1834348 sectors, 8192 bytes/sector, Ultra Density Optical, ECMA-350, ISO 17345</summary>
|
||||
UDO = 30,
|
||||
/// <summary>5.25", Phase-Change, 3669724 sectors, 8192 bytes/sector, Ultra Density Optical 2, ECMA-380, ISO 11976</summary>
|
||||
UDO2 = 31,
|
||||
PlayStationMemoryCard = 32,
|
||||
PlayStationMemoryCard2 = 33,
|
||||
/// <summary>Sony PlayStation game CD</summary>
|
||||
PS1CD = 34,
|
||||
/// <summary>Sony PlayStation 2 game CD</summary>
|
||||
PS2CD = 35,
|
||||
/// <summary>Sony PlayStation 2 game DVD</summary>
|
||||
PS2DVD = 36,
|
||||
/// <summary>Sony PlayStation 3 game DVD</summary>
|
||||
PS3DVD = 37,
|
||||
/// <summary>Sony PlayStation 3 game Blu-ray</summary>
|
||||
PS3BD = 38,
|
||||
/// <summary>Sony PlayStation 4 game Blu-ray</summary>
|
||||
PS4BD = 39,
|
||||
/// <summary>Sony PlayStation Portable Universal Media Disc (ECMA-365)</summary>
|
||||
UMD = 40,
|
||||
/// <summary>Microsoft X-box Game Disc</summary>
|
||||
XGD = 41,
|
||||
/// <summary>Microsoft X-box 360 Game Disc</summary>
|
||||
XGD2 = 42,
|
||||
/// <summary>Microsoft X-box 360 Game Disc</summary>
|
||||
XGD3 = 43,
|
||||
/// <summary>Microsoft X-box One Game Disc</summary>
|
||||
XGD4 = 44,
|
||||
/// <summary>Sega MegaCD</summary>
|
||||
MEGACD = 45,
|
||||
/// <summary>Sega Saturn disc</summary>
|
||||
SATURNCD = 46,
|
||||
/// <summary>Sega/Yamaha Gigabyte Disc</summary>
|
||||
GDROM = 47,
|
||||
SegaCard = 48,
|
||||
/// <summary>PC-Engine / TurboGrafx cartridge</summary>
|
||||
HuCard = 49,
|
||||
/// <summary>PC-Engine / TurboGrafx CD</summary>
|
||||
SuperCDROM2 = 50,
|
||||
/// <summary>Atari Jaguar CD</summary>
|
||||
JaguarCD = 51,
|
||||
/// <summary>3DO CD</summary>
|
||||
ThreeDO = 52,
|
||||
/// <summary>NEC PC-FX</summary>
|
||||
PCFX = 53,
|
||||
/// <summary>NEO-GEO CD</summary>
|
||||
NeoGeoCD = 54,
|
||||
/// <summary>8" floppy</summary>
|
||||
Floppy = 55,
|
||||
/// <summary>5.25" floppy</summary>
|
||||
Minifloppy = 56,
|
||||
/// <summary>3.5" floppy</summary>
|
||||
Microfloppy = 57,
|
||||
/// <summary>5.25", DS, ?D, ?? tracks, ?? spt, 512 bytes/sector, GCR, opposite side heads, aka Twiggy</summary>
|
||||
AppleFileWare = 58,
|
||||
Bernoulli = 59,
|
||||
Bernoulli2 = 60,
|
||||
Ditto = 61,
|
||||
DittoMax = 62,
|
||||
Jaz = 63,
|
||||
Jaz2 = 64,
|
||||
PocketZip = 65,
|
||||
REV120 = 66,
|
||||
REV35 = 67,
|
||||
REV70 = 68,
|
||||
ZIP100 = 69,
|
||||
ZIP250 = 70,
|
||||
ZIP750 = 71,
|
||||
CompactCassette = 72,
|
||||
Data8 = 73,
|
||||
MiniDV = 74,
|
||||
CFast = 75,
|
||||
CompactFlash = 76,
|
||||
CompactFlashType2 = 77,
|
||||
EZ135 = 78,
|
||||
EZ230 = 79,
|
||||
Quest = 80,
|
||||
SparQ = 81,
|
||||
SQ100 = 82,
|
||||
SQ200 = 83,
|
||||
SQ300 = 84,
|
||||
SQ310 = 85,
|
||||
SQ327 = 86,
|
||||
SQ400 = 87,
|
||||
SQ800 = 88,
|
||||
SQ1500 = 89,
|
||||
SQ2000 = 90,
|
||||
SyJet = 91,
|
||||
FamicomGamePak = 92,
|
||||
GameBoyAdvanceGamePak = 93,
|
||||
GameBoyGamePak = 94,
|
||||
GOD = 95,
|
||||
N64DD = 96,
|
||||
N64GamePak = 97,
|
||||
NESGamePak = 98,
|
||||
Nintendo3DSGameCard = 99,
|
||||
NintendoDiskCard = 100,
|
||||
NintendoDSGameCard = 101,
|
||||
NintendoDSiGameCard = 102,
|
||||
SNESGamePak = 103,
|
||||
SNESGamePakUS = 104,
|
||||
WOD = 105,
|
||||
WUOD = 106,
|
||||
SwitchGameCard = 107,
|
||||
MemoryStick = 108,
|
||||
MemoryStickDuo = 109,
|
||||
MemoryStickMicro = 110,
|
||||
MemoryStickPro = 111,
|
||||
MemoryStickProDuo = 112,
|
||||
microSD = 113,
|
||||
miniSD = 114,
|
||||
SecureDigital = 115,
|
||||
MMC = 116,
|
||||
MMCmicro = 117,
|
||||
RSMMC = 118,
|
||||
MMCplus = 118,
|
||||
MMCmobile = 119,
|
||||
eMMC = 120,
|
||||
MO120 = 121,
|
||||
MO90 = 122,
|
||||
MO300 = 123,
|
||||
MO356 = 124,
|
||||
CompactFloppy = 125,
|
||||
DemiDiskette = 126,
|
||||
/// <summary>3.5", 652 tracks, 2 sides, 512 bytes/sector, Floptical, ECMA-207, ISO 14169</summary>
|
||||
Floptical = 127,
|
||||
HiFD = 128,
|
||||
QuickDisk = 129,
|
||||
UHD144 = 130,
|
||||
VideoFloppy = 131,
|
||||
Wafer = 132,
|
||||
ZXMicrodrive = 133,
|
||||
BeeCard = 134,
|
||||
Borsu = 135,
|
||||
DataStore = 136,
|
||||
MiniCard = 137,
|
||||
Orb = 138,
|
||||
Orb5 = 139,
|
||||
SmartMedia = 140,
|
||||
xD = 141,
|
||||
XQD = 142,
|
||||
DataPlay = 143,
|
||||
LS120 = 144,
|
||||
LS240 = 145,
|
||||
FD32MB = 146,
|
||||
RDX = 147,
|
||||
PunchedCard = 148
|
||||
}
|
||||
|
||||
public enum StorageInterface
|
||||
{
|
||||
Unknown = 0,
|
||||
ACSI = 1,
|
||||
ATA = 2,
|
||||
XTA = 3,
|
||||
ESDI = 4,
|
||||
SCSI = 5,
|
||||
USB = 6,
|
||||
FireWire = 7,
|
||||
SASI = 8,
|
||||
ST506 = 9,
|
||||
IPI = 10,
|
||||
SMD = 11,
|
||||
SATA = 12,
|
||||
SSA = 13,
|
||||
DSSI = 14,
|
||||
HIPPI = 15,
|
||||
SAS = 16,
|
||||
FC = 17,
|
||||
PCIe = 18,
|
||||
M2 = 19,
|
||||
SataExpress = 20
|
||||
}
|
||||
}
|
||||
@@ -33,22 +33,8 @@ namespace Cicm.Database.Schemas
|
||||
/// <summary>Computer</summary>
|
||||
public class Machine
|
||||
{
|
||||
/// <summary>Capacity of first removable disk format</summary>
|
||||
public string Cap1;
|
||||
/// <summary>Capacity of second removable disk format</summary>
|
||||
public string Cap2;
|
||||
/// <summary>Manufacturer's company ID</summary>
|
||||
public int Company;
|
||||
/// <summary>ID of first removable disk format</summary>
|
||||
public int Disk1;
|
||||
/// <summary>ID of second removable disk format</summary>
|
||||
public int Disk2;
|
||||
/// <summary>ID of first hard disk format</summary>
|
||||
public int Hdd1;
|
||||
/// <summary>ID of second hard disk format</summary>
|
||||
public int Hdd2;
|
||||
/// <summary>ID of third hard disk format</summary>
|
||||
public int Hdd3;
|
||||
/// <summary>ID</summary>
|
||||
public int Id;
|
||||
/// <summary>Model name</summary>
|
||||
|
||||
@@ -37,20 +37,12 @@ namespace Cicm.Database.Schemas
|
||||
public string Acquired;
|
||||
/// <summary>Box present in collection</summary>
|
||||
public bool Boxed;
|
||||
/// <summary>Capacity of first removable disk format</summary>
|
||||
public int Cap1;
|
||||
/// <summary>Capacity of second removable disk format</summary>
|
||||
public int Cap2;
|
||||
/// <summary>Computer's ID</summary>
|
||||
public int ComputerId;
|
||||
/// <summary>Primary CPU</summary>
|
||||
public int Cpu1;
|
||||
/// <summary>Secondary CPU</summary>
|
||||
public int Cpu2;
|
||||
/// <summary>ID of first removable disk format</summary>
|
||||
public int Disk1;
|
||||
/// <summary>ID of second removable disk format</summary>
|
||||
public int Disk2;
|
||||
/// <summary>ID</summary>
|
||||
public int Id;
|
||||
/// <summary>Original manuals present in collection</summary>
|
||||
|
||||
120
Cicm.Database/Schemas/Sql/V20.cs
Normal file
120
Cicm.Database/Schemas/Sql/V20.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : V20.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 V20
|
||||
{
|
||||
public static readonly string Admins = V19.Admins;
|
||||
|
||||
public static readonly string BrowserTests = V19.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 ('20');";
|
||||
|
||||
public static readonly string Companies = V19.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" +
|
||||
"`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_type` (`type`));";
|
||||
|
||||
public static readonly string Forbidden = V19.Forbidden;
|
||||
|
||||
public static readonly string Gpus = V19.Gpus;
|
||||
|
||||
public static readonly string Logs = V19.Logs;
|
||||
|
||||
public static readonly string MoneyDonations = V19.MoneyDonations;
|
||||
|
||||
public static readonly string News = V19.News;
|
||||
|
||||
public static readonly string OwnedComputers = V19.OwnedComputers;
|
||||
|
||||
public static readonly string OwnedConsoles = V19.OwnedConsoles;
|
||||
|
||||
public static readonly string Processors = V19.Processors;
|
||||
|
||||
public static readonly string SoundSynths = V19.SoundSynths;
|
||||
|
||||
public static readonly string MachinesForeignKeys =
|
||||
"ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;";
|
||||
|
||||
public static readonly string Iso3166Numeric = V19.Iso3166Numeric;
|
||||
|
||||
public static readonly string Iso3166NumericValues = V19.Iso3166NumericValues;
|
||||
|
||||
public static readonly string CompaniesForeignKeys = V19.CompaniesForeignKeys;
|
||||
|
||||
public static readonly string CompanyLogos = V19.CompanyLogos;
|
||||
|
||||
public static readonly string CompanyDescriptions = V19.CompanyDescriptions;
|
||||
|
||||
public static readonly string InstructionSets = V19.InstructionSets;
|
||||
|
||||
public static readonly string InstructionSetExtensions = V19.InstructionSetExtensions;
|
||||
|
||||
public static readonly string InstructionSetExtensionsByProcessor = V19.InstructionSetExtensionsByProcessor;
|
||||
|
||||
public static readonly string ProcessorsByMachine = V19.ProcessorsByMachine;
|
||||
|
||||
public static readonly string GpusByMachine = V19.GpusByMachine;
|
||||
|
||||
public static readonly string SoundByMachine = V19.SoundByMachine;
|
||||
|
||||
public static readonly string MemoryByMachine = V19.MemoryByMachine;
|
||||
|
||||
public static readonly string Resolutions = V19.Resolutions;
|
||||
|
||||
public static readonly string ResolutionsByGpu = V19.ResolutionsByGpu;
|
||||
|
||||
public static readonly string StorageByMachine = "CREATE TABLE `storage_by_machine` (\n" +
|
||||
"`machine` INT NOT NULL,\n" +
|
||||
"`type` INT NOT NULL DEFAULT 0,\n" +
|
||||
"`interface` INT NOT NULL DEFAULT 0,\n" +
|
||||
"`capacity` BIGINT DEFAULT NULL,\n" +
|
||||
"KEY `idx_storage_machine` (`machine`),\n" +
|
||||
"KEY `idx_storage_type` (`type`),\n" +
|
||||
"KEY `idx_storage_interface` (`interface`),\n" +
|
||||
"KEY `idx_storage_capacity` (`capacity`),\n" +
|
||||
"CONSTRAINT `fk_storage_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);";
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : DiskFormat.cs
|
||||
// Filename : Computer.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// High level representation of a disk format.
|
||||
// High level representation of a computer.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -30,12 +30,16 @@
|
||||
|
||||
namespace Cicm.Database.Schemas
|
||||
{
|
||||
/// <summary>Storage format</summary>
|
||||
public class DiskFormat
|
||||
/// <summary>Computer</summary>
|
||||
public class StorageByMachine
|
||||
{
|
||||
/// <summary>Description</summary>
|
||||
public string Description;
|
||||
/// <summary>ID</summary>
|
||||
public int Id;
|
||||
/// <summary>Capacity in bytes</summary>
|
||||
public long Capacity;
|
||||
/// <summary>Storage interface</summary>
|
||||
public StorageInterface Interface;
|
||||
/// <summary>Machine ID</summary>
|
||||
public int Machine;
|
||||
/// <summary>Storage type</summary>
|
||||
public StorageType Type;
|
||||
}
|
||||
}
|
||||
@@ -37,20 +37,14 @@ namespace cicm_web.Models
|
||||
{
|
||||
public class Machine
|
||||
{
|
||||
public string Cap1;
|
||||
public string Cap2;
|
||||
public Company Company;
|
||||
public DiskFormat Disk1;
|
||||
public DiskFormat Disk2;
|
||||
public GpuByMachine[] Gpus;
|
||||
public DiskFormat Hdd1;
|
||||
public DiskFormat Hdd2;
|
||||
public DiskFormat Hdd3;
|
||||
public int Id;
|
||||
public MemoryByMachine[] Memories;
|
||||
public string Model;
|
||||
public ProcessorByMachine[] Processors;
|
||||
public SoundByMachine[] SoundSynths;
|
||||
public StorageByMachine[] Storage;
|
||||
public MachineType Type;
|
||||
public int Year;
|
||||
|
||||
@@ -83,35 +77,19 @@ namespace cicm_web.Models
|
||||
|
||||
internal static Machine TransformItem(Cicm.Database.Schemas.Machine dbItem)
|
||||
{
|
||||
Machine item = new Machine
|
||||
return new Machine
|
||||
{
|
||||
Company = Company.GetItem(dbItem.Company),
|
||||
Gpus = GpuByMachine.GetAllItems(dbItem.Id),
|
||||
Hdd1 = DiskFormat.GetItem(dbItem.Hdd1),
|
||||
Hdd2 = DiskFormat.GetItem(dbItem.Hdd2),
|
||||
Hdd3 = DiskFormat.GetItem(dbItem.Hdd3),
|
||||
Id = dbItem.Id,
|
||||
Model = dbItem.Model,
|
||||
Year = dbItem.Year,
|
||||
Type = dbItem.Type,
|
||||
Processors = ProcessorByMachine.GetAllItems(dbItem.Id),
|
||||
SoundSynths = SoundByMachine.GetAllItems(dbItem.Id),
|
||||
Memories = MemoryByMachine.GetAllItems(dbItem.Id)
|
||||
Memories = MemoryByMachine.GetAllItems(dbItem.Id),
|
||||
Storage = StorageByMachine.GetAllItems(dbItem.Id)
|
||||
};
|
||||
|
||||
if(dbItem.Disk1 > 0)
|
||||
{
|
||||
item.Cap1 = dbItem.Cap1;
|
||||
item.Disk1 = DiskFormat.GetItem(dbItem.Disk1);
|
||||
}
|
||||
|
||||
if(dbItem.Disk2 > 0)
|
||||
{
|
||||
item.Cap2 = dbItem.Cap2;
|
||||
item.Disk2 = DiskFormat.GetItem(dbItem.Disk2);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,13 +40,9 @@ namespace cicm_web.Models
|
||||
{
|
||||
public DateTime Acquired;
|
||||
public bool Boxed;
|
||||
public int Cap1;
|
||||
public int Cap2;
|
||||
public Machine Computer;
|
||||
public Processor Cpu1;
|
||||
public Processor Cpu2;
|
||||
public DiskFormat Disk1;
|
||||
public DiskFormat Disk2;
|
||||
public int Id;
|
||||
public bool Manuals;
|
||||
public float Mhz1;
|
||||
@@ -91,18 +87,6 @@ namespace cicm_web.Models
|
||||
Vram = dbItem.Vram
|
||||
};
|
||||
|
||||
if(dbItem.Disk1 > 0)
|
||||
{
|
||||
item.Cap1 = dbItem.Cap1;
|
||||
item.Disk1 = DiskFormat.GetItem(dbItem.Disk1);
|
||||
}
|
||||
|
||||
if(dbItem.Disk2 > 0)
|
||||
{
|
||||
item.Cap2 = dbItem.Cap2;
|
||||
item.Disk2 = DiskFormat.GetItem(dbItem.Disk2);
|
||||
}
|
||||
|
||||
if(dbItem.Cpu1 > 0)
|
||||
{
|
||||
item.Cpu1 = Processor.GetItem(dbItem.Cpu1);
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : DiskFormat.cs
|
||||
// Filename : StorageByMachine.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Disk format model
|
||||
// Storage by machine model
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -29,30 +29,35 @@
|
||||
*******************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Cicm.Database.Schemas;
|
||||
|
||||
namespace cicm_web.Models
|
||||
{
|
||||
public class DiskFormat
|
||||
public class StorageByMachine
|
||||
{
|
||||
public string Description;
|
||||
public int Id;
|
||||
/// <summary>Capacity in bytes</summary>
|
||||
public long Capacity;
|
||||
/// <summary>Storage interface</summary>
|
||||
public StorageInterface Interface;
|
||||
/// <summary>Storage type</summary>
|
||||
public StorageType Type;
|
||||
|
||||
public static DiskFormat GetItem(int id)
|
||||
public static StorageByMachine[] GetAllItems(int machineId)
|
||||
{
|
||||
Cicm.Database.Schemas.DiskFormat dbItem = Program.Database?.Operations.GetDiskFormat(id);
|
||||
return dbItem == null ? null : new DiskFormat {Description = dbItem.Description, Id = dbItem.Id};
|
||||
}
|
||||
|
||||
public static DiskFormat[] GetAllItems()
|
||||
{
|
||||
List<Cicm.Database.Schemas.DiskFormat> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetDiskFormats(out dbItems);
|
||||
List<Cicm.Database.Schemas.StorageByMachine> dbItems = null;
|
||||
bool? result =
|
||||
Program.Database?.Operations.GetStorageByMachines(out dbItems, machineId);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<DiskFormat> items = new List<DiskFormat>();
|
||||
List<StorageByMachine> items = new List<StorageByMachine>();
|
||||
|
||||
foreach(Cicm.Database.Schemas.DiskFormat dbItem in dbItems)
|
||||
items.Add(new DiskFormat {Id = dbItem.Id, Description = dbItem.Description});
|
||||
foreach(Cicm.Database.Schemas.StorageByMachine dbItem in dbItems)
|
||||
items.Add(new StorageByMachine
|
||||
{
|
||||
Type = dbItem.Type,
|
||||
Interface = dbItem.Interface,
|
||||
Capacity = dbItem.Capacity
|
||||
});
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
@@ -32,7 +32,10 @@
|
||||
ViewData["Title"] = "Computer";
|
||||
}
|
||||
@using System.IO
|
||||
@model Machine
|
||||
@using Cicm.Database.Schemas
|
||||
@using MemoryByMachine = cicm_web.Models.MemoryByMachine
|
||||
@using StorageByMachine = cicm_web.Models.StorageByMachine
|
||||
@model cicm_web.Models.Machine
|
||||
|
||||
<p align=center>
|
||||
@if(Model.Company.LastLogo != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.LastLogo.Guid + ".svg")))
|
||||
@@ -643,214 +646,70 @@
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if(Model.Hdd1 != null && Model.Hdd1.Id > 0 && Model.Hdd1.Id != 30)
|
||||
@if(Model.Storage != null && Model.Storage.Length > 0)
|
||||
{
|
||||
<tr>
|
||||
<th scope=row>
|
||||
<div align=right>
|
||||
Disk interfaces
|
||||
Storage
|
||||
</div>
|
||||
</th>
|
||||
<td>
|
||||
@Model.Hdd1.Description
|
||||
@if(Model.Hdd2 != null && Model.Hdd2.Id > 0 && Model.Hdd2.Id != 30)
|
||||
{
|
||||
<br>
|
||||
@Model.Hdd2.Description
|
||||
}
|
||||
@if(Model.Hdd3 != null && Model.Hdd3.Id > 0 && Model.Hdd3.Id != 30)
|
||||
{
|
||||
<br>
|
||||
@Model.Hdd3.Description
|
||||
}
|
||||
<table>
|
||||
@foreach(StorageByMachine storage in Model.Storage)
|
||||
{
|
||||
string capString = null;
|
||||
|
||||
if(storage.Capacity != 0)
|
||||
{
|
||||
if(storage.Type == StorageType.CompactCassette) { capString = $"{storage.Capacity} bps"; }
|
||||
else
|
||||
{
|
||||
if(storage.Capacity > 1073741824) { capString = $"{storage.Capacity / 1073741824} GiB"; }
|
||||
else if(storage.Capacity > 1048576) { capString = $"{storage.Capacity / 1048576} MiB"; }
|
||||
else if(storage.Capacity > 1024) { capString = $"{storage.Capacity / 1024} KiB"; }
|
||||
else if(storage.Capacity > 0) { capString = $"{storage.Capacity} bytes"; }
|
||||
else
|
||||
{ capString = null; }
|
||||
}
|
||||
}
|
||||
|
||||
<tr>
|
||||
@if(storage.Interface != StorageInterface.Unknown)
|
||||
{
|
||||
if(storage.Type == StorageType.Empty)
|
||||
{
|
||||
<td>Available @storage.Interface interface.</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
if(capString != null)
|
||||
{
|
||||
<td>@storage.Type connected thru a @storage.Interface interface with a nominal capacity of @capString</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>@storage.Type connected thru a @storage.Interface interface</td>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(capString != null)
|
||||
{
|
||||
<td>@storage.Type with a nominal capacity of @capString</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>@storage.Type</td>
|
||||
}
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@if(Model.Disk1 != null)
|
||||
{
|
||||
<tr>
|
||||
<th scope=row>
|
||||
<div align=right>
|
||||
Primary disk
|
||||
</div>
|
||||
</th>
|
||||
@if(Model.Disk1.Id != 30)
|
||||
{
|
||||
int cap1 = int.Parse(Model.Cap1);
|
||||
|
||||
if(Model.Disk1.Id != 8)
|
||||
{
|
||||
if(Model.Disk1.Id != 6)
|
||||
{
|
||||
string cap1Bytes = cap1 > 1024 ? (cap1 > 1048576 ? $"{cap1 / 1048576} GBytes" : $"{cap1 / 1024} MBytes") : (cap1 > 0 ? $"{cap1} Kbytes" : "Unknown capacity");
|
||||
|
||||
if(Model.Disk1.Id != 10)
|
||||
{
|
||||
if(Model.Disk1.Id != 15)
|
||||
{
|
||||
if(Model.Disk1.Id != 16)
|
||||
{
|
||||
if(Model.Disk1.Id != 36)
|
||||
{
|
||||
if(Model.Disk1.Id != 22)
|
||||
{
|
||||
if(Model.Disk1.Id != 23)
|
||||
{
|
||||
if(Model.Disk1.Id != 39)
|
||||
{
|
||||
if(Model.Disk1.Id != 31)
|
||||
{
|
||||
<td>@Model.Disk1.Description (@cap1Bytes)</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Propietary (@cap1Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Digital tape (@cap1Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Punched card (@cap1Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Chip card (@cap1Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Magnetic card (@cap1Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Memory (@cap1Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Magneto-optical (@cap1Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Optical disk (@cap1Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string cap1Bits = cap1 > 1000 ? (cap1 > 1000000 ? $"{cap1 / 1000000} GBits" : $"{cap1 / 1000} MBits") : (cap1 > 0 ? $"{cap1} KBits" : "Unknown capacity");
|
||||
|
||||
<td>Cartridge (@cap1Bits)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Standard audio cassette (@cap1 bps)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{ <td>None</td> }
|
||||
</tr>
|
||||
}
|
||||
@if(Model.Disk2 != null)
|
||||
{
|
||||
<tr>
|
||||
<th scope=row>
|
||||
<div align=right>
|
||||
Secondary disk
|
||||
</div>
|
||||
</th>
|
||||
@if(Model.Disk2.Id != 30)
|
||||
{
|
||||
int cap2 = int.Parse(Model.Cap2);
|
||||
|
||||
if(Model.Disk2.Id != 8)
|
||||
{
|
||||
if(Model.Disk2.Id != 6)
|
||||
{
|
||||
string cap2Bytes = cap2 > 1024 ? (cap2 > 1048576 ? $"{cap2 / 1048576} GBytes" : $"{cap2 / 1024} MBytes") : (cap2 > 0 ? $"{cap2} Kbytes" : "Unknown capacity");
|
||||
|
||||
if(Model.Disk2.Id != 10)
|
||||
{
|
||||
if(Model.Disk2.Id != 15)
|
||||
{
|
||||
if(Model.Disk2.Id != 16)
|
||||
{
|
||||
if(Model.Disk2.Id != 36)
|
||||
{
|
||||
if(Model.Disk2.Id != 22)
|
||||
{
|
||||
if(Model.Disk2.Id != 23)
|
||||
{
|
||||
if(Model.Disk2.Id != 39)
|
||||
{
|
||||
if(Model.Disk2.Id != 31)
|
||||
{
|
||||
<td>@Model.Disk2.Description (@cap2Bytes)</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Propietary (@cap2Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Digital tape (@cap2Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Punched card (@cap2Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Chip card (@cap2Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Magnetic card (@cap2Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Memory (@cap2Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Magneto-optical (@cap2Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Optical disk (@cap2Bytes)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string cap2Bits = cap2 > 1000 ? (cap2 > 1000000 ? $"{cap2 / 1000000} GBits" : $"{cap2 / 1000} MBits") : (cap2 > 0 ? $"{cap2} KBits" : "Unknown capacity");
|
||||
|
||||
<td>Cartridge (@cap2Bits)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>Standard audio cassette (@cap2 bps)</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{ <td>None</td> }
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/photos/computers", Model.Id + ".jpg")))
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<Version>3.0.99.220</Version>
|
||||
<Version>3.0.99.222</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user