Add Support for Hub Action Implementation ...
This commit is contained in:
@@ -1,10 +1,5 @@
|
|||||||
using xExceptions.Attributes;
|
|
||||||
|
|
||||||
namespace xStringService.Constants
|
namespace xStringService.Constants
|
||||||
{
|
{
|
||||||
public enum XStringHubAction
|
public enum XStringHubAction
|
||||||
{
|
{ }
|
||||||
[StringValue("ItemsDeleted")]
|
|
||||||
ItemsDeleted
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -4,11 +4,11 @@ using xStringService.Models.Entities;
|
|||||||
|
|
||||||
namespace xStringService.Hubs
|
namespace xStringService.Hubs
|
||||||
{
|
{
|
||||||
public class XStringHub : XBaseEntityHub<XString, int>
|
public class XStringEntityHub : XBaseEntityHub<XString, int>
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
#region Constructor ...
|
#region Constructor ...
|
||||||
public XStringHub(ILogger<XBaseHub> logger) : base(logger)
|
public XStringEntityHub(ILogger<XBaseHub> logger) : base(logger)
|
||||||
{ }
|
{ }
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace xStringService.Interfaces
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
#region Props ...
|
#region Props ...
|
||||||
IHubContext<XStringHub> Hub { get; }
|
IHubContext<XStringEntityHub> Hub { get; }
|
||||||
IXStringRepository Repository { get; }
|
IXStringRepository Repository { get; }
|
||||||
XAppConfiguration AppConfiguration { get; }
|
XAppConfiguration AppConfiguration { get; }
|
||||||
XDataServiceConfiguration DataConfiguration { get; }
|
XDataServiceConfiguration DataConfiguration { get; }
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DnsClient.Protocol;
|
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using xCommons.Configurations;
|
using xCommons.Configurations;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
@@ -12,7 +11,6 @@ using xDataService.Extensions;
|
|||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
using xModels.Dtos;
|
using xModels.Dtos;
|
||||||
using xPushService.Constants;
|
using xPushService.Constants;
|
||||||
using xStringService.Constants;
|
|
||||||
using xStringService.Extensions;
|
using xStringService.Extensions;
|
||||||
using xStringService.Hubs;
|
using xStringService.Hubs;
|
||||||
using xStringService.Interfaces;
|
using xStringService.Interfaces;
|
||||||
@@ -26,7 +24,7 @@ namespace xStringService.Providers
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
#region Props ...
|
#region Props ...
|
||||||
public IHubContext<XStringHub> Hub { get; }
|
public IHubContext<XStringEntityHub> Hub { get; }
|
||||||
public IXStringRepository Repository { get; }
|
public IXStringRepository Repository { get; }
|
||||||
public XAppConfiguration AppConfiguration { get; }
|
public XAppConfiguration AppConfiguration { get; }
|
||||||
public XDataServiceConfiguration DataConfiguration { get; }
|
public XDataServiceConfiguration DataConfiguration { get; }
|
||||||
@@ -38,7 +36,7 @@ namespace xStringService.Providers
|
|||||||
IXStringRepository repository,
|
IXStringRepository repository,
|
||||||
XAppConfiguration appConfiguration,
|
XAppConfiguration appConfiguration,
|
||||||
XDataServiceConfiguration dataConfiguration,
|
XDataServiceConfiguration dataConfiguration,
|
||||||
IHubContext<XStringHub> hub = null
|
IHubContext<XStringEntityHub> hub = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1210,7 +1208,7 @@ namespace xStringService.Providers
|
|||||||
//
|
//
|
||||||
var entitieIds = entities.Select(e => e.Id);
|
var entitieIds = entities.Select(e => e.Id);
|
||||||
await SendCustomPush(
|
await SendCustomPush(
|
||||||
action: XStringHubAction.ItemsDeleted.GetStringValue(),
|
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||||
payLoad: entitieIds.ToJSON(),
|
payLoad: entitieIds.ToJSON(),
|
||||||
connectionId: connectionId
|
connectionId: connectionId
|
||||||
);
|
);
|
||||||
@@ -1258,7 +1256,7 @@ namespace xStringService.Providers
|
|||||||
//
|
//
|
||||||
var ids = result.Select(i => i.Id);
|
var ids = result.Select(i => i.Id);
|
||||||
await SendCustomPush(
|
await SendCustomPush(
|
||||||
action: XStringHubAction.ItemsDeleted.GetStringValue(),
|
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||||
payLoad: ids.ToJSON(),
|
payLoad: ids.ToJSON(),
|
||||||
connectionId: connectionId
|
connectionId: connectionId
|
||||||
);
|
);
|
||||||
@@ -1390,11 +1388,15 @@ namespace xStringService.Providers
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
var hubActions = new List<string>
|
var actions = new List<string>
|
||||||
{
|
{
|
||||||
XBaseEntityHubAction.Add.GetStringValue(),
|
XBaseEntityHubAction.Add.GetStringValue(),
|
||||||
XBaseEntityHubAction.Delete.GetStringValue(),
|
|
||||||
XBaseEntityHubAction.Update.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 &&
|
entityId > 0 &&
|
||||||
!Hub.IsNull() &&
|
!Hub.IsNull() &&
|
||||||
!action.IsNullOrEmpty() &&
|
!action.IsNullOrEmpty() &&
|
||||||
hubActions.Contains(action);
|
actions.Contains(action);
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -1429,7 +1431,7 @@ namespace xStringService.Providers
|
|||||||
{
|
{
|
||||||
clients = Hub.Clients.AllExcept(connectionId);
|
clients = Hub.Clients.AllExcept(connectionId);
|
||||||
}
|
}
|
||||||
await clients.SendAsync(action, entity, connectionId);
|
await clients.SendAsync(action, entity.ToJSON(), connectionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1448,12 +1450,14 @@ namespace xStringService.Providers
|
|||||||
//
|
//
|
||||||
var customActions = new List<string>
|
var customActions = new List<string>
|
||||||
{
|
{
|
||||||
XStringHubAction.ItemsDeleted.GetStringValue(),
|
XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Validate ...
|
||||||
var isValid = !action.IsNullOrEmpty() &&
|
var isValid =
|
||||||
|
!Hub.IsNull() &&
|
||||||
|
!action.IsNullOrEmpty() &&
|
||||||
customActions.Contains(action);
|
customActions.Contains(action);
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user