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



我试图通过将项目id作为类别添加到lotusnotes日历条目中来跟踪我用于项目的时间。现在,我想选择一个时间范围内的所有约会(即最近7天(,按类别对其进行分组并总结时间。除了时间范围外,它运行良好。解决方案是GetAllDocumentsByKey方法(https://help.hcltechsw.com/dom_designer/9.0.1/appdev/H_GETALLDOCUMENTSBYKEY_METHOD.html)我试图将一个时间范围、一个字符串(主题或类别(或一个数组(值:主题或类别。

知道吗?

$notesINI = Get-IniContent $env:LOCALAPPDATAIBMNotesDatanotes.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最终需要看起来像这样:

Form=";预约"&开始日期时间>=[04/2022]&开始日期时间<=【2022年12月4日】

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

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

最新更新