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