序列化设置
parent
90ff700aa4
commit
4eecbe1095
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace IRaCIS.Core.API
|
namespace IRaCIS.Core.API
|
||||||
{
|
{
|
||||||
|
@ -41,6 +42,18 @@ namespace IRaCIS.Core.API
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Newtonsoft.Json.JsonSerializerSettings setting = new Newtonsoft.Json.JsonSerializerSettings();
|
||||||
|
JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() =>
|
||||||
|
{
|
||||||
|
//日期类型默认格式化处理
|
||||||
|
setting.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
setting.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
||||||
|
|
||||||
|
return setting;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ namespace IRaCIS.Core.Application.Filter
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
context.Result = new JsonResult(ResponseOutput.NotOk(" Program exception, please contact the developer! " + (context.Exception.InnerException is null ? (context.Exception.Message /*+ context.Exception.StackTrace*/)
|
context.Result = new JsonResult(ResponseOutput.NotOk(" Program exception, please contact the developer! " + (context.Exception.InnerException is null ? (context.Exception.Message /*+ context.Exception.StackTrace*/)
|
||||||
: (context.Exception.InnerException?.Message /*+ context.Exception.InnerException?.StackTrace*/)) ), ApiResponseCodeEnum.ProgramException);
|
: (context.Exception.InnerException?.Message /*+ context.Exception.InnerException?.StackTrace*/)), ApiResponseCodeEnum.ProgramException));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_logger.LogError(context.Exception.InnerException is null ? (context.Exception.Message +context.Exception.StackTrace): (context.Exception.InnerException?.Message+ context.Exception.InnerException?.StackTrace));
|
_logger.LogError(context.Exception.InnerException is null ? (context.Exception.Message + context.Exception.StackTrace) : (context.Exception.InnerException?.Message + context.Exception.InnerException?.StackTrace));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,13 @@ namespace IRaCIS.Core.Domain.Common
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string ToJcJson(this object obj)
|
public static string ToJcJson(this object obj)
|
||||||
{
|
{
|
||||||
JsonSerializerSettings settings = new JsonSerializerSettings();
|
//JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||||
settings.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
|
//settings.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
|
||||||
settings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
|
//settings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
|
||||||
return JsonConvert.SerializeObject(obj, settings);
|
//return JsonConvert.SerializeObject(obj, settings);
|
||||||
|
|
||||||
//return JsonSerializer.Serialize(obj);
|
|
||||||
|
return JsonConvert.SerializeObject(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,8 +295,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
||||||
var entity = data.Entity as T;
|
var entity = data.Entity as T;
|
||||||
inspection = f(entity);
|
inspection = f(entity);
|
||||||
}
|
}
|
||||||
inspection.Identification = $"{GetRequestUrl()}/{ data.Entity.GetType().ToString().Substring(data.Entity.GetType().ToString().LastIndexOf('.') + 1)}/{type}";
|
inspection.Identification = $"{_userInfo.RequestUrl}/{ data.Entity.GetType().Name}/{type}";
|
||||||
var originaldata = data.OriginalValues as T;
|
var originaldata = data.OriginalValues.ToObject();
|
||||||
if (originaldata != null)
|
if (originaldata != null)
|
||||||
{
|
{
|
||||||
inspection.LastJsonDetail = originaldata.ToJcJson();
|
inspection.LastJsonDetail = originaldata.ToJcJson();
|
||||||
|
|
|
@ -356,7 +356,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
public override int SaveChanges()
|
public override int SaveChanges()
|
||||||
{
|
{
|
||||||
//UpdateAuditInfo().GetAwaiter();
|
//UpdateAuditInfo().GetAwaiter();
|
||||||
AddAudit().GetAwaiter();
|
AddAudit().GetAwaiter();
|
||||||
return base.SaveChanges();
|
return base.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue