This commit is contained in:
@@ -72,7 +72,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
// LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
LocaleBiz biz = LocaleBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
var o = await biz.GetAsync(id);
|
var o = await biz.GetAsync(id);
|
||||||
|
|
||||||
@@ -101,7 +102,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
//LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
LocaleBiz biz = LocaleBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
var l = await biz.GetPickListAsync();
|
var l = await biz.GetPickListAsync();
|
||||||
return Ok(new ApiOkResponse(l));
|
return Ok(new ApiOkResponse(l));
|
||||||
@@ -124,7 +126,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
LocaleBiz biz = LocaleBiz.GetBiz(ct, HttpContext);
|
||||||
|
//LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
|
||||||
var l = biz.LocaleKeyCoverage();
|
var l = biz.LocaleKeyCoverage();
|
||||||
return Ok(new ApiOkResponse(l));
|
return Ok(new ApiOkResponse(l));
|
||||||
@@ -137,10 +140,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// Required roles: Any
|
/// Required roles: Any
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inObj">LocaleSubsetParam object defining the locale Id and a list of keys required</param>
|
/// <param name="inObj">List of locale key strings</param>
|
||||||
/// <returns>A key value array of localized text values</returns>
|
/// <returns>A key value array of localized text values</returns>
|
||||||
[HttpPost("SubSet")]
|
[HttpPost("SubSet")]
|
||||||
public async Task<IActionResult> SubSet([FromBody] LocaleSubsetParam inObj)
|
public async Task<IActionResult> SubSet([FromBody] List<string> inObj)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
{
|
{
|
||||||
@@ -148,7 +151,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
//LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
|
||||||
|
//Instantiate the business object handler
|
||||||
|
LocaleBiz biz = LocaleBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
var l = await biz.GetSubset(inObj);
|
var l = await biz.GetSubset(inObj);
|
||||||
return Ok(new ApiOkResponse(l));
|
return Ok(new ApiOkResponse(l));
|
||||||
@@ -172,7 +178,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
// LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
LocaleBiz biz = LocaleBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
var o = await biz.DuplicateAsync(inObj);
|
var o = await biz.DuplicateAsync(inObj);
|
||||||
|
|
||||||
@@ -232,7 +239,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
// LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
LocaleBiz biz = LocaleBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -297,7 +305,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
//LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
LocaleBiz biz = LocaleBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -365,7 +374,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
//LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
LocaleBiz biz = LocaleBiz.GetBiz(ct, HttpContext);
|
||||||
if (!biz.Delete(dbObj))
|
if (!biz.Delete(dbObj))
|
||||||
{
|
{
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
@@ -395,19 +405,19 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
//------------
|
//------------
|
||||||
|
|
||||||
public class LocaleSubsetParam
|
// public class LocaleSubsetParam
|
||||||
{
|
// {
|
||||||
[System.ComponentModel.DataAnnotations.Required]
|
// [System.ComponentModel.DataAnnotations.Required]
|
||||||
public long LocaleId { get; set; }
|
// public long LocaleId { get; set; }
|
||||||
[System.ComponentModel.DataAnnotations.Required]
|
// [System.ComponentModel.DataAnnotations.Required]
|
||||||
public List<string> Keys { get; set; }
|
// public List<string> Keys { get; set; }
|
||||||
|
|
||||||
public LocaleSubsetParam()
|
// public LocaleSubsetParam()
|
||||||
{
|
// {
|
||||||
Keys = new List<string>();
|
// Keys = new List<string>();
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
public class LocaleCoverageInfo
|
public class LocaleCoverageInfo
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace AyaNova.Biz
|
|||||||
case AyaType.TrialSeeder:
|
case AyaType.TrialSeeder:
|
||||||
return new TrialBiz(dbcontext, userId, roles);
|
return new TrialBiz(dbcontext, userId, roles);
|
||||||
case AyaType.Locale:
|
case AyaType.Locale:
|
||||||
return new LocaleBiz(dbcontext, userId, roles);
|
return new LocaleBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -20,15 +20,27 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
public bool SeedOrImportRelaxedRulesMode { get; set; }
|
public bool SeedOrImportRelaxedRulesMode { get; set; }
|
||||||
|
|
||||||
internal LocaleBiz(AyContext dbcontext, long currentUserId, AuthorizationRoles userRoles)
|
internal LocaleBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles userRoles)
|
||||||
{
|
{
|
||||||
ct = dbcontext;
|
ct = dbcontext;
|
||||||
UserId = currentUserId;
|
UserId = currentUserId;
|
||||||
|
UserLocaleId = userLocaleId;
|
||||||
CurrentUserRoles = userRoles;
|
CurrentUserRoles = userRoles;
|
||||||
BizType = AyaType.Locale;
|
BizType = AyaType.Locale;
|
||||||
SeedOrImportRelaxedRulesMode = false;//default
|
SeedOrImportRelaxedRulesMode = false;//default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static LocaleBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
|
||||||
|
{
|
||||||
|
return new LocaleBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Version for internal use
|
||||||
|
internal static LocaleBiz GetBizInternal(AyContext ct, long currentUserId, AuthorizationRoles roles)
|
||||||
|
{
|
||||||
|
return new LocaleBiz(ct, currentUserId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -141,26 +153,26 @@ namespace AyaNova.Biz
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Get the keys for a list of keys provided
|
//Get the keys for a list of keys provided
|
||||||
internal async Task<List<KeyValuePair<string, string>>> GetSubset(AyaNova.Api.Controllers.LocaleController.LocaleSubsetParam param)
|
internal async Task<List<KeyValuePair<string, string>>> GetSubset(List<string> param)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
TrackRequestedKey(param.Keys);
|
TrackRequestedKey(param);
|
||||||
#endif
|
#endif
|
||||||
var ret = await ct.LocaleItem.Where(x => x.LocaleId == param.LocaleId && param.Keys.Contains(x.Key)).ToDictionaryAsync(x => x.Key, x => x.Display);
|
var ret = await ct.LocaleItem.Where(x => x.LocaleId == UserLocaleId && param.Contains(x.Key)).ToDictionaryAsync(x => x.Key, x => x.Display);
|
||||||
return ret.ToList();
|
return ret.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the keys for a list of keys provided, static format for calling from other internal classes
|
//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)
|
internal static async Task<List<KeyValuePair<string, string>>> GetSubsetStatic(List<string> param, long localeId)
|
||||||
{
|
{
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
TrackRequestedKey(param.Keys);
|
TrackRequestedKey(param);
|
||||||
#endif
|
#endif
|
||||||
AyContext ct = ServiceProviderProvider.DBContext;
|
AyContext ct = ServiceProviderProvider.DBContext;
|
||||||
if (!LocaleExistsStatic(param.LocaleId, ct))
|
if (!LocaleExistsStatic(localeId, ct))
|
||||||
param.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
localeId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
||||||
var ret = await ct.LocaleItem.Where(x => x.LocaleId == param.LocaleId && param.Keys.Contains(x.Key)).ToDictionaryAsync(x => x.Key, x => x.Display);
|
var ret = await ct.LocaleItem.Where(x => x.LocaleId == localeId && param.Contains(x.Key)).ToDictionaryAsync(x => x.Key, x => x.Display);
|
||||||
return ret.ToList();
|
return ret.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using AyaNova.Models;
|
|||||||
namespace AyaNova.Biz
|
namespace AyaNova.Biz
|
||||||
{
|
{
|
||||||
|
|
||||||
//Prime the database with initial, minimum required data to boot and do things (manager account, locales)
|
//Prime the database with initial, minimum required data to boot and do things (manager account, locales)
|
||||||
public static class PrimeData
|
public static class PrimeData
|
||||||
{
|
{
|
||||||
// private readonly AyContext ct;
|
// private readonly AyContext ct;
|
||||||
@@ -29,16 +29,16 @@ namespace AyaNova.Biz
|
|||||||
//get a db and logger
|
//get a db and logger
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("PrimeData");
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("PrimeData");
|
||||||
User u = new User();
|
User u = new User();
|
||||||
u.Active=true;
|
u.Active = true;
|
||||||
u.Name = "AyaNova Administrator";
|
u.Name = "AyaNova Administrator";
|
||||||
u.Salt = Hasher.GenerateSalt();
|
u.Salt = Hasher.GenerateSalt();
|
||||||
u.Login = "manager";
|
u.Login = "manager";
|
||||||
u.Password = Hasher.hash(u.Salt, "l3tm3in");
|
u.Password = Hasher.hash(u.Salt, "l3tm3in");
|
||||||
u.Roles = AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull;
|
u.Roles = AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull;
|
||||||
u.OwnerId = 1;
|
u.OwnerId = 1;
|
||||||
u.LocaleId=ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;//Ensure primeLocales is called first
|
u.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;//Ensure primeLocales is called first
|
||||||
u.UserType=UserType.Administrator;
|
u.UserType = UserType.Administrator;
|
||||||
u.UserOptions=new UserOptions(1);
|
u.UserOptions = new UserOptions(1);
|
||||||
ct.User.Add(u);
|
ct.User.Add(u);
|
||||||
ct.SaveChanges();
|
ct.SaveChanges();
|
||||||
|
|
||||||
@@ -66,7 +66,8 @@ namespace AyaNova.Biz
|
|||||||
ImportLocale(ct, ResourceFolderPath, "de");
|
ImportLocale(ct, ResourceFolderPath, "de");
|
||||||
|
|
||||||
//Ensure locales are present, not missing any keys and that there is a server default locale that exists
|
//Ensure locales are present, not missing any keys and that there is a server default locale that exists
|
||||||
LocaleBiz lb = new LocaleBiz(ct, 1, AuthorizationRoles.OpsAdminFull);
|
//LocaleBiz lb = new LocaleBiz(ct, AuthorizationRoles.OpsAdminFull);
|
||||||
|
LocaleBiz lb = LocaleBiz.GetBizInternal(ct, 1, AuthorizationRoles.OpsAdminFull);
|
||||||
lb.ValidateLocales();
|
lb.ValidateLocales();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -85,7 +86,7 @@ namespace AyaNova.Biz
|
|||||||
l.Name = localeCode;
|
l.Name = localeCode;
|
||||||
l.OwnerId = 1;
|
l.OwnerId = 1;
|
||||||
l.Stock = true;
|
l.Stock = true;
|
||||||
l.CjkIndex=false;
|
l.CjkIndex = false;
|
||||||
|
|
||||||
foreach (JToken t in o.Children())
|
foreach (JToken t in o.Children())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -570,16 +570,16 @@ namespace AyaNova.Biz
|
|||||||
ct = ServiceProviderProvider.DBContext;
|
ct = ServiceProviderProvider.DBContext;
|
||||||
//Get stopwords
|
//Get stopwords
|
||||||
//Validate locale id, if not right then use default instead
|
//Validate locale id, if not right then use default instead
|
||||||
var Param = new Api.Controllers.LocaleController.LocaleSubsetParam();
|
var Param = new List<string>();
|
||||||
Param.LocaleId = LocaleBiz.EnsuredLocaleIdStatic(localeId, ct);
|
localeId = LocaleBiz.EnsuredLocaleIdStatic(localeId, ct);
|
||||||
Param.Keys.Add("StopWords1");
|
Param.Add("StopWords1");
|
||||||
Param.Keys.Add("StopWords2");
|
Param.Add("StopWords2");
|
||||||
Param.Keys.Add("StopWords3");
|
Param.Add("StopWords3");
|
||||||
Param.Keys.Add("StopWords4");
|
Param.Add("StopWords4");
|
||||||
Param.Keys.Add("StopWords5");
|
Param.Add("StopWords5");
|
||||||
Param.Keys.Add("StopWords6");
|
Param.Add("StopWords6");
|
||||||
Param.Keys.Add("StopWords7");
|
Param.Add("StopWords7");
|
||||||
var Stops = LocaleBiz.GetSubsetStatic(Param).Result;
|
var Stops = LocaleBiz.GetSubsetStatic(Param, localeId).Result;
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> kvp in Stops)
|
foreach (KeyValuePair<string, string> kvp in Stops)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user