序列化设置
parent
90ff700aa4
commit
4eecbe1095
|
@ -1,6 +1,7 @@
|
|||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace IRaCIS.Core.API
|
||||
{
|
||||
|
@ -40,7 +41,19 @@ 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
|
||||
{
|
||||
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>
|
||||
public static string ToJcJson(this object obj)
|
||||
{
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||
settings.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
|
||||
settings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
|
||||
return JsonConvert.SerializeObject(obj, settings);
|
||||
//JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||
//settings.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
|
||||
//settings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
|
||||
//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;
|
||||
inspection = f(entity);
|
||||
}
|
||||
inspection.Identification = $"{GetRequestUrl()}/{ data.Entity.GetType().ToString().Substring(data.Entity.GetType().ToString().LastIndexOf('.') + 1)}/{type}";
|
||||
var originaldata = data.OriginalValues as T;
|
||||
inspection.Identification = $"{_userInfo.RequestUrl}/{ data.Entity.GetType().Name}/{type}";
|
||||
var originaldata = data.OriginalValues.ToObject();
|
||||
if (originaldata != null)
|
||||
{
|
||||
inspection.LastJsonDetail = originaldata.ToJcJson();
|
||||
|
|
|
@ -356,7 +356,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
public override int SaveChanges()
|
||||
{
|
||||
//UpdateAuditInfo().GetAwaiter();
|
||||
AddAudit().GetAwaiter();
|
||||
AddAudit().GetAwaiter();
|
||||
return base.SaveChanges();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue