ReportMgrClr.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. #include "stdafx.h"
  2. #include "ReportMgrClr.h"
  3. #include <COTSUtilityDllFunExport.h>
  4. #include "IClassifyEngine.h"
  5. namespace OTSCLRINTERFACE {
  6. CReportMgrClr::CReportMgrClr()
  7. {
  8. m_pReportMgr = new CReportMgrPtr(new CReportMgr());
  9. }
  10. CReportMgrClr::CReportMgrClr(CReportMgrPtr pRProjFileMgr)
  11. {
  12. ASSERT(pRProjFileMgr);
  13. if (!pRProjFileMgr)
  14. {
  15. LogErrorTrace(__FILE__, __LINE__, _T("CReportMgrClr: Generate ReportProjFileMgr pointer failed."));
  16. return;
  17. }
  18. m_pReportMgr = new CReportMgrPtr(pRProjFileMgr);
  19. }
  20. CReportMgrClr::~CReportMgrClr()
  21. {
  22. if (m_pReportMgr != nullptr)
  23. {
  24. delete m_pReportMgr;
  25. m_pReportMgr = nullptr;
  26. }
  27. }
  28. CReportMgrClr::!CReportMgrClr()
  29. {
  30. if (m_pReportMgr != nullptr)
  31. {
  32. delete m_pReportMgr;
  33. m_pReportMgr = nullptr;
  34. }
  35. }
  36. CReportMgrPtr CReportMgrClr::GetCReportMgrPtr()
  37. {
  38. return *m_pReportMgr;
  39. }
  40. void CReportMgrClr::SetSwitchForSmlResultFile(int nIndex,bool ifcheck)
  41. {
  42. auto smlMgrs=m_pReportMgr->get()->GetSmplMsrResultMgrs();
  43. auto smlFile=smlMgrs[nIndex]->GetSmplMsrResultFile();
  44. smlFile->SetSwitch(ifcheck);
  45. }
  46. CPropParamClr^ CReportMgrClr::GetPropertyParamImage()
  47. {
  48. if (m_pReportMgr == nullptr)
  49. {
  50. LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamImage: current CLR point is invalid."));
  51. return nullptr;
  52. }
  53. CPropParamPtr pPropParam = m_pReportMgr->get()->GetPropertyParamImage();
  54. ASSERT(pPropParam);
  55. if (!pPropParam)
  56. {
  57. LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamImage: get empty prop param pointer."));
  58. return nullptr;
  59. }
  60. CPropParamClr^ pPropParamClr = gcnew CPropParamClr(pPropParam);
  61. return pPropParamClr;
  62. }
  63. CPropParamClr^ CReportMgrClr::GetPropertyParamTable()
  64. {
  65. if (m_pReportMgr == nullptr)
  66. {
  67. LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamGrid: current CLR point is invalid."));
  68. return nullptr;
  69. }
  70. CPropParamPtr pPropParam = m_pReportMgr->get()->GetPropertyParamForGrid();
  71. ASSERT(pPropParam);
  72. if (!pPropParam)
  73. {
  74. LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamGrid: get empty prop param pointer."));
  75. return nullptr;
  76. }
  77. CPropParamClr^ pPropParamClr = gcnew CPropParamClr(pPropParam);
  78. return pPropParamClr;
  79. }
  80. CPropParamClr^ CReportMgrClr::GetPropertyParamChart()
  81. {
  82. if (m_pReportMgr == nullptr)
  83. {
  84. LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamChart: current CLR point is invalid."));
  85. return nullptr;
  86. }
  87. CReportMgrPtr pReportProjFileMgr = GetCReportMgrPtr();
  88. ASSERT(pReportProjFileMgr);
  89. if (!pReportProjFileMgr)
  90. {
  91. LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamChart: get empty report project file manager pointer."));
  92. return nullptr;
  93. }
  94. CPropParamPtr pPropParam = pReportProjFileMgr->GetPropertyParamChart();
  95. ASSERT(pPropParam);
  96. if (!pPropParam)
  97. {
  98. LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamChart: get empty prop param pointer."));
  99. return nullptr;
  100. }
  101. CPropParamClr^ pPropParamClr = gcnew CPropParamClr(pPropParam);
  102. return pPropParamClr;
  103. }
  104. bool CReportMgrClr::ResetPropertyParams(bool a_bClear)
  105. {
  106. if (m_pReportMgr == nullptr)
  107. {
  108. LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: empty pointer."));
  109. return false;
  110. }
  111. CReportMgrPtr pRProjFileMgrPtr = GetCReportMgrPtr();
  112. if (nullptr == pRProjFileMgrPtr)
  113. {
  114. LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: can't generate pointer."));
  115. return false;
  116. }
  117. bool bRet = pRProjFileMgrPtr->ResetPropertyParams(a_bClear);
  118. return bRet;
  119. }
  120. List<CSmplMsrResultFileMgrClr^>^ CReportMgrClr::GetSmplMsrResultMgrs()
  121. {
  122. if (m_pReportMgr == nullptr)
  123. {
  124. LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer."));
  125. return nullptr;
  126. }
  127. CReportMgrPtr pRProjFileMgrPtr = GetCReportMgrPtr();
  128. if (nullptr == pRProjFileMgrPtr)
  129. {
  130. LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: can't generate pointer."));
  131. return nullptr;
  132. }
  133. List<CSmplMsrResultFileMgrClr^>^ listSmplMsrResultFileMgrClr = gcnew List<CSmplMsrResultFileMgrClr^>();
  134. CSmplMsrResultFileMgrList listCSmplMsrResultFileMgr = pRProjFileMgrPtr->GetSmplMsrResultMgrs();
  135. for (auto pCSmplMsrResultFileMgr : listCSmplMsrResultFileMgr)
  136. {
  137. CSmplMsrResultFileMgrClr^ CMgrClr = gcnew CSmplMsrResultFileMgrClr(pCSmplMsrResultFileMgr);
  138. listSmplMsrResultFileMgrClr->Add(CMgrClr);
  139. }
  140. return listSmplMsrResultFileMgrClr;
  141. }
  142. bool CReportMgrClr::AddASmplMsrResultMgr(String^ a_strPathName)
  143. {
  144. if (m_pReportMgr == nullptr)
  145. {
  146. LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer."));
  147. return false;
  148. }
  149. CReportMgrPtr pRProjFileMgrPtr = GetCReportMgrPtr();
  150. if (nullptr == pRProjFileMgrPtr)
  151. {
  152. LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: can't generate pointer."));
  153. return false;
  154. }
  155. //get the ptr object and then operate it.
  156. if (!pRProjFileMgrPtr->AddASmplMsrResultMgr(a_strPathName))
  157. {
  158. LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::AddASmplMsrResultMgr) AddASmplMsrResultMgr(a_strPathName = %s) = false "), a_strPathName);
  159. return false;
  160. }
  161. return true;
  162. }
  163. CSmplMsrResultFileMgrClr^ CReportMgrClr::GetASmplMsrResultMgrByPathName(String^ a_strPathName)
  164. {
  165. if (m_pReportMgr == nullptr)
  166. {
  167. LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer."));
  168. return nullptr;
  169. }
  170. CReportMgrPtr RProjFileMgrPtr = GetCReportMgrPtr();
  171. if (nullptr == RProjFileMgrPtr)
  172. {
  173. LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::GetASmplMsrResultMgrByPathName(String^ a_strPathName = %s)) RProjFileMgrPtr = null "), a_strPathName);
  174. return nullptr;
  175. }
  176. CSmplMsrResultFileMgrPtr pSMsrRetFileMgr = RProjFileMgrPtr->GetASmplMsrResultMgrByPathName(a_strPathName);
  177. if (nullptr == pSMsrRetFileMgr)
  178. {
  179. LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::GetASmplMsrResultMgrByPathName(String^ a_strPathName = %s)) pSMsrRetFileMgr = null "), a_strPathName);
  180. return nullptr;
  181. }
  182. CSmplMsrResultFileMgrClr^ pSMsrRetFileMgrClr = gcnew CSmplMsrResultFileMgrClr(pSMsrRetFileMgr);
  183. return pSMsrRetFileMgrClr;
  184. }
  185. // working sample index
  186. int CReportMgrClr::GetWorkingSampleIndex()
  187. {
  188. if (m_pReportMgr == nullptr)
  189. {
  190. LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleIndex: invalid pointer."));
  191. return -1;
  192. }
  193. CReportMgrPtr RProjFileMgrPtr = GetCReportMgrPtr();
  194. if (nullptr == RProjFileMgrPtr)
  195. {
  196. LogErrorTrace(__FILE__, __LINE__, _T("(GetWorkingSampleIndex: invalid pointer."));
  197. return -1;
  198. }
  199. return RProjFileMgrPtr->GetWorkingSampleIndex();
  200. }
  201. void CReportMgrClr::SetWorkingSampleIndex(int a_nWorkingSampleIndex)
  202. {
  203. if (m_pReportMgr == nullptr)
  204. {
  205. LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSampleIndex: invalid pointer."));
  206. return;
  207. }
  208. CReportMgrPtr RProjFileMgrPtr = GetCReportMgrPtr();
  209. if (nullptr == RProjFileMgrPtr)
  210. {
  211. LogErrorTrace(__FILE__, __LINE__, _T("(SetWorkingSampleIndex: invalid pointer."));
  212. return;
  213. }
  214. RProjFileMgrPtr->SetWorkingSampleIndex(a_nWorkingSampleIndex);
  215. }
  216. CGridDataListClr^ CReportMgrClr::GridDataTransfer(CPropParamClr^ thePropParam)
  217. {
  218. if (m_pReportMgr == nullptr)
  219. {
  220. LogErrorTrace(__FILE__, __LINE__, _T("GridDataTransfer: invalid pointer."));
  221. return nullptr;
  222. }
  223. CReportMgrPtr pReportMgr = GetCReportMgrPtr();
  224. ASSERT(pReportMgr);
  225. if (!pReportMgr)
  226. {
  227. LogErrorTrace(__FILE__, __LINE__, _T("GridDataTransfer: failed to create pointer."));
  228. return nullptr;
  229. }
  230. CGridDatasList listGridData = pReportMgr->GridDataTransfer(thePropParam->GetPropParamPtr());
  231. CGridDataListClr^ listGridDataClr = gcnew CGridDataListClr();
  232. for (auto pGridData : listGridData)
  233. {
  234. CGridDataClr^ GridDataClr = gcnew CGridDataClr(pGridData);
  235. listGridDataClr->Add(GridDataClr);
  236. }
  237. return listGridDataClr;
  238. }
  239. bool CReportMgrClr::IsHaveMultiDataSource()
  240. {
  241. if (m_pReportMgr == nullptr)
  242. {
  243. LogErrorTrace(__FILE__, __LINE__, _T("IsHaveMultiDataSource: invalid pointer."));
  244. return false;
  245. }
  246. CReportMgrPtr pReportProjFileMgr = GetCReportMgrPtr();
  247. ASSERT(pReportProjFileMgr);
  248. if (!pReportProjFileMgr)
  249. {
  250. LogErrorTrace(__FILE__, __LINE__, _T("IsHaveMultiDataSource: failed to create pointer."));
  251. return false;
  252. }
  253. bool bRet = pReportProjFileMgr->IsHaveMultiDataSource();
  254. return bRet;
  255. }
  256. CRptParamFileClr^ CReportMgrClr::GetRptParamFileClr()
  257. {
  258. auto paramfile = m_pReportMgr->get()->GetRptParamFilePtr();
  259. auto paramFileClr =gcnew CRptParamFileClr(paramfile);
  260. return paramFileClr;
  261. }
  262. }