Add Support for Hub Action Implementation ...

This commit is contained in:
2025-11-16 17:30:15 +03:30
parent 9b3cec02c2
commit 13cd3ed511
4 changed files with 20 additions and 21 deletions
+16 -12
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using DnsClient.Protocol;
using Microsoft.AspNetCore.SignalR;
using xCommons.Configurations;
using xCommons.Extensions;
@@ -12,7 +11,6 @@ using xDataService.Extensions;
using xExceptions.Constants;
using xModels.Dtos;
using xPushService.Constants;
using xStringService.Constants;
using xStringService.Extensions;
using xStringService.Hubs;
using xStringService.Interfaces;
@@ -26,7 +24,7 @@ namespace xStringService.Providers
{
//
#region Props ...
public IHubContext<XStringHub> Hub { get; }
public IHubContext<XStringEntityHub> Hub { get; }
public IXStringRepository Repository { get; }
public XAppConfiguration AppConfiguration { get; }
public XDataServiceConfiguration DataConfiguration { get; }
@@ -38,7 +36,7 @@ namespace xStringService.Providers
IXStringRepository repository,
XAppConfiguration appConfiguration,
XDataServiceConfiguration dataConfiguration,
IHubContext<XStringHub> hub = null
IHubContext<XStringEntityHub> hub = null
)
{
//
@@ -1210,7 +1208,7 @@ namespace xStringService.Providers
//
var entitieIds = entities.Select(e => e.Id);
await SendCustomPush(
action: XStringHubAction.ItemsDeleted.GetStringValue(),
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
payLoad: entitieIds.ToJSON(),
connectionId: connectionId
);
@@ -1258,7 +1256,7 @@ namespace xStringService.Providers
//
var ids = result.Select(i => i.Id);
await SendCustomPush(
action: XStringHubAction.ItemsDeleted.GetStringValue(),
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
payLoad: ids.ToJSON(),
connectionId: connectionId
);
@@ -1390,11 +1388,15 @@ namespace xStringService.Providers
)
{
//
var hubActions = new List<string>
var actions = new List<string>
{
XBaseEntityHubAction.Add.GetStringValue(),
XBaseEntityHubAction.Delete.GetStringValue(),
XBaseEntityHubAction.Update.GetStringValue(),
XBaseEntityHubAction.Delete.GetStringValue(),
XBaseEntityHubAction.AddMany.GetStringValue(),
XBaseEntityHubAction.DeleteMany.GetStringValue(),
XBaseEntityHubAction.UpdateMany.GetStringValue(),
XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
};
//
@@ -1403,7 +1405,7 @@ namespace xStringService.Providers
entityId > 0 &&
!Hub.IsNull() &&
!action.IsNullOrEmpty() &&
hubActions.Contains(action);
actions.Contains(action);
if (!isValid)
{
return;
@@ -1429,7 +1431,7 @@ namespace xStringService.Providers
{
clients = Hub.Clients.AllExcept(connectionId);
}
await clients.SendAsync(action, entity, connectionId);
await clients.SendAsync(action, entity.ToJSON(), connectionId);
}
/// <summary>
@@ -1448,12 +1450,14 @@ namespace xStringService.Providers
//
var customActions = new List<string>
{
XStringHubAction.ItemsDeleted.GetStringValue(),
XBaseEntityHubAction.DeleteMany.GetStringValue(),
};
//
// Validate ...
var isValid = !action.IsNullOrEmpty() &&
var isValid =
!Hub.IsNull() &&
!action.IsNullOrEmpty() &&
customActions.Contains(action);
if (!isValid)
{