在 powershell 中获取某个时间范围内的 Lotus Notes 日历条目

Get Lotus Notes calendar entries for a time range in powershell

我尝试通过将项目 ID 作为类别添加到 Lotus Notes 日历条目来跟踪我用于项目的时间。 现在我想 select 一个时间范围内的所有约会(即过去 7 天),按类别对它们进行分组并总结时间。 除了时间范围外,它工作正常。解决方案接缝是方法 GetAllDocumentsByKey (https://help.hcltechsw.com/dom_designer/9.0.1/appdev/H_GETALLDOCUMENTSBYKEY_METHOD.html) 我尝试将时间范围、字符串(主题或类别)或数组(值:主题或类别)定义为 keyArray,但没有任何接缝可以工作。

有什么想法吗?

$notesINI = Get-IniContent $env:LOCALAPPDATA\IBM\Notes\Data\notes.ini
$InputNotesMailBox = $notesINI.Notes.MailFile
$InputNotesServer = $notesINI.Notes.MailServer
$DomSession = New-Object -ComObject Lotus.NotesSession
$DomSession.Initialize()
$DomDatabase = $DomSession.GetDatabase($InputNotesServer,$InputNotesMailBox)
$DomView = $DomDatabase.GetView('Calendar')

# This works fine but is really slow because it processes all the documents in my calendar (5Min for 6k documents)
$DomDocRange = $DomView
$DomDoc = $DomDocRange.GetFirstDocument()
$date_s = $(get-date -Year 2022 -Month 4 -Day 7)
$date_e = $(get-date -Year 2022 -Month 4 -Day 14)
while($DomDoc -ne $null){
    if($DocCategory -like "proiject-*"){
        $Termin_StartDate = $DomDoc.getItemVAlue('StartDateTime')[0]
        if(IsBetweenDates2 $date_s $date_e $(get-date $Termin_StartDate)){
            # add time and project id to multidimensional array
        }
    }
}

# does not work because I don't know how to filter getAllDocumentsByKey
$date_s = $(get-date -Year 2022 -Month 4 -Day 7)
$date_e = $(get-date -Year 2022 -Month 4 -Day 14)
$DomDateRange = $DomSession.CreateDateRange()
$DomDateRange.StartDateTime = $DomSession.CreateDateTime($date_s)
$DomDateRange.EndDateTime = $DomSession.CreateDateTime($date_e)
$DomDocRange = $DomView.getAllDocumentsByKey($DomDateRange, $true)
$DomDoc = $DomDocRange.GetFirstDocument()
while($DomDoc -ne $null){
    if($DocCategory -like "proiject-*"){
        $Termin_StartDate = $DomDoc.getItemVAlue('StartDateTime')[0]
        if(IsBetweenDates2 $date_s $date_e $(get-date $Termin_StartDate)){
            # add time and project id to multidimensional array
        }
    }
}

GetDocumentByKey 是一个视图的函数,需要按您要搜索的键进行排序。 “日历”- 视图不适合此功能。

您需要摆脱 NotesView 并在不使用视图的情况下从数据库本身获取文档集合。

$DomDocRange = $DomDatabase.search( 'Form = "Appointment" & StartDateTime >= [InjectYourStartDateHere] & StartDateTime <= [InjectYourEndDateHere]', Nothing, 0 )
$DomDoc = $DomDocRange.GetFirstDocument()

构造的@Formula 最终需要如下所示:

表格 = "约会" & StartDateTime >= [04/01/2022] & StartDateTime <= [04/12/2022]

括号很重要,因为它们将给定值标记为日期。日期需要采用您当地的格式(MM/DD/YYYY 或 DD.MM.YYYY 或...)。

不幸的是我还没有使用Powershell的接口,所以我不能告诉你,如何在这里插入LotusScript变量“Nothing”,你可以尝试省略它(使用双逗号)或使用$null。 ..