当前位置: 首页>>代码示例>>C++>>正文


C++ LockManager::CreateLock方法代码示例

本文整理汇总了C++中LockManager::CreateLock方法的典型用法代码示例。如果您正苦于以下问题:C++ LockManager::CreateLock方法的具体用法?C++ LockManager::CreateLock怎么用?C++ LockManager::CreateLock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LockManager的用法示例。


在下文中一共展示了LockManager::CreateLock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestLockAttachment

void TestLockDocument::TestLockAttachment()
{
	DocProviderWorker	objWorker;
	LockManager			docLock;
	CStdString			sDocID(DocumentID::GetDocProviderId() + TEST_DIRECTORY + TEST_DOC + _T(".doc"));
	DocumentID			docID(sDocID);
	CStdString			szDummyUser(_T("HighHouseShadow"));
	CStdString			sLockFileName(docID.GetLockFileName(szDummyUser, false));
	WSDocNonCom			wsDoc;

	objWorker.GetDocument(sDocID,NULL,wsDoc);
		
	HRESULT hrLock = docLock.CreateLock(sDocID, szDummyUser);

	if(FAILED(hrLock))
	{
		CStdString szErr;
		szErr.Format(_T("CreateLock returned a Failure Error code - %08x"),hrLock);
		assertMessage(false, szErr);
	}
	
	if (_taccess(sLockFileName, 0) == -1)
	{
		assertMessage(false, _T("We didn't create a lock file as HighHouseShadow"));
	}

	HRESULT hrUnlock = docLock.RemoveLock(sDocID,szDummyUser);
	
	if(FAILED(hrUnlock))
	{
		CStdString szErr;
		szErr.Format(_T("CreateLock returned a Failure Error code - %08x"),hrUnlock);
		assertMessage(false,szErr);
	}

	if (_taccess(sLockFileName, 0) != -1)
	{
		assertMessage(false, _T("We didn't remove the HighHouseShadow lock"));
	}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:40,代码来源:TestLockDocument.cpp

示例2: TestAlreadyLockedByOther

void TestLockDocument::TestAlreadyLockedByOther()
{
	DocProviderWorker	objWorker;
	CStdString			sDocID(DocumentID::GetDocProviderId() + TEST_DIRECTORY + TEST_DOC + _T(".doc"));
	DocumentID			docID(sDocID);
	CStdString			sLockFileName(docID.GetLockFileName(_T("apple"), false));
	WSDocNonCom			wsDoc;
	LockManager			docLock;
	
	objWorker.GetDocument(sDocID, 0, wsDoc);

	docLock.CreateLock(sDocID, _T("apple"));

	if (_taccess(sLockFileName, 0) == -1)
	{
		assertMessage(false, _T("Unable to create lock file"));
	}
	
	assertTest(objWorker.LockDocument(sDocID, LOCK_DOCUMENT) == E_DOCUMENT_LOCKED_BY_ANOTHER);

	assertMessage(docLock.RemoveLock(docID, _T("apple")) == S_OK, _T("Failed to unlock document at end of test"));	
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:22,代码来源:TestLockDocument.cpp

示例3: TestFailIfLockedByOther

void TestCloseDocument::TestFailIfLockedByOther()
{
	DocProviderWorker	objWorker;
	WSDocNonCom			wsDoc;
	DocumentID			docTarget(DocumentID::GenerateIdFromFilePath(sTestOriginalFileName));
	
	wsDoc.SetDescription(docTarget.GetDescription());
	wsDoc.SetLocalFile(docTarget.GetWorkingFile());
	assertTest(objWorker.ImportDocument(wsDoc, false) == S_OK);
	m_wsImportedDoc = wsDoc;

	LockManager lckMngr;
	assertTest(lckMngr.CreateLock(wsDoc.GetDocId(),_T("poptart")) == S_OK);

	assertTest(objWorker.CloseDocument(wsDoc,0) == S_OK);

	wsDoc.SetFlags(wsDoc.GetFlags()|DOCUMENT_LOCKED_BY_US);
	
	assertTest(objWorker.CloseDocument(wsDoc,0) == E_DOCUMENT_LOCKED_BY_ANOTHER);

	lckMngr.RemoveLock(wsDoc.GetDocId(),_T("poptart"));
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:22,代码来源:TestCloseDocument.cpp

示例4: TestLockNonExistentAttachment

void TestLockDocument::TestLockNonExistentAttachment()
{
	DocProviderWorker	objWorker;
	CStdString			sDocID(DocumentID::GetDocProviderId() + TEST_DIRECTORY + TEST_DOC _T(".doc") + _T("?attach.xdf"));
	CStdString			sLockFileName(TEST_DIRECTORY + TEST_DOC _T(".doc") _T("." TEST_DMS_EXT _T("\\Version 1\\attach.xdf_Bones.lock")));
	CStdString			sFile(_T("c:\\Not\\here.doc"));

	::DeleteFile(sFile.c_str());
	::DeleteFile(sLockFileName.c_str());

	WSDocNonCom			wsDoc;
	LockManager			docLock;
	const CStdString	sUsername(_T("Bones"));

	HRESULT hrLock = docLock.CreateLock(sDocID, sUsername);

	if(SUCCEEDED(hrLock))
		assertMessage(false,_T("Reported Succeeded in creating lock on non existent file"));

	if (_taccess(sLockFileName, 0) != -1 )
	{
		assertMessage(false, _T("Lock file exists for a non existent document"));
	}	
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:24,代码来源:TestLockDocument.cpp


注:本文中的LockManager::CreateLock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。