【问题标题】:Getting documents of last 25 minutes with formula and lotusscript使用公式和莲花脚本获取最近 25 分钟的文档
【发布时间】:2017-01-27 10:03:58
【问题描述】:

在 lotus 中,我有一个订单文件的视图。 我正在构建一个代理来搜索在过去 25 分钟内修改的所有订单。

为此,我做了如下代码:

strFormule = "Form=""Order"" & @Modified >=  @Adjust(@Today;0;0;0;0;-25;0) & Deleted !=""J"""

Set ndcOrder = currentDB.Search( strFormule, Nothing, 0 )
If ndcOrder.Count <> 0 Then
Set doc = ndcOrder.GetFirstDocument
While Not doc Is Nothing

所以如果是11.00那么它需要接受今天从10.35修改的订单

但在调试器中,我也收到了 2 小时前修改的订单。

这怎么可能?

【问题讨论】:

    标签: formula lotus-notes lotus-domino lotusscript


    【解决方案1】:

    我认为这可能是因为您使用的 @today 没有时间元素。试试@Now 吗?

    【讨论】:

    • 所以如果我想要前一天的订单,那么我今天使用,如果我想要最后一小时或一分钟的订单,那么我现在使用对吗?
    • 是的,没错,或者您可以使用@Date(@Modified) = @Yesterday(只是比较时间戳的日期部分)进行昨天的修改。如果一天中的时间起作用,那么使用 @Modified = @Adjust(@Now;0;0;0;0;-25;0),就像你说的那样。
    • @bboni 在幕后,Lotus Notes 将特定的日期/时间存储为数字,而在后台,@Today = @Integer(@Now),今天中午是 @Today + 0.5。 (不要在公式语言中尝试,它不起作用,但如果您愿意,可以在 LotusScript 中使用它。)@今天是今天早上的午夜。因此,@Adjust(@Today;0;0;0;0;-25;0) 将始终是前一天晚上的晚上 11:35,无论您是什么时间。
    【解决方案2】:

    过去,我使用 LotusScript 方法 GetModifiedDocuments,它允许您指定 NotesDateTime 对象来检索此后修改的任何文档。 您的代码可能如下所示:

    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim dc As notesdocumentcollection
    Dim since As New NotesDateTime("")
    
    Set db = session.CurrentDatabase
    Call since.SetNow()
    Call since.AdjustMinute(-25)
    Set dc = db.GetModifiedDocuments(since)
    

    到目前为止,我对这种方法的体验非常好。更多信息GetModifiedDocuments

    【讨论】:

    • 好点。或者,您可以在 db.Search 中使用 since 变量。这样搜索速度会快很多
    【解决方案3】:

    为什么要使用公式? 我会创建一个隐藏视图,第一列是最后修改的日期时间,降序排序。 然后我会编写我的 Lotusscript 代码,从顶部开始,一直向下工作,直到遇到早于 25 分钟前的日期/时间值。

    类似这样的:

    Dim docs List As NotesDocument
    Set dt25 = New NotesDateEntry(Now())
    Call dt25.AdjustMinutes(-25)
    Dim col as NotesViewEntryCollection
    Dim entry as NotesViewEntry
    Set col = view.AllEntries
    Set entry = col.GetFirstEntry
    Do Until entry Is Nothing
        If Cdat(entry.ColumnValues(0))<Cdat(dt25.LSLocalTime) Then
            Exit Loop
        End If
        Set docs(entry.Document.UniversalID) = entry.Document
    Loop
    ' Now you have a list of documents created in the last 25 minutes.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 2016-01-01
      • 2012-03-16
      相关资源
      最近更新 更多