From cff905283a5f49562df92250035f212cabf21ad2 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 22 Apr 2018 01:35:57 +0100 Subject: [PATCH] Changed how database values are casted in. --- Cicm.Database/Operations/Admin.cs | 6 +- Cicm.Database/Operations/BrowserTest.cs | 34 +++++----- Cicm.Database/Operations/Company.cs | 43 ++++++------ .../Operations/CompanyDescription.cs | 9 ++- Cicm.Database/Operations/CompanyLogos.cs | 8 +-- Cicm.Database/Operations/Computer.cs | 61 ++++++++--------- Cicm.Database/Operations/Console.cs | 47 +++++++------- Cicm.Database/Operations/DiskFormat.cs | 7 +- Cicm.Database/Operations/Forbidden.cs | 10 +-- Cicm.Database/Operations/Gpu.cs | 2 +- Cicm.Database/Operations/InstructionSet.cs | 7 +- .../Operations/InstructionSetExtension.cs | 7 +- Cicm.Database/Operations/Iso3166.cs | 8 +-- Cicm.Database/Operations/Log.cs | 10 +-- Cicm.Database/Operations/MoneyDonation.cs | 6 +- Cicm.Database/Operations/MusicSynth.cs | 6 +- Cicm.Database/Operations/News.cs | 8 +-- Cicm.Database/Operations/OwnedComputer.cs | 34 +++++----- Cicm.Database/Operations/OwnedConsole.cs | 12 ++-- Cicm.Database/Operations/Processor.cs | 65 ++++++++++--------- Cicm.Database/Operations/SoundSynth.cs | 6 +- Cicm.Database/Schemas/Processor.cs | 4 +- cicm_web/Controllers/CompanyController.cs | 2 +- cicm_web/cicm_web.csproj | 2 +- 24 files changed, 184 insertions(+), 220 deletions(-) diff --git a/Cicm.Database/Operations/Admin.cs b/Cicm.Database/Operations/Admin.cs index a8702647..1d3ef395 100644 --- a/Cicm.Database/Operations/Admin.cs +++ b/Cicm.Database/Operations/Admin.cs @@ -277,9 +277,9 @@ namespace Cicm.Database { Admin entry = new Admin { - Id = int.Parse(dataRow["id"].ToString()), - Username = dataRow["user"].ToString(), - Password = dataRow["password"].ToString() + Id = (int)dataRow["id"], + Username = (string)dataRow["user"], + Password = (string)dataRow["password"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/BrowserTest.cs b/Cicm.Database/Operations/BrowserTest.cs index f546bb19..0f214d19 100644 --- a/Cicm.Database/Operations/BrowserTest.cs +++ b/Cicm.Database/Operations/BrowserTest.cs @@ -352,23 +352,23 @@ namespace Cicm.Database { BrowserTest entry = new BrowserTest { - Id = ushort.Parse(dataRow["id"].ToString()), - UserAgent = dataRow["user_agent"].ToString(), - Name = dataRow["browser"].ToString(), - Version = dataRow["version"].ToString(), - OperatingSystem = dataRow["os"].ToString(), - Architecture = dataRow["platform"].ToString(), - Gif87 = int.Parse(dataRow["gif87"].ToString()) > 0, - Gif89 = int.Parse(dataRow["gif89"].ToString()) > 0, - Jpeg = int.Parse(dataRow["jpeg"].ToString()) > 0, - Png = int.Parse(dataRow["png"].ToString()) > 0, - AlphaPng = int.Parse(dataRow["pngt"].ToString()) > 0, - AnimatedGif = int.Parse(dataRow["agif"].ToString()) > 0, - Tables = int.Parse(dataRow["table"].ToString()) > 0, - Color = int.Parse(dataRow["colors"].ToString()) > 0, - Js = int.Parse(dataRow["js"].ToString()) > 0, - Frames = int.Parse(dataRow["frames"].ToString()) > 0, - Flash = int.Parse(dataRow["flash"].ToString()) > 0 + Id = (ushort)dataRow["id"], + UserAgent = (string)dataRow["user_agent"], + Name = (string)dataRow["browser"], + Version = (string)dataRow["version"], + OperatingSystem = (string)dataRow["os"], + Architecture = (string)dataRow["platform"], + Gif87 = (int)dataRow["gif87"] > 0, + Gif89 = (int)dataRow["gif89"] > 0, + Jpeg = (int)dataRow["jpeg"] > 0, + Png = (int)dataRow["png"] > 0, + AlphaPng = (int)dataRow["pngt"] > 0, + AnimatedGif = (int)dataRow["agif"] > 0, + Tables = (int)dataRow["table"] > 0, + Color = (int)dataRow["colors"] > 0, + Js = (int)dataRow["js"] > 0, + Frames = (int)dataRow["frames"] > 0, + Flash = (int)dataRow["flash"] > 0 }; entries.Add(entry); diff --git a/Cicm.Database/Operations/Company.cs b/Cicm.Database/Operations/Company.cs index 6413faf8..30acea02 100644 --- a/Cicm.Database/Operations/Company.cs +++ b/Cicm.Database/Operations/Company.cs @@ -419,31 +419,28 @@ namespace Cicm.Database { Company entry = new Company { - Id = int.Parse(dataRow["id"].ToString()), - Name = dataRow["name"].ToString(), - Website = dataRow["website"].ToString(), - Twitter = dataRow["twitter"].ToString(), - Facebook = dataRow["facebook"].ToString(), - Address = dataRow["address"].ToString(), - City = dataRow["city"].ToString(), - Province = dataRow["province"].ToString(), - PostalCode = dataRow["postal_code"].ToString(), - Status = (CompanyStatus)int.Parse(dataRow["status"].ToString()) + Id = (int)dataRow["id"], + Name = (string)dataRow["name"], + Website = dataRow["website"] == DBNull.Value ? null : (string)dataRow["website"], + Twitter = dataRow["twitter"] == DBNull.Value ? null : (string)dataRow["twitter"], + Facebook = dataRow["facebook"] == DBNull.Value ? null : (string)dataRow["facebook"], + Address = dataRow["address"] == DBNull.Value ? null : (string)dataRow["address"], + City = dataRow["city"] == DBNull.Value ? null : (string)dataRow["city"], + Province = dataRow["province"] == DBNull.Value ? null : (string)dataRow["province"], + PostalCode = dataRow["postal_code"] == DBNull.Value ? null : (string)dataRow["postal_code"], + Status = (CompanyStatus)dataRow["status"], + Founded = + dataRow["founded"] == DBNull.Value + ? DateTime.MinValue + : Convert.ToDateTime(dataRow["founded"].ToString()), + Sold = + dataRow["sold"] == DBNull.Value + ? DateTime.MinValue + : Convert.ToDateTime(dataRow["sold"].ToString()), + SoldTo = dataRow["sold_to"] == DBNull.Value ? null : GetCompany((int)dataRow["sold_to"]), + Country = dataRow["country"] == DBNull.Value ? null : GetIso3166((ushort)dataRow["country"]) }; - if(!string.IsNullOrWhiteSpace(dataRow["founded"].ToString())) - entry.Founded = Convert.ToDateTime(dataRow["founded"].ToString()); - - if(!string.IsNullOrWhiteSpace(dataRow["sold"].ToString()) && - !string.IsNullOrWhiteSpace(dataRow["sold_to"].ToString())) - { - entry.Sold = Convert.ToDateTime(dataRow["sold"].ToString()); - entry.SoldTo = GetCompany(int.Parse(dataRow["sold_to"].ToString())); - } - - if(!string.IsNullOrWhiteSpace(dataRow["country"].ToString())) - entry.Country = GetIso3166(int.Parse(dataRow["country"].ToString())); - if(GetCompanyLogosByCompany(out List logos, entry.Id)) { entry.Logos = logos.ToArray(); diff --git a/Cicm.Database/Operations/CompanyDescription.cs b/Cicm.Database/Operations/CompanyDescription.cs index ec4c74e6..cbcd5671 100644 --- a/Cicm.Database/Operations/CompanyDescription.cs +++ b/Cicm.Database/Operations/CompanyDescription.cs @@ -214,8 +214,7 @@ namespace Cicm.Database IDbTransaction trans = dbCon.BeginTransaction(); dbcmd.Transaction = trans; - const string SQL = - "INSERT INTO company_descriptions (company_id, text) VALUES (@company_id, @text)"; + const string SQL = "INSERT INTO company_descriptions (company_id, text) VALUES (@company_id, @text)"; dbcmd.CommandText = SQL; @@ -315,9 +314,9 @@ namespace Cicm.Database { CompanyDescription entry = new CompanyDescription { - Id = int.Parse(dataRow["id"].ToString()), - CompanyId = int.Parse(dataRow["company_id"].ToString()), - Text = dataRow["text"].ToString() + Id = (int)dataRow["id"], + CompanyId = (int)dataRow["company_id"], + Text = dataRow["text"] == DBNull.Value ? null : (string)dataRow["text"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/CompanyLogos.cs b/Cicm.Database/Operations/CompanyLogos.cs index 188a8481..63f754b3 100644 --- a/Cicm.Database/Operations/CompanyLogos.cs +++ b/Cicm.Database/Operations/CompanyLogos.cs @@ -320,10 +320,10 @@ namespace Cicm.Database { CompanyLogo entry = new CompanyLogo { - Id = int.Parse(dataRow["id"].ToString()), - CompanyId = int.Parse(dataRow["company_id"].ToString()), - Year = int.Parse(dataRow["year"].ToString()), - Guid = Guid.Parse(dataRow["logo_guid"].ToString()) + Id = (int)dataRow["id"], + CompanyId = (int)dataRow["company_id"], + Year = dataRow["year"] == DBNull.Value ? 0 : (int)dataRow["year"], + Guid = (Guid)dataRow["logo_guid"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/Computer.cs b/Cicm.Database/Operations/Computer.cs index 99121a51..13ee8c32 100644 --- a/Cicm.Database/Operations/Computer.cs +++ b/Cicm.Database/Operations/Computer.cs @@ -434,41 +434,32 @@ namespace Cicm.Database { Computer entry = new Computer { - Id = int.Parse(dataRow["id"].ToString()), - Company = int.Parse(dataRow["company"].ToString()), - Year = int.Parse(dataRow["year"].ToString()), - Model = dataRow["model"].ToString(), - Cpu1 = int.Parse(dataRow["cpu1"].ToString()), - Mhz1 = float.Parse(dataRow["mhz1"].ToString()), - Cpu2 = string.IsNullOrEmpty(dataRow["cpu2"].ToString()) - ? 0 - : int.Parse(dataRow["cpu2"].ToString()), - Mhz2 = - string.IsNullOrEmpty(dataRow["mhz2"].ToString()) ? 0 : float.Parse(dataRow["mhz2"].ToString()), - Bits = int.Parse(dataRow["bits"].ToString()), - Ram = int.Parse(dataRow["ram"].ToString()), - Rom = int.Parse(dataRow["rom"].ToString()), - Gpu = int.Parse(dataRow["gpu"].ToString()), - Vram = int.Parse(dataRow["vram"].ToString()), - Colors = int.Parse(dataRow["colors"].ToString()), - Resolution = dataRow["res"].ToString(), - SoundSynth = int.Parse(dataRow["sound_synth"].ToString()), - MusicSynth = int.Parse(dataRow["music_synth"].ToString()), - SoundChannels = int.Parse(dataRow["sound_channels"].ToString()), - MusicChannels = int.Parse(dataRow["music_channels"].ToString()), - Hdd1 = int.Parse(dataRow["hdd1"].ToString()), - Hdd2 = string.IsNullOrEmpty(dataRow["hdd2"].ToString()) - ? 0 - : int.Parse(dataRow["hdd2"].ToString()), - Hdd3 = string.IsNullOrEmpty(dataRow["hdd3"].ToString()) - ? 0 - : int.Parse(dataRow["hdd3"].ToString()), - Disk1 = int.Parse(dataRow["disk1"].ToString()), - Cap1 = dataRow["cap1"].ToString(), - Disk2 = string.IsNullOrEmpty(dataRow["disk2"].ToString()) - ? 0 - : int.Parse(dataRow["disk2"].ToString()), - Cap2 = dataRow["cap2"].ToString() + Id = (int)dataRow["id"], + Company = (int)dataRow["company"], + Year = (int)dataRow["year"], + Model = (string)dataRow["model"], + Cpu1 = (int)dataRow["cpu1"], + Mhz1 = float.Parse(dataRow["mhz1"].ToString()), + Cpu2 = dataRow["cpu2"] == DBNull.Value ? 0 : (int)dataRow["cpu2"], + Mhz2 = dataRow["mhz2"] == DBNull.Value ? 0 : float.Parse(dataRow["mhz2"].ToString()), + Bits = (int)dataRow["bits"], + Ram = (int)dataRow["ram"], + Rom = (int)dataRow["rom"], + Gpu = (int)dataRow["gpu"], + Vram = (int)dataRow["vram"], + Colors = (int)dataRow["colors"], + Resolution = (string)dataRow["res"], + SoundSynth = (int)dataRow["sound_synth"], + MusicSynth = (int)dataRow["music_synth"], + SoundChannels = (int)dataRow["sound_channels"], + MusicChannels = (int)dataRow["music_channels"], + 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"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/Console.cs b/Cicm.Database/Operations/Console.cs index 789f2564..698e0927 100644 --- a/Cicm.Database/Operations/Console.cs +++ b/Cicm.Database/Operations/Console.cs @@ -413,31 +413,28 @@ namespace Cicm.Database { Console entry = new Console { - Id = int.Parse(dataRow["id"].ToString()), - Company = int.Parse(dataRow["company"].ToString()), - Year = int.Parse(dataRow["year"].ToString()), - Model = dataRow["model"].ToString(), - Cpu1 = int.Parse(dataRow["cpu1"].ToString()), - Mhz1 = float.Parse(dataRow["mhz1"].ToString()), - Cpu2 = string.IsNullOrEmpty(dataRow["cpu2"].ToString()) - ? 0 - : int.Parse(dataRow["cpu2"].ToString()), - Mhz2 = - string.IsNullOrEmpty(dataRow["mhz2"].ToString()) ? 0 : float.Parse(dataRow["mhz2"].ToString()), - Bits = int.Parse(dataRow["bits"].ToString()), - Ram = int.Parse(dataRow["ram"].ToString()), - Rom = int.Parse(dataRow["rom"].ToString()), - Gpu = int.Parse(dataRow["gpu"].ToString()), - Vram = int.Parse(dataRow["vram"].ToString()), - Colors = int.Parse(dataRow["colors"].ToString()), - Resolution = dataRow["res"].ToString(), - SoundSynth = int.Parse(dataRow["sound_synth"].ToString()), - MusicSynth = int.Parse(dataRow["music_synth"].ToString()), - SoundChannels = int.Parse(dataRow["schannels"].ToString()), - MusicChannels = int.Parse(dataRow["mchannels"].ToString()), - Palette = int.Parse(dataRow["palette"].ToString()), - Format = int.Parse(dataRow["format"].ToString()), - Cap = int.Parse(dataRow["cap"].ToString()) + Id = (int)dataRow["id"], + Company = (int)dataRow["company"], + Year = (int)dataRow["year"], + Model = (string)dataRow["model"], + Cpu1 = (int)dataRow["cpu1"], + Mhz1 = float.Parse(dataRow["mhz1"].ToString()), + Cpu2 = dataRow["cpu2"] == DBNull.Value ? 0 : (int)dataRow["cpu2"], + Mhz2 = dataRow["mhz2"] == DBNull.Value ? 0 : float.Parse(dataRow["mhz2"].ToString()), + Bits = (int)dataRow["bits"], + Ram = (int)dataRow["ram"], + Rom = (int)dataRow["rom"], + Gpu = (int)dataRow["gpu"], + Vram = (int)dataRow["vram"], + Colors = (int)dataRow["colors"], + Resolution = (string)dataRow["res"], + SoundSynth = (int)dataRow["sound_synth"], + MusicSynth = (int)dataRow["music_synth"], + SoundChannels = (int)dataRow["schannels"], + MusicChannels = (int)dataRow["mchannels"], + Palette = (int)dataRow["palette"], + Format = (int)dataRow["format"], + Cap = (int)dataRow["cap"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/DiskFormat.cs b/Cicm.Database/Operations/DiskFormat.cs index 24c92ec5..f8cedcd1 100644 --- a/Cicm.Database/Operations/DiskFormat.cs +++ b/Cicm.Database/Operations/DiskFormat.cs @@ -270,11 +270,8 @@ namespace Cicm.Database foreach(DataRow dataRow in dataTable.Rows) { - DiskFormat entry = new DiskFormat - { - Id = int.Parse(dataRow["id"].ToString()), - Description = dataRow["description"].ToString() - }; + DiskFormat entry = + new DiskFormat {Id = (int)dataRow["id"], Description = (string)dataRow["description"]}; entries.Add(entry); } diff --git a/Cicm.Database/Operations/Forbidden.cs b/Cicm.Database/Operations/Forbidden.cs index f72441d5..18e32adc 100644 --- a/Cicm.Database/Operations/Forbidden.cs +++ b/Cicm.Database/Operations/Forbidden.cs @@ -289,11 +289,11 @@ namespace Cicm.Database { Forbidden entry = new Forbidden { - Id = int.Parse(dataRow["id"].ToString()), - UserAgent = dataRow["browser"].ToString(), - Date = dataRow["date"].ToString(), - Ip = dataRow["ip"].ToString(), - Referer = dataRow["referer"].ToString() + Id = (int)dataRow["id"], + UserAgent = (string)dataRow["browser"], + Date = (string)dataRow["date"], + Ip = (string)dataRow["ip"], + Referer = (string)dataRow["referer"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/Gpu.cs b/Cicm.Database/Operations/Gpu.cs index 6264372e..fffbd464 100644 --- a/Cicm.Database/Operations/Gpu.cs +++ b/Cicm.Database/Operations/Gpu.cs @@ -270,7 +270,7 @@ namespace Cicm.Database foreach(DataRow dataRow in dataTable.Rows) { - Gpu entry = new Gpu {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["name"].ToString()}; + Gpu entry = new Gpu {Id = (int)dataRow["id"], Name = (string)dataRow["name"]}; entries.Add(entry); } diff --git a/Cicm.Database/Operations/InstructionSet.cs b/Cicm.Database/Operations/InstructionSet.cs index a3a4e077..1c55c8cc 100644 --- a/Cicm.Database/Operations/InstructionSet.cs +++ b/Cicm.Database/Operations/InstructionSet.cs @@ -270,11 +270,8 @@ namespace Cicm.Database foreach(DataRow dataRow in dataTable.Rows) { - InstructionSet entry = new InstructionSet - { - Id = int.Parse(dataRow["id"].ToString()), - Name = dataRow["instruction_set"].ToString() - }; + InstructionSet entry = + new InstructionSet {Id = (int)dataRow["id"], Name = (string)dataRow["instruction_set"]}; entries.Add(entry); } diff --git a/Cicm.Database/Operations/InstructionSetExtension.cs b/Cicm.Database/Operations/InstructionSetExtension.cs index 92f6d362..6ee12342 100644 --- a/Cicm.Database/Operations/InstructionSetExtension.cs +++ b/Cicm.Database/Operations/InstructionSetExtension.cs @@ -309,11 +309,8 @@ namespace Cicm.Database foreach(DataRow dataRow in dataTable.Rows) { - InstructionSetExtension entry = new InstructionSetExtension - { - Id = int.Parse(dataRow["id"].ToString()), - Name = dataRow["extension"].ToString() - }; + InstructionSetExtension entry = + new InstructionSetExtension {Id = (int)dataRow["id"], Name = (string)dataRow["extension"]}; entries.Add(entry); } diff --git a/Cicm.Database/Operations/Iso3166.cs b/Cicm.Database/Operations/Iso3166.cs index d217ab2e..c0e7fbd0 100644 --- a/Cicm.Database/Operations/Iso3166.cs +++ b/Cicm.Database/Operations/Iso3166.cs @@ -115,7 +115,7 @@ namespace Cicm.Database /// /// Id /// ISO 3166-1 code with specified id, null if not found or error - public Iso3166 GetIso3166(int id) + public Iso3166 GetIso3166(ushort id) { #if DEBUG Console.WriteLine("Getting ISO 3166-1 code with id {0}...", id); @@ -270,11 +270,7 @@ namespace Cicm.Database foreach(DataRow dataRow in dataTable.Rows) { - Iso3166 entry = new Iso3166 - { - Id = ushort.Parse(dataRow["id"].ToString()), - Name = dataRow["name"].ToString() - }; + Iso3166 entry = new Iso3166 {Id = (ushort)dataRow["id"], Name = (string)dataRow["name"]}; entries.Add(entry); } diff --git a/Cicm.Database/Operations/Log.cs b/Cicm.Database/Operations/Log.cs index fc660a3a..4f8637fb 100644 --- a/Cicm.Database/Operations/Log.cs +++ b/Cicm.Database/Operations/Log.cs @@ -289,11 +289,11 @@ namespace Cicm.Database { Log entry = new Log { - Id = int.Parse(dataRow["id"].ToString()), - UserAgent = dataRow["browser"].ToString(), - Date = dataRow["date"].ToString(), - Ip = dataRow["ip"].ToString(), - Referer = dataRow["referer"].ToString() + Id = (int)dataRow["id"], + UserAgent = (string)dataRow["browser"], + Date = (string)dataRow["date"], + Ip = (string)dataRow["ip"], + Referer = (string)dataRow["referer"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/MoneyDonation.cs b/Cicm.Database/Operations/MoneyDonation.cs index 1a0cb45c..8f1ef85b 100644 --- a/Cicm.Database/Operations/MoneyDonation.cs +++ b/Cicm.Database/Operations/MoneyDonation.cs @@ -278,9 +278,9 @@ namespace Cicm.Database { MoneyDonation entry = new MoneyDonation { - Id = int.Parse(dataRow["id"].ToString()), - Donator = dataRow["browser"].ToString(), - Quantity = float.Parse(dataRow["date"].ToString()) + Id = (int)dataRow["id"], + Donator = (string)dataRow["browser"], + Quantity = (float)dataRow["date"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/MusicSynth.cs b/Cicm.Database/Operations/MusicSynth.cs index a17ddda1..c5df7453 100644 --- a/Cicm.Database/Operations/MusicSynth.cs +++ b/Cicm.Database/Operations/MusicSynth.cs @@ -265,11 +265,7 @@ namespace Cicm.Database foreach(DataRow dataRow in dataTable.Rows) { - MusicSynth entry = new MusicSynth - { - Id = int.Parse(dataRow["id"].ToString()), - Name = dataRow["name"].ToString() - }; + MusicSynth entry = new MusicSynth {Id = (int)dataRow["id"], Name = (string)dataRow["name"]}; entries.Add(entry); } diff --git a/Cicm.Database/Operations/News.cs b/Cicm.Database/Operations/News.cs index c25d29da..82d3622f 100644 --- a/Cicm.Database/Operations/News.cs +++ b/Cicm.Database/Operations/News.cs @@ -282,10 +282,10 @@ namespace Cicm.Database { News entry = new News { - Id = int.Parse(dataRow["id"].ToString()), - Date = dataRow["date"].ToString(), - Type = (NewsType)int.Parse(dataRow["type"].ToString()), - AffectedId = int.Parse(dataRow["added_id"].ToString()) + Id = (int)dataRow["id"], + Date = (string)dataRow["date"], + Type = (NewsType)dataRow["type"], + AffectedId = (int)dataRow["added_id"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/OwnedComputer.cs b/Cicm.Database/Operations/OwnedComputer.cs index 768fdb5a..58766573 100644 --- a/Cicm.Database/Operations/OwnedComputer.cs +++ b/Cicm.Database/Operations/OwnedComputer.cs @@ -357,24 +357,24 @@ namespace Cicm.Database { OwnedComputer entry = new OwnedComputer { - Id = int.Parse(dataRow["id"].ToString()), - ComputerId = int.Parse(dataRow["db_id"].ToString()), + Id = (int)dataRow["id"], + ComputerId = (int)dataRow["db_id"], Acquired = dataRow["date"].ToString(), - Status = (StatusType)int.Parse(dataRow["status"].ToString()), - Trade = int.Parse(dataRow["trade"].ToString()) > 0, - Boxed = int.Parse(dataRow["boxed"].ToString()) > 0, - Manuals = int.Parse(dataRow["manuals"].ToString()) > 0, - Cpu1 = int.Parse(dataRow["cpu1"].ToString()), - Mhz1 = float.Parse(dataRow["mhz1"].ToString()), - Cpu2 = int.Parse(dataRow["cpu1"].ToString()), - Mhz2 = float.Parse(dataRow["mhz2"].ToString()), - Ram = int.Parse(dataRow["ram"].ToString()), - Vram = int.Parse(dataRow["vram"].ToString()), - Rigid = dataRow["rigid"].ToString(), - Disk1 = int.Parse(dataRow["disk1"].ToString()), - Cap1 = int.Parse(dataRow["cap1"].ToString()), - Disk2 = int.Parse(dataRow["disk2"].ToString()), - Cap2 = int.Parse(dataRow["cap2"].ToString()) + Status = (StatusType)dataRow["status"], + Trade = (int)dataRow["trade"] > 0, + Boxed = (int)dataRow["boxed"] > 0, + Manuals = (int)dataRow["manuals"] > 0, + Cpu1 = (int)dataRow["cpu1"], + Mhz1 = (float)dataRow["mhz1"], + Cpu2 = (int)dataRow["cpu1"], + 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"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/OwnedConsole.cs b/Cicm.Database/Operations/OwnedConsole.cs index da156c24..c44e08a2 100644 --- a/Cicm.Database/Operations/OwnedConsole.cs +++ b/Cicm.Database/Operations/OwnedConsole.cs @@ -300,13 +300,13 @@ namespace Cicm.Database { OwnedConsole entry = new OwnedConsole { - Id = int.Parse(dataRow["id"].ToString()), - ConsoleId = int.Parse(dataRow["db_id"].ToString()), + Id = (int)dataRow["id"], + ConsoleId = (int)dataRow["db_id"], Acquired = dataRow["date"].ToString(), - Status = (StatusType)int.Parse(dataRow["status"].ToString()), - Trade = int.Parse(dataRow["trade"].ToString()) > 0, - Boxed = int.Parse(dataRow["boxed"].ToString()) > 0, - Manuals = int.Parse(dataRow["manuals"].ToString()) > 0 + Status = (StatusType)dataRow["status"], + Trade = (int)dataRow["trade"] > 0, + Boxed = (int)dataRow["boxed"] > 0, + Manuals = (int)dataRow["manuals"] > 0 }; entries.Add(entry); diff --git a/Cicm.Database/Operations/Processor.cs b/Cicm.Database/Operations/Processor.cs index 3fd2bc6c..f3858c3c 100644 --- a/Cicm.Database/Operations/Processor.cs +++ b/Cicm.Database/Operations/Processor.cs @@ -376,40 +376,41 @@ namespace Cicm.Database { Processor entry = new Processor { - Id = int.Parse(dataRow["id"].ToString()), - Name = dataRow["name"].ToString(), - ModelCode = dataRow["model_code"].ToString(), - Speed = Convert.ToDouble(dataRow["speed"].ToString()), - Package = dataRow["package"].ToString(), - Gpr = Convert.ToInt32(dataRow["GPRs"].ToString()), - GprSize = Convert.ToInt32(dataRow["GPR_size"].ToString()), - Fpr = Convert.ToInt32(dataRow["FPRs"].ToString()), - FprSize = Convert.ToInt32(dataRow["FPR_size"].ToString()), - Cores = Convert.ToInt32(dataRow["cores"].ToString()), - ThreadsPerCore = Convert.ToInt32(dataRow["threads_per_core"].ToString()), - Process = dataRow["process"].ToString(), - ProcessNm = Convert.ToSingle(dataRow["process_nm"].ToString()), - DieSize = Convert.ToSingle(dataRow["die_size"].ToString()), - Transistors = Convert.ToUInt64(dataRow["transistors"].ToString()), - AddressBus = Convert.ToInt32(dataRow["addr_bus"].ToString()), - DataBus = Convert.ToInt32(dataRow["data_bus"].ToString()), - Simd = Convert.ToInt32(dataRow["SIMD_registers"].ToString()), - SimdSize = Convert.ToInt32(dataRow["SIMD_size"].ToString()), - L1Instruction = Convert.ToSingle(dataRow["L1_instruction"].ToString()), - L1Data = Convert.ToSingle(dataRow["L1_data"].ToString()), - L2 = Convert.ToSingle(dataRow["L2"].ToString()), - L3 = Convert.ToSingle(dataRow["L3"].ToString()) + Id = (int)dataRow["id"], + Name = (string)dataRow["name"], + ModelCode = dataRow["model_code"] == DBNull.Value ? null : (string)dataRow["model_code"], + Speed = dataRow["speed"] == DBNull.Value ? 0 : (double)dataRow["speed"], + Package = dataRow["package"] == DBNull.Value ? null : (string)dataRow["package"], + Gpr = dataRow["GPRs"] == DBNull.Value ? 0 : (int)dataRow["GPRs"], + GprSize = dataRow["GPR_size"] == DBNull.Value ? 0 : (int)dataRow["GPR_size"], + Fpr = dataRow["FPRs"] == DBNull.Value ? 0 : (int)dataRow["FPRs"], + FprSize = dataRow["FPR_size"] == DBNull.Value ? 0 : (int)dataRow["FPR_size"], + Cores = dataRow["cores"] == DBNull.Value ? 0 : (int)dataRow["cores"], + ThreadsPerCore = dataRow["threads_per_core"] == DBNull.Value ? 0 : (int)dataRow["threads_per_core"], + Process = dataRow["process"] == DBNull.Value ? null : (string)dataRow["process"], + ProcessNm = dataRow["process_nm"] == DBNull.Value ? 0 : (float)dataRow["process_nm"], + DieSize = dataRow["die_size"] == DBNull.Value ? 0 : (float)dataRow["die_size"], + Transistors = dataRow["transistors"] == DBNull.Value ? 0 : (ulong)dataRow["transistors"], + AddressBus = dataRow["addr_bus"] == DBNull.Value ? 0 : (int)dataRow["addr_bus"], + DataBus = dataRow["data_bus"] == DBNull.Value ? 0 : (int)dataRow["data_bus"], + Simd = dataRow["SIMD_registers"] == DBNull.Value ? 0 : (int)dataRow["SIMD_registers"], + SimdSize = dataRow["SIMD_size"] == DBNull.Value ? 0 : (int)dataRow["SIMD_size"], + L1Instruction = dataRow["L1_instruction"] == DBNull.Value ? 0 : (float)dataRow["L1_instruction"], + L1Data = dataRow["L1_data"] == DBNull.Value ? 0 : (float)dataRow["L1_data"], + L2 = dataRow["L2"] == DBNull.Value ? 0 : (float)dataRow["L2"], + L3 = dataRow["L3"] == DBNull.Value ? 0 : (float)dataRow["L3"], + Company = dataRow["company"] == DBNull.Value + ? null + : GetCompany((int)dataRow["company"]), + Introduced = + dataRow["introduced"] == DBNull.Value + ? DateTime.MinValue + : Convert.ToDateTime(dataRow["introduced"]), + InstructionSet = dataRow["instruction_set"] == DBNull.Value + ? null + : GetInstructionSet((int)dataRow["instruction_set"]) }; - if(!string.IsNullOrEmpty(dataRow["company"].ToString())) - entry.Company = GetCompany(Convert.ToInt32(dataRow["company"].ToString())); - - if(!string.IsNullOrEmpty(dataRow["introduced"].ToString())) - entry.Introduced = Convert.ToDateTime(dataRow["introduced"].ToString()); - - if(!string.IsNullOrEmpty(dataRow["instruction_set"].ToString())) - entry.InstructionSet = GetInstructionSet(Convert.ToInt32(dataRow["instruction_set"].ToString())); - entries.Add(entry); } diff --git a/Cicm.Database/Operations/SoundSynth.cs b/Cicm.Database/Operations/SoundSynth.cs index 36f7c631..23812bab 100644 --- a/Cicm.Database/Operations/SoundSynth.cs +++ b/Cicm.Database/Operations/SoundSynth.cs @@ -270,11 +270,7 @@ namespace Cicm.Database foreach(DataRow dataRow in dataTable.Rows) { - SoundSynth entry = new SoundSynth - { - Id = int.Parse(dataRow["id"].ToString()), - Name = dataRow["name"].ToString() - }; + SoundSynth entry = new SoundSynth {Id = (int)dataRow["id"], Name = (string)dataRow["name"]}; entries.Add(entry); } diff --git a/Cicm.Database/Schemas/Processor.cs b/Cicm.Database/Schemas/Processor.cs index bbe76555..dfbe8ce0 100644 --- a/Cicm.Database/Schemas/Processor.cs +++ b/Cicm.Database/Schemas/Processor.cs @@ -61,9 +61,9 @@ namespace Cicm.Database.Schemas public InstructionSetExtension[] InstructionSetExtensions; /// Datetime of introduction public DateTime Introduced; - /// Size in kibibytes of L1 data cache. If 0, is size of L1 unified cache + /// Size in kibibytes of L1 data cache. If -1, is size of L1 unified cache public float L1Data; - /// Size in kibibytes of L1 instruction cache. If is 0, this is size of L1 unified cache + /// Size in kibibytes of L1 instruction cache. If is -1, this is size of L1 unified cache public float L1Instruction; /// /// Size in kibibytes of L2 cache. It includes cache that's in same physical package but not in same chip die diff --git a/cicm_web/Controllers/CompanyController.cs b/cicm_web/Controllers/CompanyController.cs index e3cb96bf..ac64db12 100644 --- a/cicm_web/Controllers/CompanyController.cs +++ b/cicm_web/Controllers/CompanyController.cs @@ -68,7 +68,7 @@ namespace cicm_web.Controllers return View(company); } - public IActionResult ByCountry(int id) + public IActionResult ByCountry(ushort id) { Iso3166 iso3166 = Program.Database.Operations.GetIso3166(id); diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index cee262f4..a51dc41f 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - 3.0.99.158 + 3.0.99.176 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website