mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
[Workers] Adjust DAT import to new SabreTools API.
This commit is contained in:
@@ -39,6 +39,7 @@ using RomRepoMgr.Core.Resources;
|
|||||||
using RomRepoMgr.Database;
|
using RomRepoMgr.Database;
|
||||||
using RomRepoMgr.Database.Models;
|
using RomRepoMgr.Database.Models;
|
||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
|
using SabreTools.DatTools;
|
||||||
using SabreTools.Models.Metadata;
|
using SabreTools.Models.Metadata;
|
||||||
using DatItem = SabreTools.DatItems.DatItem;
|
using DatItem = SabreTools.DatItems.DatItem;
|
||||||
using Disk = SabreTools.DatItems.Formats.Disk;
|
using Disk = SabreTools.DatItems.Formats.Disk;
|
||||||
@@ -79,8 +80,8 @@ public sealed class DatImporter
|
|||||||
Message = Localization.ParsinDatFile
|
Message = Localization.ParsinDatFile
|
||||||
});
|
});
|
||||||
|
|
||||||
var datFile = DatFile.Create();
|
DatFile datFile = Parser.ParseStatistics(_datPath);
|
||||||
datFile.ParseFile(_datPath, 0, false, true);
|
Parser.ParseInto(datFile, _datPath, throwOnError: true);
|
||||||
|
|
||||||
SetMessage?.Invoke(this,
|
SetMessage?.Invoke(this,
|
||||||
new MessageEventArgs
|
new MessageEventArgs
|
||||||
@@ -151,14 +152,7 @@ public sealed class DatImporter
|
|||||||
Message = Localization.GettingMachineNames
|
Message = Localization.GettingMachineNames
|
||||||
});
|
});
|
||||||
|
|
||||||
var machineNames = (from value in datFile.Items.Values
|
var machineNames = datFile.Items.SortedKeys.Distinct().ToList();
|
||||||
from item in value
|
|
||||||
select item.GetFieldValue<SabreTools.DatItems.Machine>(DatItem.MachineKey)
|
|
||||||
?.GetStringFieldValue(SabreTools.Models.Metadata.Machine.NameKey)
|
|
||||||
into m
|
|
||||||
where m is not null
|
|
||||||
select m).Distinct()
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
SetMessage?.Invoke(this,
|
SetMessage?.Invoke(this,
|
||||||
new MessageEventArgs
|
new MessageEventArgs
|
||||||
@@ -251,7 +245,7 @@ public sealed class DatImporter
|
|||||||
new ProgressBoundsEventArgs
|
new ProgressBoundsEventArgs
|
||||||
{
|
{
|
||||||
Minimum = 0,
|
Minimum = 0,
|
||||||
Maximum = datFile.Items.Values.Count
|
Maximum = datFile.Items.SortedKeys.Length
|
||||||
});
|
});
|
||||||
|
|
||||||
using(DbTransaction dbTransaction = dbConnection.BeginTransaction())
|
using(DbTransaction dbTransaction = dbConnection.BeginTransaction())
|
||||||
@@ -308,7 +302,7 @@ public sealed class DatImporter
|
|||||||
dbcc.CommandText = $"CREATE TABLE \"{tmpMediaSha256Table}\" (\"Sha256\" TEXT NOT NULL);";
|
dbcc.CommandText = $"CREATE TABLE \"{tmpMediaSha256Table}\" (\"Sha256\" TEXT NOT NULL);";
|
||||||
dbcc.ExecuteNonQuery();
|
dbcc.ExecuteNonQuery();
|
||||||
|
|
||||||
foreach(List<DatItem> values in datFile.Items.Values)
|
foreach(string key in datFile.Items.SortedKeys)
|
||||||
{
|
{
|
||||||
SetProgress?.Invoke(this,
|
SetProgress?.Invoke(this,
|
||||||
new ProgressEventArgs
|
new ProgressEventArgs
|
||||||
@@ -316,7 +310,7 @@ public sealed class DatImporter
|
|||||||
Value = position
|
Value = position
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach(DatItem item in values)
|
foreach(DatItem item in datFile.GetItemsForBucket(key))
|
||||||
{
|
{
|
||||||
switch(item)
|
switch(item)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user