This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
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
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user