This commit is contained in:
@@ -237,7 +237,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
// Search.ProcessNewObjectKeywords( UserLocaleIdFromContext.Id(HttpContext.Items), v.Id, AyaType.FileAttachment, v.DisplayFileName, v.DisplayFileName, v.Notes, v.StoredFileName);
|
// Search.ProcessNewObjectKeywords( UserLocaleIdFromContext.Id(HttpContext.Items), v.Id, AyaType.FileAttachment, v.DisplayFileName, v.DisplayFileName, v.Notes, v.StoredFileName);
|
||||||
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserLocaleIdFromContext.Id(HttpContext.Items), v.Id, AyaType.FileAttachment, v.DisplayFileName);
|
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserLocaleIdFromContext.Id(HttpContext.Items), v.Id, AyaType.FileAttachment, v.DisplayFileName);
|
||||||
SearchParams.AddWord(v.Notes).AddWord(v.DisplayFileName).AddWord(v.StoredFileName);
|
SearchParams.AddText(v.Notes).AddText(v.DisplayFileName).AddText(v.StoredFileName);
|
||||||
Search.ProcessNewObjectKeywords(SearchParams);
|
Search.ProcessNewObjectKeywords(SearchParams);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,7 @@ namespace AyaNova.Biz
|
|||||||
if (formCustom == null)
|
if (formCustom == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
//var OuterJson = JObject.Parse(formCustom.Template);
|
|
||||||
var FormTemplate = JArray.Parse(formCustom.Template);
|
var FormTemplate = JArray.Parse(formCustom.Template);
|
||||||
//var FormTemplate = (JArray)OuterJson["template"];
|
|
||||||
var ThisFormCustomFieldsList = FormAvailableFields.FormFields(formCustom.FormKey).Where(x => x.Custom == true).Select(x => x.Key).ToList();
|
var ThisFormCustomFieldsList = FormAvailableFields.FormFields(formCustom.FormKey).Where(x => x.Custom == true).Select(x => x.Key).ToList();
|
||||||
|
|
||||||
//If the customFields string is empty then only validation is if any of the fields are required to be filled in
|
//If the customFields string is empty then only validation is if any of the fields are required to be filled in
|
||||||
@@ -46,6 +43,8 @@ namespace AyaNova.Biz
|
|||||||
//NOTE: to save bandwidth the actual custom fields look like this:
|
//NOTE: to save bandwidth the actual custom fields look like this:
|
||||||
// - {c1:"blah",c2:"blah",c3:"blah".....c16:"blah"}
|
// - {c1:"blah",c2:"blah",c3:"blah".....c16:"blah"}
|
||||||
//However the LT field names might be WidgetCustom1 or UserCustom16 so we need to translate by EndsWith
|
//However the LT field names might be WidgetCustom1 or UserCustom16 so we need to translate by EndsWith
|
||||||
|
|
||||||
|
//Top level object is a Object not an array when it comes to custom fields and the key names are the custom fields abbreviated
|
||||||
var CustomFieldData = JObject.Parse(customFields);
|
var CustomFieldData = JObject.Parse(customFields);
|
||||||
|
|
||||||
//make sure all the *required* keys are present
|
//make sure all the *required* keys are present
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchIndexProcessObjectParameters AddWord(string s)
|
public SearchIndexProcessObjectParameters AddText(string s)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(s))
|
if (!string.IsNullOrWhiteSpace(s))
|
||||||
{
|
{
|
||||||
@@ -402,12 +402,14 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public SearchIndexProcessObjectParameters AddWord(uint u)
|
|
||||||
|
public SearchIndexProcessObjectParameters AddText(uint u)
|
||||||
{
|
{
|
||||||
Words.Add(u.ToString());
|
Words.Add(u.ToString());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public SearchIndexProcessObjectParameters AddWord(List<string> lWords)
|
|
||||||
|
public SearchIndexProcessObjectParameters AddText(List<string> lWords)
|
||||||
{
|
{
|
||||||
if (lWords != null)
|
if (lWords != null)
|
||||||
{
|
{
|
||||||
@@ -423,6 +425,15 @@ namespace AyaNova.Biz
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SearchIndexProcessObjectParameters AddCustomFields(string jsonString)
|
||||||
|
{
|
||||||
|
//Extract the text from custom fields json fragment as an array of strings and add it here
|
||||||
|
AddText(JsonUtil.GetCustomFieldsAsStringArrayForSearchIndexing(jsonString));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -997,6 +1008,10 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Utility
|
||||||
|
|
||||||
|
#endregion utility
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|
||||||
}//eons
|
}//eons
|
||||||
@@ -60,7 +60,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
|
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
|
||||||
inObj.CustomFields=JsonUtil.CompactJson(inObj.CustomFields);
|
inObj.CustomFields = JsonUtil.CompactJson(inObj.CustomFields);
|
||||||
|
|
||||||
//Seeder sets user options in advance so no need to create them here in that case
|
//Seeder sets user options in advance so no need to create them here in that case
|
||||||
if (inObj.UserOptions == null)
|
if (inObj.UserOptions == null)
|
||||||
@@ -83,9 +83,8 @@ namespace AyaNova.Biz
|
|||||||
EventLogProcessor.LogEventToDatabase(new Event(UserId, inObj.Id, BizType, AyaEvent.Created), ct);
|
EventLogProcessor.LogEventToDatabase(new Event(UserId, inObj.Id, BizType, AyaEvent.Created), ct);
|
||||||
|
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserLocaleId, inObj.Id, BizType, inObj.Name);
|
SearchIndex(inObj, true);
|
||||||
SearchParams.AddWord(inObj.Notes).AddWord(inObj.Name).AddWord(inObj.EmployeeNumber).AddWord(inObj.Tags);
|
|
||||||
Search.ProcessNewObjectKeywords(SearchParams);
|
|
||||||
//TAGS
|
//TAGS
|
||||||
TagUtil.ProcessUpdateTagsInRepository(ct, inObj.Tags, null);
|
TagUtil.ProcessUpdateTagsInRepository(ct, inObj.Tags, null);
|
||||||
|
|
||||||
@@ -103,7 +102,7 @@ namespace AyaNova.Biz
|
|||||||
inObj.Password = Hasher.hash(inObj.Salt, inObj.Password);
|
inObj.Password = Hasher.hash(inObj.Salt, inObj.Password);
|
||||||
|
|
||||||
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
|
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
|
||||||
inObj.CustomFields=JsonUtil.CompactJson(inObj.CustomFields);
|
inObj.CustomFields = JsonUtil.CompactJson(inObj.CustomFields);
|
||||||
|
|
||||||
//Seeder sets user options in advance so no need to create them here in that case
|
//Seeder sets user options in advance so no need to create them here in that case
|
||||||
if (inObj.UserOptions == null)
|
if (inObj.UserOptions == null)
|
||||||
@@ -126,9 +125,7 @@ namespace AyaNova.Biz
|
|||||||
EventLogProcessor.LogEventToDatabase(new Event(UserId, inObj.Id, BizType, AyaEvent.Created), TempContext);
|
EventLogProcessor.LogEventToDatabase(new Event(UserId, inObj.Id, BizType, AyaEvent.Created), TempContext);
|
||||||
|
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserLocaleId, inObj.Id, BizType, inObj.Name);
|
SearchIndex(inObj, true);
|
||||||
SearchParams.AddWord(inObj.Notes).AddWord(inObj.Name).AddWord(inObj.EmployeeNumber).AddWord(inObj.Tags);
|
|
||||||
Search.ProcessNewObjectKeywords(SearchParams);
|
|
||||||
|
|
||||||
//TAGS
|
//TAGS
|
||||||
TagUtil.ProcessUpdateTagsInRepository(TempContext, inObj.Tags, null);
|
TagUtil.ProcessUpdateTagsInRepository(TempContext, inObj.Tags, null);
|
||||||
@@ -260,8 +257,6 @@ namespace AyaNova.Biz
|
|||||||
//put
|
//put
|
||||||
internal bool Put(User dbObj, User inObj)
|
internal bool Put(User dbObj, User inObj)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//Get a snapshot of the original db value object before changes
|
//Get a snapshot of the original db value object before changes
|
||||||
User SnapshotOfOriginalDBObj = new User();
|
User SnapshotOfOriginalDBObj = new User();
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
||||||
@@ -296,10 +291,8 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//Log modification
|
//Log modification
|
||||||
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
||||||
//Update keywords
|
|
||||||
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserLocaleId, dbObj.Id, BizType, dbObj.Name);
|
SearchIndex(dbObj, false);
|
||||||
SearchParams.AddWord(dbObj.Notes).AddWord(dbObj.Name).AddWord(dbObj.EmployeeNumber).AddWord(dbObj.Tags);
|
|
||||||
Search.ProcessUpdatedObjectKeywords(SearchParams);
|
|
||||||
|
|
||||||
TagUtil.ProcessUpdateTagsInRepository(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
TagUtil.ProcessUpdateTagsInRepository(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||||
|
|
||||||
@@ -319,7 +312,7 @@ namespace AyaNova.Biz
|
|||||||
//Do the patching
|
//Do the patching
|
||||||
objectPatch.ApplyTo(dbObj);
|
objectPatch.ApplyTo(dbObj);
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
||||||
dbObj.CustomFields=JsonUtil.CompactJson(dbObj.CustomFields);
|
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
||||||
|
|
||||||
//Is the user patching the password?
|
//Is the user patching the password?
|
||||||
if (!string.IsNullOrWhiteSpace(dbObj.Password) && dbObj.Password != SnapshotOfOriginalDBObj.Password)
|
if (!string.IsNullOrWhiteSpace(dbObj.Password) && dbObj.Password != SnapshotOfOriginalDBObj.Password)
|
||||||
@@ -335,12 +328,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//Log modification
|
//Log modification
|
||||||
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
||||||
|
SearchIndex(dbObj, false);
|
||||||
//Update keywords
|
|
||||||
// Search.ProcessUpdatedObjectKeywords(UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.EmployeeNumber, dbObj.Notes, dbObj.Name);
|
|
||||||
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserLocaleId, dbObj.Id, BizType, dbObj.Name);
|
|
||||||
SearchParams.AddWord(dbObj.Notes).AddWord(dbObj.Name).AddWord(dbObj.EmployeeNumber).AddWord(dbObj.Tags);
|
|
||||||
Search.ProcessUpdatedObjectKeywords(SearchParams);
|
|
||||||
|
|
||||||
TagUtil.ProcessUpdateTagsInRepository(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
TagUtil.ProcessUpdateTagsInRepository(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||||
|
|
||||||
@@ -348,6 +336,19 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void SearchIndex(User obj, bool isNew)
|
||||||
|
{
|
||||||
|
//SEARCH INDEXING
|
||||||
|
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserLocaleId, obj.Id, BizType, obj.Name);
|
||||||
|
SearchParams.AddText(obj.Notes).AddText(obj.Name).AddText(obj.EmployeeNumber).AddText(obj.Tags).AddCustomFields(obj.CustomFields);
|
||||||
|
|
||||||
|
if (isNew)
|
||||||
|
Search.ProcessNewObjectKeywords(SearchParams);
|
||||||
|
else
|
||||||
|
Search.ProcessUpdatedObjectKeywords(SearchParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//DELETE
|
//DELETE
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -231,7 +231,9 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserLocaleId, obj.Id, BizType, obj.Name);
|
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserLocaleId, obj.Id, BizType, obj.Name);
|
||||||
SearchParams.AddWord(obj.Notes).AddWord(obj.Name).AddWord(obj.Serial).AddWord(obj.Tags);
|
SearchParams.AddText(obj.Notes).AddText(obj.Name).AddText(obj.Serial).AddText(obj.Tags).AddCustomFields(obj.CustomFields);
|
||||||
|
|
||||||
|
|
||||||
if (isNew)
|
if (isNew)
|
||||||
Search.ProcessNewObjectKeywords(SearchParams);
|
Search.ProcessNewObjectKeywords(SearchParams);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
@@ -39,6 +40,37 @@ namespace AyaNova.Util
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Utility used by biz classes to extract all the custom field data as text strings suitable for search indexing
|
||||||
|
/// Does not take into account type of field only what is in it and weeds out bools and any other non suitable for search text
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jsonIn"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<string> GetCustomFieldsAsStringArrayForSearchIndexing(string jsonIn)
|
||||||
|
{
|
||||||
|
var ret = new List<string>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(jsonIn))
|
||||||
|
{
|
||||||
|
var j = JObject.Parse(jsonIn);
|
||||||
|
|
||||||
|
//iterate the values in the custom fields
|
||||||
|
foreach (KeyValuePair<string, JToken> kv in j)
|
||||||
|
{
|
||||||
|
//Add as string any value that isn't a bool since bools are useless for searching
|
||||||
|
//and don't add dates as it gets hellish to factor in time zone conversions and local server vs user date format and all that shit
|
||||||
|
//and at the end of the day it won't really be useful for searching as people will probably ask for a filter or sort instead which we may have to
|
||||||
|
//look at in future, for search though just the numbers and text that are plausibly search-worthy
|
||||||
|
if (kv.Value.Type != JTokenType.Boolean && kv.Value.Type != JTokenType.Date)
|
||||||
|
{
|
||||||
|
ret.Add(kv.Value.Value<string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|
||||||
}//eons
|
}//eons
|
||||||
Reference in New Issue
Block a user