diff --git a/FruitBank.Common.Server/FruitBank.Common.Server.csproj b/FruitBank.Common.Server/FruitBank.Common.Server.csproj index a4a0331..1ed463b 100644 --- a/FruitBank.Common.Server/FruitBank.Common.Server.csproj +++ b/FruitBank.Common.Server/FruitBank.Common.Server.csproj @@ -10,11 +10,11 @@ - - - + + + - + @@ -39,7 +39,7 @@ ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll - C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\9.0.10\ref\net9.0\Microsoft.AspNetCore.SignalR.Core.dll + C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\9.0.11\ref\net9.0\Microsoft.AspNetCore.SignalR.Core.dll ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll diff --git a/FruitBank.Common.Server/Interfaces/IStockSignalREndpointServer.cs b/FruitBank.Common.Server/Interfaces/IStockSignalREndpointServer.cs new file mode 100644 index 0000000..7e5dd75 --- /dev/null +++ b/FruitBank.Common.Server/Interfaces/IStockSignalREndpointServer.cs @@ -0,0 +1,8 @@ +using FruitBank.Common.Interfaces; + +namespace FruitBank.Common.Server.Interfaces; + +public interface IStockSignalREndpointServer : IStockSignalREndpointCommon +{ + +} \ No newline at end of file diff --git a/FruitBank.Common.Server/Services/SignalRs/DevAdminSignalRhub.cs b/FruitBank.Common.Server/Services/SignalRs/DevAdminSignalRhub.cs index 1578a21..22136b0 100644 --- a/FruitBank.Common.Server/Services/SignalRs/DevAdminSignalRhub.cs +++ b/FruitBank.Common.Server/Services/SignalRs/DevAdminSignalRhub.cs @@ -29,11 +29,12 @@ namespace FruitBank.Common.Server.Services.SignalRs; public class DevAdminSignalRHub : AcWebSignalRHubWithSessionBase> { public DevAdminSignalRHub(IConfiguration configuration, IFruitBankDataControllerServer fruitBankDataController/*, SessionService sessionService*/, - ICustomOrderSignalREndpointServer customOrderSignalREndpoint, IEnumerable logWriters) + ICustomOrderSignalREndpointServer customOrderSignalREndpoint, IStockSignalREndpointServer stockSignalREndpointServer, IEnumerable logWriters) : base(configuration, new Logger(logWriters.ToArray())) { DynamicMethodCallModels.Add(new AcDynamicMethodCallModel(fruitBankDataController)); DynamicMethodCallModels.Add(new AcDynamicMethodCallModel(customOrderSignalREndpoint)); + DynamicMethodCallModels.Add(new AcDynamicMethodCallModel(stockSignalREndpointServer)); } protected override void LogContextUserNameAndId() diff --git a/FruitBank.Common/Entities/StockTaking.cs b/FruitBank.Common/Entities/StockTaking.cs new file mode 100644 index 0000000..33376c4 --- /dev/null +++ b/FruitBank.Common/Entities/StockTaking.cs @@ -0,0 +1,11 @@ +using LinqToDB.Mapping; +using Mango.Nop.Core.Entities; + +namespace FruitBank.Common.Entities; + +[Table(Name = FruitBankConstClient.StockTakingDbTableName)] +[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.StockTakingDbTableName)] +public class StockTaking : MgStockTaking +{ + +} \ No newline at end of file diff --git a/FruitBank.Common/Entities/StockTakingItem.cs b/FruitBank.Common/Entities/StockTakingItem.cs new file mode 100644 index 0000000..9c002a2 --- /dev/null +++ b/FruitBank.Common/Entities/StockTakingItem.cs @@ -0,0 +1,32 @@ +using FruitBank.Common.Dtos; +using LinqToDB; +using LinqToDB.Mapping; +using Mango.Nop.Core.Entities; + +namespace FruitBank.Common.Entities; + +[Table(Name = FruitBankConstClient.StockTakingItemDbTableName)] +[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.StockTakingItemDbTableName)] +public class StockTakingItem : MgStockTakingItem +{ + [Column(DataType = DataType.DecFloat, CanBeNull = false)] + public double OriginalNetWeight { get; set; } + + [Column(DataType = DataType.DecFloat, CanBeNull = false)] + public double MeasuredNetWeight { get; set; } + + [Association(ThisKey = nameof(Id), OtherKey = nameof(StockTakingItemPallet.StockTakingItemId), CanBeNull = true)] + public List? StockTakingItemPallets { get; set; } + + public bool IsRequiredForMeasuring => OriginalStockQuantity != 0 || OriginalNetWeight != 0; + + public string DisplayText + { + get + { + if (IsMeasured) return $"[KÉSZ] {Product!.Name}"; + + return IsRequiredForMeasuring ? $"[KÖT] {Product!.Name}" : $"{Product!.Name}"; + } + } +} \ No newline at end of file diff --git a/FruitBank.Common/Entities/StockTakingItemPallet.cs b/FruitBank.Common/Entities/StockTakingItemPallet.cs new file mode 100644 index 0000000..9fbc832 --- /dev/null +++ b/FruitBank.Common/Entities/StockTakingItemPallet.cs @@ -0,0 +1,43 @@ +using FruitBank.Common.Dtos; +using FruitBank.Common.Interfaces; +using LinqToDB.Mapping; +using Mango.Nop.Core.Entities; + +namespace FruitBank.Common.Entities; + +public interface IStockTakingItemPallet : IMeasuringItemPalletBase +{ + int StockTakingItemId { get; set; } + public StockTakingItem? StockTakingItem{ get; set; } +} + +[Table(Name = FruitBankConstClient.StockTakingItemPalletDbTableName)] +[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.StockTakingItemPalletDbTableName)] +public class StockTakingItemPallet : MeasuringItemPalletBase, IStockTakingItemPallet +{ + public int StockTakingItemId + { + get => ForeignItemId; + set => ForeignItemId = value; + } + + [Association(ThisKey = nameof(StockTakingItemId), OtherKey = nameof(StockTakingItem.Id), CanBeNull = true)] + public StockTakingItem? StockTakingItem { get; set; } + + public override double CalculateNetWeight() => base.CalculateNetWeight(); + + public override bool IsValidSafeMeasuringValues() + { + return StockTakingItemId > 0 && base.IsValidSafeMeasuringValues(); + } + + /// + /// "Szigorúbb" mint az IsValidSafeMeasuringValues() + /// + /// + /// + public override bool IsValidMeasuringValues(bool isMeasurable) + { + return StockTakingItemId > 0 && base.IsValidMeasuringValues(isMeasurable); + } +} \ No newline at end of file diff --git a/FruitBank.Common/FruitBank.Common.csproj b/FruitBank.Common/FruitBank.Common.csproj index f0239ec..c0473ce 100644 --- a/FruitBank.Common/FruitBank.Common.csproj +++ b/FruitBank.Common/FruitBank.Common.csproj @@ -11,7 +11,7 @@ - + diff --git a/FruitBank.Common/FruitBankConstClient.cs b/FruitBank.Common/FruitBankConstClient.cs index 0f5d7fd..7d7a0da 100644 --- a/FruitBank.Common/FruitBankConstClient.cs +++ b/FruitBank.Common/FruitBankConstClient.cs @@ -38,6 +38,11 @@ public static class FruitBankConstClient public const string StockQuantityHistoryExtDbTableName = "fbStockQuantityHistoryExt"; + public const string StockTakingDbTableName = "fbStockTaking"; + public const string StockTakingItemDbTableName = "fbStockTakingItem"; + public const string StockTakingItemPalletDbTableName = "fbStockTakingItemPallet"; + + //public static Guid[] DevAdminIds = new Guid[2] { Guid.Parse("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd"), Guid.Parse("4cbaed43-2465-4d99-84f1-c8bc6b7025f7") }; //public static Guid[] SysAdmins = new Guid[3] diff --git a/FruitBank.Common/Interfaces/IFruitBankDataControllerCommon.cs b/FruitBank.Common/Interfaces/IFruitBankDataControllerCommon.cs index 9fc0a06..9f367ae 100644 --- a/FruitBank.Common/Interfaces/IFruitBankDataControllerCommon.cs +++ b/FruitBank.Common/Interfaces/IFruitBankDataControllerCommon.cs @@ -2,6 +2,7 @@ using FruitBank.Common.Entities; using FruitBank.Common.Models; using Mango.Nop.Core.Dtos; +using Mango.Nop.Core.Entities; using Mango.Nop.Core.Models; using Nop.Core.Domain.Customers; @@ -72,4 +73,11 @@ public interface IFruitBankDataControllerCommon Task LoginMeasuringUser(MgLoginModelRequest loginModelRequest); Task?> ProcessAndSaveFullShippingJson(string fullShippingJson, int customerId); + + public Task?> GetGenericAttributeDtosByEntityIdAndKeyGroup(int productId, string keyGroup, int storeId); + + public Task AddGenericAttributeDto(GenericAttributeDto genericAttributeDto); + + public Task UpdateGenericAttributeDto(GenericAttributeDto genericAttributeDto); + } \ No newline at end of file diff --git a/FruitBank.Common/Interfaces/IStockSignalREndpointClient.cs b/FruitBank.Common/Interfaces/IStockSignalREndpointClient.cs new file mode 100644 index 0000000..489ee40 --- /dev/null +++ b/FruitBank.Common/Interfaces/IStockSignalREndpointClient.cs @@ -0,0 +1,6 @@ +namespace FruitBank.Common.Interfaces; + +public interface IStockSignalREndpointClient : IStockSignalREndpointCommon +{ + +} \ No newline at end of file diff --git a/FruitBank.Common/Interfaces/IStockSignalREndpointCommon.cs b/FruitBank.Common/Interfaces/IStockSignalREndpointCommon.cs new file mode 100644 index 0000000..345a264 --- /dev/null +++ b/FruitBank.Common/Interfaces/IStockSignalREndpointCommon.cs @@ -0,0 +1,24 @@ +using FruitBank.Common.Entities; +using Mango.Nop.Core.Entities; + +namespace FruitBank.Common.Interfaces; + +public interface IStockSignalREndpointCommon +{ + public Task?> GetStockTakings(); + public Task?> GetStockTakingsByProductId(int productId); + public Task AddStockTaking(StockTaking stockTaking); + public Task UpdateStockTaking(StockTaking stockTaking); + + public Task?> GetStockTakingItems(); + public Task GetStockTakingItemsById(int stockTakingItemId); + public Task?> GetStockTakingItemsByProductId(int productId); + public Task?> GetStockTakingItemsByStockTakingId(int stockTakingId); + public Task AddStockTakingItem(StockTakingItem stockTakingItem); + public Task UpdateStockTakingItem(StockTakingItem stockTakingItem); + + public Task?> GetStockTakingItemPallets(); + public Task?> GetStockTakingItemPalletsByProductId(int productId); + public Task AddStockTakingItemPallet(StockTakingItemPallet stockTakingItemPallet); + public Task UpdateStockTakingItemPallet(StockTakingItemPallet stockTakingItemPallet); +} \ No newline at end of file diff --git a/FruitBank.Common/SignalRs/SignalRTags.cs b/FruitBank.Common/SignalRs/SignalRTags.cs index 87e4d38..8a80f2f 100644 --- a/FruitBank.Common/SignalRs/SignalRTags.cs +++ b/FruitBank.Common/SignalRs/SignalRTags.cs @@ -90,6 +90,11 @@ public class SignalRTags : AcSignalRTags public const int AddGenericAttributeDto = 168; public const int UpdateGenericAttributeDto = 169; + public const int GetStockTakings = 170; + public const int GetStockTakingItems = 173; + public const int GetStockTakingItemsById = 174; + public const int AddStockTaking = 175; + public const int AuthenticateUser = 195; public const int RefreshToken = 200; diff --git a/FruitBankHybrid.Shared.Common/FruitBankHybrid.Shared.Common.csproj b/FruitBankHybrid.Shared.Common/FruitBankHybrid.Shared.Common.csproj index 60d7f74..e5ce967 100644 --- a/FruitBankHybrid.Shared.Common/FruitBankHybrid.Shared.Common.csproj +++ b/FruitBankHybrid.Shared.Common/FruitBankHybrid.Shared.Common.csproj @@ -1,15 +1,18 @@  - - net10.0 - enable - enable - + + net10.0 + enable + enable - - - - - + true + true + + + + + + + diff --git a/FruitBankHybrid.Shared.Tests/FruitBankHybrid.Shared.Tests.csproj b/FruitBankHybrid.Shared.Tests/FruitBankHybrid.Shared.Tests.csproj index 2a80cce..40dc96a 100644 --- a/FruitBankHybrid.Shared.Tests/FruitBankHybrid.Shared.Tests.csproj +++ b/FruitBankHybrid.Shared.Tests/FruitBankHybrid.Shared.Tests.csproj @@ -1,69 +1,71 @@ - + - - net10.0 - latest - enable - enable - - true - + true + - - - - - + + + + + - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Core.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll - - - ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll - - - ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Services\bin\FruitBank\Debug\net9.0\Mango.Nop.Services.dll - - + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Core.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll + + + ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll + + + ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Services\bin\FruitBank\Debug\net9.0\Mango.Nop.Services.dll + + - - - + + + - - - + + + - - - + + + - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - - + + + - - - + + + diff --git a/FruitBankHybrid.Shared.Tests/OrderClientTests.cs b/FruitBankHybrid.Shared.Tests/OrderClientTests.cs index 300ad51..4e8d1e7 100644 --- a/FruitBankHybrid.Shared.Tests/OrderClientTests.cs +++ b/FruitBankHybrid.Shared.Tests/OrderClientTests.cs @@ -27,7 +27,39 @@ public sealed class OrderClientTests }); } - + + [TestMethod] + public async Task GetAllStockTakings() + { + var stockTakings = await _signalRClient.GetStockTakings(); + + Assert.IsNotNull(stockTakings); + Assert.IsTrue(stockTakings.Count != 0); + + Assert.IsTrue(stockTakings.All(o => o.StockTakingItems.All(oi => oi.Product != null && oi.Product.Id == oi.ProductId))); + } + + [TestMethod] + public async Task GetAllStockTakingItems() + { + var stockTakingItems = await _signalRClient.GetStockTakingItems(); + + Assert.IsNotNull(stockTakingItems); + Assert.IsTrue(stockTakingItems.Count != 0); + + Assert.IsTrue(stockTakingItems.All(oi => oi.StockTaking != null && oi.Product != null && oi.Product.Id == oi.ProductId)); + } + + [TestMethod] + public async Task GetAllStockTakingItemById() + { + var stockTakingItem = await _signalRClient.GetStockTakingItemsById(100); + + Assert.IsNotNull(stockTakingItem); + Assert.IsNotNull(stockTakingItem.Product); + Assert.IsNotNull(stockTakingItem.StockTaking); + } + [TestMethod] public async Task GetAllOrderDtos() { diff --git a/FruitBankHybrid.Shared/Components/GridDetailOrderItemDto.razor b/FruitBankHybrid.Shared/Components/GridDetailOrderItemDto.razor index 8ff39fb..02faa2f 100644 --- a/FruitBankHybrid.Shared/Components/GridDetailOrderItemDto.razor +++ b/FruitBankHybrid.Shared/Components/GridDetailOrderItemDto.razor @@ -111,7 +111,7 @@ { LoadingPanelVisibility.Visible = true; - using (await ObjectLock.GetSemaphore().UseWaitAsync()) + //using (await ObjectLock.GetSemaphore().UseWaitAsync()) { if (ProductDtos == null || !ProductDtos.Any() || forceReload) ProductDtos = await Database.ProductDtoTable.LoadDataAsync(!forceReload); } diff --git a/FruitBankHybrid.Shared/Components/GridProductDtoTemplate.razor b/FruitBankHybrid.Shared/Components/GridProductDtoTemplate.razor index 5189b9c..895d878 100644 --- a/FruitBankHybrid.Shared/Components/GridProductDtoTemplate.razor +++ b/FruitBankHybrid.Shared/Components/GridProductDtoTemplate.razor @@ -34,9 +34,18 @@ { var productDto = ((ProductDto)(context.DataItem)); var productId = productDto.Id; - + + + @{ + //GetOrderItemDtosFromDbAsync(productId).Forget(); + //var orderItemDtos = _orderItemDtos?.Where(oi => oi.ProductId == productId).ToList() ?? []; + + var contextIds = new[] { (object)productDto.Id }; + + } + @{ //GetOrderDtosFromDbAsync(productId).Forget(); @@ -51,15 +60,6 @@ } - - @{ - //GetOrderItemDtosFromDbAsync(productId).Forget(); - //var orderItemDtos = _orderItemDtos?.Where(oi => oi.ProductId == productId).ToList() ?? []; - - var contextIds = new[] { (object)productDto.Id }; - - } - @{ var genericAttributeDtos = new AcObservableCollection(productDto.GenericAttributes); @@ -72,7 +72,7 @@ @if (IsMasterGrid) { - + } @@ -124,7 +124,7 @@ if (!IsMasterGrid) return; LoadingPanelVisibility.Visible = true; - using (await ObjectLock.GetSemaphore().UseWaitAsync()) + //using (await ObjectLock.GetSemaphore().UseWaitAsync()) { if (ProductDtos == null || !ProductDtos.Any() || forceReload) ProductDtos = await Database.ProductDtoTable.LoadDataAsync(!forceReload); } diff --git a/FruitBankHybrid.Shared/Components/GridShippingItemTemplate.razor b/FruitBankHybrid.Shared/Components/GridShippingItemTemplate.razor index a074749..8eed1f5 100644 --- a/FruitBankHybrid.Shared/Components/GridShippingItemTemplate.razor +++ b/FruitBankHybrid.Shared/Components/GridShippingItemTemplate.razor @@ -15,10 +15,10 @@ @inject IEnumerable LogWriters @inject FruitBankSignalRClient FruitBankSignalRClient - + - - - + + + @@ -159,7 +159,7 @@ public async Task ReloadDataFromDb(bool forceReload = false) { - using (await ObjectLock.GetSemaphore().UseWaitAsync()) + //using (await ObjectLock.GetSemaphore().UseWaitAsync()) { if (ProductDtos == null || !ProductDtos.Any() || forceReload) ProductDtos = await Database.ProductDtoTable.LoadDataAsync(!forceReload); } @@ -190,11 +190,60 @@ if (forceReload) Grid.Reload(); } + void Grid_CustomizeElement(GridCustomizeElementEventArgs e) + { + if (e.ElementType != GridElementType.DataCell) return; + + if (e.Column.Name != nameof(ShippingItem.MeasuredNetWeight) && + e.Column.Name != nameof(ShippingItem.MeasuredGrossWeight) && + e.Column.Name != nameof(ShippingItem.MeasuredQuantity)) return; + + var isMeasured = (bool)e.Grid.GetRowValue(e.VisibleIndex, nameof(ShippingItem.IsMeasured)); + if (!isMeasured) return; + + switch (e.Column.Name) + { + case nameof(ShippingItem.MeasuredNetWeight) or nameof(ShippingItem.MeasuredGrossWeight): + { + var isMeasurable = (bool)e.Grid.GetRowValue(e.VisibleIndex, nameof(ShippingItem.IsMeasurable)); + if (!isMeasurable) return; + + var valueOnDocument = 0d; + var measuredValue = 0d; + + if (e.Column.Name == nameof(ShippingItem.MeasuredGrossWeight)) + { + valueOnDocument = (double)e.Grid.GetRowValue(e.VisibleIndex, nameof(ShippingItem.GrossWeightOnDocument)); + measuredValue = (double)e.Grid.GetRowValue(e.VisibleIndex, nameof(ShippingItem.MeasuredGrossWeight)); + } + else + { + valueOnDocument = (double)e.Grid.GetRowValue(e.VisibleIndex, nameof(ShippingItem.NetWeightOnDocument)); + measuredValue = (double)e.Grid.GetRowValue(e.VisibleIndex, nameof(ShippingItem.MeasuredNetWeight)); + } + + if (valueOnDocument > 0 && valueOnDocument > measuredValue) e.CssClass = "text-danger"; + //else if (valueOnDocument <= measuredValue) e.CssClass = "text-success"; + + break; + } + case nameof(ShippingItem.MeasuredQuantity): + { + var quantityOnDocument = (int)e.Grid.GetRowValue(e.VisibleIndex, nameof(ShippingItem.QuantityOnDocument)); + var measuredQuantity = (int)e.Grid.GetRowValue(e.VisibleIndex, nameof(ShippingItem.MeasuredQuantity)); + + if (quantityOnDocument > 0 && quantityOnDocument > measuredQuantity) e.CssClass = "text-danger"; + //else if (quantityOnDocument <= measuredQuantity) e.CssClass = "text-success"; + break; + } + } + } + async Task Grid_FocusedRowChanged(GridFocusedRowChangedEventArgs args) { if ((args.Grid.IsEditing() || args.Grid.IsEditingNewRow()) && (args.DataItem as IId).Id > 0) await args.Grid.SaveChangesAsync(); - + FocusedRowVisibleIndex = args.VisibleIndex; EditItemsEnabled = true; } diff --git a/FruitBankHybrid.Shared/Components/Grids/Products/GridStockQuantityHistoryDtoTemplate.razor b/FruitBankHybrid.Shared/Components/Grids/Products/GridStockQuantityHistoryDtoTemplate.razor index e705510..bf21ce1 100644 --- a/FruitBankHybrid.Shared/Components/Grids/Products/GridStockQuantityHistoryDtoTemplate.razor +++ b/FruitBankHybrid.Shared/Components/Grids/Products/GridStockQuantityHistoryDtoTemplate.razor @@ -17,7 +17,18 @@ - + + + + + @@ -77,7 +88,7 @@ { if (!IsMasterGrid) return; - using (await ObjectLock.GetSemaphore().UseWaitAsync()) + //using (await ObjectLock.GetSemaphore().UseWaitAsync()) { if (ProductDtos == null || !ProductDtos.Any() || forceReload) ProductDtos = await Database.ProductDtoTable.LoadDataAsync(!forceReload); } diff --git a/FruitBankHybrid.Shared/Components/Grids/ShippingItems/GridShippingItemBase.cs b/FruitBankHybrid.Shared/Components/Grids/ShippingItems/GridShippingItemBase.cs index df08744..ff59e91 100644 --- a/FruitBankHybrid.Shared/Components/Grids/ShippingItems/GridShippingItemBase.cs +++ b/FruitBankHybrid.Shared/Components/Grids/ShippingItems/GridShippingItemBase.cs @@ -54,6 +54,11 @@ public class GridShippingItemBase : FruitBankGridBase, IGrid await base.OnInitializedAsync(); } + //protected override Task OnCustomizeEditModel(GridCustomizeEditModelEventArgs e) + //{ + // return base.OnCustomizeEditModel(e); + //} + protected override void OnParametersSet() { base.OnParametersSet(); diff --git a/FruitBankHybrid.Shared/Components/Grids/StockTakingItems/GridStockTakingItem.razor b/FruitBankHybrid.Shared/Components/Grids/StockTakingItems/GridStockTakingItem.razor new file mode 100644 index 0000000..502b85a --- /dev/null +++ b/FruitBankHybrid.Shared/Components/Grids/StockTakingItems/GridStockTakingItem.razor @@ -0,0 +1,89 @@ +@using System.Collections.ObjectModel +@using AyCode.Core.Helpers +@using AyCode.Core.Loggers +@using AyCode.Utils.Extensions +@using FruitBank.Common.Dtos +@using FruitBank.Common.Entities +@using FruitBankHybrid.Shared.Components.Grids.Shippings +@using FruitBankHybrid.Shared.Components.Toolbars +@using FruitBankHybrid.Shared.Databases +@using FruitBankHybrid.Shared.Services.Loggers +@using FruitBankHybrid.Shared.Services.SignalRs + +@inject IEnumerable LogWriters +@inject FruitBankSignalRClient FruitBankSignalRClient + + + + + + + + + + + + + + + + + + + @if (IsMasterGrid) + { + + } + + + +@code { + //[Inject] public required ObjectLock ObjectLock { get; set; } + [Inject] public required DatabaseClient Database { get; set; } + + [Parameter] public bool IsMasterGrid { get; set; } = false; + [Parameter] public AcObservableCollection? Partners { get; set; } + [Parameter] public AcObservableCollection? Shippings { get; set; } + + const string ExportFileName = "ExportResult"; + string GridSearchText = ""; + bool EditItemsEnabled { get; set; } + int FocusedRowVisibleIndex { get; set; } + public GridStockTakingItemBase Grid { get; set; } + string GridCss => !IsMasterGrid ? "hide-toolbar" : string.Empty; + + private int _activeTabIndex; + private LoggerClient _logger; + + protected override async Task OnInitializedAsync() + { + _logger = new LoggerClient(LogWriters.ToArray()); + await ReloadDataFromDb(false); + } + + private async Task ReloadDataFromDb(bool forceReload = false) + { + if (!IsMasterGrid) return; + + if (Grid == null) return; + + //using (await ObjectLock.GetSemaphore().UseWaitAsync()) + //if (forceReload) await Grid.ReloadDataSourceAsync(); + + if (forceReload) Grid.Reload(); + } + + async Task Grid_FocusedRowChanged(GridFocusedRowChangedEventArgs args) + { + if (Grid == null) return; + + if (Grid.IsEditing() && !Grid.IsEditingNewRow()) + await Grid.SaveChangesAsync(); + + FocusedRowVisibleIndex = args.VisibleIndex; + EditItemsEnabled = true; + } +} + diff --git a/FruitBankHybrid.Shared/Components/Grids/StockTakingItems/GridStockTakingItemBase.cs b/FruitBankHybrid.Shared/Components/Grids/StockTakingItems/GridStockTakingItemBase.cs new file mode 100644 index 0000000..b8f74bd --- /dev/null +++ b/FruitBankHybrid.Shared/Components/Grids/StockTakingItems/GridStockTakingItemBase.cs @@ -0,0 +1,67 @@ +using AyCode.Core.Interfaces; +using DevExpress.Blazor; +using FruitBank.Common.Entities; +using FruitBank.Common.Interfaces; +using FruitBank.Common.SignalRs; +using FruitBankHybrid.Shared.Pages; +using Microsoft.AspNetCore.Components; + +namespace FruitBankHybrid.Shared.Components.Grids.StockTakingItems; + +public class GridStockTakingItemBase: FruitBankGridBase, IGrid +{ + private bool _isFirstInitializeParameterCore; + private bool _isFirstInitializeParameters; + + public GridStockTakingItemBase() : base() + { + GetAllMessageTag = SignalRTags.GetStockTakingItems; + //AddMessageTag = SignalRTags.AddPartner; + //UpdateMessageTag = SignalRTags.UpdatePartner; + + //RemoveMessageTag = SignalRTags.; + } + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + } + + protected override void OnParametersSet() + { + base.OnParametersSet(); + + if (!_isFirstInitializeParameters) + { + //if (!IsMasterGrid && (ContextIds == null || ContextIds.Length == 0)) + //{ + // ContextIds = [ParentDataItem!.Id]; + // GetAllMessageTag = SignalRTags.GetShippingItemsByDocumentId; + //} + + _isFirstInitializeParameters = false; + } + } + + protected override async Task SetParametersAsyncCore(ParameterView parameters) + { + await base.SetParametersAsyncCore(parameters); + + if (!_isFirstInitializeParameterCore) + { + //if (!IsMasterGrid && (ContextIds == null || ContextIds.Length == 0)) + //{ + // ContextIds = [ParentDataItem!.Id]; + // GetAllMessageTag = SignalRTags.GetShippingItemsByDocumentId; + //} + + //ShowFilterRow = true; + //ShowGroupPanel = true; + //AllowSort = false; + + //etc... + + _isFirstInitializeParameterCore = false; + } + } +} \ No newline at end of file diff --git a/FruitBankHybrid.Shared/Components/StockTakings/StockTakingTemplate.razor b/FruitBankHybrid.Shared/Components/StockTakings/StockTakingTemplate.razor new file mode 100644 index 0000000..c104a35 --- /dev/null +++ b/FruitBankHybrid.Shared/Components/StockTakings/StockTakingTemplate.razor @@ -0,0 +1,110 @@ +@using AyCode.Utils.Extensions +@using FruitBank.Common.Dtos +@using FruitBank.Common.Entities +@using FruitBank.Common.Models +@using FruitBankHybrid.Shared.Databases +@using FruitBankHybrid.Shared.Services.SignalRs +@using Mango.Nop.Core.Entities + + + + @* CaptionCssClass="@(SelectedProductDto?.IsMeasured == true ? "text-success" : "")"> *@ + + + + + + + + @* TextFieldName="StockTakingItem.Product.Name" *@ + + + + + + + + + + + + +@code +{ + [Inject] public required DatabaseClient Database { get; set; } + [Inject] public required LoggedInModel LoggedInModel { get; set; } + [Inject] public required FruitBankSignalRClient FruitBankSignalRClient { get; set; } + + List _stockTakings { get; set; } = []; + List _stockTakingItems { get; set; } = []; + List _stockTakingItemPallets { get; set; } = []; + StockTaking? SelectedStockTaking { get; set; } + StockTakingItem? SelectedStockTakingItem { get; set; } + + protected override async Task OnInitializedAsync() + { + await ReloadDataFromDb(false); + } + + public async Task ReloadDataFromDb(bool forceReload) + { + LoadingPanelVisibility.Visible = true; + + _stockTakings = await FruitBankSignalRClient.GetStockTakings() ?? []; + ValueChanged(_stockTakings.FirstOrDefault()); + + LoadingPanelVisibility.Visible = false; + } + + private async Task Callback() + { + var stockTaking = new StockTaking(); + stockTaking.StartDateTime = DateTime.Now; + stockTaking.Creator = LoggedInModel.CustomerDto!.Id; + + var resultStockTaking = await FruitBankSignalRClient.AddStockTaking(stockTaking); + if (resultStockTaking == null) return; + + _stockTakings.Add(resultStockTaking); + StateHasChanged(); + } + + private async Task Callback2() + { + // var resultStockTaking = await FruitBankSignalRClient.AddStockTaking(stockTaking); + // if (resultStockTaking == null) return; + + // _stockTakings.Add(resultStockTaking); + StateHasChanged(); + } + + private async Task Callback3() + { + // var resultStockTaking = await FruitBankSignalRClient.AddStockTaking(stockTaking); + // if (resultStockTaking == null) return; + + // _stockTakings.Add(resultStockTaking); + StateHasChanged(); + } + + private void ValueChanged(StockTaking? newValue) + { + SelectedStockTaking = newValue; + _stockTakingItems = SelectedStockTaking?.StockTakingItems?.OrderByDescending(x => x.IsMeasured).ThenByDescending(x => x.OriginalStockQuantity != 0 || x.OriginalNetWeight != 0).ThenBy(x => x.Product?.Name).ToList() ?? []; + + SelectedStockTakingItem = _stockTakingItems.FirstOrDefault(); + } +} diff --git a/FruitBankHybrid.Shared/Databases/DatabaseClient.cs b/FruitBankHybrid.Shared/Databases/DatabaseClient.cs index afd0311..65e0cc8 100644 --- a/FruitBankHybrid.Shared/Databases/DatabaseClient.cs +++ b/FruitBankHybrid.Shared/Databases/DatabaseClient.cs @@ -58,12 +58,13 @@ public class ShippingItemTable : SignalRDataSourceList public class ProductDtoTable(FruitBankSignalRClient fruitBankSignalRClient) : AcObservableCollection { - private readonly SemaphoreSlim _semaphoreSlim = new(1); + //private readonly SemaphoreSlim _semaphoreSlim = new(1); public async Task LoadDataAsync(bool onlyIfEmpty = true) { if (onlyIfEmpty && Count > 0) return this; - using (await _semaphoreSlim.UseWaitAsync()) + //using (await _semaphoreSlim.UseWaitAsync()) + using (await ObjectLock.GetSemaphore().UseWaitAsync()) { //Előfordulhat, h egy másik szálban már megtörtént a refresh... - J. if (onlyIfEmpty && Count > 0) return this; @@ -83,13 +84,14 @@ public class ProductDtoTable(FruitBankSignalRClient fruitBankSignalRClient) : Ac } public class OrderDtoTable(FruitBankSignalRClient fruitBankSignalRClient) : AcObservableCollection { - private readonly SemaphoreSlim _semaphoreSlim = new(1); + //private readonly SemaphoreSlim _semaphoreSlim = new(1); public async Task LoadDataAsync(bool onlyIfEmpty = true) { if (onlyIfEmpty && Count > 0) return this; - using (await _semaphoreSlim.UseWaitAsync()) + //using (await _semaphoreSlim.UseWaitAsync()) + using (await ObjectLock.GetSemaphore().UseWaitAsync()) { if (Count > 0) return this; diff --git a/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj b/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj index be7cb06..3a92d0c 100644 --- a/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj +++ b/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj @@ -1,68 +1,71 @@  - - net10.0 - enable - enable - + + net10.0 + enable + enable - - - + true + true + - - - - - - - - + + + - - - - + + + + + + + + - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Core.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Models.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll - - - - - - - - - - - - - - - - - - ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll - - + + + + + + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Core.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Models.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll + + + + + + + + + + + + + + + + + + ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll + + \ No newline at end of file diff --git a/FruitBankHybrid.Shared/Layout/NavMenu.razor b/FruitBankHybrid.Shared/Layout/NavMenu.razor index ff72e57..b13e7e9 100644 --- a/FruitBankHybrid.Shared/Layout/NavMenu.razor +++ b/FruitBankHybrid.Shared/Layout/NavMenu.razor @@ -53,9 +53,7 @@ Rendelések - Adminisztrátor - } - @if (LoggedInModel.IsDeveloper) - { +