This commit is contained in:
2018-09-19 00:00:30 +00:00
parent b45095a350
commit a9f60453c6
8 changed files with 64 additions and 32 deletions

View File

@@ -0,0 +1,15 @@
using System.Collections.Generic;
namespace AyaNova.Api.ControllerHelpers
{
internal static class LocaleIdFromContext
{
internal static long Id(IDictionary<object, object> HttpContextItems)
{
long? l = (long?)HttpContextItems["AY_LOCALE_ID"];
if (l == null)
return AyaNova.Util.ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
return (long)l;
}
}
}//eons

View File

@@ -1,10 +1,7 @@
using EnumsNET;
using System.Collections.Generic;
namespace AyaNova.Api.ControllerHelpers
{
internal static class UserIdFromContext
{
internal static long Id(IDictionary<object, object> HttpContextItems)
@@ -16,6 +13,4 @@ namespace AyaNova.Api.ControllerHelpers
return (long)l;
}
}
}//eons

View File

@@ -210,6 +210,7 @@ namespace AyaNova.Api.Controllers
{
//Log
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.Widget, AyaEvent.Modified), ct);
Search.ProcessUpdatedObjectKeywords(ct, LocaleIdFromContext.Id(HttpContext.Items), o.Id, AyaType.Widget, o.Name, o.Notes);
await ct.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
@@ -286,6 +287,7 @@ namespace AyaNova.Api.Controllers
{
//Log
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.Widget, AyaEvent.Modified), ct);
Search.ProcessUpdatedObjectKeywords(ct, LocaleIdFromContext.Id(HttpContext.Items), o.Id, AyaType.Widget, o.Name, o.Notes);
await ct.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
@@ -300,9 +302,6 @@ namespace AyaNova.Api.Controllers
}
}
return Ok(new ApiOkResponse(new { ConcurrencyToken = o.ConcurrencyToken }));
}
@@ -353,6 +352,7 @@ namespace AyaNova.Api.Controllers
//Log now that we have the Id
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.Widget, AyaEvent.Created), ct);
Search.ProcessNewObjectKeywords(ct, LocaleIdFromContext.Id(HttpContext.Items), o.Id, AyaType.Widget, o.Name, o.Notes);
await ct.SaveChangesAsync();
//return success and link
@@ -406,7 +406,7 @@ namespace AyaNova.Api.Controllers
//Log
EventLogProcessor.DeleteObject(biz.userId, AyaType.Widget, dbObj.Id, dbObj.Name, ct);
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, AyaType.Widget);
await ct.SaveChangesAsync();
//Delete children / attached objects

View File

@@ -21,10 +21,28 @@ namespace AyaNova.Biz
//ProcessKeywords into database
#region ProcessKeywords into Database
public static void ProcessNewObjectKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, string name, params string[] text)
{
ProcessKeywords(ct, localeId, objectID, objectType, true, name, text);
}
public static void ProcessUpdatedObjectKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, string name, params string[] text)
{
ProcessKeywords(ct, localeId, objectID, objectType, false, name, text);
}
public static void ProcessDeletedObjectKeywords(AyContext ct, long objectID, AyaType objectType)
{
throw new System.NotImplementedException("Search::ProcessDeletedObjectKeywords NOT CODED YET");
//ProcessKeywords(ct, localeId, objectID, objectType, false, name, text);
}
/// <summary>
/// Process the keywords into the dictionary
/// </summary>
public static void ProcessKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, bool newRecord, string keyWords, string name)
private static void ProcessKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, bool newRecord, string name, params string[] text)
{

View File

@@ -41,7 +41,7 @@ namespace AyaNova.Biz
//do stuff with widget
Widget outObj = inObj;
outObj.OwnerId = userId;
//SearchHelper(break down text fields, save to db)
//TagHelper(collection of tags??)
await ct.Widget.AddAsync(outObj);
return outObj;

View File

@@ -21,7 +21,7 @@ namespace AyaNova.Models
public AuthorizationRoles Roles { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public string Notes { get; set; }
}

View File

@@ -22,7 +22,7 @@ namespace AyaNova.Util
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
private const int DESIRED_SCHEMA_LEVEL = 9;
internal const long EXPECTED_COLUMN_COUNT = 98;
internal const long EXPECTED_COLUMN_COUNT = 99;
internal const long EXPECTED_INDEX_COUNT = 20;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
@@ -136,7 +136,7 @@ namespace AyaNova.Util
//too little is bad if search takes a dogs age to find anything
exec("CREATE TABLE asearchdictionary (id BIGSERIAL PRIMARY KEY, word varchar(255) not null)");
// exec("CREATE UNIQUE INDEX tagname_idx ON atag (name);");
// exec("CREATE UNIQUE INDEX tagname_idx ON atag (name);");
exec("CREATE TABLE asearchkey (id BIGSERIAL PRIMARY KEY, wordid bigint not null REFERENCES asearchdictionary (id), objectid bigint not null, objecttype integer not null, inname bool not null)");
//create locale text tables
@@ -190,7 +190,7 @@ namespace AyaNova.Util
//Add widget table
//id, text, longtext, boolean, currency,
exec("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, name varchar(255) not null, " +
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4)");
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4, notes text)");
setSchemaLevel(++currentSchema);
}