This commit is contained in:
@@ -269,14 +269,15 @@ namespace AyaNova.Biz
|
||||
foreach (Customer w in orderedList)
|
||||
{
|
||||
var jo = JObject.FromObject(w);
|
||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
|
||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
ReportData.Add(jo);
|
||||
}
|
||||
}
|
||||
return ReportData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORT EXPORT
|
||||
//
|
||||
@@ -295,12 +296,12 @@ namespace AyaNova.Biz
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag=$"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
var jsset = JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = new AyaNova.Util.JsonUtil.ShouldSerializeContractResolver(new string[] { "Concurrency", "Id", "CustomFields" }) });
|
||||
foreach (JObject j in ja)
|
||||
{
|
||||
var w = j.ToObject<Customer>(jsset);
|
||||
var w = j.ToObject<Customer>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
w.CustomFields = j["CustomFields"].ToString();
|
||||
w.Tags.Add(ImportTag);//so user can find them all and revert later if necessary
|
||||
|
||||
@@ -180,8 +180,7 @@ namespace AyaNova.Biz
|
||||
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
||||
foreach (CustomerNote w in orderedList)
|
||||
{
|
||||
var jo = JObject.FromObject(w);
|
||||
// jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
var jo = JObject.FromObject(w);
|
||||
ReportData.Add(jo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,8 @@ namespace AyaNova.Biz
|
||||
foreach (Widget w in orderedList)
|
||||
{
|
||||
var jo = JObject.FromObject(w);
|
||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
|
||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
ReportData.Add(jo);
|
||||
}
|
||||
}
|
||||
@@ -332,12 +333,12 @@ namespace AyaNova.Biz
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag=$"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
var jsset = JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = new AyaNova.Util.JsonUtil.ShouldSerializeContractResolver(new string[] { "Concurrency", "Id", "CustomFields" }) });
|
||||
foreach (JObject j in ja)
|
||||
{
|
||||
var w = j.ToObject<Widget>(jsset);
|
||||
var w = j.ToObject<Widget>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
w.CustomFields = j["CustomFields"].ToString();
|
||||
w.Tags.Add(ImportTag);//so user can find them all and revert later if necessary
|
||||
|
||||
@@ -69,6 +69,15 @@ namespace AyaNova.Util
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool JTokenIsNullOrEmpty(JToken token)
|
||||
{
|
||||
return (token == null) ||
|
||||
(token.Type == JTokenType.Array && !token.HasValues) ||
|
||||
(token.Type == JTokenType.Object && !token.HasValues) ||
|
||||
(token.Type == JTokenType.String && token.ToString() == String.Empty) ||
|
||||
(token.Type == JTokenType.Null);
|
||||
}
|
||||
|
||||
//Contract resolver used for exporting to file translations and report templates
|
||||
//and ignoring specified propertes
|
||||
public class ShouldSerializeContractResolver : DefaultContractResolver
|
||||
@@ -88,6 +97,8 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user