Userhez is lehet már NFC kódot rendelni
This commit is contained in:
@@ -12,7 +12,7 @@ namespace WorkFlowCheck.Common.DTO
|
|||||||
public string? UserName { get; set; }
|
public string? UserName { get; set; }
|
||||||
public string? FirstName { get; set; }
|
public string? FirstName { get; set; }
|
||||||
public string? LastName { get; set; }
|
public string? LastName { get; set; }
|
||||||
public string? Fullname => $"{LastName} {FirstName}";
|
public string? FullName => $"{LastName} {FirstName}";
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public bool NFCActive { get; set; }
|
public bool NFCActive { get; set; }
|
||||||
public string NFCCode { get; set; } = null!;
|
public string NFCCode { get; set; } = null!;
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
using Android.Util;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WorkFlowCheck.Common.DTO;
|
||||||
|
|
||||||
|
namespace WorkFlowCheck.MAUI.Helper
|
||||||
|
{
|
||||||
|
public static class SystemHelper
|
||||||
|
{
|
||||||
|
public static string DatabaseName = "";
|
||||||
|
#if DEBUG
|
||||||
|
public static string ApiBaseUrl = $"https://dev.wfcapi.nuvolar.hu/";
|
||||||
|
public static string ApiKey = $"RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=";
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if !DEBUG
|
||||||
|
public static string ApiBaseUrl = $"https://wfcapi.nuvolar.hu/";
|
||||||
|
public static string ApiKey = $"RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=";
|
||||||
|
#endif
|
||||||
|
public async static Task GetAPIInfoAsync()
|
||||||
|
{
|
||||||
|
using (var httpClient = new HttpClient())
|
||||||
|
{
|
||||||
|
|
||||||
|
httpClient.BaseAddress = new Uri(ApiBaseUrl);
|
||||||
|
httpClient.DefaultRequestHeaders.Add("X-Api-Key", ApiKey);
|
||||||
|
|
||||||
|
string endpoint = $"{ApiBaseUrl}api/System/GetDatabaseAndVersionInfo";
|
||||||
|
var retVal = new RoleDTO();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await httpClient.GetFromJsonAsync<ApiResponseDTO<string>>(endpoint);
|
||||||
|
if (response != null)
|
||||||
|
{
|
||||||
|
if (response.IsSuccess)
|
||||||
|
{
|
||||||
|
DatabaseName = response.Data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using DevExpress.Entity.Model.Metadata;
|
using DevExpress.Entity.Model.Metadata;
|
||||||
using WorkFlowCheck.Common.DTO;
|
using WorkFlowCheck.Common.DTO;
|
||||||
|
using WorkFlowCheck.MAUI.Helper;
|
||||||
using WorkFlowCheck.MAUI.Pages.Media;
|
using WorkFlowCheck.MAUI.Pages.Media;
|
||||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||||
namespace WorkFlowCheck.MAUI
|
namespace WorkFlowCheck.MAUI
|
||||||
@@ -19,7 +20,7 @@ namespace WorkFlowCheck.MAUI
|
|||||||
private void SetInfo()
|
private void SetInfo()
|
||||||
{
|
{
|
||||||
_currentUser = _userService.GetCurrentUser();
|
_currentUser = _userService.GetCurrentUser();
|
||||||
DeviceId.Text = _userService.DeviceId;
|
DeviceId.Text = $"{_userService.DeviceId}";
|
||||||
UserInfo.Text = $"{_currentUser?.FirstName} {_currentUser?.LastName}";
|
UserInfo.Text = $"{_currentUser?.FirstName} {_currentUser?.LastName}";
|
||||||
}
|
}
|
||||||
override protected async void OnAppearing()
|
override protected async void OnAppearing()
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ namespace WorkFlowCheck.MAUI.Mapper
|
|||||||
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRow));
|
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRow));
|
||||||
CreateMap<CheckListRowDTO, CheckListRow>()
|
CreateMap<CheckListRowDTO, CheckListRow>()
|
||||||
.ForMember(dest => dest.CheckListTemplateRow, opt => opt.MapFrom(src => src.CheckListTemplateRowDTO));
|
.ForMember(dest => dest.CheckListTemplateRow, opt => opt.MapFrom(src => src.CheckListTemplateRowDTO));
|
||||||
|
|
||||||
|
CreateMap<MobileUser, MobileUserDTO>();
|
||||||
|
CreateMap<MobileUserDTO, MobileUser>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using WorkFlowCheck.MAUI.Services;
|
using WorkFlowCheck.MAUI.Services;
|
||||||
using Microsoft.Extensions.Http;
|
using Microsoft.Extensions.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@@ -12,6 +11,7 @@ using Microsoft.Maui.Controls.Hosting;
|
|||||||
using Microsoft.Maui.Hosting;
|
using Microsoft.Maui.Hosting;
|
||||||
using CommunityToolkit.Maui.Core;
|
using CommunityToolkit.Maui.Core;
|
||||||
using WorkFlowCheck.MAUI.Handlers;
|
using WorkFlowCheck.MAUI.Handlers;
|
||||||
|
using WorkFlowCheck.MAUI.Helper;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI
|
namespace WorkFlowCheck.MAUI
|
||||||
{
|
{
|
||||||
@@ -21,27 +21,14 @@ namespace WorkFlowCheck.MAUI
|
|||||||
{
|
{
|
||||||
var builder = MauiApp.CreateBuilder();
|
var builder = MauiApp.CreateBuilder();
|
||||||
builder.UseDevExpress(useLocalization: false)
|
builder.UseDevExpress(useLocalization: false)
|
||||||
.UseDevExpressControls()
|
.UseDevExpressControls()
|
||||||
.UseDevExpressCollectionView();
|
.UseDevExpressCollectionView();
|
||||||
|
|
||||||
builder.Services.AddAutoMapper(typeof(MapperProfile));
|
builder.Services.AddAutoMapper(typeof(MapperProfile));
|
||||||
// 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.AddHttpClient();
|
builder.Services.AddHttpClient();
|
||||||
builder.Services.AddDbContext<AppDbContext>();
|
builder.Services.AddDbContext<AppDbContext>();
|
||||||
|
|
||||||
builder.Services.AddSingleton<IConfiguration>(configuration);
|
|
||||||
builder.Services.AddSingleton<IUserService, UserService>();
|
builder.Services.AddSingleton<IUserService, UserService>();
|
||||||
builder.Services.AddSingleton<ISyncService, SyncService>();
|
builder.Services.AddSingleton<ISyncService, SyncService>();
|
||||||
builder.Services.AddSingleton<IBaseStockService, BaseStockService>();
|
builder.Services.AddSingleton<IBaseStockService, BaseStockService>();
|
||||||
@@ -67,6 +54,15 @@ namespace WorkFlowCheck.MAUI
|
|||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
using (var scope = app.Services.CreateScope())
|
||||||
|
{
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await SystemHelper.GetAPIInfoAsync();
|
||||||
|
}).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ServiceProvider = app.Services;
|
ServiceProvider = app.Services;
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,10 @@
|
|||||||
<Button Text="Blokkolás"
|
<Button Text="Blokkolás"
|
||||||
Margin="5,0,0,0"
|
Margin="5,0,0,0"
|
||||||
BackgroundColor="Red"
|
BackgroundColor="Red"
|
||||||
|
HeightRequest="50"
|
||||||
|
MaximumHeightRequest="50"
|
||||||
|
WidthRequest="120"
|
||||||
|
MaximumWidthRequest="120"
|
||||||
IsVisible="{Binding CheckStatus, Converter={StaticResource BlockedConverter}}"
|
IsVisible="{Binding CheckStatus, Converter={StaticResource BlockedConverter}}"
|
||||||
Command="{Binding BindingContext.BlockCommand, Source={x:Reference CheckList}}"
|
Command="{Binding BindingContext.BlockCommand, Source={x:Reference CheckList}}"
|
||||||
CommandParameter="{Binding .}">
|
CommandParameter="{Binding .}">
|
||||||
@@ -73,6 +77,10 @@
|
|||||||
<Button Text="Feloldás"
|
<Button Text="Feloldás"
|
||||||
Margin="5,0,0,0"
|
Margin="5,0,0,0"
|
||||||
BackgroundColor="Green"
|
BackgroundColor="Green"
|
||||||
|
HeightRequest="50"
|
||||||
|
MaximumHeightRequest="50"
|
||||||
|
WidthRequest="120"
|
||||||
|
MaximumWidthRequest="120"
|
||||||
IsVisible="{Binding CheckStatus, Converter={StaticResource UnBlockedConverter}}"
|
IsVisible="{Binding CheckStatus, Converter={StaticResource UnBlockedConverter}}"
|
||||||
Command="{Binding BindingContext.UnblockCommand, Source={x:Reference CheckList}}"
|
Command="{Binding BindingContext.UnblockCommand, Source={x:Reference CheckList}}"
|
||||||
CommandParameter="{Binding .}">
|
CommandParameter="{Binding .}">
|
||||||
@@ -80,6 +88,10 @@
|
|||||||
<Button Text="Folytatás"
|
<Button Text="Folytatás"
|
||||||
Margin="5,0,0,0"
|
Margin="5,0,0,0"
|
||||||
BackgroundColor="Blue"
|
BackgroundColor="Blue"
|
||||||
|
HeightRequest="50"
|
||||||
|
MaximumHeightRequest="50"
|
||||||
|
WidthRequest="120"
|
||||||
|
MaximumWidthRequest="120"
|
||||||
IsVisible="{Binding CheckStatus, Converter={StaticResource ContinueConverter}}"
|
IsVisible="{Binding CheckStatus, Converter={StaticResource ContinueConverter}}"
|
||||||
Command="{Binding BindingContext.ContinueCommand, Source={x:Reference CheckList}}"
|
Command="{Binding BindingContext.ContinueCommand, Source={x:Reference CheckList}}"
|
||||||
CommandParameter="{Binding .}">
|
CommandParameter="{Binding .}">
|
||||||
@@ -116,6 +128,10 @@
|
|||||||
<Button Text="Új ellenőrzés"
|
<Button Text="Új ellenőrzés"
|
||||||
BackgroundColor="Green"
|
BackgroundColor="Green"
|
||||||
Margin="5,0,0,0"
|
Margin="5,0,0,0"
|
||||||
|
HeightRequest="50"
|
||||||
|
MaximumHeightRequest="50"
|
||||||
|
WidthRequest="120"
|
||||||
|
MaximumWidthRequest="120"
|
||||||
Command="{Binding BindingContext.NewCommand, Source={x:Reference CheckListTemplate}}"
|
Command="{Binding BindingContext.NewCommand, Source={x:Reference CheckListTemplate}}"
|
||||||
CommandParameter="{Binding .}" />
|
CommandParameter="{Binding .}" />
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public partial class CheckListPage : ContentPage
|
|||||||
{
|
{
|
||||||
_currentUser = _userService.GetCurrentUser();
|
_currentUser = _userService.GetCurrentUser();
|
||||||
DeviceId.Text = _userService.DeviceId;
|
DeviceId.Text = _userService.DeviceId;
|
||||||
UserInfo.Text = $"{_currentUser?.FirstName} {_currentUser?.LastName}";
|
UserInfo.Text = $"{_currentUser?.LastName} {_currentUser?.FirstName}";
|
||||||
}
|
}
|
||||||
protected override bool OnBackButtonPressed()
|
protected override bool OnBackButtonPressed()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,18 +17,21 @@
|
|||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke">
|
<Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke">
|
||||||
<StackLayout>
|
<Grid ColumnDefinitions="*,Auto">
|
||||||
<Label Text="{Binding ShortName}" FontSize="16" FontAttributes="Bold" />
|
<StackLayout Grid.Column="0" Spacing="2">
|
||||||
<Label Text="{Binding Code}" FontSize="14" />
|
<Label Text="{Binding FullName}" FontSize="16" FontAttributes="Bold" />
|
||||||
<HorizontalStackLayout HorizontalOptions="End">
|
<Label Text="{Binding NFCCode}" FontSize="14" />
|
||||||
<Button Text="Edit" Margin="5,0,0,0"
|
</StackLayout>
|
||||||
Command="{Binding BindingContext.EditCommand, Source={x:Reference UsersList}}"
|
<HorizontalStackLayout Grid.Column="1" HorizontalOptions="End" Spacing="5">
|
||||||
CommandParameter="{Binding .}" />
|
<Button Text="Párosítás" Margin="5,0,0,0"
|
||||||
<Button Text="Pair" Margin="5,0,0,0"
|
HeightRequest="50"
|
||||||
Command="{Binding BindingContext.PairCommand, Source={x:Reference UsersList}}"
|
MaximumHeightRequest="50"
|
||||||
CommandParameter="{Binding .}" />
|
WidthRequest="120"
|
||||||
|
MaximumWidthRequest="120"
|
||||||
|
Command="{Binding BindingContext.PairCommand, Source={x:Reference UsersList}}"
|
||||||
|
CommandParameter="{Binding .}" />
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
</StackLayout>
|
</Grid>
|
||||||
</Frame>
|
</Frame>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</CollectionView.ItemTemplate>
|
</CollectionView.ItemTemplate>
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ public partial class UsersPage : ContentPage
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
|
private readonly ISyncService _syncService;
|
||||||
|
|
||||||
public UsersPage()
|
public UsersPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
|
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
|
||||||
|
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand RefreshCommand { get; set; }
|
public ICommand RefreshCommand { get; set; }
|
||||||
@@ -25,7 +26,7 @@ public partial class UsersPage : ContentPage
|
|||||||
{
|
{
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
RefreshCommand = new Command(async () => await LoadUsers());
|
RefreshCommand = new Command(async () => await LoadUsers());
|
||||||
PairCommand = new Command<UserDTO>(OnPairItem);
|
PairCommand = new Command<MobileUserDTO>(OnPairItem);
|
||||||
|
|
||||||
BindingContext = this;
|
BindingContext = this;
|
||||||
await LoadUsers();
|
await LoadUsers();
|
||||||
@@ -35,12 +36,12 @@ public partial class UsersPage : ContentPage
|
|||||||
{
|
{
|
||||||
IsRefreshing = true;
|
IsRefreshing = true;
|
||||||
//await _syncService.SyncDatas();
|
//await _syncService.SyncDatas();
|
||||||
//UsersList.ItemsSource = await _userService.GetAllUserAsync().Result.Data;
|
UsersList.ItemsSource = await _userService.GetAllMobileUserAsync();
|
||||||
IsRefreshing = false;
|
IsRefreshing = false;
|
||||||
OnPropertyChanged(nameof(IsRefreshing));
|
OnPropertyChanged(nameof(IsRefreshing));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnPairItem(UserDTO UserDTO)
|
private async void OnPairItem(MobileUserDTO mobileUserDTO)
|
||||||
{
|
{
|
||||||
var UserCode = await NFCWaiter.ShowModalAsync();
|
var UserCode = await NFCWaiter.ShowModalAsync();
|
||||||
if (!string.IsNullOrEmpty(UserCode))
|
if (!string.IsNullOrEmpty(UserCode))
|
||||||
@@ -49,10 +50,11 @@ public partial class UsersPage : ContentPage
|
|||||||
{
|
{
|
||||||
await Navigation.PopModalAsync();
|
await Navigation.PopModalAsync();
|
||||||
}
|
}
|
||||||
if (UserDTO != null)
|
if (mobileUserDTO != null)
|
||||||
{
|
{
|
||||||
//UserDTO.Code = UserCode;
|
mobileUserDTO.NFCCode = UserCode;
|
||||||
//await _baseStockService.UpdateUser(UserDTO);
|
|
||||||
|
await _userService.UpdateCheckPoint(mobileUserDTO);
|
||||||
await LoadUsers();
|
await LoadUsers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +76,7 @@ public partial class UsersPage : ContentPage
|
|||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await _userService.SyncUsers_Up((percentage, infostring) =>
|
await _syncService.SyncUsers_Up((percentage, infostring) =>
|
||||||
{
|
{
|
||||||
MainThread.BeginInvokeOnMainThread(() =>
|
MainThread.BeginInvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"ApiBaseUrl": "https://wfcapi.nuvolar.hu/",
|
"ApiBaseUrl": "https://dev.wfcapi.nuvolar.hu/",
|
||||||
"ApiKey": "RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU="
|
"ApiKey": "RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU="
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using WorkFlowCheck.MAUI.DataLayer;
|
|||||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||||
using Android.Provider;
|
using Android.Provider;
|
||||||
using Android.DeviceLock;
|
using Android.DeviceLock;
|
||||||
|
using WorkFlowCheck.MAUI.Helper;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI.Services
|
namespace WorkFlowCheck.MAUI.Services
|
||||||
{
|
{
|
||||||
@@ -20,22 +21,21 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
{
|
{
|
||||||
public readonly HttpClient _httpClient;
|
public readonly HttpClient _httpClient;
|
||||||
public readonly AppDbContext _dbContext;
|
public readonly AppDbContext _dbContext;
|
||||||
public readonly IConfiguration _configuration;
|
|
||||||
public readonly IMapper _mapper;
|
public readonly IMapper _mapper;
|
||||||
private string _deviceId;
|
private string _deviceId;
|
||||||
public string DeviceId => _deviceId.ToUpper(); // Getter a DeviceId-hez
|
public string DeviceId => $"{_deviceId.ToUpper()}:{SystemHelper.DatabaseName}"; // Getter a DeviceId-hez
|
||||||
|
|
||||||
public BaseService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext, IMapper mapper)
|
public BaseService(HttpClient httpClient, AppDbContext dbContext, IMapper mapper)
|
||||||
{
|
{
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_configuration = configuration;
|
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
|
|
||||||
var apiBaseUrl = configuration["ApiBaseUrl"]; // API-cím elérése a konfigurációból
|
var apiBaseUrl = SystemHelper.ApiBaseUrl;
|
||||||
_httpClient.BaseAddress = new Uri(apiBaseUrl);
|
_httpClient.BaseAddress = new Uri(apiBaseUrl);
|
||||||
|
|
||||||
var apiKey = configuration["ApiKey"];
|
var apiKey = SystemHelper.ApiKey;
|
||||||
_httpClient.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
|
_httpClient.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
|
||||||
_deviceId = GetDeviceId();
|
_deviceId = GetDeviceId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,13 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
{
|
{
|
||||||
public class BaseStockService : BaseService, IBaseStockService
|
public class BaseStockService : BaseService, IBaseStockService
|
||||||
{
|
{
|
||||||
public BaseStockService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext, IMapper mapper) : base(httpClient, configuration, dbContext, mapper)
|
public BaseStockService(HttpClient httpClient, AppDbContext dbContext, IMapper mapper) : base(httpClient, dbContext, mapper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<CheckPointDTO>> GetAllCheckPoints()
|
public async Task<List<CheckPointDTO>> GetAllCheckPoints()
|
||||||
{
|
{
|
||||||
return _mapper.Map<List<CheckPointDTO>>(await _dbContext.CheckPoints.ToListAsync());
|
return _mapper.Map<List<CheckPointDTO>>(await _dbContext.CheckPoints.ToListAsync());
|
||||||
|
|
||||||
}
|
}
|
||||||
public async Task<CheckPointDTO> GetCheckPoint(int id)
|
public async Task<CheckPointDTO> GetCheckPoint(int id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
AppDbContext dbContext,
|
AppDbContext dbContext,
|
||||||
IMapper mapper,
|
IMapper mapper,
|
||||||
IUserService userService,
|
IUserService userService,
|
||||||
ISyncService syncService) : base(httpClient, configuration, dbContext, mapper)
|
ISyncService syncService) : base(httpClient, dbContext, mapper)
|
||||||
{
|
{
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
_syncService = syncService;
|
_syncService = syncService;
|
||||||
|
|||||||
@@ -22,5 +22,8 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
|
|||||||
Task<ApiResponseDTO<string>> SyncCheckListHeader_Up(int Id, Action<double, string> reportProgress);
|
Task<ApiResponseDTO<string>> SyncCheckListHeader_Up(int Id, Action<double, string> reportProgress);
|
||||||
|
|
||||||
Task<List<DeviceMessageDTO>> DeviceMessageReadUnreaded(string deviceIdBase64);
|
Task<List<DeviceMessageDTO>> DeviceMessageReadUnreaded(string deviceIdBase64);
|
||||||
|
|
||||||
|
Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress);
|
||||||
|
Task SyncUsers_Down(Action<double, string> reportProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,15 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
|
|||||||
UserDTO? GetCurrentUser();
|
UserDTO? GetCurrentUser();
|
||||||
string DeviceId { get; }
|
string DeviceId { get; }
|
||||||
Task<ApiResponseDTO<UserDTO>> GetUserAsync(int id);
|
Task<ApiResponseDTO<UserDTO>> GetUserAsync(int id);
|
||||||
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<UserDTO>> AuthenticateNFC(string NFCCode);
|
||||||
Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress);
|
|
||||||
void SetCurrentUser(UserDTO user);
|
void SetCurrentUser(UserDTO user);
|
||||||
|
|
||||||
|
|
||||||
|
Task<MobileUserDTO> UpdateCheckPoint(MobileUserDTO mobileUserDTO);
|
||||||
|
Task<List<MobileUserDTO>> GetAllMobileUserAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
{
|
{
|
||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
|
|
||||||
public SyncService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext, IMapper mapper, IUserService userService) : base(httpClient, configuration, dbContext, mapper)
|
public SyncService(HttpClient httpClient, AppDbContext dbContext, IMapper mapper, IUserService userService) : base(httpClient, dbContext, mapper)
|
||||||
{
|
{
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,7 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
await SyncEquipments_Down(reportProgress);
|
await SyncEquipments_Down(reportProgress);
|
||||||
await SyncCheckListTemplates_Down(reportProgress);
|
await SyncCheckListTemplates_Down(reportProgress);
|
||||||
await SyncCheckListHeader_Down(reportProgress);
|
await SyncCheckListHeader_Down(reportProgress);
|
||||||
|
await SyncUsers_Down(reportProgress);
|
||||||
}
|
}
|
||||||
public async Task DownloadAPK(Action<double, string> reportProgress)
|
public async Task DownloadAPK(Action<double, string> reportProgress)
|
||||||
{
|
{
|
||||||
@@ -404,5 +405,72 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress)
|
||||||
|
{
|
||||||
|
var retVal = new ApiResponseDTO<string>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PrepareAuthenticatedRequestAsync();
|
||||||
|
|
||||||
|
var userList = await _dbContext.MobileUsers.ToListAsync();
|
||||||
|
|
||||||
|
var mobileUserListDTO = _mapper.Map<List<MobileUserDTO>>(userList);
|
||||||
|
var endpoint = $"{_httpClient.BaseAddress}api/Sync/UpdateAllMobileUser";
|
||||||
|
|
||||||
|
var json = JsonConvert.SerializeObject(mobileUserListDTO, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
|
||||||
|
var jsonBytes = Encoding.UTF8.GetBytes(json);
|
||||||
|
var jsonStream = new MemoryStream(jsonBytes);
|
||||||
|
|
||||||
|
var progressContent = new ProgressableStreamContent(jsonStream, 8192, (uploaded, total) =>
|
||||||
|
{
|
||||||
|
double percentage = (double)uploaded / total * 100;
|
||||||
|
reportProgress(percentage, "Beküldés...");
|
||||||
|
});
|
||||||
|
|
||||||
|
progressContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
|
||||||
|
|
||||||
|
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsync(endpoint, progressContent))
|
||||||
|
{
|
||||||
|
httpResponseMessage.EnsureSuccessStatusCode();
|
||||||
|
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||||
|
retVal = JsonConvert.DeserializeObject<ApiResponseDTO<string>>(jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
retVal.IsSuccess = false;
|
||||||
|
retVal.Errors.Add(ex.Message);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
public async Task SyncUsers_Down(Action<double, string> reportProgress)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetAllMobileUsers";
|
||||||
|
var responseList = DownloadDataAsync<MobileUserDTO>(endpoint, reportProgress).Result;
|
||||||
|
|
||||||
|
if (responseList != null)
|
||||||
|
{
|
||||||
|
if (responseList.IsSuccess)
|
||||||
|
{
|
||||||
|
var entityList = await _dbContext.MobileUsers.ToListAsync();
|
||||||
|
var missingItems = responseList.Data.Where(f => !entityList.Any(s => s.Id == f.Id)).ToList();
|
||||||
|
|
||||||
|
var mappedMissingItems = _mapper.Map<List<MobileUser>>(missingItems);
|
||||||
|
|
||||||
|
_dbContext.MobileUsers.AddRange(mappedMissingItems);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Hiba visszaadása
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using AutoMapper;
|
|||||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using WorkFlowCheck.MAUI.Handlers;
|
using WorkFlowCheck.MAUI.Handlers;
|
||||||
|
using WorkFlowCheck.MAUI.DataLayer.Entities;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI.Services
|
namespace WorkFlowCheck.MAUI.Services
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,7 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
{
|
{
|
||||||
public UserDTO? CurrentUser { get; private set; }
|
public UserDTO? CurrentUser { get; private set; }
|
||||||
|
|
||||||
public UserService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext, IMapper mapper) : base(httpClient, configuration, dbContext, mapper)
|
public UserService(HttpClient httpClient, AppDbContext dbContext, IMapper mapper) : base(httpClient, dbContext, mapper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,29 +50,7 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<ApiResponseDTO<List<UserDTO>>> GetAllUserAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await PrepareAuthenticatedRequestAsync();
|
|
||||||
|
|
||||||
string endpoint = $"{_httpClient.BaseAddress}api/GetAllUser";
|
|
||||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<UserDTO>>>(endpoint);
|
|
||||||
|
|
||||||
return response ?? new ApiResponseDTO<List<UserDTO>>
|
|
||||||
{
|
|
||||||
IsSuccess = false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
return new ApiResponseDTO<List<UserDTO>>
|
|
||||||
{
|
|
||||||
IsSuccess = false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public async Task<ApiResponseDTO<UserDTO>> Authenticate(string username, string password)
|
public async Task<ApiResponseDTO<UserDTO>> Authenticate(string username, string password)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -148,50 +127,42 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress)
|
|
||||||
{
|
|
||||||
var retVal = new ApiResponseDTO<string>();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await PrepareAuthenticatedRequestAsync();
|
|
||||||
|
|
||||||
var userList = await _dbContext.MobileUsers.ToListAsync();
|
|
||||||
|
|
||||||
var userListDTO = _mapper.Map<List<UserDTO>>(userList);
|
|
||||||
var endpoint = $"{_httpClient.BaseAddress}api/Sync/UpdateAllUser";
|
|
||||||
|
|
||||||
var json = JsonConvert.SerializeObject(userListDTO, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
|
|
||||||
var jsonBytes = Encoding.UTF8.GetBytes(json);
|
|
||||||
var jsonStream = new MemoryStream(jsonBytes);
|
|
||||||
|
|
||||||
var progressContent = new ProgressableStreamContent(jsonStream, 8192, (uploaded, total) =>
|
|
||||||
{
|
|
||||||
double percentage = (double)uploaded / total * 100;
|
|
||||||
reportProgress(percentage, "Beküldés...");
|
|
||||||
});
|
|
||||||
|
|
||||||
progressContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
|
|
||||||
|
|
||||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsync(endpoint, progressContent))
|
|
||||||
{
|
|
||||||
httpResponseMessage.EnsureSuccessStatusCode();
|
|
||||||
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
|
||||||
retVal = JsonConvert.DeserializeObject<ApiResponseDTO<string>>(jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
retVal.IsSuccess = false;
|
|
||||||
retVal.Errors.Add(ex.Message);
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetCurrentUser(UserDTO user)
|
public void SetCurrentUser(UserDTO user)
|
||||||
{
|
{
|
||||||
CurrentUser = user;
|
CurrentUser = user;
|
||||||
}
|
}
|
||||||
public UserDTO? GetCurrentUser() => CurrentUser;
|
public UserDTO? GetCurrentUser() => CurrentUser;
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<MobileUserDTO> UpdateCheckPoint(MobileUserDTO mobileUserDTO)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var existingEntity = await _dbContext.MobileUsers.FindAsync(mobileUserDTO.Id);
|
||||||
|
|
||||||
|
if (existingEntity == null)
|
||||||
|
{
|
||||||
|
throw new Exception("MobileUser not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
existingEntity.NFCCode = mobileUserDTO.NFCCode;
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
mobileUserDTO = _mapper.Map<MobileUserDTO>(existingEntity);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return mobileUserDTO;
|
||||||
|
}
|
||||||
|
public async Task<List<MobileUserDTO>> GetAllMobileUserAsync()
|
||||||
|
{
|
||||||
|
return _mapper.Map<List<MobileUserDTO>>(await _dbContext.MobileUsers.ToListAsync());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Helper\" />
|
|
||||||
<Folder Include="Platforms\Android\Resources\mipmap-hdpi\" />
|
<Folder Include="Platforms\Android\Resources\mipmap-hdpi\" />
|
||||||
<Folder Include="Platforms\Android\Resources\mipmap-xhdpi\" />
|
<Folder Include="Platforms\Android\Resources\mipmap-xhdpi\" />
|
||||||
<Folder Include="Platforms\Android\Resources\mipmap-xxhdpi\" />
|
<Folder Include="Platforms\Android\Resources\mipmap-xxhdpi\" />
|
||||||
|
|||||||
Reference in New Issue
Block a user