last ...
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
using xExceptions.Attributes;
|
||||||
|
|
||||||
|
namespace xStringService.Constants
|
||||||
|
{
|
||||||
|
public enum XStringHubAction
|
||||||
|
{
|
||||||
|
[StringValue("ItemsDeleted")]
|
||||||
|
ItemsDeleted
|
||||||
|
}
|
||||||
|
}
|
||||||
+87
-17
@@ -12,7 +12,7 @@ using xModels.Dtos;
|
|||||||
using xStringService.Interfaces;
|
using xStringService.Interfaces;
|
||||||
using xStringService.Models.Dtos;
|
using xStringService.Models.Dtos;
|
||||||
|
|
||||||
namespace xStringService.Controllerppa
|
namespace xStringService.Controllers
|
||||||
{
|
{
|
||||||
public abstract class XStringServiceControllerBase : XIBaseProviderController, IXStringServiceControllerActions
|
public abstract class XStringServiceControllerBase : XIBaseProviderController, IXStringServiceControllerActions
|
||||||
{
|
{
|
||||||
@@ -243,7 +243,7 @@ namespace xStringService.Controllerppa
|
|||||||
/// <param name="query"></param>
|
/// <param name="query"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("QueryResourceIds")]
|
[HttpGet("QueryResourceIds")]
|
||||||
public virtual async Task<ActionResult<XQueryResult<string>>> QueryResourceIds(
|
public virtual ActionResult<XQueryResult<string>> QueryResourceIds(
|
||||||
[FromQuery] XQuery query
|
[FromQuery] XQuery query
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -252,7 +252,7 @@ namespace xStringService.Controllerppa
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = StringProvider
|
||||||
.QueryResourceIds(query);
|
.QueryResourceIds(query);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -358,12 +358,16 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.Add(
|
.Add(
|
||||||
value: value,
|
value: value,
|
||||||
resource: resource,
|
resource: resource,
|
||||||
language: language
|
language: language,
|
||||||
|
connectionId: connectionId
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -396,12 +400,16 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.Update(
|
.Update(
|
||||||
value: value,
|
value: value,
|
||||||
resource: resource,
|
resource: resource,
|
||||||
language: language
|
language: language,
|
||||||
|
connectionId: connectionId
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -434,12 +442,16 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.AddOrUpdate(
|
.AddOrUpdate(
|
||||||
value: value,
|
value: value,
|
||||||
resource: resource,
|
resource: resource,
|
||||||
language: language
|
language: language,
|
||||||
|
connectionId: connectionId
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -469,7 +481,13 @@ namespace xStringService.Controllerppa
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
var result = await StringProvider.AddEntity(item);
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await StringProvider.AddEntity(
|
||||||
|
item: item,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return Ok(result.
|
return Ok(result.
|
||||||
@@ -497,9 +515,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.UpdateEntity(item);
|
.UpdateEntity(
|
||||||
|
item: item,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return Ok(result.
|
return Ok(result.
|
||||||
@@ -527,9 +551,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.AddOrUpdateEntity(item);
|
.AddOrUpdateEntity(
|
||||||
|
item: item,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return Ok(result.
|
return Ok(result.
|
||||||
@@ -559,11 +589,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.AddByLocaleResource(
|
.AddByLocaleResource(
|
||||||
item: item,
|
item: item,
|
||||||
resource: resource
|
resource: resource,
|
||||||
|
connectionId: connectionId
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -594,11 +628,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.UpdateByLocaleResource(
|
.UpdateByLocaleResource(
|
||||||
item: item,
|
item: item,
|
||||||
resource: resource
|
resource: resource,
|
||||||
|
connectionId: connectionId
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -629,11 +667,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.AddOrUpdateByLocaleResource(
|
.AddOrUpdateByLocaleResource(
|
||||||
item: item,
|
item: item,
|
||||||
resource: resource
|
resource: resource,
|
||||||
|
connectionId: connectionId
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -662,9 +704,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.AddByResource(item);
|
.AddByResource(
|
||||||
|
item: item,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return Ok(result.
|
return Ok(result.
|
||||||
@@ -695,9 +743,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
await StringProvider
|
await StringProvider
|
||||||
.RemoveLanguageResources(language);
|
.RemoveLanguageResources(
|
||||||
|
language: language,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return Ok();
|
return Ok();
|
||||||
@@ -724,9 +778,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.RemoveResource(resource);
|
.RemoveResource(
|
||||||
|
resource: resource,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return Ok(result.
|
return Ok(result.
|
||||||
@@ -756,11 +816,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await StringProvider
|
var result = await StringProvider
|
||||||
.Remove(
|
.Remove(
|
||||||
resource: resource,
|
resource: resource,
|
||||||
language: language
|
language: language,
|
||||||
|
connectionId: connectionId
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -789,9 +853,15 @@ namespace xStringService.Controllerppa
|
|||||||
// Do ...
|
// Do ...
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
var connectionId = GetConnectionId();
|
||||||
|
|
||||||
//
|
//
|
||||||
await StringProvider
|
await StringProvider
|
||||||
.RemoveByResource(item);
|
.RemoveByResource(
|
||||||
|
item: item,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return Ok();
|
return Ok();
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using xPushService.Base;
|
||||||
|
using xStringService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xStringService.Hubs
|
||||||
|
{
|
||||||
|
public class XStringHub : XBaseEntityHub<XString, int>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
#region Constructor ...
|
||||||
|
public XStringHub(ILogger<XBaseHub> logger) : base(logger)
|
||||||
|
{ }
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,11 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using xCommons.Configurations;
|
using xCommons.Configurations;
|
||||||
using xDataService.Configuration;
|
using xDataService.Configuration;
|
||||||
using xModels.Dtos;
|
using xModels.Dtos;
|
||||||
|
using xStringService.Hubs;
|
||||||
using xStringService.Interfaces.Entities;
|
using xStringService.Interfaces.Entities;
|
||||||
using xStringService.Models.Dtos;
|
using xStringService.Models.Dtos;
|
||||||
using xStringService.Models.Entities;
|
using xStringService.Models.Entities;
|
||||||
@@ -15,6 +17,7 @@ namespace xStringService.Interfaces
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
#region Props ...
|
#region Props ...
|
||||||
|
IHubContext<XStringHub> Hub { get; }
|
||||||
IXStringRepository Repository { get; }
|
IXStringRepository Repository { get; }
|
||||||
XAppConfiguration AppConfiguration { get; }
|
XAppConfiguration AppConfiguration { get; }
|
||||||
XDataServiceConfiguration DataConfiguration { get; }
|
XDataServiceConfiguration DataConfiguration { get; }
|
||||||
@@ -38,7 +41,7 @@ namespace xStringService.Interfaces
|
|||||||
string resource,
|
string resource,
|
||||||
string language = null
|
string language = null
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve Specified Resource ...
|
/// Retrieve Specified Resource ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -83,7 +86,7 @@ namespace xStringService.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="query"></param>
|
/// <param name="query"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XQueryResult<string>> QueryResourceIds(XQuery query);
|
XQueryResult<string> QueryResourceIds(XQuery query);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query Specified Language Resources ...
|
/// Query Specified Language Resources ...
|
||||||
@@ -129,11 +132,13 @@ namespace xStringService.Interfaces
|
|||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> Add(
|
Task<bool> Add(
|
||||||
string resource,
|
string resource,
|
||||||
string value,
|
string value,
|
||||||
string language = null
|
string language = null,
|
||||||
|
string connectionId = null
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -142,11 +147,13 @@ namespace xStringService.Interfaces
|
|||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> Update(
|
Task<bool> Update(
|
||||||
string resource,
|
string resource,
|
||||||
string value,
|
string value,
|
||||||
string language = null
|
string language = null,
|
||||||
|
string connectionId = null
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -155,43 +162,59 @@ namespace xStringService.Interfaces
|
|||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> AddOrUpdate(
|
Task<bool> AddOrUpdate(
|
||||||
string resource,
|
string resource,
|
||||||
string value,
|
string value,
|
||||||
string language = null
|
string language = null,
|
||||||
|
string connectionId = null
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add Specified Resource ...
|
/// Add Specified Resource ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XStringDto> AddEntity(XStringDto item);
|
Task<XStringDto> AddEntity(
|
||||||
|
XStringDto item,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update Specified Entity ...
|
/// Update Specified Entity ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XStringDto> UpdateEntity(XStringDto item);
|
Task<XStringDto> UpdateEntity(
|
||||||
|
XStringDto item,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add Or Update Specified Entitiy ...
|
/// Add Or Update Specified Entitiy ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XStringDto> AddOrUpdateEntity(XStringDto item);
|
Task<XStringDto> AddOrUpdateEntity(
|
||||||
|
XStringDto item,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add Specified Locale Resource ...
|
/// Add Specified Locale Resource ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XStringDto> AddByLocaleResource(
|
Task<XStringDto> AddByLocaleResource(
|
||||||
XLocaleResourceDto item,
|
XLocaleResourceDto item,
|
||||||
string resource
|
string resource,
|
||||||
|
string connectionId = null
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -199,10 +222,12 @@ namespace xStringService.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XStringDto> UpdateByLocaleResource(
|
Task<XStringDto> UpdateByLocaleResource(
|
||||||
XLocaleResourceDto item,
|
XLocaleResourceDto item,
|
||||||
string resource
|
string resource,
|
||||||
|
string connectionId = null
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -210,18 +235,24 @@ namespace xStringService.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XStringDto> AddOrUpdateByLocaleResource(
|
Task<XStringDto> AddOrUpdateByLocaleResource(
|
||||||
XLocaleResourceDto item,
|
XLocaleResourceDto item,
|
||||||
string resource
|
string resource,
|
||||||
|
string connectionId = null
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add Or Update all XResourceDto(s) Locales ...
|
/// Add Or Update all XResourceDto(s) Locales ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<XStringDto>> AddByResource(XResourceDto item);
|
Task<IEnumerable<XStringDto>> AddByResource(
|
||||||
|
XResourceDto item,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -230,33 +261,47 @@ namespace xStringService.Interfaces
|
|||||||
/// Remove all Specified Language's Resources ...
|
/// Remove all Specified Language's Resources ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task RemoveLanguageResources(string language);
|
Task RemoveLanguageResources(
|
||||||
|
string language,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove all Specified Resource Ids instances ...
|
/// Remove all Specified Resource Ids instances ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<XStringDto>> RemoveResource(string resource);
|
Task<IEnumerable<XStringDto>> RemoveResource(
|
||||||
|
string resource,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove Specified Resource ...
|
/// Remove Specified Resource ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> Remove(
|
Task<bool> Remove(
|
||||||
string resource,
|
string resource,
|
||||||
string language = null
|
string language = null,
|
||||||
|
string connectionId = null
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove all Resource of Specified XResourceDto ...
|
/// Remove all Resource of Specified XResourceDto ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task RemoveByResource(XResourceDto item);
|
Task RemoveByResource(
|
||||||
|
XResourceDto item,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ namespace xStringService.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="query"></param>
|
/// <param name="query"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<XQueryResult<string>>> QueryResourceIds(
|
ActionResult<XQueryResult<string>> QueryResourceIds(
|
||||||
[FromQuery] XQuery query
|
[FromQuery] XQuery query
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+245
-24
@@ -3,13 +3,18 @@ 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 xCommons.Configurations;
|
using xCommons.Configurations;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xDataService.Configuration;
|
using xDataService.Configuration;
|
||||||
using xDataService.Extensions;
|
using xDataService.Extensions;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
using xModels.Dtos;
|
using xModels.Dtos;
|
||||||
|
using xPushService.Constants;
|
||||||
|
using xStringService.Constants;
|
||||||
using xStringService.Extensions;
|
using xStringService.Extensions;
|
||||||
|
using xStringService.Hubs;
|
||||||
using xStringService.Interfaces;
|
using xStringService.Interfaces;
|
||||||
using xStringService.Interfaces.Entities;
|
using xStringService.Interfaces.Entities;
|
||||||
using xStringService.Models.Dtos;
|
using xStringService.Models.Dtos;
|
||||||
@@ -21,6 +26,7 @@ namespace xStringService.Providers
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
#region Props ...
|
#region Props ...
|
||||||
|
public IHubContext<XStringHub> 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; }
|
||||||
@@ -31,13 +37,15 @@ namespace xStringService.Providers
|
|||||||
public XStringProvider(
|
public XStringProvider(
|
||||||
IXStringRepository repository,
|
IXStringRepository repository,
|
||||||
XAppConfiguration appConfiguration,
|
XAppConfiguration appConfiguration,
|
||||||
XDataServiceConfiguration dataConfiguration
|
XDataServiceConfiguration dataConfiguration,
|
||||||
|
IHubContext<XStringHub> hub = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Repository = repository;
|
Repository = repository;
|
||||||
AppConfiguration = appConfiguration;
|
AppConfiguration = appConfiguration;
|
||||||
DataConfiguration = dataConfiguration;
|
DataConfiguration = dataConfiguration;
|
||||||
|
Hub = hub;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -304,7 +312,7 @@ namespace xStringService.Providers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="query"></param>
|
/// <param name="query"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<XQueryResult<string>> QueryResourceIds(XQuery query)
|
public XQueryResult<string> QueryResourceIds(XQuery query)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Normalize ...
|
// Normalize ...
|
||||||
@@ -410,7 +418,7 @@ namespace xStringService.Providers
|
|||||||
TotalPages = entityResult.TotalPages,
|
TotalPages = entityResult.TotalPages,
|
||||||
TotalItems = entityResult.TotalItems,
|
TotalItems = entityResult.TotalItems,
|
||||||
TotalFilteredPages = entityResult.TotalFilteredPages,
|
TotalFilteredPages = entityResult.TotalFilteredPages,
|
||||||
TotalFilteredItems = entityResult.TotalFilteredItems,
|
TotalFilteredItems = entityResult.TotalFilteredItems,
|
||||||
Items = entityResult.Items.Select(i => i.ToXStringDto()),
|
Items = entityResult.Items.Select(i => i.ToXStringDto()),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -562,11 +570,13 @@ namespace xStringService.Providers
|
|||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> Add(
|
public async Task<bool> Add(
|
||||||
string resource,
|
string resource,
|
||||||
string value,
|
string value,
|
||||||
string language = null
|
string language = null,
|
||||||
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -607,8 +617,17 @@ namespace xStringService.Providers
|
|||||||
TranslatedValue = value,
|
TranslatedValue = value,
|
||||||
ResourceTitle = resource,
|
ResourceTitle = resource,
|
||||||
};
|
};
|
||||||
var added = await Repository.AddAsync(entity);
|
entity = await Repository.AddAsync(entity);
|
||||||
result = !added.IsNullOrDefault();
|
result = !entity.IsNullOrDefault();
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await SendPush(
|
||||||
|
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||||
|
entityId: entity.Id,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -620,11 +639,13 @@ namespace xStringService.Providers
|
|||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> Update(
|
public async Task<bool> Update(
|
||||||
string resource,
|
string resource,
|
||||||
string value,
|
string value,
|
||||||
string language = null
|
string language = null,
|
||||||
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -674,6 +695,15 @@ namespace xStringService.Providers
|
|||||||
entity.TranslatedValue = value;
|
entity.TranslatedValue = value;
|
||||||
entity = await Repository.UpdateAsync(entity.Id, entity);
|
entity = await Repository.UpdateAsync(entity.Id, entity);
|
||||||
result = !entity.IsNullOrDefault();
|
result = !entity.IsNullOrDefault();
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await SendPush(
|
||||||
|
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||||
|
entityId: entity.Id,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -685,11 +715,13 @@ namespace xStringService.Providers
|
|||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> AddOrUpdate(
|
public async Task<bool> AddOrUpdate(
|
||||||
string resource,
|
string resource,
|
||||||
string value,
|
string value,
|
||||||
string language = null
|
string language = null,
|
||||||
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -738,8 +770,12 @@ namespace xStringService.Providers
|
|||||||
/// Add Specified Resource ...
|
/// Add Specified Resource ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<XStringDto> AddEntity(XStringDto item)
|
public async Task<XStringDto> AddEntity(
|
||||||
|
XStringDto item,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Validate ...
|
||||||
@@ -787,6 +823,13 @@ namespace xStringService.Providers
|
|||||||
XException.ActionFailed.Throw();
|
XException.ActionFailed.Throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
await SendPush(
|
||||||
|
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||||
|
entityId: result.Id,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result.ToXStringDto();
|
return result.ToXStringDto();
|
||||||
}
|
}
|
||||||
@@ -795,8 +838,12 @@ namespace xStringService.Providers
|
|||||||
/// Update Specified Entity ...
|
/// Update Specified Entity ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<XStringDto> UpdateEntity(XStringDto item)
|
public async Task<XStringDto> UpdateEntity(
|
||||||
|
XStringDto item,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Validate ...
|
||||||
@@ -852,6 +899,11 @@ namespace xStringService.Providers
|
|||||||
|
|
||||||
//
|
//
|
||||||
XStringDto result = entity.ToXStringDto();
|
XStringDto result = entity.ToXStringDto();
|
||||||
|
await SendPush(
|
||||||
|
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||||
|
entityId: entity.Id,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -861,8 +913,12 @@ namespace xStringService.Providers
|
|||||||
/// Add Or Update Specified Entitiy ...
|
/// Add Or Update Specified Entitiy ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<XStringDto> AddOrUpdateEntity(XStringDto item)
|
public async Task<XStringDto> AddOrUpdateEntity(
|
||||||
|
XStringDto item,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Validate ...
|
||||||
@@ -897,11 +953,11 @@ namespace xStringService.Providers
|
|||||||
XStringDto result = null;
|
XStringDto result = null;
|
||||||
if (!isExists)
|
if (!isExists)
|
||||||
{
|
{
|
||||||
result = await AddEntity(item);
|
result = await AddEntity(item, connectionId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = await UpdateEntity(item);
|
result = await UpdateEntity(item, connectionId);
|
||||||
}
|
}
|
||||||
if (result.IsNullOrDefault())
|
if (result.IsNullOrDefault())
|
||||||
{
|
{
|
||||||
@@ -917,10 +973,12 @@ namespace xStringService.Providers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<XStringDto> AddByLocaleResource(
|
public async Task<XStringDto> AddByLocaleResource(
|
||||||
XLocaleResourceDto item,
|
XLocaleResourceDto item,
|
||||||
string resource
|
string resource,
|
||||||
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -954,7 +1012,7 @@ namespace xStringService.Providers
|
|||||||
ResourceTitle = resource,
|
ResourceTitle = resource,
|
||||||
TranslatedValue = item.Value
|
TranslatedValue = item.Value
|
||||||
};
|
};
|
||||||
result = await AddEntity(result);
|
result = await AddEntity(result, connectionId);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -965,10 +1023,12 @@ namespace xStringService.Providers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<XStringDto> UpdateByLocaleResource(
|
public async Task<XStringDto> UpdateByLocaleResource(
|
||||||
XLocaleResourceDto item,
|
XLocaleResourceDto item,
|
||||||
string resource
|
string resource,
|
||||||
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1015,6 +1075,13 @@ namespace xStringService.Providers
|
|||||||
|
|
||||||
//
|
//
|
||||||
XStringDto result = entity.ToXStringDto();
|
XStringDto result = entity.ToXStringDto();
|
||||||
|
await SendPush(
|
||||||
|
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||||
|
entityId: entity.Id,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1023,10 +1090,12 @@ namespace xStringService.Providers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<XStringDto> AddOrUpdateByLocaleResource(
|
public async Task<XStringDto> AddOrUpdateByLocaleResource(
|
||||||
XLocaleResourceDto item,
|
XLocaleResourceDto item,
|
||||||
string resource
|
string resource,
|
||||||
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1079,8 +1148,12 @@ namespace xStringService.Providers
|
|||||||
/// Add Or Update all XResourceDto(s) Locales ...
|
/// Add Or Update all XResourceDto(s) Locales ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IEnumerable<XStringDto>> AddByResource(XResourceDto item)
|
public async Task<IEnumerable<XStringDto>> AddByResource(
|
||||||
|
XResourceDto item,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Validate ...
|
||||||
@@ -1109,8 +1182,12 @@ namespace xStringService.Providers
|
|||||||
/// Remove all Specified Language's Resources ...
|
/// Remove all Specified Language's Resources ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task RemoveLanguageResources(string language)
|
public async Task RemoveLanguageResources(
|
||||||
|
string language,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Validate ...
|
||||||
@@ -1123,15 +1200,37 @@ namespace xStringService.Providers
|
|||||||
//
|
//
|
||||||
var entities = await Repository
|
var entities = await Repository
|
||||||
.FindManyAsync(e => e.Language.ToNormalString() == language.ToNormalString());
|
.FindManyAsync(e => e.Language.ToNormalString() == language.ToNormalString());
|
||||||
await Repository.RemoveRangeAsync(entities);
|
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Repository.RemoveRangeAsync(entities);
|
||||||
|
|
||||||
|
//
|
||||||
|
var entitieIds = entities.Select(e => e.Id);
|
||||||
|
await SendCustomPush(
|
||||||
|
action: XStringHubAction.ItemsDeleted.GetStringValue(),
|
||||||
|
payLoad: entitieIds.ToJSON(),
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove all Specified Resource Ids instances ...
|
/// Remove all Specified Resource Ids instances ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IEnumerable<XStringDto>> RemoveResource(string resource)
|
public async Task<IEnumerable<XStringDto>> RemoveResource(
|
||||||
|
string resource,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Validate ...
|
||||||
@@ -1153,6 +1252,18 @@ namespace xStringService.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result.HasChild())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var ids = result.Select(i => i.Id);
|
||||||
|
await SendCustomPush(
|
||||||
|
action: XStringHubAction.ItemsDeleted.GetStringValue(),
|
||||||
|
payLoad: ids.ToJSON(),
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1162,10 +1273,12 @@ namespace xStringService.Providers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="resource"></param>
|
/// <param name="resource"></param>
|
||||||
/// <param name="language"></param>
|
/// <param name="language"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> Remove(
|
public async Task<bool> Remove(
|
||||||
string resource,
|
string resource,
|
||||||
string language = null
|
string language = null,
|
||||||
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1215,6 +1328,15 @@ namespace xStringService.Providers
|
|||||||
// Delete ...
|
// Delete ...
|
||||||
entity = await Repository.RemoveAsync(entity.Id);
|
entity = await Repository.RemoveAsync(entity.Id);
|
||||||
result = !entity.IsNullOrDefault();
|
result = !entity.IsNullOrDefault();
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await SendPush(
|
||||||
|
action: XBaseEntityHubAction.Delete.GetStringValue(),
|
||||||
|
entityId: entity.Id,
|
||||||
|
connectionId: connectionId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -1224,8 +1346,12 @@ namespace xStringService.Providers
|
|||||||
/// Remove all Resource of Specified XResourceDto ...
|
/// Remove all Resource of Specified XResourceDto ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task RemoveByResource(XResourceDto item)
|
public async Task RemoveByResource(
|
||||||
|
XResourceDto item,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool isValid =
|
bool isValid =
|
||||||
@@ -1237,7 +1363,7 @@ namespace xStringService.Providers
|
|||||||
XException.InvalidArgs.Throw();
|
XException.InvalidArgs.Throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
foreach (var locale in item.Locales)
|
foreach (var locale in item.Locales)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1248,5 +1374,100 @@ namespace xStringService.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Hub Actions ...
|
||||||
|
/// <summary>
|
||||||
|
/// Send Specified Hub Action Notifications ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
/// <param name="entityId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task SendPush(
|
||||||
|
string action,
|
||||||
|
int entityId,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var hubActions = new List<string>
|
||||||
|
{
|
||||||
|
XBaseEntityHubAction.Add.GetStringValue(),
|
||||||
|
XBaseEntityHubAction.Delete.GetStringValue(),
|
||||||
|
XBaseEntityHubAction.Update.GetStringValue(),
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid =
|
||||||
|
entityId > 0 &&
|
||||||
|
!Hub.IsNull() &&
|
||||||
|
!action.IsNullOrEmpty() &&
|
||||||
|
hubActions.Contains(action);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve and Validate Entity ...
|
||||||
|
XString entity = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
entity = await Repository.GetAsync(entityId);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
isValid = !entity.IsNullOrDefault();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var clients = Hub.Clients.All;
|
||||||
|
if (!connectionId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
clients = Hub.Clients.AllExcept(connectionId);
|
||||||
|
}
|
||||||
|
await clients.SendAsync(action, entity, connectionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send Custom Push Message ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
/// <param name="payLoad"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task SendCustomPush(
|
||||||
|
string action,
|
||||||
|
string payLoad,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var customActions = new List<string>
|
||||||
|
{
|
||||||
|
XStringHubAction.ItemsDeleted.GetStringValue(),
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !action.IsNullOrEmpty() &&
|
||||||
|
customActions.Contains(action);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var clients = Hub.Clients.All;
|
||||||
|
if (!connectionId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
clients = Hub.Clients.AllExcept(connectionId);
|
||||||
|
}
|
||||||
|
await clients.SendAsync(action, payLoad, connectionId);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,9 +20,16 @@
|
|||||||
<None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true" PackagePath="\icon.png" />
|
<None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true" PackagePath="\icon.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Local Modules -->
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="xDashboard.xDataService" Version="1.0.0" />
|
||||||
|
<!-- <PackageReference Include="xDashboard.xIdentityService" Version="1.0.0" /> -->
|
||||||
|
<!-- <PackageReference Include="xDashboard.xStringService" Version="1.0.0" /> -->
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Local Dependencies -->
|
<!-- Local Dependencies -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../xDataService/xDataService.csproj" />
|
<!-- <ProjectReference Include="../xDataService/xDataService.csproj" /> -->
|
||||||
<ProjectReference Include="../xPushService/xPushService.csproj" />
|
<ProjectReference Include="../xPushService/xPushService.csproj" />
|
||||||
<ProjectReference Include="../xIdentityService/xIdentityService.csproj" />
|
<ProjectReference Include="../xIdentityService/xIdentityService.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user