AopInterceptor.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Castle.DynamicProxy;
  2. namespace SHJX.Service.Control.Proxy
  3. {
  4. public class AopInterceptor : IInterceptor
  5. {
  6. private static readonly ILogger logger = LogFactory.BuildLogger(typeof(AopInterceptor));
  7. private static IDataManager _dataManager;
  8. private static ReadConfigUtil _configUtil;
  9. public AopInterceptor(IDataManager dataManager, ReadConfigUtil configUtil)
  10. {
  11. _dataManager = dataManager;
  12. _configUtil = configUtil;
  13. }
  14. public void Intercept(IInvocation invocation)
  15. {
  16. try
  17. {
  18. if (!_configUtil.TaskRunning)
  19. {
  20. logger.LogDebug("任务已暂停");
  21. }
  22. while (!_configUtil.TaskRunning)
  23. {
  24. Thread.Sleep(1 * 1000);
  25. }
  26. invocation?.Proceed();
  27. }
  28. catch (Exception ex)
  29. {
  30. logger.LogError(ex.ToString());
  31. }
  32. }
  33. }
  34. }