improvements, fixes, etc...

This commit is contained in:
Loretta 2025-09-29 13:33:34 +02:00
parent 8cae7bbd76
commit df4715360e
26 changed files with 315 additions and 141 deletions

View File

@ -10,7 +10,10 @@ namespace FruitBank.Common.Server
public class FruitBankConst : AcConst public class FruitBankConst : AcConst
{ {
public static string ProjectIdString = "aad53443-2ee2-4650-8a99-97e907265e4e"; public static string ProjectIdString = "aad53443-2ee2-4650-8a99-97e907265e4e";
public static string MeasuringRoleSystemName = "Measuring"; public static string MeasuringRoleSystemName = "Measuring";
public static string MeasuringRevisorRoleSystemName = "MeasuringRevisor";
public static string IsMeasureableAttributeName = "IsMeasurable";
static FruitBankConst() static FruitBankConst()
{ {

View File

@ -13,6 +13,8 @@ public class Shipping : MgEntityBase, IShipping
public string LicencePlate { get; set; } public string LicencePlate { get; set; }
public bool IsAllMeasured { get; set; } public bool IsAllMeasured { get; set; }
public DateTime? MeasuredDate { get; set; }
[Association(ThisKey = nameof(Id), OtherKey = nameof(ShippingDocument.ShippingId), CanBeNull = true)] [Association(ThisKey = nameof(Id), OtherKey = nameof(ShippingDocument.ShippingId), CanBeNull = true)]
public List<ShippingDocument>? ShippingDocuments { get; set; } public List<ShippingDocument>? ShippingDocuments { get; set; }

View File

@ -2,6 +2,7 @@
using FruitBank.Common.Models; using FruitBank.Common.Models;
using Mango.Nop.Core.Dtos; using Mango.Nop.Core.Dtos;
using Mango.Nop.Core.Models; using Mango.Nop.Core.Models;
using Nop.Core.Domain.Customers;
namespace FruitBank.Common.Interfaces; namespace FruitBank.Common.Interfaces;
@ -38,6 +39,7 @@ public interface IFruitBankDataControllerCommon
#region Customer #region Customer
public Task<List<CustomerDto>?> GetMeasuringUsers(); public Task<List<CustomerDto>?> GetMeasuringUsers();
public Task<List<CustomerRole>?> GetCustomerRolesByCustomerId(int customerId);
#endregion Customer #endregion Customer
#region Product #region Product

View File

@ -0,0 +1,9 @@
namespace FruitBank.Common.Interfaces;
public interface IMeasuringAttributeValues
{
double? NetWeight { get; set; }
double? GrossWeight { get; set; }
bool? IsMeasurable { get; set; }
}

View File

@ -10,6 +10,7 @@ public interface IShipping : IEntityInt, ITimeStampInfo
DateTime ShippingDate { get; set; } DateTime ShippingDate { get; set; }
string LicencePlate { get; set; } string LicencePlate { get; set; }
bool IsAllMeasured { get; set; } bool IsAllMeasured { get; set; }
DateTime? MeasuredDate { get; set; }
public List<ShippingDocument>? ShippingDocuments { get; set; } public List<ShippingDocument>? ShippingDocuments { get; set; }
} }

View File

@ -0,0 +1,27 @@
namespace FruitBank.Common.Interfaces;
public class MeasuringAttributeValues : IMeasuringAttributeValues
{
public double? NetWeight { get; set; }
public double? GrossWeight { get; set; }
public bool? IsMeasurable { get; set; }
public MeasuringAttributeValues()
{
}
public MeasuringAttributeValues(double? netWeight, double? grossWeight, bool? isMeasurable)
{
Initialize(netWeight, grossWeight, isMeasurable);
}
public void Initialize(double? netWeight, double? grossWeight, bool? isMeasurable)
{
NetWeight = netWeight;
GrossWeight = grossWeight;
IsMeasurable = isMeasurable;
}
public bool HasValues()
=> NetWeight != null && GrossWeight != null && IsMeasurable != null;
}

View File

@ -0,0 +1,46 @@
using AyCode.Core;
using Mango.Nop.Core.Dtos;
using Mango.Nop.Core.Models;
using Nop.Core.Domain.Customers;
namespace FruitBank.Common.Models;
public class LoggedInModel
{
public bool IsLoggedIn => CustomerDto != null;
public CustomerDto? CustomerDto { get; private set; }
public List<CustomerRole> CustomerRoles { get; private set; } = [];
public LoggedInModel()
{
}
public LoggedInModel(CustomerDto? customerDto)
{
InitLoggedInCustomer(customerDto);
}
public LoggedInModel(MgLoginModelResponse loginModelResponse) : this(loginModelResponse.CustomerDto)
{
}
public void InitLoggedInCustomer(CustomerDto? customerDto)
{
LogOut();
if (customerDto != null) CustomerDto = customerDto;
}
public void InitCustomerRoles(List<CustomerRole> customerRoles)
{
CustomerRoles.Clear();
CustomerRoles.AddRange(customerRoles);
}
public void LogOut()
{
CustomerDto = null;
CustomerRoles.Clear();
}
}

View File

@ -33,6 +33,7 @@ public class SignalRTags : AcSignalRTags
public const int GetMeasuringUsers = 70; public const int GetMeasuringUsers = 70;
public const int GetCustomerDtoById = 71; public const int GetCustomerDtoById = 71;
public const int GetCustomerRolesByCustomerId = 72;
public const int GetProductDtos = 80; public const int GetProductDtos = 80;
public const int GetProductDtoById = 81; public const int GetProductDtoById = 81;

View File

@ -6,12 +6,15 @@ using FruitBank.Common.Interfaces;
using FruitBank.Common.Loggers; using FruitBank.Common.Loggers;
using FruitBankHybrid.Shared.Services.SignalRs; using FruitBankHybrid.Shared.Services.SignalRs;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices.JavaScript;
using FruitBank.Common;
namespace FruitBankHybrid.Shared.Tests namespace FruitBankHybrid.Shared.Tests
{ {
[TestClass] [TestClass]
public sealed class FruitBankClientTests public sealed class FruitBankClientTests
{ {
private const int CustomerIdAasdDsserverCom = 6;//aasd@dsserver.com
private const string Fixture = "_test.temp"; private const string Fixture = "_test.temp";
private FruitBankSignalRClient _signalRClient = null!; private FruitBankSignalRClient _signalRClient = null!;
@ -88,7 +91,8 @@ namespace FruitBankHybrid.Shared.Tests
var shippings = await _signalRClient.GetNotMeasuredShippings(); var shippings = await _signalRClient.GetNotMeasuredShippings();
Assert.IsNotNull(shippings); Assert.IsNotNull(shippings);
Assert.IsTrue(shippings.All(s => !s.IsAllMeasured)); var ShippingMeasuredDateAddDay = 1000; //dfd
Assert.IsTrue(shippings.All(s => !s.IsAllMeasured || s.MeasuredDate != null || s.MeasuredDate < DateTime.Now.AddDays(ShippingMeasuredDateAddDay)));
} }
//[TestMethod] //[TestMethod]
@ -159,7 +163,9 @@ namespace FruitBankHybrid.Shared.Tests
[DataTestMethod] [DataTestMethod]
[DataRow(1)] [DataRow(1)]
//[DataRow(2)] [DataRow(2)]
//[DataRow(3)]
//[DataRow(4)]
public async Task UpdateShippingItemTest(int shippingItemId) public async Task UpdateShippingItemTest(int shippingItemId)
{ {
var originalShippingItem = await GetShippingItemByIdTest(shippingItemId); var originalShippingItem = await GetShippingItemByIdTest(shippingItemId);
@ -249,6 +255,17 @@ namespace FruitBankHybrid.Shared.Tests
Assert.IsTrue(users.All(x => !x.Email.IsNullOrEmpty() && !x.Deleted)); Assert.IsTrue(users.All(x => !x.Email.IsNullOrEmpty() && !x.Deleted));
} }
[TestMethod]
[DataRow(CustomerIdAasdDsserverCom)]
public async Task GetCustomerRolesByCustomerIdTest(int customerId)
{
var customerRoles = await _signalRClient.GetCustomerRolesByCustomerId(customerId);
Assert.IsNotNull(customerRoles);
Assert.IsTrue(customerRoles.Count > 0);
Assert.IsTrue(customerRoles.Any(cr => cr.SystemName == "Measuring"));
}
#endregion Customer #endregion Customer
#region Product #region Product
@ -265,6 +282,7 @@ namespace FruitBankHybrid.Shared.Tests
#endregion Product #endregion Product
#region Login
[TestMethod] [TestMethod]
[DataRow("aasd@dsserver.com", "Asdasd123456")] [DataRow("aasd@dsserver.com", "Asdasd123456")]
public async Task LoginMeasuringUserTest_TrueIfHasCustomerDto(string email, string password) public async Task LoginMeasuringUserTest_TrueIfHasCustomerDto(string email, string password)
@ -289,5 +307,6 @@ namespace FruitBankHybrid.Shared.Tests
Assert.IsFalse(loginModelResponse.ErrorMessage.IsNullOrWhiteSpace()); Assert.IsFalse(loginModelResponse.ErrorMessage.IsNullOrWhiteSpace());
Console.WriteLine($"Succes: {loginModelResponse.ErrorMessage}"); Console.WriteLine($"Succes: {loginModelResponse.ErrorMessage}");
} }
#endregion Login
} }
} }

