mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move device statistics to database.
This commit is contained in:
3
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
3
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -307,11 +307,14 @@
|
||||
<e p="20181221015906_NameValueStatistics.cs" t="Include" />
|
||||
<e p="20181221032605_MediaStatistics.Designer.cs" t="Include" />
|
||||
<e p="20181221032605_MediaStatistics.cs" t="Include" />
|
||||
<e p="20181221034941_SeenDevicesStatistics.Designer.cs" t="Include" />
|
||||
<e p="20181221034941_SeenDevicesStatistics.cs" t="Include" />
|
||||
<e p="DicContextModelSnapshot.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Models" t="Include">
|
||||
<e p="Command.cs" t="Include" />
|
||||
<e p="Device.cs" t="Include" />
|
||||
<e p="DeviceStat.cs" t="Include" />
|
||||
<e p="Filesystem.cs" t="Include" />
|
||||
<e p="Filter.cs" t="Include" />
|
||||
<e p="Media.cs" t="Include" />
|
||||
|
||||
@@ -393,39 +393,14 @@ namespace DiscImageChef.Core
|
||||
else if(dev.IsFireWire) deviceBus = "FireWire";
|
||||
else deviceBus = dev.Type.ToString();
|
||||
|
||||
DeviceStats old = AllStats.Devices.FirstOrDefault(ds => ds.Manufacturer == dev.Manufacturer &&
|
||||
ds.Model == dev.Model &&
|
||||
ds.Revision == dev.Revision &&
|
||||
ds.Bus == deviceBus);
|
||||
|
||||
if(old != null) AllStats.Devices.Remove(old);
|
||||
|
||||
DeviceStats nw = new DeviceStats
|
||||
ctx.SeenDevices.Add(new DeviceStat
|
||||
{
|
||||
Model = dev.Model,
|
||||
Manufacturer = dev.Manufacturer,
|
||||
Revision = dev.Revision,
|
||||
Bus = deviceBus,
|
||||
ManufacturerSpecified = true
|
||||
};
|
||||
AllStats.Devices.Add(nw);
|
||||
|
||||
old = CurrentStats.Devices.FirstOrDefault(ds => ds.Manufacturer == dev.Manufacturer &&
|
||||
ds.Model == dev.Model &&
|
||||
ds.Revision == dev.Revision &&
|
||||
ds.Bus == deviceBus);
|
||||
|
||||
if(old != null) CurrentStats.Devices.Remove(old);
|
||||
|
||||
nw = new DeviceStats
|
||||
{
|
||||
Model = dev.Model,
|
||||
Manufacturer = dev.Manufacturer,
|
||||
Model = dev.Model,
|
||||
Revision = dev.Revision,
|
||||
Bus = deviceBus,
|
||||
ManufacturerSpecified = true
|
||||
};
|
||||
CurrentStats.Devices.Add(nw);
|
||||
Synchronized = false
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace DiscImageChef.Database
|
||||
public DbSet<MediaFormat> MediaFormats { get; set; }
|
||||
public DbSet<Partition> Partitions { get; set; }
|
||||
public DbSet<Media> Medias { get; set; }
|
||||
public DbSet<DeviceStat> SeenDevices { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
|
||||
@@ -68,9 +68,12 @@
|
||||
<Compile Include="Migrations\20181221015906_NameValueStatistics.Designer.cs" />
|
||||
<Compile Include="Migrations\20181221032605_MediaStatistics.cs" />
|
||||
<Compile Include="Migrations\20181221032605_MediaStatistics.Designer.cs" />
|
||||
<Compile Include="Migrations\20181221034941_SeenDevicesStatistics.cs" />
|
||||
<Compile Include="Migrations\20181221034941_SeenDevicesStatistics.Designer.cs" />
|
||||
<Compile Include="Migrations\DicContextModelSnapshot.cs" />
|
||||
<Compile Include="Models\Command.cs" />
|
||||
<Compile Include="Models\Device.cs" />
|
||||
<Compile Include="Models\DeviceStat.cs" />
|
||||
<Compile Include="Models\Filesystem.cs" />
|
||||
<Compile Include="Models\Filter.cs" />
|
||||
<Compile Include="Models\Media.cs" />
|
||||
|
||||
1365
DiscImageChef.Database/Migrations/20181221034941_SeenDevicesStatistics.Designer.cs
generated
Normal file
1365
DiscImageChef.Database/Migrations/20181221034941_SeenDevicesStatistics.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace DiscImageChef.Database.Migrations
|
||||
{
|
||||
public partial class SeenDevicesStatistics : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("SeenDevices",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Manufacturer = table.Column<string>(nullable: true),
|
||||
Model = table.Column<string>(nullable: true),
|
||||
Revision = table.Column<string>(nullable: true),
|
||||
Bus = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table => { table.PrimaryKey("PK_SeenDevices", x => x.Id); });
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("SeenDevices");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -890,6 +890,25 @@ namespace DiscImageChef.Database.Migrations
|
||||
b.ToTable("Devices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiscImageChef.Database.Models.DeviceStat", b =>
|
||||
{
|
||||
b.Property<int>("Id").ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Bus");
|
||||
|
||||
b.Property<string>("Manufacturer");
|
||||
|
||||
b.Property<string>("Model");
|
||||
|
||||
b.Property<string>("Revision");
|
||||
|
||||
b.Property<bool>("Synchronized");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SeenDevices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiscImageChef.Database.Models.Filesystem", b =>
|
||||
{
|
||||
b.Property<int>("Id").ValueGeneratedOnAdd();
|
||||
|
||||
15
DiscImageChef.Database/Models/DeviceStat.cs
Normal file
15
DiscImageChef.Database/Models/DeviceStat.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace DiscImageChef.Database.Models
|
||||
{
|
||||
public class DeviceStat
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Manufacturer { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string Revision { get; set; }
|
||||
public string Bus { get; set; }
|
||||
public bool Synchronized { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user