OP.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 DoOperationWithoutCheck(string operationName, params object[] args)
  33. {
  34. if (InnerOperationManager != null)
  35. InnerOperationManager.DoOperationWithoutCheck(operationName, args);
  36. }
  37. public static void DoOperation(string operationName, out string reason, int time, params object[] args)
  38. {
  39. reason = string.Empty;
  40. if (OperationManager != null)
  41. OperationManager.DoOperation(operationName, out reason, time, args);
  42. }
  43. public static bool ContainsOperation(string operation)
  44. {
  45. if (InnerOperationManager != null)
  46. return InnerOperationManager.ContainsOperation(operation);
  47. return true;
  48. }
  49. public static bool CanDoOperation(string operation, out string reason, params object[] args)
  50. {
  51. if (InnerOperationManager != null)
  52. return InnerOperationManager.CanDoOperation(operation, out reason, args);
  53. reason = string.Empty;
  54. return true;
  55. }
  56. public static bool AddCheck(string operation, IInterlockChecker checker)
  57. {
  58. if (InnerOperationManager != null)
  59. return InnerOperationManager.AddCheck(operation, checker);
  60. return true;
  61. }
  62. }
  63. }