View File

@ -11,7 +11,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DevExpress.Blazor" Version="25.1.*" /> <PackageReference Include="DevExpress.Blazor" Version="25.1.3" />
<PackageReference Include="MessagePack" Version="3.1.4" /> <PackageReference Include="MessagePack" Version="3.1.4" />
<PackageReference Include="MessagePack.Annotations" Version="3.1.4" /> <PackageReference Include="MessagePack.Annotations" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.9" /> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.9" />
@ -46,19 +46,19 @@
<HintPath>..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll</HintPath> <HintPath>..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Blazor.Resources.v25.1"> <Reference Include="DevExpress.Blazor.Resources.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.Resources.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Blazor.v25.1"> <Reference Include="DevExpress.Blazor.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Blazor.v25.1.Viewer"> <Reference Include="DevExpress.Blazor.v25.1.Viewer">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.v25.1.Viewer.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Data.v25.1"> <Reference Include="DevExpress.Data.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Data.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Utils.v25.1"> <Reference Include="DevExpress.Utils.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Utils.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="Mango.Nop.Core"> <Reference Include="Mango.Nop.Core">
<HintPath>..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll</HintPath> <HintPath>..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll</HintPath>

View File

@ -1,23 +1,30 @@
@inherits LayoutComponentBase @using FruitBank.Common.Models
@inherits LayoutComponentBase
<div class="page"> <div class="page">
<div class="sidebar"> <div class="sidebar">
<NavMenu /> <NavMenu @ref="_navMenu" />
</div> </div>
<main> <main>
<div class="top-row px-4"> <div class="top-row px-4">
<a href="">Kijelentkezés</a> @if (LoggedInModel.IsLoggedIn)
</div> {
<DxButton Text="Kijelentkezés" Click="OnLogoutClick" />
@* <a href="" on>Kijelentkezés</a> *@
}
</div>
<article class="content px-4"> <article class="content px-4">
@Body <CascadingValue Value="RefreshMainLayoutEventCallback">
</article> @Body
</main> </CascadingValue>
</article>
</main>
</div> </div>
<div id="blazor-error-ui" data-nosnippet> <div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred. An unhandled error has occurred.
<a href="." class="reload">Reload</a> <a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span> <span class="dismiss">🗙</span>
</div> </div>

