通过Lotusscript代码从损坏的数据库中抽取数据

问题:

在某些少见的情况下,一个Notes/Domino数据库可能因为损坏而无法正常打开。但当你用
notespeek或者其他工具检查这个数据库的时候,发现其中的文档看起来还是完好无损的。然而你
使用"fixup", "updall -r" 或者"compact" 却无法修复此问题。有其他方法可以恢复这些文档并
且可以访问这些文档吗?

回答:

数据库损坏后,根据损坏的程度以及损坏的类型,有可能可以通过lotusscript代理把那些
文档从损坏的数据库拷贝到另一个新的数据库。如果这损坏的部分只是影响这个数据库的设计,
那么这些文档是可以恢复的。

举例来说,如果一个用户的邮件文件不能被Notes客户端打开,你就可以根据他所使用的模版来创
建一个新的邮件数据库。接着写一个代理来把这个损坏的数据库中的文档拷贝到这个新的邮件数
据库中。这个代理代码附在后面。
注意:这个脚本代码只是一个处理数据库损坏的方法,在运行之前,你应当尝试其他的方法(见后)


代理代码示例:

1. 创建一个手工执行的代理在任一个数据库。

2. 使用下面的样例代码,并执行,

Sub Initialize
Dim s As New notessession
'Change "" in the next line to the appropriate server name if the database is not local.
Dim srcdb As New notesdatabase("","badfile.nsf") 'replace "badfile.nsf" with the name of the corrupted db
Dim newdb As New notesdatabase("","newfile.nsf") 'replace "newfile.nsf" with the name of the new db
Dim coll As notesdocumentcollection
Dim doc As notesdocument
Set coll=srcdb.alldocuments
For i = 1 To coll.count
Set doc=coll.getnthdocument(i)
Call doc.copytodatabase(newdb)
Next
End Sub

其他可能的解决方法:

-- 尝试通过log.nsf, 来定位那些损坏的某个文档或者设计元素,然后拷贝并粘贴这些文档或元
素到这个数据库中。
-- 为这个数据库创建一个副本或着新拷贝。
-- 运行"fixup", "updall -r", 或者"compact" 。
-- 如果这个数据库有全文索引,可以尝试删除并重新创建全文索引。

posted @ 2011-09-06 00:50  hannover  阅读(404)  评论(0编辑  收藏  举报