SysLog.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. using Abp.Auditing;
  2. using Abp.Extensions;
  3. using IwbZero.BaseSysInfo;
  4. namespace ShwasherSys.BaseSysInfo
  5. {
  6. public class SysLog : IwbSysLog
  7. {
  8. public static SysLog CreateFromAuditInfo(AuditInfo auditInfo, string userName, int logType)
  9. {
  10. var exceptionMessage = auditInfo.Exception?.ToString();
  11. return new SysLog
  12. {
  13. //TenantId = auditInfo.TenantId,
  14. UserId = auditInfo.UserId,
  15. UserName = userName,
  16. LogType = logType,
  17. ServiceName = auditInfo.ServiceName.TruncateWithPostfix(MaxServiceNameLength),
  18. MethodName = auditInfo.MethodName.TruncateWithPostfix(MaxMethodNameLength),
  19. Parameters = auditInfo.Parameters.TruncateWithPostfix(MaxParametersLength),
  20. ExecutionTime = auditInfo.ExecutionTime,
  21. ExecutionDuration = auditInfo.ExecutionDuration,
  22. ClientIpAddress = auditInfo.ClientIpAddress.TruncateWithPostfix(MaxClientIpAddressLength),
  23. ClientName = auditInfo.ClientName.TruncateWithPostfix(MaxClientNameLength),
  24. BrowserInfo = auditInfo.BrowserInfo.TruncateWithPostfix(MaxBrowserInfoLength),
  25. Exception = exceptionMessage.TruncateWithPostfix(MaxExceptionLength),
  26. ImpersonatorUserId = auditInfo.ImpersonatorUserId,
  27. ImpersonatorTenantId = auditInfo.ImpersonatorTenantId,
  28. CustomData = auditInfo.CustomData.TruncateWithPostfix(MaxCustomDataLength)
  29. };
  30. }
  31. }
  32. }