View File

@ -0,0 +1,25 @@
using FruitBank.Common.Models;
using Microsoft.AspNetCore.Components;
namespace FruitBankHybrid.Shared.Layout;
public partial class MainLayout : LayoutComponentBase
{
[Inject] public required LoggedInModel LoggedInModel { get; set; }
private EventCallback RefreshMainLayoutEventCallback => EventCallback.Factory.Create(this, RefreshMainLayout);
private NavMenu _navMenu = null!;
private void OnLogoutClick()
{
LoggedInModel.LogOut();
RefreshMainLayout();
}
public void RefreshMainLayout()
{
_navMenu.RefreshNavMenu();
StateHasChanged();
}
}

View File

@ -1,4 +1,8 @@
<div class="top-row ps-3 navbar navbar-dark"> @using AyCode.Core
@using FruitBank.Common.Models
@inject LoggedInModel LoggedInModel
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="">FruitBank Measuring</a> <a class="navbar-brand" href="">FruitBank Measuring</a>
</div> </div>
@ -8,21 +12,25 @@
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()"> <div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
<nav class="flex-column"> <nav class="flex-column">
<div class="nav-item px-3"> @if (LoggedInModel.IsLoggedIn)// || AcDomain.IsDeveloperVersion)
<NavLink class="nav-link" href="" Match="NavLinkMatch.All"> {
<span class="icon home-icon" aria-hidden="true"></span> Kezdőlap <div class="nav-item px-3">
</NavLink> <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
</div> <span class="icon home-icon" aria-hidden="true"></span> Kezdőlap
<div class="nav-item px-3"> </NavLink>
<NavLink class="nav-link" href="MeasuringIn"> </div>
<span class="icon counter-icon" aria-hidden="true"></span> Bejövő mérés <div class="nav-item px-3">
</NavLink> <NavLink class="nav-link" href="MeasuringIn">
</div> <span class="icon counter-icon" aria-hidden="true"></span> Bejövő mérés
<div class="nav-item px-3"> </NavLink>
<NavLink class="nav-link" href="MeasuringOut"> </div>
<span class="icon counter-icon" aria-hidden="true"></span> Kimenő mérés <div class="nav-item px-3">
</NavLink> <NavLink class="nav-link" href="MeasuringOut">
</div> <span class="icon counter-icon" aria-hidden="true"></span> Kimenő mérés
</NavLink>
</div>
}
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="Login"> <NavLink class="nav-link" href="Login">
<span class="icon weather-icon" aria-hidden="true"></span> Bejelentkezés <span class="icon weather-icon" aria-hidden="true"></span> Bejelentkezés
@ -32,3 +40,10 @@
</nav> </nav>
</div> </div>
@code
{
public void RefreshNavMenu()
{
StateHasChanged();
}
}

View File

@ -1,30 +0,0 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">FruitBankHybrid</a>
</div>
</div>
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
<nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="icon home-icon" aria-hidden="true"></span> Home
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="icon counter-icon" aria-hidden="true"></span> Counter
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="weather">
<span class="icon weather-icon" aria-hidden="true"></span> Weather
</NavLink>
</div>
</nav>
</div>

View File

@ -1,9 +1,12 @@
using Microsoft.AspNetCore.Components; using FruitBank.Common.Models;
using Microsoft.AspNetCore.Components;
namespace FruitBankHybrid.Shared.Pages; namespace FruitBankHybrid.Shared.Pages;
public partial class Home : ComponentBase public partial class Home : ComponentBase
{ {
[Inject] public required LoggedInModel LoggedInModel { get; set; }
private string Factor => FormFactor.GetFormFactor(); private string Factor => FormFactor.GetFormFactor();
private string Platform => FormFactor.GetPlatform(); private string Platform => FormFactor.GetPlatform();

View File

@ -3,46 +3,50 @@
<h3>Bejelentkezés</h3> <h3>Bejelentkezés</h3>
<DxFormLayout CaptionPosition="CaptionPosition.Vertical" CssClass="w-500">
<DxFormLayoutItem Caption="Válasszon felhasználót:" ColSpanMd="6"> @if (!LoggedInModel.IsLoggedIn)
<DxComboBox Data="@Users" {
@bind-Value="@SelectedUser" <DxFormLayout CaptionPosition="CaptionPosition.Vertical" CssClass="w-500">
Text="Select Employee" <DxFormLayoutItem Caption="Válasszon felhasználót:" ColSpanMd="6">
ValueFieldName="@nameof(CustomerDto.Id)" <DxComboBox Data="@Users"
TextFieldName="@nameof(CustomerDto.FullName)" @bind-Value="@SelectedUser"
CssClass="cw-320" Text="Select Employee"
InputId="cbItemTemplate"> ValueFieldName="@nameof(CustomerDto.Id)"
<ItemDisplayTemplate Context="ctxCombo"> TextFieldName="@nameof(CustomerDto.FullName)"
<div class="combobox-item-template"> CssClass="cw-320"
<img src="@GetImageFileName(ctxCombo.DataItem)" alt="@ctxCombo.DataItem.Email" /> InputId="cbItemTemplate">
<div class="combobox-item-template-text"> <ItemDisplayTemplate Context="ctxCombo">
<span>@ctxCombo.DataItem.FullName</span> <div class="combobox-item-template">
<span class="combobox-item-template-employee-phone">@ctxCombo.DataItem.Email</span> <img src="@GetImageFileName(ctxCombo.DataItem)" alt="@ctxCombo.DataItem.Email" />
<div class="combobox-item-template-text">
<span>@ctxCombo.DataItem.FullName</span>
<span class="combobox-item-template-employee-phone">@ctxCombo.DataItem.Email</span>
</div>
</div> </div>
</div> </ItemDisplayTemplate>
</ItemDisplayTemplate> </DxComboBox>
</DxComboBox> </DxFormLayoutItem>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Adja meg a jelszavát:" ColSpanMd="6"> <DxFormLayoutItem Caption="Adja meg a jelszavát:" ColSpanMd="6">
<DxTextBox @bind-Text="@PasswordValue" <DxTextBox @bind-Text="@PasswordValue"
@onkeydown="OnPasswordKeyDown" @onkeydown="OnPasswordKeyDown"
Password="true" Password="true"
CssClass="cw-320" CssClass="cw-320"
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto" ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto"
BindValueMode="BindValueMode.OnInput" BindValueMode="BindValueMode.OnInput"
NullText="Enter password" NullText="Enter password"
InputId="tbPassword" /> InputId="tbPassword" />
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="12" BeginRow="true"> <DxFormLayoutItem ColSpanMd="12" BeginRow="true">
<DxButton Text="Bejelentkezés" Click="OnLoginClick" CssClass="w-100" /> <DxButton Text="Bejelentkezés" Click="OnLoginClick" CssClass="w-100" />
</DxFormLayoutItem> </DxFormLayoutItem>
</DxFormLayout> </DxFormLayout>
}
<div class="row w-100" style="margin-top: 30px;"> <div class="row w-100" style="margin-top: 30px;">
<div class="col-md-12"> <div class="col-md-12">
<b>@(LoginModelResponse?.CustomerDto == null ? LoginModelResponse?.ErrorMessage : LoginModelResponse?.CustomerDto.FullName)</b> <b>@(LoggedInModel.CustomerDto == null ? LoginModelResponse?.ErrorMessage : LoggedInModel.CustomerDto.FullName + $" [{_rolesText}]")</b>
</div> </div>
</div> </div>

View File

@ -3,6 +3,7 @@ using AyCode.Core.Loggers;
using AyCode.Interfaces.Users; using AyCode.Interfaces.Users;
using AyCode.Utils.Extensions; using AyCode.Utils.Extensions;
using FruitBank.Common.Loggers; using FruitBank.Common.Loggers;
using FruitBank.Common.Models;
using FruitBankHybrid.Shared.Services.Loggers; using FruitBankHybrid.Shared.Services.Loggers;
using FruitBankHybrid.Shared.Services.SignalRs; using FruitBankHybrid.Shared.Services.SignalRs;
using Mango.Nop.Core.Dtos; using Mango.Nop.Core.Dtos;
@ -17,6 +18,7 @@ public partial class Login : ComponentBase
{ {
[Inject] public required IEnumerable<IAcLogWriterClientBase> LogWriters { get; set; } [Inject] public required IEnumerable<IAcLogWriterClientBase> LogWriters { get; set; }
[Inject] public required FruitBankSignalRClient FruitBankSignalRClient { get; set; } [Inject] public required FruitBankSignalRClient FruitBankSignalRClient { get; set; }
[Inject] public required LoggedInModel LoggedInModel { get; set; }
private ILogger _logger = null!; private ILogger _logger = null!;
private List<CustomerDto> Users { get; set; } private List<CustomerDto> Users { get; set; }
@ -24,20 +26,31 @@ public partial class Login : ComponentBase
private string PasswordValue { get; set; } = string.Empty; private string PasswordValue { get; set; } = string.Empty;
private MgLoginModelResponse? LoginModelResponse { get; set; } private MgLoginModelResponse? LoginModelResponse { get; set; }
[CascadingParameter]
public EventCallback UpdateStyle { get; set; }
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_logger = new LoggerClient<Login>(LogWriters.ToArray()); _logger = new LoggerClient<Login>(LogWriters.ToArray());
_logger.Info("OnInitializedAsync"); _logger.Info("OnInitializedAsync");
Users = await FruitBankSignalRClient.GetMeasuringUsers() ?? []; if (!LoggedInModel.IsLoggedIn)
SelectedUser = Users.FirstOrDefault(); {
Users = await FruitBankSignalRClient.GetMeasuringUsers() ?? [];
SelectedUser = Users.FirstOrDefault();
}
else _rolesText = string.Join("; ", LoggedInModel.CustomerRoles.Select(x => x.Name));
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
private string _rolesText = string.Empty;
private async Task OnLoginClick() private async Task OnLoginClick()
{ {
if (LoggedInModel.IsLoggedIn) return;
_rolesText = string.Empty;
if (SelectedUser == null || PasswordValue.IsNullOrWhiteSpace()) if (SelectedUser == null || PasswordValue.IsNullOrWhiteSpace())
{ {
LoginModelResponse = new MgLoginModelResponse LoginModelResponse = new MgLoginModelResponse
@ -49,11 +62,27 @@ public partial class Login : ComponentBase
} }
LoginModelResponse = await FruitBankSignalRClient.LoginMeasuringUser(SelectedUser.Email, PasswordValue); LoginModelResponse = await FruitBankSignalRClient.LoginMeasuringUser(SelectedUser.Email, PasswordValue);
if (LoginModelResponse is { IsSuccesLogin: true })
{
LoggedInModel.InitLoggedInCustomer(LoginModelResponse.CustomerDto);
var customerRoles = await FruitBankSignalRClient.GetCustomerRolesByCustomerId(LoginModelResponse.CustomerDto!.Id);
if (customerRoles != null)
{
LoggedInModel.InitCustomerRoles(customerRoles);
_rolesText = string.Join("; ", LoggedInModel.CustomerRoles.Select(x => x.Name));
}
}
await UpdateStyle.InvokeAsync();
StateHasChanged();
} }
protected async Task OnPasswordKeyDown(KeyboardEventArgs e) protected async Task OnPasswordKeyDown(KeyboardEventArgs e)
{ {
if (e.Key == "Enter") await OnLoginClick(); if (!LoggedInModel.IsLoggedIn && e.Key == "Enter") await OnLoginClick();
} }
private string GetImageFileName(CustomerDto employee) private string GetImageFileName(CustomerDto employee)

View File

@ -103,14 +103,14 @@
@* <DataAnnotationsValidator /> *@ @* <DataAnnotationsValidator /> *@
<DxFormLayout Data="@SelectedShippingItem" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating(pair.Key, pair.Value))"> <DxFormLayout Data="@SelectedShippingItem" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating(pair.Key, pair.Value))">
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.Name)" Caption="Item Name:" Enabled="false" ColSpanMd="6" /> <DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.Name)" Caption="Item Name:" Enabled="false" ColSpanMd="6" />
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.GrossWeight)" Caption="GrossWeight:" Enabled="false" ColSpanMd="3" /> <DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.GrossWeight)" Caption="GrossWeight:" Enabled="false" ColSpanMd="3" />
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.NetWeight)" Caption="NetWeight:" Enabled="false" ColSpanMd="3" /> <DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.NetWeight)" Caption="NetWeight:" Enabled="false" ColSpanMd="3" />
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" <DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
Field="@nameof(ShippingItem.MeasuredQuantity)" Field="@nameof(ShippingItem.MeasuredQuantity)"
Caption="MeasuredQuantity:" Caption="MeasuredQuantity:"
ColSpanMd="2" ColSpanMd="2"
BeginRow="true"> BeginRow="false">
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" <DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
@ -127,7 +127,7 @@
ColSpanMd="2"> ColSpanMd="2">
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" <DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
Field="@nameof(ShippingItem.IsMeasured)" Field="@nameof(ShippingItem.IsMeasured)"
Enabled="false" Caption="Sikeres mérés:" ColSpanMd="6"> Enabled="false" Caption="Sikeres mérés:" ColSpanMd="6">
</DxFormLayoutItem> </DxFormLayoutItem>

