Na most kezd valami kinézni
This commit is contained in:
@@ -22,10 +22,13 @@ namespace WorkFlowCheck.MAUI.DataLayer
|
|||||||
public AppDbContext()
|
public AppDbContext()
|
||||||
{
|
{
|
||||||
DbPath = Path.Combine(FileSystem.AppDataDirectory, "wfc.db");
|
DbPath = Path.Combine(FileSystem.AppDataDirectory, "wfc.db");
|
||||||
|
|
||||||
}
|
}
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
{
|
{
|
||||||
options.UseSqlite($"Data Source={DbPath}");
|
options.UseSqlite($"Data Source={DbPath};Foreign Keys=False;");
|
||||||
|
options.EnableSensitiveDataLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WorkFlowCheck.MAUI.DataLayer.SQLiteFolder
|
||||||
|
{
|
||||||
|
public static class Constants
|
||||||
|
{
|
||||||
|
public const string DatabaseFilename = "WFC.db3";
|
||||||
|
|
||||||
|
public const SQLite.SQLiteOpenFlags Flags =
|
||||||
|
// open the database in read/write mode
|
||||||
|
SQLite.SQLiteOpenFlags.ReadWrite |
|
||||||
|
// create the database if it doesn't exist
|
||||||
|
SQLite.SQLiteOpenFlags.Create |
|
||||||
|
// enable multi-threaded database access
|
||||||
|
SQLite.SQLiteOpenFlags.SharedCache;
|
||||||
|
|
||||||
|
public static string DatabasePath =>
|
||||||
|
Path.Combine(FileSystem.AppDataDirectory, DatabaseFilename);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using SQLite;
|
||||||
|
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.SQLiteFolder
|
||||||
|
{
|
||||||
|
public class WFCDatabase
|
||||||
|
{
|
||||||
|
SQLiteAsyncConnection Database;
|
||||||
|
public WFCDatabase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
async Task Init()
|
||||||
|
{
|
||||||
|
if (Database is not null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Database = new SQLiteAsyncConnection(Constants.DatabasePath, Constants.Flags);
|
||||||
|
|
||||||
|
var result = await Database.CreateTableAsync<CheckPoint>();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,26 +4,30 @@
|
|||||||
x:Class="WorkFlowCheck.MAUI.Pages.BaseStock.BaseStockPage"
|
x:Class="WorkFlowCheck.MAUI.Pages.BaseStock.BaseStockPage"
|
||||||
Title="Törzs adatok">
|
Title="Törzs adatok">
|
||||||
<VerticalStackLayout Margin="10,0,10,0">
|
<VerticalStackLayout Margin="10,0,10,0">
|
||||||
<Button
|
<Frame BorderColor="Gray" Padding="5" Margin="1" HasShadow="True">
|
||||||
|
<VerticalStackLayout Margin="10,10,10,0">
|
||||||
|
<Button
|
||||||
x:Name="ButtonGetCheckPoints"
|
x:Name="ButtonGetCheckPoints"
|
||||||
Margin="0,0,0,20"
|
Margin="0,0,0,10"
|
||||||
Text="Ellenőrzési pontok"
|
Text="Ellenőrzési pontok"
|
||||||
SemanticProperties.Hint="Ellenőrzési pontok"
|
SemanticProperties.Hint="Ellenőrzési pontok"
|
||||||
Clicked="OnButtonGetCheckPoints"
|
Clicked="OnButtonGetCheckPoints"
|
||||||
HorizontalOptions="Fill" />
|
HorizontalOptions="Fill" />
|
||||||
<Button
|
<Button
|
||||||
x:Name="ButtonGetEquipments"
|
x:Name="ButtonGetEquipments"
|
||||||
Margin="0,0,0,20"
|
Margin="0,0,0,10"
|
||||||
Text="Berendezések"
|
Text="Berendezések"
|
||||||
SemanticProperties.Hint="Berendezések"
|
SemanticProperties.Hint="Berendezések"
|
||||||
Clicked="OnButtonGetCheckPoints"
|
Clicked="OnButtonGetCheckPoints"
|
||||||
HorizontalOptions="Fill" />
|
HorizontalOptions="Fill" />
|
||||||
<Button
|
<Button
|
||||||
x:Name="ButtonGetLocations"
|
x:Name="ButtonGetLocations"
|
||||||
Margin="0,0,0,20"
|
Margin="0,0,0,10"
|
||||||
Text="Lokációk"
|
Text="Lokációk"
|
||||||
SemanticProperties.Hint="Lokációk"
|
SemanticProperties.Hint="Lokációk"
|
||||||
Clicked="OnButtonGetCheckPoints"
|
Clicked="OnButtonGetCheckPoints"
|
||||||
HorizontalOptions="Fill" />
|
HorizontalOptions="Fill" />
|
||||||
|
</VerticalStackLayout>
|
||||||
|
</Frame>
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
@@ -11,7 +11,7 @@ public partial class CheckPointsPage : ContentPage
|
|||||||
{
|
{
|
||||||
private readonly IBaseStockService _baseStockService;
|
private readonly IBaseStockService _baseStockService;
|
||||||
private readonly ISyncService _syncService;
|
private readonly ISyncService _syncService;
|
||||||
|
private bool _onReceiveing = false;
|
||||||
|
|
||||||
public CheckPointsPage()
|
public CheckPointsPage()
|
||||||
{
|
{
|
||||||
@@ -52,7 +52,7 @@ public partial class CheckPointsPage : ContentPage
|
|||||||
private async void OnPairItem(CheckPointDTO checkPointDTO)
|
private async void OnPairItem(CheckPointDTO checkPointDTO)
|
||||||
{
|
{
|
||||||
_checkPointDTO = checkPointDTO;
|
_checkPointDTO = checkPointDTO;
|
||||||
await BeginListening();
|
await BeginListening();
|
||||||
}
|
}
|
||||||
protected override bool OnBackButtonPressed()
|
protected override bool OnBackButtonPressed()
|
||||||
{
|
{
|
||||||
@@ -93,7 +93,8 @@ public partial class CheckPointsPage : ContentPage
|
|||||||
}
|
}
|
||||||
async void Current_OnMessageReceived_NFCData(ITagInfo tagInfo)
|
async void Current_OnMessageReceived_NFCData(ITagInfo tagInfo)
|
||||||
{
|
{
|
||||||
|
if (_onReceiveing) return;
|
||||||
|
_onReceiveing = true;
|
||||||
if (tagInfo == null)
|
if (tagInfo == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -105,10 +106,11 @@ public partial class CheckPointsPage : ContentPage
|
|||||||
{
|
{
|
||||||
_checkPointDTO.Code = serialNumber;
|
_checkPointDTO.Code = serialNumber;
|
||||||
await _baseStockService.UpdateCheckPoint(_checkPointDTO);
|
await _baseStockService.UpdateCheckPoint(_checkPointDTO);
|
||||||
|
//CrossNFC.Current.StopListening();
|
||||||
UnsubscribeEvents();
|
UnsubscribeEvents();
|
||||||
CrossNFC.Current.StopListening();
|
|
||||||
await LoadCheckPoints();
|
await LoadCheckPoints();
|
||||||
}
|
}
|
||||||
|
_onReceiveing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -29,14 +30,32 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
return _mapper.Map<CheckPointDTO>(await _dbContext.CheckPoints.Where(w => w.Id == id).FirstOrDefaultAsync());
|
return _mapper.Map<CheckPointDTO>(await _dbContext.CheckPoints.Where(w => w.Id == id).FirstOrDefaultAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CheckPointDTO> UpdateCheckPoint(CheckPointDTO checkPoint)
|
public async Task<CheckPointDTO> UpdateCheckPoint(CheckPointDTO checkPointDto)
|
||||||
{
|
{
|
||||||
var retVal = checkPoint;
|
// Lekérjük a meglévő entitást az adatbázisból
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var existingEntity = await _dbContext.CheckPoints.FindAsync(checkPointDto.Id);
|
||||||
|
|
||||||
_dbContext.CheckPoints.Update(_mapper.Map<CheckPoint>(checkPoint));
|
if (existingEntity == null)
|
||||||
_dbContext.SaveChanges();
|
{
|
||||||
|
throw new Exception("CheckPoint not found.");
|
||||||
|
}
|
||||||
|
|
||||||
return retVal;
|
// Frissítjük az adatokat
|
||||||
|
existingEntity.ShortName = checkPointDto.ShortName;
|
||||||
|
existingEntity.Code = checkPointDto.Code;
|
||||||
|
|
||||||
|
// Mivel a DbContext már követi az existingEntity-t, nem kell explicit Update() hívás
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return checkPointDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
|
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user