长事务

长事务用于支持 AutoCAD 参照编辑功能,对于 ObjectARX 应用程序非常有用。这些类和函数为应用程序提供了一种方案,用于签出实体以进行编辑并将其签回其原始位置。此操作会将原始对象替换为已编辑的对象。有三种类型的长期交易结帐:

  • 从同一图形中的普通块
  • 从图形的外部参照 (外部参照)
  • 从不相关的临时数据库

长事务类和函数概述

主要的长事务类和函数是

  • AcDbLongTransaction.class
  • AcDbLongTransWorkSetIterator.class
  • AcApLongTransactionReactor.class
  • AcApLongTransactionManager.class
  • wblockCloneObject.class

AcDbLongTransaction Class

AcDbLongTransaction是包含跟踪长事务所需信息的类。该类AcDbLongTransactionManager负责创建AcDbLongTransaction对象并将其追加到数据库。然后它返回对象AcDbLongTransaction的AcDbObjectId。与所有其他驻留在数据库的对象一样,其销毁由数据库处理。

注意:AcDbLongTransaction对象在处于活动状态时添加到数据库中,并在事务完成后擦除。它们不存储在 DWG 或 DXF 文件中,因此不是持久性的。

AcDbLongTransWorkSetIterator Class

AcDbLongTransWorkSetIterator提供对工作集中对象的只读访问权限。在构造AcDbLongTransaction::newWorkSetIterator()期间,可以将其设置为仅包含活动工作集,或者包括添加到工作集的对象,因为它们被工作集中的对象(辅助对象)引用。它还可以处理从工作集中移除的对象,无论是通过擦除AcDbLongTransaction::removeFromWorkSet()还是被擦除。

AcApLongTransactionReactor Class

AcApLongTransactionReactor提供特定于长事务操作的通知。它旨在与也将发送的深层克隆通知结合使用,但会因正在执行的签出/签入类型而异。要将这些通知与深层克隆通知连接起来,可以通过调用AcDbLongTransaction::activeIdMap()函数来检索用于克隆的对象AcDbIdMapping。

AcApLongTransactionManager Class

AcApLongTransactionManager是用于启动和控制多头事务的管理器。每个 AutoCAD 会话只有一个acapLongTransactionManager,可通过对象返回的指针进行访问。

AcDbDatabase::wblockCloneObjects() Function

wblockCloneObjects()函数是AcDbDatase的成员。它将对象从一个数据库深度克隆到另一个数据库,并遵循硬引用,以便所有依赖对象也被克隆。当发现重复项时,符号表记录的行为由类型参数确定。下图显示了符号表类型 (enum DuplicateRecordCloning) 和深层克隆类型 (enum DeepCloneType) 之间的关系。

Relationship between DeepCloneTypes and DuplicateRecordCloning for different commands and functions

Command or API Function

DeepCloneType

DuplicateRecordCloning

命令或 API 函数

深度克隆类型

复制记录克隆

copy

kDcCopy

kDrcNotApplicable

explode

kDcExplode

kDrcNotApplicable

block

kDcBlock

kDrcNotApplicable

INSERT/BIND

kDcXrefInsert

kDrcIgnore

XRESOLVE

kDcSymTableMerge

kDrcXrefMangleName

INSERT

kDcInsert

kDrcIgnore

insert()

kDcInsertCopy

kDrcIgnore

WBLOCK

kDcWblock

kDrcNotApplicable

deepCloneObjects()

kDcObjects

kDrcNotApplicable

wblockObjects()

kDcObjects

kDrcIgnore

wblockObjects()

kDcObjects

kDrcReplace

wblockObjects()

kDcObjects

kDrcMangleName

wblockObjects()

kDcObjects

kDrcUnmangleName

长事务示例

这个简单的示例演示如何从另一个数据库中签出实体,在当前数据库中修改它们,然后将其签回原始数据库。作为长事务过程一部分的调用以粗体显示。

