Add Support for Hub Action Implementation ...
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
using xExceptions.Attributes;
|
||||
|
||||
namespace xStringService.Constants
|
||||
{
|
||||
public enum XStringHubAction
|
||||
{
|
||||
[StringValue("ItemsDeleted")]
|
||||
ItemsDeleted
|
||||
}
|
||||
{ }
|
||||
}
|
||||
@@ -4,11 +4,11 @@ using xStringService.Models.Entities;
|
||||
|
||||
namespace xStringService.Hubs
|
||||
{
|
||||
public class XStringHub : XBaseEntityHub<XString, int>
|
||||
public class XStringEntityHub : XBaseEntityHub<XString, int>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public XStringHub(ILogger<XBaseHub> logger) : base(logger)
|
||||
public XStringEntityHub(ILogger<XBaseHub> logger) : base(logger)
|
||||
{ }
|
||||
#endregion
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace xStringService.Interfaces
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
IHubContext<XStringHub> Hub { get; }
|
||||
IHubContext<XStringEntityHub> Hub { get; }
|
||||
IXStringRepository Repository { get; }
|
||||
XAppConfiguration AppConfiguration { get; }
|
||||
XDataServiceConfiguration DataConfiguration { get; }
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user