获取powershell的时间范围的Lotus Notes日历条目
我尝试通过将项目ID作为类别添加到Lotus Notes日历条目来跟踪项目的时间。 现在,我想在一个时间范围内选择所有约会(即最近7天),按类别分组并总结时间。 除了时间范围外,它可以正常工作。解决方案接缝为GetallDocumentsByKey的方法() 我试图将时间范围,字符串(主题或类别)或数组(值:主题或类别)定义为关键,但没有任何缝隙可以工作。
有什么想法吗?
$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
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GetDocumentByKey 是视图的一个函数,需要按您要搜索的键进行排序。 “日历”视图不适合此功能。
您需要摆脱 NotesView 并从数据库本身获取文档集合,而不使用视图。
构造的@Formula最终需要看起来像这样:
Form = "Appointment" &开始日期时间 >= [04/01/2022] & StartDateTime <= [04/12/2022]
括号很重要,因为它们将给定值标记为日期。日期必须采用您的本地格式(MM/DD/YYYY 或 DD.MM.YYYY 或...)。
不幸的是我还没有使用 Powershell 的接口,所以我不能告诉你,如何在这里插入 LotusScript 变量“Nothing”,你可以尝试省略它(使用双逗号)或使用 $null...
GetDocumentByKey is a function of a view that needs to be sorted by the key you are searching for. The "Calendar"- view is not suitable for this function.
You need to get away from NotesView and get your document collection from the database itself without using the view.
The constructed @Formula needs to look like this in the end:
Form = "Appointment" & StartDateTime >= [04/01/2022] & StartDateTime <= [04/12/2022]
The brackets are important as they mark the given value as a date. The date needs to be in your local format (MM/DD/YYYY or DD.MM.YYYY or...).
Unfortunately I did not use the interface with Powershell yet, so I can't tell you, how the insert the LotusScript variable "Nothing" here, you could try omit it (use double comma) or use $null...