#include "stdafx.h" #include "ReportMgrClr.h" #include #include "IClassifyEngine.h" namespace OTSCLRINTERFACE { CReportMgrClr::CReportMgrClr() { m_pReportMgr = new CReportMgrPtr(new CReportMgr()); } CReportMgrClr::CReportMgrClr(CReportMgrPtr pRProjFileMgr) { ASSERT(pRProjFileMgr); if (!pRProjFileMgr) { LogErrorTrace(__FILE__, __LINE__, _T("CReportMgrClr: Generate ReportProjFileMgr pointer failed.")); return; } m_pReportMgr = new CReportMgrPtr(pRProjFileMgr); } CReportMgrClr::~CReportMgrClr() { if (m_pReportMgr != nullptr) { delete m_pReportMgr; m_pReportMgr = nullptr; } } CReportMgrClr::!CReportMgrClr() { if (m_pReportMgr != nullptr) { delete m_pReportMgr; m_pReportMgr = nullptr; } } CReportMgrPtr CReportMgrClr::GetCReportProjFileMgrPtr() { return *m_pReportMgr; } void CReportMgrClr::SetSwitchForSmlResultFile(int nIndex,bool ifcheck) { auto smlMgrs=m_pReportMgr->get()->GetSmplMsrResultMgrs(); auto smlFile=smlMgrs[nIndex]->GetSmplMsrResultFile(); smlFile->SetSwitch(ifcheck); } CPropParamClr^ CReportMgrClr::GetPropertyParamImage() { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamImage: current CLR point is invalid.")); return nullptr; } CPropParamPtr pPropParam = m_pReportMgr->get()->GetPropertyParamImage(); ASSERT(pPropParam); if (!pPropParam) { LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamImage: get empty prop param pointer.")); return nullptr; } CPropParamClr^ pPropParamClr = gcnew CPropParamClr(pPropParam); return pPropParamClr; } CPropParamClr^ CReportMgrClr::GetPropertyParamTable() { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamGrid: current CLR point is invalid.")); return nullptr; } CPropParamPtr pPropParam = m_pReportMgr->get()->GetPropertyParamGrid(); ASSERT(pPropParam); if (!pPropParam) { LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamGrid: get empty prop param pointer.")); return nullptr; } CPropParamClr^ pPropParamClr = gcnew CPropParamClr(pPropParam); return pPropParamClr; } CPropParamClr^ CReportMgrClr::GetPropertyParamChart() { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamChart: current CLR point is invalid.")); return nullptr; } CReportMgrPtr pReportProjFileMgr = GetCReportProjFileMgrPtr(); ASSERT(pReportProjFileMgr); if (!pReportProjFileMgr) { LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamChart: get empty report project file manager pointer.")); return nullptr; } CPropParamPtr pPropParam = pReportProjFileMgr->GetPropertyParamChart(); ASSERT(pPropParam); if (!pPropParam) { LogErrorTrace(__FILE__, __LINE__, _T("GetPropertyParamChart: get empty prop param pointer.")); return nullptr; } CPropParamClr^ pPropParamClr = gcnew CPropParamClr(pPropParam); return pPropParamClr; } bool CReportMgrClr::ResetPropertyParams(bool a_bClear) { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: empty pointer.")); return false; } CReportMgrPtr pRProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == pRProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: can't generate pointer.")); return false; } bool bRet = pRProjFileMgrPtr->ResetPropertyParams(a_bClear); return bRet; } List^ CReportMgrClr::GetSmplMsrResultMgrs() { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer.")); return nullptr; } CReportMgrPtr pRProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == pRProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: can't generate pointer.")); return nullptr; } List^ listSmplMsrResultFileMgrClr = gcnew List(); CSmplMsrResultFileMgrList listCSmplMsrResultFileMgr = pRProjFileMgrPtr->GetSmplMsrResultMgrs(); for (auto pCSmplMsrResultFileMgr : listCSmplMsrResultFileMgr) { CSmplMsrResultFileMgrClr^ CMgrClr = gcnew CSmplMsrResultFileMgrClr(pCSmplMsrResultFileMgr); listSmplMsrResultFileMgrClr->Add(CMgrClr); } return listSmplMsrResultFileMgrClr; } bool CReportMgrClr::AddASmplMsrResultMgr(String^ a_strPathName) { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer.")); return false; } CReportMgrPtr pRProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == pRProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: can't generate pointer.")); return false; } //get the ptr object and then operate it. if (!pRProjFileMgrPtr->AddASmplMsrResultMgr(a_strPathName)) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::AddASmplMsrResultMgr) AddASmplMsrResultMgr(a_strPathName = %s) = false "), a_strPathName); return false; } return true; } CSmplMsrResultFileMgrClr^ CReportMgrClr::GetASmplMsrResultMgrById(int a_nIndex) { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer.")); return nullptr; } CReportMgrPtr RProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == RProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::GetASmplMsrResultMgrById(int a_nIndex = %d)) RProjFileMgrPtr = null "), a_nIndex); return nullptr; } CSmplMsrResultFileMgrPtr pSMsrRetFileMgr = RProjFileMgrPtr->GetASmplMsrResultMgrById(a_nIndex); CSmplMsrResultFileMgrClr^ pSMsrRetFileMgrClr = gcnew CSmplMsrResultFileMgrClr(pSMsrRetFileMgr); return pSMsrRetFileMgrClr; } CSmplMsrResultFileMgrClr^ CReportMgrClr::GetASmplMsrResultMgrByPathName(String^ a_strPathName) { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer.")); return nullptr; } CReportMgrPtr RProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == RProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::GetASmplMsrResultMgrByPathName(String^ a_strPathName = %s)) RProjFileMgrPtr = null "), a_strPathName); return nullptr; } CSmplMsrResultFileMgrPtr pSMsrRetFileMgr = RProjFileMgrPtr->GetASmplMsrResultMgrByPathName(a_strPathName); if (nullptr == pSMsrRetFileMgr) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::GetASmplMsrResultMgrByPathName(String^ a_strPathName = %s)) pSMsrRetFileMgr = null "), a_strPathName); return nullptr; } CSmplMsrResultFileMgrClr^ pSMsrRetFileMgrClr = gcnew CSmplMsrResultFileMgrClr(pSMsrRetFileMgr); return pSMsrRetFileMgrClr; } bool CReportMgrClr::DeleteASmplMsrResultMgrById(int a_nIndex) { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer.")); return false; } CReportMgrPtr RProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == RProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::DeleteASmplMsrResultMgrById(int a_nIndex )) RProjFileMgrPtr = null ")); return false; } if (!RProjFileMgrPtr->DeleteASmplMsrResultMgrById(a_nIndex)) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::DeleteASmplMsrResultMgrById(a_nIndex)) DeleteASmplMsrResultMgrById(a_nIndex = %d) "), a_nIndex); return false; } return true; } bool CReportMgrClr::DeleteASmplMsrResultMgrByPathName(String^ a_strPathName) { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer.")); return false; } CReportMgrPtr RProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == RProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::DeleteASmplMsrResultMgrByPathName(String^ a_strPathName)) RProjFileMgrPtr = null ")); return false; } if (!RProjFileMgrPtr->DeleteASmplMsrResultMgrByPathName(a_strPathName)) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::DeleteASmplMsrResultMgrByPathName(String^ a_strPathName)) DeleteASmplMsrResultMgrByPathName(a_strPathName = %s) = false "), a_strPathName); return false; } return true; } CSmplMsrResultFileMgrClr^ CReportMgrClr::GetWorkingSmplMsrReslMgr() { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSmplMsrReslMgr: empty pointer.")); return nullptr; } CReportMgrPtr RProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == RProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::GetWorkingSmplMsrReslMgr(String^ a_strPathName)) RProjFileMgrPtr = null ")); return nullptr; } CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = RProjFileMgrPtr->GetWorkingSmplMsrReslMgr(); ASSERT(pSmplMsrResultFileMgr); if (!pSmplMsrResultFileMgr) { LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::GetWorkingSmplMsrReslMgr(String^ a_strPathName)) RProjFileMgrPtr = null ")); return nullptr; } CSmplMsrResultFileMgrClr^ pSMRFMgrClr = gcnew CSmplMsrResultFileMgrClr(pSmplMsrResultFileMgr); return pSMRFMgrClr; } String^ CReportMgrClr::GetWorkingSampleName() { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: empty pointer.")); return nullptr; } CReportMgrPtr RProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == RProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid pointer. ")); return nullptr; } CString strName = RProjFileMgrPtr->GetWorkingSampleName(); String^ strNameClr = gcnew String(strName); return strNameClr; } bool CReportMgrClr::SetWorkingSmplMsrReslMgr(CSmplMsrResultFileMgrClr^ a_pSmpMsr) { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: empty pointer.")); return false; } ASSERT(a_pSmpMsr); if (!a_pSmpMsr) { LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: invalid sample measure result file manger clr pointer.")); return false; } CReportMgrPtr RProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == RProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: can't get report project file manager pointer.")); return false; } CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = a_pSmpMsr->GetCSmplMsrResultFileMgrPtr(); ASSERT(pSmplMsrResultFileMgr); if (!pSmplMsrResultFileMgr) { LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: invalid sample measure result file manager pointer.")); return false; } bool bRet = RProjFileMgrPtr->SetWorkingSmplMsrReslMgr(pSmplMsrResultFileMgr); return bRet; } // working sample index int CReportMgrClr::GetWorkingSampleIndex() { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleIndex: invalid pointer.")); return -1; } CReportMgrPtr RProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == RProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("(GetWorkingSampleIndex: invalid pointer.")); return -1; } return RProjFileMgrPtr->GetWorkingSampleIndex(); } void CReportMgrClr::SetWorkingSampleIndex(int a_nWorkingSampleIndex) { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSampleIndex: invalid pointer.")); return; } CReportMgrPtr RProjFileMgrPtr = GetCReportProjFileMgrPtr(); if (nullptr == RProjFileMgrPtr) { LogErrorTrace(__FILE__, __LINE__, _T("(SetWorkingSampleIndex: invalid pointer.")); return; } RProjFileMgrPtr->SetWorkingSampleIndex(a_nWorkingSampleIndex); } CGridDataListClr^ CReportMgrClr::GridDataTransfer(CPropParamClr^ thePropParam) { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GridDataTransfer: invalid pointer.")); return nullptr; } CReportMgrPtr pReportProjFileMgr = GetCReportProjFileMgrPtr(); ASSERT(pReportProjFileMgr); if (!pReportProjFileMgr) { LogErrorTrace(__FILE__, __LINE__, _T("GridDataTransfer: failed to create pointer.")); return nullptr; } CGridDatasList listGridData = pReportProjFileMgr->GridDataTransfer(thePropParam->GetPropParamPtr()); CGridDataListClr^ listGridDataClr = gcnew CGridDataListClr(); for (auto pGridData : listGridData) { CGridDataClr^ GridDataClr = gcnew CGridDataClr(pGridData); listGridDataClr->Add(GridDataClr); } return listGridDataClr; } bool CReportMgrClr::IsHaveMultiDataSource() { if (m_pReportMgr == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("IsHaveMultiDataSource: invalid pointer.")); return false; } CReportMgrPtr pReportProjFileMgr = GetCReportProjFileMgrPtr(); ASSERT(pReportProjFileMgr); if (!pReportProjFileMgr) { LogErrorTrace(__FILE__, __LINE__, _T("IsHaveMultiDataSource: failed to create pointer.")); return false; } bool bRet = pReportProjFileMgr->IsHaveMultiDataSource(); return bRet; } CRptParamFileClr^ CReportMgrClr::GetRptParamFileClr() { auto paramfile = m_pReportMgr->get()->GetRptParamFilePtr(); auto paramFileClr =gcnew CRptParamFileClr(paramfile); return paramFileClr; } }