This commit is contained in:
@@ -90,6 +90,7 @@ namespace AyaNova.Biz
|
||||
outObj.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
|
||||
|
||||
outObj.Tags = TagUtil.NormalizeTags(outObj.Tags);
|
||||
outObj.CustomFields=JsonUtil.CompactJson(outObj.CustomFields);
|
||||
|
||||
await ct.Widget.AddAsync(outObj);
|
||||
await ct.SaveChangesAsync();
|
||||
@@ -117,6 +118,7 @@ namespace AyaNova.Biz
|
||||
//Test get serial id visible id number from generator
|
||||
outObj.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
|
||||
outObj.Tags = TagUtil.NormalizeTags(outObj.Tags);
|
||||
outObj.CustomFields=JsonUtil.CompactJson(outObj.CustomFields);
|
||||
|
||||
TempContext.Widget.Add(outObj);
|
||||
TempContext.SaveChanges();
|
||||
@@ -174,6 +176,7 @@ namespace AyaNova.Biz
|
||||
CopyObject.Copy(inObj, dbObj, "Id,Serial");
|
||||
|
||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
||||
dbObj.CustomFields=JsonUtil.CompactJson(dbObj.CustomFields);
|
||||
|
||||
//Set "original" value of concurrency token to input token
|
||||
//this will allow EF to check it out
|
||||
@@ -207,6 +210,7 @@ namespace AyaNova.Biz
|
||||
objectPatch.ApplyTo(dbObj);
|
||||
|
||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
||||
dbObj.CustomFields=JsonUtil.CompactJson(dbObj.CustomFields);
|
||||
|
||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
||||
Validate(dbObj, SnapshotOfOriginalDBObj);
|
||||
|
||||
44
server/AyaNova/util/JsonUtil.cs
Normal file
44
server/AyaNova/util/JsonUtil.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
|
||||
|
||||
internal static class JsonUtil
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Clean JSON string fragment, remove unnecessary characters
|
||||
/// can be called with anything and should handle it properly even empty values etc
|
||||
/// </summary>
|
||||
/// <param name="jsonIn"></param>
|
||||
/// <returns></returns>
|
||||
public static string CompactJson(string jsonIn)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(jsonIn))
|
||||
{
|
||||
return jsonIn;
|
||||
}
|
||||
if (jsonIn.StartsWith("["))
|
||||
{
|
||||
JArray j = JArray.Parse(jsonIn);
|
||||
return JsonConvert.SerializeObject(j, Formatting.None);
|
||||
}
|
||||
|
||||
if (jsonIn.StartsWith("{"))
|
||||
{
|
||||
JObject j = JObject.Parse(jsonIn);
|
||||
return JsonConvert.SerializeObject(j, Formatting.None);
|
||||
}
|
||||
|
||||
//Not an object or an array so just return it, possibly suspect, maybe log this shit
|
||||
return jsonIn;
|
||||
}
|
||||
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user