Compare commits

..

No commits in common. "daa0b960320a69cc52f688d264cfa5e38d9ca6a2" and "7a6fe38b9f82935a50a98d40461fce83937d9d31" have entirely different histories.

17 changed files with 54 additions and 145 deletions

View File

@ -942,11 +942,5 @@
<SelectedItem Type="Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlUser, Microsoft.Data.Tools.Schema.Sql, Version=162.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>Anata_Development_Team</Name>
</SelectedItem>
<SelectedItem Type="Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlFile, Microsoft.Data.Tools.Schema.Sql, Version=162.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>TIAM_DEV</Name>
</SelectedItem>
<SelectedItem Type="Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlFile, Microsoft.Data.Tools.Schema.Sql, Version=162.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>TIAM_DEV_log</Name>
</SelectedItem>
</ExcludedSourceElements>
</SchemaComparison>

View File

@ -371,7 +371,7 @@ namespace TIAM.Database.Test
Assert.IsTrue(company.Id == companyId);
company.OwnerId = userId;
Assert.IsNotNull(await Dal.UpdateCompanyAsync(company));
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
company = await Dal.GetCompanyByIdAsync(companyId);
@ -380,7 +380,7 @@ namespace TIAM.Database.Test
Assert.IsTrue(company.UserToServiceProviders.Any(x=>x.UserId == userId && x.ServiceProviderId == companyId));
company.CommissionPercent = 5;
Assert.IsNotNull(await Dal.UpdateCompanyAsync(company));
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
var addressId = company.Profile.AddressId;
Assert.IsTrue(await Dal.RemoveCompanyAsync(company.Id)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.

View File

@ -30,7 +30,6 @@ using DevExpress.Data.Linq;
using DevExpress.Data.Linq.Helpers;
using TIAM.Database.DbSets.Drivers;
using AyCode.Entities.Server.LogItems;
using AyCode.Interfaces.Entities;
namespace TIAM.Database.DataLayers.Admins
{
@ -347,27 +346,30 @@ namespace TIAM.Database.DataLayers.Admins
//}
//14. (IserviceProviderDataService) Update service provider
//public Task<bool> UpdateCompanyAsync(Company company)
//{
// var result = NewUpdateCompanyAsync(company);
// return Task.FromResult(result.Result != null && !result.Result.Id.IsNullOrEmpty());
//}
public Task<Company?> UpdateCompanyAsync(Company company) => UpdateSafeAsync(company, (ctx, safeCompany) =>
public Task<bool> UpdateCompanyAsync(Company company)
{
ctx.Entry(safeCompany.Profile).CurrentValues.SetValues(company.Profile);
return ctx.UpdateCompany(safeCompany);
var result = NewUpdateCompanyAsync(company);
if (result.Result != null || (result.Result).Id != Guid.Empty)
{
return Task.FromResult(true);
}
else
{
return Task.FromResult(false);
}
}
public Task<Company?> NewUpdateCompanyAsync(Company company) => UpdateSafeAsync(company, (ctx, safeCompany) => ctx.UpdateCompany(safeCompany));
public Task<bool> UpdateCompanyAsync(Company company, Profile profile)
=> TransactionAsync(ctx =>
{
ctx.UpdateProfile(profile);
ctx.SaveChanges();
return ctx.UpdateCompany(company);
});
//public Task<bool> UpdateCompanyAsync(Company company, Profile profile)
// => TransactionAsync(ctx =>
// {
// ctx.UpdateProfile(profile);
// ctx.SaveChanges();
// return ctx.UpdateCompany(company);
// });
//13. (IserviceProviderDataService) delete service provider
public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId));
@ -683,8 +685,8 @@ namespace TIAM.Database.DataLayers.Admins
#region Logs
public Task<List<AcLogItem>> GetLogItemsAsync(int takeCount, DateTime utcFromDate, DateTime utcToDate) => SessionAsync(ctx => ctx.LogItems.Where(x => x.TimeStampUtc.Date >= utcFromDate.Date && x.TimeStampUtc.Date <= utcToDate.Date).Take(takeCount).ToList());
public Task<List<AcLogItem>> GetLogItemsByFilterAsync(CriteriaOperator criteriaOperator, int takeCount, DateTime utcFromDate, DateTime utcToDate) => SessionAsync(ctx => (ctx.LogItems.Where(x => x.TimeStampUtc.Date >= utcFromDate.Date && x.TimeStampUtc.Date <= utcToDate.Date).AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator).Take(takeCount) as IQueryable<AcLogItem>)!.ToList());
public Task<List<AcLogItem>> GetLogItemsAsync(int takeCount = 500) => SessionAsync(ctx => ctx.LogItems.Take(takeCount).ToList());
public Task<List<AcLogItem>> GetLogItemsByFilterAsync(CriteriaOperator criteriaOperator, int takeCount = 500) => SessionAsync(ctx => (ctx.LogItems.AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator).Take(takeCount) as IQueryable<AcLogItem>)!.ToList());
#endregion
}

