mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Update DB to version 19: Resolutions are gpu dependant,
move to separate table and use an interconnection table, `resolution_by_gpu`.
This commit is contained in:
@@ -32,7 +32,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using Cicm.Database.Schemas;
|
using Cicm.Database.Schemas;
|
||||||
using Console = System.Console;
|
|
||||||
|
|
||||||
namespace Cicm.Database
|
namespace Cicm.Database
|
||||||
{
|
{
|
||||||
@@ -300,6 +299,14 @@ namespace Cicm.Database
|
|||||||
param9.Value = entry.Transistors;
|
param9.Value = entry.Transistors;
|
||||||
|
|
||||||
dbcmd.Parameters.Add(param1);
|
dbcmd.Parameters.Add(param1);
|
||||||
|
dbcmd.Parameters.Add(param2);
|
||||||
|
dbcmd.Parameters.Add(param3);
|
||||||
|
dbcmd.Parameters.Add(param4);
|
||||||
|
dbcmd.Parameters.Add(param5);
|
||||||
|
dbcmd.Parameters.Add(param6);
|
||||||
|
dbcmd.Parameters.Add(param7);
|
||||||
|
dbcmd.Parameters.Add(param8);
|
||||||
|
dbcmd.Parameters.Add(param9);
|
||||||
|
|
||||||
return dbcmd;
|
return dbcmd;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,115 +49,123 @@ namespace Cicm.Database
|
|||||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `admins`");
|
Console.WriteLine("Creating table `admins`");
|
||||||
dbCmd.CommandText = V18.Admins;
|
dbCmd.CommandText = V19.Admins;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `browser_tests`");
|
Console.WriteLine("Creating table `browser_tests`");
|
||||||
dbCmd.CommandText = V18.BrowserTests;
|
dbCmd.CommandText = V19.BrowserTests;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `cicm_db`");
|
Console.WriteLine("Creating table `cicm_db`");
|
||||||
dbCmd.CommandText = V18.CicmDb;
|
dbCmd.CommandText = V19.CicmDb;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `companies`");
|
Console.WriteLine("Creating table `companies`");
|
||||||
dbCmd.CommandText = V18.Companies;
|
dbCmd.CommandText = V19.Companies;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `machines`");
|
Console.WriteLine("Creating table `machines`");
|
||||||
dbCmd.CommandText = V18.Machines;
|
dbCmd.CommandText = V19.Machines;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `disk_formats`");
|
Console.WriteLine("Creating table `disk_formats`");
|
||||||
dbCmd.CommandText = V18.DiskFormats;
|
dbCmd.CommandText = V19.DiskFormats;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `forbidden`");
|
Console.WriteLine("Creating table `forbidden`");
|
||||||
dbCmd.CommandText = V18.Forbidden;
|
dbCmd.CommandText = V19.Forbidden;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `gpus`");
|
Console.WriteLine("Creating table `gpus`");
|
||||||
dbCmd.CommandText = V18.Gpus;
|
dbCmd.CommandText = V19.Gpus;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `log`");
|
Console.WriteLine("Creating table `log`");
|
||||||
dbCmd.CommandText = V18.Logs;
|
dbCmd.CommandText = V19.Logs;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `money_donations`");
|
Console.WriteLine("Creating table `money_donations`");
|
||||||
dbCmd.CommandText = V18.MoneyDonations;
|
dbCmd.CommandText = V19.MoneyDonations;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `news`");
|
Console.WriteLine("Creating table `news`");
|
||||||
dbCmd.CommandText = V18.News;
|
dbCmd.CommandText = V19.News;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `owned_computers`");
|
Console.WriteLine("Creating table `owned_computers`");
|
||||||
dbCmd.CommandText = V18.OwnedComputers;
|
dbCmd.CommandText = V19.OwnedComputers;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `owned_consoles`");
|
Console.WriteLine("Creating table `owned_consoles`");
|
||||||
dbCmd.CommandText = V18.OwnedConsoles;
|
dbCmd.CommandText = V19.OwnedConsoles;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `instruction_sets`");
|
Console.WriteLine("Creating table `instruction_sets`");
|
||||||
dbCmd.CommandText = V18.InstructionSets;
|
dbCmd.CommandText = V19.InstructionSets;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `instruction_set_extensions`");
|
Console.WriteLine("Creating table `instruction_set_extensions`");
|
||||||
dbCmd.CommandText = V18.InstructionSetExtensions;
|
dbCmd.CommandText = V19.InstructionSetExtensions;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `processors`");
|
Console.WriteLine("Creating table `processors`");
|
||||||
dbCmd.CommandText = V18.Processors;
|
dbCmd.CommandText = V19.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 = V18.InstructionSetExtensionsByProcessor;
|
dbCmd.CommandText = V19.InstructionSetExtensionsByProcessor;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `sound_synths`");
|
Console.WriteLine("Creating table `sound_synths`");
|
||||||
dbCmd.CommandText = V18.SoundSynths;
|
dbCmd.CommandText = V19.SoundSynths;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `iso3166_1_numeric`");
|
Console.WriteLine("Creating table `iso3166_1_numeric`");
|
||||||
dbCmd.CommandText = V18.Iso3166Numeric;
|
dbCmd.CommandText = V19.Iso3166Numeric;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Filling table `iso3166_1_numeric`");
|
Console.WriteLine("Filling table `iso3166_1_numeric`");
|
||||||
dbCmd.CommandText = V18.Iso3166NumericValues;
|
dbCmd.CommandText = V19.Iso3166NumericValues;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating foreign keys for table `companies`");
|
Console.WriteLine("Creating foreign keys for table `companies`");
|
||||||
dbCmd.CommandText = V18.CompaniesForeignKeys;
|
dbCmd.CommandText = V19.CompaniesForeignKeys;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating foreign keys for table `machines`");
|
Console.WriteLine("Creating foreign keys for table `machines`");
|
||||||
dbCmd.CommandText = V18.MachinesForeignKeys;
|
dbCmd.CommandText = V19.MachinesForeignKeys;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `company_logos`");
|
Console.WriteLine("Creating table `company_logos`");
|
||||||
dbCmd.CommandText = V18.CompanyLogos;
|
dbCmd.CommandText = V19.CompanyLogos;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `company_descriptions`");
|
Console.WriteLine("Creating table `company_descriptions`");
|
||||||
dbCmd.CommandText = V18.CompanyDescriptions;
|
dbCmd.CommandText = V19.CompanyDescriptions;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `processors_by_machine`");
|
Console.WriteLine("Creating table `processors_by_machine`");
|
||||||
dbCmd.CommandText = V18.ProcessorsByMachine;
|
dbCmd.CommandText = V19.ProcessorsByMachine;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `gpus_by_machine`");
|
Console.WriteLine("Creating table `gpus_by_machine`");
|
||||||
dbCmd.CommandText = V18.GpusByMachine;
|
dbCmd.CommandText = V19.GpusByMachine;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `sound_by_machine`");
|
Console.WriteLine("Creating table `sound_by_machine`");
|
||||||
dbCmd.CommandText = V18.SoundByMachine;
|
dbCmd.CommandText = V19.SoundByMachine;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
Console.WriteLine("Creating table `memory_by_machine`");
|
Console.WriteLine("Creating table `memory_by_machine`");
|
||||||
dbCmd.CommandText = V18.MemoryByMachine;
|
dbCmd.CommandText = V19.MemoryByMachine;
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("Creating table `resolutions`");
|
||||||
|
dbCmd.CommandText = V19.Resolutions;
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("Creating table `resolutions_by_gpu`");
|
||||||
|
dbCmd.CommandText = V19.ResolutionsByGpu;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -304,50 +304,42 @@ namespace Cicm.Database
|
|||||||
IDbDataParameter param9 = dbcmd.CreateParameter();
|
IDbDataParameter param9 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param10 = dbcmd.CreateParameter();
|
IDbDataParameter param10 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param11 = dbcmd.CreateParameter();
|
IDbDataParameter param11 = dbcmd.CreateParameter();
|
||||||
IDbDataParameter param12 = dbcmd.CreateParameter();
|
|
||||||
IDbDataParameter param13 = dbcmd.CreateParameter();
|
|
||||||
|
|
||||||
param1.ParameterName = "@company";
|
param1.ParameterName = "@company";
|
||||||
param2.ParameterName = "@year";
|
param2.ParameterName = "@year";
|
||||||
param3.ParameterName = "@model";
|
param3.ParameterName = "@model";
|
||||||
param4.ParameterName = "@colors";
|
param4.ParameterName = "@hdd1";
|
||||||
param5.ParameterName = "@res";
|
param5.ParameterName = "@hdd2";
|
||||||
param6.ParameterName = "@hdd1";
|
param6.ParameterName = "@hdd3";
|
||||||
param7.ParameterName = "@hdd2";
|
param7.ParameterName = "@disk1";
|
||||||
param8.ParameterName = "@hdd3";
|
param8.ParameterName = "@cap1";
|
||||||
param9.ParameterName = "@disk1";
|
param9.ParameterName = "@disk2";
|
||||||
param10.ParameterName = "@cap1";
|
param10.ParameterName = "@cap2";
|
||||||
param11.ParameterName = "@disk2";
|
param11.ParameterName = "@type";
|
||||||
param12.ParameterName = "@cap2";
|
|
||||||
param13.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.String;
|
param5.DbType = DbType.Int32;
|
||||||
param6.DbType = DbType.Int32;
|
param6.DbType = DbType.Int32;
|
||||||
param7.DbType = DbType.Int32;
|
param7.DbType = DbType.Int32;
|
||||||
param8.DbType = DbType.Int32;
|
param8.DbType = DbType.String;
|
||||||
param9.DbType = DbType.Int32;
|
param9.DbType = DbType.Int32;
|
||||||
param10.DbType = DbType.String;
|
param10.DbType = DbType.String;
|
||||||
param11.DbType = DbType.Int32;
|
param11.DbType = DbType.Int32;
|
||||||
param12.DbType = DbType.String;
|
|
||||||
param13.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.Colors;
|
param4.Value = entry.Hdd1;
|
||||||
param5.Value = entry.Resolution;
|
param5.Value = entry.Hdd2;
|
||||||
param6.Value = entry.Hdd1;
|
param6.Value = entry.Hdd3;
|
||||||
param7.Value = entry.Hdd2;
|
param7.Value = entry.Disk1;
|
||||||
param8.Value = entry.Hdd3;
|
param8.Value = entry.Cap1;
|
||||||
param9.Value = entry.Disk1;
|
param9.Value = entry.Disk2;
|
||||||
param10.Value = entry.Cap1;
|
param10.Value = entry.Cap2;
|
||||||
param11.Value = entry.Disk2;
|
param11.Value = entry.Type;
|
||||||
param12.Value = entry.Cap2;
|
|
||||||
param13.Value = entry.Type;
|
|
||||||
|
|
||||||
dbcmd.Parameters.Add(param1);
|
dbcmd.Parameters.Add(param1);
|
||||||
dbcmd.Parameters.Add(param2);
|
dbcmd.Parameters.Add(param2);
|
||||||
@@ -360,8 +352,6 @@ namespace Cicm.Database
|
|||||||
dbcmd.Parameters.Add(param9);
|
dbcmd.Parameters.Add(param9);
|
||||||
dbcmd.Parameters.Add(param10);
|
dbcmd.Parameters.Add(param10);
|
||||||
dbcmd.Parameters.Add(param11);
|
dbcmd.Parameters.Add(param11);
|
||||||
dbcmd.Parameters.Add(param12);
|
|
||||||
dbcmd.Parameters.Add(param13);
|
|
||||||
|
|
||||||
return dbcmd;
|
return dbcmd;
|
||||||
}
|
}
|
||||||
@@ -378,8 +368,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"],
|
||||||
Colors = (int)dataRow["colors"],
|
|
||||||
Resolution = (string)dataRow["res"],
|
|
||||||
Hdd1 = (int)dataRow["hdd1"],
|
Hdd1 = (int)dataRow["hdd1"],
|
||||||
Hdd2 = dataRow["hdd2"] == DBNull.Value ? 0 : (int)dataRow["hdd2"],
|
Hdd2 = dataRow["hdd2"] == DBNull.Value ? 0 : (int)dataRow["hdd2"],
|
||||||
Hdd3 = dataRow["hdd3"] == DBNull.Value ? 0 : (int)dataRow["hdd3"],
|
Hdd3 = dataRow["hdd3"] == DBNull.Value ? 0 : (int)dataRow["hdd3"],
|
||||||
|
|||||||
@@ -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 = 18;
|
const int DB_VERSION = 19;
|
||||||
/// <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>
|
||||||
|
|||||||
418
Cicm.Database/Operations/Resolution.cs
Normal file
418
Cicm.Database/Operations/Resolution.cs
Normal file
@@ -0,0 +1,418 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : Resolution.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Contains operations to manage Resolutions.
|
||||||
|
//
|
||||||
|
// --[ 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 Resolutions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entries">All Resolutions</param>
|
||||||
|
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||||
|
public bool GetResolutions(out List<Resolution> entries)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting all Resolutions...");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const string SQL = "SELECT * from resolutions";
|
||||||
|
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||||
|
dbCmd.CommandText = SQL;
|
||||||
|
DataSet dataSet = new DataSet();
|
||||||
|
dataAdapter.SelectCommand = dbCmd;
|
||||||
|
dataAdapter.Fill(dataSet);
|
||||||
|
|
||||||
|
entries = ResolutionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting Resolutions.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
entries = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the specified number of Resolutions since the specified start
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entries">List of Resolutions</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 GetResolutions(out List<Resolution> entries, ulong start, ulong count)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting {0} Resolutions from {1}...", count, start);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * FROM resolutions 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 = ResolutionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting Resolutions.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
entries = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets Resolution by specified id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id</param>
|
||||||
|
/// <returns>Resolution with specified id, <c>null</c> if not found or error</returns>
|
||||||
|
public Resolution GetResolution(int id)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting Resolution with id {0}...", id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * from resolutions 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<Resolution> entries = ResolutionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting Resolution.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets Resolution by specified id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id</param>
|
||||||
|
/// <returns>Resolution with specified id, <c>null</c> if not found or error</returns>
|
||||||
|
public Resolution GetResolution(int width, int height)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting first resolution of {0}x{1}...", width, height);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * from resolutions WHERE width = {width} AND height = {height}";
|
||||||
|
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||||
|
dbCmd.CommandText = sql;
|
||||||
|
DataSet dataSet = new DataSet();
|
||||||
|
dataAdapter.SelectCommand = dbCmd;
|
||||||
|
dataAdapter.Fill(dataSet);
|
||||||
|
|
||||||
|
List<Resolution> entries = ResolutionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting Resolution.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets Resolution by specified id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id</param>
|
||||||
|
/// <returns>Resolution with specified id, <c>null</c> if not found or error</returns>
|
||||||
|
public Resolution GetResolution(int width, int height, long colors)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting first resolution of {0}x{1} with {2} colors...", width, height, colors);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql =
|
||||||
|
$"SELECT * from resolutions WHERE width = {width} AND height = {height} AND colors = {colors}";
|
||||||
|
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||||
|
dbCmd.CommandText = sql;
|
||||||
|
DataSet dataSet = new DataSet();
|
||||||
|
dataAdapter.SelectCommand = dbCmd;
|
||||||
|
dataAdapter.Fill(dataSet);
|
||||||
|
|
||||||
|
List<Resolution> entries = ResolutionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting Resolution.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets Resolution by specified id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id</param>
|
||||||
|
/// <returns>Resolution with specified id, <c>null</c> if not found or error</returns>
|
||||||
|
public Resolution GetResolution(int width, int height, long colors, long palette)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting first resolution of {0}x{1} with {2} colors from a palette of {3} colors...",
|
||||||
|
width, height, colors, palette);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql =
|
||||||
|
$"SELECT * from resolutions WHERE width = {width} AND height = {height} AND colors = {colors} AND palette = {palette}";
|
||||||
|
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||||
|
dbCmd.CommandText = sql;
|
||||||
|
DataSet dataSet = new DataSet();
|
||||||
|
dataAdapter.SelectCommand = dbCmd;
|
||||||
|
dataAdapter.Fill(dataSet);
|
||||||
|
|
||||||
|
List<Resolution> entries = ResolutionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting Resolution.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts the number of Resolutions in the database
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Entries in database</returns>
|
||||||
|
public long CountResolutions()
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Counting resolutions...");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||||
|
dbcmd.CommandText = "SELECT COUNT(*) FROM resolutions";
|
||||||
|
object count = dbcmd.ExecuteScalar();
|
||||||
|
dbcmd.Dispose();
|
||||||
|
try { return Convert.ToInt64(count); }
|
||||||
|
catch { return 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new Resolution 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 AddResolution(Resolution entry, out long id)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.Write("Adding Resolution...");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDbCommand dbcmd = GetCommandResolution(entry);
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
const string SQL =
|
||||||
|
"INSERT INTO resolutions (width, height, colors, palette, chars) VALUES (@width, @height, @colors, " +
|
||||||
|
"@palette, @chars)";
|
||||||
|
|
||||||
|
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 Resolution in the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entry">Updated entry</param>
|
||||||
|
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||||
|
public bool UpdateResolution(Resolution entry)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Updating Resolution `{0}`...", entry.Id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDbCommand dbcmd = GetCommandResolution(entry);
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
string sql =
|
||||||
|
"UPDATE resolutions SET width = @width, height = @height, colors = @colors, palette = @palette, " +
|
||||||
|
"chars = @chars " +
|
||||||
|
$"WHERE id = {entry.Id}";
|
||||||
|
|
||||||
|
dbcmd.CommandText = sql;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbcmd.Dispose();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a Resolution 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 RemoveResolution(long id)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Removing Resolution widh id `{0}`...", id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
string sql = $"DELETE FROM resolutions WHERE id = '{id}';";
|
||||||
|
|
||||||
|
dbcmd.CommandText = sql;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbcmd.Dispose();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IDbCommand GetCommandResolution(Resolution 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 = "@width";
|
||||||
|
param2.ParameterName = "@height";
|
||||||
|
param3.ParameterName = "@colors";
|
||||||
|
param4.ParameterName = "@palette";
|
||||||
|
param5.ParameterName = "@chars";
|
||||||
|
|
||||||
|
param1.DbType = DbType.Int32;
|
||||||
|
param2.DbType = DbType.Int32;
|
||||||
|
param3.DbType = DbType.Int64;
|
||||||
|
param4.DbType = DbType.Int64;
|
||||||
|
param5.DbType = DbType.Boolean;
|
||||||
|
|
||||||
|
param1.Value = entry.Width;
|
||||||
|
param2.Value = entry.Height;
|
||||||
|
param3.Value = entry.Colors == 0 ? (object)null : entry.Colors;
|
||||||
|
param4.Value = entry.Palette == 0 ? (object)null : entry.Palette;
|
||||||
|
param5.Value = entry.Chars;
|
||||||
|
|
||||||
|
dbcmd.Parameters.Add(param1);
|
||||||
|
dbcmd.Parameters.Add(param2);
|
||||||
|
dbcmd.Parameters.Add(param3);
|
||||||
|
dbcmd.Parameters.Add(param4);
|
||||||
|
dbcmd.Parameters.Add(param5);
|
||||||
|
|
||||||
|
return dbcmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<Resolution> ResolutionsFromDataTable(DataTable dataTable)
|
||||||
|
{
|
||||||
|
List<Resolution> entries = new List<Resolution>();
|
||||||
|
|
||||||
|
foreach(DataRow dataRow in dataTable.Rows)
|
||||||
|
{
|
||||||
|
Resolution entry = new Resolution
|
||||||
|
{
|
||||||
|
Id = (int)dataRow["id"],
|
||||||
|
Width = (int)dataRow["width"],
|
||||||
|
Height = (int)dataRow["height"],
|
||||||
|
Colors = dataRow["colors"] == DBNull.Value ? 0 : (long)dataRow["colors"],
|
||||||
|
Palette = dataRow["palette"] == DBNull.Value ? 0 : (long)dataRow["palette"],
|
||||||
|
Chars = (bool)dataRow["chars"]
|
||||||
|
};
|
||||||
|
|
||||||
|
entries.Add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
80
Cicm.Database/Operations/ResolutionByGpu.cs
Normal file
80
Cicm.Database/Operations/ResolutionByGpu.cs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : Resolution.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Contains operations to manage Resolutions.
|
||||||
|
//
|
||||||
|
// --[ 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 Resolutions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entries">All Resolutions</param>
|
||||||
|
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||||
|
public bool GetResolutions(out List<Resolution> entries, int gpuId)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting all resolutions for GPU {0}...", gpuId);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * FROM resolutions_by_gpu 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 = new List<Resolution>();
|
||||||
|
foreach(DataRow dataRow in dataSet.Tables[0].Rows)
|
||||||
|
entries.Add(GetResolution((int)dataRow["resolution"]));
|
||||||
|
|
||||||
|
if(entries.Count != 0) return true;
|
||||||
|
|
||||||
|
entries = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting Resolutions.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
entries = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -159,6 +159,11 @@ namespace Cicm.Database
|
|||||||
UpdateDatabaseToV18();
|
UpdateDatabaseToV18();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 18:
|
||||||
|
{
|
||||||
|
UpdateDatabaseToV19();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OptimizeDatabase();
|
OptimizeDatabase();
|
||||||
@@ -2026,6 +2031,147 @@ namespace Cicm.Database
|
|||||||
dbCmd.Dispose();
|
dbCmd.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateDatabaseToV19()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Updating database to version 19");
|
||||||
|
|
||||||
|
Console.WriteLine("Creating table `resolutions`");
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = V19.Resolutions;
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
|
||||||
|
Console.WriteLine("Creating table `resolutions_by_gpu`");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = V19.ResolutionsByGpu;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if(dataRow["colors"] == DBNull.Value || dataRow["res"] == DBNull.Value ||
|
||||||
|
(int)dataRow["colors"] == 0 ||
|
||||||
|
(string)dataRow["res"] == "???") continue;
|
||||||
|
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbDataAdapter dataAdapter2 = dbCore.GetNewDataAdapter();
|
||||||
|
dbCmd.CommandText = $"SELECT * FROM gpus_by_machine WHERE machine = {(int)dataRow["id"]}";
|
||||||
|
DataSet dataSet2 = new DataSet();
|
||||||
|
dataAdapter2.SelectCommand = dbCmd;
|
||||||
|
dataAdapter2.Fill(dataSet2);
|
||||||
|
|
||||||
|
if(dataSet2.Tables[0].Rows.Count == 0) continue;
|
||||||
|
|
||||||
|
int gpuId = (int)dataSet2.Tables[0].Rows[0]["gpu"];
|
||||||
|
|
||||||
|
string[] resPieces = ((string)dataRow["res"]).Split('x');
|
||||||
|
|
||||||
|
if(!int.TryParse(resPieces[0], out int width)) continue;
|
||||||
|
if(!int.TryParse(resPieces[1], out int height)) continue;
|
||||||
|
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
dataAdapter2 = dbCore.GetNewDataAdapter();
|
||||||
|
dbCmd.CommandText =
|
||||||
|
$"SELECT * FROM resolutions WHERE width = {width} AND height = {height} AND colors = {(int)dataRow["colors"]}";
|
||||||
|
dataSet2 = new DataSet();
|
||||||
|
dataAdapter2.SelectCommand = dbCmd;
|
||||||
|
dataAdapter2.Fill(dataSet2);
|
||||||
|
|
||||||
|
int resId;
|
||||||
|
string sql;
|
||||||
|
|
||||||
|
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||||
|
|
||||||
|
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param2 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param3 = dbcmd.CreateParameter();
|
||||||
|
|
||||||
|
if(dataSet2.Tables[0].Rows.Count == 0)
|
||||||
|
{
|
||||||
|
param1.ParameterName = "@width";
|
||||||
|
param2.ParameterName = "@height";
|
||||||
|
param3.ParameterName = "@colors";
|
||||||
|
|
||||||
|
param1.DbType = DbType.Int32;
|
||||||
|
param2.DbType = DbType.Int32;
|
||||||
|
param3.DbType = DbType.Int64;
|
||||||
|
|
||||||
|
param1.Value = width;
|
||||||
|
param2.Value = height;
|
||||||
|
param3.Value = (int)dataRow["colors"];
|
||||||
|
|
||||||
|
sql = "INSERT INTO `resolutions` (`width`, `height`, `colors`) VALUES (@width, @height, @colors)";
|
||||||
|
|
||||||
|
dbcmd.Parameters.Add(param1);
|
||||||
|
dbcmd.Parameters.Add(param2);
|
||||||
|
dbcmd.Parameters.Add(param3);
|
||||||
|
|
||||||
|
dbcmd.CommandText = sql;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
dbcmd.Dispose();
|
||||||
|
|
||||||
|
resId = (int)dbCore.LastInsertRowId;
|
||||||
|
}
|
||||||
|
else resId = (int)dataSet2.Tables[0].Rows[0]["id"];
|
||||||
|
|
||||||
|
dbcmd = dbCon.CreateCommand();
|
||||||
|
|
||||||
|
param1 = dbcmd.CreateParameter();
|
||||||
|
param2 = dbcmd.CreateParameter();
|
||||||
|
|
||||||
|
param1.ParameterName = "@gpu";
|
||||||
|
param2.ParameterName = "@resolution";
|
||||||
|
|
||||||
|
param1.DbType = DbType.Int32;
|
||||||
|
param2.DbType = DbType.Int32;
|
||||||
|
|
||||||
|
param1.Value = gpuId;
|
||||||
|
param2.Value = resId;
|
||||||
|
|
||||||
|
sql = "INSERT INTO `resolutions_by_gpu` (`gpu`, `resolution`) VALUES (@gpu, @resolution)";
|
||||||
|
|
||||||
|
dbcmd.Parameters.Add(param1);
|
||||||
|
dbcmd.Parameters.Add(param2);
|
||||||
|
|
||||||
|
dbcmd.CommandText = sql;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
dbcmd.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Removing resolution columns from table `machines`");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `res`;\n" +
|
||||||
|
"ALTER TABLE `machines` DROP COLUMN `colors`;";
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
|
||||||
|
Console.WriteLine("Setting new database version to 19...");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('19')";
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
void OptimizeDatabase()
|
void OptimizeDatabase()
|
||||||
{
|
{
|
||||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ namespace Cicm.Database.Schemas
|
|||||||
public string Cap1;
|
public string Cap1;
|
||||||
/// <summary>Capacity of second removable disk format</summary>
|
/// <summary>Capacity of second removable disk format</summary>
|
||||||
public string Cap2;
|
public string Cap2;
|
||||||
/// <summary>Maximum colors on screen</summary>
|
|
||||||
public int Colors;
|
|
||||||
/// <summary>Manufacturer's company ID</summary>
|
/// <summary>Manufacturer's company ID</summary>
|
||||||
public int Company;
|
public int Company;
|
||||||
/// <summary>ID of first removable disk format</summary>
|
/// <summary>ID of first removable disk format</summary>
|
||||||
@@ -55,8 +53,6 @@ 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>Resolution in WxH pixels</summary>
|
|
||||||
public string Resolution;
|
|
||||||
/// <summary>Machine type</summary>
|
/// <summary>Machine type</summary>
|
||||||
public MachineType Type;
|
public MachineType Type;
|
||||||
/// <summary>Introduction date, 0 if unknown, 1000 if prototype</summary>
|
/// <summary>Introduction date, 0 if unknown, 1000 if prototype</summary>
|
||||||
|
|||||||
49
Cicm.Database/Schemas/Resolution.cs
Normal file
49
Cicm.Database/Schemas/Resolution.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : Processor.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// High level representation of a processor .
|
||||||
|
//
|
||||||
|
// --[ 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>Processor</summary>
|
||||||
|
public class Resolution
|
||||||
|
{
|
||||||
|
/// <summary>If <c>true</c> width and height indicate characters, else they indicate pixels</summary>
|
||||||
|
public bool Chars;
|
||||||
|
/// <summary>Colors</summary>
|
||||||
|
public long Colors;
|
||||||
|
/// <summary>Height</summary>
|
||||||
|
public int Height;
|
||||||
|
/// <summary>Resolution ID</summary>
|
||||||
|
public int Id;
|
||||||
|
/// <summary>Palette, 0 if same as <see cref="Colors" /></summary>
|
||||||
|
public long Palette;
|
||||||
|
/// <summary>Width</summary>
|
||||||
|
public int Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
145
Cicm.Database/Schemas/Sql/V19.cs
Normal file
145
Cicm.Database/Schemas/Sql/V19.cs
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : V19.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 V19
|
||||||
|
{
|
||||||
|
public static readonly string Admins = V18.Admins;
|
||||||
|
|
||||||
|
public static readonly string BrowserTests = V18.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 ('19');";
|
||||||
|
|
||||||
|
public static readonly string Companies = V18.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" +
|
||||||
|
"`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_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 = V18.DiskFormats;
|
||||||
|
|
||||||
|
public static readonly string Forbidden = V18.Forbidden;
|
||||||
|
|
||||||
|
public static readonly string Gpus = V18.Gpus;
|
||||||
|
|
||||||
|
public static readonly string Logs = V18.Logs;
|
||||||
|
|
||||||
|
public static readonly string MoneyDonations = V18.MoneyDonations;
|
||||||
|
|
||||||
|
public static readonly string News = V18.News;
|
||||||
|
|
||||||
|
public static readonly string OwnedComputers = V18.OwnedComputers;
|
||||||
|
|
||||||
|
public static readonly string OwnedConsoles = V18.OwnedConsoles;
|
||||||
|
|
||||||
|
public static readonly string Processors = V18.Processors;
|
||||||
|
|
||||||
|
public static readonly string SoundSynths = V18.SoundSynths;
|
||||||
|
|
||||||
|
public static readonly string MachinesForeignKeys = V18.MachinesForeignKeys;
|
||||||
|
|
||||||
|
public static readonly string Iso3166Numeric = V18.Iso3166Numeric;
|
||||||
|
|
||||||
|
public static readonly string Iso3166NumericValues = V18.Iso3166NumericValues;
|
||||||
|
|
||||||
|
public static readonly string CompaniesForeignKeys = V18.CompaniesForeignKeys;
|
||||||
|
|
||||||
|
public static readonly string CompanyLogos = V18.CompanyLogos;
|
||||||
|
|
||||||
|
public static readonly string CompanyDescriptions = V18.CompanyDescriptions;
|
||||||
|
|
||||||
|
public static readonly string InstructionSets = V18.InstructionSets;
|
||||||
|
|
||||||
|
public static readonly string InstructionSetExtensions = V18.InstructionSetExtensions;
|
||||||
|
|
||||||
|
public static readonly string InstructionSetExtensionsByProcessor = V18.InstructionSetExtensionsByProcessor;
|
||||||
|
|
||||||
|
public static readonly string ProcessorsByMachine = V18.ProcessorsByMachine;
|
||||||
|
|
||||||
|
public static readonly string GpusByMachine = V18.GpusByMachine;
|
||||||
|
|
||||||
|
public static readonly string SoundByMachine = V18.SoundByMachine;
|
||||||
|
|
||||||
|
public static readonly string MemoryByMachine = V18.MemoryByMachine;
|
||||||
|
|
||||||
|
public static readonly string Resolutions =
|
||||||
|
"CREATE TABLE `resolutions` (\n" +
|
||||||
|
"`id` INT NOT NULL AUTO_INCREMENT,\n" +
|
||||||
|
"`width` INT NOT NULL DEFAULT 0,\n" +
|
||||||
|
"`height` INT NOT NULL DEFAULT 0,\n" +
|
||||||
|
"`colors` BIGINT DEFAULT NULL,\n" +
|
||||||
|
"`palette` BIGINT DEFAULT NULL,\n" +
|
||||||
|
"`chars` BOOL NOT NULL DEFAULT 0,\n" + "PRIMARY KEY (`id`),\n" +
|
||||||
|
"KEY `idx_resolutions_width` (`width`),\n" +
|
||||||
|
"KEY `idx_resolutions_height` (`height`),\n" +
|
||||||
|
"KEY `idx_resolutions_colors` (`colors`),\n" +
|
||||||
|
"KEY `idx_resolutions_palette` (`palette`),\n" +
|
||||||
|
"INDEX `idx_resolutions_resolution` (`width`,`height`),\n" +
|
||||||
|
"INDEX `idx_resolutions_resolution_with_color` (`width`,`height`,`colors`),\n" +
|
||||||
|
"INDEX `idx_resolutions_resolution_with_color_and_palette` (`width`,`height`,`colors`,`palette`));";
|
||||||
|
|
||||||
|
public static readonly string ResolutionsByGpu =
|
||||||
|
"CREATE TABLE `resolutions_by_gpu` (\n" +
|
||||||
|
"`gpu` INT NOT NULL,\n" +
|
||||||
|
"`resolution` INT NOT NULL,\n" +
|
||||||
|
"KEY `idx_resolutions_by_gpu_gpu` (`gpu`),\n" +
|
||||||
|
"KEY `idx_resolutions_by_gpu_resolution` (`resolution`),\n" +
|
||||||
|
"CONSTRAINT `fk_resolutions_by_gpu_gpu` FOREIGN KEY (`gpu`) REFERENCES `gpus` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" +
|
||||||
|
"CONSTRAINT `fk_resolutions_by_gpu_resolution` FOREIGN KEY (`resolution`) REFERENCES `resolutions` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,7 +39,6 @@ namespace cicm_web.Models
|
|||||||
{
|
{
|
||||||
public string Cap1;
|
public string Cap1;
|
||||||
public string Cap2;
|
public string Cap2;
|
||||||
public int Colors;
|
|
||||||
public Company Company;
|
public Company Company;
|
||||||
public DiskFormat Disk1;
|
public DiskFormat Disk1;
|
||||||
public DiskFormat Disk2;
|
public DiskFormat Disk2;
|
||||||
@@ -51,7 +50,6 @@ namespace cicm_web.Models
|
|||||||
public MemoryByMachine[] Memories;
|
public MemoryByMachine[] Memories;
|
||||||
public string Model;
|
public string Model;
|
||||||
public ProcessorByMachine[] Processors;
|
public ProcessorByMachine[] Processors;
|
||||||
public string Resolution;
|
|
||||||
public SoundByMachine[] SoundSynths;
|
public SoundByMachine[] SoundSynths;
|
||||||
public MachineType Type;
|
public MachineType Type;
|
||||||
public int Year;
|
public int Year;
|
||||||
@@ -87,7 +85,6 @@ namespace cicm_web.Models
|
|||||||
{
|
{
|
||||||
Machine item = new Machine
|
Machine item = new Machine
|
||||||
{
|
{
|
||||||
Colors = dbItem.Colors,
|
|
||||||
Company = Company.GetItem(dbItem.Company),
|
Company = Company.GetItem(dbItem.Company),
|
||||||
Gpus = GpuByMachine.GetAllItems(dbItem.Id),
|
Gpus = GpuByMachine.GetAllItems(dbItem.Id),
|
||||||
Hdd1 = DiskFormat.GetItem(dbItem.Hdd1),
|
Hdd1 = DiskFormat.GetItem(dbItem.Hdd1),
|
||||||
@@ -95,7 +92,6 @@ 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,
|
||||||
Resolution = dbItem.Resolution,
|
|
||||||
Year = dbItem.Year,
|
Year = dbItem.Year,
|
||||||
Type = dbItem.Type,
|
Type = dbItem.Type,
|
||||||
Processors = ProcessorByMachine.GetAllItems(dbItem.Id),
|
Processors = ProcessorByMachine.GetAllItems(dbItem.Id),
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Copyright © 2003-2018 Natalia Portillo
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
// TODO: Resolutions
|
||||||
ViewData["Title"] = "Computer";
|
ViewData["Title"] = "Computer";
|
||||||
}
|
}
|
||||||
@using System.IO
|
@using System.IO
|
||||||
@@ -489,37 +489,6 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
<tr>
|
|
||||||
<th scope=row>
|
|
||||||
<div align=right>
|
|
||||||
Video resolution
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
@if(Model.Resolution != "???")
|
|
||||||
{
|
|
||||||
<td>@Model.Resolution</td>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<td>Unknown data</td>
|
|
||||||
}
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope=row>
|
|
||||||
<div align=right>
|
|
||||||
Colors
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
@if(Model.Colors > 0)
|
|
||||||
{
|
|
||||||
<td>@Model.Colors</td>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<td>Unknown data</td>
|
|
||||||
}
|
|
||||||
</tr>
|
|
||||||
@if(Model.SoundSynths != null && Model.SoundSynths.Length > 0)
|
@if(Model.SoundSynths != null && Model.SoundSynths.Length > 0)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
<Version>3.0.99.215</Version>
|
<Version>3.0.99.220</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