本文整理汇总了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"));
}
}
示例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"));
}
示例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"));
}
示例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"));
}
}