| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 | #include "stdafx.h"#include "ReportMgrClr.h"#include <COTSUtilityDllFunExport.h>#include "IClassifyEngine.h"#include <CGBCalculate.h>namespace OTSCLRINTERFACE {		using namespace OTSGBCalculate;	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::GetCReportMgrPtr()	{		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()->GetPropertyParamForGrid();		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 = GetCReportMgrPtr();		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 = GetCReportMgrPtr();				if (nullptr == pRProjFileMgrPtr)		{			LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: can't generate pointer."));			return false;		}		bool bRet = pRProjFileMgrPtr->ResetPropertyParams(a_bClear);				return bRet;	}		List<CSmplMsrResultFileMgrClr^>^ CReportMgrClr::GetSmplMsrResultMgrs()	{		if (m_pReportMgr == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer."));			return nullptr;		}		CReportMgrPtr pRProjFileMgrPtr = GetCReportMgrPtr();		if (nullptr == pRProjFileMgrPtr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: can't generate pointer."));			return nullptr;		}		List<CSmplMsrResultFileMgrClr^>^ listSmplMsrResultFileMgrClr = gcnew List<CSmplMsrResultFileMgrClr^>();		CSmplMsrResultFileMgrList listCSmplMsrResultFileMgr = pRProjFileMgrPtr->GetSmplMsrResultMgrs();		for (auto pCSmplMsrResultFileMgr : listCSmplMsrResultFileMgr)		{			CSmplMsrResultFileMgrClr^ CMgrClr = gcnew CSmplMsrResultFileMgrClr(pCSmplMsrResultFileMgr);			listSmplMsrResultFileMgrClr->Add(CMgrClr);		}		return listSmplMsrResultFileMgrClr;	}	bool CReportMgrClr::AddASmplMsrResultMgr(String^ a_strPathName,String^ anotherName)	{		if (m_pReportMgr == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer."));			return false;		}		CReportMgrPtr pRProjFileMgrPtr = GetCReportMgrPtr();		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,anotherName))		{			LogErrorTrace(__FILE__, __LINE__, _T("(CReportMgrClr::AddASmplMsrResultMgr) AddASmplMsrResultMgr(a_strPathName = %s) = false "), a_strPathName);			return false;		}			return true;	}	void CReportMgrClr::ClearSmplResults()	{		m_pReportMgr->get()->ClearSmplResults();	}	CSmplMsrResultFileMgrClr^ CReportMgrClr::GetASmplMsrResultMgrByPathName(String^ a_strPathName)	{		if (m_pReportMgr == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetSmplMsrResultMgrs: empty pointer."));			return nullptr;		}		CReportMgrPtr RProjFileMgrPtr = GetCReportMgrPtr();		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;	}			// working sample index	int CReportMgrClr::GetWorkingSampleIndex()	{		if (m_pReportMgr == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleIndex: invalid pointer."));			return -1;		}		CReportMgrPtr RProjFileMgrPtr = GetCReportMgrPtr();		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 = GetCReportMgrPtr();		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 pReportMgr = GetCReportMgrPtr();				CGridDatasList listGridData = pReportMgr->GridDataTransfer(thePropParam->GetPropParamPtr());		CGridDataListClr^ listGridDataClr = gcnew CGridDataListClr();		for (auto pGridData : listGridData)		{			CGridDataClr^ GridDataClr = gcnew CGridDataClr(pGridData);			listGridDataClr->Add(GridDataClr);		}		return listGridDataClr;	}	DataTable^ CReportMgrClr::GetAllGBFields(CPropParamClr^ thePropParam)	{		DataTable^ tbl = gcnew DataTable();		CReportMgrPtr pReportMgr = GetCReportMgrPtr();		auto flds = pReportMgr->GetAllGBFields(thePropParam->GetPropParamPtr());		tbl->Columns->Add("fieldX");		tbl->Columns->Add("fieldY");		tbl->Columns->Add("grade");		tbl->Columns->Add("gradeDetail");		tbl->Columns->Add("topGrade");		for (auto f : flds)		{			auto r = tbl->NewRow();			r["fieldX"] = f->GetPosition().x;			r["fieldY"] = f->GetPosition().y;					String^ tmpMStr =gcnew String(f->GetGBGradeString().c_str());			r["grade"] = tmpMStr;			tmpMStr = gcnew String(f->GetGBGradeDetail().c_str());			r["gradeDetail"] = tmpMStr;			tbl->Rows->Add(r);			int tp = (int)f->GetGBTopGrade();			r["topGrade"] = tp;		}		return tbl;	}	DataTable^ CReportMgrClr::GetAllParticlesOfOneGBField(CPropParamClr^ thePropParam,float fieldx,float fieldy)	{		DataTable^ tbl = gcnew DataTable();		CReportMgrPtr pReportMgr = GetCReportMgrPtr();		auto flds = pReportMgr->GetAllGBFields(thePropParam->GetPropParamPtr());		tbl->Columns->Add("fieldId");		tbl->Columns->Add("particleId");		tbl->Columns->Add("gbClassify");			for (auto f : flds)		{			auto fldx = f->GetPosition().x;			auto fldy = f->GetPosition().y;			if (fldx == fieldx && fldy == fieldy)			{				//------------A				for (auto p : f->listAThinParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] =gcnew System::String( p->GetParticleId());					r["gbClassify"] = "A";					tbl->Rows->Add(r);				}				for (auto p : f->listAWideParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "A";					tbl->Rows->Add(r);				}				for (auto p : f->listASuperParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "A";					tbl->Rows->Add(r);				}				//--------------B				for (auto p : f->listBThinParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "B";					tbl->Rows->Add(r);				}				for (auto p : f->listBWideParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "B";					tbl->Rows->Add(r);				}				for (auto p : f->listBSuperParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "B";					tbl->Rows->Add(r);				}				//--------------C				for (auto p : f->listCThinParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "C";					tbl->Rows->Add(r);				}				for (auto p : f->listCWideParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "C";					tbl->Rows->Add(r);				}				for (auto p : f->listCSuperParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "C";					tbl->Rows->Add(r);				}				//--------------D				for (auto p : f->listDThinParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "D";					tbl->Rows->Add(r);				}				for (auto p : f->listDWideParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "D";					tbl->Rows->Add(r);				}				for (auto p : f->listDSuperParticles)				{					auto r = tbl->NewRow();					r["fieldId"] = p->GetFieldId();					r["particleId"] = gcnew System::String(p->GetParticleId());					r["gbClassify"] = "D";					tbl->Rows->Add(r);				}							}					}		return tbl;	}	DataTable^ CReportMgrClr::GetGBDSParticles(CPropParamClr^ thePropParam)	{		DataTable^ tbl = gcnew DataTable();		CReportMgrPtr pReportMgr = GetCReportMgrPtr();		CGBCalculate GBCal(pReportMgr.get());		CALCULATE_TABLE_TYPE CalTableType = (CALCULATE_TABLE_TYPE)thePropParam->GetCalTableType();		CPropParamPtr currentProp = pReportMgr->GetPropertyParamForGrid();		std::vector<CString> listDataSource = currentProp->GetDataSourceList();		int nSelectedDataSourceIndex = currentProp->GetDataSourceId();		CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];		std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));			if (listSelectedDataSource.size() > 1) return tbl;		CSmplMsrResultFileMgrPtr rstFileMgrPrt = pReportMgr->GetASmplMsrResultMgrByFileName(listSelectedDataSource[0]);		GB_METHODE_TYPE t;		switch (CalTableType)		{		case CALCULATE_TABLE_TYPE::GB_Method1:			t = GB_METHODE_TYPE::METHODE_1;			break;		case CALCULATE_TABLE_TYPE::GB_Method2:			t = GB_METHODE_TYPE::METHODE_2;			break;		case CALCULATE_TABLE_TYPE::ASTM:			t = GB_METHODE_TYPE::ASTM;			break;		default:			t = GB_METHODE_TYPE::METHODE_1;			break;		}		CGBFieldList listGBFields = GBCal.CalGBFields(rstFileMgrPrt,t);		GBCal.CategoryGBInclutions(listGBFields, CalTableType);		CGBGradeData gradeData = CGBGradeData(listGBFields);		tbl->Columns->Add("fieldId");		tbl->Columns->Add("particleId");		tbl->Columns->Add("DSGrade");		for (auto p : gradeData.allDSParts)		{			auto r=tbl->NewRow();			r["fieldId"] = p->GetFieldId();			r["particleId"] = gcnew System::String(p->GetParticleId());			CString partDsGrade = OTSGBCalculate::GetDSGrade(p->GetFeretDiameter());			String^ pDsGr = gcnew String(partDsGrade);			r["DSGrade"] = pDsGr;			tbl->Rows->Add(r);		}		return tbl;		}				bool CReportMgrClr::IsHaveMultiDataSource()	{		if (m_pReportMgr == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("IsHaveMultiDataSource: invalid pointer."));			return false;		}		CReportMgrPtr pReportProjFileMgr = GetCReportMgrPtr();		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;	}	}
 |