mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Code refactor.
This commit is contained in:
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -86,7 +86,8 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM machines WHERE company = '{company}' AND type = '{(int)MachineType.Computer}'";
|
||||
string sql =
|
||||
$"SELECT * FROM machines WHERE company = '{company}' AND type = '{(int)MachineType.Computer}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -123,7 +124,8 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM machines LIMIT {start}, {count} WHERE type = '{(int)MachineType.Computer}'";
|
||||
string sql =
|
||||
$"SELECT * FROM machines LIMIT {start}, {count} WHERE type = '{(int)MachineType.Computer}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
|
||||
@@ -86,7 +86,8 @@ namespace Cicm.Database
|
||||
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT * FROM machines WHERE company = '{company}' AND type = '{(int)MachineType.Console}'";
|
||||
string sql =
|
||||
$"SELECT * FROM machines WHERE company = '{company}' AND type = '{(int)MachineType.Console}'";
|
||||
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -134,11 +134,7 @@ namespace Cicm.Database
|
||||
|
||||
foreach(DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
GpuByMachine entry = new GpuByMachine
|
||||
{
|
||||
Machine = (int)dataRow["machine"],
|
||||
Gpu = (int)dataRow["gpu"]
|
||||
};
|
||||
GpuByMachine entry = new GpuByMachine {Machine = (int)dataRow["machine"], Gpu = (int)dataRow["gpu"]};
|
||||
|
||||
entries.Add(entry);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Cicm.Database
|
||||
param1.Value = entry.Machine;
|
||||
param2.Value = entry.Type;
|
||||
param3.Value = entry.Usage;
|
||||
param4.Value = entry.Size == 0 ? (object)null : entry.Size;
|
||||
param4.Value = entry.Size == 0 ? (object)null : entry.Size;
|
||||
param5.Value = entry.Speed <= 0 ? (object)null : entry.Speed;
|
||||
|
||||
dbcmd.Parameters.Add(param1);
|
||||
@@ -156,7 +156,7 @@ namespace Cicm.Database
|
||||
Type = (MemoryType)dataRow["type"],
|
||||
Usage = (MemoryUsage)dataRow["usage"],
|
||||
Size = dataRow["size"] == DBNull.Value ? 0 : (long)dataRow["size"],
|
||||
Speed = dataRow["speed"] == DBNull.Value ? 0 : (double)dataRow["speed"],
|
||||
Speed = dataRow["speed"] == DBNull.Value ? 0 : (double)dataRow["speed"]
|
||||
};
|
||||
|
||||
entries.Add(entry);
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Cicm.Database.Schemas;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cicm.Database
|
||||
{
|
||||
|
||||
@@ -2554,8 +2554,8 @@ namespace Cicm.Database
|
||||
Console.WriteLine("Updating database to version 23");
|
||||
|
||||
Console.WriteLine("Altering `browser_tests` primary key");
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbCmd.Transaction = trans;
|
||||
dbCmd.CommandText = "ALTER TABLE browser_tests MODIFY id int NOT NULL auto_increment;";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
@@ -2570,7 +2570,7 @@ namespace Cicm.Database
|
||||
dbCmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbCmd.Dispose();
|
||||
|
||||
|
||||
Console.WriteLine("Altering `iso3166_1_numeric` primary key");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
trans = dbCon.BeginTransaction();
|
||||
@@ -2584,8 +2584,7 @@ namespace Cicm.Database
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
trans = dbCon.BeginTransaction();
|
||||
dbCmd.Transaction = trans;
|
||||
dbCmd.CommandText =
|
||||
"ALTER TABLE companies MODIFY country smallint(3);";
|
||||
dbCmd.CommandText = "ALTER TABLE companies MODIFY country smallint(3);";
|
||||
dbCmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbCmd.Dispose();
|
||||
@@ -2599,7 +2598,7 @@ namespace Cicm.Database
|
||||
dbCmd.ExecuteNonQuery();
|
||||
trans.Commit();
|
||||
dbCmd.Dispose();
|
||||
|
||||
|
||||
Console.WriteLine("Adding primary keys to several tables");
|
||||
dbCmd = dbCon.CreateCommand();
|
||||
trans = dbCon.BeginTransaction();
|
||||
@@ -2621,6 +2620,7 @@ namespace Cicm.Database
|
||||
dbCmd.ExecuteNonQuery();
|
||||
dbCmd.Dispose();
|
||||
}
|
||||
|
||||
void OptimizeDatabase()
|
||||
{
|
||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||
|
||||
@@ -41,6 +41,8 @@ namespace Cicm.Database.Schemas
|
||||
public string City;
|
||||
/// <summary>Country</summary>
|
||||
public Iso3166 Country;
|
||||
/// <summary>Description</summary>
|
||||
public string Description;
|
||||
/// <summary>Facebook account</summary>
|
||||
public string Facebook;
|
||||
/// <summary>Founding date</summary>
|
||||
@@ -67,7 +69,5 @@ namespace Cicm.Database.Schemas
|
||||
public string Twitter;
|
||||
/// <summary>Website</summary>
|
||||
public string Website;
|
||||
/// <summary>Description</summary>
|
||||
public string Description;
|
||||
}
|
||||
}
|
||||
@@ -28,17 +28,15 @@
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Cicm.Database.Schemas
|
||||
{
|
||||
/// <summary>Company description</summary>
|
||||
public class CompanyDescription
|
||||
{
|
||||
/// <summary>ID</summary>
|
||||
public int Id;
|
||||
/// <summary>Company ID</summary>
|
||||
public int CompanyId;
|
||||
/// <summary>ID</summary>
|
||||
public int Id;
|
||||
/// <summary>Description</summary>
|
||||
public string Text;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace Cicm.Database.Schemas
|
||||
/// <summary>Computer</summary>
|
||||
public class GpuByMachine
|
||||
{
|
||||
/// <summary>Machine ID</summary>
|
||||
public int Machine;
|
||||
/// <summary>GPU ID</summary>
|
||||
public int Gpu;
|
||||
/// <summary>Machine ID</summary>
|
||||
public int Machine;
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,13 @@ namespace Cicm.Database.Schemas
|
||||
{
|
||||
/// <summary>Machine ID</summary>
|
||||
public int Machine;
|
||||
/// <summary>Memory type</summary>
|
||||
public MemoryType Type;
|
||||
/// <summary>Memory usage</summary>
|
||||
public MemoryUsage Usage;
|
||||
/// <summary>Memory size in bytes</summary>
|
||||
public long Size;
|
||||
/// <summary>Memory speed in Hz</summary>
|
||||
public double Speed;
|
||||
/// <summary>Memory type</summary>
|
||||
public MemoryType Type;
|
||||
/// <summary>Memory usage</summary>
|
||||
public MemoryUsage Usage;
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ namespace Cicm.Database.Schemas.Sql
|
||||
`manuals` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
);";
|
||||
|
||||
|
||||
public static readonly string Processors = @"CREATE TABLE IF NOT EXISTS `processors` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` char(50) NOT NULL DEFAULT '',
|
||||
|
||||
@@ -72,24 +72,26 @@ namespace Cicm.Database.Schemas.Sql
|
||||
|
||||
public static readonly string SoundSynths = V4.SoundSynths;
|
||||
|
||||
public static readonly string ComputersForeignKeys = "ALTER TABLE computers ADD FOREIGN KEY fk_computers_company (company) REFERENCES companies (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu1 (cpu1) REFERENCES processors (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu2 (cpu2) REFERENCES processors (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_gpu (gpu) REFERENCES gpus (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_sound_synth (sound_synth) REFERENCES sound_synths (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_music_synth (music_synth) REFERENCES music_synths (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd1 (hdd1) REFERENCES disk_formats (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd2 (hdd2) REFERENCES disk_formats (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd3 (hdd3) REFERENCES disk_formats (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk1 (disk1) REFERENCES disk_formats (id);\n"+
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk2 (disk2) REFERENCES disk_formats (id);";
|
||||
|
||||
public static readonly string ConsolesForeignKeys = "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_company (company) REFERENCES companies (id);\n" +
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu1 (cpu1) REFERENCES processors (id);\n"+
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu2 (cpu2) REFERENCES processors (id);\n"+
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_gpu (gpu) REFERENCES gpus (id);\n"+
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_sound_synth (sound_synth) REFERENCES sound_synths (id);\n"+
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_music_synth (music_synth) REFERENCES music_synths (id);\n"+
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_format (format) REFERENCES disk_formats (id);";
|
||||
public static readonly string ComputersForeignKeys =
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_company (company) REFERENCES companies (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu1 (cpu1) REFERENCES processors (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu2 (cpu2) REFERENCES processors (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_gpu (gpu) REFERENCES gpus (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_music_synth (music_synth) REFERENCES music_synths (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd1 (hdd1) REFERENCES disk_formats (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd2 (hdd2) REFERENCES disk_formats (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd3 (hdd3) REFERENCES disk_formats (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk1 (disk1) REFERENCES disk_formats (id);\n" +
|
||||
"ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk2 (disk2) REFERENCES disk_formats (id);";
|
||||
|
||||
public static readonly string ConsolesForeignKeys =
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_company (company) REFERENCES companies (id);\n" +
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu1 (cpu1) REFERENCES processors (id);\n" +
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu2 (cpu2) REFERENCES processors (id);\n" +
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_gpu (gpu) REFERENCES gpus (id);\n" +
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" +
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_music_synth (music_synth) REFERENCES music_synths (id);\n" +
|
||||
"ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_format (format) REFERENCES disk_formats (id);";
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ namespace Cicm.Database.Schemas.Sql
|
||||
public static readonly string CompanyLogos = "CREATE TABLE IF NOT EXISTS `company_logos` (\n" +
|
||||
"`id` INT NOT NULL AUTO_INCREMENT,\n" +
|
||||
"`company_id` INT(11) NOT NULL,\n" +
|
||||
"`year` INT(4) DEFAULT NULL,\n" +
|
||||
"`year` INT(4) DEFAULT NULL,\n" +
|
||||
"`logo_guid` CHAR(36) NOT NULL,\n" +
|
||||
"PRIMARY KEY (`id`, `company_id`, `logo_guid`),\n" +
|
||||
"UNIQUE INDEX `idx_id` (`id` ASC),\n" +
|
||||
|
||||
Reference in New Issue
Block a user