From 4507f69f9ea941c773bfcf2cf62c91a5170f9136 Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 4 Jul 2024 20:03:24 +0200 Subject: [PATCH] improvements, fixes... --- .../TransferToDriverGridComponent.razor | 35 ++++++++++--------- .../UserProductMappingGridComponent.razor | 30 ++-------------- 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferToDriverGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferToDriverGridComponent.razor index c52bc2b2..2cf730b4 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/TransferToDriverGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferToDriverGridComponent.razor @@ -137,8 +137,8 @@ private TransferToDriversDetailGrid _transferToDriversGrid = null!; private LoggerClient _logger = null!; - private List _cars = []; - private List _drivers = []; + private static List _cars = []; + private static List _drivers = []; protected override async Task OnInitializedAsync() { @@ -146,23 +146,26 @@ _logger.Info($"DetailGridData: {ParentData.TransferToDrivers.Count}"); - _cars.AddRange((await AdminSignalRClient.GetAllAsync>(SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])) ?? []); - _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping)); + // _cars.AddRange((await AdminSignalRClient.GetAllAsync>(SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])) ?? []); + // _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping)); - // //AdminSignalRClient.GetAllIntoAsync(_cars, SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId]) - // AdminSignalRClient.GetAllAsync>(SignalRTags.GetAllCarsByProductId, response => - // { - // if (response.Status != SignalResponseStatus.Success || response.ResponseData == null) - // { - // _logger.Error($"GetAllAsync>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}"); - // return Task.CompletedTask; - // } + //AdminSignalRClient.GetAllIntoAsync(_cars, SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId]) + AdminSignalRClient.GetAllAsync>(SignalRTags.GetAllCarsByProductId, async response => + { + if (response.Status != SignalResponseStatus.Success || response.ResponseData == null) + { + _logger.Error($"GetAllAsync>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}"); + return; + } - // _cars.AddRange(response.ResponseData); - // _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping)); + _cars.Clear(); + _drivers.Clear(); - // return Task.CompletedTask; - // }, [TiamConstClient.TransferProductId]).Forget(); + _cars.AddRange(response.ResponseData); + _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping)); + + await InvokeAsync(StateHasChanged); + }, [TiamConstClient.TransferProductId]).Forget(); await base.OnInitializedAsync(); } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/UserProductMappingGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/UserProductMappingGridComponent.razor index e2f7c1f8..e5234478 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/UserProductMappingGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/UserProductMappingGridComponent.razor @@ -99,42 +99,16 @@ private bool? _isNewState = null; private LoggerClient _logger; - private List _users = []; - private List _products = []; + private static List _users = []; + private static List _products = []; protected override async Task OnInitializedAsync() { _logger = new LoggerClient(LogWriters.ToArray()); - //_products = (await AdminSignalRClient.GetAllAsync>(SignalRTags.GetAllProducts)) ?? []; - AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget(); AdminSignalRClient.GetAllIntoAsync(_users, SignalRTags.GetAllUsers).Forget(); - // AdminSignalRClient.GetAllAsync>(SignalRTags.GetAllProducts, response => - // { - // if (response.Status != SignalResponseStatus.Success || response.ResponseData == null) - // { - // _logger.Error($"GetAllAsync>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}"); - // return Task.CompletedTask; - // } - - // _products.AddRange(response.ResponseData); - // return Task.CompletedTask; - // }).Forget(); - - // AdminSignalRClient.GetAllAsync>(SignalRTags.getal, response => - // { - // if (response.Status != SignalResponseStatus.Success || response.ResponseData == null) - // { - // _logger.Error($"GetAllAsync>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}"); - // return Task.CompletedTask; - // } - - // _products.AddRange(response.ResponseData); - // return Task.CompletedTask; - // }).Forget(); - await base.OnInitializedAsync(); }