Lotus Notes如何检测当前是否正在打开文档?

时间:2019-01-30 08:35:45

标签: lotus-notes lotus-domino lotusscript

作为标题。

Lotus Notes如何检测当前是否正在打开文档?

由于用户的需要,该解决方案应没有“文档锁定”。

我有1个主文档和1个子文档,但是子文档和主文档不是父母。

我使用了“ IsUIDocOpen”,但它仅在当前文档中有效。

还有其他方法吗?

1 个答案:

答案 0 :(得分:0)

如果只要求一个客户,那么无需文档锁定即可完成,但是它需要一些高级技巧:

如果将参数“ newInstance”设置为false,则可以使用NotesUIWorkspace获取任何给定的后端文档的当前打开的文档。

要获取当前打开的文档(作为uidocument,但是您当然可以使用.Document属性从中获取NotesDocument),请使用以下代码。如果未返回任何内容,则说明文档未打开:

Dim ses as New NotesSession
Dim ws as New NotesUIWorkspace

Dim docToGetFrontendFor as NotesDocument
Dim uidoc as NotesDocument

Set docToGetFrontendFor = .... 'somehow get the document you wanna have the frontend for

Call ses.SetEnvironmentvar( "PreventOpen" , "TRUE" )
Set uidoc = ws.EditDocument( False, docToGetFrontendFor, False, "", True, False )
If not uidoc is Nothing then '-document was open already
    '- do whatever with the frontend- document

为什么使用ses.SetEnvironmentvar( "PreventOpen" , "TRUE" )

EditDocument会打开文档,无论它是否已经打开。

如果文档尚未打开,则需要防止其打开。因此,您可以操纵“ QueryOpen”-文档形式的事件:

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
  Dim ses as New NotesSession
  Dim strPrevent as String
  strPrevent = ses.GetEnvironmentstring( "PreventOpen" )
  Call ses.SetEnvironmentVar( "PreventOpen" , "" )
  If strPrevent = "TRUE" Then Continue = False
End Sub

因此:如果设置了PreventOpen,则无法打开文档,因此,如果尚未打开,它将保持关闭状态。

此方法有一个很大的缺点:Notes客户端有一个“ BUG”:如果打开文档并保存,然后用我的代码再次打开,则它将在第二个窗口中打开,尽管参数为“ newInstance”除非您关闭并重新打开该文档,否则将其设置为false。

解释:

  • 创建文档
  • 保存文档
  • 关闭文档
  • 重新打开文档
  • 使用我的代码 ==>就像代码只是“重用”窗口一样

  • 创建文档

  • 保存文档
  • 使用我的代码

==>将尝试为该文档打开第二个实例,然后返回NOTHING,因为此新实例由于代码而无法打开...

相关问题