diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a4d6d9c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vs/ \ No newline at end of file diff --git a/Extension/API.js b/Extension/API.js index cf48be8..1220ba4 100644 --- a/Extension/API.js +++ b/Extension/API.js @@ -29,7 +29,18 @@ async function setBaseDataHorseAPI(id, basedata) { } async function getHorseAPI(id) { let horseData; - const apiUrl = url+`getHorseInfo/id=${id}`; + const apiUrl = url+`getHorse/id=${id}`; + await fetch(apiUrl) + .then(response => response.json()) + .then(data => { + horseData = data; + }); + return horseData; +} +async function getHorseLoadStateAPIAsync(id) +{ + let horseData; + const apiUrl = url+`getHorseLoadState/id=${id}`; await fetch(apiUrl) .then(response => response.json()) .then(data => { diff --git a/Extension/horse.js b/Extension/horse.js index 58f5746..8da866c 100644 --- a/Extension/horse.js +++ b/Extension/horse.js @@ -1,3 +1,6 @@ +// Information about loading states of the horses + + // Modell für ein Pferd var globalHorse = { diff --git a/HRServer-Exporter/.vs/HRServer-Exporter/CopilotIndices/0.2.1653.9816/SemanticSymbols.db-shm b/HRServer-Exporter/.vs/HRServer-Exporter/CopilotIndices/0.2.1653.9816/SemanticSymbols.db-shm index a5897ea..ddecc3e 100644 Binary files a/HRServer-Exporter/.vs/HRServer-Exporter/CopilotIndices/0.2.1653.9816/SemanticSymbols.db-shm and b/HRServer-Exporter/.vs/HRServer-Exporter/CopilotIndices/0.2.1653.9816/SemanticSymbols.db-shm differ diff --git a/HRServer-Exporter/.vs/HRServer-Exporter/DesignTimeBuild/.dtbcache.v2 b/HRServer-Exporter/.vs/HRServer-Exporter/DesignTimeBuild/.dtbcache.v2 index cdb6ea5..2740ceb 100644 Binary files a/HRServer-Exporter/.vs/HRServer-Exporter/DesignTimeBuild/.dtbcache.v2 and b/HRServer-Exporter/.vs/HRServer-Exporter/DesignTimeBuild/.dtbcache.v2 differ diff --git a/HRServer-Exporter/.vs/HRServer-Exporter/FileContentIndex/410397f1-e154-4847-b568-19ff3386dd88.vsidx b/HRServer-Exporter/.vs/HRServer-Exporter/FileContentIndex/410397f1-e154-4847-b568-19ff3386dd88.vsidx deleted file mode 100644 index d2d521b..0000000 Binary files a/HRServer-Exporter/.vs/HRServer-Exporter/FileContentIndex/410397f1-e154-4847-b568-19ff3386dd88.vsidx and /dev/null differ diff --git a/HRServer-Exporter/.vs/HRServer-Exporter/FileContentIndex/81fd1417-9b73-4074-8733-8060f29e7cbb.vsidx b/HRServer-Exporter/.vs/HRServer-Exporter/FileContentIndex/81fd1417-9b73-4074-8733-8060f29e7cbb.vsidx deleted file mode 100644 index 04e031f..0000000 Binary files a/HRServer-Exporter/.vs/HRServer-Exporter/FileContentIndex/81fd1417-9b73-4074-8733-8060f29e7cbb.vsidx and /dev/null differ diff --git a/HRServer-Exporter/.vs/HRServer-Exporter/FileContentIndex/f6cf1ad8-ea4d-4886-93ed-cf6ed311e04d.vsidx b/HRServer-Exporter/.vs/HRServer-Exporter/FileContentIndex/f6cf1ad8-ea4d-4886-93ed-cf6ed311e04d.vsidx deleted file mode 100644 index af3423f..0000000 Binary files a/HRServer-Exporter/.vs/HRServer-Exporter/FileContentIndex/f6cf1ad8-ea4d-4886-93ed-cf6ed311e04d.vsidx and /dev/null differ diff --git a/HRServer-Exporter/.vs/HRServer-Exporter/v17/.suo b/HRServer-Exporter/.vs/HRServer-Exporter/v17/.suo index 3b05b37..3fe5331 100644 Binary files a/HRServer-Exporter/.vs/HRServer-Exporter/v17/.suo and b/HRServer-Exporter/.vs/HRServer-Exporter/v17/.suo differ diff --git a/HRServer-Exporter/HRServer/Controllers/HorseController.cs b/HRServer-Exporter/HRServer/Controllers/HorseController.cs index 8c0373a..d87bc7b 100644 --- a/HRServer-Exporter/HRServer/Controllers/HorseController.cs +++ b/HRServer-Exporter/HRServer/Controllers/HorseController.cs @@ -1,3 +1,4 @@ +using HRServer.Models; using Microsoft.AspNetCore.Mvc; namespace HRServer.Controllers @@ -12,11 +13,30 @@ namespace HRServer.Controllers { _logger = logger; } - - [HttpGet(Name = "GetWeatherForecast")] - public async Task> GetHorsesAsync() + [HttpGet("/api/getHorse/{id}")] + public IActionResult GetHorse ([FromRoute] int id) { - return new(); + var horse = HorseFactory.GetHorse((ulong)id); + if (horse == null) + return NotFound(new { Message = "Horse not found." }); + return Ok(horse); } + [HttpGet("/api/getHorseLoadState/{id}")] + public IActionResult GetHorseLoadState ([FromRoute] int id) + { + // Hole das Pferd aus der Factory + var horse = HorseFactory.GetHorse((ulong)id); + + // Überprüfe, ob das Pferd existiert + if (horse == null) + return NotFound(new { Message = "Horse not found." }); + + // Gib den Ladezustand des Pferdes zurück + return Ok(horse.LoadState); + } + /*[HttpGet("/api/setHorseBasicData/{id}")] + public IActionResult GetHorsesAsync([FromRoute] int id) + { + }*/ } } diff --git a/HRServer-Exporter/HRServer/Models/Horse.cs b/HRServer-Exporter/HRServer/Models/Horse.cs index 3c4418c..d38bce1 100644 --- a/HRServer-Exporter/HRServer/Models/Horse.cs +++ b/HRServer-Exporter/HRServer/Models/Horse.cs @@ -1,7 +1,228 @@ namespace HRServer.Models { + public enum Gender + { + Male, + Female + } + public static class HorseFactory + { + // Thread-safe Dictionary, um gleichzeitigen Zugriff zu ermöglichen + private static readonly Dictionary Horses = new(); + + // Methode, um ein Pferd nach ID zu suchen + public static Horse? GetHorse(ulong id) + { + // Verwende Dictionary.TryGetValue für bessere Performance und Lesbarkeit + return Horses.TryGetValue(id, out var horse) ? horse : null; + } + + // Methode, um ein Pferd hinzuzufügen oder zu aktualisieren + public static void AddOrUpdateHorse(Horse horse) + { + if (horse == null || horse.Id == null) + throw new ArgumentNullException(nameof(horse), "Horse or its ID cannot be null."); + + Horses[horse.Id.Value] = horse; + } + + // Methode, um alle Pferde zu holen (z. B. für Debugging oder Verarbeitung) + public static IReadOnlyDictionary GetAllHorses() + { + return Horses; + } + } + public class Horse { + // Basic Information + private ulong? _id; + private int? _age; + private string _horseName = string.Empty; + private string _gender = string.Empty; + private string _breed = string.Empty; + private string _link = string.Empty; + public ulong? Id + { + get => _id; + set + { + _id = value; + LoadState.BasicInfoLoaded = true; + } + } + + public int? Age + { + get => _age; + set + { + _age = value; + LoadState.BasicInfoLoaded = true; + } + } + + public string HorseName + { + get => _horseName; + set + { + _horseName = value; + LoadState.BasicInfoLoaded = true; + } + } + + public string Gender + { + get => _gender; + set + { + _gender = value; + LoadState.BasicInfoLoaded = true; + } + } + + public string Breed + { + get => _breed; + set + { + _breed = value; + LoadState.BasicInfoLoaded = true; + } + } + + public string Link + { + get => _link; + set + { + _link = value; + LoadState.BasicInfoLoaded = true; + } + } + + // Other Sections + private HorseSummary _summary = new(); + public HorseSummary Summary + { + get => _summary; + set + { + _summary = value; + LoadState.SummaryLoaded = true; + } + } + + private HorseTraining _training = new(); + public HorseTraining Training + { + get => _training; + set + { + _training = value; + LoadState.TrainingLoaded = true; + } + } + + private HorseGenetics _genetics = new(); + public HorseGenetics Genetics + { + get => _genetics; + set + { + _genetics = value; + LoadState.GeneticsLoaded = true; + } + } + + private HorseAchievements _achievements = new(); + public HorseAchievements Achievements + { + get => _achievements; + set + { + _achievements = value; + LoadState.AchievementsLoaded = true; + } + } + + private HorseHealth _health = new(); + public HorseHealth Health + { + get => _health; + set + { + _health = value; + LoadState.HealthLoaded = true; + } + } + + // Load State + public DataLoadState LoadState { get; set; } = new(); + + // Helper Methods + public bool IsAllDataLoaded() + { + return LoadState.IsAllDataLoaded(); + } + + public void PrintLoadState() + { + Console.WriteLine("Load State of Horse Data:"); + Console.WriteLine($"- Basic Info Loaded: {LoadState.BasicInfoLoaded}"); + Console.WriteLine($"- Summary Loaded: {LoadState.SummaryLoaded}"); + Console.WriteLine($"- Training Loaded: {LoadState.TrainingLoaded}"); + Console.WriteLine($"- Genetics Loaded: {LoadState.GeneticsLoaded}"); + Console.WriteLine($"- Achievements Loaded: {LoadState.AchievementsLoaded}"); + Console.WriteLine($"- Health Loaded: {LoadState.HealthLoaded}"); + } } -} + + // Class to track the loading state of data + public class DataLoadState + { + public bool BasicInfoLoaded { get; set; } = false; + public bool SummaryLoaded { get; set; } = false; + public bool TrainingLoaded { get; set; } = false; + public bool GeneticsLoaded { get; set; } = false; + public bool AchievementsLoaded { get; set; } = false; + public bool HealthLoaded { get; set; } = false; + + // Method to check if all data is loaded + public bool IsAllDataLoaded() + { + return BasicInfoLoaded && SummaryLoaded && TrainingLoaded && GeneticsLoaded && AchievementsLoaded && HealthLoaded; + } + } + + // Other classes + public class HorseSummary + { + public List RelatedIds { get; set; } = new(); + } + + public class HorseTraining + { + public string Training { get; set; } = string.Empty; + } + + public class HorseGenetics + { + public int GP { get; set; } + public Dictionary Features { get; set; } = new(); + public string Extension { get; set; } = string.Empty; + } + + public class HorseAchievements + { + public Dictionary Conformation { get; set; } = new(); + public string ShortConformation { get; set; } = string.Empty; + } + + public class HorseHealth + { + public string Fertility { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.AssemblyInfo.cs b/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.AssemblyInfo.cs index 4640049..b5594b1 100644 --- a/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.AssemblyInfo.cs +++ b/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("HRServer")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+61e6e23dae50c1f4f9adf20b24676e1fe61fe435")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6e5ae3f9b3254f84dca052d06f64382fc35cc6d4")] [assembly: System.Reflection.AssemblyProductAttribute("HRServer")] [assembly: System.Reflection.AssemblyTitleAttribute("HRServer")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.AssemblyInfoInputs.cache b/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.AssemblyInfoInputs.cache index 85325ed..53d083b 100644 --- a/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.AssemblyInfoInputs.cache +++ b/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.AssemblyInfoInputs.cache @@ -1 +1 @@ -419ce3097d8083c4540b0d88268e23c0a89ac5f37fd5d769a90222609f0f847f +c249390f111095a716c75dcba28e2f2d1acdc90eb5e2495d35cb08b47c8606be diff --git a/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.GeneratedMSBuildEditorConfig.editorconfig b/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.GeneratedMSBuildEditorConfig.editorconfig index e3f8a1c..e10caf2 100644 --- a/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.GeneratedMSBuildEditorConfig.editorconfig +++ b/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.GeneratedMSBuildEditorConfig.editorconfig @@ -9,11 +9,11 @@ build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = HRServer build_property.RootNamespace = HRServer -build_property.ProjectDir = C:\Users\SvenK\source\repos\HRServer-Exporter\HRServer\ +build_property.ProjectDir = Z:\[01] Kribitz Development\[02] Projekte\HR-Collector\HRServer-Exporter\HRServer\ build_property.EnableComHosting = build_property.EnableGeneratedComInterfaceComImportInterop = build_property.RazorLangVersion = 8.0 build_property.SupportLocalizedComponentNames = build_property.GenerateRazorMetadataSourceChecksumAttributes = -build_property.MSBuildProjectDirectory = C:\Users\SvenK\source\repos\HRServer-Exporter\HRServer +build_property.MSBuildProjectDirectory = Z:\[01] Kribitz Development\[02] Projekte\HR-Collector\HRServer-Exporter\HRServer build_property._RazorSourceGeneratorDebug = diff --git a/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.assets.cache b/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.assets.cache index bb8da7d..9ce3a91 100644 Binary files a/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.assets.cache and b/HRServer-Exporter/HRServer/obj/Debug/net8.0/HRServer.assets.cache differ diff --git a/HRServer-Exporter/HRServer/obj/HRServer.csproj.nuget.dgspec.json b/HRServer-Exporter/HRServer/obj/HRServer.csproj.nuget.dgspec.json index 10b9547..89babf7 100644 --- a/HRServer-Exporter/HRServer/obj/HRServer.csproj.nuget.dgspec.json +++ b/HRServer-Exporter/HRServer/obj/HRServer.csproj.nuget.dgspec.json @@ -1,17 +1,17 @@ { "format": 1, "restore": { - "C:\\Users\\SvenK\\source\\repos\\HRServer-Exporter\\HRServer\\HRServer.csproj": {} + "Z:\\[01] Kribitz Development\\[02] Projekte\\HR-Collector\\HRServer-Exporter\\HRServer\\HRServer.csproj": {} }, "projects": { - "C:\\Users\\SvenK\\source\\repos\\HRServer-Exporter\\HRServer\\HRServer.csproj": { + "Z:\\[01] Kribitz Development\\[02] Projekte\\HR-Collector\\HRServer-Exporter\\HRServer\\HRServer.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "C:\\Users\\SvenK\\source\\repos\\HRServer-Exporter\\HRServer\\HRServer.csproj", + "projectUniqueName": "Z:\\[01] Kribitz Development\\[02] Projekte\\HR-Collector\\HRServer-Exporter\\HRServer\\HRServer.csproj", "projectName": "HRServer", - "projectPath": "C:\\Users\\SvenK\\source\\repos\\HRServer-Exporter\\HRServer\\HRServer.csproj", + "projectPath": "Z:\\[01] Kribitz Development\\[02] Projekte\\HR-Collector\\HRServer-Exporter\\HRServer\\HRServer.csproj", "packagesPath": "C:\\Users\\SvenK\\.nuget\\packages\\", - "outputPath": "C:\\Users\\SvenK\\source\\repos\\HRServer-Exporter\\HRServer\\obj\\", + "outputPath": "Z:\\[01] Kribitz Development\\[02] Projekte\\HR-Collector\\HRServer-Exporter\\HRServer\\obj\\", "projectStyle": "PackageReference", "fallbackFolders": [ "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages" diff --git a/HRServer-Exporter/HRServer/obj/project.assets.json b/HRServer-Exporter/HRServer/obj/project.assets.json index d72e041..d2b1117 100644 --- a/HRServer-Exporter/HRServer/obj/project.assets.json +++ b/HRServer-Exporter/HRServer/obj/project.assets.json @@ -434,11 +434,11 @@ "project": { "version": "1.0.0", "restore": { - "projectUniqueName": "C:\\Users\\SvenK\\source\\repos\\HRServer-Exporter\\HRServer\\HRServer.csproj", + "projectUniqueName": "Z:\\[01] Kribitz Development\\[02] Projekte\\HR-Collector\\HRServer-Exporter\\HRServer\\HRServer.csproj", "projectName": "HRServer", - "projectPath": "C:\\Users\\SvenK\\source\\repos\\HRServer-Exporter\\HRServer\\HRServer.csproj", + "projectPath": "Z:\\[01] Kribitz Development\\[02] Projekte\\HR-Collector\\HRServer-Exporter\\HRServer\\HRServer.csproj", "packagesPath": "C:\\Users\\SvenK\\.nuget\\packages\\", - "outputPath": "C:\\Users\\SvenK\\source\\repos\\HRServer-Exporter\\HRServer\\obj\\", + "outputPath": "Z:\\[01] Kribitz Development\\[02] Projekte\\HR-Collector\\HRServer-Exporter\\HRServer\\obj\\", "projectStyle": "PackageReference", "fallbackFolders": [ "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages" diff --git a/HRServer-Exporter/HRServer/obj/project.nuget.cache b/HRServer-Exporter/HRServer/obj/project.nuget.cache index 24e0ecd..28deacd 100644 --- a/HRServer-Exporter/HRServer/obj/project.nuget.cache +++ b/HRServer-Exporter/HRServer/obj/project.nuget.cache @@ -1,8 +1,8 @@ { "version": 2, - "dgSpecHash": "IWssXfMVU1U=", + "dgSpecHash": "VjLTbzNjiB0=", "success": true, - "projectFilePath": "C:\\Users\\SvenK\\source\\repos\\HRServer-Exporter\\HRServer\\HRServer.csproj", + "projectFilePath": "Z:\\[01] Kribitz Development\\[02] Projekte\\HR-Collector\\HRServer-Exporter\\HRServer\\HRServer.csproj", "expectedPackageFiles": [ "C:\\Users\\SvenK\\.nuget\\packages\\microsoft.extensions.apidescription.server\\6.0.5\\microsoft.extensions.apidescription.server.6.0.5.nupkg.sha512", "C:\\Users\\SvenK\\.nuget\\packages\\microsoft.openapi\\1.2.3\\microsoft.openapi.1.2.3.nupkg.sha512",