assignfile(f,tstring);
rewrite(f);
writeln(f,'开始时间:'+DateTimeToStr(now));
writeln(f,'SDE源数据库'+trim(form1.MServer.Text)+'——〉'
+'SDE目标数据库'+trim(form1.EServer.Text));
closefile(f);
assignfile(f,tstring);
append(f);
writeln(f,'数据转移方式:用户自定义');
writeln(f,'操作: 选定SDE源数据库内容列表中的若干个图层,将其导入SDE目标数据库');
if form1.Slist.SelCount=0 then
begin
showmessage('请先在源数据库中选择要传送的图层!');
exit;
end;
transfering:=true;
scount:=form1.Slist.SelCount;
for i:=0 to form1.Slist.Items.Count-1do
begin
if form1.Slist.Selected then
writeln(f,form1.Slist.items);
end;
writeln(f,'操作结果:');
for i:=0 to form1.Slist.Items.Count-1do
begin
if form1.Slist.Selected then
begin
name:=form1.Slist.Items;
j:=0;
while j<form1.Mlist.Items.countdo
begin
if form1.Mlist.Items[j]=name then
break;
inc(j);
end;
if j=form1.Mlist.Items.Count then
begin
form1.statusbar1.SimpleText:='SDE目标数据库中缺少'+name+'图层!'+'请先用ArcInfo新建所缺文件!';
writeln(f,'SDE目标数据库中缺少'+name+'图层!');
messagedlg('SDE目标数据库中缺少'+name+'图层!',mtwarning,[Mbok],0);
continue;
end;
if form1.modify(name)=false then
begin
form1.statusbar1.SimpleText:='目标数据库中图层'+name+'改建有误!';
writeln(f,'目标数据库中图层'+name+'改建有误!');
messagedlg('目标数据库中图层'+name+'改建有误!',mtwarning,[mbok],0);
continue;//modify用于改建图层,保持文件结构,清空内容
end;
try
form1.statusbar1.Simpletext:='正在传送图层'+name+'的数据,请等待……';
Slyr.GeoDataSet:=IMOGeoDataset(Ssdecon.FindGeoDataset(Name));
SRecSet:=Slyr.Records;
lyr.GeoDataset:=IMOGeoDataset(SDECon.FindGeoDataset(name));
RecSet:=lyr.Records;
tcount:=SRecSet.TableDesc.FieldCount;
SRecSet.MoveFirst;
while not SRecSet.eofdo
begin
RecSet.AddNew;
RecSet.Fields.Item('shape').Value:=SRecSet.Fields.Item('shape').Value;
for k:=0 to tcount-1do
begin
str:=SRecSet.TableDesc.FieldName[k];
RecSet.fields.Item(str).Value:=SRecSet.Fields.Item(str).Value;
end;
RecSet.Update;
RecSet.StopEditing;
SRecSet.MoveNext;
end;
form1.Slist.Selected:=false;
dec(scount);
form1.statusbar1.Simpletext:=name+'传送成功,目标数据库中的改建为空的'+name+'已经恢复!';
writeln(f,name+'传送成功!');
except
form1.statusbar1.Simpletext:=name+'传送失败,目标数据库中的改建为空的'+name+'没能恢复!';
writeln(f,name+'传送失败!');
messagedlg('数据传送失败!',mtwarning,[mbok],0);
continue;
end;
end;
if scount=0 then
break;
end;
writeln(f,'完成时间:'+DateTimeToStr(now));
closefile(f);
messagedlg('数据传送完毕! 请查看日志文件,以获取详细操作结。',mtinformation,[mbok],0);
[red] transfering:=false;[/red]
如果自动删除的话,总是出现异常,不知是何原因,绿色箭头指向transfering:=false;一行,异常为EInvalidoperation:canvasdo
es not allow drawing!