IwbSysLog.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System;
  2. using System.ComponentModel.DataAnnotations.Schema;
  3. using Abp.Auditing;
  4. using Abp.Domain.Entities;
  5. namespace IwbZero.BaseSysInfo
  6. {
  7. [Table("Sys_AuditLogs")]
  8. public class IwbSysLog : Entity<long>
  9. {
  10. /// <summary>
  11. /// Maximum length of <see cref="ServiceName"/> property.
  12. /// </summary>
  13. public static int MaxServiceNameLength = 256;
  14. /// <summary>
  15. /// Maximum length of <see cref="MethodName"/> property.
  16. /// </summary>
  17. public static int MaxMethodNameLength = 256;
  18. /// <summary>
  19. /// Maximum length of <see cref="Parameters"/> property.
  20. /// </summary>
  21. public static int MaxParametersLength = 1024;
  22. /// <summary>
  23. /// Maximum length of <see cref="ClientIpAddress"/> property.
  24. /// </summary>
  25. public static int MaxClientIpAddressLength = 64;
  26. /// <summary>
  27. /// Maximum length of <see cref="ClientName"/> property.
  28. /// </summary>
  29. public static int MaxClientNameLength = 128;
  30. /// <summary>
  31. /// Maximum length of <see cref="BrowserInfo"/> property.
  32. /// </summary>
  33. public static int MaxBrowserInfoLength = 512;
  34. /// <summary>
  35. /// Maximum length of <see cref="Exception"/> property.
  36. /// </summary>
  37. public static int MaxExceptionLength = 2000;
  38. /// <summary>
  39. /// Maximum length of <see cref="CustomData"/> property.
  40. /// </summary>
  41. public static int MaxCustomDataLength = 2000;
  42. ///// <summary>
  43. ///// TenantId.
  44. ///// </summary>
  45. //public virtual int? TenantId { get; set; }
  46. /// <summary>
  47. /// UserId.
  48. /// </summary>
  49. public virtual long? UserId { get; set; }
  50. /// <summary>
  51. /// UserId.
  52. /// </summary>
  53. public virtual string UserName { get; set; }
  54. /// <summary>
  55. /// Service (class/interface) name.
  56. /// </summary>
  57. public virtual string ServiceName { get; set; }
  58. /// <summary>
  59. /// Executed method name.
  60. /// </summary>
  61. public virtual string MethodName { get; set; }
  62. /// <summary>
  63. /// Calling parameters.
  64. /// </summary>
  65. public virtual string Parameters { get; set; }
  66. /// <summary>
  67. /// Start time of the method execution.
  68. /// </summary>
  69. public virtual DateTime ExecutionTime { get; set; }
  70. /// <summary>
  71. /// Total duration of the method call as milliseconds.
  72. /// </summary>
  73. public virtual int ExecutionDuration { get; set; }
  74. /// <summary>
  75. /// IP address of the client.
  76. /// </summary>
  77. public virtual string ClientIpAddress { get; set; }
  78. /// <summary>
  79. /// Name (generally computer name) of the client.
  80. /// </summary>
  81. public virtual string ClientName { get; set; }
  82. /// <summary>
  83. /// Browser information if this method is called in a web request.
  84. /// </summary>
  85. public virtual string BrowserInfo { get; set; }
  86. /// <summary>
  87. /// Exception object, if an exception occured during execution of the method.
  88. /// </summary>
  89. public virtual string Exception { get; set; }
  90. /// <summary>
  91. /// <see cref="AuditInfo.ImpersonatorUserId"/>.
  92. /// </summary>
  93. public virtual long? ImpersonatorUserId { get; set; }
  94. /// <summary>
  95. /// <see cref="AuditInfo.ImpersonatorTenantId"/>.
  96. /// </summary>
  97. public virtual int? ImpersonatorTenantId { get; set; }
  98. public virtual string CustomData { get; set; }
  99. public virtual int LogType { get; set; }
  100. public virtual IwbSysLog CreateFromAuditInfo(AuditInfo auditInfo)
  101. {
  102. return null;
  103. }
  104. public override string ToString()
  105. {
  106. return
  107. $"AUDIT LOG: {ServiceName}.{MethodName} is executed by user {UserId} in {ExecutionDuration} ms from {ClientIpAddress} IP address.";
  108. }
  109. }
  110. }