From d995ce608bbe788d646cecc2b6514cb8ec7ee2a8 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 28 Aug 2018 15:03:55 +0000 Subject: [PATCH] --- devdocs/specs/core-internationalization.txt | 9 ++++ devdocs/specs/core-localization.txt | 2 + .../UserLocaleIdFromContext.cs | 20 --------- .../AyaNova/Controllers/EventLogController.cs | 9 ++-- server/AyaNova/Startup.cs | 3 +- server/AyaNova/biz/EventLogProcessor.cs | 44 +++++++++---------- 6 files changed, 38 insertions(+), 49 deletions(-) create mode 100644 devdocs/specs/core-internationalization.txt delete mode 100644 server/AyaNova/ControllerHelpers/UserLocaleIdFromContext.cs diff --git a/devdocs/specs/core-internationalization.txt b/devdocs/specs/core-internationalization.txt new file mode 100644 index 00000000..12808bd3 --- /dev/null +++ b/devdocs/specs/core-internationalization.txt @@ -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?) \ No newline at end of file diff --git a/devdocs/specs/core-localization.txt b/devdocs/specs/core-localization.txt index cadd9e30..cee4c8d6 100644 --- a/devdocs/specs/core-localization.txt +++ b/devdocs/specs/core-localization.txt @@ -2,6 +2,8 @@ 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 - Not numeric ID's for these, strictly textual - values may have substitution tokens in them for certain things diff --git a/server/AyaNova/ControllerHelpers/UserLocaleIdFromContext.cs b/server/AyaNova/ControllerHelpers/UserLocaleIdFromContext.cs deleted file mode 100644 index 1ac10840..00000000 --- a/server/AyaNova/ControllerHelpers/UserLocaleIdFromContext.cs +++ /dev/null @@ -1,20 +0,0 @@ -using EnumsNET; -using System.Collections.Generic; - -namespace AyaNova.Api.ControllerHelpers -{ - - internal static class UserLocaleIdFromContext - { - internal static long LocaleId(IDictionary HttpContextItems) - { - - long? l = (long?)HttpContextItems["AY_LOCALE_ID"]; - if (l==null) - return 0L; - return (long)l; - } - } - - -}//eons \ No newline at end of file diff --git a/server/AyaNova/Controllers/EventLogController.cs b/server/AyaNova/Controllers/EventLogController.cs index 8aefc594..dfb10d28 100644 --- a/server/AyaNova/Controllers/EventLogController.cs +++ b/server/AyaNova/Controllers/EventLogController.cs @@ -43,17 +43,16 @@ namespace AyaNova.Api.Controllers } - //TODO: code the log makers in EventLogProcessor - // + /// - /// Get events as text document for object specified + /// Get event log for object and date range specified /// /// Required roles: /// Read rights to object type specified /// /// - /// Event log for object + /// Event log entry list for object [HttpGet("ObjectLog")] public async Task GetObjectLog([FromQuery] EventLogOptions opt) { @@ -78,7 +77,7 @@ namespace AyaNova.Api.Controllers /// - /// Get events for a user as text document for object specified + /// Get event log entries for a specified user and date range /// /// Required roles: /// Read rights to User object or UserId specified must be requestor Id diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index bef694a0..dd400287 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -337,11 +337,10 @@ namespace AyaNova var ct = context.RequestServices.GetService(); //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_USERNAME"] = u.name; context.Request.HttpContext.Items["AY_USER_ID"] = u.Id; - context.Request.HttpContext.Items["AY_LOCALE_ID"] = u.LocaleId; } await next.Invoke(); }); diff --git a/server/AyaNova/biz/EventLogProcessor.cs b/server/AyaNova/biz/EventLogProcessor.cs index ac1c4f4e..4e3b9ad7 100644 --- a/server/AyaNova/biz/EventLogProcessor.cs +++ b/server/AyaNova/biz/EventLogProcessor.cs @@ -1,4 +1,5 @@ using System; +using System.Text; using System.Linq; using System.Threading.Tasks; using System.Collections.Generic; @@ -46,11 +47,7 @@ namespace AyaNova.Biz /// /// Get the event log for a specified object /// - /// - /// - /// - /// - internal static async Task GetLogForObject(long ayId, long userLocaleId, AyContext ct) + internal static async Task GetLogForObject(long ayId, DateTime StartDate, DateTime EndDate, AyContext ct) { var items = await ct.Event .Where(m => m.AyId == ayId) @@ -62,23 +59,10 @@ namespace AyaNova.Biz 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> lt) + + internal static string BuildLogEntry(bool userFormat, Event ev, List> 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 ":"; }