2024-04-16 18:29:40 +00:00
|
|
|
using LootDumpProcessor.Logger;
|
2023-08-12 19:08:38 +01:00
|
|
|
using LootDumpProcessor.Model;
|
|
|
|
using LootDumpProcessor.Model.Processing;
|
|
|
|
using LootDumpProcessor.Storage;
|
|
|
|
|
2024-04-16 18:29:40 +00:00
|
|
|
namespace LootDumpProcessor.Process.Processor.FileProcessor;
|
2023-08-12 19:08:38 +01:00
|
|
|
|
|
|
|
public class FileProcessor : IFileProcessor
|
|
|
|
{
|
|
|
|
public PartialData Process(BasicInfo parsedData)
|
|
|
|
{
|
2024-04-16 18:29:40 +00:00
|
|
|
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Debug))
|
|
|
|
LoggerFactory.GetInstance().Log($"Processing file {parsedData.FileName}...", LogLevel.Debug);
|
2023-08-12 19:08:38 +01:00
|
|
|
List<Template> looseLoot = new List<Template>();
|
|
|
|
List<Template> staticLoot = new List<Template>();
|
|
|
|
|
|
|
|
foreach (var item in parsedData.Data.Data.Loot)
|
|
|
|
{
|
|
|
|
if (item.IsContainer ?? false)
|
|
|
|
staticLoot.Add(item);
|
|
|
|
else
|
|
|
|
looseLoot.Add(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
parsedData.Data = null;
|
|
|
|
|
|
|
|
var dumpData = new ParsedDump
|
|
|
|
{
|
|
|
|
BasicInfo = parsedData
|
|
|
|
};
|
|
|
|
|
2024-04-16 18:29:40 +00:00
|
|
|
var data = new PartialData
|
2023-08-12 19:08:38 +01:00
|
|
|
{
|
|
|
|
BasicInfo = parsedData,
|
|
|
|
ParsedDumpKey = (AbstractKey)dumpData.GetKey()
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!DataStorageFactory.GetInstance().Exists(dumpData.GetKey()))
|
|
|
|
{
|
2024-04-16 18:29:40 +00:00
|
|
|
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Debug))
|
|
|
|
LoggerFactory.GetInstance().Log(
|
|
|
|
$"Cached not found for {string.Join("/", dumpData.GetKey().GetLookupIndex())} processing.",
|
|
|
|
LogLevel.Debug
|
|
|
|
);
|
2023-08-12 19:08:38 +01:00
|
|
|
dumpData.Containers = StaticLootProcessor.PreProcessStaticLoot(staticLoot);
|
|
|
|
dumpData.LooseLoot = LooseLootProcessor.PreProcessLooseLoot(looseLoot);
|
|
|
|
DataStorageFactory.GetInstance().Store(dumpData);
|
|
|
|
}
|
2024-04-16 18:29:40 +00:00
|
|
|
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Debug))
|
|
|
|
LoggerFactory.GetInstance().Log($"File {parsedData.FileName} finished processing!", LogLevel.Debug);
|
2023-08-12 19:08:38 +01:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|