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.Models.Dtos;
|
||||
|
||||
namespace xStringService.Controllerppa
|
||||
namespace xStringService.Controllers
|
||||
{
|
||||
public abstract class XStringServiceControllerBase : XIBaseProviderController, IXStringServiceControllerActions
|
||||
{
|
||||
@@ -243,7 +243,7 @@ namespace xStringService.Controllerppa
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("QueryResourceIds")]
|
||||
public virtual async Task<ActionResult<XQueryResult<string>>> QueryResourceIds(
|
||||
public virtual ActionResult<XQueryResult<string>> QueryResourceIds(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
@@ -252,7 +252,7 @@ namespace xStringService.Controllerppa
|
||||
try
|
||||
{
|
||||
//
|
||||
var result = await StringProvider
|
||||
var result = StringProvider
|
||||
.QueryResourceIds(query);
|
||||
|
||||
//
|
||||
@@ -358,12 +358,16 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.Add(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
language: language,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
@@ -396,12 +400,16 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.Update(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
language: language,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
@@ -434,12 +442,16 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.AddOrUpdate(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
language: language,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
@@ -469,7 +481,13 @@ namespace xStringService.Controllerppa
|
||||
try
|
||||
{
|
||||
//
|
||||
var result = await StringProvider.AddEntity(item);
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider.AddEntity(
|
||||
item: item,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.
|
||||
@@ -497,9 +515,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.UpdateEntity(item);
|
||||
.UpdateEntity(
|
||||
item: item,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.
|
||||
@@ -527,9 +551,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.AddOrUpdateEntity(item);
|
||||
.AddOrUpdateEntity(
|
||||
item: item,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.
|
||||
@@ -559,11 +589,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.AddByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
resource: resource,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
@@ -594,11 +628,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.UpdateByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
resource: resource,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
@@ -629,11 +667,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.AddOrUpdateByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
resource: resource,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
@@ -662,9 +704,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.AddByResource(item);
|
||||
.AddByResource(
|
||||
item: item,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.
|
||||
@@ -695,9 +743,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
await StringProvider
|
||||
.RemoveLanguageResources(language);
|
||||
.RemoveLanguageResources(
|
||||
language: language,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok();
|
||||
@@ -724,9 +778,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.RemoveResource(resource);
|
||||
.RemoveResource(
|
||||
resource: resource,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.
|
||||
@@ -756,11 +816,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await StringProvider
|
||||
.Remove(
|
||||
resource: resource,
|
||||
language: language
|
||||
language: language,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
@@ -789,9 +853,15 @@ namespace xStringService.Controllerppa
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
await StringProvider
|
||||
.RemoveByResource(item);
|
||||
.RemoveByResource(
|
||||
item: item,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
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.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using xCommons.Configurations;
|
||||
using xDataService.Configuration;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Hubs;
|
||||
using xStringService.Interfaces.Entities;
|
||||
using xStringService.Models.Dtos;
|
||||
using xStringService.Models.Entities;
|
||||
@@ -15,6 +17,7 @@ namespace xStringService.Interfaces
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
IHubContext<XStringHub> Hub { get; }
|
||||
IXStringRepository Repository { get; }
|
||||
XAppConfiguration AppConfiguration { get; }
|
||||
XDataServiceConfiguration DataConfiguration { get; }
|
||||
@@ -83,7 +86,7 @@ namespace xStringService.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<string>> QueryResourceIds(XQuery query);
|
||||
XQueryResult<string> QueryResourceIds(XQuery query);
|
||||
|
||||
/// <summary>
|
||||
/// Query Specified Language Resources ...
|
||||
@@ -129,11 +132,13 @@ namespace xStringService.Interfaces
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(
|
||||
string resource,
|
||||
string value,
|
||||
string language = null
|
||||
string language = null,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
@@ -142,11 +147,13 @@ namespace xStringService.Interfaces
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Update(
|
||||
string resource,
|
||||
string value,
|
||||
string language = null
|
||||
string language = null,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
@@ -155,43 +162,59 @@ namespace xStringService.Interfaces
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddOrUpdate(
|
||||
string resource,
|
||||
string value,
|
||||
string language = null
|
||||
string language = null,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XStringDto> AddEntity(XStringDto item);
|
||||
Task<XStringDto> AddEntity(
|
||||
XStringDto item,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Entity ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XStringDto> UpdateEntity(XStringDto item);
|
||||
Task<XStringDto> UpdateEntity(
|
||||
XStringDto item,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Specified Entitiy ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XStringDto> AddOrUpdateEntity(XStringDto item);
|
||||
Task<XStringDto> AddOrUpdateEntity(
|
||||
XStringDto item,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Locale Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XStringDto> AddByLocaleResource(
|
||||
XLocaleResourceDto item,
|
||||
string resource
|
||||
string resource,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
@@ -199,10 +222,12 @@ namespace xStringService.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XStringDto> UpdateByLocaleResource(
|
||||
XLocaleResourceDto item,
|
||||
string resource
|
||||
string resource,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
@@ -210,18 +235,24 @@ namespace xStringService.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XStringDto> AddOrUpdateByLocaleResource(
|
||||
XLocaleResourceDto item,
|
||||
string resource
|
||||
string resource,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update all XResourceDto(s) Locales ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XStringDto>> AddByResource(XResourceDto item);
|
||||
Task<IEnumerable<XStringDto>> AddByResource(
|
||||
XResourceDto item,
|
||||
string connectionId = null
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
@@ -230,33 +261,47 @@ namespace xStringService.Interfaces
|
||||
/// Remove all Specified Language's Resources ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveLanguageResources(string language);
|
||||
Task RemoveLanguageResources(
|
||||
string language,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Specified Resource Ids instances ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XStringDto>> RemoveResource(string resource);
|
||||
Task<IEnumerable<XStringDto>> RemoveResource(
|
||||
string resource,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Remove(
|
||||
string resource,
|
||||
string language = null
|
||||
string language = null,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Resource of Specified XResourceDto ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveByResource(XResourceDto item);
|
||||
Task RemoveByResource(
|
||||
XResourceDto item,
|
||||
string connectionId = null
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ namespace xStringService.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
Task<ActionResult<XQueryResult<string>>> QueryResourceIds(
|
||||
ActionResult<XQueryResult<string>> QueryResourceIds(
|
||||
[FromQuery] XQuery query
|
||||
);
|
||||
|
||||
|
||||
+243
-22
@@ -3,13 +3,18 @@ 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;
|
||||
using xDataService.Configuration;
|
||||
using xDataService.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Constants;
|
||||
using xStringService.Constants;
|
||||
using xStringService.Extensions;
|
||||
using xStringService.Hubs;
|
||||
using xStringService.Interfaces;
|
||||
using xStringService.Interfaces.Entities;
|
||||
using xStringService.Models.Dtos;
|
||||
@@ -21,6 +26,7 @@ namespace xStringService.Providers
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
public IHubContext<XStringHub> Hub { get; }
|
||||
public IXStringRepository Repository { get; }
|
||||
public XAppConfiguration AppConfiguration { get; }
|
||||
public XDataServiceConfiguration DataConfiguration { get; }
|
||||
@@ -31,13 +37,15 @@ namespace xStringService.Providers
|
||||
public XStringProvider(
|
||||
IXStringRepository repository,
|
||||
XAppConfiguration appConfiguration,
|
||||
XDataServiceConfiguration dataConfiguration
|
||||
XDataServiceConfiguration dataConfiguration,
|
||||
IHubContext<XStringHub> hub = null
|
||||
)
|
||||
{
|
||||
//
|
||||
Repository = repository;
|
||||
AppConfiguration = appConfiguration;
|
||||
DataConfiguration = dataConfiguration;
|
||||
Hub = hub;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -304,7 +312,7 @@ namespace xStringService.Providers
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XQueryResult<string>> QueryResourceIds(XQuery query)
|
||||
public XQueryResult<string> QueryResourceIds(XQuery query)
|
||||
{
|
||||
//
|
||||
// Normalize ...
|
||||
@@ -562,11 +570,13 @@ namespace xStringService.Providers
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Add(
|
||||
string resource,
|
||||
string value,
|
||||
string language = null
|
||||
string language = null,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -607,8 +617,17 @@ namespace xStringService.Providers
|
||||
TranslatedValue = value,
|
||||
ResourceTitle = resource,
|
||||
};
|
||||
var added = await Repository.AddAsync(entity);
|
||||
result = !added.IsNullOrDefault();
|
||||
entity = await Repository.AddAsync(entity);
|
||||
result = !entity.IsNullOrDefault();
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||
entityId: entity.Id,
|
||||
connectionId: connectionId
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -620,11 +639,13 @@ namespace xStringService.Providers
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Update(
|
||||
string resource,
|
||||
string value,
|
||||
string language = null
|
||||
string language = null,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -674,6 +695,15 @@ namespace xStringService.Providers
|
||||
entity.TranslatedValue = value;
|
||||
entity = await Repository.UpdateAsync(entity.Id, entity);
|
||||
result = !entity.IsNullOrDefault();
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
entityId: entity.Id,
|
||||
connectionId: connectionId
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -685,11 +715,13 @@ namespace xStringService.Providers
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddOrUpdate(
|
||||
string resource,
|
||||
string value,
|
||||
string language = null
|
||||
string language = null,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -738,8 +770,12 @@ namespace xStringService.Providers
|
||||
/// Add Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XStringDto> AddEntity(XStringDto item)
|
||||
public async Task<XStringDto> AddEntity(
|
||||
XStringDto item,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
@@ -787,6 +823,13 @@ namespace xStringService.Providers
|
||||
XException.ActionFailed.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||
entityId: result.Id,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return result.ToXStringDto();
|
||||
}
|
||||
@@ -795,8 +838,12 @@ namespace xStringService.Providers
|
||||
/// Update Specified Entity ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XStringDto> UpdateEntity(XStringDto item)
|
||||
public async Task<XStringDto> UpdateEntity(
|
||||
XStringDto item,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
@@ -852,6 +899,11 @@ namespace xStringService.Providers
|
||||
|
||||
//
|
||||
XStringDto result = entity.ToXStringDto();
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
entityId: entity.Id,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -861,8 +913,12 @@ namespace xStringService.Providers
|
||||
/// Add Or Update Specified Entitiy ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XStringDto> AddOrUpdateEntity(XStringDto item)
|
||||
public async Task<XStringDto> AddOrUpdateEntity(
|
||||
XStringDto item,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
@@ -897,11 +953,11 @@ namespace xStringService.Providers
|
||||
XStringDto result = null;
|
||||
if (!isExists)
|
||||
{
|
||||
result = await AddEntity(item);
|
||||
result = await AddEntity(item, connectionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await UpdateEntity(item);
|
||||
result = await UpdateEntity(item, connectionId);
|
||||
}
|
||||
if (result.IsNullOrDefault())
|
||||
{
|
||||
@@ -917,10 +973,12 @@ namespace xStringService.Providers
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XStringDto> AddByLocaleResource(
|
||||
XLocaleResourceDto item,
|
||||
string resource
|
||||
string resource,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -954,7 +1012,7 @@ namespace xStringService.Providers
|
||||
ResourceTitle = resource,
|
||||
TranslatedValue = item.Value
|
||||
};
|
||||
result = await AddEntity(result);
|
||||
result = await AddEntity(result, connectionId);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -965,10 +1023,12 @@ namespace xStringService.Providers
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XStringDto> UpdateByLocaleResource(
|
||||
XLocaleResourceDto item,
|
||||
string resource
|
||||
string resource,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1015,6 +1075,13 @@ namespace xStringService.Providers
|
||||
|
||||
//
|
||||
XStringDto result = entity.ToXStringDto();
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
entityId: entity.Id,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1023,10 +1090,12 @@ namespace xStringService.Providers
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XStringDto> AddOrUpdateByLocaleResource(
|
||||
XLocaleResourceDto item,
|
||||
string resource
|
||||
string resource,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1079,8 +1148,12 @@ namespace xStringService.Providers
|
||||
/// Add Or Update all XResourceDto(s) Locales ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XStringDto>> AddByResource(XResourceDto item)
|
||||
public async Task<IEnumerable<XStringDto>> AddByResource(
|
||||
XResourceDto item,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
@@ -1109,8 +1182,12 @@ namespace xStringService.Providers
|
||||
/// Remove all Specified Language's Resources ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task RemoveLanguageResources(string language)
|
||||
public async Task RemoveLanguageResources(
|
||||
string language,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
@@ -1123,15 +1200,37 @@ namespace xStringService.Providers
|
||||
//
|
||||
var entities = await Repository
|
||||
.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>
|
||||
/// Remove all Specified Resource Ids instances ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XStringDto>> RemoveResource(string resource)
|
||||
public async Task<IEnumerable<XStringDto>> RemoveResource(
|
||||
string resource,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
@@ -1162,10 +1273,12 @@ namespace xStringService.Providers
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Remove(
|
||||
string resource,
|
||||
string language = null
|
||||
string language = null,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1215,6 +1328,15 @@ namespace xStringService.Providers
|
||||
// Delete ...
|
||||
entity = await Repository.RemoveAsync(entity.Id);
|
||||
result = !entity.IsNullOrDefault();
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
entityId: entity.Id,
|
||||
connectionId: connectionId
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -1224,8 +1346,12 @@ namespace xStringService.Providers
|
||||
/// Remove all Resource of Specified XResourceDto ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task RemoveByResource(XResourceDto item)
|
||||
public async Task RemoveByResource(
|
||||
XResourceDto item,
|
||||
string connectionId = null
|
||||
)
|
||||
{
|
||||
//
|
||||
bool isValid =
|
||||
@@ -1248,5 +1374,100 @@ namespace xStringService.Providers
|
||||
}
|
||||
}
|
||||
#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" />
|
||||
</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 -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../xDataService/xDataService.csproj" />
|
||||
<!-- <ProjectReference Include="../xDataService/xDataService.csproj" /> -->
|
||||
<ProjectReference Include="../xPushService/xPushService.csproj" />
|
||||
<ProjectReference Include="../xIdentityService/xIdentityService.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user