SQLLite vol 1.
This commit is contained in:
@@ -1,16 +1,24 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using WorkFlowCheck.Common.DTO;
|
using WorkFlowCheck.Common.DTO;
|
||||||
|
using WorkFlowCheck.MAUI.DataLayer;
|
||||||
using WorkFlowCheck.MAUI.Services;
|
using WorkFlowCheck.MAUI.Services;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI
|
namespace WorkFlowCheck.MAUI
|
||||||
{
|
{
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
|
private readonly AppDbContext _dbContext;
|
||||||
public App(IServiceProvider serviceProvider)
|
public App(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
//MainPage = serviceProvider.GetRequiredService<MainPage>();
|
_dbContext = serviceProvider.GetRequiredService<AppDbContext>();
|
||||||
|
|
||||||
|
_dbContext.Database.EnsureDeleted(); // Adatbázis törlése
|
||||||
|
_dbContext.Database.EnsureCreated(); // Új adatbázis létrehozása
|
||||||
|
|
||||||
|
|
||||||
MainPage = new AppShell();
|
MainPage = new AppShell();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WorkFlowCheck.MAUI.DataLayer.Entities;
|
||||||
|
|
||||||
|
namespace WorkFlowCheck.MAUI.DataLayer
|
||||||
|
{
|
||||||
|
public class AppDbContext : DbContext
|
||||||
|
{
|
||||||
|
private string DbPath { get; }
|
||||||
|
|
||||||
|
public DbSet<CheckListTemplateHeader> CheckListTemplateHeaders { get; set; }
|
||||||
|
public DbSet<CheckListTemplateRow> CheckListTemplateRows { get; set; }
|
||||||
|
public DbSet<CheckPoint> CheckPoints { get; set; }
|
||||||
|
public DbSet<Equipment> Equipments { get; set; }
|
||||||
|
|
||||||
|
public AppDbContext()
|
||||||
|
{
|
||||||
|
DbPath = Path.Combine(FileSystem.AppDataDirectory, "wfc.db");
|
||||||
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
options.UseSqlite($"Data Source={DbPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WorkFlowCheck.MAUI.DataLayer.Entities
|
||||||
|
{
|
||||||
|
public class CheckListTemplateHeader
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ShortName { get; set; } = null!;
|
||||||
|
public string Description { get; set; } = null!;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WorkFlowCheck.MAUI.DataLayer.Entities
|
||||||
|
{
|
||||||
|
public class CheckListTemplateRow
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int RowIndex { get; set; }
|
||||||
|
public int CheckListTemplateHeaderId { get; set; }
|
||||||
|
public virtual CheckListTemplateHeader CheckListTemplateHeader { get; set; }
|
||||||
|
public int EquipmentId { get; set; }
|
||||||
|
public virtual Equipment Equipment { get; set; }
|
||||||
|
public int CheckPointId { get; set; }
|
||||||
|
public virtual CheckPoint CheckPoint { get; set; }
|
||||||
|
public string OperationDescription { get; set; } = null!;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WorkFlowCheck.MAUI.DataLayer.Entities
|
||||||
|
{
|
||||||
|
public class CheckPoint
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ShortName { get; set; } = null!;
|
||||||
|
public string Code { get; set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WorkFlowCheck.MAUI.DataLayer.Entities
|
||||||
|
{
|
||||||
|
public class Equipment
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ShortName { get; set; } = null!;
|
||||||
|
public string EquipmentNumber { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ 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;
|
||||||
|
using CommunityToolkit.Maui;
|
||||||
|
using WorkFlowCheck.MAUI.DataLayer;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI
|
namespace WorkFlowCheck.MAUI
|
||||||
{
|
{
|
||||||
@@ -11,12 +13,8 @@ namespace WorkFlowCheck.MAUI
|
|||||||
public static MauiApp CreateMauiApp()
|
public static MauiApp CreateMauiApp()
|
||||||
{
|
{
|
||||||
var builder = MauiApp.CreateBuilder();
|
var builder = MauiApp.CreateBuilder();
|
||||||
|
|
||||||
|
|
||||||
// appsettings.json beállítása
|
// appsettings.json beállítása
|
||||||
|
|
||||||
string jsonFilePath = Path.Combine(FileSystem.AppDataDirectory, "appsettings.json");
|
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
|
// Másold a fájlt a Raw erőforrásokból az AppDataDirectory-ba, ha még nincs ott
|
||||||
if (!File.Exists(jsonFilePath))
|
if (!File.Exists(jsonFilePath))
|
||||||
{
|
{
|
||||||
@@ -25,43 +23,37 @@ namespace WorkFlowCheck.MAUI
|
|||||||
File.WriteAllText(jsonFilePath, reader.ReadToEnd());
|
File.WriteAllText(jsonFilePath, reader.ReadToEnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
var configuration = new ConfigurationBuilder()
|
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
|
||||||
.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();
|
||||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
builder.Services.AddHttpClient<UserService>(client =>
|
builder.Services.AddHttpClient<UserService>(client =>
|
||||||
{
|
{
|
||||||
var apiUrl = configuration["ApiBaseUrl"]; // API-cím betöltése a konfigurációból
|
var apiUrl = configuration["ApiBaseUrl"]; // API-cím betöltése a konfigurációból
|
||||||
client.BaseAddress = new Uri(apiUrl);
|
client.BaseAddress = new Uri(apiUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddSingleton<IConfiguration>(configuration);
|
builder.Services.AddDbContext<AppDbContext>();
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<IConfiguration>(configuration);
|
||||||
|
builder.Services.AddSingleton<IUserService, UserService>();
|
||||||
|
builder.Services.AddSingleton<ISyncService, SyncService>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IUserService, UserService>();
|
|
||||||
builder.Services.AddTransient<MainPage>();
|
builder.Services.AddTransient<MainPage>();
|
||||||
|
|
||||||
builder
|
builder.UseMauiApp<App>().ConfigureFonts(fonts =>
|
||||||
.UseMauiApp<App>()
|
|
||||||
.ConfigureFonts(fonts =>
|
|
||||||
{
|
{
|
||||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
||||||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
|
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
|
||||||
});
|
}).UseMauiCommunityToolkit();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
builder.Logging.AddDebug();
|
builder.Logging.AddDebug();
|
||||||
#endif
|
#endif
|
||||||
// HttpClient regisztrálása az alap API-címmel
|
// HttpClient regisztrálása az alap API-címmel
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Szolgáltató tárolása globálisan
|
// Szolgáltató tárolása globálisan
|
||||||
ServiceProvider = app.Services;
|
ServiceProvider = app.Services;
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceProvider ServiceProvider { get; private set; }
|
public static IServiceProvider ServiceProvider { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,4 +127,8 @@ public partial class NFCTestPage : ContentPage
|
|||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
protected override bool OnBackButtonPressed() {
|
||||||
|
Shell.Current.GoToAsync("//MainPage");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ namespace WorkFlowCheck.MAUI.Pages.Security;
|
|||||||
|
|
||||||
public partial class LoginPage : ContentPage
|
public partial class LoginPage : ContentPage
|
||||||
{
|
{
|
||||||
private readonly IUserService _userService;
|
private IUserService _userService;
|
||||||
public LoginPage()
|
public LoginPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -24,6 +24,7 @@ public partial class LoginPage : ContentPage
|
|||||||
|
|
||||||
if (response != null && response.IsSuccess)
|
if (response != null && response.IsSuccess)
|
||||||
{
|
{
|
||||||
|
_userService.SetUser(response.Data);
|
||||||
|
|
||||||
var wFCUser = Newtonsoft.Json.JsonConvert.SerializeObject(response.Data);
|
var wFCUser = Newtonsoft.Json.JsonConvert.SerializeObject(response.Data);
|
||||||
await SecureStorage.Default.SetAsync("WFCUser", "wFCUser");
|
await SecureStorage.Default.SetAsync("WFCUser", "wFCUser");
|
||||||
|
|||||||
@@ -4,5 +4,10 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.NFC" />
|
<uses-permission android:name="android.permission.NFC" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
||||||
|
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.nfc" android:required="false" />
|
<uses-feature android:name="android.hardware.nfc" android:required="false" />
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WorkFlowCheck.MAUI.Services
|
||||||
|
{
|
||||||
|
public interface ISyncService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,5 +11,6 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
{
|
{
|
||||||
Task<ApiResponseDTO<UserDTO>> GetUserAsync();
|
Task<ApiResponseDTO<UserDTO>> GetUserAsync();
|
||||||
Task<ApiResponseDTO<UserDTO>> Authenticate(string username, string password);
|
Task<ApiResponseDTO<UserDTO>> Authenticate(string username, string password);
|
||||||
|
void SetUser(UserDTO user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WorkFlowCheck.MAUI.DataLayer;
|
||||||
|
|
||||||
|
namespace WorkFlowCheck.MAUI.Services
|
||||||
|
{
|
||||||
|
public class SyncService: ISyncService
|
||||||
|
{
|
||||||
|
private readonly HttpClient _httpClient;
|
||||||
|
private readonly AppDbContext _dbContext;
|
||||||
|
|
||||||
|
public SyncService(HttpClient httpClient, AppDbContext dbContext)
|
||||||
|
{
|
||||||
|
_httpClient = httpClient;
|
||||||
|
_dbContext = dbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,8 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
public class UserService : IUserService
|
public class UserService : IUserService
|
||||||
{
|
{
|
||||||
private readonly HttpClient _httpClient;
|
private readonly HttpClient _httpClient;
|
||||||
|
|
||||||
|
public UserDTO? CurrentUser { get; private set; }
|
||||||
public UserService(HttpClient httpClient, IConfiguration configuration)
|
public UserService(HttpClient httpClient, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
@@ -91,5 +93,9 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void SetUser(UserDTO user)
|
||||||
|
{
|
||||||
|
CurrentUser = user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,16 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.12">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.12" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
<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.Extensions.Http" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
|
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
|
||||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
|
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
|
||||||
@@ -81,4 +88,8 @@
|
|||||||
</MauiXaml>
|
</MauiXaml>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Pages\CheckList\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user