EfCore Tracking fix; Implement FilterText to TiamGrid/DataSource; Implement multiple Context[Id]s params to SignalRClient; improvements, fixes, etc...
This commit is contained in:
parent
ffb0187395
commit
8059ed50b1
|
|
@ -11,6 +11,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using AyCode.Core.Extensions;
|
using System.Linq.Expressions;
|
||||||
|
using AyCode.Core.Extensions;
|
||||||
using AyCode.Core.Server.Loggers;
|
using AyCode.Core.Server.Loggers;
|
||||||
using AyCode.Database.DbSets.Messages;
|
using AyCode.Database.DbSets.Messages;
|
||||||
using AyCode.Database.DbSets.Users;
|
using AyCode.Database.DbSets.Users;
|
||||||
|
|
@ -23,6 +24,9 @@ using TIAM.Entities.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
using TIAM.Models.Dtos.Products;
|
using TIAM.Models.Dtos.Products;
|
||||||
using AyCode.Database.DbSets.Profiles;
|
using AyCode.Database.DbSets.Profiles;
|
||||||
|
using DevExpress.Data.Filtering;
|
||||||
|
using DevExpress.Data.Linq;
|
||||||
|
using DevExpress.Data.Linq.Helpers;
|
||||||
using TIAM.Database.DbSets.Drivers;
|
using TIAM.Database.DbSets.Drivers;
|
||||||
|
|
||||||
namespace TIAM.Database.DataLayers.Admins
|
namespace TIAM.Database.DataLayers.Admins
|
||||||
|
|
@ -47,6 +51,8 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
|
|
||||||
#region Transfer
|
#region Transfer
|
||||||
|
|
||||||
|
public Task<List<Transfer>> GetTransfersByFilterAsync(CriteriaOperator criteriaOperator) => SessionAsync(ctx => (ctx.GetTransfers().AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator) as IQueryable<Transfer>)!.ToList());
|
||||||
|
|
||||||
public Task<List<Transfer>> GetTransfersAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
|
public Task<List<Transfer>> GetTransfersAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
|
||||||
public Task<string> GetTransfersJsonAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
|
public Task<string> GetTransfersJsonAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
|
||||||
public Task<string> GetTransfersByUserIdJsonAsync(Guid userId) => SessionAsync(ctx => ctx.GetTransfers().Where(x => x.UserId == userId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
|
public Task<string> GetTransfersByUserIdJsonAsync(Guid userId) => SessionAsync(ctx => ctx.GetTransfers().Where(x => x.UserId == userId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
|
||||||
|
|
@ -55,7 +61,17 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
public string? GetTransferJsonById(Guid transferId) => Session(ctx => ctx.GetTransferById(transferId)?.ToJson());
|
public string? GetTransferJsonById(Guid transferId) => Session(ctx => ctx.GetTransferById(transferId)?.ToJson());
|
||||||
|
|
||||||
public Task<bool> AddTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.AddTransfer(transfer));
|
public Task<bool> AddTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.AddTransfer(transfer));
|
||||||
public Task<bool> UpdateTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.UpdateTransfer(transfer));
|
public Task<bool> UpdateTransferAsync(Transfer transfer) => TransactionAsync(ctx =>
|
||||||
|
{
|
||||||
|
//foreach (var entityEntry in ctx.ChangeTracker.Entries())
|
||||||
|
//{
|
||||||
|
// if (entityEntry.Entity is not Transfer)
|
||||||
|
// entityEntry.State = EntityState.Unchanged;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//transfer.TransferToDrivers = null!;
|
||||||
|
return ctx.UpdateTransfer(transfer);
|
||||||
|
});
|
||||||
|
|
||||||
public Task<bool> UpdateTransferAsync(Transfer transfer, TransferToDriver transferToDriver) => UpdateTransferAsync(transfer, [transferToDriver]);
|
public Task<bool> UpdateTransferAsync(Transfer transfer, TransferToDriver transferToDriver) => UpdateTransferAsync(transfer, [transferToDriver]);
|
||||||
public Task<bool> UpdateTransferAsync(Transfer transfer, List<TransferToDriver> transferToDrivers)
|
public Task<bool> UpdateTransferAsync(Transfer transfer, List<TransferToDriver> transferToDrivers)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using AyCode.Database.DbContexts;
|
using AyCode.Database.DbContexts;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace TIAM.Database.DbContexts
|
namespace TIAM.Database.DbContexts
|
||||||
{
|
{
|
||||||
|
|
@ -22,9 +23,11 @@ namespace TIAM.Database.DbContexts
|
||||||
{
|
{
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
|
||||||
optionsBuilder.UseLazyLoadingProxies(true);
|
optionsBuilder.UseLazyLoadingProxies(false);
|
||||||
optionsBuilder.EnableDetailedErrors(true);
|
optionsBuilder.EnableDetailedErrors(true);
|
||||||
|
|
||||||
|
optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTrackingWithIdentityResolution);
|
||||||
|
|
||||||
//optionsBuilder.UseSqlServer(Configuration.GetConnectionString("DeveloperDbConnection"));
|
//optionsBuilder.UseSqlServer(Configuration.GetConnectionString("DeveloperDbConnection"));
|
||||||
//var connString = "Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Trusted_Connection=false;Encrypt=false;TrustServerCertificate=True;Connect Timeout=200;User ID=Anata_Development_Team;Password=v6f_?xNfg9N1;MultipleActiveResultSets=true";
|
//var connString = "Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Trusted_Connection=false;Encrypt=false;TrustServerCertificate=True;Connect Timeout=200;User ID=Anata_Development_Team;Password=v6f_?xNfg9N1;MultipleActiveResultSets=true";
|
||||||
//optionsBuilder.UseSqlServer(connString);
|
//optionsBuilder.UseSqlServer(connString);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DevExpress.Data" Version="24.1.3" />
|
||||||
<PackageReference Include="MessagePack.Annotations" Version="2.5.168" />
|
<PackageReference Include="MessagePack.Annotations" Version="2.5.168" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.6" />
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ public class SignalRTags : AcSignalRTags
|
||||||
public const int GetTransfersByProductId = 5;
|
public const int GetTransfersByProductId = 5;
|
||||||
public const int GetTransfersByCompanyId = 6;
|
public const int GetTransfersByCompanyId = 6;
|
||||||
|
|
||||||
|
public const int GetTransfersByFilterText = 301;
|
||||||
|
|
||||||
public const int UpdateTransfer = 7;
|
public const int UpdateTransfer = 7;
|
||||||
public const int AddTransfer = 8;
|
public const int AddTransfer = 8;
|
||||||
public const int RemoveTransfer = 9;
|
public const int RemoveTransfer = 9;
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,8 @@
|
||||||
<TransferGrid @ref="_gridTransfer"
|
<TransferGrid @ref="_gridTransfer"
|
||||||
Logger="_logger"
|
Logger="_logger"
|
||||||
SignalRClient="AdminSignalRClient"
|
SignalRClient="AdminSignalRClient"
|
||||||
|
ContextIds="[Guid.NewGuid()]"
|
||||||
|
FilterText="@_filterText"
|
||||||
OnDataSourceChanged="DataSourceChanged"
|
OnDataSourceChanged="DataSourceChanged"
|
||||||
OnGridItemChanging="DataSourceItemChanging"
|
OnGridItemChanging="DataSourceItemChanging"
|
||||||
OnGridItemChanged="DataSourceItemChanged"
|
OnGridItemChanged="DataSourceItemChanged"
|
||||||
|
|
@ -192,7 +194,7 @@
|
||||||
|
|
||||||
<ToolbarTemplate>
|
<ToolbarTemplate>
|
||||||
<div>
|
<div>
|
||||||
<DxTagBox Data="@Statuses" Values="@SelectedCategories" @ref="_filterTag"
|
<DxTagBox Data="@Statuses" Values="@_selectedCategories" @ref="_filterTag"
|
||||||
ValuesChanged="(IEnumerable<TransferStatusModel> values) => TagBox_ValuesChanged(values)"
|
ValuesChanged="(IEnumerable<TransferStatusModel> values) => TagBox_ValuesChanged(values)"
|
||||||
ValueFieldName="StatusValue" TextFieldName="StatusName" NullText="Select category..."
|
ValueFieldName="StatusValue" TextFieldName="StatusName" NullText="Select category..."
|
||||||
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto" aria-label="Select category" />
|
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto" aria-label="Select category" />
|
||||||
|
|
@ -235,10 +237,8 @@
|
||||||
|
|
||||||
private bool _popupVisible;
|
private bool _popupVisible;
|
||||||
private TransferGrid _gridTransfer;
|
private TransferGrid _gridTransfer;
|
||||||
private DxTagBox<TransferStatusModel, TransferStatusModel> _filterTag;
|
|
||||||
|
|
||||||
List<TransferStatusModel> SelectedCategories { get; set; }
|
private DxTagBox<TransferStatusModel, TransferStatusModel> _filterTag;
|
||||||
= Statuses.Where(x => x.StatusValue != (byte)TransferStatusType.Finished && x.StatusValue != (byte)TransferStatusType.UserCanceled && x.StatusValue != (byte)TransferStatusType.AdminDenied).ToList();
|
|
||||||
|
|
||||||
public List<string> IgnoreList =
|
public List<string> IgnoreList =
|
||||||
[
|
[
|
||||||
|
|
@ -251,7 +251,7 @@
|
||||||
"ContextId",
|
"ContextId",
|
||||||
];
|
];
|
||||||
|
|
||||||
public static List<TransferStatusModel> Statuses { get; set; } =
|
private static List<TransferStatusModel> Statuses =
|
||||||
[
|
[
|
||||||
new(Convert.ToByte(TransferStatusType.OrderSubmitted), "Order submitted"),
|
new(Convert.ToByte(TransferStatusType.OrderSubmitted), "Order submitted"),
|
||||||
new(Convert.ToByte(TransferStatusType.OrderConfirmed), "Order confirmed"),
|
new(Convert.ToByte(TransferStatusType.OrderConfirmed), "Order confirmed"),
|
||||||
|
|
@ -264,6 +264,9 @@
|
||||||
new(Convert.ToByte(TransferStatusType.AdminDenied), "Admin cancelled")
|
new(Convert.ToByte(TransferStatusType.AdminDenied), "Admin cancelled")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
private static List<TransferStatusModel> _selectedCategories = Statuses.Where(x => x.StatusValue != (byte)TransferStatusType.Finished && x.StatusValue != (byte)TransferStatusType.UserCanceled && x.StatusValue != (byte)TransferStatusType.AdminDenied).ToList();
|
||||||
|
private string? _filterText = GetFilterText(_selectedCategories.Select(x => (TransferStatusType)x.StatusValue).ToList());
|
||||||
|
|
||||||
private MessageWizardModel _messageWizardModel = new();
|
private MessageWizardModel _messageWizardModel = new();
|
||||||
|
|
||||||
public List<AppointmentModel> AppointmentModels { get; set; } = null!;
|
public List<AppointmentModel> AppointmentModels { get; set; } = null!;
|
||||||
|
|
@ -375,13 +378,23 @@
|
||||||
transferEditModel.ContactEmail = "your@email.address";
|
transferEditModel.ContactEmail = "your@email.address";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string? GetFilterText(ICollection<TransferStatusType> selectedTransferStatuses)
|
||||||
|
=> selectedTransferStatuses.Count == 0 ? null : CriteriaOperator.FromLambda<Transfer>(t => selectedTransferStatuses.Contains(t.TransferStatusType)).ToString();
|
||||||
|
|
||||||
void TagBox_ValuesChanged(IEnumerable<TransferStatusModel> newSelectedCategories)
|
void TagBox_ValuesChanged(IEnumerable<TransferStatusModel> newSelectedCategories)
|
||||||
{
|
{
|
||||||
SelectedCategories = newSelectedCategories.ToList();
|
string? filterText = null;
|
||||||
var filterCriteria = SelectedCategories.Any()
|
InOperator? filterCriteria = null;
|
||||||
? new InOperator("TransferStatusType", SelectedCategories.Select(c => c.StatusValue))
|
|
||||||
: null;
|
|
||||||
|
|
||||||
|
_selectedCategories = newSelectedCategories.ToList();
|
||||||
|
|
||||||
|
if (_selectedCategories.Count > 0)
|
||||||
|
{
|
||||||
|
filterCriteria = new InOperator("TransferStatusType", _selectedCategories.Select(c => c.StatusValue));
|
||||||
|
filterText = GetFilterText(_selectedCategories.Select(x => (TransferStatusType)x.StatusValue).ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
_filterText = filterText;
|
||||||
_gridTransfer.SetFieldFilterCriteria("TransferStatusType", filterCriteria);
|
_gridTransfer.SetFieldFilterCriteria("TransferStatusType", filterCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -391,8 +404,8 @@
|
||||||
|
|
||||||
InitializeAppointments(transfers);
|
InitializeAppointments(transfers);
|
||||||
|
|
||||||
if (SelectedCategories.Count > 0)
|
if (_selectedCategories.Count > 0)
|
||||||
TagBox_ValuesChanged(SelectedCategories);
|
TagBox_ValuesChanged(_selectedCategories);
|
||||||
|
|
||||||
// if(!SelectedCategories.Any())
|
// if(!SelectedCategories.Any())
|
||||||
// SelectedCategories = [Statuses.FirstOrDefault(x => x.StatusValue == (byte)TransferStatusType.Finished)!];
|
// SelectedCategories = [Statuses.FirstOrDefault(x => x.StatusValue == (byte)TransferStatusType.Finished)!];
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@
|
||||||
|
|
||||||
_logger.Info($"DetailGridData: {ParentData.TransferToDrivers.Count}");
|
_logger.Info($"DetailGridData: {ParentData.TransferToDrivers.Count}");
|
||||||
|
|
||||||
_cars.AddRange((await AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, TiamConstClient.TransferProductId))!);
|
_cars.AddRange((await AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId]))!);
|
||||||
// AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCars, response =>
|
// AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCars, response =>
|
||||||
// {
|
// {
|
||||||
// _cars.AddRange(response.ResponseData!);
|
// _cars.AddRange(response.ResponseData!);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Data.Common;
|
||||||
using AyCode.Blazor.Components.Services;
|
using AyCode.Blazor.Components.Services;
|
||||||
using AyCode.Core;
|
using AyCode.Core;
|
||||||
using AyCode.Core.Enums;
|
using AyCode.Core.Enums;
|
||||||
|
|
@ -9,6 +10,8 @@ using AyCode.Services.SignalRs;
|
||||||
using AyCode.Utils.Extensions;
|
using AyCode.Utils.Extensions;
|
||||||
using DevExpress.Blazor;
|
using DevExpress.Blazor;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using TIAM.Core.Enums;
|
||||||
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Services;
|
using TIAM.Services;
|
||||||
using TIAMWebApp.Shared.Application.Services;
|
using TIAMWebApp.Shared.Application.Services;
|
||||||
using TIAMWebApp.Shared.Application.Utility;
|
using TIAMWebApp.Shared.Application.Utility;
|
||||||
|
|
@ -29,6 +32,25 @@ namespace TIAMSharedUI.Shared.Components.Grids
|
||||||
[Parameter] public LoggerClient Logger { get; set; }
|
[Parameter] public LoggerClient Logger { get; set; }
|
||||||
[Parameter] public string GridName { get; set; }
|
[Parameter] public string GridName { get; set; }
|
||||||
[Parameter] public Guid[]? ContextIds { get; set; }
|
[Parameter] public Guid[]? ContextIds { get; set; }
|
||||||
|
|
||||||
|
private string? _filterText = null;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string? FilterText
|
||||||
|
{
|
||||||
|
get => _filterText;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_filterText = value;
|
||||||
|
|
||||||
|
if (_dataSource != null! && _dataSource.FilterText != value)
|
||||||
|
{
|
||||||
|
_dataSource.FilterText = value;
|
||||||
|
LoadDataSourceAsync().Forget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Parameter] public AcSignalRClientBase SignalRClient { get; set; }
|
[Parameter] public AcSignalRClientBase SignalRClient { get; set; }
|
||||||
|
|
||||||
[Parameter] public int GetAllMessageTag { get; set; }
|
[Parameter] public int GetAllMessageTag { get; set; }
|
||||||
|
|
@ -83,6 +105,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
|
||||||
|
|
||||||
var crudTags = new SignalRCrudTags(GetAllMessageTag, GetItemMessageTag, AddMessageTag, UpdateMessageTag, RemoveMessageTag);
|
var crudTags = new SignalRCrudTags(GetAllMessageTag, GetItemMessageTag, AddMessageTag, UpdateMessageTag, RemoveMessageTag);
|
||||||
_dataSource = new SignalRDataSource<TDataItem>(SignalRClient, crudTags, ContextIds);
|
_dataSource = new SignalRDataSource<TDataItem>(SignalRClient, crudTags, ContextIds);
|
||||||
|
_dataSource.FilterText = FilterText;
|
||||||
|
|
||||||
Data = _dataSource;
|
Data = _dataSource;
|
||||||
|
|
||||||
|
|
@ -111,7 +134,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
|
||||||
|
|
||||||
private Task OnDataSourceLoaded()
|
private Task OnDataSourceLoaded()
|
||||||
{
|
{
|
||||||
Logger.Debug($"{_gridLogName} OnDataSourceLoaded");
|
Logger.Debug($"{_gridLogName} OnDataSourceLoaded; Count: {_dataSource.Count}");
|
||||||
|
|
||||||
Reload();
|
Reload();
|
||||||
//_dataSource.LoadItem(_dataSource.First().Id).Forget();
|
//_dataSource.LoadItem(_dataSource.First().Id).Forget();
|
||||||
|
|
@ -303,6 +326,11 @@ namespace TIAMSharedUI.Shared.Components.Grids
|
||||||
|
|
||||||
return _dataSource.Remove(dataItem, true);
|
return _dataSource.Remove(dataItem, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task LoadDataSourceAsync()
|
||||||
|
{
|
||||||
|
return _dataSource.LoadDataSourceAsync(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GridDataItemChangingEventArgs<TDataItem> : GridDataItemChangedEventArgs<TDataItem> where TDataItem : class, IId<Guid>
|
public class GridDataItemChangingEventArgs<TDataItem> : GridDataItemChangedEventArgs<TDataItem> where TDataItem : class, IId<Guid>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ public class TransferGrid : TiamGrid<Transfer>
|
||||||
{
|
{
|
||||||
public TransferGrid() : base()
|
public TransferGrid() : base()
|
||||||
{
|
{
|
||||||
GetAllMessageTag = SignalRTags.GetTransfers;
|
GetAllMessageTag = SignalRTags.GetTransfersByFilterText;//SignalRTags.GetTransfers;
|
||||||
AddMessageTag = SignalRTags.AddTransfer;
|
AddMessageTag = SignalRTags.AddTransfer;
|
||||||
UpdateMessageTag = SignalRTags.UpdateTransfer;
|
UpdateMessageTag = SignalRTags.UpdateTransfer;
|
||||||
RemoveMessageTag = SignalRTags.RemoveTransfer;
|
RemoveMessageTag = SignalRTags.RemoveTransfer;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using AyCode.Core.Loggers;
|
using AyCode.Core.Loggers;
|
||||||
using AyCode.Services.SignalRs;
|
using AyCode.Services.SignalRs;
|
||||||
|
|
@ -22,6 +23,12 @@ using AyCode.Core.Extensions;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
using TIAMSharedUI.Shared.Components.Grids;
|
using TIAMSharedUI.Shared.Components.Grids;
|
||||||
using AyCode.Core.Helpers;
|
using AyCode.Core.Helpers;
|
||||||
|
using System.Linq;
|
||||||
|
using DevExpress.Data.Filtering;
|
||||||
|
using DevExpress.Data.Linq;
|
||||||
|
using DevExpress.Data.Linq.Helpers;
|
||||||
|
using System;
|
||||||
|
using TIAM.Database.DbSets.Transfers;
|
||||||
|
|
||||||
namespace TIAMWebApp.Server.Controllers
|
namespace TIAMWebApp.Server.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -540,12 +547,12 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route(APIUrls.GetTransfersRouteName)]
|
[Route(APIUrls.GetTransfersRouteName)]
|
||||||
[SignalR(SignalRTags.GetTransfers)]
|
[SignalR(SignalRTags.GetTransfers)]
|
||||||
public async Task<string> GetTransfers()
|
public async Task<List<Transfer>> GetTransfers()
|
||||||
{
|
{
|
||||||
//var token = _authService.GetAuthTokenFromRequest(Request);
|
//var token = _authService.GetAuthTokenFromRequest(Request);
|
||||||
//_logger.Detail(token);
|
//_logger.Detail(token);
|
||||||
|
|
||||||
var result = await _adminDal.GetTransfersJsonAsync();
|
var result = await _adminDal.GetTransfersAsync();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -559,6 +566,15 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetTransfersByFilterText)]
|
||||||
|
public async Task<List<Transfer>> GetTransfersByFilterText(Guid userId, string criteriaOperatorText)
|
||||||
|
{
|
||||||
|
if (criteriaOperatorText.IsNullOrWhiteSpace()) return await GetTransfers();
|
||||||
|
|
||||||
|
var results = await _adminDal.GetTransfersByFilterAsync(CriteriaOperator.Parse(criteriaOperatorText));
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route(APIUrls.GetTransferByIdRouteName)]
|
[Route(APIUrls.GetTransferByIdRouteName)]
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
using Microsoft.AspNetCore.ResponseCompression;
|
using Microsoft.AspNetCore.ResponseCompression;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
|
@ -44,7 +45,7 @@ builder.Services.AddScoped<MessageAPIController>();
|
||||||
builder.Services.AddScoped<ProfileAPIController>();
|
builder.Services.AddScoped<ProfileAPIController>();
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddSignalR(options => options.MaximumReceiveMessageSize = 256 * 1024);//.AddMessagePackProtocol(options => options.SerializerOptions = MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData));
|
builder.Services.AddSignalR(options => options.MaximumReceiveMessageSize = 102400 * 1024);//.AddMessagePackProtocol(options => options.SerializerOptions = MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData));
|
||||||
|
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,16 @@ using TIAM.Entities.ServiceProviders;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using MessagePack;
|
using MessagePack;
|
||||||
using TIAM.Entities.Addresses;
|
using TIAM.Entities.Addresses;
|
||||||
using TIAM.Entities.Profiles;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using AutoMapper;
|
||||||
|
using DevExpress.Pdf.Native.BouncyCastle.Security;
|
||||||
using TIAM.Entities.Emails;
|
using TIAM.Entities.Emails;
|
||||||
using TIAM.Services.Server;
|
using TIAM.Services.Server;
|
||||||
|
using Profile = TIAM.Entities.Profiles.Profile;
|
||||||
|
using Serialize.Linq.Serializers;
|
||||||
|
|
||||||
namespace TIAMWebApp.Server.Services;
|
namespace TIAMWebApp.Server.Services;
|
||||||
|
|
||||||
|
|
@ -37,7 +42,7 @@ public static class ExtensionMethods
|
||||||
|
|
||||||
public class MethodInfoModel<TAttribute> where TAttribute : TagAttribute
|
public class MethodInfoModel<TAttribute> where TAttribute : TagAttribute
|
||||||
{
|
{
|
||||||
public Type? ParameterType { get; init; } = null;
|
public ParameterInfo[]? ParamInfos { get; init; } = null;
|
||||||
public TAttribute Attribute { get; init; }
|
public TAttribute Attribute { get; init; }
|
||||||
public MethodInfo MethodInfo { get; init; }
|
public MethodInfo MethodInfo { get; init; }
|
||||||
|
|
||||||
|
|
@ -51,8 +56,7 @@ public class MethodInfoModel<TAttribute> where TAttribute : TagAttribute
|
||||||
//if (parameters.Length > 1)
|
//if (parameters.Length > 1)
|
||||||
// throw new Exception("MethodInfoModel; parameters.Length > 1");
|
// throw new Exception("MethodInfoModel; parameters.Length > 1");
|
||||||
|
|
||||||
if (parameters.Length > 0)
|
ParamInfos = parameters;
|
||||||
ParameterType = parameters[0].ParameterType;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,27 +152,59 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
|
||||||
|
|
||||||
logText = $"Found dynamic method for the tag! tag: {messageTag}; method: {methodsByDeclaringObject.InstanceObject.GetType().Name}.{methodInfoModel.MethodInfo.Name}";
|
logText = $"Found dynamic method for the tag! tag: {messageTag}; method: {methodsByDeclaringObject.InstanceObject.GetType().Name}.{methodInfoModel.MethodInfo.Name}";
|
||||||
|
|
||||||
if (methodInfoModel.ParameterType != null)
|
if (methodInfoModel.ParamInfos is { Length: > 0 })
|
||||||
{
|
{
|
||||||
_logger.Debug($"{logText}({methodInfoModel.ParameterType.Name})");
|
_logger.Debug($"{logText}({string.Join(", ", methodInfoModel.ParamInfos.Select(x => x.Name))})");
|
||||||
|
|
||||||
//paramValues = new object[1];
|
paramValues = new object[methodInfoModel.ParamInfos.Length];
|
||||||
|
|
||||||
if (methodInfoModel.ParameterType == typeof(Guid) || methodInfoModel.ParameterType == typeof(Guid?))
|
var firstParamType = methodInfoModel.ParamInfos[0].ParameterType;
|
||||||
|
if (methodInfoModel.ParamInfos.Length > 1 || firstParamType == typeof(string) || firstParamType == typeof(Guid) || firstParamType == typeof(Guid?))
|
||||||
{
|
{
|
||||||
var msg = message!.MessagePackTo<SignalPostJsonDataMessage<IdMessage>>();
|
var msg = message!.MessagePackTo<SignalPostJsonDataMessage<IdMessage>>();
|
||||||
|
|
||||||
paramValues = new object[msg.PostData.Ids.Count];
|
|
||||||
|
|
||||||
for (var i = 0; i < msg.PostData.Ids.Count; i++)
|
for (var i = 0; i < msg.PostData.Ids.Count; i++)
|
||||||
{
|
{
|
||||||
var id = msg.PostData.Ids[i];
|
//var obj = (string)msg.PostData.Ids[i];
|
||||||
if (id.IsNullOrEmpty()) throw new NullReferenceException($"PostData.Id.IsNullOrEmpty(); Ids: {msg.PostData.Ids}");
|
//if (msg.PostData.Ids[i] is Guid id)
|
||||||
|
//{
|
||||||
|
// if (id.IsNullOrEmpty()) throw new NullReferenceException($"PostData.Id.IsNullOrEmpty(); Ids: {msg.PostData.Ids}");
|
||||||
|
// paramValues[i] = id;
|
||||||
|
//}
|
||||||
|
//else if (Guid.TryParse(obj, out id))
|
||||||
|
//{
|
||||||
|
// if (id.IsNullOrEmpty()) throw new NullReferenceException($"PostData.Id.IsNullOrEmpty(); Ids: {msg.PostData.Ids}");
|
||||||
|
// paramValues[i] = id;
|
||||||
|
//}
|
||||||
|
//else if (Enum.TryParse(methodInfoModel.ParameterType, obj, out var enumObj))
|
||||||
|
//{
|
||||||
|
// paramValues[i] = enumObj;
|
||||||
|
//}
|
||||||
|
//else paramValues[i] = Convert.ChangeType(obj, methodInfoModel.ParameterType);
|
||||||
|
|
||||||
|
var obj = msg.PostData.Ids[i];
|
||||||
|
//var config = new MapperConfiguration(cfg =>
|
||||||
|
//{
|
||||||
|
// cfg.CreateMap(obj.GetType(), methodInfoModel.ParameterType);
|
||||||
|
//});
|
||||||
|
|
||||||
|
//var mapper = new Mapper(config);
|
||||||
|
//paramValues[i] = mapper.Map(obj, methodInfoModel.ParameterType);
|
||||||
|
|
||||||
|
//paramValues[i] = obj;
|
||||||
|
|
||||||
|
var a = Array.CreateInstance(methodInfoModel.ParamInfos[i].ParameterType, 1);
|
||||||
|
|
||||||
|
if (methodInfoModel.ParamInfos[i].ParameterType == typeof(Expression))
|
||||||
|
{
|
||||||
|
var serializer = new ExpressionSerializer(new JsonSerializer());
|
||||||
|
paramValues[i] = serializer.DeserializeText((string)(obj.JsonTo(a.GetType()) as Array)?.GetValue(0)!);
|
||||||
|
}
|
||||||
|
else paramValues[i] = (obj.JsonTo(a.GetType()) as Array)?.GetValue(0)!;
|
||||||
|
|
||||||
paramValues[i] = msg.PostData.Ids[i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else paramValues = [message!.MessagePackTo<SignalPostJsonDataMessage<object>>(MessagePackSerializerOptions.Standard).PostDataJson.JsonTo(methodInfoModel.ParameterType)!];
|
else paramValues[0] = message!.MessagePackTo<SignalPostJsonDataMessage<object>>(MessagePackSerializerOptions.Standard).PostDataJson.JsonTo(firstParamType)!;
|
||||||
}
|
}
|
||||||
else _logger.Debug($"{logText}()");
|
else _logger.Debug($"{logText}()");
|
||||||
|
|
||||||
|
|
@ -182,7 +218,8 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
|
||||||
switch (messageTag)
|
switch (messageTag)
|
||||||
{
|
{
|
||||||
case SignalRTags.GetAddress:
|
case SignalRTags.GetAddress:
|
||||||
var id = message!.MessagePackTo<SignalPostJsonDataMessage<IdMessage>>().PostData.Ids[0];
|
//var id = Guid.Parse((string)message!.MessagePackTo<SignalPostJsonDataMessage<IdMessage>>().PostData.Ids[0]);
|
||||||
|
var id = message!.MessagePackTo<SignalPostJsonDataMessage<IdMessage>>().PostData.Ids[0].JsonTo<Guid[]>()![0];
|
||||||
|
|
||||||
var address = await _adminDal.GetAddressByIdAsync(id);
|
var address = await _adminDal.GetAddressByIdAsync(id);
|
||||||
await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, address), requestId);
|
await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, address), requestId);
|
||||||
|
|
@ -190,7 +227,8 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case SignalRTags.GetAddressesByContextId:
|
case SignalRTags.GetAddressesByContextId:
|
||||||
id = message!.MessagePackTo<SignalPostJsonDataMessage<IdMessage>>().PostData.Ids[0];
|
//id = Guid.Parse((string)message!.MessagePackTo<SignalPostJsonDataMessage<IdMessage>>().PostData.Ids[0]);
|
||||||
|
id = message!.MessagePackTo<SignalPostJsonDataMessage<IdMessage>>().PostData.Ids[0].JsonTo<Guid[]>()![0];
|
||||||
|
|
||||||
address = await _adminDal.GetAddressByIdAsync(id);
|
address = await _adminDal.GetAddressByIdAsync(id);
|
||||||
await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, new List<Address> { address! }), requestId);
|
await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, new List<Address> { address! }), requestId);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GoogleApi" Version="5.4.3" />
|
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||||
|
<PackageReference Include="GoogleApi" Version="5.4.4" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.6" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.6" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="8.0.6" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="8.0.6" />
|
||||||
|
|
|
||||||
|
|
@ -123,13 +123,13 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
callback.Invoke(response.ResponseData);
|
callback.Invoke(response.ResponseData);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}, id);
|
}, [id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//17.
|
//17.
|
||||||
public async Task<Dictionary<Guid, string>?> GetPropertiesByOwnerIdAsync(Guid id)
|
public async Task<Dictionary<Guid, string>?> GetPropertiesByOwnerIdAsync(Guid id)
|
||||||
{
|
{
|
||||||
var companyPropertiesByOwner = await _adminSignalRClient.GetByIdAsync<Dictionary<Guid, string>>(SignalRTags.GetPropertiesByOwnerId, id);
|
var companyPropertiesByOwner = await _adminSignalRClient.GetByIdAsync<Dictionary<Guid, string>>(SignalRTags.GetPropertiesByOwnerId, [id]);
|
||||||
if (companyPropertiesByOwner != null) _logger.DetailConditional($"companyPropertiesByOwner: {string.Join("; ", companyPropertiesByOwner.Values)}");
|
if (companyPropertiesByOwner != null) _logger.DetailConditional($"companyPropertiesByOwner: {string.Join("; ", companyPropertiesByOwner.Values)}");
|
||||||
|
|
||||||
return companyPropertiesByOwner;
|
return companyPropertiesByOwner;
|
||||||
|
|
@ -157,7 +157,7 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
//18.
|
//18.
|
||||||
public async Task<Company?> GetServiceProviderByIdAsync(Guid id)
|
public async Task<Company?> GetServiceProviderByIdAsync(Guid id)
|
||||||
{
|
{
|
||||||
var company = await _adminSignalRClient.GetByIdAsync<Company>(SignalRTags.GetCompany, id);
|
var company = await _adminSignalRClient.GetByIdAsync<Company>(SignalRTags.GetCompany, [id]);
|
||||||
if (company != null) _logger.DetailConditional($"company: {company.Name}");
|
if (company != null) _logger.DetailConditional($"company: {company.Name}");
|
||||||
|
|
||||||
return company;
|
return company;
|
||||||
|
|
@ -249,7 +249,7 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
|
|
||||||
public async Task<Product> GetProductByIdAsync(Guid id)
|
public async Task<Product> GetProductByIdAsync(Guid id)
|
||||||
{
|
{
|
||||||
var result = await _adminSignalRClient.GetByIdAsync<Product>(SignalRTags.GetProductById);
|
var result = await _adminSignalRClient.GetByIdAsync<Product>(SignalRTags.GetProductById, [id]);
|
||||||
|
|
||||||
//var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetProductById}";
|
//var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetProductById}";
|
||||||
//var response = await http.GetFromJsonAsync(url, typeof(Product));
|
//var response = await http.GetFromJsonAsync(url, typeof(Product));
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@ using AyCode.Core.Loggers;
|
||||||
using AyCode.Services.Loggers;
|
using AyCode.Services.Loggers;
|
||||||
using AyCode.Services.SignalRs;
|
using AyCode.Services.SignalRs;
|
||||||
using Azure;
|
using Azure;
|
||||||
|
using DevExpress.Data.Filtering;
|
||||||
|
using DevExpress.Data.Linq;
|
||||||
|
using DevExpress.Data.Linq.Helpers;
|
||||||
|
using TIAM.Core.Enums;
|
||||||
using TIAM.Core.Loggers;
|
using TIAM.Core.Loggers;
|
||||||
using TIAM.Database.Test;
|
using TIAM.Database.Test;
|
||||||
using TIAM.Entities.ServiceProviders;
|
using TIAM.Entities.ServiceProviders;
|
||||||
|
|
@ -35,7 +39,7 @@ namespace Tiam.Services.Client.Tests
|
||||||
public async Task GetCompanyTest_ReturnCompany_WhenHasCompany(string companyIdString)
|
public async Task GetCompanyTest_ReturnCompany_WhenHasCompany(string companyIdString)
|
||||||
{
|
{
|
||||||
var companyId = Guid.Parse(companyIdString);
|
var companyId = Guid.Parse(companyIdString);
|
||||||
var company = await _signalRClient.GetByIdAsync<Company>(SignalRTags.GetCompany, companyId);
|
var company = await _signalRClient.GetByIdAsync<Company>(SignalRTags.GetCompany, [companyId]);
|
||||||
|
|
||||||
Assert.IsNotNull(company);
|
Assert.IsNotNull(company);
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +59,7 @@ namespace Tiam.Services.Client.Tests
|
||||||
company = response.ResponseData;
|
company = response.ResponseData;
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}, companyId);
|
}, [companyId]);
|
||||||
|
|
||||||
await TaskHelper.WaitToAsync(() => company != null, 5000, 50);
|
await TaskHelper.WaitToAsync(() => company != null, 5000, 50);
|
||||||
|
|
||||||
|
|
@ -115,7 +119,7 @@ namespace Tiam.Services.Client.Tests
|
||||||
transferDest = await _signalRClient.PostDataAsync(SignalRTags.CreateTransferDestination, transferDest);
|
transferDest = await _signalRClient.PostDataAsync(SignalRTags.CreateTransferDestination, transferDest);
|
||||||
Assert.IsNotNull(transferDest);
|
Assert.IsNotNull(transferDest);
|
||||||
|
|
||||||
transferDest = await _signalRClient.GetByIdAsync<TransferDestination>(SignalRTags.GetTransferDestinationById, transferDestId);
|
transferDest = await _signalRClient.GetByIdAsync<TransferDestination>(SignalRTags.GetTransferDestinationById,[transferDestId]);
|
||||||
|
|
||||||
Assert.IsNotNull(transferDest);
|
Assert.IsNotNull(transferDest);
|
||||||
Assert.IsNotNull(transferDest.Address);
|
Assert.IsNotNull(transferDest.Address);
|
||||||
|
|
@ -136,7 +140,7 @@ namespace Tiam.Services.Client.Tests
|
||||||
|
|
||||||
await _signalRClient.PostDataAsync(SignalRTags.RemoveTransferDestination, transferDest); //mielõbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
await _signalRClient.PostDataAsync(SignalRTags.RemoveTransferDestination, transferDest); //mielõbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||||
|
|
||||||
transferDest = await _signalRClient.GetByIdAsync<TransferDestination>(SignalRTags.GetTransferDestinationById, transferDestId);
|
transferDest = await _signalRClient.GetByIdAsync<TransferDestination>(SignalRTags.GetTransferDestinationById, [transferDestId]);
|
||||||
Assert.IsNull(transferDest); //a korábbi törlés miatt NULL kell legyen - J.
|
Assert.IsNull(transferDest); //a korábbi törlés miatt NULL kell legyen - J.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +159,7 @@ namespace Tiam.Services.Client.Tests
|
||||||
transferDestinationToProduct = await _signalRClient.PostDataAsync(SignalRTags.CreateTransferDestinationToProduct, transferDestinationToProduct);
|
transferDestinationToProduct = await _signalRClient.PostDataAsync(SignalRTags.CreateTransferDestinationToProduct, transferDestinationToProduct);
|
||||||
Assert.IsNotNull(transferDestinationToProduct);
|
Assert.IsNotNull(transferDestinationToProduct);
|
||||||
|
|
||||||
transferDestinationToProduct = await _signalRClient.GetByIdAsync<TransferDestinationToProduct>(SignalRTags.GetTransferDestinationToProductById, transferDestinationToProductId);
|
transferDestinationToProduct = await _signalRClient.GetByIdAsync<TransferDestinationToProduct>(SignalRTags.GetTransferDestinationToProductById, [transferDestinationToProductId]);
|
||||||
|
|
||||||
Assert.IsNotNull(transferDestinationToProduct);
|
Assert.IsNotNull(transferDestinationToProduct);
|
||||||
Assert.IsNotNull(transferDestinationToProduct.TransferDestination);
|
Assert.IsNotNull(transferDestinationToProduct.TransferDestination);
|
||||||
|
|
@ -169,20 +173,59 @@ namespace Tiam.Services.Client.Tests
|
||||||
Assert.IsTrue((int)transferDestinationToProduct.Price == 20000);
|
Assert.IsTrue((int)transferDestinationToProduct.Price == 20000);
|
||||||
Assert.IsTrue(transferDestinationToProduct.Id == transferDestinationToProductId, "transferDestinationToProduct.Id != transferDestinationToProductId");
|
Assert.IsTrue(transferDestinationToProduct.Id == transferDestinationToProductId, "transferDestinationToProduct.Id != transferDestinationToProductId");
|
||||||
|
|
||||||
var transferDestinationToProducts = await _signalRClient.GetByIdAsync<List<TransferDestinationToProduct>>(SignalRTags.GetTransferDestinationToProductsByTransferDestinationId, transferDestId);
|
var transferDestinationToProducts = await _signalRClient.GetByIdAsync<List<TransferDestinationToProduct>>(SignalRTags.GetTransferDestinationToProductsByTransferDestinationId, [transferDestId]);
|
||||||
Assert.IsNotNull(transferDestinationToProducts);
|
Assert.IsNotNull(transferDestinationToProducts);
|
||||||
Assert.IsTrue(transferDestinationToProducts.Count > 0);
|
Assert.IsTrue(transferDestinationToProducts.Count > 0);
|
||||||
Assert.IsTrue(transferDestinationToProducts.All(x=>x.TransferDestinationId == transferDestId));
|
Assert.IsTrue(transferDestinationToProducts.All(x=>x.TransferDestinationId == transferDestId));
|
||||||
|
|
||||||
transferDestinationToProducts = await _signalRClient.GetByIdAsync<List<TransferDestinationToProduct>>(SignalRTags.GetTransferDestinationToProductsByProductId, productId);
|
transferDestinationToProducts = await _signalRClient.GetByIdAsync<List<TransferDestinationToProduct>>(SignalRTags.GetTransferDestinationToProductsByProductId, [productId]);
|
||||||
Assert.IsNotNull(transferDestinationToProducts);
|
Assert.IsNotNull(transferDestinationToProducts);
|
||||||
Assert.IsTrue(transferDestinationToProducts.Count > 0);
|
Assert.IsTrue(transferDestinationToProducts.Count > 0);
|
||||||
Assert.IsTrue(transferDestinationToProducts.All(x=>x.ProductId == productId));
|
Assert.IsTrue(transferDestinationToProducts.All(x=>x.ProductId == productId));
|
||||||
|
|
||||||
await _signalRClient.PostDataAsync(SignalRTags.RemoveTransferDestinationToProduct, transferDestinationToProduct); //mielõbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
await _signalRClient.PostDataAsync(SignalRTags.RemoveTransferDestinationToProduct, transferDestinationToProduct); //mielõbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||||
|
|
||||||
transferDestinationToProduct = await _signalRClient.GetByIdAsync<TransferDestinationToProduct>(SignalRTags.GetTransferDestinationToProductById, transferDestinationToProductId);
|
transferDestinationToProduct = await _signalRClient.GetByIdAsync<TransferDestinationToProduct>(SignalRTags.GetTransferDestinationToProductById, [transferDestinationToProductId]);
|
||||||
Assert.IsNull(transferDestinationToProduct); //a korábbi törlés miatt NULL kell legyen - J.
|
Assert.IsNull(transferDestinationToProduct); //a korábbi törlés miatt NULL kell legyen - J.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DataTestMethod]
|
||||||
|
public async Task FilterExpressionTest_WhenTransfersFiletered()
|
||||||
|
{
|
||||||
|
var userId = Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00");
|
||||||
|
|
||||||
|
var statuses = new List<TransferStatusType>() { TransferStatusType.OrderConfirmed, TransferStatusType.AssignedToDriver, TransferStatusType.Finished };
|
||||||
|
var converter = new CriteriaToExpressionConverter();
|
||||||
|
var criteriaString = CriteriaOperator.FromLambda<Transfer>(x => x.UserId == userId && statuses.Contains(x.TransferStatusType)).ToString();
|
||||||
|
|
||||||
|
//var criteria = CriteriaOperator.Parse(criteriaString);
|
||||||
|
|
||||||
|
//_signalRDataSource.AsQueryable().Expression.
|
||||||
|
//var filteredData = new List<Transfer>().AsQueryable().AppendWhere(converter, criteria) as IQueryable<Transfer>;
|
||||||
|
|
||||||
|
var transfers = await _signalRClient.GetAllAsync<List<Transfer>>(SignalRTags.GetTransfersByFilterText, [Guid.NewGuid(), criteriaString]);
|
||||||
|
//var transfers = await _signalRClient.GetAllAsync<List<Transfer>>(SignalRTags.GetTransfersByExpression, [userId, filteredData!.Expression]);
|
||||||
|
|
||||||
|
Assert.IsNotNull(transfers);
|
||||||
|
Assert.IsTrue(transfers.Count > 0);
|
||||||
|
Assert.IsTrue(transfers.All(x=>statuses.Contains(x.TransferStatusType)));
|
||||||
|
|
||||||
|
//var converter = new CriteriaToExpressionConverter();
|
||||||
|
////CriteriaOperator critOps = CriteriaOperator.Parse(tdashboard.EmployeeFilter);
|
||||||
|
//var criteriaString = CriteriaOperator.FromLambda<Transfer>(x => x.LuggageCount == 1).ToString();
|
||||||
|
|
||||||
|
////var json = criteria.AsQueryable().Expression.ToJson();
|
||||||
|
////criteria = JsonConvert.DeserializeObject<Expression<Transfer>(json);
|
||||||
|
//var criteria = CriteriaOperator.Parse(criteriaString);
|
||||||
|
|
||||||
|
////_signalRDataSource.AsQueryable().Expression.
|
||||||
|
//var filteredData = _signalRDataSource.AsQueryable().AppendWhere(converter, criteria) as IQueryable<Transfer>;
|
||||||
|
|
||||||
|
//Assert.IsNotNull(filteredData);
|
||||||
|
//var filteredTransfers = _signalRDataSource.AsQueryable().Provider.CreateQuery<Transfer>(filteredData.Expression).ToList();
|
||||||
|
|
||||||
|
//Assert.IsNotNull(filteredTransfers);
|
||||||
|
//Assert.IsTrue(filteredTransfers.All(x => x.LuggageCount == 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +75,7 @@ namespace Tiam.Services.Client.Tests
|
||||||
await _signalRDataSource.SaveItem(transferId, TrackingState.Update);
|
await _signalRDataSource.SaveItem(transferId, TrackingState.Update);
|
||||||
Assert.IsTrue(transfer.LuggageCount == luggageCount);
|
Assert.IsTrue(transfer.LuggageCount == luggageCount);
|
||||||
|
|
||||||
var dbTransfer = await _signalRDataSource.SignalRClient.GetByIdAsync<Transfer>(SignalRTags.GetTransfer, transferId);
|
var dbTransfer = await _signalRDataSource.SignalRClient.GetByIdAsync<Transfer>(SignalRTags.GetTransfer, [transferId]);
|
||||||
|
|
||||||
Assert.IsNotNull(dbTransfer);
|
Assert.IsNotNull(dbTransfer);
|
||||||
Assert.IsTrue(dbTransfer.LuggageCount == luggageCount);
|
Assert.IsTrue(dbTransfer.LuggageCount == luggageCount);
|
||||||
|
|
@ -92,7 +92,6 @@ namespace Tiam.Services.Client.Tests
|
||||||
//var json = criteria.AsQueryable().Expression.ToJson();
|
//var json = criteria.AsQueryable().Expression.ToJson();
|
||||||
//criteria = JsonConvert.DeserializeObject<Expression<Transfer>(json);
|
//criteria = JsonConvert.DeserializeObject<Expression<Transfer>(json);
|
||||||
var criteria = CriteriaOperator.Parse(criteriaString);
|
var criteria = CriteriaOperator.Parse(criteriaString);
|
||||||
|
|
||||||
//_signalRDataSource.AsQueryable().Expression.
|
//_signalRDataSource.AsQueryable().Expression.
|
||||||
var filteredData = _signalRDataSource.AsQueryable().AppendWhere(converter, criteria) as IQueryable<Transfer>;
|
var filteredData = _signalRDataSource.AsQueryable().AppendWhere(converter, criteria) as IQueryable<Transfer>;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue