Lotus Domino无法将子文档从一个文档移动到另一个文档?

时间:2011-10-06 07:29:50

标签: lotus-notes lotus-domino lotusscript

我们的Domino开发人员告诉我们,在文档之间移动子文档是“技术上不可能的”。这是真的吗?

今年早些时候,他为我们写了一个课程注册系统,其中包含以下数据库图表:

database diagram

现在我们问他如何将等候名单的注册人从完整的培训课程转移到那些没有参加的培训课程。他说这是不可能的。他说我们需要重新输入(手动重新创建,复制和粘贴)等候名单记录,因为Domino无法将与会者从一个会话移动到另一个会话。

我们的候补名单中有超过1000名与会者。

他是对的吗?这是真的吗?我们希望有一个解决方案。

4 个答案:

答案 0 :(得分:2)

如何操作取决于文档的链接方式。但无论如何,应该可以使用代码(formula / lotusscript / java)重新链接文档。

Lotus设计器的帮助包含许多有关应用程序开发的信息。另一个资源是IBM developerworks

有许多Lotus相关的blogs

从Lotus Designer帮助中: MakeResponse:使一个文档成为对另一个文档的响应。这两个文件必须位于同一个数据库中。

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim docA As NotesDocument
Dim docB As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView( "All documents" )
Set docA = view.GetFirstDocument
Set docB = view.GetNextDocument( docA )
Call docB.MakeResponse( docA )
docB.Form = "Response"
Call docB.Save( True, True )

答案 1 :(得分:1)

文档可以通过两种方式链接:   - 通过钥匙,柔软的方式   - 分层次地,使用文档 - 响应链接(即父子)

如果只有逻辑链接,使用键,您只需调整关键字段。如果存在“物理”文档响应链接,则可以轻松地中断并重新创建该链接。在LotusScript中,有NotesDocument.MakeResponse方法将任何文档附加到新父级。如果使用这两种方法,当然需要恢复某些链接时是实际的冗余,则需要进行两种更改。通常,一些关键字段从父母到孩子重复

仅出于测试目的,您可以尝试这样做: - 选择要挂在其他位置的响应文档 - Ctrl-X - 选择新的父文档 - Ctrl-V

在测试数据库中执行此操作,因为关键字段不会自动更新。顺便说一下:在粘贴这样的响应文档之后,可以编写代码来修复密钥。

答案 2 :(得分:0)

如果要保留现有文档,可以通过编程方式复制/复制它们。 使用copyAllItems方法很容易。

查看Domino帮助(带示例)here

您可以使用notesView对象(getFirstDocument()/ getNextDocument()方法)迭代文档,在notesdocument.responses方法上迭代响应......

相信我们,有可能,Domino很灵活: - )

答案 3 :(得分:0)

在您描述的数据模型中,这些数据基本上有两种链接方式。如果数据通过响应文档层次结构链接,则它与基于键的文档结构略有不同。

向开发人员展示这一点,他应该能够插入代码以启用您所谈论的“移动与会者”要求。

有几点需要注意。

  • 我假设您需要操作的所有数据都在一个数据库中。
  • 我正在按照字面意思提供你的图表。
  • 对于基于密钥的文档结构,您需要检查用于查找与会者文档的视图和键值。具体检查“MoveAttendeesKeyBased”子中的这两行:

    设置vwAttendeesByCourseID = db.GetView(“(LkupAllAttendeesByCourseID)”)

    设置dcAttendees = vwAttendeesbyCourseID.GetAllDocumentsByKey(docCourseFrom.CourseID(0),True)

  • 该代码旨在查看名为“CourseID”,“状态”的字段以及“等待列出”的值,以显示要移动的与会者的状态值。

  • 编写此功能的两个版本大约需要20分钟。

基于响应的文档结构

Sub MoveAttendeesResponseBased(docCourseFrom As notesDocument, docCourseTo As NotesDocument)
%REM
    A simple move attendees function if the relationship between courses and attendees is based on
    response document hierarchies
