This commit is contained in:
2018-08-28 15:03:55 +00:00
parent a4e9ed7828
commit d995ce608b
6 changed files with 38 additions and 49 deletions

View File

@@ -0,0 +1,9 @@
# Internationalization specifications
DATES, TIMES, CURRENCY, (RTL?)
REQUIREMENTS
- Client does *ALL* internationalization display locally, only exception is the server ops logs
- This saves bandwidth and hassle and leaves presentation to the client where it belongs (was a source of trouble in v7)
- User options contain the date, timezone and currency format for presentation purposes
- API data is in as neutral a format as possible, i.e. ISO whatever it is for dates and times, currency is just a number? (not going multicurrency?)

View File

@@ -2,6 +2,8 @@
REQUIREMENTS REQUIREMENTS
- Client does *ALL* localization locally, only exception is the server ops logs
- This saves bandwidth and hassle and leaves presentation to the client where it belongs (was a source of trouble in v7)
- Keys are text, human readable and as short as possible - Keys are text, human readable and as short as possible
- Not numeric ID's for these, strictly textual - Not numeric ID's for these, strictly textual
- values may have substitution tokens in them for certain things - values may have substitution tokens in them for certain things

View File

@@ -1,20 +0,0 @@
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

View File

@@ -43,17 +43,16 @@ namespace AyaNova.Api.Controllers
} }
//TODO: code the log makers in EventLogProcessor
//
/// <summary> /// <summary>
/// Get events as text document for object specified /// Get event log for object and date range specified
/// ///
/// Required roles: /// Required roles:
/// Read rights to object type specified /// Read rights to object type specified
/// ///
/// </summary> /// </summary>
/// <returns>Event log for object</returns> /// <returns>Event log entry list for object</returns>
[HttpGet("ObjectLog")] [HttpGet("ObjectLog")]
public async Task<IActionResult> GetObjectLog([FromQuery] EventLogOptions opt) public async Task<IActionResult> GetObjectLog([FromQuery] EventLogOptions opt)
{ {
@@ -78,7 +77,7 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Get events for a user as text document for object specified /// Get event log entries for a specified user and date range
/// ///
/// Required roles: /// Required roles:
/// Read rights to User object or UserId specified must be requestor Id /// Read rights to User object or UserId specified must be requestor Id

View File

@@ -337,11 +337,10 @@ 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, LocaleId = m.LocaleId }).First(); var u = ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, Id = m.Id }).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();
}); });

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Text;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
@@ -46,11 +47,7 @@ namespace AyaNova.Biz
/// <summary> /// <summary>
/// Get the event log for a specified object /// Get the event log for a specified object
/// </summary> /// </summary>
/// <param name="ayId"></param> internal static async Task<string> GetLogForObject(long ayId, DateTime StartDate, DateTime EndDate, AyContext ct)
/// <param name="userLocaleId"></param>
/// <param name="ct"></param>
/// <returns></returns>
internal static async Task<string> GetLogForObject(long ayId, long userLocaleId, AyContext ct)
{ {
var items = await ct.Event var items = await ct.Event
.Where(m => m.AyId == ayId) .Where(m => m.AyId == ayId)
@@ -62,23 +59,10 @@ namespace AyaNova.Biz
return ""; return "";
} }
AyaNova.Api.Controllers.LocaleController.LocaleSubsetParam param = new Api.Controllers.LocaleController.LocaleSubsetParam();
param.LocaleId = userLocaleId;
param.Keys.AddRange(new string[] { "CommonCreated", "Delete", "Modified", "Retrieved" });
//TODO: add all the keys from all the events in AyaEvent
//Attachment, Created instead of AttachmentCreate, or is it attached?
var LT = await LocaleBiz.GetSubsetStatic(param);
//Have list of locales and list of ops, now make it into a readable text display and return it
System.Text.StringBuilder SbReturn = new System.Text.StringBuilder();
foreach (Event ev in items)
{
SbReturn.AppendLine(BuildLogEntry(ev, LT));
}
return SbReturn.ToString();
} }
@@ -88,8 +72,24 @@ namespace AyaNova.Biz
} }
internal static string BuildLogEntry(Event ev, List<KeyValuePair<string, string>> lt)
internal static string BuildLogEntry(bool userFormat, Event ev, List<KeyValuePair<string, string>> lt)
{ {
StringBuilder S=new StringBuilder();
//Object format:
//DateTime, UserId, ActionNumber, Textra
//User format:
//DateTime, ObjectType, ObjectId, ActionNumber, Textra
ev
switch(ev.AyEvent){
case AyaEvent.Created:
break;
}
return ":"; return ":";
} }