Writeln(F,'---------------------------------------------------------------------------------');
For I := 0 To Stringlist.Count - 1 Do
Writeln(F,StringList.Strings[i]);
//把列表中内容输出到文本文件中。
Writeln(F);
CloseFile(F);//关闭文件。
BinderParentHandle := 1;
while(BinderParentHandle <> 0) Do
Begin
BinderHandle := ClientApi_GetDocumentOwnerBinder(EntityHandle);
//得到当前实体所在的上一级容器句柄。
BinderEntity := TEntity.Create(BinderHandle);
//根据得到的上一级容器建立一个实体对象BinderEntity。
BinderEntity.QueryDatabase(eGetState);//同步数据。
BinderParentHandle := BinderEntity.ParentHandle;
//得到实体对象的父实体句柄。
EntityHandle := BinderParentHandle;//父实体句柄赋予EntityHandle。
End;
//遍历整个DDB包,直到最上一级实体,其主要目的是为了对整个DDB包进行刷新。
//遍历完成后,BinderParentHandle和EntityHandle是0,因为已到上一级了,此时BinderHandle
//中存放在是最高层实体即DDB的句柄。
NewTextDochandle := WaitForCommit(BinderHandle,AbsoluteString);//刷新实体直到获得实体句柄。
//把DDB句柄和要刷新的文档作为参数。
ClientAPI_OpenDocumentEntity(NewTextDochandle,False);
//在窗体中打开新建的实体文档。
DDBItem.Free;
BinderEntity.Free;
End;
{................................................................................}
//主程序,在容器中查找文档实体,查找到后把其完整抽象地址加到一个列表中,然后调用
//一个WriteToATextDocument过程把列表中内容输出到一个文本文件。
Procedure FindEntitiesInDDBAmend;
Var
EntityHandle : TObjectHandle;//当前窗体中实体句柄。
Iterator : TObjectHandle;//迭代程序对面。
BinderHandle : TObjectHandle;//容器句柄。
DocumentEntity : TDocumentEntity;//文本实体。
Stringlist : TStringList;//子图表列表。
Begin
EntityHandle :=
ClientApi_FindEntityByDataHandle(MessageRouter_GetState_CurrentEditorWindow);
//MessageRouter_GetState_CurrentEditorWindow函数返回当前在项层的文档的窗体句柄。当前在项层在文档的窗体句柄。
//ClientApi_FindEntityByDataHandle函数使用一个编辑器窗体句柄来返回查找返回一个实体的句柄。
If EntityHandle = 0 Then Exit; //如果无实体对象则退出。
BinderHandle := ClientApi_GetDocumentOwnerBinder(EntityHandle);
//得到当前实体对象的容器对象句柄。
Iterator := ClientApi_CreateIterator(Binderhandle,[eDocument],eAll);
//创建一个迭代程序对象,在容器Binderhandle中查找文档实体,eDocument表示文档对象。
EntityHandle := ClientApi_GetFirstEntity(Iterator);//查找第一个文档实体。
StringList := TStringList.Create;//建立列表实体对象。
DocumentEntity := TDocumentEntity.Create(0);//建立文档实体对象。
While EntityHandle <> 0 Do//查找文件对象循环。
Begin
DocumentEntity.Handle := EntityHandle;//查找到的文件句柄赋予新建的文档实体句柄。
DocumentEntity.QueryDatabase(eGetState);//客户端内部服务器数据同步外部服务器数据。
StringList.Add('一个实体的抽象地址(Absolute address of an entity) = ' + DocumentEntity.FullAddress);
//把文档的完整抽象地址加到列表中。
EntityHandle := ClientApi_GetNextEntity(Iterator);//查找下一个对象。
End;
ClientApi_DestroyIterator(Iterator);//销毁迭代程序对象。
DocumentEntity.Free;//释放文档实体对象。
WriteToATextDocument(Binderhandle,StringList);//把容器中存在的所有文档抽象地址列表中内容输出到一个文本文件。
StringList.Free;//释放列表对象。
End;
{....................................................................................}
Procedure Command_IterateAndShowAmend(Window : TServerWindow; Parameters : PChar);
Begin
FindEntitiesInDDBAmend;
End;