UpgradeManager_server_g.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef __UPGRADEMANAGER_SERVER_G_H
  2. #define __UPGRADEMANAGER_SERVER_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "UpgradeManager_def_g.h"
  6. namespace UpgradeManager {
  7. class UpgradeMgrService_ServerSessionBase : public CServerSessionBase
  8. {
  9. public:
  10. UpgradeMgrService_ServerSessionBase()
  11. {
  12. /// override by user
  13. }
  14. virtual ~UpgradeMgrService_ServerSessionBase()
  15. {
  16. /// override by user
  17. }
  18. virtual bool IsExclusive() { return false; }
  19. virtual bool IsSessionOverlap() { return true; }
  20. virtual ErrorCodeEnum GetMessageAttr(DWORD dwMessageID, DWORD dwSignature, bool &bOverlap)
  21. {
  22. ErrorCodeEnum Error = Error_Succeed;
  23. switch (dwMessageID) {
  24. case UpgradeMgrService_Method_GetUpgradeState:
  25. if (dwSignature == UpgradeMgrService_MethodSignature_GetUpgradeState) {
  26. bOverlap = true;
  27. } else {
  28. Error = Error_MethodSignatureFailed;
  29. }
  30. break;
  31. case UpgradeMgrService_Method_RollbackUpdate:
  32. if (dwSignature == UpgradeMgrService_MethodSignature_RollbackUpdate) {
  33. bOverlap = true;
  34. } else {
  35. Error = Error_MethodSignatureFailed;
  36. }
  37. break;
  38. default:
  39. Error = Error_MethodNotFound;
  40. break;
  41. }
  42. return Error;
  43. }
  44. int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
  45. {
  46. ErrorCodeEnum Error = Error_Succeed;
  47. switch (dwMessageID) {
  48. case UpgradeMgrService_Method_GetUpgradeState:
  49. if (dwSignature != UpgradeMgrService_MethodSignature_GetUpgradeState) {
  50. Error = Error_MethodSignatureFailed;
  51. }
  52. break;
  53. case UpgradeMgrService_Method_RollbackUpdate:
  54. if (dwSignature != UpgradeMgrService_MethodSignature_RollbackUpdate) {
  55. Error = Error_MethodSignatureFailed;
  56. }
  57. break;
  58. default:
  59. Error = Error_MethodNotFound;
  60. break;
  61. }
  62. return Error;
  63. }
  64. virtual void Handle_GetUpgradeState(SpReqAnsContext<UpgradeMgrService_GetUpgradeState_Req, UpgradeMgrService_GetUpgradeState_Ans>::Pointer ctx)
  65. {
  66. /// override by user
  67. }
  68. virtual void Handle_RollbackUpdate(SpReqAnsContext<UpgradeMgrService_RollbackUpdate_Req, UpgradeMgrService_RollbackUpdate_Ans>::Pointer ctx)
  69. {
  70. /// override by user
  71. }
  72. virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
  73. {
  74. CAutoBuffer Buf;
  75. DWORD dwMessageID;
  76. DWORD dwMessageSignature;
  77. ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
  78. if (Error == Error_Succeed) {
  79. #ifdef DEBUG
  80. assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
  81. #else
  82. if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
  83. pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
  84. return;
  85. }
  86. #endif
  87. switch (dwMessageID) {
  88. case UpgradeMgrService_Method_GetUpgradeState:
  89. {
  90. SpReqAnsContext<UpgradeMgrService_GetUpgradeState_Req,UpgradeMgrService_GetUpgradeState_Ans>::Pointer ctx;
  91. ctx.Attach(new SpReqAnsContext<UpgradeMgrService_GetUpgradeState_Req,UpgradeMgrService_GetUpgradeState_Ans>(pTransactionContext));
  92. SpBuffer2Object(Buf, ctx->Req);
  93. pTransactionContext->GetLinkContext(ctx->link);
  94. EntityResource::setLink(ctx->link);
  95. Handle_GetUpgradeState(ctx);
  96. }
  97. break;
  98. case UpgradeMgrService_Method_RollbackUpdate:
  99. {
  100. SpReqAnsContext<UpgradeMgrService_RollbackUpdate_Req,UpgradeMgrService_RollbackUpdate_Ans>::Pointer ctx;
  101. ctx.Attach(new SpReqAnsContext<UpgradeMgrService_RollbackUpdate_Req,UpgradeMgrService_RollbackUpdate_Ans>(pTransactionContext));
  102. SpBuffer2Object(Buf, ctx->Req);
  103. pTransactionContext->GetLinkContext(ctx->link);
  104. EntityResource::setLink(ctx->link);
  105. Handle_RollbackUpdate(ctx);
  106. }
  107. break;
  108. default:
  109. assert(0);
  110. break;
  111. }
  112. } else {
  113. pTransactionContext->SendAnswer(Error);
  114. }
  115. }
  116. };
  117. ///////////////////////////
  118. } // namespace UpgradeManager
  119. #endif // __UPGRADEMANAGER_SERVER_G_H