Figyelmeztető üzenet javítása + hangjelzés

This commit is contained in:
2025-04-16 08:41:30 +02:00
parent ab86c845ab
commit 8815df06b3
6 changed files with 66 additions and 10 deletions
+37 -5
View File
@@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
using System.Threading;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.DataLayer;
using WorkFlowCheck.MAUI.Helper;
using WorkFlowCheck.MAUI.Services;
using WorkFlowCheck.MAUI.Services.Interfaces;
@@ -70,7 +71,7 @@ namespace WorkFlowCheck.MAUI
{
var userDTO = _userService.GetCurrentUser();
if (userDTO != null && userDTO.Id > 0)
if (userDTO != null && userDTO.Id > 0 && SystemHelper.Syncronised)
{
if (userDTO.RoleDTO?.Count > 0)
{
@@ -81,7 +82,13 @@ namespace WorkFlowCheck.MAUI
var deviceMessageDTOList = await _syncService.DeviceMessageReadUnreaded(_userService.DeviceId.ToUpper());
if (deviceMessageDTOList != null && deviceMessageDTOList.Count > 0)
{
await ShowSnackbar(deviceMessageDTOList[0].Message);
await ShowSnackbar(deviceMessageDTOList[0].Message, async () => await GoToCheckListPage());
break;
}
deviceMessageDTOList = await _syncService.DeviceMessageReadUnreadedRole(roleDTO.Id);
if (deviceMessageDTOList != null && deviceMessageDTOList.Count > 0)
{
await ShowSnackbar(deviceMessageDTOList[0].Message, async () => await GoToCheckListPage());
break;
}
}
@@ -96,8 +103,32 @@ namespace WorkFlowCheck.MAUI
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
}
}
private async Task ShowSnackbar(string message)
private async Task GoToCheckListPage()
{
await Shell.Current.GoToAsync("//CheckListPage");
}
private async Task ShowSnackbar(string message, Func<Task> action)
{
#if ANDROID
try
{
var context = Android.App.Application.Context;
var player = Android.Media.MediaPlayer.Create(context, Resource.Raw.siren_alert);
player.Start();
// Ha lejátszás után el akarod engedni az erőforrást:
player.Completion += (s, e) =>
{
player.Release();
player.Dispose();
};
}
catch (Exception ex)
{
Console.WriteLine("Hanglejátszás hiba: " + ex.Message);
}
#endif
var visualOptions = new SnackbarOptions
{
ActionButtonTextColor = Colors.Yellow,
@@ -105,17 +136,18 @@ namespace WorkFlowCheck.MAUI
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
TextColor = Colors.Yellow
};
var snackbar = Snackbar.Make(message,
duration: TimeSpan.FromSeconds(10),
action: () => Console.WriteLine("Snackbar dismissed"),
action: async () => await action(),
actionButtonText: "OK",
visualOptions: visualOptions
);
await snackbar.Show();
}
private async Task<ApiResponseDTO<UserDTO>> CheckSecurity()
{
var isLogged = await SecureStorage.Default.GetAsync("WFCUser");
@@ -14,6 +14,7 @@ namespace WorkFlowCheck.MAUI.Helper
public static class SystemHelper
{
public static string DatabaseName = "";
public static bool Syncronised = false;
#if DEBUG
public static string ApiBaseUrl = $"https://dev.wfcapi.nuvolar.hu/";
public static string ApiKey = $"RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=";
@@ -1,5 +1,6 @@
using Android.DeviceLock;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Helper;
using WorkFlowCheck.MAUI.Services.Interfaces;
namespace WorkFlowCheck.MAUI.Pages.System;
@@ -49,7 +50,7 @@ public partial class SyncPage : ContentPage
});
});
});
SystemHelper.Syncronised = true;
progressLabel.Text = "Szinkronizálás befejezve!";
await Shell.Current.GoToAsync("//MainPage");
}
@@ -22,6 +22,7 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
Task<ApiResponseDTO<string>> SyncCheckListHeader_Up(int Id, Action<double, string> reportProgress);
Task<List<DeviceMessageDTO>> DeviceMessageReadUnreaded(string deviceIdBase64);
Task<List<DeviceMessageDTO>> DeviceMessageReadUnreadedRole(int roleId);
Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress);
Task SyncUsers_Down(Action<double, string> reportProgress);
@@ -405,6 +405,27 @@ namespace WorkFlowCheck.MAUI.Services
}
return retVal;
}
public async Task<List<DeviceMessageDTO>> DeviceMessageReadUnreadedRole(int roleId)
{
string endpoint = $"{_httpClient.BaseAddress}api/Sync/DeviceMessageReadUnreadedRole/{roleId}";
var retVal = new List<DeviceMessageDTO>();
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<DeviceMessageDTO>>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
}
return retVal;
}
public async Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress)
{