Move operating system statistics to database.

This commit is contained in:
2018-12-21 04:08:58 +00:00
parent f376286e8a
commit 4f445e53c3
8 changed files with 1464 additions and 29 deletions

View File

@@ -309,6 +309,8 @@
<e p="20181221032605_MediaStatistics.cs" t="Include" />
<e p="20181221034941_SeenDevicesStatistics.Designer.cs" t="Include" />
<e p="20181221034941_SeenDevicesStatistics.cs" t="Include" />
<e p="20181221040408_OperatingSystemStatistics.Designer.cs" t="Include" />
<e p="20181221040408_OperatingSystemStatistics.cs" t="Include" />
<e p="DicContextModelSnapshot.cs" t="Include" />
</e>
<e p="Models" t="Include">
@@ -319,6 +321,7 @@
<e p="Filter.cs" t="Include" />
<e p="Media.cs" t="Include" />
<e p="MediaFormat.cs" t="Include" />
<e p="OperatingSystem.cs" t="Include" />
<e p="Partition.cs" t="Include" />
<e p="Report.cs" t="Include" />
</e>

View File

@@ -43,6 +43,7 @@ using DiscImageChef.Database;
using DiscImageChef.Database.Models;
using Device = DiscImageChef.Devices.Device;
using MediaType = DiscImageChef.CommonTypes.MediaType;
using OperatingSystem = DiscImageChef.Database.Models.OperatingSystem;
using Version = DiscImageChef.CommonTypes.Interop.Version;
namespace DiscImageChef.Core
@@ -75,18 +76,14 @@ namespace DiscImageChef.Core
if(File.Exists(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml")))
{
AllStats = new Stats();
ctx.OperatingSystems.Add(new OperatingSystem
{
Name = DetectOS.GetRealPlatformID().ToString(),
Synchronized = false,
Version = DetectOS.GetVersion()
});
CurrentStats = new Stats
{
OperatingSystems =
new List<OsStats>
{
new OsStats
{
name = DetectOS.GetRealPlatformID().ToString(),
Value = 1,
version = DetectOS.GetVersion()
}
},
Versions = new List<NameValueStats>
{
new NameValueStats {name = Version.GetVersion(), Value = 1}
@@ -100,18 +97,14 @@ namespace DiscImageChef.Core
else if(Settings.Settings.Current.Stats != null)
{
AllStats = new Stats();
ctx.OperatingSystems.Add(new OperatingSystem
{
Name = DetectOS.GetRealPlatformID().ToString(),
Synchronized = false,
Version = DetectOS.GetVersion()
});
CurrentStats = new Stats
{
OperatingSystems =
new List<OsStats>
{
new OsStats
{
name = DetectOS.GetRealPlatformID().ToString(),
Value = 1,
version = DetectOS.GetVersion()
}
},
Versions = new List<NameValueStats>
{
new NameValueStats {name = Version.GetVersion(), Value = 1}

View File

@@ -43,15 +43,16 @@ namespace DiscImageChef.Database
Database.Migrate();
}
public DbSet<Device> Devices { get; set; }
public DbSet<Report> Reports { get; set; }
public DbSet<Command> Commands { get; set; }
public DbSet<Filesystem> Filesystems { get; set; }
public DbSet<Filter> Filters { get; set; }
public DbSet<MediaFormat> MediaFormats { get; set; }
public DbSet<Partition> Partitions { get; set; }
public DbSet<Media> Medias { get; set; }
public DbSet<DeviceStat> SeenDevices { get; set; }
public DbSet<Device> Devices { get; set; }
public DbSet<Report> Reports { get; set; }
public DbSet<Command> Commands { get; set; }
public DbSet<Filesystem> Filesystems { get; set; }
public DbSet<Filter> Filters { get; set; }
public DbSet<MediaFormat> MediaFormats { get; set; }
public DbSet<Partition> Partitions { get; set; }
public DbSet<Media> Medias { get; set; }
public DbSet<DeviceStat> SeenDevices { get; set; }
public DbSet<OperatingSystem> OperatingSystems { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{

View File

@@ -70,6 +70,8 @@
<Compile Include="Migrations\20181221032605_MediaStatistics.Designer.cs" />
<Compile Include="Migrations\20181221034941_SeenDevicesStatistics.cs" />
<Compile Include="Migrations\20181221034941_SeenDevicesStatistics.Designer.cs" />
<Compile Include="Migrations\20181221040408_OperatingSystemStatistics.cs" />
<Compile Include="Migrations\20181221040408_OperatingSystemStatistics.Designer.cs" />
<Compile Include="Migrations\DicContextModelSnapshot.cs" />
<Compile Include="Models\Command.cs" />
<Compile Include="Models\Device.cs" />
@@ -78,6 +80,7 @@
<Compile Include="Models\Filter.cs" />
<Compile Include="Models\Media.cs" />
<Compile Include="Models\MediaFormat.cs" />
<Compile Include="Models\OperatingSystem.cs" />
<Compile Include="Models\Partition.cs" />
<Compile Include="Models\Report.cs" />
</ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DiscImageChef.Database.Migrations
{
public partial class OperatingSystemStatistics : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("OperatingSystems",
table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(nullable: true),
Version = table.Column<string>(nullable: true),
Synchronized = table.Column<bool>(nullable: false)
},
constraints: table => { table.PrimaryKey("PK_OperatingSystems", x => x.Id); });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("OperatingSystems");
}
}
}

View File

@@ -963,6 +963,21 @@ namespace DiscImageChef.Database.Migrations
b.ToTable("MediaFormats");
});
modelBuilder.Entity("DiscImageChef.Database.Models.OperatingSystem", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<bool>("Synchronized");
b.Property<string>("Version");
b.HasKey("Id");
b.ToTable("OperatingSystems");
});
modelBuilder.Entity("DiscImageChef.Database.Models.Partition", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();

View File

@@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Database.Models
{
public class OperatingSystem
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Version { get; set; }
public bool Synchronized { get; set; }
}
}