From 3b11c6adc5beb79ef6d7b0fec5751b8785eac704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szab=C3=B3=20Iv=C3=A1n?= Date: Tue, 21 Jan 2025 12:50:36 +0100 Subject: [PATCH] =?UTF-8?q?Mobilr=C3=B3l=20m=C5=B1k=C3=B6dik=20a=20h=C3=AD?= =?UTF-8?q?v=C3=A1s=20https-en=20:)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/ApiResponseDTO.cs | 2 +- .../DTO/UserDTO.cs | 2 +- .../WorkFlowCheck.Common.csproj | 9 +++++ src/WorkFlowCheck.DL/WorkFlowCheck.DL.csproj | 1 - src/WorkFlowCheck.MAUI/MainPage.xaml.cs | 4 +-- src/WorkFlowCheck.MAUI/MauiProgram.cs | 23 +++++++++--- .../Resources/Raw/appsettings.json | 2 +- .../Services/IUserService.cs | 2 +- .../Services/UserService.cs | 10 +++--- .../WorkFlowCheck.MAUI.csproj | 2 +- src/WorkFlowCheck.MOBILE.sln | 36 +++++++++++++++++++ src/WorkFlowCheck.sln | 6 ++++ 12 files changed, 83 insertions(+), 16 deletions(-) rename src/{WorkFlowCheck.BL => WorkFlowCheck.Common}/DTO/ApiResponseDTO.cs (96%) rename src/{WorkFlowCheck.BL => WorkFlowCheck.Common}/DTO/UserDTO.cs (86%) create mode 100644 src/WorkFlowCheck.Common/WorkFlowCheck.Common.csproj create mode 100644 src/WorkFlowCheck.MOBILE.sln diff --git a/src/WorkFlowCheck.BL/DTO/ApiResponseDTO.cs b/src/WorkFlowCheck.Common/DTO/ApiResponseDTO.cs similarity index 96% rename from src/WorkFlowCheck.BL/DTO/ApiResponseDTO.cs rename to src/WorkFlowCheck.Common/DTO/ApiResponseDTO.cs index 3545a79..c5c5e1d 100644 --- a/src/WorkFlowCheck.BL/DTO/ApiResponseDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/ApiResponseDTO.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace WorkFlowCheck.BL.DTO +namespace WorkFlowCheck.Common.DTO { public class ApiResponseBaseDTO { diff --git a/src/WorkFlowCheck.BL/DTO/UserDTO.cs b/src/WorkFlowCheck.Common/DTO/UserDTO.cs similarity index 86% rename from src/WorkFlowCheck.BL/DTO/UserDTO.cs rename to src/WorkFlowCheck.Common/DTO/UserDTO.cs index 5b13dca..d36daa7 100644 --- a/src/WorkFlowCheck.BL/DTO/UserDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/UserDTO.cs @@ -1,4 +1,4 @@ -namespace WorkFlowCheck.BL.DTO +namespace WorkFlowCheck.Common.DTO { public class UserDTO { diff --git a/src/WorkFlowCheck.Common/WorkFlowCheck.Common.csproj b/src/WorkFlowCheck.Common/WorkFlowCheck.Common.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/src/WorkFlowCheck.Common/WorkFlowCheck.Common.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/src/WorkFlowCheck.DL/WorkFlowCheck.DL.csproj b/src/WorkFlowCheck.DL/WorkFlowCheck.DL.csproj index e6a1636..2d72b84 100644 --- a/src/WorkFlowCheck.DL/WorkFlowCheck.DL.csproj +++ b/src/WorkFlowCheck.DL/WorkFlowCheck.DL.csproj @@ -13,7 +13,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - diff --git a/src/WorkFlowCheck.MAUI/MainPage.xaml.cs b/src/WorkFlowCheck.MAUI/MainPage.xaml.cs index 07e12ce..6e916b6 100644 --- a/src/WorkFlowCheck.MAUI/MainPage.xaml.cs +++ b/src/WorkFlowCheck.MAUI/MainPage.xaml.cs @@ -1,4 +1,4 @@ -using WorkFlowCheck.BL.DTO; +using WorkFlowCheck.Common.DTO; using WorkFlowCheck.MAUI.Services; namespace WorkFlowCheck.MAUI { @@ -33,7 +33,7 @@ namespace WorkFlowCheck.MAUI { try { - WelcomeLabel.Text = response.Data.Name; + WelcomeLabel.Text = response.Data.FirstName; } catch (Exception ex) { diff --git a/src/WorkFlowCheck.MAUI/MauiProgram.cs b/src/WorkFlowCheck.MAUI/MauiProgram.cs index 9d1c406..6e15a77 100644 --- a/src/WorkFlowCheck.MAUI/MauiProgram.cs +++ b/src/WorkFlowCheck.MAUI/MauiProgram.cs @@ -11,19 +11,34 @@ namespace WorkFlowCheck.MAUI public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); + + + // appsettings.json beállítása + + string jsonFilePath = Path.Combine(FileSystem.AppDataDirectory, "appsettings.json"); + + // Másold a fájlt a Raw erőforrásokból az AppDataDirectory-ba, ha még nincs ott + if (!File.Exists(jsonFilePath)) + { + using var stream = FileSystem.OpenAppPackageFileAsync("appsettings.json").Result; + using var reader = new StreamReader(stream); + File.WriteAllText(jsonFilePath, reader.ReadToEnd()); + } + var configuration = new ConfigurationBuilder() .SetBasePath(FileSystem.AppDataDirectory) // A konfigurációs fájl betöltése az alkalmazás adat könyvtárából .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .Build(); - builder.Services.AddSingleton(configuration); + builder.Services.AddHttpClient(client => { var apiUrl = configuration["ApiBaseUrl"]; // API-cím betöltése a konfigurációból client.BaseAddress = new Uri(apiUrl); }); + builder.Services.AddSingleton(configuration); builder.Services.AddSingleton(); - + builder .UseMauiApp() .ConfigureFonts(fonts => @@ -33,10 +48,10 @@ namespace WorkFlowCheck.MAUI }); #if DEBUG - builder.Logging.AddDebug(); + builder.Logging.AddDebug(); #endif // HttpClient regisztrálása az alap API-címmel - + var app = builder.Build(); diff --git a/src/WorkFlowCheck.MAUI/Resources/Raw/appsettings.json b/src/WorkFlowCheck.MAUI/Resources/Raw/appsettings.json index 92e3bb3..9b76ca7 100644 --- a/src/WorkFlowCheck.MAUI/Resources/Raw/appsettings.json +++ b/src/WorkFlowCheck.MAUI/Resources/Raw/appsettings.json @@ -1,4 +1,4 @@ { - "ApiBaseUrl": "https://localhost:5069", + "ApiBaseUrl": "https://wfcapi.nuvolar.hu/", "ApiKey": "RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=" } diff --git a/src/WorkFlowCheck.MAUI/Services/IUserService.cs b/src/WorkFlowCheck.MAUI/Services/IUserService.cs index 3f26349..c7511c9 100644 --- a/src/WorkFlowCheck.MAUI/Services/IUserService.cs +++ b/src/WorkFlowCheck.MAUI/Services/IUserService.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using WorkFlowCheck.BL.DTO; +using WorkFlowCheck.Common.DTO; namespace WorkFlowCheck.MAUI.Services { diff --git a/src/WorkFlowCheck.MAUI/Services/UserService.cs b/src/WorkFlowCheck.MAUI/Services/UserService.cs index 9183984..222f268 100644 --- a/src/WorkFlowCheck.MAUI/Services/UserService.cs +++ b/src/WorkFlowCheck.MAUI/Services/UserService.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Net.Http.Json; using System.Text; using System.Threading.Tasks; -using WorkFlowCheck.BL.DTO; +using WorkFlowCheck.Common.DTO; namespace WorkFlowCheck.MAUI.Services { @@ -17,19 +17,21 @@ namespace WorkFlowCheck.MAUI.Services _httpClient = httpClient; var apiBaseUrl = configuration["ApiBaseUrl"]; // API-cím elérése a konfigurációból - _httpClient.BaseAddress = new Uri("https://192.168.50.128:5069"); + _httpClient.BaseAddress = new Uri(apiBaseUrl); + + var apiKey = configuration["ApiKey"]; // Alapértelmezett fejléc beállítása az API-kulccsal //_httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_KEY"); // Ha egyéni fejlécet használsz: - _httpClient.DefaultRequestHeaders.Add("X-Api-Key", "RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU="); + _httpClient.DefaultRequestHeaders.Add("X-Api-Key", apiKey); } public async Task> GetUserAsync() { try { // Az API végpont meghatározása - string endpoint = $"{_httpClient.BaseAddress}api/User"; + string endpoint = $"{_httpClient.BaseAddress}api/User/1"; // HTTP GET kérés küldése var response = await _httpClient.GetFromJsonAsync>(endpoint); diff --git a/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj b/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj index 095239c..bd7663a 100644 --- a/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj +++ b/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj @@ -68,7 +68,7 @@ - + diff --git a/src/WorkFlowCheck.MOBILE.sln b/src/WorkFlowCheck.MOBILE.sln new file mode 100644 index 0000000..e6ca217 --- /dev/null +++ b/src/WorkFlowCheck.MOBILE.sln @@ -0,0 +1,36 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin.NFC", "Plugin.NFC\Plugin.NFC.csproj", "{6B46795C-DF5A-4F12-95A9-691BC1741AB8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.MAUI", "WorkFlowCheck.MAUI\WorkFlowCheck.MAUI.csproj", "{0E2BD120-EE91-4A24-A78A-CE7CA87E09AE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.Common", "WorkFlowCheck.Common\WorkFlowCheck.Common.csproj", "{CBB000AD-E96B-4A4E-A037-4650EFECBB11}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6B46795C-DF5A-4F12-95A9-691BC1741AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B46795C-DF5A-4F12-95A9-691BC1741AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B46795C-DF5A-4F12-95A9-691BC1741AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B46795C-DF5A-4F12-95A9-691BC1741AB8}.Release|Any CPU.Build.0 = Release|Any CPU + {0E2BD120-EE91-4A24-A78A-CE7CA87E09AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E2BD120-EE91-4A24-A78A-CE7CA87E09AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E2BD120-EE91-4A24-A78A-CE7CA87E09AE}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {0E2BD120-EE91-4A24-A78A-CE7CA87E09AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E2BD120-EE91-4A24-A78A-CE7CA87E09AE}.Release|Any CPU.Build.0 = Release|Any CPU + {0E2BD120-EE91-4A24-A78A-CE7CA87E09AE}.Release|Any CPU.Deploy.0 = Release|Any CPU + {CBB000AD-E96B-4A4E-A037-4650EFECBB11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CBB000AD-E96B-4A4E-A037-4650EFECBB11}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CBB000AD-E96B-4A4E-A037-4650EFECBB11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CBB000AD-E96B-4A4E-A037-4650EFECBB11}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/WorkFlowCheck.sln b/src/WorkFlowCheck.sln index 0782e62..81304f8 100644 --- a/src/WorkFlowCheck.sln +++ b/src/WorkFlowCheck.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.DL", "WorkFlo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.BL", "WorkFlowCheck.BL\WorkFlowCheck.BL.csproj", "{73049F81-7A5D-4819-ADB8-A9926672365E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.Common", "WorkFlowCheck.Common\WorkFlowCheck.Common.csproj", "{CBB000AD-E96B-4A4E-A037-4650EFECBB11}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,6 +43,10 @@ Global {73049F81-7A5D-4819-ADB8-A9926672365E}.Debug|Any CPU.Build.0 = Debug|Any CPU {73049F81-7A5D-4819-ADB8-A9926672365E}.Release|Any CPU.ActiveCfg = Release|Any CPU {73049F81-7A5D-4819-ADB8-A9926672365E}.Release|Any CPU.Build.0 = Release|Any CPU + {CBB000AD-E96B-4A4E-A037-4650EFECBB11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CBB000AD-E96B-4A4E-A037-4650EFECBB11}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CBB000AD-E96B-4A4E-A037-4650EFECBB11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CBB000AD-E96B-4A4E-A037-4650EFECBB11}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE