2011-10-06 52 views
1

我们的Domino开发人员告诉我们,在文档之间移动子文档是“技术上不可能的”。这是真的?今年Lotus Domino不能将子文档从一个文档移动到另一个文档?

此前,他为我们提供以下数据库图表写了课程注册系统:

database diagram

现在,我们问他怎么轮候登记从完整的培训课程转移到那些没有会话。他说这是不可能的。他说我们需要重新输入(手动重新创建,复制和粘贴)等待列表记录,因为Domino不能将参与者从一个会话移动到另一个会话。

我们有超过1000名参加者在我们的等候名单中。

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

+0

我有时间思考技术问题,并想出了2种方法可以实现此功能。请看下面的答案 – giulio

回答

2

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

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

有许多莲花相关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) 
+0

谢谢贾斯珀!你有我可以与我们的开发人员分享的URL(教程)吗?或者,也许有一个问题,我可以让他找出这些文档如何链接,然后给出他的答案,我可以与他分享一个教程如何做这个“重新链接”过程。他听起来像是真的不知道如何。我认为“将此参加者移至[此课程其他课程的下拉列表]”控制对于我们所需要的已足够,您是否同意? –

+0

这真的取决于应用程序的结构。如果这是一次“转换”,最好的办法就是成立一个lotusscript代理。互联网上有很多资源。我已通过几条链接更新了我的答案 –

+0

这不会是一次性的,因为注册人每天都会进来,会话每周都会打开。 (我们在圣诞节前开放50个新的“响应需求”会议....)请告诉我们:代码是否只是将子文档分配给一个新的“父文档”,然后保存它?我自己是一名ex-SQL开发人员,所以我喜欢任何示例代码。这听起来很基本。 –

1

有2种方法的文档可以链接: - 通过按键,软办法 - 分层,使用文档响应链接(即父母与子女)

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

只是为了测试目的,你可以试试这个: - 选择要在其他地方挂 的响应文件 - 按Ctrl-X - 选择新的父文件 - Ctrl-V

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

0

如果你想保留现有的文件,你可以编程方式复制/复制它们。 使用copyAllItems方法很容易。

看的Domino帮助(例如)here

你可以重复使用的NotesView对象(getFirstDocument()/ getNextDocument()方法)的文件,重复上notesdocument.responses方法回应...

信任我们,这是可能的,多米诺灵活:-)

0

基本上有2种方式这个数据是在你所描述的数据模型联系起来。如果数据通过响应文档层次结构链接,则与基于关键字的文档结构略有不同。

向您的开发人员显示此信息,他应该能够插入代码以启用您所谈论的“移动参与者”要求。

有几件事要注意。

  • 我假设你需要操纵的所有数据都在一个数据库中。
  • 我把你的图表从字面上提供。
  • 对于基于关键字的文档结构,您需要检查使用的视图和键值o查找与会者文档。具体地检查这些2行中的 “MoveAttendeesKeyBased” 子:

    集vwAttendeesByCourseID = db.GetView( “(LkupAllAttendeesByCourseID)”)

    集dcAttendees = vwAttendeesbyCourseID.GetAllDocumentsByKey(docCourseFrom.CourseID(0),真)

  • 该代码旨在查看名为“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来关联自己,而且如果您偶然移动了与会者,就不可能知道哪个课程没有原始课程信息而让与会者重新回到上面,因此引导您回到基于文档的关键结构(但这只是我的观点).....

相关问题