OTSLicMgrFunExport.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. #include "stdafx.h"
  2. #include "OTSLicMgrFunExport.h"
  3. namespace OTSINTERFACE {
  4. COTSLicenseInfoClr::COTSLicenseInfoClr() // constructor
  5. {
  6. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::COTSLicenseInfoClr ***************");
  7. m_pOTSLicenseInfo = new COTSLicenseInfo();
  8. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::COTSLicenseInfoClr &&&&&&&&&&&&&&&");
  9. }
  10. COTSLicenseInfoClr::COTSLicenseInfoClr(COTSLicenseInfoPtr a_Ptr) // constructor
  11. {
  12. if (a_Ptr == nullptr)
  13. {
  14. LogErrorTrace(__FILE__, __LINE__, _T("COTSLicenseInfoClr: invalid pointer"));
  15. return;
  16. }
  17. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::COTSLicenseInfoClr ***************");
  18. m_pOTSLicenseInfo = new COTSLicenseInfo(a_Ptr.get());
  19. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::COTSLicenseInfoClr &&&&&&&&&&&&&&&");
  20. }
  21. COTSLicenseInfoClr::~COTSLicenseInfoClr() // detractor
  22. {
  23. if (m_pOTSLicenseInfo != nullptr)
  24. {
  25. delete m_pOTSLicenseInfo;
  26. m_pOTSLicenseInfo = nullptr;
  27. }
  28. }
  29. COTSLicenseInfoClr::!COTSLicenseInfoClr() // detractor
  30. {
  31. if (m_pOTSLicenseInfo != nullptr)
  32. {
  33. delete m_pOTSLicenseInfo;
  34. m_pOTSLicenseInfo = nullptr;
  35. }
  36. }
  37. void COTSLicenseInfoClr::FreePointer() // detractor
  38. {
  39. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::FreePointer ***************");
  40. if (m_pOTSLicenseInfo != NULL)
  41. {
  42. delete m_pOTSLicenseInfo;
  43. m_pOTSLicenseInfo = NULL;
  44. }
  45. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::FreePointer ***************");
  46. }
  47. // machine id
  48. String^ COTSLicenseInfoClr::GetMachineId()
  49. {
  50. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::GetMachineId ***************");
  51. CString a_str = m_pOTSLicenseInfo->GetMachineId();
  52. String^ strOut = gcnew String(a_str);
  53. LogInfoTrace(__FILE__, __LINE__, _T("GetMachineId is %s"), a_str);
  54. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::GetMachineId ***************");
  55. return strOut;
  56. }
  57. void COTSLicenseInfoClr::SetMachineId(String^ a_strMachineId)
  58. {
  59. if (a_strMachineId == nullptr)
  60. {
  61. LogErrorTrace(__FILE__, __LINE__, _T("SetMachineId: invalid pointer"));
  62. return;
  63. }
  64. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::SetMachineId ***************");
  65. CString a_str = a_strMachineId;
  66. LogInfoTrace(__FILE__, __LINE__, _T("SetMachineId %s"),a_str);
  67. m_pOTSLicenseInfo->SetMachineId(a_str);
  68. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::SetMachineId ***************");
  69. }
  70. // software package id
  71. int COTSLicenseInfoClr::GetPackId()
  72. {
  73. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::GetPackId ***************");
  74. int bRet;
  75. bRet = (int)m_pOTSLicenseInfo->GetPackId();
  76. LogInfoTrace(__FILE__, __LINE__, _T("GetPackId is %d"), bRet);
  77. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::GetPackId ***************");
  78. return bRet;
  79. }
  80. void COTSLicenseInfoClr::SetPackId( int a_nPackId)
  81. {
  82. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::SetPackId ***************");
  83. m_pOTSLicenseInfo->SetPackId((OTS_SOFT_PACKAGE_ID)a_nPackId);
  84. LogInfoTrace(__FILE__, __LINE__, _T("SetPackId %d"), a_nPackId);
  85. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::SetPackId ***************");
  86. }
  87. // license type
  88. int COTSLicenseInfoClr::GetLicType()
  89. {
  90. int bRet;
  91. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::GetLicType ***************");
  92. bRet = (int)m_pOTSLicenseInfo->GetLicType();
  93. LogInfoTrace(__FILE__, __LINE__, _T("GetLicType is %d"), bRet);
  94. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::GetLicType ***************");
  95. return bRet;
  96. }
  97. void COTSLicenseInfoClr::SetLicType(int a_nLicType)
  98. {
  99. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::SetLicType ***************");
  100. m_pOTSLicenseInfo->SetLicType((OTS_LICENSE_TYPE)a_nLicType);
  101. LogInfoTrace(__FILE__, __LINE__, _T("SetLicType %d"), a_nLicType);
  102. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::SetLicType ***************");
  103. }
  104. // expire date
  105. DateTime^ COTSLicenseInfoClr::GetExpireDate()
  106. {
  107. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::GetExpireDate ***************");
  108. COleDateTime a_DT;
  109. a_DT = m_pOTSLicenseInfo->GetExpireDate();
  110. LogInfoTrace(__FILE__, __LINE__, _T("GetExpireDate: Year: Month: Date:is (%d:%d:%d)"), a_DT.GetYear(), a_DT.GetMonth(), a_DT.GetDay());
  111. #pragma warning(disable: 4244)
  112. DateTime^ a_dt = gcnew DateTime(a_DT);
  113. #pragma warning(default: 4244)
  114. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::GetExpireDate ***************");
  115. return a_dt;
  116. }
  117. void COTSLicenseInfoClr::SetExpireDate(DateTime^ a_oexpiredate)
  118. {
  119. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::SetExpireDate ***************");
  120. COleDateTime a_DT(a_oexpiredate->Year,
  121. a_oexpiredate->Month,
  122. a_oexpiredate->Day,
  123. a_oexpiredate->Hour,
  124. a_oexpiredate->Minute,
  125. a_oexpiredate->Second);
  126. LogInfoTrace(__FILE__, __LINE__, _T("SetExpireDate: Year: Month: Date:is (%d:%d:%d)"), a_DT.GetYear(), a_DT.GetMonth(), a_DT.GetDay());
  127. m_pOTSLicenseInfo->SetExpireDate(a_DT);
  128. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::SetExpireDate ***************");
  129. }
  130. // computer nick name
  131. String^ COTSLicenseInfoClr::GetComputerNickName()
  132. {
  133. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::GetComputerNickName ***************");
  134. CString a_str = m_pOTSLicenseInfo->GetComputerNickName();
  135. LogInfoTrace(__FILE__, __LINE__, _T("GetComputerNickName is %s"), a_str);
  136. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::GetComputerNickName ***************");
  137. String^ strOut = gcnew String(a_str);
  138. return strOut;
  139. }
  140. void COTSLicenseInfoClr::SetComputerNickName(String^ a_strComputerNickName)
  141. {
  142. if (a_strComputerNickName == nullptr)
  143. {
  144. LogErrorTrace(__FILE__, __LINE__, _T("SetComputerNickName: invalid pointer"));
  145. return;
  146. }
  147. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::SetComputerNickName ***************");
  148. CString a_str = a_strComputerNickName;
  149. LogInfoTrace(__FILE__, __LINE__, _T("SetComputerNickName %s"), a_str);
  150. m_pOTSLicenseInfo->SetComputerNickName(a_str);
  151. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::SetComputerNickName ***************");
  152. }
  153. COTSLicenseInfoPtr COTSLicenseInfoClr::GetCOTSLicenseInfo()
  154. {
  155. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseInfoClr::GetCOTSLicenseInfo ***************");
  156. COTSLicenseInfoPtr a_pt ( new COTSLicenseInfo(m_pOTSLicenseInfo));
  157. return a_pt;
  158. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseInfoClr::GetCOTSLicenseInfo ***************");
  159. }
  160. COTSLicInfoFileClr::COTSLicInfoFileClr() // constructor
  161. {
  162. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicInfoFileClr::COTSLicInfoFileClr ***************");
  163. m_pOTSLicInfoFile = new COTSLicInfoFile();
  164. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicInfoFileClr::COTSLicInfoFileClr ***************");
  165. }
  166. COTSLicInfoFileClr::COTSLicInfoFileClr(COTSLicInfoFilePtr a_ptr) // constructor
  167. {
  168. if (a_ptr == nullptr)
  169. {
  170. LogErrorTrace(__FILE__, __LINE__, _T("COTSLicInfoFileClr:invalid pointer"));
  171. return;
  172. }
  173. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicInfoFileClr::COTSLicInfoFileClr ***************");
  174. m_pOTSLicInfoFile = new COTSLicInfoFile(a_ptr.get());
  175. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicInfoFileClr::COTSLicInfoFileClr ***************");
  176. }
  177. COTSLicInfoFileClr::~COTSLicInfoFileClr() // detractor
  178. {
  179. if (m_pOTSLicInfoFile != NULL)
  180. {
  181. delete m_pOTSLicInfoFile;
  182. m_pOTSLicInfoFile = NULL;
  183. }
  184. }
  185. COTSLicInfoFileClr::!COTSLicInfoFileClr() // detractor
  186. {
  187. if (m_pOTSLicInfoFile != NULL)
  188. {
  189. delete m_pOTSLicInfoFile;
  190. m_pOTSLicInfoFile = NULL;
  191. }
  192. }
  193. void COTSLicInfoFileClr::FreePointer() // detractor
  194. {
  195. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicInfoFileClr::FreePointer ***************");
  196. if (m_pOTSLicInfoFile != NULL)
  197. {
  198. delete m_pOTSLicInfoFile;
  199. m_pOTSLicInfoFile = NULL;
  200. }
  201. LogInfoTrace(__FILE__, __LINE__, "***************** Exit COTSLicInfoFileClr::FreePointer ***************");
  202. }
  203. // file pathname
  204. String^ COTSLicInfoFileClr::GetPathName()
  205. {
  206. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicInfoFileClr::GetPathName ***************");
  207. CString a_str = m_pOTSLicInfoFile->GetPathName();
  208. String^ strOut = gcnew String(a_str);
  209. LogInfoTrace(__FILE__, __LINE__, _T("GetPathName %s"), a_str);
  210. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicInfoFileClr::GetPathName ***************");
  211. return strOut;
  212. }
  213. void COTSLicInfoFileClr::SetPathName(String^ a_strPathName)
  214. {
  215. if (a_strPathName == nullptr)
  216. {
  217. LogErrorTrace(__FILE__, __LINE__, _T("SetPathName:invalid pointer"));
  218. return;
  219. }
  220. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicInfoFileClr::SetMachineId ***************");
  221. CString a_str = a_strPathName;
  222. LogInfoTrace(__FILE__, __LINE__, _T("SetMachineId %s"), a_str);
  223. m_pOTSLicInfoFile->SetPathName(a_str);
  224. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicInfoFileClr::SetMachineId ***************");
  225. }
  226. // modify flag
  227. bool COTSLicInfoFileClr::IsModified()
  228. {
  229. bool bRet;
  230. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicInfoFileClr::IsModified ***************");
  231. bRet = m_pOTSLicInfoFile->IsModified();
  232. LogInfoTrace(__FILE__, __LINE__, _T("IsModified return is %d"), bRet);
  233. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicInfoFileClr::IsModified ***************");
  234. return bRet;
  235. }
  236. void COTSLicInfoFileClr::SetModify(bool a_bModify)
  237. {
  238. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicInfoFileClr::SetModify ***************");
  239. m_pOTSLicInfoFile->SetModify(a_bModify);
  240. LogInfoTrace(__FILE__, __LINE__, _T("SetModify %d"), a_bModify);
  241. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicInfoFileClr::SetModify ***************");
  242. }
  243. // Load/Save
  244. bool COTSLicInfoFileClr::Load(String^ a_strPathName)
  245. {
  246. if (a_strPathName == nullptr)
  247. {
  248. LogErrorTrace(__FILE__, __LINE__, _T("Load:invalid pointer"));
  249. return false;
  250. }
  251. bool bRet;
  252. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicInfoFileClr::Load ***************");
  253. CString a_str = a_strPathName;
  254. bRet = m_pOTSLicInfoFile->Load(a_str);
  255. LogInfoTrace(__FILE__, __LINE__, _T("Load return is %d"), bRet);
  256. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicInfoFileClr::Load ***************");
  257. return bRet;
  258. }
  259. bool COTSLicInfoFileClr::Save()
  260. {
  261. bool bRet;
  262. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicInfoFileClr::Save ***************");
  263. bRet = m_pOTSLicInfoFile->Save();
  264. LogInfoTrace(__FILE__, __LINE__, _T("Save return is %d"), bRet);
  265. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicInfoFileClr::Save ***************");
  266. return bRet;
  267. }
  268. COTSLicenseFileClr::COTSLicenseFileClr() // constructor
  269. {
  270. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseFileClr::COTSLicenseFileClr ***************");
  271. m_pOTSLicenseFile = new COTSLicenseFile();
  272. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseFileClr::COTSLicenseFileClr ***************");
  273. }
  274. COTSLicenseFileClr::COTSLicenseFileClr(COTSLicenseFilePtr a_Ptr) // constructor
  275. {
  276. if (a_Ptr == nullptr)
  277. {
  278. LogErrorTrace(__FILE__, __LINE__, _T("COTSLicenseFileClr:invalid pointer"));
  279. return;
  280. }
  281. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseFileClr::COTSLicenseFileClr ***************");
  282. m_pOTSLicenseFile = new COTSLicenseFile(a_Ptr.get());
  283. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseFileClr::COTSLicenseFileClr ***************");
  284. }
  285. COTSLicenseFileClr::~COTSLicenseFileClr() // detractor
  286. {
  287. if (m_pOTSLicenseFile != NULL)
  288. {
  289. delete m_pOTSLicenseFile;
  290. m_pOTSLicenseFile = NULL;
  291. }
  292. }
  293. COTSLicenseFileClr::!COTSLicenseFileClr() // detractor
  294. {
  295. if (m_pOTSLicenseFile != NULL)
  296. {
  297. delete m_pOTSLicenseFile;
  298. m_pOTSLicenseFile = NULL;
  299. }
  300. }
  301. void COTSLicenseFileClr::FreePointer() // detractor
  302. {
  303. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseFileClr::FreePointer ***************");
  304. if (m_pOTSLicenseFile != NULL)
  305. {
  306. delete m_pOTSLicenseFile;
  307. m_pOTSLicenseFile = NULL;
  308. }
  309. LogInfoTrace(__FILE__, __LINE__, "***************** Exit COTSLicenseFileClr::FreePointer ***************");
  310. }
  311. String^ COTSLicenseFileClr::GetPathName()
  312. {
  313. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseFileClr::GetPathName ***************");
  314. CString a_str = m_pOTSLicenseFile->GetPathName();
  315. String^ strOut = gcnew String(a_str);
  316. LogInfoTrace(__FILE__, __LINE__, _T("GetPathName %s"), a_str);
  317. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseFileClr::GetPathName ***************");
  318. return strOut;
  319. }
  320. bool COTSLicenseFileClr::GetLicenseInfo(COTSLicenseInfoClr^ % a_pOTSLicenseInfo)
  321. {
  322. bool bRet;
  323. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseFileClr::GetLicenseInfo ***************");
  324. COTSLicenseInfoPtr a_Ptr;
  325. a_Ptr = m_pOTSLicenseFile->GetLicenseInfo();
  326. if (a_Ptr == nullptr)
  327. {
  328. return false;
  329. }
  330. else
  331. {
  332. a_pOTSLicenseInfo = gcnew COTSLicenseInfoClr(a_Ptr);
  333. return true;
  334. }
  335. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseFileClr::GetLicenseInfo ***************");
  336. return bRet;
  337. }
  338. void COTSLicenseFileClr::SetLicenseInfo(COTSLicenseInfoClr^ a_pLicenseInfo)
  339. {
  340. if (a_pLicenseInfo == nullptr)
  341. {
  342. LogErrorTrace(__FILE__, __LINE__, _T("SetLicenseInfo:invalid pointer"));
  343. return;
  344. }
  345. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseFileClr::SetLicenseInfo ***************");
  346. COTSLicenseInfoPtr a_Ptr ( new COTSLicenseInfo(a_pLicenseInfo->GetCOTSLicenseInfo().get()));
  347. m_pOTSLicenseFile->SetLicenseInfo(a_Ptr);
  348. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseFileClr::SetLicenseInfo ***************");
  349. }
  350. bool COTSLicenseFileClr::Load(String^ a_strPathName)
  351. {
  352. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseFileClr::Load ***************");
  353. bool bRet;
  354. CString a_str = a_strPathName;
  355. bRet = m_pOTSLicenseFile->Load(a_str);
  356. LogInfoTrace(__FILE__, __LINE__, _T("Load return %d"),bRet);
  357. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseFileClr::Load ***************");
  358. return bRet;
  359. }
  360. bool COTSLicenseFileClr::Save(String^ a_strPathName)
  361. {
  362. if (a_strPathName == nullptr)
  363. {
  364. LogErrorTrace(__FILE__, __LINE__, _T("Save:invalid pointer"));
  365. return false;
  366. }
  367. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicenseFileClr::Save ***************");
  368. bool bRet;
  369. CString a_str = a_strPathName;
  370. bRet = m_pOTSLicenseFile->Save(a_str);
  371. LogInfoTrace(__FILE__, __LINE__, _T("Save return %d"), bRet);
  372. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicenseFileClr::Save ***************");
  373. return bRet;
  374. }
  375. // COTSLicMgrClr Class
  376. COTSLicMgrClr::COTSLicMgrClr()
  377. {
  378. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::COTSLicMgrClr ***************");
  379. m_pOTSLicMgr = new COTSLicMgr();
  380. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::COTSLicMgrClr ***************");
  381. }
  382. COTSLicMgrClr::~COTSLicMgrClr()
  383. {
  384. if (m_pOTSLicMgr != NULL)
  385. {
  386. delete m_pOTSLicMgr;
  387. m_pOTSLicMgr = NULL;
  388. }
  389. }
  390. COTSLicMgrClr::!COTSLicMgrClr()
  391. {
  392. if (m_pOTSLicMgr != NULL)
  393. {
  394. delete m_pOTSLicMgr;
  395. m_pOTSLicMgr = NULL;
  396. }
  397. }
  398. void COTSLicMgrClr::FreePointer()
  399. {
  400. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::FreePointer ***************");
  401. if (m_pOTSLicMgr != NULL)
  402. {
  403. delete m_pOTSLicMgr;
  404. m_pOTSLicMgr = NULL;
  405. }
  406. LogInfoTrace(__FILE__, __LINE__, "***************** Exit COTSLicMgrClr::FreePointer ***************");
  407. }
  408. bool COTSLicMgrClr::IsThereValidPackLicense(int a_nPackId)
  409. {
  410. bool bRet = false;
  411. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::IsThereValidPackLicense ***************");
  412. bRet = m_pOTSLicMgr->IsThereValidPackLicense((OTS_SOFT_PACKAGE_ID)a_nPackId);
  413. LogInfoTrace(__FILE__, __LINE__, _T("IsThereValidPackLicense return is %d"), bRet);
  414. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::IsThereValidPackLicense ***************");
  415. return bRet;
  416. }
  417. bool COTSLicMgrClr::GetOTSLiceseFile(COTSLicenseFileClr^ % a_pOTSLicenseInfo)
  418. {
  419. bool bRet = false;
  420. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::GetOTSLicenseFile ***************");
  421. COTSLicenseFilePtr a_ptr = m_pOTSLicMgr->GetOTSLicenseFile();
  422. if (a_ptr == nullptr)
  423. {
  424. bRet = false;
  425. }
  426. else
  427. {
  428. a_pOTSLicenseInfo = gcnew COTSLicenseFileClr(a_ptr);
  429. bRet = true;
  430. }
  431. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::GetOTSLicenseFile ***************");
  432. return bRet;
  433. }
  434. // load license info file
  435. bool COTSLicMgrClr::LoadLicenseInfoFile()
  436. {
  437. bool bRet = false;
  438. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::LoadLicenseInfoFile ***************");
  439. bRet = m_pOTSLicMgr->LoadLicenseInfoFile();
  440. LogInfoTrace(__FILE__, __LINE__, _T("LoadLicenseInfoFile return is %d"), bRet);
  441. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::LoadLicenseInfoFile ***************");
  442. return bRet;
  443. }
  444. bool COTSLicMgrClr::GetOTSLicenseInfoFile(COTSLicInfoFileClr^ % a_pOTSLicenseInfo)
  445. {
  446. bool bRet;
  447. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::GetOTSLicenseInfoFile ***************");
  448. COTSLicInfoFilePtr a_ptr = m_pOTSLicMgr->GetOTSLicenseInfoFile();
  449. if (a_ptr == nullptr)
  450. {
  451. bRet = false;
  452. }
  453. else
  454. {
  455. a_pOTSLicenseInfo = gcnew COTSLicInfoFileClr(a_ptr);
  456. bRet = true;
  457. }
  458. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::GetOTSLicenseInfoFile ***************");
  459. return bRet;
  460. }
  461. // get license info file name
  462. String^ COTSLicMgrClr::GetLicenseInfoFilePathName()
  463. {
  464. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::GetLicenseInfoFilePathName ***************");
  465. CString a_str = COTSLicMgr::GetLicenseInfoFilePathName();
  466. String^ strOut = gcnew String(a_str);
  467. LogInfoTrace(__FILE__, __LINE__, _T("GetLicenseInfoFilePathName is %s"), a_str);
  468. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::GetLicenseInfoFilePathName ***************");
  469. return strOut;
  470. }
  471. // get software package license file name
  472. String^ COTSLicMgrClr::GetPackLicenseFilePathName(int a_nPackId)
  473. {
  474. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::GetPackLicenseFilePathName ***************");
  475. CString a_str = COTSLicMgr::GetPackLicenseFilePathName((OTS_SOFT_PACKAGE_ID)a_nPackId);
  476. String^ strOut = gcnew String(a_str);
  477. LogInfoTrace(__FILE__, __LINE__, _T("GetPackLicenseFilePathName is %s"), a_str);
  478. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::GetPackLicenseFilePathName ***************");
  479. return strOut;
  480. }
  481. // check if the given license file is valid
  482. bool COTSLicMgrClr::IsValidLicense(int a_nPackId,
  483. COTSLicenseInfoClr^ a_pOTSLicenseInfo,
  484. int% a_nLicStatus,
  485. bool a_bCheckMachinId,
  486. bool a_bTraceInfo)
  487. {
  488. if (a_pOTSLicenseInfo == nullptr)
  489. {
  490. LogErrorTrace(__FILE__, __LINE__, _T("Save:invalid pointer"));
  491. return false;
  492. }
  493. bool bRet;
  494. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::IsValidLicense ***************");
  495. int a_nLicS = 0;
  496. COTSLicenseInfoPtr a_ptr(new COTSLicenseInfo(a_pOTSLicenseInfo->GetCOTSLicenseInfo().get()));
  497. bRet = COTSLicMgr::IsValidLicense((OTS_SOFT_PACKAGE_ID)a_nPackId,
  498. a_ptr,
  499. (OTS_LICENSE_STATUS &)a_nLicS,
  500. a_bCheckMachinId,
  501. a_bTraceInfo);
  502. a_nLicStatus = a_nLicS;
  503. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::IsValidLicense ***************");
  504. return bRet;
  505. }
  506. // // load license info from file
  507. bool COTSLicMgrClr::LoadLicenseInfoFromFile(COTSLicenseInfoClr^ %a_pOTSLicenseInfo)
  508. {
  509. bool bRet;
  510. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::LoadLicenseInfoFromFile ***************");
  511. COTSLicenseInfoPtr a_ptr = COTSLicMgr::LoadLicenseInfoFromFile();
  512. if (a_ptr == nullptr)
  513. {
  514. bRet = false;
  515. }
  516. else
  517. {
  518. a_pOTSLicenseInfo = gcnew COTSLicenseInfoClr(a_ptr);
  519. m_ComputerNicName = gcnew String(a_ptr->GetComputerNickName());
  520. m_MachineId = gcnew String(a_ptr->GetMachineId());
  521. m_PackId = (int)a_ptr->GetPackId();
  522. m_LicType = (int)a_ptr->GetLicType();
  523. m_oExpireDate = gcnew DateTime(a_ptr->GetExpireDate().GetYear(), a_ptr->GetExpireDate().GetMonth(), a_ptr->GetExpireDate().GetDay());
  524. bRet = true;
  525. }
  526. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::LoadLicenseInfoFromFile ***************");
  527. return bRet;
  528. }
  529. // // create license file
  530. bool COTSLicMgrClr::CreateLicenseFile(COTSLicenseInfoClr^ a_pOTSLicenseInfo)
  531. {
  532. if (a_pOTSLicenseInfo == nullptr)
  533. {
  534. LogErrorTrace(__FILE__, __LINE__, _T("CreateLicenseFile:invalid pointer"));
  535. return false;
  536. }
  537. bool bRet;
  538. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::CreateLicenseFile ***************");
  539. COTSLicenseInfoPtr a_ptr(new COTSLicenseInfo(a_pOTSLicenseInfo->GetCOTSLicenseInfo().get()));
  540. bRet = COTSLicMgr::CreateLicenseFile(a_ptr);
  541. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::CreateLicenseFile ***************");
  542. return bRet;
  543. }
  544. // // read license info from a text file
  545. bool COTSLicMgrClr::LoadLicenseInfoFromTextFile(String^ a_strFilePathName, COTSLicenseInfoClr^ %a_pOTSLicenseInfo)
  546. {
  547. if (a_strFilePathName == nullptr)
  548. {
  549. LogErrorTrace(__FILE__, __LINE__, _T("LoadLicenseInfoFromTextFile:invalid pointer"));
  550. return false;
  551. }
  552. bool bRet;
  553. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::LoadLicenseInfoFromTextFile ***************");
  554. CString a_str = a_strFilePathName;
  555. COTSLicenseInfoPtr a_ptr = COTSLicMgr::LoadLicenseInfoFromTextFile(a_str);
  556. if (a_ptr == nullptr)
  557. {
  558. bRet = false;
  559. }
  560. else
  561. {
  562. a_pOTSLicenseInfo = gcnew COTSLicenseInfoClr(a_ptr);
  563. bRet = true;
  564. }
  565. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::LoadLicenseInfoFromTextFile ***************");
  566. return bRet;
  567. }
  568. // // get license info item
  569. bool COTSLicMgrClr::GetLicnseInfoItem(COTSLicenseInfoClr^ a_pLicenseInfo, String^ a_strTitle, String^ a_strValue)
  570. {
  571. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::GetLicnseInfoItem ***************");
  572. CString a_strTil = a_strTitle;
  573. CString a_strval = a_strValue;
  574. COTSLicenseInfoPtr a_ptr(new COTSLicenseInfo(a_pLicenseInfo->GetCOTSLicenseInfo().get()));
  575. bool bRet = COTSLicMgr::GetLicnseInfoItem(a_ptr, a_strTil, a_strval);
  576. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::GetLicnseInfoItem ***************");
  577. return bRet;
  578. }
  579. // get software pack id string
  580. String^ COTSLicMgrClr::GetSoftwarePackIdString(int a_nPackId)
  581. {
  582. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr:: GetSoftwarePackIdString ***************");
  583. CString a_str = COTSLicMgr::GetSoftwarePackIdString((OTS_SOFT_PACKAGE_ID)a_nPackId);
  584. String^ strOut = gcnew String(a_str);
  585. LogInfoTrace(__FILE__, __LINE__, _T("GetSoftwarePackIdString is %s"), a_str);
  586. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::GetSoftwarePackIdString ***************");
  587. return strOut;
  588. }
  589. // get license type string
  590. String^ COTSLicMgrClr::GetLicenseTypeIdString(int a_nLicTypeId)
  591. {
  592. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::GetLicenseTypeIdString ***************");
  593. CString a_str = COTSLicMgr::GetLicenseTypeIdString((OTS_LICENSE_TYPE)a_nLicTypeId);
  594. String^ strOut = gcnew String(a_str);
  595. LogInfoTrace(__FILE__, __LINE__, _T("GetLicenseTypeIdString is %s"), a_str);
  596. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::GetLicenseTypeIdString ***************");
  597. return strOut;
  598. }
  599. // // encrypt/decrypt license info string
  600. String^ COTSLicMgrClr::EncryptLicenseInfo(COTSLicenseInfoClr^ a_pLicenseInfo)
  601. {
  602. if (a_pLicenseInfo == nullptr)
  603. {
  604. LogErrorTrace(__FILE__, __LINE__, _T("LoadLicenseInfoFromTextFile:invalid pointer"));
  605. return nullptr;
  606. }
  607. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::EncryptLicenseInfo ***************");
  608. COTSLicenseInfoPtr a_ptr(new COTSLicenseInfo(a_pLicenseInfo->GetCOTSLicenseInfo().get()));
  609. CString a_str = COTSLicMgr::EncryptLicenseInfo(a_ptr);
  610. String^ bRet = gcnew String(a_str);
  611. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::EncryptLicenseInfo ***************");
  612. return bRet;
  613. }
  614. bool COTSLicMgrClr::DecryptLicenseInfo(String^ a_strLicense, COTSLicenseInfoClr^ % a_pOTSLicenseInfo)
  615. {
  616. if (a_strLicense == nullptr)
  617. {
  618. LogErrorTrace(__FILE__, __LINE__, _T("DecryptLicenseInfo:invalid pointer"));
  619. return false;
  620. }
  621. bool bRet;
  622. LogInfoTrace(__FILE__, __LINE__, "***************** Enter COTSLicMgrClr::DecryptLicenseInfo ***************");
  623. CString a_str = a_strLicense;
  624. COTSLicenseInfoPtr a_ptr = COTSLicMgr::DecryptLicenseInfo(a_str);
  625. if (a_ptr == nullptr)
  626. {
  627. bRet = false;
  628. }
  629. else
  630. {
  631. a_pOTSLicenseInfo = gcnew COTSLicenseInfoClr(a_ptr);
  632. bRet = true;
  633. }
  634. LogInfoTrace(__FILE__, __LINE__, "&&&&&&&&& Exit COTSLicMgrClr::DecryptLicenseInfo ***************");
  635. return bRet;
  636. }
  637. }