Üzenetküldés frontenden
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using CommunityToolkit.Maui.Alerts;
|
||||
using CommunityToolkit.Maui.Core;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Threading;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.MAUI.DataLayer;
|
||||
using WorkFlowCheck.MAUI.Services;
|
||||
@@ -10,22 +13,29 @@ namespace WorkFlowCheck.MAUI
|
||||
public partial class App : Application
|
||||
{
|
||||
private readonly AppDbContext _dbContext;
|
||||
private readonly IUserService _userService;
|
||||
private readonly ISyncService _syncService;
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
public App(IServiceProvider serviceProvider)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_dbContext = serviceProvider.GetRequiredService<AppDbContext>();
|
||||
_userService = serviceProvider.GetRequiredService<IUserService>();
|
||||
_syncService = serviceProvider.GetRequiredService<ISyncService>();
|
||||
|
||||
_dbContext.Database.EnsureDeleted(); // Adatbázis törlése
|
||||
_dbContext.Database.EnsureCreated(); // Új adatbázis létrehozása
|
||||
|
||||
|
||||
StartBackgroundTask();
|
||||
MainPage = new AppShell();
|
||||
//MainPage = new NavigationPage(new MainPage(serviceProvider.GetRequiredService<IUserService>()));
|
||||
|
||||
}
|
||||
protected async override void OnResume()
|
||||
{
|
||||
StartBackgroundTask();
|
||||
base.OnResume();
|
||||
var isLogged = await SecureStorage.Default.GetAsync("WFCUser");
|
||||
if (isLogged == null)
|
||||
@@ -35,6 +45,7 @@ namespace WorkFlowCheck.MAUI
|
||||
}
|
||||
protected override void OnSleep()
|
||||
{
|
||||
_cancellationTokenSource?.Cancel();
|
||||
SecureStorage.Default.Remove("WFCUser");
|
||||
base.OnSleep();
|
||||
}
|
||||
@@ -44,6 +55,67 @@ namespace WorkFlowCheck.MAUI
|
||||
SecureStorage.Default.Remove("WFCUser");
|
||||
await Shell.Current.GoToAsync("//LoginPage");
|
||||
}
|
||||
|
||||
|
||||
private void StartBackgroundTask()
|
||||
{
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() => BackgroundTask(_cancellationTokenSource.Token));
|
||||
}
|
||||
private async Task BackgroundTask(CancellationToken cancellationToken)
|
||||
{
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
var userDTO = _userService.GetCurrentUser();
|
||||
|
||||
if (userDTO != null && userDTO.Id > 0)
|
||||
{
|
||||
if (userDTO.RoleDTO?.Count > 0)
|
||||
{
|
||||
foreach (var roleDTO in userDTO.RoleDTO)
|
||||
{
|
||||
if (roleDTO.CanEnableBlocked)
|
||||
{
|
||||
var deviceMessageDTOList = await _syncService.DeviceMessageReadUnreaded(_userService.DeviceId.ToUpper());
|
||||
if (deviceMessageDTOList != null && deviceMessageDTOList.Count > 0)
|
||||
{
|
||||
await ShowSnackbar(deviceMessageDTOList[0].Message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
|
||||
}
|
||||
}
|
||||
private async Task ShowSnackbar(string message)
|
||||
{
|
||||
var visualOptions = new SnackbarOptions
|
||||
{
|
||||
ActionButtonTextColor = Colors.Yellow,
|
||||
CornerRadius = new CornerRadius(5),
|
||||
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"),
|
||||
actionButtonText: "OK",
|
||||
visualOptions: visualOptions
|
||||
);
|
||||
|
||||
await snackbar.Show();
|
||||
}
|
||||
private async Task<ApiResponseDTO<UserDTO>> CheckSecurity()
|
||||
{
|
||||
var isLogged = await SecureStorage.Default.GetAsync("WFCUser");
|
||||
|
||||
@@ -5,20 +5,46 @@
|
||||
Title="Főmenü"
|
||||
BackgroundColor="#f0f0f0">
|
||||
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem x:Name="DeviceId"
|
||||
Text="MK001"
|
||||
Order="Primary"
|
||||
Priority="0" />
|
||||
<!--<ToolbarItem Text="Gomb" Order="Primary" Priority="1" Clicked="OnButtonAction" />-->
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<Shell.TitleView>
|
||||
<Grid Padding="2" VerticalOptions="Center">
|
||||
<Label Text="Főmenü"
|
||||
FontSize="22"
|
||||
FontAttributes="Bold"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Start" />
|
||||
<HorizontalStackLayout
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End"
|
||||
Spacing="5">
|
||||
<Frame CornerRadius="1"
|
||||
Padding="5"
|
||||
HasShadow="True"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End">
|
||||
<Label x:Name="DeviceId"
|
||||
FontSize="10"
|
||||
TextColor="Black"/>
|
||||
</Frame>
|
||||
<Frame CornerRadius="1"
|
||||
Padding="5"
|
||||
HasShadow="True"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End">
|
||||
<Label x:Name="UserInfo"
|
||||
FontSize="10"
|
||||
FontAttributes="Bold"
|
||||
TextColor="Black"/>
|
||||
</Frame>
|
||||
</HorizontalStackLayout>
|
||||
</Grid>
|
||||
</Shell.TitleView>
|
||||
<Grid RowDefinitions="Auto, * , Auto" Padding="30,0">
|
||||
|
||||
<ScrollView Grid.Row="1"
|
||||
Padding="25">
|
||||
<VerticalStackLayout Spacing="25">
|
||||
<Frame BorderColor="Gray"
|
||||
<Frame x:Name="AdminFrame"
|
||||
BorderColor="Gray"
|
||||
Padding="5"
|
||||
CornerRadius="10"
|
||||
Margin="1"
|
||||
@@ -91,7 +117,7 @@
|
||||
</Frame>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</ContentPage>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using DevExpress.Entity.Model.Metadata;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.MAUI.Pages.Media;
|
||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
namespace WorkFlowCheck.MAUI
|
||||
{
|
||||
public partial class MainPage : ContentPage
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
private IUserService _userService;
|
||||
private UserDTO _currentUser;
|
||||
|
||||
public MainPage(IUserService userService)
|
||||
{
|
||||
@@ -14,31 +16,31 @@ namespace WorkFlowCheck.MAUI
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
private void SetInfo()
|
||||
{
|
||||
_currentUser = _userService.GetCurrentUser();
|
||||
DeviceId.Text = _userService.DeviceId;
|
||||
UserInfo.Text = $"{_currentUser?.FirstName} {_currentUser?.LastName}";
|
||||
}
|
||||
override protected async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
var currentUser = _userService.GetCurrentUser();
|
||||
DeviceId.Text = _userService.DeviceId;
|
||||
if (currentUser != null)
|
||||
SetInfo();
|
||||
if (_currentUser != null)
|
||||
{
|
||||
foreach (var role in currentUser.RoleDTO)
|
||||
AdminFrame.IsVisible = false;
|
||||
foreach (var role in _currentUser?.RoleDTO)
|
||||
{
|
||||
if (role.RoleName == "Admin")
|
||||
{
|
||||
if (role.IsAdmin) AdminFrame.IsVisible = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private async void OnButtonAction(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
private void OnButtonDownloadAPK(object sender, EventArgs e)
|
||||
{
|
||||
Shell.Current.GoToAsync("//DownloadAPKPage");
|
||||
@@ -57,6 +59,7 @@ namespace WorkFlowCheck.MAUI
|
||||
}
|
||||
private void OnButtonLogout(object sender, EventArgs e)
|
||||
{
|
||||
_userService.SetCurrentUser(null);
|
||||
SecureStorage.Default.Remove("WFCUser");
|
||||
SecureStorage.Default.Remove("AuthToken");
|
||||
Shell.Current.GoToAsync("//LoginPage");
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="WorkFlowCheck.MAUI.Pages.BasePage">
|
||||
<!--<Shell.TitleView>
|
||||
<Grid BackgroundColor="Blue" Padding="2" VerticalOptions="Center">
|
||||
--><!-- Bal oldali cím --><!--
|
||||
<Label Text="MK001"
|
||||
TextColor="White"
|
||||
FontSize="18"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Start" />
|
||||
|
||||
--><!-- Jobb oldali keret --><!--
|
||||
<Frame BackgroundColor="White"
|
||||
CornerRadius="10"
|
||||
Padding="5"
|
||||
HasShadow="True"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End">
|
||||
<Label Text="Custom Frame" TextColor="Black"/>
|
||||
</Frame>
|
||||
</Grid>
|
||||
</Shell.TitleView>-->
|
||||
<Grid x:Name="MainGrid">
|
||||
<!-- A tartalom helye -->
|
||||
<ContentPresenter x:Name="MainContent"
|
||||
VerticalOptions="Fill"
|
||||
HorizontalOptions="Fill"/>
|
||||
|
||||
<!-- Jobb alsó sarokban a szöveg -->
|
||||
<Label Text="Verzió 1.0.0"
|
||||
TextColor="Black"
|
||||
FontSize="8"
|
||||
HorizontalOptions="End"
|
||||
VerticalOptions="End"
|
||||
Margin="5"
|
||||
Opacity="0.5"
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
</ContentPage>
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace WorkFlowCheck.MAUI.Pages;
|
||||
|
||||
public partial class BasePage : ContentPage
|
||||
{
|
||||
public BasePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
protected void SetContent(View content)
|
||||
{
|
||||
MainGrid.Children.Add(content);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,39 @@
|
||||
x:Class="WorkFlowCheck.MAUI.Pages.CheckList.CheckListPage"
|
||||
Title="Ellenőrzések"
|
||||
BackgroundColor="#f0f0f0">
|
||||
<Shell.TitleView>
|
||||
<Grid Padding="2" VerticalOptions="Center">
|
||||
<Label Text="Ellenőrzések"
|
||||
FontSize="22"
|
||||
FontAttributes="Bold"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Start" />
|
||||
<HorizontalStackLayout
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End"
|
||||
Spacing="5">
|
||||
<Frame CornerRadius="1"
|
||||
Padding="5"
|
||||
HasShadow="True"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End">
|
||||
<Label x:Name="DeviceId"
|
||||
FontSize="10"
|
||||
TextColor="Black"/>
|
||||
</Frame>
|
||||
<Frame CornerRadius="1"
|
||||
Padding="5"
|
||||
HasShadow="True"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End">
|
||||
<Label x:Name="UserInfo"
|
||||
FontSize="10"
|
||||
FontAttributes="Bold"
|
||||
TextColor="Black"/>
|
||||
</Frame>
|
||||
</HorizontalStackLayout>
|
||||
</Grid>
|
||||
</Shell.TitleView>
|
||||
<Grid RowDefinitions="*,*" Padding="30,30">
|
||||
<Frame Grid.Row="0"
|
||||
BorderColor="Gray"
|
||||
|
||||
@@ -14,7 +14,7 @@ public partial class CheckListPage : ContentPage
|
||||
private readonly ICheckListService _checkListService;
|
||||
private readonly IUserService _userService;
|
||||
private bool _isLoading;
|
||||
|
||||
private UserDTO _currentUser;
|
||||
|
||||
public ICommand NewCommand { get; set; }
|
||||
public ICommand ContinueCommand { get; set; }
|
||||
@@ -42,6 +42,12 @@ public partial class CheckListPage : ContentPage
|
||||
BlockCommand = new Command<CheckListHeaderDTO>(OnBlockItem);
|
||||
|
||||
}
|
||||
private void SetInfo()
|
||||
{
|
||||
_currentUser = _userService.GetCurrentUser();
|
||||
DeviceId.Text = _userService.DeviceId;
|
||||
UserInfo.Text = $"{_currentUser?.FirstName} {_currentUser?.LastName}";
|
||||
}
|
||||
protected override bool OnBackButtonPressed()
|
||||
{
|
||||
Shell.Current.GoToAsync("//MainPage");
|
||||
@@ -50,7 +56,7 @@ public partial class CheckListPage : ContentPage
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
|
||||
SetInfo();
|
||||
BindingContext = this;
|
||||
await LoadCheckListTemplate();
|
||||
await LoadCheckList();
|
||||
@@ -90,15 +96,15 @@ public partial class CheckListPage : ContentPage
|
||||
private async Task LoadCheckListTemplate()
|
||||
{
|
||||
IsLoading = true;
|
||||
var userId = _userService.GetCurrentUser()?.Id;
|
||||
CheckListTemplate.ItemsSource = await _checkListService.GetCheckListTemplates(userId ?? 1);
|
||||
|
||||
CheckListTemplate.ItemsSource = await _checkListService.GetCheckListTemplates(_currentUser.Id);
|
||||
IsLoading = false;
|
||||
}
|
||||
private async Task LoadCheckList()
|
||||
{
|
||||
IsLoading = true;
|
||||
var userId = _userService.GetCurrentUser()?.Id;
|
||||
CheckList.ItemsSource = await _checkListService.GetCheckLists(userId ?? 1);
|
||||
|
||||
CheckList.ItemsSource = await _checkListService.GetCheckLists(_currentUser.Id);
|
||||
IsLoading = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,39 @@
|
||||
xmlns:local="clr-namespace:WorkFlowCheck.MAUI.Pages.CheckList"
|
||||
BackgroundColor="#f0f0f0"
|
||||
Title="">
|
||||
<Shell.TitleView>
|
||||
<Grid Padding="2" VerticalOptions="Center">
|
||||
<Label Text=""
|
||||
FontSize="22"
|
||||
FontAttributes="Bold"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Start" />
|
||||
<HorizontalStackLayout
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End"
|
||||
Spacing="5">
|
||||
<Frame CornerRadius="1"
|
||||
Padding="5"
|
||||
HasShadow="True"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End">
|
||||
<Label x:Name="DeviceId"
|
||||
FontSize="10"
|
||||
TextColor="Black"/>
|
||||
</Frame>
|
||||
<Frame CornerRadius="1"
|
||||
Padding="5"
|
||||
HasShadow="True"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="End">
|
||||
<Label x:Name="UserInfo"
|
||||
FontSize="10"
|
||||
FontAttributes="Bold"
|
||||
TextColor="Black"/>
|
||||
</Frame>
|
||||
</HorizontalStackLayout>
|
||||
</Grid>
|
||||
</Shell.TitleView>
|
||||
<Grid>
|
||||
<StackLayout Padding="20">
|
||||
<Label x:Name="progressLabel" Text="Folyamatjelző" FontSize="Default" HorizontalOptions="Center" />
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
<local:BasePage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="WorkFlowCheck.MAUI.Pages.Security.LoginPage"
|
||||
xmlns:local="clr-namespace:WorkFlowCheck.MAUI.Pages"
|
||||
Title="Bejelentkezés"
|
||||
BackgroundColor="#f0f0f0">
|
||||
|
||||
<ScrollView>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<ContentView x:Name="LoginContent">
|
||||
<ScrollView>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Középen lévő kártya, ami mobilon is jól mutat, tableten pedig középen marad -->
|
||||
<Frame Grid.Row="1"
|
||||
<!-- Középen lévő kártya, ami mobilon is jól mutat, tableten pedig középen marad -->
|
||||
<Frame Grid.Row="1"
|
||||
BackgroundColor="White"
|
||||
BorderColor="#cccccc"
|
||||
CornerRadius="20"
|
||||
@@ -25,22 +27,22 @@
|
||||
WidthRequest="{OnPlatform Android=350, iOS=350, WinUI=400, MacCatalyst=400}"
|
||||
MaximumWidthRequest="500">
|
||||
|
||||
<VerticalStackLayout Spacing="20">
|
||||
<VerticalStackLayout Spacing="20">
|
||||
|
||||
<Label Text="Bejelentkezés"
|
||||
<Label Text="Bejelentkezés"
|
||||
FontSize="24"
|
||||
FontAttributes="Bold"
|
||||
HorizontalOptions="Center"
|
||||
TextColor="#333" />
|
||||
|
||||
<Entry x:Name="UsernameEntry"
|
||||
<Entry x:Name="UsernameEntry"
|
||||
Placeholder="Felhasználói név"
|
||||
FontSize="18"
|
||||
BackgroundColor="#f9f9f9"
|
||||
HeightRequest="50"
|
||||
Margin="0" />
|
||||
|
||||
<Entry x:Name="PasswordEntry"
|
||||
<Entry x:Name="PasswordEntry"
|
||||
Placeholder="PIN kód"
|
||||
IsPassword="True"
|
||||
Keyboard="Numeric"
|
||||
@@ -48,21 +50,21 @@
|
||||
BackgroundColor="#f9f9f9"
|
||||
HeightRequest="50"
|
||||
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"
|
||||
|
||||
<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"
|
||||
Text="Bejelentkezés"
|
||||
FontSize="18"
|
||||
HeightRequest="50"
|
||||
CornerRadius="10"
|
||||
TextColor="White"
|
||||
Clicked="OnLoginClicked" />
|
||||
|
||||
<Button x:Name="LoginNFCBtn"
|
||||
|
||||
<Button x:Name="LoginNFCBtn"
|
||||
Text="NFC azonosítás"
|
||||
FontSize="18"
|
||||
HeightRequest="50"
|
||||
@@ -70,12 +72,13 @@
|
||||
TextColor="White"
|
||||
Clicked="OnLoginNFCClicked" />
|
||||
|
||||
<ActivityIndicator x:Name="LoadingIndicator"
|
||||
<ActivityIndicator x:Name="LoadingIndicator"
|
||||
IsRunning="False"
|
||||
IsVisible="False"
|
||||
HorizontalOptions="Center" />
|
||||
</VerticalStackLayout>
|
||||
</Frame>
|
||||
</Grid>
|
||||
</ScrollView>
|
||||
</ContentPage>
|
||||
</VerticalStackLayout>
|
||||
</Frame>
|
||||
</Grid>
|
||||
</ScrollView>
|
||||
</ContentView>
|
||||
</local:BasePage>
|
||||
|
||||
@@ -6,13 +6,14 @@ using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Pages.Security;
|
||||
|
||||
public partial class LoginPage : ContentPage
|
||||
public partial class LoginPage : BasePage
|
||||
{
|
||||
private IUserService _userService;
|
||||
private ISyncService _syncService;
|
||||
public LoginPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetContent(LoginContent);
|
||||
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
|
||||
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
|
||||
Task SyncCheckListHeader_Down(Action<double, string> reportProgress);
|
||||
Task<ApiResponseDTO<string>> SyncCheckListHeader_Up(int Id, Action<double, string> reportProgress);
|
||||
|
||||
|
||||
Task<List<DeviceMessageDTO>> DeviceMessageReadUnreaded(string deviceIdBase64);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
using Android.Content;
|
||||
using Android.Util;
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.MAUI.DataLayer;
|
||||
using WorkFlowCheck.MAUI.DataLayer.Entities;
|
||||
using WorkFlowCheck.MAUI.Handlers;
|
||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
using static Android.Renderscripts.ScriptGroup;
|
||||
using Location = WorkFlowCheck.MAUI.DataLayer.Entities.Location;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Services
|
||||
@@ -16,10 +20,13 @@ namespace WorkFlowCheck.MAUI.Services
|
||||
public class SyncService : BaseService, ISyncService
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public SyncService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext, IMapper mapper, IUserService userService) : base(httpClient, configuration, dbContext, mapper)
|
||||
{
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
|
||||
public async Task SyncDatas(Action<double, string> reportProgress)
|
||||
{
|
||||
await SyncCheckPoints_Down(reportProgress);
|
||||
@@ -372,5 +379,28 @@ namespace WorkFlowCheck.MAUI.Services
|
||||
var responseList = JsonConvert.DeserializeObject<ApiResponseDTO<List<T>>>(jsonString);
|
||||
return responseList;
|
||||
}
|
||||
|
||||
public async Task<List<DeviceMessageDTO>> DeviceMessageReadUnreaded(string deviceId)
|
||||
{
|
||||
var deviceIdBase64= Base64UrlEncoder.Encode(Encoding.UTF8.GetBytes(deviceId));
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/Sync/DeviceMessageReadUnreaded/{deviceIdBase64}";
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace WorkFlowCheck.MAUI.Services
|
||||
public class UserService : BaseService, IUserService
|
||||
{
|
||||
public UserDTO? CurrentUser { get; private set; }
|
||||
|
||||
|
||||
public UserService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext, IMapper mapper) : base(httpClient, configuration, dbContext, mapper)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public async Task<ApiResponseDTO<UserDTO>> GetUserAsync(int id)
|
||||
{
|
||||
try
|
||||
@@ -187,11 +187,11 @@ namespace WorkFlowCheck.MAUI.Services
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public void SetCurrentUser(UserDTO user)
|
||||
{
|
||||
CurrentUser = user;
|
||||
}
|
||||
|
||||
public UserDTO? GetCurrentUser() => CurrentUser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.7.0" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
|
||||
@@ -102,6 +103,9 @@
|
||||
<MauiXaml Update="ContentViews\HeaderView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
<MauiXaml Update="Pages\BasePage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
<MauiXaml Update="Pages\BaseStock\BaseStockPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
@@ -147,6 +151,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Helper\" />
|
||||
<Folder Include="Platforms\Android\Resources\mipmap-hdpi\" />
|
||||
<Folder Include="Platforms\Android\Resources\mipmap-xhdpi\" />
|
||||
<Folder Include="Platforms\Android\Resources\mipmap-xxhdpi\" />
|
||||
|
||||
Reference in New Issue
Block a user