View File

@ -41,7 +41,7 @@
<CompanyGrid @ref="_gridCompany"
Logger="_logger"
SignalRClient="AdminSignalRClient"
ContextIds="contextIds.Cast<object>().ToArray()"
ContextIds="contextIds"
GetAllMessageTag="SignalRTags.GetCompaniesByContextId"
PageSize="12"
ValidationEnabled="false"

View File

@ -29,7 +29,7 @@
<div class="w-100 ch-220">
<CompanyByIdDetailGrid @ref="_gridCompany"
Context="myContext"
ContextIds="@(CompanyId?.Cast<object>().ToArray())"
ContextIds="@CompanyId"
Logger="_logger"
SignalRClient="AdminSignalRClient"
CustomizeElement="Grid_CustomizeElement"

View File

@ -22,7 +22,7 @@
<AddressDetailGrid @ref="_addressGrid"
ContextIds="new object[] {ParentData.AddressId}"
ContextIds="new[] {ParentData.AddressId}"
DataSource="DataSource"
Logger="_logger"
SignalRClient="AdminSignalRClient"

View File

@ -60,7 +60,7 @@
<UserProductMappingDriverGrid Logger="_logger"
@ref="_driverGrid"
ContextIds="new object[] {ContextId}"
ContextIds="new [] {ContextId}"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"

View File