void
refEditApiExample()
{
AcDbObjectId transId;
AcDbDatabase* pDb;
TCHAR *fname;
struct resbuf *rb;
// Get a dwg file from the user.
//
rb = acutNewRb(RTSTR);
int stat = acedGetFileD(_T("Pick a drawing"), NULL, _T("dwg"),
0, rb);
if ((stat != RTNORM) || (rb == NULL)) {
acutPrintf(_T("\nYou must pick a drawing file.")); return; }
fname = (TCHAR*)acad_malloc((_tcslen(rb->resval.rstring) + 1) *
sizeof(TCHAR));
_tcscpy(fname, rb->resval.rstring);
acutRelRb(rb);
// Open the dwg file.
//
pDb = new AcDbDatabase(Adesk::kFalse);
if (pDb->readDwgFile(fname) != Acad::eOk) {
acutPrintf(_T("\nSorry, that drawing is probably already
open."));
return;
}
// Get the Block Table and then the model space record.
//
AcDbBlockTable *pBlockTable;
pDb->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pOtherMsBtr;
pBlockTable->getAt(ACDB_MODEL_SPACE, pOtherMsBtr,
AcDb::kForRead);
pBlockTable->close();
// Create an iterator.
//
AcDbBlockTableRecordIterator *pIter;
pOtherMsBtr->newIterator(pIter);
// Set up an object ID array.
//
AcDbObjectIdArray objIdArray;
// Iterate over the model space BTR. Look specifically
// for lines and append their object ID to the array.
//
for (pIter->start(); !pIter->done(); pIter->step()) {
AcDbEntity *pEntity;
pIter->getEntity(pEntity, AcDb::kForRead);
// Look for only AcDbLine objects and add them to the
// object ID array.
//
if (pEntity->isKindOf(AcDbLine::desc())) {
objIdArray.append(pEntity->objectId());
}
pEntity->close();
}
delete pIter;
pOtherMsBtr->close();
if (objIdArray.isEmpty()) {
acad_free(fname);
acutPrintf(_T("\nYou must pick a drawing file that contains
lines."));
return;
}
// Now get the current database and the object ID for the
// current database's model space BTR.
//
AcDbBlockTable *pThisBlockTable;
acdbHostApplicationServices()->workingDatabase()->
getSymbolTable(pThisBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pThisMsBtr;
pThisBlockTable->getAt(ACDB_MODEL_SPACE, pThisMsBtr,
AcDb::kForWrite);
pThisBlockTable->close();
AcDbObjectId id = pThisMsBtr->objectId();
pThisMsBtr->close();
// Create the long transaction. This will check all the entities
// out of the external database.
//
AcDbIdMapping errorMap;
acapLongTransactionManagerPtr()->checkOut(transId, objIdArray,
id, errorMap);
// Now modify the color of these entities.
//
int colorIndex;
acedGetInt(_T("\nEnter color number to change entities to: "),
&colorIndex);
AcDbObject* pObj;
if (acdbOpenObject(pObj, transId, AcDb::kForRead) == Acad::eOk) {
// Get a pointer to the transaction.
//
AcDbLongTransaction* pLongTrans =
AcDbLongTransaction::cast(pObj);
if (pLongTrans != NULL) {
// Get a work set iterator.
//
AcDbLongTransWorkSetIterator* pWorkSetIter;
pLongTrans->newWorkSetIterator(pWorkSetIter);
// Iterate over the entities in the work set and change
// the color.
for (pWorkSetIter->start(); !pWorkSetIter->done();
pWorkSetIter->step()) {
AcDbEntity *pEntity;
acdbOpenAcDbEntity(pEntity, pWorkSetIter->objectId(),
AcDb::kForWrite);
pEntity->setColorIndex(colorIndex);
pEntity->close();
}
delete pWorkSetIter;
}
pObj->close();
}
// Pause to see the change.
//
TCHAR str[132];
acedGetString(0, _T("\nSee the new colors. Press return to check
the object into the original database"), str);
// Check the entities back in to the original database.
//
acapLongTransactionManagerPtr()->checkIn(transId, errorMap);
// Save the original database, since we have made changes.
//
pDb->saveAs(fname);
// Close/Delete the database
//
delete pDb;
pDb = NULL;
acad_free(fname);
}

长事务 (Long Transactions)的更多相关文章

  1. ogg-01027(长事务)

    OGG-01027(长事务) 示例9-25: WARNING OGG-01027  Long Running Transaction: XID 82.4.242063, Items 0,  Extra ...

  2. mysql 监控长事务

    mysql> desc information_schema.innodb_trx -> ; +----------------------------+----------------- ...

  3. redis学习之——Redis事务(transactions)

    Redis事务:可以一次执行多个命令,本质是一组命令的集合.一个事务中的,所有命令都会序列化,按顺序地串行化执行而不会被其它命令插入,不许加塞. 常用命令:MULTI  开启事务  EXEC 提交事务 ...

  4. SQL Server 查出未提交事务(长事务)SQL

    ),value )); INSERT INTO @tab EXEC('DBCC OPENTRAN WITH TABLERESULTS'); SELECT name,CAST(value AS DATE ...

  5. ogg:Extract 进程遇长事务执行 Forcestop 引发的惨案

    http://www.linuxidc.com/Linux/2015-04/115777.htm SQL> select t.addr,t.START_DATE from v$transacti ...

  6. oracle事务和锁

    数据库事务概括 1. 说明 一组SQL,一个逻辑工作单位,执行时整体修改或者整体回退. 2.事务相关概念 1)事务的提交和回滚:COMMIT/ROLLBACK 2)事务的开始和结束 开始事务:连接到数 ...

  7. oracle事务和锁(转)

    If you use a SET TRANSACTION statement, then it must be the first statement in your transaction. How ...

  8. MySQL 事务与锁机制

    下表展示了本人安装的MariaDB(10.1.19,MySQL的分支)所支持的所有存储引擎概况,其中支持事务的有InnoDB.SEQUENCE,另外InnoDB还支持XA事务,MyISAM不支持事务. ...

  9. mysql 分库分表 ~ 柔性事务

    一 定义 TCC方案是可能是目前最火的一种柔性事务方案二 具体 内容 TCC=try(预设)-confrim(应用确认)-canal(回滚取消)三 目的 解决跨服务调用场景下的分布式事务问题,避免使用 ...

随机推荐

  1. PowerPoint 常识备忘录

    一句科普 插入超链接时所链接的目标不能是幻灯片中的某个对象.可以给文本.图形等对象添加超链接,链接的对象可以是文件或网页,不能是幻灯片中的某个对象. 名词解释 视图 视图指的是显示幻灯片的方式.视图的 ...

  2. 哔哩哔哩b站提取Cookie方法,bilibili获取Cookie教程

    大家可能对Cookie很陌生,甚至不知道是干嘛用,没关系,今天小编详细给大家讲解! Cookie是保存在客户端的纯文本文件,比如txt文件,所谓的客户端就是我们自己的本地电脑,当我们使用自己的电脑通过 ...

  3. discuz怎么转wordpress,详细实操过程

    因为原来的是Discuz! X3.4论坛,目前访问不了,但里面有两个栏目是比较有用的,一个付费栏目,另一个免费栏目,放在硬盘有点可惜,于是想把它转为wordpress的两个栏目.发现网上都没有详细过程 ...

  4. React报错之You provided a `checked` prop to a form field

    正文从这开始~ 总览 当我们在多选框上设置了checked 属性,却没有onChange 处理函数时,会产生"You provided a checked prop to a form fi ...

  5. mac M1通过homebrew安装python3报错Error: Command failed with exit 128: git

    fatal: not in a git directoryError: Command failed with exit 128: git 只需要运行 git config --global --ad ...

  6. Haproxy部署及控制台使用手册

    一.介绍 1.简介 HAProxy是一个使用C语言编写开源软件,提供高可用,负载均衡,以及基于TCP(四层)和HTTP(七层)的应用程序代理: HAProxy特别适用于那些负载特大的web站点,这些站 ...

  7. 【多服务场景化解决方案】智能家居(UrbanHome)

    ​ 介绍 UrbanHome是一款提供房屋维修服务的移动应用.如有维修需求,用户可通过该应用联系所在城市的管道工,电工,保洁,漆匠,木匠,修理工等,或是搜寻导航附近的维修商店. 通过构建UrbanHo ...

  8. Netty整合STOMP

    1.STOMP协议简介 常用的WebSocket协议定义了两种传输信息类型:文本信息和二进制信息.类型虽然被确定,但是他们的传输体是没有规定的,也就是说传输体可以自定义成什么样的数据格式都行,只要客户 ...

  9. 华南理工大学 Python第6章课后测验-1

    1.(单选)以下关于语句 a = [1,2,3,(4,5)]的说法中,正确的个数有( )个.(1)a是元组类型   (2)a是列表类型  (3)a有5个元素      (4)a有4个元素(5)a[2] ...

  10. Windows 10 索引设置

    有时候想找一下电脑上的某个文件,但是只记得关键字不记得文件名的信息了.这个时候就会尝试在Windows的窗口中搜索.不过有时候明明文件存在,但是无法找到文件.这个时候就需要检查索引设置了.https: ...