View File

@ -26,6 +26,7 @@ namespace FruitBankHybrid.Shared.Pages
{ {
[Inject] public required IEnumerable<IAcLogWriterClientBase> LogWriters { get; set; } [Inject] public required IEnumerable<IAcLogWriterClientBase> LogWriters { get; set; }
[Inject] public required FruitBankSignalRClient FruitBankSignalRClient { get; set; } [Inject] public required FruitBankSignalRClient FruitBankSignalRClient { get; set; }
[Inject] public required LoggedInModel LoggedInModel { get; set; }
private ILogger _logger = null!; private ILogger _logger = null!;
@ -54,14 +55,11 @@ namespace FruitBankHybrid.Shared.Pages
private async Task RefreshShippingsFromDb(DateTime dateTime) private async Task RefreshShippingsFromDb(DateTime dateTime)
{ {
var shippings = await FruitBankSignalRClient.GetShippings() ?? []; var shippings = await FruitBankSignalRClient.GetNotMeasuredShippings() ?? [];
_shippingDates = shippings.Select(shipping => new ShippingDateModel(shipping.Id, shipping.ShippingDate.Date, shipping.IsAllMeasured)).ToList(); _shippingDates = shippings.Select(shipping => new ShippingDateModel(shipping.Id, shipping.ShippingDate.Date, shipping.IsAllMeasured)).ToList();
NotMeasuredShippings = shippings.Where(shipping => DaysEqual(shipping.ShippingDate.Date, dateTime)).ToList(); NotMeasuredShippings = shippings.Where(shipping => DaysEqual(shipping.ShippingDate.Date, dateTime)).ToList();
//if (getAllShipping) NotMeasuredShippings = await FruitBankSignalRClient.GetShippings() ?? [];
//else NotMeasuredShippings = await FruitBankSignalRClient.GetNotMeasuredShippings() ?? [];
SelectedShipping = NotMeasuredShippings.FirstOrDefault(); SelectedShipping = NotMeasuredShippings.FirstOrDefault();
} }
@ -124,6 +122,7 @@ namespace FruitBankHybrid.Shared.Pages
SelectedShippingItem.MeasuredQuantity = shippingItemFromDb.MeasuredQuantity; SelectedShippingItem.MeasuredQuantity = shippingItemFromDb.MeasuredQuantity;
SelectedShippingItem.MeasuredNetWeight = shippingItemFromDb.MeasuredNetWeight; SelectedShippingItem.MeasuredNetWeight = shippingItemFromDb.MeasuredNetWeight;
SelectedShippingItem.MeasuredGrossWeight = shippingItemFromDb.MeasuredGrossWeight; SelectedShippingItem.MeasuredGrossWeight = shippingItemFromDb.MeasuredGrossWeight;
//SelectedShippingItem.IsMeasurable = shippingItemFromDb.IsMeasurable;
SelectedShippingItem.IsMeasured = shippingItemFromDb.IsMeasured; SelectedShippingItem.IsMeasured = shippingItemFromDb.IsMeasured;
if (SelectedShippingDocument != null) if (SelectedShippingDocument != null)

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components; using FruitBank.Common.Models;
using Microsoft.AspNetCore.Components;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -9,5 +10,6 @@ namespace FruitBankHybrid.Shared.Pages
{ {
public partial class MeasuringOut : ComponentBase public partial class MeasuringOut : ComponentBase
{ {
[Inject] public required LoggedInModel LoggedInModel { get; set; }
} }
} }

View File

@ -10,6 +10,7 @@ using FruitBank.Common.SignalRs;
using FruitBankHybrid.Shared.Services.Loggers; using FruitBankHybrid.Shared.Services.Loggers;
using Mango.Nop.Core.Dtos; using Mango.Nop.Core.Dtos;
using Mango.Nop.Core.Models; using Mango.Nop.Core.Models;
using Nop.Core.Domain.Customers;
namespace FruitBankHybrid.Shared.Services.SignalRs namespace FruitBankHybrid.Shared.Services.SignalRs
{ {
@ -94,7 +95,9 @@ namespace FruitBankHybrid.Shared.Services.SignalRs
public Task<List<CustomerDto>?> GetMeasuringUsers() public Task<List<CustomerDto>?> GetMeasuringUsers()
=> GetAllAsync<List<CustomerDto>>(SignalRTags.GetMeasuringUsers); => GetAllAsync<List<CustomerDto>>(SignalRTags.GetMeasuringUsers);
public Task<List<CustomerRole>?> GetCustomerRolesByCustomerId(int customerId)
=> GetAllAsync<List<CustomerRole>>(SignalRTags.GetCustomerRolesByCustomerId, [customerId]);
#endregion Customer #endregion Customer
#region Product #region Product

View File

@ -40,19 +40,19 @@
<HintPath>..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll</HintPath> <HintPath>..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Blazor.Resources.v25.1"> <Reference Include="DevExpress.Blazor.Resources.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.Resources.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Blazor.v25.1"> <Reference Include="DevExpress.Blazor.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Blazor.v25.1.Viewer"> <Reference Include="DevExpress.Blazor.v25.1.Viewer">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.v25.1.Viewer.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Data.v25.1"> <Reference Include="DevExpress.Data.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Data.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Utils.v25.1"> <Reference Include="DevExpress.Utils.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Utils.v25.1.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>

View File

@ -1,5 +1,6 @@
using AyCode.Core.Loggers; using AyCode.Core.Loggers;
using FruitBank.Common.Loggers; using FruitBank.Common.Loggers;
using FruitBank.Common.Models;
using FruitBankHybrid.Shared.Services; using FruitBankHybrid.Shared.Services;
using FruitBankHybrid.Shared.Services.SignalRs; using FruitBankHybrid.Shared.Services.SignalRs;
using FruitBankHybrid.Web.Client.Services; using FruitBankHybrid.Web.Client.Services;
@ -14,6 +15,7 @@ builder.Services.AddDevExpressBlazor(configure => configure.SizeMode = DevExpres
builder.Services.AddSingleton<IFormFactor, FormFactor>(); builder.Services.AddSingleton<IFormFactor, FormFactor>();
//builder.Services.AddScoped<ISignalRService, SignalRService>(); //builder.Services.AddScoped<ISignalRService, SignalRService>();
builder.Services.AddSingleton<LoggedInModel>();
builder.Services.AddScoped<FruitBankSignalRClient>(); builder.Services.AddScoped<FruitBankSignalRClient>();
#if DEBUG #if DEBUG

View File

@ -14,7 +14,7 @@
<ProjectReference Include="..\FruitBankHybrid.Shared\FruitBankHybrid.Shared.csproj" /> <ProjectReference Include="..\FruitBankHybrid.Shared\FruitBankHybrid.Shared.csproj" />
<ProjectReference Include="..\FruitBankHybrid.Web.Client\FruitBankHybrid.Web.Client.csproj" /> <ProjectReference Include="..\FruitBankHybrid.Web.Client\FruitBankHybrid.Web.Client.csproj" />
<PackageReference Include="DevExpress.Blazor" Version="25.1.*" /> <PackageReference Include="DevExpress.Blazor" Version="25.1.3" />
<PackageReference Include="MessagePack" Version="3.1.4" /> <PackageReference Include="MessagePack" Version="3.1.4" />
<PackageReference Include="MessagePack.Annotations" Version="3.1.4" /> <PackageReference Include="MessagePack.Annotations" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.9" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.9" />
@ -57,19 +57,19 @@
<HintPath>..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll</HintPath> <HintPath>..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Blazor.Resources.v25.1"> <Reference Include="DevExpress.Blazor.Resources.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.Resources.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Blazor.v25.1"> <Reference Include="DevExpress.Blazor.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Blazor.v25.1.Viewer"> <Reference Include="DevExpress.Blazor.v25.1.Viewer">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.v25.1.Viewer.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Data.v25.1"> <Reference Include="DevExpress.Data.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Data.v25.1.dll</HintPath>
</Reference> </Reference>
<Reference Include="DevExpress.Utils.v25.1"> <Reference Include="DevExpress.Utils.v25.1">
<HintPath>C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Utils.v25.1.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>

View File

@ -1,5 +1,6 @@
using AyCode.Core.Loggers; using AyCode.Core.Loggers;
using FruitBank.Common; using FruitBank.Common;
using FruitBank.Common.Models;
using FruitBank.Common.Server.Services.Loggers; using FruitBank.Common.Server.Services.Loggers;
using FruitBank.Common.Server.Services.SignalRs; using FruitBank.Common.Server.Services.SignalRs;
using FruitBankHybrid.Shared.Services; using FruitBankHybrid.Shared.Services;
@ -14,8 +15,9 @@ builder.Services.AddMvc();
builder.Services.AddSingleton<IFormFactor, FormFactor>(); builder.Services.AddSingleton<IFormFactor, FormFactor>();
builder.Services.AddSingleton<LoggerToLoggerApiController>(); builder.Services.AddScoped<LoggedInModel>();
builder.Services.AddSingleton<IAcLogWriterBase, ConsoleLogWriter>(); builder.Services.AddScoped<LoggerToLoggerApiController>();
builder.Services.AddScoped<IAcLogWriterBase, ConsoleLogWriter>();
//builder.Services.AddSingleton<SessionService>(); //builder.Services.AddSingleton<SessionService>();
//builder.Services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>(); //builder.Services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();

View File

@ -1,11 +1,12 @@
using FruitBankHybrid.Services; using AyCode.Core.Loggers;
using FruitBank.Common.Loggers;
using FruitBank.Common.Models;
using FruitBankHybrid.Services;
using FruitBankHybrid.Services.Loggers;
using FruitBankHybrid.Shared.Services; using FruitBankHybrid.Shared.Services;
using FruitBankHybrid.Shared.Services.SignalRs;
//using DevExpress.Maui; //using DevExpress.Maui;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using FruitBankHybrid.Shared.Services.SignalRs;
using FruitBank.Common.Loggers;
using AyCode.Core.Loggers;
using FruitBankHybrid.Services.Loggers;
namespace FruitBankHybrid namespace FruitBankHybrid
{ {
@ -24,18 +25,20 @@ namespace FruitBankHybrid
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
}); });
// Add device-specific services used by the FruitBankHybrid.Shared project // Add device-specific services used by the FruitBankHybrid.Shared project
builder.Services.AddSingleton<IFormFactor, FormFactor>(); builder.Services.AddSingleton<IFormFactor, FormFactor>();
//builder.Services.AddScoped<ISignalRService, SignalRService>();
builder.Services.AddScoped<FruitBankSignalRClient>(); builder.Services.AddSingleton<LoggedInModel>();
//builder.Services.AddScoped<ISignalRService, SignalRService>();
builder.Services.AddScoped<FruitBankSignalRClient>();
#if DEBUG #if DEBUG
builder.Services.AddSingleton<IAcLogWriterClientBase, BrowserConsoleLogWriter>(); builder.Services.AddSingleton<IAcLogWriterClientBase, BrowserConsoleLogWriter>();
#endif #endif
builder.Services.AddSingleton<IAcLogWriterClientBase, SignaRClientLogItemWriter>(); builder.Services.AddSingleton<IAcLogWriterClientBase, SignaRClientLogItemWriter>();
builder.Services.AddMauiBlazorWebView(); builder.Services.AddMauiBlazorWebView();