SystemLogRepository.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Hotline.Repository.SqlSugar.DataPermissions;
  2. using Hotline.Settings;
  3. using Hotline.Share.Tools;
  4. using SqlSugar;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Runtime.CompilerServices;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using XF.Domain.Dependency;
  13. namespace Hotline.Repository.SqlSugar.System;
  14. public class SystemLogRepository : BaseRepository<SystemLog>, ISystemLogRepository, IScopeDependency
  15. {
  16. public SystemLogRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder) : base(uow, dataPermissionFilterBuilder)
  17. {
  18. }
  19. public void Add(string name, string executeParam = "", string remark = "", [CallerMemberName]string executeUrl = "", int status = 0, string ipUrl = "", string executeResult = "")
  20. {
  21. try
  22. {
  23. var entity = new SystemLog
  24. {
  25. Name = name,
  26. ExecuteParam = executeParam,
  27. ExecuteResult = executeResult,
  28. ExecuteUrl = executeUrl,
  29. Remark = remark,
  30. Status = status,
  31. IpUrl = ipUrl
  32. };
  33. if (executeUrl.IsNullOrEmpty())
  34. {
  35. entity.ExecuteUrl = new StackTrace().GetFrame(1).GetMethod().Name;
  36. }
  37. AddAsync(entity).GetAwaiter().GetResult();
  38. }
  39. catch
  40. {
  41. // ignore
  42. }
  43. }
  44. }