1

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

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

数据库图

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

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

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

4

4 回答 4

2

如何做到这一点取决于文档的链接方式。但无论如何,应该可以使用代码(公式/lotusscript/java)重新链接文档。

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

有许多与 Lotus 相关的博客

来自 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 )
于 2011-10-06T07:38:34.450 回答
1

有两种方法可以链接文档: - 通过键,软方式 - 分层,使用文档响应链接(即父子链接)

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

仅出于测试目的,您可以尝试以下操作: - 选择要挂在其他地方的响应文档 - Ctrl-X - 选择新的父文档 - Ctrl-V

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

于 2011-10-06T09:26:32.093 回答
0

如果您想保留现有文档,您可以以编程方式复制/复制它们。使用 copyAllItems 方法非常简单。

在此处查看 Domino 帮助(带有示例)

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

相信我们,这是可能的,Domino 很灵活 :-)

于 2011-10-06T19:03:46.697 回答
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 来关联自己,而且如果您不小心移动了参与者,如果没有原始课程信息,就不可能知道将参与者放回哪个课程,从而将您带回到基于密钥的文档结构。(但这只是我的观点).....

于 2011-10-07T03:24:40.793 回答