OP.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using MECF.Framework.Common.OperationCenter;
  6. namespace Aitex.Core.RT.OperationCenter
  7. {
  8. public class OP
  9. {
  10. public static ICommonOperation InnerOperationManager { set; private get; }
  11. public static IOperation OperationManager { set; private get; }
  12. public static void Subscribe<T>(T instance, string keyPrefix = null) where T : class
  13. {
  14. if (InnerOperationManager != null)
  15. InnerOperationManager.Subscribe<T>(instance, keyPrefix);
  16. }
  17. public static void Subscribe(string key, Func<string, object[], bool> op)
  18. {
  19. if (InnerOperationManager != null)
  20. InnerOperationManager.Subscribe(key, op);
  21. }
  22. public static void Subscribe(string key, OperationFunction op)
  23. {
  24. if (OperationManager != null)
  25. OperationManager.Subscribe(key, op);
  26. }
  27. public static void DoOperation(string operationName, params object[] args)
  28. {
  29. if (InnerOperationManager != null)
  30. InnerOperationManager.DoOperation(operationName, args);
  31. }
  32. public static void DoOperation(string operationName, out string reason, int time, params object[] args)
  33. {
  34. reason = string.Empty;
  35. if (OperationManager != null)
  36. OperationManager.DoOperation(operationName, out reason, time, args);
  37. }
  38. public static bool ContainsOperation(string operation)
  39. {
  40. if (InnerOperationManager != null)
  41. return InnerOperationManager.ContainsOperation(operation);
  42. return true;
  43. }
  44. public static bool CanDoOperation(string operation, out string reason, params object[] args)
  45. {
  46. if (InnerOperationManager != null)
  47. return InnerOperationManager.CanDoOperation(operation, out reason, args);
  48. reason = string.Empty;
  49. return true;
  50. }
  51. public static bool AddCheck(string operation, IInterlockChecker checker)
  52. {
  53. if (InnerOperationManager != null)
  54. return InnerOperationManager.AddCheck(operation, checker);
  55. return true;
  56. }
  57. }
  58. }