Exemple #1
0
HRESULT DMSHelper::GetDocIDDescription(const CStdStringW& sDocumentID, CStdStringW& sDescription)
{
	LOG_WS_FUNCTION_SCOPE_MSG(sDocumentID);

	BSTR bsDocID = sDocumentID.AllocSysString();
	BSTR bsDescription = NULL;
	sDescription = _T("");

	HRESULT hr = GetDocProvProxy()->GetDocIDDescription(bsDocID, &bsDescription);

	::SysFreeString(bsDocID);

	if (SUCCEEDED(hr) && bsDescription != NULL)
	{
		sDescription = bsDescription;
		SysFreeString(bsDescription);
	}
	else
	{
		CStdString sError;
		sError.Format(_T("hr = %x"), hr);
		LOG_WS_ERROR(sError.c_str());
	}
	
	return hr;
}
Exemple #2
0
HRESULT DMSHelper::TranslateODMAID(CStdStringW sODMAID, CStdStringW& sDocID)
{
	LOG_WS_FUNCTION_SCOPE_MSG(sDocID);

	BSTR bsODMAID = sODMAID.AllocSysString();
	BSTR bsDocID = NULL;
	sDocID = _T("");

	HRESULT hr = GetDocProvProxy()->TranslateODMAID(bsODMAID, &bsDocID);
	
	::SysFreeString(bsODMAID);
	
	if (SUCCEEDED(hr) && bsDocID != NULL)
	{
		sDocID = bsDocID;
		SysFreeString(bsDocID);
	}
	else
	{
		CStdString sError;
		sError.Format(_T("hr = %x"), hr);
		LOG_WS_ERROR(sError.c_str());
	}
	
	return hr;
}
Exemple #3
0
HRESULT DMSHelper::LockDocumentAsOtherUserForTesting(const CStdStringW& sDocumentID,  const CStdStringW& sUserName,  const CStdStringW& sPassword,  long lLockFlags)
{
	BSTR bsDocID = sDocumentID.AllocSysString();
	BSTR bsUserName = sUserName.AllocSysString();
	BSTR bsPassword = sPassword.AllocSysString();

	HRESULT hr = GetDocProvProxy()->LockDocumentAsOtherUserForTesting(bsDocID, bsUserName, bsPassword, lLockFlags);

	if (FAILED(hr))
	{
		CStdString sError;
		sError.Format(_T("hr = %x"), hr);
		LOG_WS_ERROR(sError.c_str());
	}

	::SysFreeString(bsDocID);
	::SysFreeString(bsUserName);
	::SysFreeString(bsPassword);

	return E_NOTIMPL;
}
Exemple #4
0
HRESULT DMSHelper::SelectDocumentEx(long lHWnd, CStdStringW sFormatString,  CStdStringW sCurrentDocumentID, CStdStringW& sDocumentID)
{
	HRESULT hr				= E_FAIL;
	BSTR bstrFormatString	= sFormatString.AllocSysString();
	BSTR bstrDocumentID		= NULL;
	BSTR bstrCurrentDocumentID = sCurrentDocumentID.AllocSysString();
	try
	{
		hr = GetDocProvProxy()->SelectDocumentEx(lHWnd, bstrFormatString,bstrCurrentDocumentID, &bstrDocumentID);
	}
	catch(_com_error& e)
	{
		LOG_WS_ERROR(e.Description());
		hr = e.Error();
	}
	catch(...)
	{
		LOG_WS_ERROR(_T("SelectDocumentEx unknown error"));
		hr = E_FAIL;
	}

	if (SUCCEEDED(hr) && bstrDocumentID != NULL)
	{
		sDocumentID = bstrDocumentID;
		SysFreeString(bstrDocumentID);
	}
	else
	{
		CStdString sError;
		sError.Format(_T("hr = %x"), hr);
		LOG_WS_ERROR(sError.c_str());
	}

	SysFreeString(bstrFormatString);
	SysFreeString(bstrCurrentDocumentID);

	return hr;

}
Exemple #5
0
HRESULT DMSHelper::DemoteToDocument(const CStdStringW& sDocumentID)
{
	BSTR bsDocID = sDocumentID.AllocSysString();

	HRESULT hr = GetDocProvProxy()->DemoteToDocument(bsDocID);

	if (FAILED(hr))
	{
		CStdString sError;
		sError.Format(_T("hr = %x"), hr);
		LOG_WS_ERROR(sError.c_str());
	}
	::SysFreeString(bsDocID);
	return hr;
}
Exemple #6
0
HRESULT DMSHelper::LockDocument(const CStdStringW& sDocumentID, long lLockFlags)
{
	LOG_WS_FUNCTION_SCOPE_MSG(sDocumentID);

	BSTR bsDocID = sDocumentID.AllocSysString();

	HRESULT hr = GetDocProvProxy()->LockDocument(bsDocID, lLockFlags);

	if (FAILED(hr))
	{
		CStdString sError;
		sError.Format(_T("hr = %x"), hr);
		LOG_WS_ERROR(sError.c_str());
	}
	::SysFreeString(bsDocID);
	return hr;
}
Exemple #7
0
//so you must call save first if you dont want to lose your changes
//returns the DocID of the newly created version
HRESULT DMSHelper::VersionDocument(CStdStringW& szDocumentID, const CStdStringW& sComment)
{
	LOG_WS_FUNCTION_SCOPE_MSG(szDocumentID);

	BSTR bstrDocumentID = szDocumentID.AllocSysString();
	HRESULT hRes =  GetDocProvProxy()->VersionDocument(&bstrDocumentID, _bstr_t(sComment));
	if(FAILED(hRes))
	{
		CStdString sErr(_T("DMSHelper::VersionDocument failed on document : "));
		sErr+= szDocumentID;
		LOG_WS_ERROR(sErr.c_str());
	}

	if(bstrDocumentID != NULL)
	{
		szDocumentID = bstrDocumentID;
		::SysFreeString(bstrDocumentID);
	}

	return hRes;
}
Exemple #8
0
HRESULT DMSHelper::GetDocumentLockStatus(CStdStringW sDocumentID, long* plLockStatus, CStdStringW& sLockedBy)
{
	LOG_WS_FUNCTION_SCOPE_MSG(sDocumentID);

	HRESULT  hr = E_FAIL;
	BSTR	bstrDocID = sDocumentID.AllocSysString();
	BSTR	bstrLockedBy = NULL;

	try
	{
		hr = GetDocProvProxy()->GetDocumentLockStatus(bstrDocID, plLockStatus, &bstrLockedBy);
	}
	catch(_com_error& e)
	{
		LOG_WS_ERROR(e.Description());
		hr = e.Error();
	}
	catch(...)
	{
		LOG_WS_ERROR(_T("GetDocumentLockStatus unknown error"));
		hr = E_FAIL;
	}

	if (SUCCEEDED(hr) && bstrLockedBy != NULL)
	{
		sLockedBy = bstrLockedBy;
		SysFreeString(bstrLockedBy);
	}
	else
	{
		CStdString sError;
		sError.Format(_T("hr = %x"), hr);
		LOG_WS_ERROR(sError.c_str());
	}

	SysFreeString(bstrDocID);

	return hr;
}
Exemple #9
0
HRESULT DMSHelper::PromoteToSynergy(CStdStringW& sDocumentID, CStdStringW& sErrorReason)
{
	CStdString sErr;
	CStdString sErrReason(_T(""));
	BSTR bsDocID = sDocumentID.AllocSysString();

	HRESULT hr = GetDocProvProxy()->PromoteToSynergy(&bsDocID);
	
	if (SUCCEEDED(hr) && bsDocID != NULL)
	{
		sDocumentID = bsDocID;
		::SysFreeString(bsDocID);
	}
	else
	{
		GetDocProvProxy()->GetErrorDescription(hr,sErrReason);

		sErr.Format(_T("GetSynergyRelatedDocuments failed, error code %08x, %s"),hr,sErrReason.c_str());
		LOG_WS_ERROR(sErr.c_str());
	}

	return hr;
}