add some new features in data service ...
This commit is contained in:
+57
-20
@@ -1,14 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Extensions;
|
||||
using xModels.Base;
|
||||
using xPushService.Constants;
|
||||
using xPushService.Interfaces;
|
||||
|
||||
namespace xPushService.Base
|
||||
{
|
||||
public abstract class XBaseEntityHub<TEntity, TKey> : XBaseHub
|
||||
public abstract class XBaseEntityHub<TEntity, TKey> : XBaseHub, IXBaseEntityHub<TEntity, TKey>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
{
|
||||
//
|
||||
@@ -23,8 +25,12 @@ namespace xPushService.Base
|
||||
/// Notify a New Entity added ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Add(TEntity entity)
|
||||
public async Task Add(
|
||||
TEntity entity,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
@@ -36,7 +42,8 @@ namespace xPushService.Base
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.Add.GetStringValue(),
|
||||
entity.ToJSON(camelCase: true),
|
||||
connectionId
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -45,8 +52,12 @@ namespace xPushService.Base
|
||||
/// Notify a New Entity added ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task AddOrUpdate(TEntity entity)
|
||||
public async Task AddOrUpdate(
|
||||
TEntity entity,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
@@ -58,7 +69,8 @@ namespace xPushService.Base
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
entity.ToJSON(camelCase: true),
|
||||
connectionId
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -66,9 +78,13 @@ namespace xPushService.Base
|
||||
/// <summary>
|
||||
/// Notify Add Many Entities ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="entities"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task AddMany(IEnumerable<TEntity> entities)
|
||||
public async Task AddMany(
|
||||
IEnumerable<TEntity> entities,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
@@ -80,7 +96,8 @@ namespace xPushService.Base
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
entities.ToJSON(camelCase: true),
|
||||
connectionId
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -89,8 +106,12 @@ namespace xPushService.Base
|
||||
/// Notify an Entity Deleted ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Delete(TEntity entity)
|
||||
public async Task Delete(
|
||||
TEntity entity,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
@@ -102,7 +123,8 @@ namespace xPushService.Base
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
entity.ToJSON(camelCase: true),
|
||||
connectionId
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -110,9 +132,13 @@ namespace xPushService.Base
|
||||
/// <summary>
|
||||
/// Notify Delete Many Entities ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="entities"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteMany(IEnumerable<TEntity> entities)
|
||||
public async Task DeleteMany(
|
||||
IEnumerable<TEntity> entities,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
@@ -124,7 +150,8 @@ namespace xPushService.Base
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
entities.ToJSON(camelCase: true),
|
||||
connectionId
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -133,8 +160,12 @@ namespace xPushService.Base
|
||||
/// Notify an Entity Updated ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Update(TEntity entity)
|
||||
public async Task Update(
|
||||
TEntity entity,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
@@ -146,7 +177,8 @@ namespace xPushService.Base
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.Update.GetStringValue(),
|
||||
entity.ToJSON(camelCase: true),
|
||||
connectionId
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -154,9 +186,13 @@ namespace xPushService.Base
|
||||
/// <summary>
|
||||
/// Notify Update Many Entities ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="entities"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateMany(IEnumerable<TEntity> entities)
|
||||
public async Task UpdateMany(
|
||||
IEnumerable<TEntity> entities,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
@@ -166,9 +202,10 @@ namespace xPushService.Base
|
||||
await Clients
|
||||
.AllExcept(connectionId)
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
entities.ToJSON(camelCase: true),
|
||||
connectionId
|
||||
XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
entities.ToJSON(camelCase: true),
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user