This commit is contained in:
@@ -187,6 +187,7 @@ namespace AyaNova.Api.Controllers
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> SubSet([FromRoute] long id, [FromBody] List<string> inObj)
|
||||
{
|
||||
//## NOTE: This route is ONLY used at present for the reset password form at the client
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
var l = await TranslationBiz.GetSpecifiedTranslationSubsetStaticAsync(inObj, id);
|
||||
|
||||
@@ -465,7 +465,7 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTIFICATION PROCESSING
|
||||
//
|
||||
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj=null)
|
||||
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||
{
|
||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<ReviewBiz>();
|
||||
if (ServerBootConfig.SEEDING) return;
|
||||
@@ -501,6 +501,8 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
{
|
||||
var eventNameTranslated = await TranslationBiz.GetTranslationForUserStaticAsync("ReviewOverDue", r.UserId);
|
||||
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.GeneralNotification,
|
||||
@@ -508,7 +510,7 @@ namespace AyaNova.Biz
|
||||
ObjectId = proposedObj.Id,
|
||||
AyaType = AyaType.Review,
|
||||
NotifySubscriptionId = userNotifySub.Id,
|
||||
Name = "LT:ReviewOverDue - " + proposedObj.Name,
|
||||
Name = $"{eventNameTranslated} - {proposedObj.Name}",
|
||||
EventDate = r.DueDate
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
@@ -517,6 +519,7 @@ namespace AyaNova.Biz
|
||||
|
||||
if (supervisorNotifySub != null)
|
||||
{
|
||||
var eventNameTranslated = await TranslationBiz.GetTranslationForUserStaticAsync("ReviewOverDue", r.AssignedByUserId);
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.GeneralNotification,
|
||||
@@ -524,7 +527,7 @@ namespace AyaNova.Biz
|
||||
ObjectId = proposedObj.Id,
|
||||
AyaType = AyaType.Review,
|
||||
NotifySubscriptionId = supervisorNotifySub.Id,
|
||||
Name = "LT:ReviewOverDue - " + proposedObj.Name,
|
||||
Name = $"{eventNameTranslated} - {proposedObj.Name}",
|
||||
EventDate = r.DueDate
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace AyaNova.Biz
|
||||
|
||||
internal class TranslationBiz : BizObject
|
||||
{
|
||||
|
||||
|
||||
|
||||
internal TranslationBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles userRoles)
|
||||
{
|
||||
@@ -20,7 +20,7 @@ namespace AyaNova.Biz
|
||||
UserId = currentUserId;
|
||||
UserTranslationId = userTranslationId;
|
||||
CurrentUserRoles = userRoles;
|
||||
BizType = AyaType.Translation;
|
||||
BizType = AyaType.Translation;
|
||||
}
|
||||
|
||||
internal static TranslationBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
|
||||
@@ -335,7 +335,7 @@ namespace AyaNova.Biz
|
||||
// Get subset for specified translation ID
|
||||
// called from controller and Used when user is not logged in
|
||||
// e.g. when resetting their password
|
||||
//
|
||||
// ## NOTE: NO other use for this other than the reset password at this point
|
||||
internal static async Task<List<KeyValuePair<string, string>>> GetSpecifiedTranslationSubsetStaticAsync(List<string> param, long translationId)
|
||||
{
|
||||
#if (DEBUG)
|
||||
@@ -371,6 +371,43 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Get subset for specified user (looks up translation id) statically
|
||||
// called from internal code (e.g. notification processing)
|
||||
//
|
||||
internal static async Task<Dictionary<string, string>> GetSubsetForUserStaticAsync(List<string> param, long userId)
|
||||
{
|
||||
long translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
translationId = await ct.UserOptions.AsNoTracking().Where(z => z.UserId == userId).Select(z => z.TranslationId).SingleAsync();
|
||||
}
|
||||
return await GetSubsetStaticAsync(param, translationId);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Get single item for specified user (looks up translation id) statically
|
||||
// called from internal code (e.g. notification processing)
|
||||
//
|
||||
internal static async Task<string> GetTranslationForUserStaticAsync(string translationKey, long userId)
|
||||
{
|
||||
long translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
translationId = await ct.UserOptions.AsNoTracking().Where(z => z.UserId == userId).Select(z => z.TranslationId).SingleAsync();
|
||||
}
|
||||
var param = new List<string>() { translationKey };
|
||||
var ret = await GetSubsetStaticAsync(param, translationId);
|
||||
if (ret.Count > 0) return ret[translationKey];
|
||||
return $"??{translationKey}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//used by internal notification and other processes i.e. "Server" in all languages for server based notifications
|
||||
internal static async Task<Dictionary<long, string>> GetAllTranslationsForKey(string translationKey)
|
||||
{
|
||||
@@ -394,28 +431,29 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the value of the key provided in the default translation chosen
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
internal static async Task<string> GetDefaultTranslationAsync(string key)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
return "ERROR: GetDefaultTranslation NO KEY VALUE SPECIFIED";
|
||||
#if (DEBUG)
|
||||
TrackRequestedKey(key);
|
||||
#endif
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
return await ct.TranslationItem.Where(z => z.TranslationId == ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID && z.Key == key).Select(z => z.Display).AsNoTracking().FirstOrDefaultAsync();
|
||||
}
|
||||
//DEPRECATED
|
||||
// /// <summary>
|
||||
// /// Get the value of the key provided in the default translation chosen
|
||||
// /// </summary>
|
||||
// /// <param name="key"></param>
|
||||
// /// <returns></returns>
|
||||
// internal static async Task<string> GetDefaultTranslationAsync(string key)
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(key))
|
||||
// return "ERROR: GetDefaultTranslation NO KEY VALUE SPECIFIED";
|
||||
// #if (DEBUG)
|
||||
// TrackRequestedKey(key);
|
||||
// #endif
|
||||
// using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
// return await ct.TranslationItem.Where(z => z.TranslationId == ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID && z.Key == key).Select(z => z.Display).AsNoTracking().FirstOrDefaultAsync();
|
||||
// }
|
||||
|
||||
//Get all stock keys that are valid (used for key coverage reporting)
|
||||
internal static async Task<List<string>> GetKeyListAsync()
|
||||
{
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
return await ct.TranslationItem.Where(z => z.TranslationId == 1).OrderBy(z => z.Key).Select(z => z.Key).AsNoTracking().ToListAsync();
|
||||
}
|
||||
// //Get all stock keys that are valid (used for key coverage reporting)
|
||||
// internal static async Task<List<string>> GetKeyListAsync()
|
||||
// {
|
||||
// using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
// return await ct.TranslationItem.Where(z => z.TranslationId == 1).OrderBy(z => z.Key).Select(z => z.Key).AsNoTracking().ToListAsync();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user