mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Add statistics to list of rom sets.
This commit is contained in:
@@ -27,14 +27,20 @@ namespace RomRepoMgr.Core.Models
|
||||
{
|
||||
public class RomSetModel
|
||||
{
|
||||
public string Author { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Homepage { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Version { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public string Sha384 { get; set; }
|
||||
public string Author { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Homepage { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Version { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public string Sha384 { get; set; }
|
||||
public long TotalMachines { get; set; }
|
||||
public long CompleteMachines { get; set; }
|
||||
public long IncompleteMachines { get; set; }
|
||||
public long TotalRoms { get; set; }
|
||||
public long HaveRoms { get; set; }
|
||||
public long MissRoms { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -114,22 +114,6 @@ namespace RomRepoMgr.Core.Workers
|
||||
Context.Singleton.RomSets.Add(romSet);
|
||||
Context.Singleton.SaveChanges();
|
||||
|
||||
RomSetAdded?.Invoke(this, new RomSetEventArgs
|
||||
{
|
||||
RomSet = new RomSetModel
|
||||
{
|
||||
Author = romSet.Author,
|
||||
Comment = romSet.Comment,
|
||||
Date = romSet.Date,
|
||||
Description = romSet.Description,
|
||||
Filename = romSet.Filename,
|
||||
Homepage = romSet.Homepage,
|
||||
Name = romSet.Name,
|
||||
Sha384 = romSet.Sha384,
|
||||
Version = romSet.Version
|
||||
}
|
||||
});
|
||||
|
||||
SetMessage?.Invoke(this, new MessageEventArgs
|
||||
{
|
||||
Message = "Compressing DAT file..."
|
||||
@@ -473,6 +457,30 @@ namespace RomRepoMgr.Core.Workers
|
||||
});
|
||||
|
||||
WorkFinished?.Invoke(this, System.EventArgs.Empty);
|
||||
|
||||
romSet = Context.Singleton.RomSets.Find(romSet.Id);
|
||||
|
||||
RomSetAdded?.Invoke(this, new RomSetEventArgs
|
||||
{
|
||||
RomSet = new RomSetModel
|
||||
{
|
||||
Author = romSet.Author,
|
||||
Comment = romSet.Comment,
|
||||
Date = romSet.Date,
|
||||
Description = romSet.Description,
|
||||
Filename = romSet.Filename,
|
||||
Homepage = romSet.Homepage,
|
||||
Name = romSet.Name,
|
||||
Sha384 = romSet.Sha384,
|
||||
Version = romSet.Version,
|
||||
TotalMachines = romSet.Machines.Count,
|
||||
CompleteMachines = romSet.Machines.Count(m => m.Files.All(f => f.File.IsInRepo)),
|
||||
IncompleteMachines = romSet.Machines.Count(m => m.Files.Any(f => !f.File.IsInRepo)),
|
||||
TotalRoms = romSet.Machines.Sum(m => m.Files.Count),
|
||||
HaveRoms = romSet.Machines.Sum(m => m.Files.Count(f => f.File.IsInRepo)),
|
||||
MissRoms = romSet.Machines.Sum(m => m.Files.Count(f => !f.File.IsInRepo))
|
||||
}
|
||||
});
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RomRepoMgr.Database.Models;
|
||||
|
||||
namespace RomRepoMgr.Database
|
||||
@@ -62,7 +63,12 @@ namespace RomRepoMgr.Database
|
||||
public static Context Create(string dbPath)
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder();
|
||||
optionsBuilder.UseLazyLoadingProxies().UseSqlite($"Data Source={dbPath}");
|
||||
|
||||
optionsBuilder.UseLazyLoadingProxies()
|
||||
#if DEBUG
|
||||
.UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()))
|
||||
#endif
|
||||
.UseSqlite($"Data Source={dbPath}");
|
||||
|
||||
return new Context(optionsBuilder.Options);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.7" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.7" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -53,15 +53,20 @@ namespace RomRepoMgr.ViewModels
|
||||
RomSets = new ObservableCollection<RomSetModel>(romSets);
|
||||
}
|
||||
|
||||
public ObservableCollection<RomSetModel> RomSets { get; }
|
||||
public string RomSetLabel => "ROM sets";
|
||||
public string RomSetNameLabel => "Name";
|
||||
public string RomSetVersionLabel => "Version";
|
||||
public string RomSetAuthorLabel => "Author";
|
||||
public string RomSetDateLabel => "Date";
|
||||
public string RomSetDescriptionLabel => "Description";
|
||||
public string RomSetCommentLabel => "Comment";
|
||||
public string RomSetHomepageLabel => "Homepage";
|
||||
public ObservableCollection<RomSetModel> RomSets { get; }
|
||||
public string RomSetLabel => "ROM sets";
|
||||
public string RomSetNameLabel => "Name";
|
||||
public string RomSetVersionLabel => "Version";
|
||||
public string RomSetAuthorLabel => "Author";
|
||||
public string RomSetDateLabel => "Date";
|
||||
public string RomSetDescriptionLabel => "Description";
|
||||
public string RomSetCommentLabel => "Comment";
|
||||
public string RomSetTotalMachinesLabel => "Games";
|
||||
public string RomSetCompleteMachinesLabel => "Complete";
|
||||
public string RomSetIncompleteMachinesLabel => "Incomplete";
|
||||
public string RomSetTotalRomsLabel => "ROMs";
|
||||
public string RomSetHaveRomsLabel => "Have";
|
||||
public string RomSetMissRomsLabel => "Miss";
|
||||
|
||||
public string Greeting => "Hello World!";
|
||||
public bool NativeMenuSupported =>
|
||||
|
||||
@@ -370,15 +370,23 @@ namespace RomRepoMgr.ViewModels
|
||||
ThenBy(r => r.Date).ThenBy(r => r.Description).ThenBy(r => r.Comment).
|
||||
ThenBy(r => r.Filename).Select(r => new RomSetModel
|
||||
{
|
||||
Author = r.Author,
|
||||
Comment = r.Comment,
|
||||
Date = r.Date,
|
||||
Description = r.Description,
|
||||
Filename = r.Filename,
|
||||
Homepage = r.Homepage,
|
||||
Name = r.Name,
|
||||
Sha384 = r.Sha384,
|
||||
Version = r.Version
|
||||
Author = r.Author,
|
||||
Comment = r.Comment,
|
||||
Date = r.Date,
|
||||
Description = r.Description,
|
||||
Filename = r.Filename,
|
||||
Homepage = r.Homepage,
|
||||
Name = r.Name,
|
||||
Sha384 = r.Sha384,
|
||||
Version = r.Version,
|
||||
TotalMachines = r.Machines.Count,
|
||||
CompleteMachines =
|
||||
r.Machines.Count(m => m.Files.All(f => f.File.IsInRepo)),
|
||||
IncompleteMachines =
|
||||
r.Machines.Count(m => m.Files.Any(f => !f.File.IsInRepo)),
|
||||
TotalRoms = r.Machines.Sum(m => m.Files.Count),
|
||||
HaveRoms = r.Machines.Sum(m => m.Files.Count(f => f.File.IsInRepo)),
|
||||
MissRoms = r.Machines.Sum(m => m.Files.Count(f => !f.File.IsInRepo))
|
||||
}).ToList()
|
||||
});
|
||||
|
||||
|
||||
@@ -66,6 +66,36 @@
|
||||
<TextBlock Text="{Binding RomSetHomepageLabel}" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Binding="{Binding TotalMachines}" Width="Auto" IsReadOnly="True">
|
||||
<DataGridTextColumn.Header>
|
||||
<TextBlock Text="{Binding RomSetTotalMachinesLabel}" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Binding="{Binding CompleteMachines}" Width="Auto" IsReadOnly="True">
|
||||
<DataGridTextColumn.Header>
|
||||
<TextBlock Text="{Binding RomSetCompleteMachinesLabel}" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Binding="{Binding IncompleteMachines}" Width="Auto" IsReadOnly="True">
|
||||
<DataGridTextColumn.Header>
|
||||
<TextBlock Text="{Binding RomSetIncompleteMachinesLabel}" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Binding="{Binding TotalRoms}" Width="Auto" IsReadOnly="True">
|
||||
<DataGridTextColumn.Header>
|
||||
<TextBlock Text="{Binding RomSetTotalRomsLabel}" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Binding="{Binding HaveRoms}" Width="Auto" IsReadOnly="True">
|
||||
<DataGridTextColumn.Header>
|
||||
<TextBlock Text="{Binding RomSetHaveRomsLabel}" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Binding="{Binding MissRoms}" Width="Auto" IsReadOnly="True">
|
||||
<DataGridTextColumn.Header>
|
||||
<TextBlock Text="{Binding RomSetMissRomsLabel}" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
|
||||
Reference in New Issue
Block a user