improvements, fixes...

This commit is contained in:
Loretta 2024-07-04 20:03:24 +02:00
parent dd6d9f17b7
commit 4507f69f9e
2 changed files with 21 additions and 44 deletions

View File

@ -137,8 +137,8 @@
private TransferToDriversDetailGrid _transferToDriversGrid = null!;
private LoggerClient<TransferToDriverGridComponent> _logger = null!;
private List<Car> _cars = [];
private List<UserProductMapping> _drivers = [];
private static List<Car> _cars = [];
private static List<UserProductMapping> _drivers = [];
protected override async Task OnInitializedAsync()
{
@ -146,23 +146,26 @@
_logger.Info($"DetailGridData: {ParentData.TransferToDrivers.Count}");
_cars.AddRange((await AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])) ?? []);
_drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping));
// _cars.AddRange((await AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])) ?? []);
// _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping));
// //AdminSignalRClient.GetAllIntoAsync<Car>(_cars, SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])
// AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, response =>
// {
// if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
// {
// _logger.Error($"GetAllAsync<List<Car>>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}");
// return Task.CompletedTask;
// }
//AdminSignalRClient.GetAllIntoAsync<Car>(_cars, SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])
AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, async response =>
{
if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
{
_logger.Error($"GetAllAsync<List<Car>>(); 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();
}

View File

@ -99,42 +99,16 @@
private bool? _isNewState = null;
private LoggerClient<UserProductMappingGridComponent> _logger;
private List<User> _users = [];
private List<Product> _products = [];
private static List<User> _users = [];
private static List<Product> _products = [];
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
//_products = (await AdminSignalRClient.GetAllAsync<List<Product>>(SignalRTags.GetAllProducts)) ?? [];
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
AdminSignalRClient.GetAllIntoAsync(_users, SignalRTags.GetAllUsers).Forget();
// AdminSignalRClient.GetAllAsync<List<Product>>(SignalRTags.GetAllProducts, response =>
// {
// if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
// {
// _logger.Error($"GetAllAsync<List<Car>>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}");
// return Task.CompletedTask;
// }
// _products.AddRange(response.ResponseData);
// return Task.CompletedTask;
// }).Forget();
// AdminSignalRClient.GetAllAsync<List<User>>(SignalRTags.getal, response =>
// {
// if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
// {
// _logger.Error($"GetAllAsync<List<Car>>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}");
// return Task.CompletedTask;
// }
// _products.AddRange(response.ResponseData);
// return Task.CompletedTask;
// }).Forget();
await base.OnInitializedAsync();
}