added database to store metadata

This commit is contained in:
2025-04-10 19:56:35 +05:00
parent c4af1f31e8
commit d7dcd7afc9
15 changed files with 278 additions and 153 deletions
@@ -0,0 +1,45 @@
using System.Text.Json.Serialization;
namespace ParadoxSaveParser.WebAPI.Database;
public enum SaveFileProcessingStatus
{
Initialized,
Uploaded,
Parsing,
SavingResults,
Done,
Error,
}
public class SaveFileMetadata
{
[SQLite.PrimaryKey]
[SQLite.NotNull]
public string id { get; init; } = null!;
[JsonConverter(typeof(JsonStringEnumConverter))]
[SQLite.NotNull]
public Game game { get; init; }
[JsonConverter(typeof(JsonStringEnumConverter))]
[SQLite.NotNull]
public SaveFileProcessingStatus status { get; set; }
[SQLite.NotNull]
public DateTime uploadDateTime { get; set; }
// if error occured during parsing, it's message is saved here
// status stays the same as when error occured
public string? errorMessage { get; set; }
public IOPath GetSaveFilePath() => Path.Concat(PathHelper.SAVES_DIR, id + ".eu4");
public IOPath GetParsedDataPath() => Path.Concat(PathHelper.PARSED_DIR, id + ".parsed.json");
public bool AssociatedFilesExist()
{
return File.Exists(GetSaveFilePath()) && File.Exists(GetParsedDataPath());
}
}