Update DB to version 15: Machines can have an arbitrary number of processors,

so use an interconnection table, `processors_by_machine`.
This commit is contained in:
2018-04-28 13:16:53 +01:00
parent d8127630b3
commit 02b9981681
12 changed files with 853 additions and 599 deletions

View File

@@ -37,32 +37,29 @@ namespace cicm_web.Models
{
public class Machine
{
public string Cap1;
public string Cap2;
public int Colors;
public Company Company;
public Processor Cpu1;
public Processor Cpu2;
public DiskFormat Disk1;
public DiskFormat Disk2;
public Gpu Gpu;
public DiskFormat Hdd1;
public DiskFormat Hdd2;
public DiskFormat Hdd3;
public int Id;
public float Mhz1;
public float Mhz2;
public string Model;
public int MusicChannels;
public SoundSynth MusicSynth;
public int Ram;
public string Resolution;
public int Rom;
public int SoundChannels;
public SoundSynth SoundSynth;
public MachineType Type;
public int Vram;
public int Year;
public string Cap1;
public string Cap2;
public int Colors;
public Company Company;
public DiskFormat Disk1;
public DiskFormat Disk2;
public Gpu Gpu;
public DiskFormat Hdd1;
public DiskFormat Hdd2;
public DiskFormat Hdd3;
public int Id;
public string Model;
public int MusicChannels;
public SoundSynth MusicSynth;
public ProcessorByMachine[] Processors;
public int Ram;
public string Resolution;
public int Rom;
public int SoundChannels;
public SoundSynth SoundSynth;
public MachineType Type;
public int Vram;
public int Year;
public static Machine[] GetAllItems()
{
@@ -108,7 +105,8 @@ namespace cicm_web.Models
Rom = dbItem.Rom,
Vram = dbItem.Vram,
Year = dbItem.Year,
Type = dbItem.Type
Type = dbItem.Type,
Processors = ProcessorByMachine.GetAllItems(dbItem.Id)
};
if(dbItem.Disk1 > 0)
@@ -123,18 +121,6 @@ namespace cicm_web.Models
item.Disk2 = DiskFormat.GetItem(dbItem.Disk2);
}
if(dbItem.Cpu1 > 0)
{
item.Cpu1 = Processor.GetItem(dbItem.Cpu1);
item.Mhz1 = dbItem.Mhz1;
}
if(dbItem.Cpu2 > 0)
{
item.Cpu2 = Processor.GetItem(dbItem.Cpu2);
item.Mhz2 = dbItem.Mhz2;
}
if(dbItem.MusicSynth > 0)
{
item.MusicSynth = SoundSynth.GetItem(dbItem.MusicSynth);

View File

@@ -0,0 +1,59 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : ProcessorByMachine.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Processor by machine model
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/
using System.Collections.Generic;
namespace cicm_web.Models
{
public class ProcessorByMachine
{
public Processor Processor;
public float Speed;
public static ProcessorByMachine[] GetAllItems(int machineId)
{
List<Cicm.Database.Schemas.ProcessorByMachine> dbItems = null;
bool? result =
Program.Database?.Operations.GetProcessorsByMachines(out dbItems, machineId);
if(result == null || result.Value == false || dbItems == null) return null;
List<ProcessorByMachine> items = new List<ProcessorByMachine>();
foreach(Cicm.Database.Schemas.ProcessorByMachine dbItem in dbItems)
items.Add(new ProcessorByMachine
{
Processor = Processor.GetItem(dbItem.Processor),
Speed = dbItem.Speed
});
return items.ToArray();
}
}
}