Lotus Notes中如何检测是否一个文件正在打开?

问题描述 投票:1回答:1

如题。

Lotus Notes中如何检测是否一个文件正在打开?

没有,因为用户的用户需求“文件锁定”出现在解决方案。

我有1个maindoc和1个subdoc的,但subdoc的和maindoc不是的父母。

我用的是“IsUIDocOpen”,但它只是在currentdocument工作。

是否有任何其他方式做到这一点?

lotus-notes lotus-domino lotusscript
1个回答
0
投票

如果你问只是一个客户端,那么这是没有文件锁定可行的,但它需要一些高级技巧:

您可以使用NotesUIWorkspace得到一个当前打开的文档对于任何给定的后端文件,如果你设置参数“的newInstance”为假。

为了得到当前打开的文档(如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除非您关闭并重新打开该文档。

解释:

  • 创建文档
  • 保存文件
  • 关闭文件
  • 重新打开文档
  • 用我的代码==>作品作为代码只是“重用”窗口
  • 创建文档
  • 保存文件
  • 使用我的代码

==>将尝试打开第二个实例文档,然后返回任何结果,因为这新的实例,因为代码不开...

© www.soinside.com 2019 - 2024. All rights reserved.