OP.cs 2.5 KB

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