BusinessLogService.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Abp.Dependency;
  7. using Abp.Domain.Repositories;
  8. using Abp.Extensions;
  9. using Abp.Timing;
  10. using ShwasherSys.BaseSysInfo;
  11. using ShwasherSys.NotificationInfo;
  12. using ShwasherSys.NotificationInfo.Dto;
  13. using ShwasherSys.ProductionOrderInfo;
  14. namespace ShwasherSys.Common
  15. {
  16. public static class BusinessLogService
  17. {
  18. public static void WriteLog(this IRepository<BusinessLog> logRepository, BusinessLog logInfo)
  19. {
  20. logRepository.InsertAsync(logInfo);
  21. }
  22. public static void WriteLog(this IRepository<BusinessLog> logRepository, BusinessLogTypeEnum logType, string logCommand, string logMsg,string logErrorMsg="",string logExtend1Info="", string logExtend2Info = "", string logExtend3Info = "", string logExtend4Info = "")
  23. {
  24. /*IRepository<BusinessLog> logRepository = IocManager.Resolve<IRepository<BusinessLog>>alize();*/
  25. BusinessLog log = new BusinessLog()
  26. {
  27. LogDate = Clock.Now,
  28. Extend1Log = logExtend1Info,
  29. Extend2Log = logExtend2Info,
  30. Extend3Log = logExtend3Info,
  31. Extend4Log = logExtend4Info,
  32. LogCommand = logCommand,
  33. LogErrorMessage = logErrorMsg,
  34. LogMessage = logMsg,
  35. LogType = logType.ToInt()
  36. };
  37. WriteLog(logRepository, log);
  38. }
  39. public static void WriteLog(this BusinessLogTypeEnum logType, IRepository<BusinessLog> logRepository, string logCommand, string logMsg, string logExt1 = "", string logExt2 = "", string logExt3 = "", string logExt4 = "" ,string eMsg = "")
  40. {
  41. //Action ac = () =>
  42. //{
  43. // BusinessLog log = new BusinessLog()
  44. // {
  45. // LogDate = Clock.Now,
  46. // Extend1Log = logExt1,
  47. // Extend2Log = logExt2,
  48. // Extend3Log = logExt3,
  49. // Extend4Log = logExt4,
  50. // LogCommand = logCommand,
  51. // LogErrorMessage = eMsg,
  52. // LogMessage = logMsg,
  53. // LogType = logType.ToInt()
  54. // };
  55. // WriteLog(logRepository, log);
  56. //};
  57. //ac.BeginInvoke(null,null);
  58. BusinessLog log = new BusinessLog()
  59. {
  60. LogDate = Clock.Now,
  61. Extend1Log = logExt1,
  62. Extend2Log = logExt2,
  63. Extend3Log = logExt3,
  64. Extend4Log = logExt4,
  65. LogCommand = logCommand,
  66. LogErrorMessage = eMsg,
  67. LogMessage = logMsg,
  68. LogType = logType.ToInt()
  69. };
  70. WriteLog(logRepository, log);
  71. }
  72. public static void ErrorLog(this BusinessLogTypeEnum logType, IRepository<BusinessLog> logRepository, string logCommand, string eMsg, string logExt1 = "", string logExt2 = "", string logExt3 = "", string logExt4 = "" ,string logMsg = "")
  73. {
  74. BusinessLog log = new BusinessLog()
  75. {
  76. LogDate = Clock.Now,
  77. Extend1Log = logExt1,
  78. Extend2Log = logExt2,
  79. Extend3Log = logExt3,
  80. Extend4Log = logExt4,
  81. LogCommand = logCommand,
  82. LogErrorMessage = eMsg,
  83. LogMessage = logMsg,
  84. LogType = logType.ToInt()
  85. };
  86. WriteLog(logRepository, log);
  87. }
  88. /// <summary>
  89. /// 写入短消息
  90. /// </summary>
  91. /// <param name="msgRepository"></param>
  92. /// <param name="sendman">发送人</param>
  93. /// <param name="recieveIds">接收用户名 eg:shenjianfang,menghanming,jiangjingeng</param>
  94. /// <param name="title"></param>
  95. /// <param name="content"></param>
  96. public static void WriteShortMessage(this IRepository<ShortMessage> msgRepository,string sendman,string recieveIds,string title="",string content="")
  97. {
  98. ShortMessage shortMessage = new ShortMessage()
  99. {
  100. SendUserID = sendman,
  101. SendTime = Clock.Now,
  102. Title = title,
  103. Content = content,
  104. RecieveUserIds = recieveIds,
  105. IsDelete = "N"
  106. };
  107. msgRepository.InsertAsync(shortMessage);
  108. }
  109. }
  110. }