获取powershell的时间范围的Lotus Notes日历条目

发布于 2025-01-20 16:51:46 字数 2143 浏览 6 评论 0 原文

我尝试通过将项目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
        }
    }
}

I try to track the time I use for projects by adding the project id as a category to a lotus notes calendar entry.
Now I want to select all appointments over a time range (i.e. the last 7 days), group them by category and sum up the time.
Except for the time range thingy it works fine. The solution seams to be the method GetAllDocumentsByKey (https://help.hcltechsw.com/dom_designer/9.0.1/appdev/H_GETALLDOCUMENTSBYKEY_METHOD.html)
I tried to define a time range, a string (subject or category) or an array (values: subject or category) as keyArray but nothing seams to work.

Any idea?

$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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坚持沉默 2025-01-27 16:51:46

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

您需要摆脱 NotesView 并从数据库本身获取文档集合,而不使用视图。

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

构造的@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.

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

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文