OTSLicMgrFunExport.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #pragma once
  2. #include "OTSLicMgr.h"
  3. #include "OTSHelper.h"
  4. #include "DlgLicenseInfo.h"
  5. namespace OTSINTERFACE {
  6. using namespace System;
  7. using namespace OTSMODEL;
  8. using namespace OTSDATA;
  9. //using namespace System::Collections::Generic;
  10. // COTSLicenseInfo command target
  11. // license info class
  12. public ref class COTSLicenseInfoClr : public Object
  13. {
  14. public:
  15. COTSLicenseInfoClr(); // constructor
  16. COTSLicenseInfoClr(COTSLicenseInfoPtr a_Ptr);
  17. ~COTSLicenseInfoClr(); // detractor
  18. !COTSLicenseInfoClr();
  19. void FreePointer();
  20. // // machine id
  21. String^ GetMachineId();
  22. void SetMachineId(String^ a_strMachineId);
  23. // software package id
  24. int GetPackId();
  25. void SetPackId(int a_nPackId);
  26. // license type
  27. int GetLicType();
  28. void SetLicType(int a_nLicType);
  29. // expire date
  30. DateTime^ GetExpireDate();
  31. void SetExpireDate(DateTime^ a_oexpiredate);
  32. // computer nick name
  33. String^ GetComputerNickName();
  34. void SetComputerNickName(String^ a_strComputerNickName);
  35. COTSLicenseInfoPtr GetCOTSLicenseInfo();
  36. private:
  37. COTSLicenseInfo* m_pOTSLicenseInfo;
  38. };
  39. // COTSLicInfoFile command target
  40. // license manager app file
  41. public ref class COTSLicInfoFileClr : public Object
  42. {
  43. public:
  44. COTSLicInfoFileClr(); // constructor
  45. COTSLicInfoFileClr(COTSLicInfoFilePtr a_ptr);
  46. ~COTSLicInfoFileClr(); // detractor
  47. !COTSLicInfoFileClr();
  48. void FreePointer();
  49. // file pathname
  50. String^ GetPathName();
  51. void SetPathName(String^ a_strPathName);
  52. // modify flag
  53. bool IsModified();
  54. void SetModify(bool a_bModify );
  55. // Load/Save
  56. bool Load(String^ a_strPathName);
  57. bool Save();
  58. private:
  59. COTSLicInfoFile* m_pOTSLicInfoFile;
  60. };
  61. // COTSLicenseFile command target
  62. // OTS license/license key file
  63. public ref class COTSLicenseFileClr : public Object
  64. {
  65. public:
  66. COTSLicenseFileClr(); // constructor
  67. COTSLicenseFileClr(COTSLicenseFilePtr a_Ptr); // constructor
  68. ~COTSLicenseFileClr(); // detractor
  69. !COTSLicenseFileClr();
  70. void FreePointer();
  71. // // file pathname
  72. String^ GetPathName();
  73. // license info
  74. bool GetLicenseInfo(COTSLicenseInfoClr^ % a_pOTSLicenseInfo);
  75. void SetLicenseInfo(COTSLicenseInfoClr^ a_pLicenseInfo);
  76. // Load/Save
  77. bool Load(String^ a_strPathName);
  78. bool Save(String^ a_strPathName);
  79. private:
  80. COTSLicenseFile* m_pOTSLicenseFile;
  81. };
  82. // COTSLicMgr command target
  83. // manage license info file and license file
  84. public ref class COTSLicMgrClr : public Object
  85. {
  86. public:
  87. COTSLicMgrClr(); // constructor
  88. ~COTSLicMgrClr(); // constructor
  89. !COTSLicMgrClr();
  90. void FreePointer();
  91. // check if there is valid license of the given software package
  92. bool IsThereValidPackLicense(int a_nPackId);
  93. bool GetOTSLiceseFile(COTSLicenseFileClr^ % a_pOTSLicenseInfo);
  94. // load license info file
  95. bool LoadLicenseInfoFile();
  96. bool GetOTSLicenseInfoFile(COTSLicInfoFileClr^ % a_pOTSLicenseInfo);
  97. // get license info file name
  98. String^ GetLicenseInfoFilePathName();
  99. // get software package license file name
  100. String^ GetPackLicenseFilePathName(int a_nPackId);
  101. // check if the given license file is valid
  102. bool IsValidLicense(int a_nPackId,
  103. COTSLicenseInfoClr^ a_pOTSLicenseInfo,
  104. int% m_nLicStatus,
  105. bool a_bCheckMachinId,
  106. bool a_bTraceInfo);
  107. // // load license info from file
  108. bool LoadLicenseInfoFromFile(COTSLicenseInfoClr^ % a_pOTSLicenseInfo);
  109. // // create license file
  110. bool CreateLicenseFile(COTSLicenseInfoClr^ a_pOTSLicenseInfo);
  111. // // read license info from a text file
  112. bool LoadLicenseInfoFromTextFile(String^ a_strFilePathName, COTSLicenseInfoClr^ % a_pOTSLicenseInfo);
  113. // // get license info item
  114. bool GetLicnseInfoItem(COTSLicenseInfoClr^ a_pLicenseInfo, String^ a_strTitle, String^ a_strValue);
  115. // get software pack id string
  116. String^ GetSoftwarePackIdString(int a_nPackId);
  117. // get license type string
  118. String^ GetLicenseTypeIdString(int a_nLicTypeId);
  119. // // encrypt/decrypt license info string
  120. String^ EncryptLicenseInfo(COTSLicenseInfoClr^ a_pLicenseInfo);
  121. bool DecryptLicenseInfo(String^ a_strLicense, COTSLicenseInfoClr^ % a_pOTSLicenseInfo);
  122. bool ShowEditDialogExport(COTSLicenseInfoClr^ a_pLicenseInfo, bool a_bAdd, bool a_bRequest)
  123. {
  124. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::ShowEditDialogExport ***************");
  125. bool bRet;
  126. COTSLicenseInfoPtr a_ptr(new COTSLicenseInfo(a_pLicenseInfo->GetCOTSLicenseInfo().get()));
  127. bRet = ShowEditDialog(*a_ptr.get(), a_bAdd, a_bRequest);
  128. m_ComputerNicName = gcnew String(a_ptr->GetComputerNickName());
  129. m_MachineId = gcnew String(a_ptr->GetMachineId());
  130. m_PackId = (int)a_ptr->GetPackId();
  131. m_LicType = (int)a_ptr->GetLicType();
  132. m_oExpireDate = gcnew DateTime(a_ptr->GetExpireDate().GetYear(), a_ptr->GetExpireDate().GetMonth(), a_ptr->GetExpireDate().GetDay());
  133. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&&&&&&&&&&& Enter COTSLicMgrClr::ShowEditDialogExport &&&&&&&&&&&&&&&");
  134. return bRet;
  135. }
  136. String^ GetMachineId()
  137. {
  138. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::GetMachineId ***************");
  139. CString a_str = COTSHelper::GetMachineId();
  140. String^ str = gcnew String(a_str);
  141. LogInfoTrace(__FILE__, __LINE__, _T("COTSLicMgrClr::GetMachineId is %s"), a_str);
  142. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::GetMachineId &&&&&&&&&&&&&&&");
  143. return str;
  144. }
  145. public:
  146. String^ m_ComputerNicName;
  147. String^ m_MachineId;
  148. int m_PackId;
  149. int m_LicType;
  150. DateTime^ m_oExpireDate;
  151. private:
  152. COTSLicMgr* m_pOTSLicMgr;
  153. };
  154. }