NFC azonosítás is beállítva
This commit is contained in:
@@ -3,12 +3,29 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="WorkFlowCheck.MAUI.Pages.NFC.NFCWaiter"
|
x:Class="WorkFlowCheck.MAUI.Pages.NFC.NFCWaiter"
|
||||||
Title="Várakozás NFC olvasásra"
|
Title="Várakozás NFC olvasásra"
|
||||||
BackgroundColor="Black">
|
BackgroundColor="#f0f0f0">
|
||||||
<VerticalStackLayout Padding="20" HorizontalOptions="Center" VerticalOptions="Center">
|
|
||||||
|
<Frame BackgroundColor="White"
|
||||||
|
BorderColor="#cccccc"
|
||||||
|
CornerRadius="20"
|
||||||
|
Padding="30"
|
||||||
|
HasShadow="True"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
WidthRequest="{OnPlatform Android=450, iOS=350, WinUI=400, MacCatalyst=400}"
|
||||||
|
MaximumWidthRequest="500">
|
||||||
|
<VerticalStackLayout Spacing="20" Padding="20" HorizontalOptions="Center" VerticalOptions="Center">
|
||||||
<Label Text="Tartsa a készülékhez az NFC tag-et..."
|
<Label Text="Tartsa a készülékhez az NFC tag-et..."
|
||||||
TextColor="White"
|
TextColor="Black"
|
||||||
FontSize="20"
|
FontSize="20"
|
||||||
HorizontalOptions="Center" />
|
HorizontalOptions="Center" />
|
||||||
<ActivityIndicator IsRunning="True" Color="White" />
|
<ActivityIndicator IsRunning="True" />
|
||||||
|
<Button x:Name="CancelButton"
|
||||||
|
Text="Mégse"
|
||||||
|
FontSize="18"
|
||||||
|
TextColor="White"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
Clicked="OnCancelButtonClicked" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
|
</Frame>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
@@ -56,7 +56,7 @@ public partial class NFCWaiter : ContentPage
|
|||||||
Finish(tagId);
|
Finish(tagId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Finish(string tagId)
|
private async Task Finish(string tagId)
|
||||||
{
|
{
|
||||||
#if ANDROID
|
#if ANDROID
|
||||||
if (Platform.CurrentActivity is Android.App.Activity activity && activity is MainActivity mainActivity)
|
if (Platform.CurrentActivity is Android.App.Activity activity && activity is MainActivity mainActivity)
|
||||||
@@ -79,6 +79,10 @@ public partial class NFCWaiter : ContentPage
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private async void OnCancelButtonClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
await Finish("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,15 +49,27 @@
|
|||||||
HeightRequest="50"
|
HeightRequest="50"
|
||||||
Margin="0" />
|
Margin="0" />
|
||||||
|
|
||||||
|
<HorizontalStackLayout Spacing="20" HorizontalOptions="Center">
|
||||||
|
<RadioButton x:Name="ProdOption" Content="PROD" GroupName="Environment" />
|
||||||
|
<RadioButton x:Name="UatOption" Content="UAT" GroupName="Environment" />
|
||||||
|
</HorizontalStackLayout>
|
||||||
|
|
||||||
<Button x:Name="LoginBtn"
|
<Button x:Name="LoginBtn"
|
||||||
Text="Bejelentkezés"
|
Text="Bejelentkezés"
|
||||||
FontSize="18"
|
FontSize="18"
|
||||||
HeightRequest="50"
|
HeightRequest="50"
|
||||||
CornerRadius="10"
|
CornerRadius="10"
|
||||||
BackgroundColor="#007aff"
|
|
||||||
TextColor="White"
|
TextColor="White"
|
||||||
Clicked="OnLoginClicked" />
|
Clicked="OnLoginClicked" />
|
||||||
|
|
||||||
|
<Button x:Name="LoginNFCBtn"
|
||||||
|
Text="NFC azonosítás"
|
||||||
|
FontSize="18"
|
||||||
|
HeightRequest="50"
|
||||||
|
CornerRadius="10"
|
||||||
|
TextColor="White"
|
||||||
|
Clicked="OnLoginNFCClicked" />
|
||||||
|
|
||||||
<ActivityIndicator x:Name="LoadingIndicator"
|
<ActivityIndicator x:Name="LoadingIndicator"
|
||||||
IsRunning="False"
|
IsRunning="False"
|
||||||
IsVisible="False"
|
IsVisible="False"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using CommunityToolkit.Maui.Alerts;
|
using CommunityToolkit.Maui.Alerts;
|
||||||
using CommunityToolkit.Maui.Core;
|
using CommunityToolkit.Maui.Core;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using WorkFlowCheck.MAUI.Pages.NFC;
|
||||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI.Pages.Security;
|
namespace WorkFlowCheck.MAUI.Pages.Security;
|
||||||
@@ -47,7 +48,7 @@ public partial class LoginPage : ContentPage
|
|||||||
CornerRadius = new CornerRadius(10),
|
CornerRadius = new CornerRadius(10),
|
||||||
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
|
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
|
||||||
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
|
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
|
||||||
TextColor=Colors.Yellow
|
TextColor = Colors.Yellow
|
||||||
|
|
||||||
};
|
};
|
||||||
var snackbar = Snackbar.Make(
|
var snackbar = Snackbar.Make(
|
||||||
@@ -77,4 +78,71 @@ public partial class LoginPage : ContentPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private async void OnLoginNFCClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadingIndicator.IsRunning = true;
|
||||||
|
LoadingIndicator.IsVisible = true;
|
||||||
|
LoginBtn.IsEnabled = false;
|
||||||
|
LoginNFCBtn.IsEnabled = false;
|
||||||
|
UsernameEntry.IsEnabled = false;
|
||||||
|
PasswordEntry.IsEnabled = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var nFCCode = await NFCWaiter.ShowModalAsync();
|
||||||
|
if (!string.IsNullOrEmpty(nFCCode))
|
||||||
|
{
|
||||||
|
var response = await _userService.AuthenticateNFC(nFCCode);
|
||||||
|
|
||||||
|
if (response != null && response.IsSuccess)
|
||||||
|
{
|
||||||
|
_userService.SetCurrentUser(response.Data);
|
||||||
|
|
||||||
|
//await _syncService.SyncDatas();
|
||||||
|
|
||||||
|
var wFCUser = Newtonsoft.Json.JsonConvert.SerializeObject(response.Data);
|
||||||
|
await SecureStorage.Default.SetAsync("WFCUser", "wFCUser");
|
||||||
|
await SecureStorage.Default.SetAsync("AuthToken", response.Data.JwtToken);
|
||||||
|
|
||||||
|
await Shell.Current.GoToAsync("//SyncPage");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var visualOptions = new SnackbarOptions
|
||||||
|
{
|
||||||
|
ActionButtonTextColor = Colors.Yellow,
|
||||||
|
CornerRadius = new CornerRadius(10),
|
||||||
|
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
|
||||||
|
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
|
||||||
|
TextColor = Colors.Yellow
|
||||||
|
|
||||||
|
};
|
||||||
|
var snackbar = Snackbar.Make(
|
||||||
|
"Invalid login credentials.",
|
||||||
|
duration: TimeSpan.FromSeconds(10),
|
||||||
|
action: () => Console.WriteLine("Snackbar dismissed"),
|
||||||
|
actionButtonText: "OK",
|
||||||
|
visualOptions: visualOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await snackbar.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
LoginBtn.IsEnabled = true;
|
||||||
|
LoadingIndicator.IsRunning = false;
|
||||||
|
LoadingIndicator.IsVisible = false;
|
||||||
|
UsernameEntry.IsEnabled = true;
|
||||||
|
PasswordEntry.IsEnabled = true;
|
||||||
|
LoginNFCBtn.IsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ public partial class UsersPage : ContentPage
|
|||||||
{
|
{
|
||||||
IsRefreshing = true;
|
IsRefreshing = true;
|
||||||
//await _syncService.SyncDatas();
|
//await _syncService.SyncDatas();
|
||||||
UsersList.ItemsSource = await _userService.GetAllUsers();
|
//UsersList.ItemsSource = await _userService.GetAllUserAsync().Result.Data;
|
||||||
IsRefreshing = false;
|
IsRefreshing = false;
|
||||||
OnPropertyChanged(nameof(IsRefreshing));
|
OnPropertyChanged(nameof(IsRefreshing));
|
||||||
}
|
}
|
||||||
@@ -51,8 +51,8 @@ public partial class UsersPage : ContentPage
|
|||||||
}
|
}
|
||||||
if (UserDTO != null)
|
if (UserDTO != null)
|
||||||
{
|
{
|
||||||
UserDTO.Code = UserCode;
|
//UserDTO.Code = UserCode;
|
||||||
await _baseStockService.UpdateUser(UserDTO);
|
//await _baseStockService.UpdateUser(UserDTO);
|
||||||
await LoadUsers();
|
await LoadUsers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
|
|||||||
Task<ApiResponseDTO<UserDTO>> GetUserAsync(int id);
|
Task<ApiResponseDTO<UserDTO>> GetUserAsync(int id);
|
||||||
Task<ApiResponseDTO<List<UserDTO>>> GetAllUserAsync();
|
Task<ApiResponseDTO<List<UserDTO>>> GetAllUserAsync();
|
||||||
Task<ApiResponseDTO<UserDTO>> Authenticate(string username, string password);
|
Task<ApiResponseDTO<UserDTO>> Authenticate(string username, string password);
|
||||||
|
Task<ApiResponseDTO<UserDTO>> AuthenticateNFC(string NFCCode);
|
||||||
Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress);
|
Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress);
|
||||||
void SetCurrentUser(UserDTO user);
|
void SetCurrentUser(UserDTO user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,44 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public async Task<ApiResponseDTO<UserDTO>> AuthenticateNFC(string NFCCode)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Az API végpont meghatározása
|
||||||
|
string endpoint = $"{_httpClient.BaseAddress}api/user/authenticatenfc";
|
||||||
|
|
||||||
|
var userSimpleDTO = new UserSimpleDTO()
|
||||||
|
{
|
||||||
|
UserName = NFCCode,
|
||||||
|
Password = NFCCode,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// HTTP POST kérés küldése
|
||||||
|
|
||||||
|
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, userSimpleDTO))
|
||||||
|
{
|
||||||
|
httpResponseMessage.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||||
|
var response = JsonConvert.DeserializeObject<ApiResponseDTO<UserDTO>>(jsonString);
|
||||||
|
|
||||||
|
return response ?? new ApiResponseDTO<UserDTO>
|
||||||
|
{
|
||||||
|
IsSuccess = false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Hiba visszaadása
|
||||||
|
return new ApiResponseDTO<UserDTO>
|
||||||
|
{
|
||||||
|
IsSuccess = false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
public async Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress)
|
public async Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress)
|
||||||
{
|
{
|
||||||
var retVal = new ApiResponseDTO<string>();
|
var retVal = new ApiResponseDTO<string>();
|
||||||
@@ -116,7 +154,7 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
{
|
{
|
||||||
await PrepareAuthenticatedRequestAsync();
|
await PrepareAuthenticatedRequestAsync();
|
||||||
|
|
||||||
var userList = await _dbContext.Users.ToListAsync();
|
var userList = await _dbContext.MobileUsers.ToListAsync();
|
||||||
|
|
||||||
var userListDTO = _mapper.Map<List<UserDTO>>(userList);
|
var userListDTO = _mapper.Map<List<UserDTO>>(userList);
|
||||||
var endpoint = $"{_httpClient.BaseAddress}api/Sync/UpdateAllUser";
|
var endpoint = $"{_httpClient.BaseAddress}api/Sync/UpdateAllUser";
|
||||||
|
|||||||
Reference in New Issue
Block a user