Mobilról működik a hívás https-en :)
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace WorkFlowCheck.BL.DTO
|
namespace WorkFlowCheck.Common.DTO
|
||||||
{
|
{
|
||||||
public class ApiResponseBaseDTO
|
public class ApiResponseBaseDTO
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace WorkFlowCheck.BL.DTO
|
namespace WorkFlowCheck.Common.DTO
|
||||||
{
|
{
|
||||||
public class UserDTO
|
public class UserDTO
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using WorkFlowCheck.BL.DTO;
|
using WorkFlowCheck.Common.DTO;
|
||||||
using WorkFlowCheck.MAUI.Services;
|
using WorkFlowCheck.MAUI.Services;
|
||||||
namespace WorkFlowCheck.MAUI
|
namespace WorkFlowCheck.MAUI
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ namespace WorkFlowCheck.MAUI
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
WelcomeLabel.Text = response.Data.Name;
|
WelcomeLabel.Text = response.Data.FirstName;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,19 +11,34 @@ namespace WorkFlowCheck.MAUI
|
|||||||
public static MauiApp CreateMauiApp()
|
public static MauiApp CreateMauiApp()
|
||||||
{
|
{
|
||||||
var builder = MauiApp.CreateBuilder();
|
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()
|
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
|
.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)
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||||
.Build();
|
.Build();
|
||||||
builder.Services.AddSingleton<IConfiguration>(configuration);
|
|
||||||
builder.Services.AddHttpClient<UserService>(client =>
|
builder.Services.AddHttpClient<UserService>(client =>
|
||||||
{
|
{
|
||||||
var apiUrl = configuration["ApiBaseUrl"]; // API-cím betöltése a konfigurációból
|
var apiUrl = configuration["ApiBaseUrl"]; // API-cím betöltése a konfigurációból
|
||||||
client.BaseAddress = new Uri(apiUrl);
|
client.BaseAddress = new Uri(apiUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<IConfiguration>(configuration);
|
||||||
builder.Services.AddSingleton<IUserService, UserService>();
|
builder.Services.AddSingleton<IUserService, UserService>();
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.UseMauiApp<App>()
|
.UseMauiApp<App>()
|
||||||
.ConfigureFonts(fonts =>
|
.ConfigureFonts(fonts =>
|
||||||
@@ -33,10 +48,10 @@ namespace WorkFlowCheck.MAUI
|
|||||||
});
|
});
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
builder.Logging.AddDebug();
|
builder.Logging.AddDebug();
|
||||||
#endif
|
#endif
|
||||||
// HttpClient regisztrálása az alap API-címmel
|
// HttpClient regisztrálása az alap API-címmel
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"ApiBaseUrl": "https://localhost:5069",
|
"ApiBaseUrl": "https://wfcapi.nuvolar.hu/",
|
||||||
"ApiKey": "RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU="
|
"ApiKey": "RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU="
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WorkFlowCheck.BL.DTO;
|
using WorkFlowCheck.Common.DTO;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI.Services
|
namespace WorkFlowCheck.MAUI.Services
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WorkFlowCheck.BL.DTO;
|
using WorkFlowCheck.Common.DTO;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI.Services
|
namespace WorkFlowCheck.MAUI.Services
|
||||||
{
|
{
|
||||||
@@ -17,19 +17,21 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
|
|
||||||
var apiBaseUrl = configuration["ApiBaseUrl"]; // API-cím elérése a konfigurációból
|
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
|
// Alapértelmezett fejléc beállítása az API-kulccsal
|
||||||
//_httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_KEY");
|
//_httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_KEY");
|
||||||
// Ha egyéni fejlécet használsz:
|
// Ha egyéni fejlécet használsz:
|
||||||
_httpClient.DefaultRequestHeaders.Add("X-Api-Key", "RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=");
|
_httpClient.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
|
||||||
}
|
}
|
||||||
public async Task<ApiResponseDTO<UserDTO>> GetUserAsync()
|
public async Task<ApiResponseDTO<UserDTO>> GetUserAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Az API végpont meghatározása
|
// 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
|
// HTTP GET kérés küldése
|
||||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<UserDTO>>(endpoint);
|
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<UserDTO>>(endpoint);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Plugin.NFC\Plugin.NFC.csproj" />
|
<ProjectReference Include="..\Plugin.NFC\Plugin.NFC.csproj" />
|
||||||
<ProjectReference Include="..\WorkFlowCheck.BL\WorkFlowCheck.BL.csproj" />
|
<ProjectReference Include="..\WorkFlowCheck.Common\WorkFlowCheck.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.DL", "WorkFlo
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.BL", "WorkFlowCheck.BL\WorkFlowCheck.BL.csproj", "{73049F81-7A5D-4819-ADB8-A9926672365E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.BL", "WorkFlowCheck.BL\WorkFlowCheck.BL.csproj", "{73049F81-7A5D-4819-ADB8-A9926672365E}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.Common", "WorkFlowCheck.Common\WorkFlowCheck.Common.csproj", "{CBB000AD-E96B-4A4E-A037-4650EFECBB11}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{73049F81-7A5D-4819-ADB8-A9926672365E}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user