I am writing a standalone app for EPDM, and I am not able to make the CommitUpdate call work properly. Does anyone see anything obiviously wrong with my commit update that i'm doing? I have tried changing the size of the SAFEARRAY from -1,0, 1 and something really large like 10000000.
bool CEpdmVault::BatchUpdateVaultProperties( CPartNumberTable *table )
{
bool bSuccess = false;
/********************************************************************************************** STEP 1 Create the interface for the Batch Update Interface **********************************************************************************************/
EDM::IEdmBatchUpdate2Ptr poUtility = m_poVault->CreateUtility(EDM::EdmUtil_BatchUpdate);
/********************************************************************************************** STEP 2 Call the SetVar method for each variable you want to write to a file **********************************************************************************************/
std::list
// Loop through all the records in the list
while( currentRecord != table->m_partNumberTable.end() ) {
if(currentRecord->GetFieldString(PART_NUMBER) == "10903") { MoveToFolder((_bstr_t)_T
"Drawings")); EDM::IEdmFile8Ptr poFile = m_poFolder->GetFile((_bstr_t)_T(
"10903.DWG"));
// Check to see if the file exists
if( poFile != NULL) {
//IEdmVariableMgr6
EDM::IEdmVariableMgr6Ptr poVarManager = m_poVault->CreateUtility(EDM::EdmUtil_VariableMgr);
EDM::IEdmPos5Ptr poVarPos = poVarManager->GetFirstVariablePosition();
while(poVarPos->IsNull == VARIANT_FALSE) { EDM::IEdmVariable5Ptr poVar = poVarManager->GetNextVariable(poVarPos); VARIANT value; value.vt = VT_BSTR; value.bstrVal = (_bstr_t)_T(
"Test");
long fileID; poFile->get_ID( &fileID );
long variableID; poVar->get_ID(&variableID); BSTR variableName; poVar->get_Name(&variableName);
//poUtility->SetVar(fileID, variableID, &value, (_bstr_t)_T("ALL"), EDM::EdmBatch_AllConfigs);
poUtility->SetVar(fileID, poVarPos, &value, (_bstr_t)_T(
"ALL"), EDM::EdmBatch_AllConfigs); VariantClear(&value); } } } currentRecord++; }
/********************************************************************************************** STEP 3 Call the SetFolderVar method for each variable you want to write to a folder **********************************************************************************************/
/********************************************************************************************** STEP 4 Call the CommitUpdate method to actually write the variables to files and folders **********************************************************************************************/
HRESULT hr = S_OK;
ITypeLib *typelib = NULL;
hr = ::LoadTypeLibEx(_T(
"C:\\Users\\mlkress\\Documents\\Visual Studio 2008\\Projects\\EPDM2010\\Edm.tlb"), REGKIND_REGISTER, &typelib);
const GUID IEDMLib = __uuidof(EDM::__EdmLib); hr = LoadRegTypeLib(IEDMLib, 5, 14, GetUserDefaultLCID(), &typelib );
const GUID IEDMType = __uuidof(EDM::EdmBatchError2); ITypeInfo *typeInfo = NULL; typelib->GetTypeInfoOfGuid( IEDMType, &typeInfo ); IRecordInfo *recordInfo = NULL; hr = GetRecordInfoFromTypeInfo( typeInfo, &recordInfo); SAFEARRAY *errors = NULL; SAFEARRAYBOUND dimensions[1]; dimensions[0].cElements = -1; dimensions[0].lLbound = 0; EDM::IEdmCallbackPtr poCallback; errors = SafeArrayCreateEx(VT_RECORD, 1 , dimensions, recordInfo);
long errorCount = poUtility->CommitUpdate(&errors, poCallback);
return bSuccess; }