%END REM
    On Error Goto errHandle
    Dim dcAttendees As notesDocumentCollection
    Dim docAttendee As notesDocument
    Dim iAvailablePlaces As Integer
    Dim bMoved As Boolean

    If Not (docCourseFrom Is Nothing Or docCourseTo Is Nothing) Then        
        iAvailablePlaces = docCourseTo.availablePlaces(0)
        If 0 < iAvailablePlaces Then
            bMoved = False
            Set dcAttendees = docCourseFrom.Responses
            Set docAttendee = dcAttendees.GetFirstDocument
            While Not docAttendee Is Nothing And 0 < iAvailablePlaces
                If Ucase(Trim(docAttendee.Status(0)))= "WAIT LISTED" Then
                    Call docAttendee.MakeResponse(docCourseTo)
                    If docAttendee.Save(True,True) Then
                        iAvailablePlaces = iAvailablePlaces - 1
                        bMoved = True
                    End If
                End If
                Set docAttendee = dcAttendees.GetNextDocument(docAttendee)
            Wend
            If bMoved Then
                docCourseTo.availablePlaces = iAvailablePlaces
                Call docCourseTo.Save(True,False)
            End If
        End If
    End If  
    Exit Sub
errHandle:
    Messagebox Lsi_info(2) + " - " + Str(Err) + " : " + Error(Err) + ", at line " + Str(Erl)
    Exit Sub
End Sub

基于密钥的文档结构

Sub MoveAttendeesKeyBased(docCourseFrom As notesDocument, docCourseTo As notesDocument)
%REM
    A simple move attendees function if the relationship between courses and attendees uses 
    (non-response) key based documents
%END REM
    On Error Goto errHandle
    Dim session As New notesSession
    Dim dcAttendees As notesDocumentCollection
    Dim docAttendee As notesDocument
    Dim iAvailablePlaces As Integer
    Dim bMoved As Boolean
    ' a view that lists attendees by Course ID
    Dim vwAttendeesByCourseID As notesView
    Dim db As notesDatabase

    If Not (docCourseFrom Is Nothing Or docCourseTo Is Nothing) Then        
        iAvailablePlaces = docCourseTo.availablePlaces(0)
        If 0 < iAvailablePlaces Then
            Set db = session.CurrentDatabase
            ' do a lookup of all attendees based on the CourseFrom document course id
            Set vwAttendeesByCourseID = db.GetView("(LkupAllAttendeesByCourseID)")
            ' this is the collection of all attendees under the CourseFrom document
            Set dcAttendees = vwAttendeesbyCourseID.GetAllDocumentsByKey(docCourseFrom.CourseID(0), True)
            bMoved = False
            Set docAttendee = dcAttendees.GetFirstDocument
            ' While there are attendee documents to process and there are available places to goto
            While Not docAttendee Is Nothing And 0 < iAvailablePlaces
                ' if the attendee's status is "Wait Listed" then move them
                If Ucase(Trim(docAttendee.Status(0)))= "WAIT LISTED" Then
                    ' Update the course ID for the Attendee
                    docAttendee.CourseID = docCourseTo.CourseID(0)
                    If docAttendee.Save(True,True) Then
                        ' decrement the available places
                        iAvailablePlaces = iAvailablePlaces - 1
                        bMoved = True
                    End If
                End If
                Set docAttendee = dcAttendees.GetNextDocument(docAttendee)
            Wend
            If bMoved Then
                ' available places may be >= 0. Just update the available places so you don't over book the course
                docCourseTo.availablePlaces = iAvailablePlaces
                Call docCourseTo.Save(True,False)
            End If
        End If
    End If  
    Exit Sub
errHandle:
    Messagebox Lsi_info(2) + " - " + Str(Err) + " : " + Error(Err) + ", at line " + Str(Erl)
    Exit Sub
End Sub

基于密钥的文档还有一些工作,但我认为这是一个更好的结构,因为您可以轻松地在数据库中移动文档并从备份,复制和粘贴中恢复。对于响应文档,您可能会在恢复备份时遇到问题,因为响应文档使用父文档UNID将其自身关联,并且如果您意外移动与会者,则无法知道在没有原始课程信息的情况下将参加者重新安排到哪个课程,从而引导你回到基于密钥的文档结构。(但这只是我的观点).....