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());
|
||||
}
|
||||
|
||||
var result = await EventLogProcessor.GetLogForObject(opt.AyId, ct);
|
||||
var result = await EventLogProcessor.GetLogForObject(opt.AyId, UserLocaleIdFromContext.LocaleId(HttpContext.Items), ct);
|
||||
|
||||
//Log
|
||||
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());
|
||||
}
|
||||
|
||||
var result = await EventLogProcessor.GetLogForUser(opt.AyId, ct);
|
||||
var result = await EventLogProcessor.GetLogForUser(opt.AyId, UserLocaleIdFromContext.LocaleId(HttpContext.Items), ct);
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntry(new Event(UserId, 0, AyaType.Metrics, AyaEvent.Retrieved), ct);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace AyaNova
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
AyaNova.Util.ApplicationLogging.LoggerFactory = logFactory;
|
||||
//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>();
|
||||
|
||||
//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_USERNAME"] = u.name;
|
||||
context.Request.HttpContext.Items["AY_USER_ID"] = u.Id;
|
||||
context.Request.HttpContext.Items["AY_LOCALE_ID"] = u.LocaleId;
|
||||
}
|
||||
await next.Invoke();
|
||||
});
|
||||
|
||||
@@ -43,12 +43,32 @@ namespace AyaNova.Biz
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -103,6 +103,16 @@ namespace AyaNova.Biz
|
||||
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>
|
||||
/// 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)
|
||||
{
|
||||
|
||||
if (dbParent.Stock == true)
|
||||
if (dbParent.Stock == true)
|
||||
{
|
||||
AddError(ValidationErrorType.InvalidOperation, "object", "LocaleItem is from a Stock locale and cannot be modified");
|
||||
return false;
|
||||
@@ -271,6 +281,11 @@ namespace AyaNova.Biz
|
||||
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)
|
||||
{
|
||||
return ct.LocaleItem.Any(e => e.Id == id);
|
||||
|
||||
@@ -1411,5 +1411,8 @@
|
||||
"WorkorderStatusName": "Arbeitsauftragsstatus - Name",
|
||||
"WorkorderStatusUnderlined": "Unterstrichen",
|
||||
"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",
|
||||
"WorkorderStatusUnderlined": "Underlined",
|
||||
"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",
|
||||
"WorkorderStatusUnderlined": "Subrayado",
|
||||
"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",
|
||||
"WorkorderStatusUnderlined": "Souligné",
|
||||
"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