void CFoxBase::ExceptionInfo(_com_error &e) { if(e.Description().length()>0) ExceptionInfo(e.Description()); else ExceptionInfo(e.ErrorMessage()); }
static void finishCurrentOp( OperationContext* txn, Client* client, CurOp* currentOp, WriteErrorDetail* opError ) { currentOp->done(); int executionTime = currentOp->debug().executionTime = currentOp->totalTimeMillis(); currentOp->debug().recordStats(); if ( opError ) { currentOp->debug().exceptionInfo = ExceptionInfo( opError->getErrMessage(), opError->getErrCode() ); LOG(3) << " Caught Assertion in " << opToString( currentOp->getOp() ) << ", continuing " << causedBy( opError->getErrMessage() ) << endl; } bool logAll = logger::globalLogDomain()->shouldLog( logger::LogSeverity::Debug( 1 ) ); bool logSlow = executionTime > ( serverGlobalParams.slowMS + currentOp->getExpectedLatencyMs() ); if ( logAll || logSlow ) { LOG(0) << currentOp->debug().report( *currentOp ) << endl; } if ( currentOp->shouldDBProfile( executionTime ) ) { profile( txn, *client, currentOp->getOp(), *currentOp ); } }
void ExceptionInfoDialog::OnInitDialog(wxInitDialogEvent &e) { wxDialog::OnInitDialog(e); wxSizer* sizer = ExceptionInfo(this, true, true); // 获取各控件的引用 mListBox = wxDynamicCast(this->FindWindow(ID_EXCEPTION_LISTBOX),wxListBox); assert (mListBox); mListBox->InsertItems(mDescArrayString,0); }
//////////////////////////////////////////////////// // //从表的第一条记录开始寻找指定的逻辑关系 // //IRecordset[in] 记录集智能指针 //FieldsName[in] 字段名 //Relations[in] 逻辑关系,等于、不等于…… //Value[in] 输入与FieldsName比较的值 // //函数成功返回TRUE,否则返回FALSE //如果需比较的字段与关系不匹配会抛出_com_error异常 //指针指向找到的记录上 // BOOL CFoxBase::LocateFor(_RecordsetPtr IRecordset, _variant_t FieldsName, int Relations, _variant_t Value) { _variant_t tempvalue; CString tempstr; if(IRecordset==NULL || Value.vt==VT_NULL) return FALSE; try { IRecordset->MoveFirst(); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } return LocateForCurrent(IRecordset,FieldsName,Relations,Value); }
BOOL CFoxBase::CopyTo(LPCTSTR pSourceTable, LPCTSTR pDestinationTable) { CString SourceTable,DestinationTable; CString SQL; _RecordsetPtr IRecordS,IRecordD; FieldsPtr IFields; FieldPtr IField; if(pSourceTable==NULL || pDestinationTable==NULL) { ExceptionInfo(_T("Source table or destination table cann't be empty")); return FALSE; } SourceTable=pSourceTable; DestinationTable=pDestinationTable; SourceTable.TrimLeft(); SourceTable.TrimRight(); DestinationTable.TrimLeft(); DestinationTable.TrimRight(); if(SourceTable.IsEmpty() || DestinationTable.IsEmpty()) { ExceptionInfo(_T("Source table or destination table cann't be empty")); return FALSE; } try { IRecordS.CreateInstance(__uuidof(Recordset)); IRecordS->Open(_variant_t(pSourceTable),_variant_t((IDispatch*)GetConnect()), adOpenKeyset,adLockOptimistic,adCmdTable); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } SQL=CreateTableSQL(IRecordS,pDestinationTable); if(SQL.IsEmpty()) { return FALSE; } try { GetConnect()->Execute(_bstr_t(SQL),NULL,adExecuteNoRecords); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } try { IRecordD.CreateInstance(__uuidof(Recordset)); IRecordD->Open(_variant_t(pDestinationTable),_variant_t((IDispatch*)GetConnect()), adOpenKeyset,adLockOptimistic,adCmdTable); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } if(!CopyData(IRecordS,IRecordD)) { return FALSE; } return TRUE; }
BOOL CFoxBase::CopyData(_RecordsetPtr &IRecordS, _RecordsetPtr &IRecordD) { _variant_t TempValue; short Item; FieldsPtr IFields; FieldPtr IField; if(IRecordS==NULL || IRecordD==NULL) { ExceptionInfo(_T("Source Recordset or destination Recordset cann't be empty")); return FALSE; } if(IRecordS->adoEOF && IRecordS->BOF) { return TRUE; } if(!IRecordD->adoEOF || !IRecordD->BOF) { try { IRecordD->MoveLast(); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } } try { IRecordS->MoveFirst(); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } try { while(!IRecordS->adoEOF) { IRecordS->get_Fields(&IFields); IRecordD->AddNew(); for(Item=0;Item<IFields->GetCount();Item++) { IFields->get_Item(_variant_t(Item),&IField); TempValue=IRecordS->GetCollect(_variant_t(IField->GetName())); IRecordD->PutCollect(_variant_t(IField->GetName()),TempValue); IField.Release(); } IRecordD->Update(); IFields.Release(); IRecordS->MoveNext(); } } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } return TRUE; }
CString CFoxBase::CreateTableSQL(_RecordsetPtr &IRecord,LPCTSTR pTableName) { short Item; CString CreateSQL; CString DefList; FieldsPtr IFields; FieldPtr IField; CreateSQL=_T(""); if(IRecord==NULL) { ExceptionInfo(_T("Recordset interface cann't be NULL")); return CreateSQL; } if(pTableName==NULL) { ExceptionInfo(_T("Table name cann't be NULL")); return CreateSQL; } IRecord->get_Fields(&IFields); DefList=_T(""); for(Item=0;Item<IFields->GetCount();Item++) { IFields->get_Item(_variant_t(Item),&IField); DefList+=IField->GetName(); DefList+=_T(" "); switch(IField->GetType()) { case adVarWChar: { CString Temp; Temp.Format(_T("varchar(%d)"),IField->GetDefinedSize()); DefList+=Temp; break; } case adLongVarWChar: DefList+=_T("text"); break; case adVarBinary: { CString Temp; Temp.Format(_T("varbinary(%d)"),IField->GetDefinedSize()); DefList+=Temp; break; } // case adNumeric: // case adGUID: // case adLongVarBinary: // { // ExceptionInfo(_T("不支持LongVarBinary")); // return CreateSQL; // } // break; case adInteger: DefList+=_T("int"); break; case adUnsignedTinyInt: case adSmallInt: DefList+=_T("smallint"); break; case adSingle: case adDouble: DefList+=_T("float"); break; case adDBTimeStamp: case adDate: DefList+=_T("date"); break; // case adBoolean: // break; default: { ExceptionInfo(_T("不支持此类型")); return CreateSQL; } } if(Item < IFields->GetCount()-1) { DefList+=_T(","); } IField.Release(); } CreateSQL.Format(_T("CREATE TABLE %s(%s)"),pTableName,DefList); return CreateSQL; }
///////////////////////////////////////////////////// // // 在记录集的当前位置插入一条新记录 // // IRecord[in] 记录集智能指针 // // 函数成功返回TRUE,否则返回FALSE // 如果有异常将调用ExceptionInfo函数 // // 函数成功后记录集将指向新插入的空记录 // BOOL CFoxBase::InsertNew(_RecordsetPtr &IRecord,int after) { int pos; CMap<short,short&,_variant_t,_variant_t&> FieldMap; CMap<short,short&,_variant_t,_variant_t&> newFieldMap; //将新增加的记录的值记下来 _variant_t TempValue; short Item; FieldsPtr IFields; FieldPtr IField; int pos1; int nCount; //字段个数. if(IRecord==NULL) { ExceptionInfo(_T("Recordset cann't be empty")); return FALSE; } //如果记录集为空将插入一条新记录 if(IRecord->adoEOF && IRecord->BOF) { try { IRecord->AddNew(); IRecord->Update(); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } return TRUE; } else if(IRecord->adoEOF) { IRecord->AddNew(); IRecord->Update(); IRecord->MoveLast(); return true; } for(pos=0; !IRecord->adoEOF ;pos++) { try { IRecord->MoveNext(); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } } // // 查如一条新记录,并将刚开始所指的以后的记录向后移 // try { IRecord->AddNew(); IRecord->Update(); IRecord->MoveLast(); //将新增加的记录的值记下来. IFields = IRecord->GetFields(); nCount = IFields->GetCount(); //字段个数 for (Item = 0; Item < nCount; Item++) { newFieldMap[Item] = IRecord->GetCollect(_variant_t(Item)); } IFields.Release(); // IRecord->MovePrevious(); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } if(after==1) pos--; //使pos再减一,变成在指针的当前位置上加入一条新记录,insert blank pos1=pos; while(pos>0) { try { for(Item=0;Item<nCount;Item++) { TempValue=IRecord->GetCollect(_variant_t(Item)); FieldMap[Item]=TempValue; } IRecord->MoveNext(); for(Item=0;Item<nCount;Item++) { IRecord->PutCollect(_variant_t(Item),FieldMap[Item]); } IRecord->Update(); IRecord->MovePrevious(); pos--; if(pos>0) IRecord->MovePrevious(); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } } // 使最开始所指的记录内容为空 if(pos1==0 && after==1) {IRecord->MoveNext();} else { try { TempValue.Clear(); for(Item=0;Item<nCount;Item++) { IRecord->PutCollect(_variant_t(Item),newFieldMap[Item]); } IRecord->Update(); } catch(_com_error &e) { ExceptionInfo(e); return FALSE; } } return TRUE; }