This commit is contained in:
20
server/AyaNova/ControllerHelpers/UserLocaleIdFromContext.cs
Normal file
20
server/AyaNova/ControllerHelpers/UserLocaleIdFromContext.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using EnumsNET;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AyaNova.Api.ControllerHelpers
|
||||||
|
{
|
||||||
|
|
||||||
|
internal static class UserLocaleIdFromContext
|
||||||
|
{
|
||||||
|
internal static long LocaleId(IDictionary<object, object> HttpContextItems)
|
||||||
|
{
|
||||||
|
|
||||||
|
long? l = (long?)HttpContextItems["AY_LOCALE_ID"];
|
||||||
|
if (l==null)
|
||||||
|
return 0L;
|
||||||
|
return (long)l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}//eons
|
||||||
@@ -67,7 +67,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(401, new ApiNotAuthorizedResponse());
|
return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await EventLogProcessor.GetLogForObject(opt.AyId, ct);
|
var result = await EventLogProcessor.GetLogForObject(opt.AyId, UserLocaleIdFromContext.LocaleId(HttpContext.Items), ct);
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
EventLogProcessor.AddEntry(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.Metrics, AyaEvent.Retrieved), ct);
|
EventLogProcessor.AddEntry(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.Metrics, AyaEvent.Retrieved), ct);
|
||||||
@@ -107,7 +107,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(401, new ApiNotAuthorizedResponse());
|
return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await EventLogProcessor.GetLogForUser(opt.AyId, ct);
|
var result = await EventLogProcessor.GetLogForUser(opt.AyId, UserLocaleIdFromContext.LocaleId(HttpContext.Items), ct);
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
EventLogProcessor.AddEntry(new Event(UserId, 0, AyaType.Metrics, AyaEvent.Retrieved), ct);
|
EventLogProcessor.AddEntry(new Event(UserId, 0, AyaType.Metrics, AyaEvent.Retrieved), ct);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace AyaNova
|
|||||||
_hostingEnvironment = hostingEnvironment;
|
_hostingEnvironment = hostingEnvironment;
|
||||||
AyaNova.Util.ApplicationLogging.LoggerFactory = logFactory;
|
AyaNova.Util.ApplicationLogging.LoggerFactory = logFactory;
|
||||||
//this must be set here
|
//this must be set here
|
||||||
ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH=hostingEnvironment.ContentRootPath;
|
ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH = hostingEnvironment.ContentRootPath;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,10 +337,11 @@ namespace AyaNova
|
|||||||
var ct = context.RequestServices.GetService<AyContext>();
|
var ct = context.RequestServices.GetService<AyContext>();
|
||||||
|
|
||||||
//get the user record
|
//get the user record
|
||||||
var u = ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, Id = m.Id }).First();
|
var u = ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, Id = m.Id, LocaleId = m.LocaleId }).First();
|
||||||
context.Request.HttpContext.Items["AY_ROLES"] = u.roles;
|
context.Request.HttpContext.Items["AY_ROLES"] = u.roles;
|
||||||
context.Request.HttpContext.Items["AY_USERNAME"] = u.name;
|
context.Request.HttpContext.Items["AY_USERNAME"] = u.name;
|
||||||
context.Request.HttpContext.Items["AY_USER_ID"] = u.Id;
|
context.Request.HttpContext.Items["AY_USER_ID"] = u.Id;
|
||||||
|
context.Request.HttpContext.Items["AY_LOCALE_ID"] = u.LocaleId;
|
||||||
}
|
}
|
||||||
await next.Invoke();
|
await next.Invoke();
|
||||||
});
|
});
|
||||||
@@ -384,13 +385,13 @@ namespace AyaNova
|
|||||||
// AyaNova.Core.License.Initialize(apiServerState, dbContext, _log);
|
// AyaNova.Core.License.Initialize(apiServerState, dbContext, _log);
|
||||||
// AyaNova.Core.License.Fetch(apiServerState, dbContext, _log);
|
// AyaNova.Core.License.Fetch(apiServerState, dbContext, _log);
|
||||||
// Util.Seeder.SeedDatabase(dbContext, Util.Seeder.SeedLevel.SmallOneManShopTrialDataSet);
|
// Util.Seeder.SeedDatabase(dbContext, Util.Seeder.SeedLevel.SmallOneManShopTrialDataSet);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Open up the server for visitors
|
//Open up the server for visitors
|
||||||
apiServerState.SetOpen();
|
apiServerState.SetOpen();
|
||||||
|
|||||||
@@ -43,12 +43,32 @@ namespace AyaNova.Biz
|
|||||||
ct.SaveChanges();
|
ct.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Task<string> GetLogForObject(long ayId, AyContext ct)
|
/// <summary>
|
||||||
|
/// Get the event log for a specified object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ayId"></param>
|
||||||
|
/// <param name="userLocaleId"></param>
|
||||||
|
/// <param name="ct"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
internal static async Task<string> GetLogForObject(long ayId, long userLocaleId, AyContext ct)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var items = await ct.Event
|
||||||
|
.Where(m => m.AyId == ayId)
|
||||||
|
.OrderBy(m => m.Created)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
AyaNova.Api.Controllers.LocaleController.LocaleSubsetParam param = new Api.Controllers.LocaleController.LocaleSubsetParam();
|
||||||
|
param.LocaleId = userLocaleId;
|
||||||
|
param.Keys.AddRange(new string[] { "CommonCreated", "Delete","Modified","Retrieved" });
|
||||||
|
var LT = LocaleBiz.GetSubsetStatic(param);
|
||||||
|
|
||||||
|
//Have list of locales
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Task<string> GetLogForUser(long ayId, AyContext ct)
|
internal static Task<string> GetLogForUser(long ayId, long userLocaleId, AyContext ct)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,16 @@ namespace AyaNova.Biz
|
|||||||
return ret.ToList();
|
return ret.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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)
|
||||||
|
{
|
||||||
|
AyContext ct = ServiceProviderProvider.DBContext;
|
||||||
|
if (!LocaleExistsStatic(param.LocaleId, ct))
|
||||||
|
param.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);
|
||||||
|
return ret.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the value of the key provided in the default locale chosen
|
/// Get the value of the key provided in the default locale chosen
|
||||||
@@ -133,7 +143,7 @@ namespace AyaNova.Biz
|
|||||||
internal bool PutLocaleItemDisplayText(LocaleItem dbObj, NewTextIdConcurrencyTokenItem inObj, Locale dbParent)
|
internal bool PutLocaleItemDisplayText(LocaleItem dbObj, NewTextIdConcurrencyTokenItem inObj, Locale dbParent)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (dbParent.Stock == true)
|
if (dbParent.Stock == true)
|
||||||
{
|
{
|
||||||
AddError(ValidationErrorType.InvalidOperation, "object", "LocaleItem is from a Stock locale and cannot be modified");
|
AddError(ValidationErrorType.InvalidOperation, "object", "LocaleItem is from a Stock locale and cannot be modified");
|
||||||
return false;
|
return false;
|
||||||
@@ -271,6 +281,11 @@ namespace AyaNova.Biz
|
|||||||
return ct.Locale.Any(e => e.Id == id);
|
return ct.Locale.Any(e => e.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool LocaleExistsStatic(long id, AyContext ct)
|
||||||
|
{
|
||||||
|
return ct.Locale.Any(e => e.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
public bool LocaleItemExists(long id)
|
public bool LocaleItemExists(long id)
|
||||||
{
|
{
|
||||||
return ct.LocaleItem.Any(e => e.Id == id);
|
return ct.LocaleItem.Any(e => e.Id == id);
|
||||||
|
|||||||
@@ -1411,5 +1411,8 @@
|
|||||||
"WorkorderStatusName": "Arbeitsauftragsstatus - Name",
|
"WorkorderStatusName": "Arbeitsauftragsstatus - Name",
|
||||||
"WorkorderStatusUnderlined": "Unterstrichen",
|
"WorkorderStatusUnderlined": "Unterstrichen",
|
||||||
"WorkorderSummaryTemplate": "Arbeitsauftragspostenzusammenfassung - Vorlage",
|
"WorkorderSummaryTemplate": "Arbeitsauftragspostenzusammenfassung - Vorlage",
|
||||||
"WorkorderSummaryWorkorderItem": "Anzuzeigende Informationen über Arbeitsauftragsposten"
|
"WorkorderSummaryWorkorderItem": "Anzuzeigende Informationen über Arbeitsauftragsposten",
|
||||||
|
|
||||||
|
"Modified":"Modified",
|
||||||
|
"Retrieved":"Retrieved"
|
||||||
}
|
}
|
||||||
@@ -1411,5 +1411,8 @@
|
|||||||
"WorkorderStatusName": "Workorder Status Name",
|
"WorkorderStatusName": "Workorder Status Name",
|
||||||
"WorkorderStatusUnderlined": "Underlined",
|
"WorkorderStatusUnderlined": "Underlined",
|
||||||
"WorkorderSummaryTemplate": "Workorder Item Summary Template",
|
"WorkorderSummaryTemplate": "Workorder Item Summary Template",
|
||||||
"WorkorderSummaryWorkorderItem": "Workorder Item Info To Display"
|
"WorkorderSummaryWorkorderItem": "Workorder Item Info To Display",
|
||||||
|
|
||||||
|
"Modified":"Modified",
|
||||||
|
"Retrieved":"Retrieved"
|
||||||
}
|
}
|
||||||
@@ -1411,5 +1411,8 @@
|
|||||||
"WorkorderStatusName": "Nombre estado del pedido",
|
"WorkorderStatusName": "Nombre estado del pedido",
|
||||||
"WorkorderStatusUnderlined": "Subrayado",
|
"WorkorderStatusUnderlined": "Subrayado",
|
||||||
"WorkorderSummaryTemplate": "Plantilla resumen elemento pedido",
|
"WorkorderSummaryTemplate": "Plantilla resumen elemento pedido",
|
||||||
"WorkorderSummaryWorkorderItem": "Información mostrada elemento de pedido"
|
"WorkorderSummaryWorkorderItem": "Información mostrada elemento de pedido",
|
||||||
|
|
||||||
|
"Modified":"Modified",
|
||||||
|
"Retrieved":"Retrieved"
|
||||||
}
|
}
|
||||||
@@ -1411,5 +1411,8 @@
|
|||||||
"WorkorderStatusName": "Nom d'état de bon de travail",
|
"WorkorderStatusName": "Nom d'état de bon de travail",
|
||||||
"WorkorderStatusUnderlined": "Souligné",
|
"WorkorderStatusUnderlined": "Souligné",
|
||||||
"WorkorderSummaryTemplate": "Modèle de résumé d'élément de bon de travail",
|
"WorkorderSummaryTemplate": "Modèle de résumé d'élément de bon de travail",
|
||||||
"WorkorderSummaryWorkorderItem": "Infos de bon de travail à afficher"
|
"WorkorderSummaryWorkorderItem": "Infos de bon de travail à afficher",
|
||||||
}
|
|
||||||
|
"Modified": "Modified",
|
||||||
|
"Retrieved":"Retrieved"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user