diff --git a/src/WorkFlowCheck.Common/DTO/MobileUserDTO.cs b/src/WorkFlowCheck.Common/DTO/MobileUserDTO.cs index 38d11bc..221b1a7 100644 --- a/src/WorkFlowCheck.Common/DTO/MobileUserDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/MobileUserDTO.cs @@ -12,7 +12,7 @@ namespace WorkFlowCheck.Common.DTO public string? UserName { get; set; } public string? FirstName { get; set; } public string? LastName { get; set; } - public string? Fullname => $"{LastName} {FirstName}"; + public string? FullName => $"{LastName} {FirstName}"; public string? Email { get; set; } public bool NFCActive { get; set; } public string NFCCode { get; set; } = null!; diff --git a/src/WorkFlowCheck.MAUI/Helper/SystemHelper.cs b/src/WorkFlowCheck.MAUI/Helper/SystemHelper.cs new file mode 100644 index 0000000..9c29e3d --- /dev/null +++ b/src/WorkFlowCheck.MAUI/Helper/SystemHelper.cs @@ -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>(endpoint); + if (response != null) + { + if (response.IsSuccess) + { + DatabaseName = response.Data; + } + } + } + catch (Exception ex) + { + //Log.Error(ex.Message); + } + } + } + } +} diff --git a/src/WorkFlowCheck.MAUI/MainPage.xaml.cs b/src/WorkFlowCheck.MAUI/MainPage.xaml.cs index f5874f7..93d1896 100644 --- a/src/WorkFlowCheck.MAUI/MainPage.xaml.cs +++ b/src/WorkFlowCheck.MAUI/MainPage.xaml.cs @@ -1,5 +1,6 @@ using DevExpress.Entity.Model.Metadata; using WorkFlowCheck.Common.DTO; +using WorkFlowCheck.MAUI.Helper; using WorkFlowCheck.MAUI.Pages.Media; using WorkFlowCheck.MAUI.Services.Interfaces; namespace WorkFlowCheck.MAUI @@ -19,7 +20,7 @@ namespace WorkFlowCheck.MAUI private void SetInfo() { _currentUser = _userService.GetCurrentUser(); - DeviceId.Text = _userService.DeviceId; + DeviceId.Text = $"{_userService.DeviceId}"; UserInfo.Text = $"{_currentUser?.FirstName} {_currentUser?.LastName}"; } override protected async void OnAppearing() @@ -59,7 +60,7 @@ namespace WorkFlowCheck.MAUI } private void OnButtonLogout(object sender, EventArgs e) { - _userService.SetCurrentUser(null); + _userService.SetCurrentUser(null); SecureStorage.Default.Remove("WFCUser"); SecureStorage.Default.Remove("AuthToken"); Shell.Current.GoToAsync("//LoginPage"); diff --git a/src/WorkFlowCheck.MAUI/Mapper/MapperProfile.cs b/src/WorkFlowCheck.MAUI/Mapper/MapperProfile.cs index 6ec83e6..2c038be 100644 --- a/src/WorkFlowCheck.MAUI/Mapper/MapperProfile.cs +++ b/src/WorkFlowCheck.MAUI/Mapper/MapperProfile.cs @@ -34,7 +34,10 @@ namespace WorkFlowCheck.MAUI.Mapper CreateMap() .ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRow)); CreateMap() - .ForMember(dest => dest.CheckListTemplateRow, opt => opt.MapFrom(src => src.CheckListTemplateRowDTO)); + .ForMember(dest => dest.CheckListTemplateRow, opt => opt.MapFrom(src => src.CheckListTemplateRowDTO)); + + CreateMap(); + CreateMap(); } } } diff --git a/src/WorkFlowCheck.MAUI/MauiProgram.cs b/src/WorkFlowCheck.MAUI/MauiProgram.cs index 079da77..f984473 100644 --- a/src/WorkFlowCheck.MAUI/MauiProgram.cs +++ b/src/WorkFlowCheck.MAUI/MauiProgram.cs @@ -1,5 +1,4 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using WorkFlowCheck.MAUI.Services; using Microsoft.Extensions.Http; using Microsoft.Extensions.DependencyInjection; @@ -12,6 +11,7 @@ using Microsoft.Maui.Controls.Hosting; using Microsoft.Maui.Hosting; using CommunityToolkit.Maui.Core; using WorkFlowCheck.MAUI.Handlers; +using WorkFlowCheck.MAUI.Helper; namespace WorkFlowCheck.MAUI { @@ -21,27 +21,14 @@ namespace WorkFlowCheck.MAUI { var builder = MauiApp.CreateBuilder(); builder.UseDevExpress(useLocalization: false) - .UseDevExpressControls() - .UseDevExpressCollectionView(); + .UseDevExpressControls() + .UseDevExpressCollectionView(); + 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.AddDbContext(); - builder.Services.AddSingleton(configuration); + builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); @@ -64,9 +51,18 @@ namespace WorkFlowCheck.MAUI #if DEBUG builder.Logging.AddDebug(); #endif - + var app = builder.Build(); + using (var scope = app.Services.CreateScope()) + { + Task.Run(async () => + { + await SystemHelper.GetAPIInfoAsync(); + }).GetAwaiter().GetResult(); + } + + ServiceProvider = app.Services; return app; } diff --git a/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListPage.xaml b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListPage.xaml index e04e9c5..a9740ff 100644 --- a/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListPage.xaml +++ b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListPage.xaml @@ -66,6 +66,10 @@