/* PasteCol 表名 源列名称 目标列名称 */ bool TCManager::PasteCol(TCPacket &inP,AnaWord &aw, TCPacket &outP) { if (aw.GetWordCount() !=4) return SetResultState(false,outP,GetLanguage(FormatIsError)); int nUserID = GetUserID(inP); if (nUserID==0) return SetResultState(false,outP,GetLanguage(UserIDIsNotFound)); string sTableName = aw.GetAt(1); string sSrcName = aw.GetAt(2); string sDstName = aw.GetAt(3); CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1)); if (pDI == NULL) return SetResultState(false,outP,GetLanguage(UserTableIsNotFound)); CField *pSrcField = pDI->FieldByName(sSrcName.c_str()); if (pSrcField == NULL) return SetResultState(false,outP,GetLanguage(FieldNameNotFind)); CFieldType ft = pSrcField->GetFieldType(); CField *pDstField = pDI->FieldByName(sDstName.c_str()); if (pDstField == NULL) { pDstField = pDI->m_DataAccess.m_pFieldList->CreateField(ft); pDstField->SetFieldName(sDstName); pDstField->SetWidth(pSrcField->GetWidth()); pDI->m_DataAccess.m_pFieldList->Add(pDstField); } pDI->m_DataAccess.First(); while (!pDI->m_DataAccess.Eof()) { pDI->m_DataAccess.Edit(); if (pSrcField->IsNull()) { pDstField->SetNull(); } else { if (ft == fDouble) pDstField->SetAsDouble(pSrcField->GetAsDouble()); else if (ft == fInt) pDstField->SetAsInteger(pSrcField->GetAsInteger()); else if (ft == fBoolean) pDstField->SetAsBool(pSrcField->GetAsBool()); else if (ft == fString) pDstField->SetAsString(pSrcField->GetAsString()); else pDstField->SetAsDateTime(&pSrcField->GetAsDateTime()); } pDI->m_DataAccess.Next(); } return SetResultState(true,outP); }
void CMarkovChain::DrawResult() { if (m_nTotalID > 1000 || m_bSaveData) { //在主界面输出聚类结果 int i; CDataAccess DataAcc; CField *pUserIdNum = DataAcc.m_pFieldList->CreateField(fInt); CField *pCluster = DataAcc.m_pFieldList->CreateField(fInt); pUserIdNum->SetFieldName("用户序号"); pCluster->SetFieldName("分类结果"); DataAcc.m_pFieldList->Add(pUserIdNum); DataAcc.m_pFieldList->Add(pCluster); for ( i=0; i<m_nTotalID; i++) { DataAcc.Append(); pUserIdNum->SetAsInteger(i+1); pCluster->SetAsInteger(m_VecClus(i) ); } BOOL bSucSave;//保存文件 CTString NoUse, FileName; if (m_bSaveData) { bSucSave = DataAcc.SaveFile(m_DataFile, &NoUse); FileName = m_DataFile; } else { CTString strOutNameTemp = "_马尔可夫链聚类结果"; CTString strOrgNameTemp = m_pDataInterface->m_DataAccess.GetFileName(); FileName = CFileReadWrite::GetSaveFileName(strOrgNameTemp, strOutNameTemp); bSucSave = DataAcc.SaveFile(FileName, &NoUse); } CRsltElementText * pWarningTextRslt = new CRsltElementText( "马尔可夫链分类结果" ); CTString strWarn; if (bSucSave) strWarn = "模型运行结束,结果已经成功输出到"+FileName+"文件里。"; else strWarn = "模型运行结束,结果已经成功输出到"+NoUse+"文件里。"; pWarningTextRslt->AddString(strWarn); m_pResult->Add( pWarningTextRslt ); return; } else { CTLTable * pTable = new CTLTable; CRsltElementTable * pETable = new CRsltElementTable("马尔可夫链分类结果",pTable);//申请一个表对象类的对象 pTable->CreateTable(2, 2); pTable->SetTitle("马尔可夫链分类情况"); pTable->SetCols(2); pTable->SetRows(m_nTotalID+1); pTable->InsertColumn(0,"用户序号"); pTable->InsertColumn(1,"分类结果"); CTString str; for(int i=0;i<m_nTotalID;i++) { str.Format("%d",i+1); pTable->InsertItem(i,str); pTable->SetItemText(i, 1, m_VecClus(i) ); } m_pResult->Add(pETable); return; } }