This commit is contained in:
@@ -95,10 +95,13 @@ CHANGES:
|
||||
- If the text is changed at the server then a notification should occur for clients using that local to invalidate their cache
|
||||
- Although, that would be a pretty rare event so...maybe not so much, a logout could clear the cache or a login I guess
|
||||
|
||||
|
||||
***********************************************************************************************************************************
|
||||
|
||||
LOCALIZED TEXT KEYS ACTUALLY USED
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
Here are the localized text keys in RAVEN that have been specified for use at any level.
|
||||
|
||||
|
||||
NewKeyValue, OldKeyValue
|
||||
------------------------
|
||||
|
||||
|
||||
@@ -28,11 +28,7 @@ Once that is done then can steam ahead on the biz objects but until I have the c
|
||||
IMMEDIATE ITEMS:
|
||||
================
|
||||
|
||||
- Need an ObjectExists type object for checking if something exists when specified by type and ID
|
||||
- Could this be a combined method to get the name as well just to save time?
|
||||
- Or should that be another method (YES, first code a translator to translate types to db tables (however the fuck that works with EF),
|
||||
then can use it in turn to verify existance and get name separately)
|
||||
- Once we have that go back into any code that accepts a typeandid and add to Validation code to check for it
|
||||
|
||||
- Localized text
|
||||
- ** DEVISE a system to ensure no unused keys are brought forward to raven
|
||||
- Search and search text indexing
|
||||
|
||||
@@ -108,6 +108,30 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
#if (DEBUG)
|
||||
/// <summary>
|
||||
/// Get all unique Locale keys that were tracked
|
||||
/// Required roles: Any
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>List in alphabetical order of all unique locale keys requested since last server reboot</returns>
|
||||
[HttpGet("RequestedKeyList")]
|
||||
public ActionResult RequestedKeyList()
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
//Instantiate the business object handler
|
||||
LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||
|
||||
var l = biz.RequestedKeyList();
|
||||
return Ok(new ApiOkResponse(l));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get subset of locale values
|
||||
/// Required roles: Any
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace AyaNova.Biz
|
||||
//AyaNova.Biz.BizObjectExistsInDatabase
|
||||
//AyaNova.Biz.BizObjectFactory
|
||||
//AyaNova.Biz.BizRoles
|
||||
//AyaNova.Biz.BizObjectNameFetcher
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -97,9 +97,39 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
|
||||
#if (DEBUG)
|
||||
internal List<string> RequestedKeyList()
|
||||
{
|
||||
return ServerBootConfig.LocaleKeysRequested;
|
||||
}
|
||||
|
||||
//Track requests for keys so we can determine which are being used and which are not
|
||||
//TODO: Ideally this should be paired with tests that either directly request each key that are def. being used
|
||||
//or the UI needs to be tested in a way that triggers every key to be used even errors etc
|
||||
internal static void TrackRequestedKey(string key)
|
||||
{
|
||||
if (!ServerBootConfig.LocaleKeysRequested.Contains(key))
|
||||
ServerBootConfig.LocaleKeysRequested.Add(key);
|
||||
}
|
||||
|
||||
internal static void TrackRequestedKey(List<string> keys)
|
||||
{
|
||||
foreach (string Key in keys)
|
||||
{
|
||||
if (!ServerBootConfig.LocaleKeysRequested.Contains(Key))
|
||||
ServerBootConfig.LocaleKeysRequested.Add(Key);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Get the keys for a list of keys provided
|
||||
internal async Task<List<KeyValuePair<string, string>>> GetSubset(AyaNova.Api.Controllers.LocaleController.LocaleSubsetParam param)
|
||||
{
|
||||
|
||||
#if (DEBUG)
|
||||
TrackRequestedKey(param.Keys);
|
||||
#endif
|
||||
var ret = await ct.LocaleItem.Where(x => x.LocaleId == param.LocaleId && param.Keys.Contains(x.Key)).ToDictionaryAsync(x => x.Key, x => x.Display);
|
||||
return ret.ToList();
|
||||
}
|
||||
@@ -107,6 +137,9 @@ namespace AyaNova.Biz
|
||||
//Get the keys for a list of keys provided, static format for calling from other internal classes
|
||||
internal static async Task<List<KeyValuePair<string, string>>> GetSubsetStatic(AyaNova.Api.Controllers.LocaleController.LocaleSubsetParam param)
|
||||
{
|
||||
#if (DEBUG)
|
||||
TrackRequestedKey(param.Keys);
|
||||
#endif
|
||||
AyContext ct = ServiceProviderProvider.DBContext;
|
||||
if (!LocaleExistsStatic(param.LocaleId, ct))
|
||||
param.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
||||
@@ -124,6 +157,9 @@ namespace AyaNova.Biz
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
return "ERROR: GetDefaultLocalizedText NO KEY VALUE SPECIFIED";
|
||||
#if (DEBUG)
|
||||
TrackRequestedKey(key);
|
||||
#endif
|
||||
AyContext ct = ServiceProviderProvider.DBContext;
|
||||
return await ct.LocaleItem.Where(m => m.LocaleId == ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID && m.Key == key).Select(m => m.Display).FirstOrDefaultAsync();
|
||||
}
|
||||
@@ -439,9 +475,11 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//Now add keys that were added after v7 for RAVEN using default locale values
|
||||
foreach(string s in ValidKeys){
|
||||
if(!NewLocaleDict.ContainsKey(s)){
|
||||
NewLocaleDict.Add(s,GetDefaultLocalizedText(s).Result);
|
||||
foreach (string s in ValidKeys)
|
||||
{
|
||||
if (!NewLocaleDict.ContainsKey(s))
|
||||
{
|
||||
NewLocaleDict.Add(s, GetDefaultLocalizedText(s).Result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
@@ -11,6 +12,14 @@ namespace AyaNova.Util
|
||||
internal static class ServerBootConfig
|
||||
{
|
||||
|
||||
|
||||
//Diagnostic static values used during development, may not be related to config at all, this is just a convenient class to put them in
|
||||
#if (DEBUG)
|
||||
internal static List<string> LocaleKeysRequested { get; set; }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//CONTENTROOTPATH
|
||||
internal static string AYANOVA_CONTENT_ROOT_PATH { get; set; } //Note: set in startup.cs, not in program.cs as it requires startup IHostingEnvironment
|
||||
|
||||
@@ -55,6 +64,11 @@ namespace AyaNova.Util
|
||||
/// <param name="config"></param>
|
||||
internal static void SetConfiguration(IConfigurationRoot config)
|
||||
{
|
||||
|
||||
#if (DEBUG)
|
||||
LocaleKeysRequested = new List<string>();
|
||||
#endif
|
||||
|
||||
bool? bTemp = null;
|
||||
|
||||
#region SERVER BASICS
|
||||
|
||||
Reference in New Issue
Block a user