This commit is contained in:
@@ -337,10 +337,14 @@ 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();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -339,11 +339,20 @@ 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)
|
public static bool LocaleExistsStatic(long id, AyContext ct)
|
||||||
{
|
{
|
||||||
return ct.Locale.Any(e => e.Id == id);
|
return ct.Locale.Any(e => e.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static long EnsuredLocaleIdStatic(long id, AyContext ct)
|
||||||
|
{
|
||||||
|
if (!ct.Locale.Any(e => e.Id == id))
|
||||||
|
return ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
||||||
|
return 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);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -9,23 +10,17 @@ using AyaNova.Models;
|
|||||||
namespace AyaNova.Biz
|
namespace AyaNova.Biz
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//This class handles word breaking, processing keywords and searching for results
|
||||||
public static class Search
|
public static class Search
|
||||||
{
|
{
|
||||||
// private readonly AyContext ct;
|
|
||||||
// private readonly ILogger<PrimeData> log;
|
|
||||||
|
|
||||||
// public PrimeData(AyContext dbcontext, ILogger<PrimeData> logger)
|
|
||||||
// {
|
|
||||||
// ct = dbcontext;
|
|
||||||
// log = logger;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process the keywords into the dictionary
|
/// Process the keywords into the dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ProcessKeywords(AyContext ct, long objectID, AyaType objectType, bool newRecord, string keyWords, string name)
|
public static void ProcessKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, bool newRecord, string keyWords, string name)
|
||||||
{
|
{
|
||||||
|
var StopWords = GetStopWords(ct, localeId);
|
||||||
|
|
||||||
|
|
||||||
// //get a db and logger
|
// //get a db and logger
|
||||||
// ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("PrimeData");
|
// ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("PrimeData");
|
||||||
// User u = new User();
|
// User u = new User();
|
||||||
@@ -41,14 +36,34 @@ namespace AyaNova.Biz
|
|||||||
// u.UserOptions=new UserOptions(1);
|
// u.UserOptions=new UserOptions(1);
|
||||||
// ct.User.Add(u);
|
// ct.User.Add(u);
|
||||||
// ct.SaveChanges();
|
// ct.SaveChanges();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<string> GetStopWords(AyContext ct, long localeId)
|
||||||
|
{
|
||||||
|
//Get stopwords
|
||||||
|
//Validate locale id, if not right then use default instead
|
||||||
|
var Param = new Api.Controllers.LocaleController.LocaleSubsetParam();
|
||||||
|
Param.LocaleId = LocaleBiz.EnsuredLocaleIdStatic(localeId, ct);
|
||||||
|
Param.Keys.Add("StopWords1");
|
||||||
|
Param.Keys.Add("StopWords2");
|
||||||
|
Param.Keys.Add("StopWords3");
|
||||||
|
Param.Keys.Add("StopWords4");
|
||||||
|
Param.Keys.Add("StopWords5");
|
||||||
|
Param.Keys.Add("StopWords6");
|
||||||
|
Param.Keys.Add("StopWords7");
|
||||||
|
var Stops = LocaleBiz.GetSubsetStatic(Param).Result;
|
||||||
|
List<string> StopWords = new List<string>();
|
||||||
|
foreach (KeyValuePair<string, string> kvp in Stops)
|
||||||
|
{
|
||||||
|
//Each stopwords locale key is a space delimited list of words and in the case of an empty local string (i.e. StopWords7) it's value is a single question mark
|
||||||
|
if (kvp.Value != "?")
|
||||||
|
{
|
||||||
|
StopWords.AddRange(kvp.Value.Split(" "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StopWords;
|
||||||
|
}
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|
||||||
}//eons
|
}//eons
|
||||||
Reference in New Issue
Block a user