@ -14,10 +14,8 @@
@using AyCode.Services.Loggers
@using AyCode.Core
@using AyCode.Core.Extensions
@using AyCode.Core.Helpers
@using Castle.Components.DictionaryAdapter
@using DevExpress.Data.Filtering
@using DevExpress.DirectX.Common.Direct2D
@using TIAM.Core.Enums
@inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@ -29,7 +27,6 @@
@* VirtualScrollingEnabled="true" *@
<LogViewerGrid Logger="_logger"
@ref="_logViewerGrid"
ContextIds="_contextParams"
SignalRClient="AdminSignalRClient"
FilterText="@_filterText"
ShowGroupPanel="true"
@ -59,60 +56,16 @@
var a = ((LogItemViewerModel)context.DataItem);
}
<div><p>@($"{a.CategoryName}->{a.CallerName}")</p></div>
<div><p>@($"{a.Text}")</p></div>
<div><p>@($"{a.Text}")</p></div><br />
<div style="font-weight: bold;">Exception:</div>
<div><p style="text-wrap: wrap;">@a.Exception</p></div>
</DetailRowTemplate>
<ToolbarTemplate>
<DxGridLayout>
<Rows>
<DxGridLayoutRow />
</Rows>
<Columns>
<DxGridLayoutColumn />
<DxGridLayoutColumn Width="130" />
<DxGridLayoutColumn Width="130" />
<DxGridLayoutColumn Width="100" />
<DxGridLayoutColumn Width="auto" />
</Columns>
<Items>
<DxGridLayoutItem Row="0" Column="0">
<Template>
<div>
<DxTagBox Data="@(Enum.GetValues<LogLevel>().ToList())" Values="@_selectedLogLevels"
NullText="Select status type..." ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto" aria-label="Select status type"
ValuesChanged="(IEnumerable<LogLevel> values) => TagBox_ValuesChanged(values)" />
</Template>
</DxGridLayoutItem>
<DxGridLayoutItem Row="0" Column="1">
<Template>
<DxDateEdit Date="@_fromDate"
NullText="Select fromDate..."
DisplayFormat="d"
DateChanged="@((DateTime fromDate) => OnValueChangedStartDate(fromDate))"
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Never">
</DxDateEdit>
</Template>
</DxGridLayoutItem>
<DxGridLayoutItem Row="0" Column="2">
<Template>
<DxDateEdit Date="@_toDate"
NullText="select toDate..."
DisplayFormat="d"
DateChanged="@((DateTime toDate) => OnValueChangedEndDate(toDate))"
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Never">
</DxDateEdit>
</Template>
</DxGridLayoutItem>
<DxGridLayoutItem Row="0" Column="3">
<Template>
<DxSpinEdit Value="@_takeCount" CssClass="dx-demo-editor-width" MinValue="0" Increment="500" BindValueMode="BindValueMode.OnDelayedInput" InputDelay="1500"
ValueChanged="@((int newValue) => OnValueChangedTakeCount(newValue))">
</DxSpinEdit>
</Template>
</DxGridLayoutItem>
</Items>
</DxGridLayout>
</div>
</ToolbarTemplate>
</LogViewerGrid>
@ -120,13 +73,6 @@
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private LogViewerGrid _logViewerGrid;
private static DateTime _fromDate = DateTime.Today.AddDays(-2);
private static DateTime _toDate = DateTime.Today;
private static int _takeCount = 250;
private object[] _contextParams = new object[3] { _takeCount, _fromDate, _toDate };
private LoggerClient<LogViewerGridComponent> _logger;
private static List<LogLevel> _selectedLogLevels = [LogLevel.Error, LogLevel.Warning, LogLevel.Suggest];
private static string _filterText = GetFilterText(_selectedLogLevels);
@ -158,39 +104,6 @@
_logViewerGrid.SetFieldFilterCriteria(nameof(LogLevel), filterCriteria);
}
private async Task OnValueChangedTakeCount(int value)
{
if (_takeCount == value) return;
_takeCount = value;
_contextParams[0] = _takeCount;
await _logViewerGrid.LoadDataSourceAsync();
}
private async Task OnValueChangedStartDate(DateTime value)
{
if (_fromDate == value) return;
_fromDate = value;
if (_fromDate.Date > DateTime.Today.Date) _fromDate = DateTime.Today;
_contextParams[1] = _fromDate;
if (_fromDate.Date > _toDate.Date) return;
await _logViewerGrid.LoadDataSourceAsync();
}
private async Task OnValueChangedEndDate(DateTime value)
{
if (_toDate == value) return;
_toDate = value;
_contextParams[2] = _toDate;
if (_fromDate.Date > _toDate.Date) return;
await _logViewerGrid.LoadDataSourceAsync();
}
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
{
if (e.ElementType != GridElementType.DataRow) return;

View File

@ -92,7 +92,7 @@
CustomizeEditModel="Grid_CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
AllowSelectRowByClick="true"
AllowSelectRowByClick="false"
PageSize="13"
ShowFilterRow="true">

View File

@ -18,7 +18,7 @@
<CompanyDetailGrid Data="_detailGridData"
Logger="_logger"
SignalRClient="AdminSignalRClient"
ContextIds="ContextIds?.Cast<object>().ToArray()"
ContextIds="ContextIds"
PageSize="5"
ValidationEnabled="false"
EditMode="GridEditMode.EditForm"

View File

@ -19,7 +19,7 @@
<TransferDestinationToProductDetailGrid
Logger="_logger"
SignalRClient="AdminSignalRClient"
ContextIds="ContextIds?.Cast<object>().ToArray()"
ContextIds="ContextIds"
GetAllMessageTag="GetAllTag"
PageSize="10"
ValidationEnabled="false"

View File

@ -18,7 +18,7 @@
<UserProductMappingGrid Logger="_logger"
ContextIds="ContextIds?.Cast<object>().ToArray()"
ContextIds="ContextIds"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"

View File

@ -31,7 +31,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
[Parameter] public LoggerClient Logger { get; set; }
[Parameter] public string GridName { get; set; }
[Parameter] public object[]? ContextIds { get; set; }
[Parameter] public Guid[]? ContextIds { get; set; }
private string? _filterText = null;

View File

@ -57,13 +57,13 @@ namespace TIAMWebApp.Server.Controllers
[HttpGet]
[Route(APIUrls.GetAllLogItemsRouteName)]
[SignalR(SignalRTags.GetAllLogItemsByFilterText)]
public async Task<List<LogItemViewerModel>> GetAllLogItems(int takeCount, DateTime fromDate, DateTime toDate, string? criteriaOperatorText) //(int takeCount, string filterText)
public async Task<List<LogItemViewerModel>> GetAllLogItems(string? criteriaOperatorText) //(int takeCount, string filterText)
{
logger.Debug($"GetAllLogItems; takeCount: {takeCount}; fromDate: {fromDate}; toDate: {toDate}; criteriaOperatorText: {criteriaOperatorText}");
//public Task<List<Transfer>> GetTransfersByFilterAsync(CriteriaOperator criteriaOperator) => SessionAsync(ctx => (ctx.GetTransfers().AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator) as IQueryable<Transfer>)!.ToList());
List<AcLogItem> logItemList;
if (criteriaOperatorText.IsNullOrWhiteSpace()) logItemList = await adminDal.GetLogItemsAsync(takeCount, fromDate, toDate);
else logItemList = await adminDal.GetLogItemsByFilterAsync(CriteriaOperator.Parse(criteriaOperatorText), takeCount, fromDate, toDate);
if (criteriaOperatorText.IsNullOrWhiteSpace()) logItemList = await adminDal.GetLogItemsAsync(1000);
else logItemList = await adminDal.GetLogItemsByFilterAsync(CriteriaOperator.Parse(criteriaOperatorText),1000);
var resultList = new List<LogItemViewerModel>(logItemList.Count);
//logItemList[0].ToModelDto<LogItemViewerModel, AcLogItem>();

View File

@ -31,14 +31,14 @@ namespace TIAMWebApp.Server.Controllers
[NonAction]
[ApiExplorerSettings(IgnoreApi = true)]
private async Task<Company?> CompanyDataChanging(Company company, TrackingState trackingState)
private async Task<bool> CompanyDataChanging(Company company, TrackingState trackingState)
{
var logText = $"[{trackingState.ToString().ToUpper()}] CompanyDataChanging called; Id: {company.Id}; OwnerId: {company.OwnerId}; Name: {company.Name}";
if (company.Name.IsNullOrEmpty())
{
_logger.Error(logText);
return null;
return false;
}
_logger.Info(logText);
@ -53,12 +53,12 @@ namespace TIAMWebApp.Server.Controllers
//company.SetProfile(new Profile(Guid.NewGuid(), company.Name));
//company.Profile.SetAddress(new Address(Guid.NewGuid(), "Controller AddCompanyAsync; address text..."));
return (await adminDal.AddCompanyAsync(company)) ? company : null;
return await adminDal.AddCompanyAsync(company);
case TrackingState.Update:
return await adminDal.UpdateCompanyAsync(company);
case TrackingState.Remove:
return (await adminDal.RemoveCompanyAsync(company.Id)) ? company : null;
return await adminDal.RemoveCompanyAsync(company.Id);
case TrackingState.Get:
case TrackingState.GetAll:
@ -71,21 +71,21 @@ namespace TIAMWebApp.Server.Controllers
[ApiExplorerSettings(IgnoreApi = true)]
[SignalR(SignalRTags.AddCompany)]
public async Task<string> AddCompanyAsync(Company company)
=> (await CompanyDataChanging(company, TrackingState.Add))?.ToJson() ?? string.Empty;
=> await CompanyDataChanging(company, TrackingState.Add) ? company.ToJson() : string.Empty;
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.UpdateServiceProviderRouteName)]
[SignalR(SignalRTags.UpdateCompany)]
public async Task<string> UpdateServiceProvider(Company company)
=> (await CompanyDataChanging(company, TrackingState.Update))?.ToJson() ?? string.Empty;
=> await CompanyDataChanging(company, TrackingState.Update) ? company.ToJson() : string.Empty;
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.RemoveServiceProviderRouteName)]
[SignalR(SignalRTags.RemoveCompany)]
public async Task<string> RemoveServiceProvider(Company company)
=> (await CompanyDataChanging(company, TrackingState.Remove))?.ToJson() ?? string.Empty;
=> await CompanyDataChanging(company, TrackingState.Remove) ? company.ToJson() : string.Empty;
//15.
[AllowAnonymous]

View File

@ -162,7 +162,7 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
paramValues = new object[methodInfoModel.ParamInfos.Length];
var firstParamType = methodInfoModel.ParamInfos[0].ParameterType;
if (methodInfoModel.ParamInfos.Length > 1 || firstParamType == typeof(string) || firstParamType.IsEnum || firstParamType.IsValueType || firstParamType == typeof(DateTime))
if (methodInfoModel.ParamInfos.Length > 1 || firstParamType == typeof(string) || firstParamType.IsEnum || firstParamType.IsValueType)
{
var msg = message!.MessagePackTo<SignalPostJsonDataMessage<IdMessage>>();

View File

@ -17,6 +17,6 @@ namespace TIAMWebApp.Shared.Application.Utility
{
[Serializable]
[DebuggerDisplay("Count = {Count}")]
public class SignalRDataSource<T>(AcSignalRClientBase signalRClient, SignalRCrudTags signalRCrudTags, params object[]? contextIds)
public class SignalRDataSource<T>(AcSignalRClientBase signalRClient, SignalRCrudTags signalRCrudTags, params Guid[]? contextIds)
: AcSignalRDataSource<T>(signalRClient, signalRCrudTags, contextIds) where T : class, IId<Guid>;
}